@runtypelabs/persona 3.33.0 → 3.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -10
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.global.js +191 -190
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/launcher.global.js +117 -117
- package/dist/launcher.global.js.map +1 -1
- package/dist/smart-dom-reader.d.cts +32 -0
- package/dist/smart-dom-reader.d.ts +32 -0
- package/dist/theme-editor.cjs +13 -13
- package/dist/theme-editor.d.cts +32 -0
- package/dist/theme-editor.d.ts +32 -0
- package/dist/theme-editor.js +14 -14
- package/package.json +3 -3
- package/src/codegen.test.ts +0 -14
- package/src/runtime/host-layout.test.ts +51 -9
- package/src/runtime/host-layout.ts +29 -10
- package/src/runtime/init.test.ts +2 -2
- package/src/types.ts +29 -0
- package/src/ui.docked.test.ts +2 -2
- package/src/voice/voice.test.ts +0 -51
- package/src/install-config.test.ts +0 -38
package/dist/index.global.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
"use strict";var AgentWidget=(()=>{var
|
|
2
|
-
\r `.includes(r[
|
|
3
|
-
`).map(
|
|
4
|
-
`)}var
|
|
5
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let
|
|
6
|
-
$1`);
|
|
7
|
-
`);let
|
|
8
|
-
`,1)[0].replace(/^\t+/,
|
|
9
|
-
`,1)[0],
|
|
10
|
-
`,e=e.substring(p.length+1),u=!0),!u){let
|
|
11
|
-
`,1)[0];if(p=
|
|
12
|
-
`+p.slice(
|
|
13
|
-
`+p}!
|
|
14
|
-
`,e=e.substring(
|
|
15
|
-
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(
|
|
16
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:
|
|
17
|
-
]`).replace("lheading",
|
|
18
|
-
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let
|
|
19
|
-
`:t.push(
|
|
20
|
-
`+
|
|
21
|
-
`+
|
|
22
|
-
`+
|
|
23
|
-
`+
|
|
24
|
-
`+
|
|
25
|
-
`+
|
|
26
|
-
`+
|
|
27
|
-
`+
|
|
28
|
-
`,
|
|
29
|
-
`:"<pre><code>"+(
|
|
1
|
+
"use strict";var AgentWidget=(()=>{var ib=Object.create;var Rs=Object.defineProperty;var lb=Object.getOwnPropertyDescriptor;var db=Object.getOwnPropertyNames;var cb=Object.getPrototypeOf,pb=Object.prototype.hasOwnProperty;var zg=r=>{throw TypeError(r)};var ub=(r,e,t)=>e in r?Rs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var fb=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var $g=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),mb=(r,e)=>{for(var t in e)Rs(r,t,{get:e[t],enumerable:!0})},Vg=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of db(e))!pb.call(r,n)&&n!==t&&Rs(r,n,{get:()=>e[n],enumerable:!(o=lb(e,n))||o.enumerable});return r};var Bi=(r,e,t)=>(t=r!=null?ib(cb(r)):{},Vg(e||!r||!r.__esModule?Rs(t,"default",{value:r,enumerable:!0}):t,r)),gb=r=>Vg(Rs({},"__esModule",{value:!0}),r);var lr=(r,e,t)=>ub(r,typeof e!="symbol"?e+"":e,t),hb=(r,e,t)=>e.has(r)||zg("Cannot "+t);var jg=(r,e,t)=>e.has(r)?zg("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t);var Di=(r,e,t)=>(hb(r,e,"access private method"),t);var Wd=$g($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});$e.Allow=$e.ALL=$e.COLLECTION=$e.ATOM=$e.SPECIAL=$e.INF=$e._INFINITY=$e.INFINITY=$e.NAN=$e.BOOL=$e.NULL=$e.OBJ=$e.ARR=$e.NUM=$e.STR=void 0;$e.STR=1;$e.NUM=2;$e.ARR=4;$e.OBJ=8;$e.NULL=16;$e.BOOL=32;$e.NAN=64;$e.INFINITY=128;$e._INFINITY=256;$e.INF=$e.INFINITY|$e._INFINITY;$e.SPECIAL=$e.NULL|$e.BOOL|$e.INF|$e.NAN;$e.ATOM=$e.STR|$e.NUM|$e.SPECIAL;$e.COLLECTION=$e.ARR|$e.OBJ;$e.ALL=$e.ATOM|$e.COLLECTION;$e.Allow={STR:$e.STR,NUM:$e.NUM,ARR:$e.ARR,OBJ:$e.OBJ,NULL:$e.NULL,BOOL:$e.BOOL,NAN:$e.NAN,INFINITY:$e.INFINITY,_INFINITY:$e._INFINITY,INF:$e.INF,SPECIAL:$e.SPECIAL,ATOM:$e.ATOM,COLLECTION:$e.COLLECTION,ALL:$e.ALL};$e.default=$e.Allow});var ji=$g(Qr=>{"use strict";var q0=Qr&&Qr.__createBinding||(Object.create?(function(r,e,t,o){o===void 0&&(o=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,o,n)}):(function(r,e,t,o){o===void 0&&(o=t),r[o]=e[t]})),z0=Qr&&Qr.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&q0(e,r,t)};Object.defineProperty(Qr,"__esModule",{value:!0});Qr.Allow=Qr.MalformedJSON=Qr.PartialJSON=Qr.parseJSON=Qr.parse=void 0;var wo=Wd();Object.defineProperty(Qr,"Allow",{enumerable:!0,get:function(){return wo.Allow}});z0(Wd(),Qr);var $i=class extends Error{};Qr.PartialJSON=$i;var Vi=class extends Error{};Qr.MalformedJSON=Vi;function Dh(r,e=wo.Allow.ALL){if(typeof r!="string")throw new TypeError(`expecting str, got ${typeof r}`);if(!r.trim())throw new Error(`${r} is empty`);return $0(r.trim(),e)}Qr.parseJSON=Dh;var $0=(r,e)=>{let t=r.length,o=0,n=p=>{throw new $i(`${p} at position ${o}`)},a=p=>{throw new Vi(`${p} at position ${o}`)},s=()=>(f(),o>=t&&n("Unexpected end of input"),r[o]==='"'?i():r[o]==="{"?d():r[o]==="["?l():r.substring(o,o+4)==="null"||wo.Allow.NULL&e&&t-o<4&&"null".startsWith(r.substring(o))?(o+=4,null):r.substring(o,o+4)==="true"||wo.Allow.BOOL&e&&t-o<4&&"true".startsWith(r.substring(o))?(o+=4,!0):r.substring(o,o+5)==="false"||wo.Allow.BOOL&e&&t-o<5&&"false".startsWith(r.substring(o))?(o+=5,!1):r.substring(o,o+8)==="Infinity"||wo.Allow.INFINITY&e&&t-o<8&&"Infinity".startsWith(r.substring(o))?(o+=8,1/0):r.substring(o,o+9)==="-Infinity"||wo.Allow._INFINITY&e&&1<t-o&&t-o<9&&"-Infinity".startsWith(r.substring(o))?(o+=9,-1/0):r.substring(o,o+3)==="NaN"||wo.Allow.NAN&e&&t-o<3&&"NaN".startsWith(r.substring(o))?(o+=3,NaN):u()),i=()=>{let p=o,m=!1;for(o++;o<t&&(r[o]!=='"'||m&&r[o-1]==="\\");)m=r[o]==="\\"?!m:!1,o++;if(r.charAt(o)=='"')try{return JSON.parse(r.substring(p,++o-Number(m)))}catch(y){a(String(y))}else if(wo.Allow.STR&e)try{return JSON.parse(r.substring(p,o-Number(m))+'"')}catch{return JSON.parse(r.substring(p,r.lastIndexOf("\\"))+'"')}n("Unterminated string literal")},d=()=>{o++,f();let p={};try{for(;r[o]!=="}";){if(f(),o>=t&&wo.Allow.OBJ&e)return p;let m=i();f(),o++;try{let y=s();p[m]=y}catch(y){if(wo.Allow.OBJ&e)return p;throw y}f(),r[o]===","&&o++}}catch{if(wo.Allow.OBJ&e)return p;n("Expected '}' at end of object")}return o++,p},l=()=>{o++;let p=[];try{for(;r[o]!=="]";)p.push(s()),f(),r[o]===","&&o++}catch{if(wo.Allow.ARR&e)return p;n("Expected ']' at end of array")}return o++,p},u=()=>{if(o===0){r==="-"&&a("Not sure what '-' is");try{return JSON.parse(r)}catch(m){if(wo.Allow.NUM&e)try{return JSON.parse(r.substring(0,r.lastIndexOf("e")))}catch{}a(String(m))}}let p=o;for(r[o]==="-"&&o++;r[o]&&",]}".indexOf(r[o])===-1;)o++;o==t&&!(wo.Allow.NUM&e)&&n("Unterminated number literal");try{return JSON.parse(r.substring(p,o))}catch{r.substring(p,o)==="-"&&n("Not sure what '-' is");try{return JSON.parse(r.substring(p,r.lastIndexOf("e")))}catch(y){a(String(y))}}},f=()=>{for(;o<t&&`
|
|
2
|
+
\r `.includes(r[o]);)o++};return s()},V0=Dh;Qr.parse=V0});var Kw={};mb(Kw,{ASK_USER_QUESTION_CLIENT_TOOL:()=>$d,ASK_USER_QUESTION_PARAMETERS_SCHEMA:()=>zd,ASK_USER_QUESTION_TOOL_NAME:()=>$s,AgentWidgetClient:()=>ya,AgentWidgetSession:()=>Za,AttachmentManager:()=>wa,DEFAULT_COMPONENTS:()=>$p,DEFAULT_FLOATING_LAUNCHER_MAX_WIDTH:()=>Sl,DEFAULT_FLOATING_LAUNCHER_WIDTH:()=>Wo,DEFAULT_PALETTE:()=>qp,DEFAULT_SEMANTIC:()=>zp,DEFAULT_WIDGET_CONFIG:()=>Xt,PRESETS:()=>Lu,PRESET_FULLSCREEN:()=>Eu,PRESET_MINIMAL:()=>ku,PRESET_SHOP:()=>Mu,SUGGEST_REPLIES_CLIENT_TOOL:()=>Qi,SUGGEST_REPLIES_PARAMETERS_SCHEMA:()=>Fd,SUGGEST_REPLIES_TOOL_NAME:()=>en,THEME_ZONES:()=>bx,VERSION:()=>By,WEBMCP_TOOL_PREFIX:()=>Cn,WebMcpBridge:()=>Ga,accessibilityPlugin:()=>Dy,animationsPlugin:()=>Oy,applyThemeVariables:()=>Vn,attachHeaderToContainer:()=>Ta,brandPlugin:()=>_y,buildComposer:()=>ns,buildDefaultHeader:()=>eu,buildHeader:()=>kn,buildHeaderWithLayout:()=>os,buildMinimalHeader:()=>tu,builtInClientToolsForDispatch:()=>Gs,collectEnrichedPageContext:()=>Iy,componentRegistry:()=>En,createActionManager:()=>hi,createAgentExperience:()=>sd,createAskUserQuestionBubble:()=>Xh,createBestAvailableVoiceProvider:()=>ul,createBubbleWithLayout:()=>Ux,createCSATFeedback:()=>od,createComboButton:()=>Nl,createComponentMiddleware:()=>py,createComponentStreamParser:()=>Zl,createDefaultSanitizer:()=>Pd,createDirectivePostprocessor:()=>uh,createDropdownMenu:()=>Xn,createFlexibleJsonStreamParser:()=>Zh,createIconButton:()=>Br,createImagePart:()=>sx,createJsonStreamParser:()=>nl,createLabelButton:()=>ci,createLocalStorageAdapter:()=>Jl,createMarkdownProcessor:()=>_s,createMarkdownProcessorFromConfig:()=>ua,createMessageActions:()=>su,createNPSFeedback:()=>nd,createPlainTextParser:()=>rl,createPlugin:()=>Uy,createRegexJsonParser:()=>ol,createStandardBubble:()=>as,createTextPart:()=>Qs,createTheme:()=>ts,createThemeObserver:()=>El,createToggleGroup:()=>Wx,createTypingIndicator:()=>Ma,createVoiceProvider:()=>Ca,createWidgetHostLayout:()=>xi,createXmlParser:()=>al,defaultActionHandlers:()=>Ea,defaultJsonActionParser:()=>gi,defaultParseRules:()=>Su,detectColorScheme:()=>ti,directivePostprocessor:()=>fh,ensureAskUserQuestionSheet:()=>Qa,escapeHtml:()=>fa,extractComponentDirectiveFromMessage:()=>rd,fileToImagePart:()=>ix,formatEnrichedContext:()=>Hy,generateAssistantMessageId:()=>ba,generateMessageId:()=>tx,generateStableSelector:()=>Tu,generateUserMessageId:()=>Ja,getActiveTheme:()=>rs,getColorScheme:()=>jp,getDisplayText:()=>ox,getHeaderLayout:()=>ru,getImageParts:()=>ax,getPreset:()=>zy,hasComponentDirective:()=>td,hasImages:()=>nx,headerLayouts:()=>Fl,highContrastPlugin:()=>Fy,initAgentWidget:()=>Cy,isAskUserQuestionMessage:()=>wn,isComponentDirectiveType:()=>cy,isDockedMountMode:()=>Lr,isSuggestRepliesMessage:()=>js,isVoiceSupported:()=>Js,isWebMcpToolName:()=>ga,latestAgentSuggestions:()=>Yi,listRegisteredStreamAnimations:()=>Qp,markdownPostprocessor:()=>wd,mergeWithDefaults:()=>Tl,normalizeContent:()=>rx,parseAskUserQuestionPayload:()=>An,parseSuggestRepliesPayload:()=>qd,pluginRegistry:()=>mi,reducedMotionPlugin:()=>Ny,registerStreamAnimationPlugin:()=>Sa,removeAskUserQuestionSheet:()=>zn,renderComponentDirective:()=>ed,renderLoadingIndicatorWithFallback:()=>au,renderLucideIcon:()=>Ee,resolveDockConfig:()=>Bo,resolveSanitizer:()=>ja,resolveTokens:()=>Ml,stripWebMcpPrefix:()=>zi,themeToCssVariables:()=>kl,unregisterStreamAnimationPlugin:()=>Xp,validateImageFile:()=>lx,validateTheme:()=>Vp});function hd(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pa=hd();function Jg(r){pa=r}var Zg=/[&<>"']/,xb=new RegExp(Zg.source,"g"),eh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,yb=new RegExp(eh.source,"g"),bb={"&":"&","<":"<",">":">",'"':""","'":"'"},Gg=r=>bb[r];function Ho(r,e){if(e){if(Zg.test(r))return r.replace(xb,Gg)}else if(eh.test(r))return r.replace(yb,Gg);return r}var vb=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Cb(r){return r.replace(vb,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}var wb=/(^|[^\[])\^/g;function rr(r,e){let t=typeof r=="string"?r:r.source;e=e||"";let o={replace:(n,a)=>{let s=typeof a=="string"?a:a.source;return s=s.replace(wb,"$1"),t=t.replace(n,s),o},getRegex:()=>new RegExp(t,e)};return o}function Kg(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}var Hs={exec:()=>null};function Xg(r,e){let t=r.replace(/\|/g,(a,s,i)=>{let d=!1,l=s;for(;--l>=0&&i[l]==="\\";)d=!d;return d?"|":" |"}),o=t.split(/ \|/),n=0;if(o[0].trim()||o.shift(),o.length>0&&!o[o.length-1].trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;n<o.length;n++)o[n]=o[n].trim().replace(/\\\|/g,"|");return o}function Oi(r,e,t){let o=r.length;if(o===0)return"";let n=0;for(;n<o;){let a=r.charAt(o-n-1);if(a===e&&!t)n++;else if(a!==e&&t)n++;else break}return r.slice(0,o-n)}function Ab(r,e){if(r.indexOf(e[1])===-1)return-1;let t=0;for(let o=0;o<r.length;o++)if(r[o]==="\\")o++;else if(r[o]===e[0])t++;else if(r[o]===e[1]&&(t--,t<0))return o;return-1}function Qg(r,e,t,o){let n=e.href,a=e.title?Ho(e.title):null,s=r[1].replace(/\\([\[\]])/g,"$1");if(r[0].charAt(0)!=="!"){o.state.inLink=!0;let i={type:"link",raw:t,href:n,title:a,text:s,tokens:o.inlineTokens(s)};return o.state.inLink=!1,i}return{type:"image",raw:t,href:n,title:a,text:Ho(s)}}function Sb(r,e){let t=r.match(/^(\s+)(?:```)/);if(t===null)return e;let o=t[1];return e.split(`
|
|
3
|
+
`).map(n=>{let a=n.match(/^\s+/);if(a===null)return n;let[s]=a;return s.length>=o.length?n.slice(o.length):n}).join(`
|
|
4
|
+
`)}var qa=class{constructor(e){lr(this,"options");lr(this,"rules");lr(this,"lexer");this.options=e||pa}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let o=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?o:Oi(o,`
|
|
5
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let o=t[0],n=Sb(o,t[3]||"");return{type:"code",raw:o,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let o=t[2].trim();if(/#$/.test(o)){let n=Oi(o,"#");(this.options.pedantic||!n||/ $/.test(n))&&(o=n.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:o,tokens:this.lexer.inline(o)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let o=t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
|
|
6
|
+
$1`);o=Oi(o.replace(/^ *>[ \t]?/gm,""),`
|
|
7
|
+
`);let n=this.lexer.state.top;this.lexer.state.top=!0;let a=this.lexer.blockTokens(o);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:a,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let o=t[1].trim(),n=o.length>1,a={type:"list",raw:"",ordered:n,start:n?+o.slice(0,-1):"",loose:!1,items:[]};o=n?`\\d{1,9}\\${o.slice(-1)}`:`\\${o}`,this.options.pedantic&&(o=n?o:"[*+-]");let s=new RegExp(`^( {0,3}${o})((?:[ ][^\\n]*)?(?:\\n|$))`),i="",d="",l=!1;for(;e;){let u=!1;if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let f=t[2].split(`
|
|
8
|
+
`,1)[0].replace(/^\t+/,M=>" ".repeat(3*M.length)),p=e.split(`
|
|
9
|
+
`,1)[0],m=0;this.options.pedantic?(m=2,d=f.trimStart()):(m=t[2].search(/[^ ]/),m=m>4?1:m,d=f.slice(m),m+=t[1].length);let y=!1;if(!f&&/^ *$/.test(p)&&(i+=p+`
|
|
10
|
+
`,e=e.substring(p.length+1),u=!0),!u){let M=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),k=new RegExp(`^ {0,${Math.min(3,m-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),L=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:\`\`\`|~~~)`),x=new RegExp(`^ {0,${Math.min(3,m-1)}}#`);for(;e;){let w=e.split(`
|
|
11
|
+
`,1)[0];if(p=w,this.options.pedantic&&(p=p.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),L.test(p)||x.test(p)||M.test(p)||k.test(e))break;if(p.search(/[^ ]/)>=m||!p.trim())d+=`
|
|
12
|
+
`+p.slice(m);else{if(y||f.search(/[^ ]/)>=4||L.test(f)||x.test(f)||k.test(f))break;d+=`
|
|
13
|
+
`+p}!y&&!p.trim()&&(y=!0),i+=w+`
|
|
14
|
+
`,e=e.substring(w.length+1),f=p.slice(m)}}a.loose||(l?a.loose=!0:/\n *\n *$/.test(i)&&(l=!0));let h=null,T;this.options.gfm&&(h=/^\[[ xX]\] /.exec(d),h&&(T=h[0]!=="[ ] ",d=d.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:i,task:!!h,checked:T,loose:!1,text:d,tokens:[]}),a.raw+=i}a.items[a.items.length-1].raw=i.trimEnd(),a.items[a.items.length-1].text=d.trimEnd(),a.raw=a.raw.trimEnd();for(let u=0;u<a.items.length;u++)if(this.lexer.state.top=!1,a.items[u].tokens=this.lexer.blockTokens(a.items[u].text,[]),!a.loose){let f=a.items[u].tokens.filter(m=>m.type==="space"),p=f.length>0&&f.some(m=>/\n.*\n/.test(m.raw));a.loose=p}if(a.loose)for(let u=0;u<a.items.length;u++)a.items[u].loose=!0;return a}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let o=t[1].toLowerCase().replace(/\s+/g," "),n=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:o,raw:t[0],href:n,title:a}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!/[:|]/.test(t[2]))return;let o=Xg(t[1]),n=t[2].replace(/^\||\| *$/g,"").split("|"),a=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(`
|
|
15
|
+
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(o.length===n.length){for(let i of n)/^ *-+: *$/.test(i)?s.align.push("right"):/^ *:-+: *$/.test(i)?s.align.push("center"):/^ *:-+ *$/.test(i)?s.align.push("left"):s.align.push(null);for(let i of o)s.header.push({text:i,tokens:this.lexer.inline(i)});for(let i of a)s.rows.push(Xg(i,s.header.length).map(d=>({text:d,tokens:this.lexer.inline(d)})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let o=t[1].charAt(t[1].length-1)===`
|
|
16
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:o,tokens:this.lexer.inline(o)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:Ho(t[1])}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let o=t[2].trim();if(!this.options.pedantic&&/^</.test(o)){if(!/>$/.test(o))return;let s=Oi(o.slice(0,-1),"\\");if((o.length-s.length)%2===0)return}else{let s=Ab(t[2],"()");if(s>-1){let d=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,d).trim(),t[3]=""}}let n=t[2],a="";if(this.options.pedantic){let s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);s&&(n=s[1],a=s[3])}else a=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^</.test(n)&&(this.options.pedantic&&!/>$/.test(o)?n=n.slice(1):n=n.slice(1,-1)),Qg(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer)}}reflink(e,t){let o;if((o=this.rules.inline.reflink.exec(e))||(o=this.rules.inline.nolink.exec(e))){let n=(o[2]||o[1]).replace(/\s+/g," "),a=t[n.toLowerCase()];if(!a){let s=o[0].charAt(0);return{type:"text",raw:s,text:s}}return Qg(o,a,o[0],this.lexer)}}emStrong(e,t,o=""){let n=this.rules.inline.emStrongLDelim.exec(e);if(!n||n[3]&&o.match(/[\p{L}\p{N}]/u))return;if(!(n[1]||n[2]||"")||!o||this.rules.inline.punctuation.exec(o)){let s=[...n[0]].length-1,i,d,l=s,u=0,f=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(f.lastIndex=0,t=t.slice(-1*e.length+s);(n=f.exec(t))!=null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i)continue;if(d=[...i].length,n[3]||n[4]){l+=d;continue}else if((n[5]||n[6])&&s%3&&!((s+d)%3)){u+=d;continue}if(l-=d,l>0)continue;d=Math.min(d,d+l+u);let p=[...n[0]][0].length,m=e.slice(0,s+n.index+p+d);if(Math.min(s,d)%2){let h=m.slice(1,-1);return{type:"em",raw:m,text:h,tokens:this.lexer.inlineTokens(h)}}let y=m.slice(2,-2);return{type:"strong",raw:m,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let o=t[2].replace(/\n/g," "),n=/[^ ]/.test(o),a=/^ /.test(o)&&/ $/.test(o);return n&&a&&(o=o.substring(1,o.length-1)),o=Ho(o,!0),{type:"codespan",raw:t[0],text:o}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let o,n;return t[2]==="@"?(o=Ho(t[1]),n="mailto:"+o):(o=Ho(t[1]),n=o),{type:"link",raw:t[0],text:o,href:n,tokens:[{type:"text",raw:o,text:o}]}}}url(e){var o,n;let t;if(t=this.rules.inline.url.exec(e)){let a,s;if(t[2]==="@")a=Ho(t[0]),s="mailto:"+a;else{let i;do i=t[0],t[0]=(n=(o=this.rules.inline._backpedal.exec(t[0]))==null?void 0:o[0])!=null?n:"";while(i!==t[0]);a=Ho(t[0]),t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:a,href:s,tokens:[{type:"text",raw:a,text:a}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let o;return this.lexer.state.inRawBlock?o=t[0]:o=Ho(t[0]),{type:"text",raw:t[0],text:o}}}},Tb=/^(?: *(?:\n|$))+/,Mb=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,kb=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ds=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Eb=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,th=/(?:[*+-]|\d{1,9}[.)])/,rh=rr(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,th).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),xd=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Lb=/^[^\n]+/,yd=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Pb=rr(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",yd).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Rb=rr(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,th).getRegex(),Fi="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",bd=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ib=rr("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",bd).replace("tag",Fi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),oh=rr(xd).replace("hr",Ds).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fi).getRegex(),Hb=rr(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",oh).getRegex(),vd={blockquote:Hb,code:Mb,def:Pb,fences:kb,heading:Eb,hr:Ds,html:Ib,lheading:rh,list:Rb,newline:Tb,paragraph:oh,table:Hs,text:Lb},Yg=rr("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ds).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fi).getRegex(),Wb={...vd,table:Yg,paragraph:rr(xd).replace("hr",Ds).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Yg).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fi).getRegex()},Bb={...vd,html:rr(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",bd).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Hs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rr(xd).replace("hr",Ds).replace("heading",` *#{1,6} *[^
|
|
17
|
+
]`).replace("lheading",rh).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},nh=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Db=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ah=/^( {2,}|\\)\n(?!\s*$)/,Ob=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Os="\\p{P}\\p{S}",_b=rr(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,Os).getRegex(),Nb=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,Fb=rr(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,Os).getRegex(),Ub=rr("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,Os).getRegex(),qb=rr("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,Os).getRegex(),zb=rr(/\\([punct])/,"gu").replace(/punct/g,Os).getRegex(),$b=rr(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Vb=rr(bd).replace("(?:-->|$)","-->").getRegex(),jb=rr("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Vb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ni=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Gb=rr(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Ni).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),sh=rr(/^!?\[(label)\]\[(ref)\]/).replace("label",Ni).replace("ref",yd).getRegex(),ih=rr(/^!?\[(ref)\](?:\[\])?/).replace("ref",yd).getRegex(),Kb=rr("reflink|nolink(?!\\()","g").replace("reflink",sh).replace("nolink",ih).getRegex(),Cd={_backpedal:Hs,anyPunctuation:zb,autolink:$b,blockSkip:Nb,br:ah,code:Db,del:Hs,emStrongLDelim:Fb,emStrongRDelimAst:Ub,emStrongRDelimUnd:qb,escape:nh,link:Gb,nolink:ih,punctuation:_b,reflink:sh,reflinkSearch:Kb,tag:jb,text:Ob,url:Hs},Xb={...Cd,link:rr(/^!?\[(label)\]\((.*?)\)/).replace("label",Ni).getRegex(),reflink:rr(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ni).getRegex()},md={...Cd,escape:rr(nh).replace("])","~|])").getRegex(),url:rr(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Qb={...md,br:rr(ah).replace("{2,}","*").getRegex(),text:rr(md.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},_i={normal:vd,gfm:Wb,pedantic:Bb},Is={normal:Cd,gfm:md,breaks:Qb,pedantic:Xb},bn=class r{constructor(e){lr(this,"tokens");lr(this,"options");lr(this,"state");lr(this,"tokenizer");lr(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||pa,this.options.tokenizer=this.options.tokenizer||new qa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={block:_i.normal,inline:Is.normal};this.options.pedantic?(t.block=_i.pedantic,t.inline=Is.pedantic):this.options.gfm&&(t.block=_i.gfm,this.options.breaks?t.inline=Is.breaks:t.inline=Is.gfm),this.tokenizer.rules=t}static get rules(){return{block:_i,inline:Is}}static lex(e,t){return new r(t).lex(e)}static lexInline(e,t){return new r(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
|
|
18
|
+
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let o=this.inlineQueue[t];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(i,d,l)=>d+" ".repeat(l.length));let o,n,a,s;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(i=>(o=i.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))){if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length),o.raw.length===1&&t.length>0?t[t.length-1].raw+=`
|
|
19
|
+
`:t.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length),n=t[t.length-1],n&&(n.type==="paragraph"||n.type==="text")?(n.raw+=`
|
|
20
|
+
`+o.raw,n.text+=`
|
|
21
|
+
`+o.text,this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(o);continue}if(o=this.tokenizer.fences(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.heading(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.hr(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.blockquote(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.list(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.html(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.def(e)){e=e.substring(o.raw.length),n=t[t.length-1],n&&(n.type==="paragraph"||n.type==="text")?(n.raw+=`
|
|
22
|
+
`+o.raw,n.text+=`
|
|
23
|
+
`+o.raw,this.inlineQueue[this.inlineQueue.length-1].src=n.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title});continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),t.push(o);continue}if(a=e,this.options.extensions&&this.options.extensions.startBlock){let i=1/0,d=e.slice(1),l;this.options.extensions.startBlock.forEach(u=>{l=u.call({lexer:this},d),typeof l=="number"&&l>=0&&(i=Math.min(i,l))}),i<1/0&&i>=0&&(a=e.substring(0,i+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){n=t[t.length-1],s&&n.type==="paragraph"?(n.raw+=`
|
|
24
|
+
`+o.raw,n.text+=`
|
|
25
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(o),s=a.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length),n=t[t.length-1],n&&n.type==="text"?(n.raw+=`
|
|
26
|
+
`+o.raw,n.text+=`
|
|
27
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(o);continue}if(e){let i="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let o,n,a,s=e,i,d,l;if(this.tokens.links){let u=Object.keys(this.tokens.links);if(u.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)u.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,i.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(d||(l=""),d=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(u=>(o=u.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))){if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),n=t[t.length-1],n&&o.type==="text"&&n.type==="text"?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length),n=t[t.length-1],n&&o.type==="text"&&n.type==="text"?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,s,l)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}if(a=e,this.options.extensions&&this.options.extensions.startInline){let u=1/0,f=e.slice(1),p;this.options.extensions.startInline.forEach(m=>{p=m.call({lexer:this},f),typeof p=="number"&&p>=0&&(u=Math.min(u,p))}),u<1/0&&u>=0&&(a=e.substring(0,u+1))}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(l=o.raw.slice(-1)),d=!0,n=t[t.length-1],n&&n.type==="text"?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return t}},za=class{constructor(e){lr(this,"options");this.options=e||pa}code(e,t,o){var a;let n=(a=(t||"").match(/^\S*/))==null?void 0:a[0];return e=e.replace(/\n$/,"")+`
|
|
28
|
+
`,n?'<pre><code class="language-'+Ho(n)+'">'+(o?e:Ho(e,!0))+`</code></pre>
|
|
29
|
+
`:"<pre><code>"+(o?e:Ho(e,!0))+`</code></pre>
|
|
30
30
|
`}blockquote(e){return`<blockquote>
|
|
31
31
|
${e}</blockquote>
|
|
32
|
-
`}html(e,t){return e}heading(e,t,
|
|
32
|
+
`}html(e,t){return e}heading(e,t,o){return`<h${t}>${e}</h${t}>
|
|
33
33
|
`}hr(){return`<hr>
|
|
34
|
-
`}list(e,t,
|
|
35
|
-
`+e+"</"+
|
|
36
|
-
`}listitem(e,t,
|
|
34
|
+
`}list(e,t,o){let n=t?"ol":"ul",a=t&&o!==1?' start="'+o+'"':"";return"<"+n+a+`>
|
|
35
|
+
`+e+"</"+n+`>
|
|
36
|
+
`}listitem(e,t,o){return`<li>${e}</li>
|
|
37
37
|
`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p>
|
|
38
38
|
`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),`<table>
|
|
39
39
|
<thead>
|
|
@@ -41,25 +41,26 @@ ${e}</blockquote>
|
|
|
41
41
|
`+t+`</table>
|
|
42
42
|
`}tablerow(e){return`<tr>
|
|
43
43
|
${e}</tr>
|
|
44
|
-
`}tablecell(e,t){let
|
|
45
|
-
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,
|
|
46
|
-
`+(s.tokens?this.parseInline(s.tokens):s.text);
|
|
47
|
-
Please report this to https://github.com/markedjs/marked.`,e){let o="<p>An error occurred:</p><pre>"+Cn(n.message+"",!0)+"</pre>";return t?Promise.resolve(o):o}if(t)return Promise.reject(n);throw n}};var oa=new Es;function rr(r,e){return oa.parse(r,e)}rr.options=rr.setOptions=function(r){return oa.setOptions(r),rr.defaults=oa.defaults,Qg(rr.defaults),rr};rr.getDefaults=fd;rr.defaults=sa;rr.use=function(...r){return oa.use(...r),rr.defaults=oa.defaults,Qg(rr.defaults),rr};rr.walkTokens=function(r,e){return oa.walkTokens(r,e)};rr.parseInline=oa.parseInline;rr.Parser=mo;rr.parser=mo.parse;rr.Renderer=Oa;rr.TextRenderer=ks;rr.Lexer=fo;rr.lexer=fo.lex;rr.Tokenizer=Fa;rr.Hooks=na;rr.parse=rr;var Hw=rr.options,Ww=rr.setOptions,Bw=rr.use,Dw=rr.walkTokens,Fw=rr.parseInline;var Ow=mo.parse,Nw=fo.lex;var $y=r=>{if(r)return r},Rs=r=>{var o,a;let e=r==null?void 0:r.markedOptions,t=new Es({gfm:(o=e==null?void 0:e.gfm)!=null?o:!0,breaks:(a=e==null?void 0:e.breaks)!=null?a:!0,pedantic:e==null?void 0:e.pedantic,silent:e==null?void 0:e.silent}),n=$y(r==null?void 0:r.renderer);return n&&t.use({renderer:n}),s=>t.parse(s)},ia=r=>r?Rs({markedOptions:r.options,renderer:r.renderer}):Rs(),Vy=Rs(),yd=r=>Vy(r),la=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),lh=r=>r.replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),ih=r=>`%%FORM_PLACEHOLDER_${r}%%`,dh=(r,e)=>{let t=r;return t=t.replace(/<Directive>([\s\S]*?)<\/Directive>/gi,(n,o)=>{try{let a=JSON.parse(o.trim());if(a&&typeof a=="object"&&a.component==="form"&&a.type){let s=ih(e.length);return e.push({token:s,type:String(a.type)}),s}}catch{return n}return n}),t=t.replace(/<Form\s+type="([^"]+)"\s*\/>/gi,(n,o)=>{let a=ih(e.length);return e.push({token:a,type:o}),a}),t},ch=r=>{let e=ia(r);return t=>{let n=[],o=dh(t,n),a=e(o);return n.forEach(({token:s,type:i})=>{let d=new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),u=`<div class="persona-form-directive" data-tv-form="${lh(i)}"></div>`;a=a.replace(d,u)}),a}},ph=r=>{let e=[],t=dh(r,e),n=yd(t);return e.forEach(({token:o,type:a})=>{let s=new RegExp(o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),d=`<div class="persona-form-directive" data-tv-form="${lh(a)}"></div>`;n=n.replace(s,d)}),n};var{entries:vh,setPrototypeOf:uh,isFrozen:jy,getPrototypeOf:Gy,getOwnPropertyDescriptor:Ky}=Object,{freeze:rn,seal:Hn,create:Fi}=Object,{apply:Md,construct:kd}=typeof Reflect!="undefined"&&Reflect;rn||(rn=function(e){return e});Hn||(Hn=function(e){return e});Md||(Md=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),a=2;a<n;a++)o[a-2]=arguments[a];return e.apply(t,o)});kd||(kd=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});var Bi=nn(Array.prototype.forEach),Xy=nn(Array.prototype.lastIndexOf),fh=nn(Array.prototype.pop),Is=nn(Array.prototype.push),Qy=nn(Array.prototype.splice),Oi=nn(String.prototype.toLowerCase),vd=nn(String.prototype.toString),Cd=nn(String.prototype.match),Hs=nn(String.prototype.replace),Jy=nn(String.prototype.indexOf),Yy=nn(String.prototype.trim),wn=nn(Object.prototype.hasOwnProperty),tn=nn(RegExp.prototype.test),Ws=Zy(TypeError);function nn(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return Md(r,e,n)}}function Zy(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return kd(r,t)}}function Ht(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Oi;uh&&uh(r,null);let n=e.length;for(;n--;){let o=e[n];if(typeof o=="string"){let a=t(o);a!==o&&(jy(e)||(e[n]=a),o=a)}r[o]=!0}return r}function e0(r){for(let e=0;e<r.length;e++)wn(r,e)||(r[e]=null);return r}function to(r){let e=Fi(null);for(let[t,n]of vh(r))wn(r,t)&&(Array.isArray(n)?e[t]=e0(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=to(n):e[t]=n);return e}function Bs(r,e){for(;r!==null;){let n=Ky(r,e);if(n){if(n.get)return nn(n.get);if(typeof n.value=="function")return nn(n.value)}r=Gy(r)}function t(){return null}return t}var mh=rn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),wd=rn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ad=rn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),t0=rn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Sd=rn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),r0=rn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),gh=rn(["#text"]),hh=rn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Td=rn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),xh=rn(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Di=rn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),n0=Hn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),o0=Hn(/<%[\w\W]*|[\w\W]*%>/gm),a0=Hn(/\$\{[\w\W]*/gm),s0=Hn(/^data-[\-\w.\u00B7-\uFFFF]+$/),i0=Hn(/^aria-[\-\w]+$/),Ch=Hn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),l0=Hn(/^(?:\w+script|data):/i),d0=Hn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),wh=Hn(/^html$/i),c0=Hn(/^[a-z][.\w]*(-[.\w]+)+$/i),bh=Object.freeze({__proto__:null,ARIA_ATTR:i0,ATTR_WHITESPACE:d0,CUSTOM_ELEMENT:c0,DATA_ATTR:s0,DOCTYPE_NAME:wh,ERB_EXPR:o0,IS_ALLOWED_URI:Ch,IS_SCRIPT_OR_DATA:l0,MUSTACHE_EXPR:n0,TMPLIT_EXPR:a0}),Ds={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},p0=function(){return typeof window=="undefined"?null:window},u0=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null,o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));let a="dompurify"+(n?"#"+n:"");try{return e.createPolicy(a,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},yh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ah(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p0(),e=_e=>Ah(_e);if(e.version="3.3.3",e.removed=[],!r||!r.document||r.document.nodeType!==Ds.document||!r.Element)return e.isSupported=!1,e;let{document:t}=r,n=t,o=n.currentScript,{DocumentFragment:a,HTMLTemplateElement:s,Node:i,Element:d,NodeFilter:l,NamedNodeMap:u=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:m,DOMParser:p,trustedTypes:f}=r,b=d.prototype,h=Bs(b,"cloneNode"),S=Bs(b,"remove"),T=Bs(b,"nextSibling"),M=Bs(b,"childNodes"),k=Bs(b,"parentNode");if(typeof s=="function"){let _e=t.createElement("template");_e.content&&_e.content.ownerDocument&&(t=_e.content.ownerDocument)}let x,C="",{implementation:w,createNodeIterator:E,createDocumentFragment:H,getElementsByTagName:I}=t,{importNode:L}=n,O=yh();e.isSupported=typeof vh=="function"&&typeof k=="function"&&w&&w.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:$,ERB_EXPR:te,TMPLIT_EXPR:xe,DATA_ATTR:Je,ARIA_ATTR:we,IS_SCRIPT_OR_DATA:De,ATTR_WHITESPACE:Ae,CUSTOM_ELEMENT:qe}=bh,{IS_ALLOWED_URI:He}=bh,J=null,re=Ht({},[...mh,...wd,...Ad,...Sd,...gh]),Q=null,ge=Ht({},[...hh,...Td,...xh,...Di]),Z=Object.seal(Fi(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),G=null,pe=null,ke=Object.seal(Fi(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),le=!0,ne=!0,de=!1,Et=!0,wt=!1,We=!0,he=!1,at=!1,Re=!1,j=!1,ue=!1,nt=!1,Rt=!0,ee=!1,Ge="user-content-",Fr=!0,Bt=!1,or={},hr=null,sn=Ht({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),F=null,fe=Ht({},["audio","video","img","source","image","track"]),Ie=null,Xe=Ht({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Fe="http://www.w3.org/1998/Math/MathML",Ne="http://www.w3.org/2000/svg",Ye="http://www.w3.org/1999/xhtml",At=Ye,Xt=!1,ar=null,K=Ht({},[Fe,Ne,Ye],vd),mt=Ht({},["mi","mo","mn","ms","mtext"]),it=Ht({},["annotation-xml"]),ye=Ht({},["title","style","font","a","script"]),ie=null,st=["application/xhtml+xml","text/html"],pr="text/html",pt=null,yr=null,Rr=t.createElement("form"),ut=function(R){return R instanceof RegExp||R instanceof Function},Lt=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(yr&&yr===R)){if((!R||typeof R!="object")&&(R={}),R=to(R),ie=st.indexOf(R.PARSER_MEDIA_TYPE)===-1?pr:R.PARSER_MEDIA_TYPE,pt=ie==="application/xhtml+xml"?vd:Oi,J=wn(R,"ALLOWED_TAGS")?Ht({},R.ALLOWED_TAGS,pt):re,Q=wn(R,"ALLOWED_ATTR")?Ht({},R.ALLOWED_ATTR,pt):ge,ar=wn(R,"ALLOWED_NAMESPACES")?Ht({},R.ALLOWED_NAMESPACES,vd):K,Ie=wn(R,"ADD_URI_SAFE_ATTR")?Ht(to(Xe),R.ADD_URI_SAFE_ATTR,pt):Xe,F=wn(R,"ADD_DATA_URI_TAGS")?Ht(to(fe),R.ADD_DATA_URI_TAGS,pt):fe,hr=wn(R,"FORBID_CONTENTS")?Ht({},R.FORBID_CONTENTS,pt):sn,G=wn(R,"FORBID_TAGS")?Ht({},R.FORBID_TAGS,pt):to({}),pe=wn(R,"FORBID_ATTR")?Ht({},R.FORBID_ATTR,pt):to({}),or=wn(R,"USE_PROFILES")?R.USE_PROFILES:!1,le=R.ALLOW_ARIA_ATTR!==!1,ne=R.ALLOW_DATA_ATTR!==!1,de=R.ALLOW_UNKNOWN_PROTOCOLS||!1,Et=R.ALLOW_SELF_CLOSE_IN_ATTR!==!1,wt=R.SAFE_FOR_TEMPLATES||!1,We=R.SAFE_FOR_XML!==!1,he=R.WHOLE_DOCUMENT||!1,j=R.RETURN_DOM||!1,ue=R.RETURN_DOM_FRAGMENT||!1,nt=R.RETURN_TRUSTED_TYPE||!1,Re=R.FORCE_BODY||!1,Rt=R.SANITIZE_DOM!==!1,ee=R.SANITIZE_NAMED_PROPS||!1,Fr=R.KEEP_CONTENT!==!1,Bt=R.IN_PLACE||!1,He=R.ALLOWED_URI_REGEXP||Ch,At=R.NAMESPACE||Ye,mt=R.MATHML_TEXT_INTEGRATION_POINTS||mt,it=R.HTML_INTEGRATION_POINTS||it,Z=R.CUSTOM_ELEMENT_HANDLING||{},R.CUSTOM_ELEMENT_HANDLING&&ut(R.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Z.tagNameCheck=R.CUSTOM_ELEMENT_HANDLING.tagNameCheck),R.CUSTOM_ELEMENT_HANDLING&&ut(R.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Z.attributeNameCheck=R.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),R.CUSTOM_ELEMENT_HANDLING&&typeof R.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Z.allowCustomizedBuiltInElements=R.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),wt&&(ne=!1),ue&&(j=!0),or&&(J=Ht({},gh),Q=Fi(null),or.html===!0&&(Ht(J,mh),Ht(Q,hh)),or.svg===!0&&(Ht(J,wd),Ht(Q,Td),Ht(Q,Di)),or.svgFilters===!0&&(Ht(J,Ad),Ht(Q,Td),Ht(Q,Di)),or.mathMl===!0&&(Ht(J,Sd),Ht(Q,xh),Ht(Q,Di))),wn(R,"ADD_TAGS")||(ke.tagCheck=null),wn(R,"ADD_ATTR")||(ke.attributeCheck=null),R.ADD_TAGS&&(typeof R.ADD_TAGS=="function"?ke.tagCheck=R.ADD_TAGS:(J===re&&(J=to(J)),Ht(J,R.ADD_TAGS,pt))),R.ADD_ATTR&&(typeof R.ADD_ATTR=="function"?ke.attributeCheck=R.ADD_ATTR:(Q===ge&&(Q=to(Q)),Ht(Q,R.ADD_ATTR,pt))),R.ADD_URI_SAFE_ATTR&&Ht(Ie,R.ADD_URI_SAFE_ATTR,pt),R.FORBID_CONTENTS&&(hr===sn&&(hr=to(hr)),Ht(hr,R.FORBID_CONTENTS,pt)),R.ADD_FORBID_CONTENTS&&(hr===sn&&(hr=to(hr)),Ht(hr,R.ADD_FORBID_CONTENTS,pt)),Fr&&(J["#text"]=!0),he&&Ht(J,["html","head","body"]),J.table&&(Ht(J,["tbody"]),delete G.tbody),R.TRUSTED_TYPES_POLICY){if(typeof R.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ws('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof R.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ws('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=R.TRUSTED_TYPES_POLICY,C=x.createHTML("")}else x===void 0&&(x=u0(f,o)),x!==null&&typeof C=="string"&&(C=x.createHTML(""));rn&&rn(R),yr=R}},tt=Ht({},[...wd,...Ad,...t0]),zt=Ht({},[...Sd,...r0]),vr=function(R){let se=k(R);(!se||!se.tagName)&&(se={namespaceURI:At,tagName:"template"});let Ee=Oi(R.tagName),Ot=Oi(se.tagName);return ar[R.namespaceURI]?R.namespaceURI===Ne?se.namespaceURI===Ye?Ee==="svg":se.namespaceURI===Fe?Ee==="svg"&&(Ot==="annotation-xml"||mt[Ot]):!!tt[Ee]:R.namespaceURI===Fe?se.namespaceURI===Ye?Ee==="math":se.namespaceURI===Ne?Ee==="math"&&it[Ot]:!!zt[Ee]:R.namespaceURI===Ye?se.namespaceURI===Ne&&!it[Ot]||se.namespaceURI===Fe&&!mt[Ot]?!1:!zt[Ee]&&(ye[Ee]||!tt[Ee]):!!(ie==="application/xhtml+xml"&&ar[R.namespaceURI]):!1},sr=function(R){Is(e.removed,{element:R});try{k(R).removeChild(R)}catch{S(R)}},ur=function(R,se){try{Is(e.removed,{attribute:se.getAttributeNode(R),from:se})}catch{Is(e.removed,{attribute:null,from:se})}if(se.removeAttribute(R),R==="is")if(j||ue)try{sr(se)}catch{}else try{se.setAttribute(R,"")}catch{}},Mr=function(R){let se=null,Ee=null;if(Re)R="<remove></remove>"+R;else{let Nt=Cd(R,/^[\r\n\t ]+/);Ee=Nt&&Nt[0]}ie==="application/xhtml+xml"&&At===Ye&&(R='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+R+"</body></html>");let Ot=x?x.createHTML(R):R;if(At===Ye)try{se=new p().parseFromString(Ot,ie)}catch{}if(!se||!se.documentElement){se=w.createDocument(At,"template",null);try{se.documentElement.innerHTML=Xt?C:Ot}catch{}}let et=se.body||se.documentElement;return R&&Ee&&et.insertBefore(t.createTextNode(Ee),et.childNodes[0]||null),At===Ye?I.call(se,he?"html":"body")[0]:he?se.documentElement:et},un=function(R){return E.call(R.ownerDocument||R,R,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},St=function(R){return R instanceof m&&(typeof R.nodeName!="string"||typeof R.textContent!="string"||typeof R.removeChild!="function"||!(R.attributes instanceof u)||typeof R.removeAttribute!="function"||typeof R.setAttribute!="function"||typeof R.namespaceURI!="string"||typeof R.insertBefore!="function"||typeof R.hasChildNodes!="function")},qr=function(R){return typeof i=="function"&&R instanceof i};function xr(_e,R,se){Bi(_e,Ee=>{Ee.call(e,R,se,yr)})}let Mn=function(R){let se=null;if(xr(O.beforeSanitizeElements,R,null),St(R))return sr(R),!0;let Ee=pt(R.nodeName);if(xr(O.uponSanitizeElement,R,{tagName:Ee,allowedTags:J}),We&&R.hasChildNodes()&&!qr(R.firstElementChild)&&tn(/<[/\w!]/g,R.innerHTML)&&tn(/<[/\w!]/g,R.textContent)||R.nodeType===Ds.progressingInstruction||We&&R.nodeType===Ds.comment&&tn(/<[/\w]/g,R.data))return sr(R),!0;if(!(ke.tagCheck instanceof Function&&ke.tagCheck(Ee))&&(!J[Ee]||G[Ee])){if(!G[Ee]&&yt(Ee)&&(Z.tagNameCheck instanceof RegExp&&tn(Z.tagNameCheck,Ee)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(Ee)))return!1;if(Fr&&!hr[Ee]){let Ot=k(R)||R.parentNode,et=M(R)||R.childNodes;if(et&&Ot){let Nt=et.length;for(let Yt=Nt-1;Yt>=0;--Yt){let lr=h(et[Yt],!0);lr.__removalCount=(R.__removalCount||0)+1,Ot.insertBefore(lr,T(R))}}}return sr(R),!0}return R instanceof d&&!vr(R)||(Ee==="noscript"||Ee==="noembed"||Ee==="noframes")&&tn(/<\/no(script|embed|frames)/i,R.innerHTML)?(sr(R),!0):(wt&&R.nodeType===Ds.text&&(se=R.textContent,Bi([$,te,xe],Ot=>{se=Hs(se,Ot," ")}),R.textContent!==se&&(Is(e.removed,{element:R.cloneNode()}),R.textContent=se)),xr(O.afterSanitizeElements,R,null),!1)},ln=function(R,se,Ee){if(pe[se]||Rt&&(se==="id"||se==="name")&&(Ee in t||Ee in Rr))return!1;if(!(ne&&!pe[se]&&tn(Je,se))){if(!(le&&tn(we,se))){if(!(ke.attributeCheck instanceof Function&&ke.attributeCheck(se,R))){if(!Q[se]||pe[se]){if(!(yt(R)&&(Z.tagNameCheck instanceof RegExp&&tn(Z.tagNameCheck,R)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(R))&&(Z.attributeNameCheck instanceof RegExp&&tn(Z.attributeNameCheck,se)||Z.attributeNameCheck instanceof Function&&Z.attributeNameCheck(se,R))||se==="is"&&Z.allowCustomizedBuiltInElements&&(Z.tagNameCheck instanceof RegExp&&tn(Z.tagNameCheck,Ee)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(Ee))))return!1}else if(!Ie[se]){if(!tn(He,Hs(Ee,Ae,""))){if(!((se==="src"||se==="xlink:href"||se==="href")&&R!=="script"&&Jy(Ee,"data:")===0&&F[R])){if(!(de&&!tn(De,Hs(Ee,Ae,"")))){if(Ee)return!1}}}}}}}return!0},yt=function(R){return R!=="annotation-xml"&&Cd(R,qe)},Gn=function(R){xr(O.beforeSanitizeAttributes,R,null);let{attributes:se}=R;if(!se||St(R))return;let Ee={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Q,forceKeepAttr:void 0},Ot=se.length;for(;Ot--;){let et=se[Ot],{name:Nt,namespaceURI:Yt,value:lr}=et,vt=pt(Nt),zr=lr,$t=Nt==="value"?zr:Yy(zr);if(Ee.attrName=vt,Ee.attrValue=$t,Ee.keepAttr=!0,Ee.forceKeepAttr=void 0,xr(O.uponSanitizeAttribute,R,Ee),$t=Ee.attrValue,ee&&(vt==="id"||vt==="name")&&(ur(Nt,R),$t=Ge+$t),We&&tn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,$t)){ur(Nt,R);continue}if(vt==="attributename"&&Cd($t,"href")){ur(Nt,R);continue}if(Ee.forceKeepAttr)continue;if(!Ee.keepAttr){ur(Nt,R);continue}if(!Et&&tn(/\/>/i,$t)){ur(Nt,R);continue}wt&&Bi([$,te,xe],Dn=>{$t=Hs($t,Dn," ")});let $r=pt(R.nodeName);if(!ln($r,vt,$t)){ur(Nt,R);continue}if(x&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!Yt)switch(f.getAttributeType($r,vt)){case"TrustedHTML":{$t=x.createHTML($t);break}case"TrustedScriptURL":{$t=x.createScriptURL($t);break}}if($t!==zr)try{Yt?R.setAttributeNS(Yt,Nt,$t):R.setAttribute(Nt,$t),St(R)?sr(R):fh(e.removed)}catch{ur(Nt,R)}}xr(O.afterSanitizeAttributes,R,null)},kn=function _e(R){let se=null,Ee=un(R);for(xr(O.beforeSanitizeShadowDOM,R,null);se=Ee.nextNode();)xr(O.uponSanitizeShadowNode,se,null),Mn(se),Gn(se),se.content instanceof a&&_e(se.content);xr(O.afterSanitizeShadowDOM,R,null)};return e.sanitize=function(_e){let R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se=null,Ee=null,Ot=null,et=null;if(Xt=!_e,Xt&&(_e="<!-->"),typeof _e!="string"&&!qr(_e))if(typeof _e.toString=="function"){if(_e=_e.toString(),typeof _e!="string")throw Ws("dirty is not a string, aborting")}else throw Ws("toString is not a function");if(!e.isSupported)return _e;if(at||Lt(R),e.removed=[],typeof _e=="string"&&(Bt=!1),Bt){if(_e.nodeName){let lr=pt(_e.nodeName);if(!J[lr]||G[lr])throw Ws("root node is forbidden and cannot be sanitized in-place")}}else if(_e instanceof i)se=Mr("<!---->"),Ee=se.ownerDocument.importNode(_e,!0),Ee.nodeType===Ds.element&&Ee.nodeName==="BODY"||Ee.nodeName==="HTML"?se=Ee:se.appendChild(Ee);else{if(!j&&!wt&&!he&&_e.indexOf("<")===-1)return x&&nt?x.createHTML(_e):_e;if(se=Mr(_e),!se)return j?null:nt?C:""}se&&Re&&sr(se.firstChild);let Nt=un(Bt?_e:se);for(;Ot=Nt.nextNode();)Mn(Ot),Gn(Ot),Ot.content instanceof a&&kn(Ot.content);if(Bt)return _e;if(j){if(ue)for(et=H.call(se.ownerDocument);se.firstChild;)et.appendChild(se.firstChild);else et=se;return(Q.shadowroot||Q.shadowrootmode)&&(et=L.call(n,et,!0)),et}let Yt=he?se.outerHTML:se.innerHTML;return he&&J["!doctype"]&&se.ownerDocument&&se.ownerDocument.doctype&&se.ownerDocument.doctype.name&&tn(wh,se.ownerDocument.doctype.name)&&(Yt="<!DOCTYPE "+se.ownerDocument.doctype.name+`>
|
|
48
|
-
`+Yt),wt&&Bi([$,te,xe],lr=>{Yt=Hs(Yt,lr," ")}),x&&nt?x.createHTML(Yt):Yt},e.setConfig=function(){let _e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Lt(_e),at=!0},e.clearConfig=function(){yr=null,at=!1},e.isValidAttribute=function(_e,R,se){yr||Lt({});let Ee=pt(_e),Ot=pt(R);return ln(Ee,Ot,se)},e.addHook=function(_e,R){typeof R=="function"&&Is(O[_e],R)},e.removeHook=function(_e,R){if(R!==void 0){let se=Xy(O[_e],R);return se===-1?void 0:Qy(O[_e],se,1)[0]}return fh(O[_e])},e.removeHooks=function(_e){O[_e]=[]},e.removeAllHooks=function(){O=yh()},e}var Sh=Ah();var f0={ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","hr","div","span","ul","ol","li","dl","dt","dd","strong","em","b","i","u","s","del","ins","mark","small","sub","sup","abbr","kbd","var","samp","code","a","img","blockquote","pre","details","summary","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","input","label","select","option","textarea","button"],ALLOWED_ATTR:["href","src","alt","title","target","rel","loading","width","height","colspan","rowspan","scope","class","id","type","name","value","placeholder","disabled","checked","for","aria-label","aria-hidden","aria-expanded","role","tabindex","data-tv-form","data-message-id","data-persona-component-directive","data-preserve-animation","data-persona-instance"]},m0=/^data:image\/(?:png|jpe?g|gif|webp|bmp|x-icon|avif)/i,Ed=()=>{let r=Sh(typeof window!="undefined"?window:void 0);return r.addHook("uponSanitizeAttribute",(e,t)=>{if(t.attrName==="src"||t.attrName==="href"){let n=t.attrValue;n.toLowerCase().startsWith("data:")&&!m0.test(n)&&(t.attrValue="",t.keepAttr=!1)}}),e=>r.sanitize(e,f0)},Na=r=>r===!1?null:typeof r=="function"?r:Ed();var go="webmcp:",Ld=new Map,Th=r=>{var e;Ld.clear();for(let t of r){let n=(e=t.title)==null?void 0:e.trim();n&&Ld.set(t.name,n)}},Rd=r=>Ld.get(_i(r)),Ni={warn(r,...e){typeof console!="undefined"&&typeof console.warn=="function"&&console.warn(`[Persona/WebMCP] ${r}`,...e)}},Pd=null,kh=r=>{Pd=r};function Eh(r){if(r.length===0)return"0:empty";let e=r.map(t=>{var n,o;return[t.name,(n=t.description)!=null?n:"",t.parametersSchema?JSON.stringify(t.parametersSchema):"",(o=t.origin)!=null?o:"",t.annotations?JSON.stringify(t.annotations):""].join("")}).sort();return`${r.length}:${g0(e.join(""))}`}function Mh(r,e){let t=3735928559^e,n=1103547991^e;for(let o=0;o<r.length;o++){let a=r.charCodeAt(o);t=Math.imul(t^a,2654435761),n=Math.imul(n^a,1597334677)}return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}function g0(r){let e=Mh(r,0).toString(36),t=Mh(r,2654435761).toString(36);return`${e}.${t}`}var _a=class{constructor(e){this.config=e;this.installed=!1;this.readyPromise=null;this.incompatibleContextWarned=!1;var t;this.confirmHandler=(t=e.onConfirm)!=null?t:null,this.timeoutMs=3e4}setConfirmHandler(e){this.confirmHandler=e}isOperational(){return this.config.enabled!==!0||!this.installed?!1:this.getModelContext()!==null}async snapshotForDispatch(){if(await this.ensureReady(),this.config.enabled!==!0)return[];let e=this.getModelContext();if(!e)return[];let t;try{t=await e.getTools()}catch(o){return Ni.warn("getTools() threw \u2014 shipping an empty WebMCP snapshot.",o),[]}Th(t);let n=typeof location!="undefined"?location.origin:"";return t.filter(o=>this.passesClientAllowlist(o.name)).map(o=>{let a={name:o.name,description:o.description,origin:"webmcp",...n?{pageOrigin:n}:{}},s=x0(o.inputSchema);return s&&(a.parametersSchema=s),a})}async executeToolCall(e,t,n){if(await this.ensureReady(),this.config.enabled!==!0)return $n("WebMCP is not enabled on this widget.");let o=this.getModelContext();if(!o){let b=typeof document!="undefined"&&!!document.modelContext;return $n(b?"WebMCP is not operational: document.modelContext is present but does not expose the strict getTools()/executeTool() surface (likely a different or older WebMCP polyfill).":"WebMCP bridge is not operational on this page (document.modelContext not available).")}let a=_i(e),s;try{s=await o.getTools()}catch(b){let h=b instanceof Error?b.message:String(b);return $n(`Failed to read WebMCP registry: ${h}`)}Th(s);let i=s.find(b=>b.name===a);if(!i)return $n(`WebMCP tool not registered on this page: ${a}`);if(!this.passesClientAllowlist(a))return $n(`WebMCP tool not allowed by client allowlist: ${a}`);if(n!=null&&n.aborted)return $n("Aborted by cancel()");let d=Rd(a),l={toolName:a,args:t,description:i.description,...d?{title:d}:{},reason:"gate"};if(!await this.requestConfirm(l))return $n("User declined the tool call.");if(n!=null&&n.aborted)return $n("Aborted by cancel()");let u=new AbortController,m=!1,p=setTimeout(()=>{m=!0,u.abort()},this.timeoutMs),f=()=>u.abort();n&&(n.aborted?u.abort():n.addEventListener("abort",f,{once:!0}));try{let b=await o.executeTool(i,C0(t),{signal:u.signal});return b0(b)}catch(b){if(m)return $n(`WebMCP tool '${a}' timed out after ${this.timeoutMs}ms`);if(n!=null&&n.aborted)return $n("Aborted by cancel()");let h=b instanceof Error?b.message:String(b);return $n(h)}finally{clearTimeout(p),n&&n.removeEventListener("abort",f)}}ensureReady(){return this.config.enabled!==!0?Promise.resolve():(this.readyPromise||(this.readyPromise=this.install()),this.readyPromise)}async install(){try{if(this.getModelContext()){this.installed=!0;return}(Pd?await Pd():await import("@mcp-b/webmcp-polyfill")).initializeWebMCPPolyfill(),this.installed=!0}catch(e){Ni.warn("Failed to load @mcp-b/webmcp-polyfill \u2014 WebMCP consumption disabled.",e),this.installed=!1}}getModelContext(){if(typeof document=="undefined")return null;let e=document.modelContext;if(!e||typeof e!="object")return null;let t=e;return typeof t.getTools!="function"||typeof t.executeTool!="function"?(this.incompatibleContextWarned||(this.incompatibleContextWarned=!0,Ni.warn("document.modelContext is present but does not expose getTools()/executeTool() \u2014 WebMCP consumption is disabled. Another (incompatible or older) WebMCP polyfill likely installed document.modelContext before Persona. Remove it, or use a polyfill implementing the strict standard surface (e.g. @mcp-b/webmcp-polyfill).")),null):e}async requestConfirm(e){var n;let t=(n=this.confirmHandler)!=null?n:y0;try{return await t(e)}catch(o){return Ni.warn(`Confirm handler threw for WebMCP tool '${e.toolName}'; declining.`,o),!1}}passesClientAllowlist(e){let t=this.config.allowlist;return!t||t.length===0?!0:t.some(n=>h0(e,n))}},_i=r=>r.startsWith(go)?r.slice(go.length):r,da=r=>r.startsWith(go),h0=(r,e)=>{if(e==="*")return!0;let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return new RegExp("^"+t.replace(/\*/g,".*")+"$").test(r)},x0=r=>{if(!(r===void 0||r===""))try{let e=JSON.parse(r);return e!==null&&typeof e=="object"?e:void 0}catch{return}},b0=r=>{if(r==null)return{content:[{type:"text",text:""}]};let e;try{e=JSON.parse(r)}catch{return{content:[{type:"text",text:r}]}}return e!==null&&typeof e=="object"&&Array.isArray(e.content)?e:{content:[{type:"text",text:typeof e=="string"?e:w0(e)}]}},$n=r=>({isError:!0,content:[{type:"text",text:r}]}),y0=async r=>{if(typeof window=="undefined"||typeof window.confirm!="function")return!1;let e=v0(r.args),t=`Allow the AI to call ${r.toolName}`+(e?`
|
|
44
|
+
`}tablecell(e,t){let o=t.header?"th":"td";return(t.align?`<${o} align="${t.align}">`:`<${o}>`)+e+`</${o}>
|
|
45
|
+
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,o){let n=Kg(e);if(n===null)return o;e=n;let a='<a href="'+e+'"';return t&&(a+=' title="'+t+'"'),a+=">"+o+"</a>",a}image(e,t,o){let n=Kg(e);if(n===null)return o;e=n;let a=`<img src="${e}" alt="${o}"`;return t&&(a+=` title="${t}"`),a+=">",a}text(e){return e}},Ws=class{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,o){return""+o}image(e,t,o){return""+o}br(){return""}},vn=class r{constructor(e){lr(this,"options");lr(this,"renderer");lr(this,"textRenderer");this.options=e||pa,this.options.renderer=this.options.renderer||new za,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Ws}static parse(e,t){return new r(t).parse(e)}static parseInline(e,t){return new r(t).parseInline(e)}parse(e,t=!0){let o="";for(let n=0;n<e.length;n++){let a=e[n];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){let s=a,i=this.options.extensions.renderers[s.type].call({parser:this},s);if(i!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(s.type)){o+=i||"";continue}}switch(a.type){case"space":continue;case"hr":{o+=this.renderer.hr();continue}case"heading":{let s=a;o+=this.renderer.heading(this.parseInline(s.tokens),s.depth,Cb(this.parseInline(s.tokens,this.textRenderer)));continue}case"code":{let s=a;o+=this.renderer.code(s.text,s.lang,!!s.escaped);continue}case"table":{let s=a,i="",d="";for(let u=0;u<s.header.length;u++)d+=this.renderer.tablecell(this.parseInline(s.header[u].tokens),{header:!0,align:s.align[u]});i+=this.renderer.tablerow(d);let l="";for(let u=0;u<s.rows.length;u++){let f=s.rows[u];d="";for(let p=0;p<f.length;p++)d+=this.renderer.tablecell(this.parseInline(f[p].tokens),{header:!1,align:s.align[p]});l+=this.renderer.tablerow(d)}o+=this.renderer.table(i,l);continue}case"blockquote":{let s=a,i=this.parse(s.tokens);o+=this.renderer.blockquote(i);continue}case"list":{let s=a,i=s.ordered,d=s.start,l=s.loose,u="";for(let f=0;f<s.items.length;f++){let p=s.items[f],m=p.checked,y=p.task,h="";if(p.task){let T=this.renderer.checkbox(!!m);l?p.tokens.length>0&&p.tokens[0].type==="paragraph"?(p.tokens[0].text=T+" "+p.tokens[0].text,p.tokens[0].tokens&&p.tokens[0].tokens.length>0&&p.tokens[0].tokens[0].type==="text"&&(p.tokens[0].tokens[0].text=T+" "+p.tokens[0].tokens[0].text)):p.tokens.unshift({type:"text",text:T+" "}):h+=T+" "}h+=this.parse(p.tokens,l),u+=this.renderer.listitem(h,y,!!m)}o+=this.renderer.list(u,i,d);continue}case"html":{let s=a;o+=this.renderer.html(s.text,s.block);continue}case"paragraph":{let s=a;o+=this.renderer.paragraph(this.parseInline(s.tokens));continue}case"text":{let s=a,i=s.tokens?this.parseInline(s.tokens):s.text;for(;n+1<e.length&&e[n+1].type==="text";)s=e[++n],i+=`
|
|
46
|
+
`+(s.tokens?this.parseInline(s.tokens):s.text);o+=t?this.renderer.paragraph(i):i;continue}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return o}parseInline(e,t){t=t||this.renderer;let o="";for(let n=0;n<e.length;n++){let a=e[n];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){let s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){o+=s||"";continue}}switch(a.type){case"escape":{let s=a;o+=t.text(s.text);break}case"html":{let s=a;o+=t.html(s.text);break}case"link":{let s=a;o+=t.link(s.href,s.title,this.parseInline(s.tokens,t));break}case"image":{let s=a;o+=t.image(s.href,s.title,s.text);break}case"strong":{let s=a;o+=t.strong(this.parseInline(s.tokens,t));break}case"em":{let s=a;o+=t.em(this.parseInline(s.tokens,t));break}case"codespan":{let s=a;o+=t.codespan(s.text);break}case"br":{o+=t.br();break}case"del":{let s=a;o+=t.del(this.parseInline(s.tokens,t));break}case"text":{let s=a;o+=t.text(s.text);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return o}},la=class{constructor(e){lr(this,"options");this.options=e||pa}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}};lr(la,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var ca,gd,lh,Bs=class{constructor(...e){jg(this,ca);lr(this,"defaults",hd());lr(this,"options",this.setOptions);lr(this,"parse",Di(this,ca,gd).call(this,bn.lex,vn.parse));lr(this,"parseInline",Di(this,ca,gd).call(this,bn.lexInline,vn.parseInline));lr(this,"Parser",vn);lr(this,"Renderer",za);lr(this,"TextRenderer",Ws);lr(this,"Lexer",bn);lr(this,"Tokenizer",qa);lr(this,"Hooks",la);this.use(...e)}walkTokens(e,t){var n,a;let o=[];for(let s of e)switch(o=o.concat(t.call(this,s)),s.type){case"table":{let i=s;for(let d of i.header)o=o.concat(this.walkTokens(d.tokens,t));for(let d of i.rows)for(let l of d)o=o.concat(this.walkTokens(l.tokens,t));break}case"list":{let i=s;o=o.concat(this.walkTokens(i.items,t));break}default:{let i=s;(a=(n=this.defaults.extensions)==null?void 0:n.childTokens)!=null&&a[i.type]?this.defaults.extensions.childTokens[i.type].forEach(d=>{let l=i[d].flat(1/0);o=o.concat(this.walkTokens(l,t))}):i.tokens&&(o=o.concat(this.walkTokens(i.tokens,t)))}}return o}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(o=>{let n={...o};if(n.async=this.defaults.async||n.async||!1,o.extensions&&(o.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){let s=t.renderers[a.name];s?t.renderers[a.name]=function(...i){let d=a.renderer.apply(this,i);return d===!1&&(d=s.apply(this,i)),d}:t.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[a.level];s?s.unshift(a.tokenizer):t[a.level]=[a.tokenizer],a.start&&(a.level==="block"?t.startBlock?t.startBlock.push(a.start):t.startBlock=[a.start]:a.level==="inline"&&(t.startInline?t.startInline.push(a.start):t.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(t.childTokens[a.name]=a.childTokens)}),n.extensions=t),o.renderer){let a=this.defaults.renderer||new za(this.defaults);for(let s in o.renderer){if(!(s in a))throw new Error(`renderer '${s}' does not exist`);if(s==="options")continue;let i=s,d=o.renderer[i],l=a[i];a[i]=(...u)=>{let f=d.apply(a,u);return f===!1&&(f=l.apply(a,u)),f||""}}n.renderer=a}if(o.tokenizer){let a=this.defaults.tokenizer||new qa(this.defaults);for(let s in o.tokenizer){if(!(s in a))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=s,d=o.tokenizer[i],l=a[i];a[i]=(...u)=>{let f=d.apply(a,u);return f===!1&&(f=l.apply(a,u)),f}}n.tokenizer=a}if(o.hooks){let a=this.defaults.hooks||new la;for(let s in o.hooks){if(!(s in a))throw new Error(`hook '${s}' does not exist`);if(s==="options")continue;let i=s,d=o.hooks[i],l=a[i];la.passThroughHooks.has(s)?a[i]=u=>{if(this.defaults.async)return Promise.resolve(d.call(a,u)).then(p=>l.call(a,p));let f=d.call(a,u);return l.call(a,f)}:a[i]=(...u)=>{let f=d.apply(a,u);return f===!1&&(f=l.apply(a,u)),f}}n.hooks=a}if(o.walkTokens){let a=this.defaults.walkTokens,s=o.walkTokens;n.walkTokens=function(i){let d=[];return d.push(s.call(this,i)),a&&(d=d.concat(a.call(this,i))),d}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return bn.lex(e,t!=null?t:this.defaults)}parser(e,t){return vn.parse(e,t!=null?t:this.defaults)}};ca=new WeakSet,gd=function(e,t){return(o,n)=>{let a={...n},s={...this.defaults,...a};this.defaults.async===!0&&a.async===!1&&(s.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),s.async=!0);let i=Di(this,ca,lh).call(this,!!s.silent,!!s.async);if(typeof o=="undefined"||o===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof o!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(o)+", string expected"));if(s.hooks&&(s.hooks.options=s),s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(o):o).then(d=>e(d,s)).then(d=>s.hooks?s.hooks.processAllTokens(d):d).then(d=>s.walkTokens?Promise.all(this.walkTokens(d,s.walkTokens)).then(()=>d):d).then(d=>t(d,s)).then(d=>s.hooks?s.hooks.postprocess(d):d).catch(i);try{s.hooks&&(o=s.hooks.preprocess(o));let d=e(o,s);s.hooks&&(d=s.hooks.processAllTokens(d)),s.walkTokens&&this.walkTokens(d,s.walkTokens);let l=t(d,s);return s.hooks&&(l=s.hooks.postprocess(l)),l}catch(d){return i(d)}}},lh=function(e,t){return o=>{if(o.message+=`
|
|
47
|
+
Please report this to https://github.com/markedjs/marked.`,e){let n="<p>An error occurred:</p><pre>"+Ho(o.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(o);throw o}};var da=new Bs;function tr(r,e){return da.parse(r,e)}tr.options=tr.setOptions=function(r){return da.setOptions(r),tr.defaults=da.defaults,Jg(tr.defaults),tr};tr.getDefaults=hd;tr.defaults=pa;tr.use=function(...r){return da.use(...r),tr.defaults=da.defaults,Jg(tr.defaults),tr};tr.walkTokens=function(r,e){return da.walkTokens(r,e)};tr.parseInline=da.parseInline;tr.Parser=vn;tr.parser=vn.parse;tr.Renderer=za;tr.TextRenderer=Ws;tr.Lexer=bn;tr.lexer=bn.lex;tr.Tokenizer=qa;tr.Hooks=la;tr.parse=tr;var Jw=tr.options,Zw=tr.setOptions,eA=tr.use,tA=tr.walkTokens,rA=tr.parseInline;var oA=vn.parse,nA=bn.lex;var Yb=r=>{if(r)return r},_s=r=>{var n,a;let e=r==null?void 0:r.markedOptions,t=new Bs({gfm:(n=e==null?void 0:e.gfm)!=null?n:!0,breaks:(a=e==null?void 0:e.breaks)!=null?a:!0,pedantic:e==null?void 0:e.pedantic,silent:e==null?void 0:e.silent}),o=Yb(r==null?void 0:r.renderer);return o&&t.use({renderer:o}),s=>t.parse(s)},ua=r=>r?_s({markedOptions:r.options,renderer:r.renderer}):_s(),Jb=_s(),wd=r=>Jb(r),fa=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),ch=r=>r.replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),dh=r=>`%%FORM_PLACEHOLDER_${r}%%`,ph=(r,e)=>{let t=r;return t=t.replace(/<Directive>([\s\S]*?)<\/Directive>/gi,(o,n)=>{try{let a=JSON.parse(n.trim());if(a&&typeof a=="object"&&a.component==="form"&&a.type){let s=dh(e.length);return e.push({token:s,type:String(a.type)}),s}}catch{return o}return o}),t=t.replace(/<Form\s+type="([^"]+)"\s*\/>/gi,(o,n)=>{let a=dh(e.length);return e.push({token:a,type:n}),a}),t},uh=r=>{let e=ua(r);return t=>{let o=[],n=ph(t,o),a=e(n);return o.forEach(({token:s,type:i})=>{let d=new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),u=`<div class="persona-form-directive" data-tv-form="${ch(i)}"></div>`;a=a.replace(d,u)}),a}},fh=r=>{let e=[],t=ph(r,e),o=wd(t);return e.forEach(({token:n,type:a})=>{let s=new RegExp(n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),d=`<div class="persona-form-directive" data-tv-form="${ch(a)}"></div>`;o=o.replace(s,d)}),o};function mh(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,o=Array(e);t<e;t++)o[t]=r[t];return o}function Zb(r){if(Array.isArray(r))return r}function e0(r,e){var t=r==null?null:typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var o,n,a,s,i=[],d=!0,l=!1;try{if(a=(t=t.call(r)).next,e!==0)for(;!(d=(o=a.call(t)).done)&&(i.push(o.value),i.length!==e);d=!0);}catch(u){l=!0,n=u}finally{try{if(!d&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(l)throw n}}return i}}function t0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
48
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function r0(r,e){return Zb(r)||e0(r,e)||o0(r,e)||t0()}function o0(r,e){if(r){if(typeof r=="string")return mh(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?mh(r,e):void 0}}var Eh=Object.entries,gh=Object.setPrototypeOf,n0=Object.isFrozen,a0=Object.getPrototypeOf,s0=Object.getOwnPropertyDescriptor,Kr=Object.freeze,Xr=Object.seal,Va=Object.create,Lh=typeof Reflect!="undefined"&&Reflect,Ed=Lh.apply,Ld=Lh.construct;Kr||(Kr=function(e){return e});Xr||(Xr=function(e){return e});Ed||(Ed=function(e,t){for(var o=arguments.length,n=new Array(o>2?o-2:0),a=2;a<o;a++)n[a-2]=arguments[a];return e.apply(t,n)});Ld||(Ld=function(e){for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return new e(...o)});var Ns=Er(Array.prototype.forEach),i0=Er(Array.prototype.lastIndexOf),hh=Er(Array.prototype.pop),$a=Er(Array.prototype.push),l0=Er(Array.prototype.splice),Fn=Array.isArray,qs=Er(String.prototype.toLowerCase),Ad=Er(String.prototype.toString),xh=Er(String.prototype.match),Fs=Er(String.prototype.replace),yh=Er(String.prototype.indexOf),d0=Er(String.prototype.trim),c0=Er(Number.prototype.toString),p0=Er(Boolean.prototype.toString),bh=typeof BigInt=="undefined"?null:Er(BigInt.prototype.toString),vh=typeof Symbol=="undefined"?null:Er(Symbol.prototype.toString),Co=Er(Object.prototype.hasOwnProperty),Us=Er(Object.prototype.toString),Gr=Er(RegExp.prototype.test),ma=u0(TypeError);function Er(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return Ed(r,e,o)}}function u0(r){return function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return Ld(r,t)}}function Nt(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qs;if(gh&&gh(r,null),!Fn(e))return r;let o=e.length;for(;o--;){let n=e[o];if(typeof n=="string"){let a=t(n);a!==n&&(n0(e)||(e[o]=a),n=a)}r[n]=!0}return r}function f0(r){for(let e=0;e<r.length;e++)Co(r,e)||(r[e]=null);return r}function vo(r){let e=Va(null);for(let o of Eh(r)){var t=r0(o,2);let n=t[0],a=t[1];Co(r,n)&&(Fn(a)?e[n]=f0(a):a&&typeof a=="object"&&a.constructor===Object?e[n]=vo(a):e[n]=a)}return e}function m0(r){switch(typeof r){case"string":return r;case"number":return c0(r);case"boolean":return p0(r);case"bigint":return bh?bh(r):"0";case"symbol":return vh?vh(r):"Symbol()";case"undefined":return Us(r);case"function":case"object":{if(r===null)return Us(r);let e=r,t=pn(e,"toString");if(typeof t=="function"){let o=t(e);return typeof o=="string"?o:Us(o)}return Us(r)}default:return Us(r)}}function pn(r,e){for(;r!==null;){let o=s0(r,e);if(o){if(o.get)return Er(o.get);if(typeof o.value=="function")return Er(o.value)}r=a0(r)}function t(){return null}return t}function g0(r){try{return Gr(r,""),!0}catch{return!1}}var Ch=Kr(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Sd=Kr(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Td=Kr(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),h0=Kr(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Md=Kr(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),x0=Kr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wh=Kr(["#text"]),Ah=Kr(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),kd=Kr(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Sh=Kr(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ui=Kr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),y0=Xr(/{{[\w\W]*|^[\w\W]*}}/g),b0=Xr(/<%[\w\W]*|^[\w\W]*%>/g),v0=Xr(/\${[\w\W]*/g),C0=Xr(/^data-[\-\w.\u00B7-\uFFFF]+$/),w0=Xr(/^aria-[\-\w]+$/),Th=Xr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),A0=Xr(/^(?:\w+script|data):/i),S0=Xr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),T0=Xr(/^html$/i),M0=Xr(/^[a-z][.\w]*(-[.\w]+)+$/i),Mh=Xr(/<[/\w!]/g),k0=Xr(/<[/\w]/g),E0=Xr(/<\/no(script|embed|frames)/i),L0=Xr(/\/>/i),cn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},P0=function(){return typeof window=="undefined"?null:window},R0=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let o=null,n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(o=t.getAttribute(n));let a="dompurify"+(o?"#"+o:"");try{return e.createPolicy(a,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},kh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Nn=function(e,t,o,n){return Co(e,t)&&Fn(e[t])?Nt(n.base?vo(n.base):{},e[t],n.transform):o};function Ph(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:P0(),e=re=>Ph(re);if(e.version="3.4.10",e.removed=[],!r||!r.document||r.document.nodeType!==cn.document||!r.Element)return e.isSupported=!1,e;let t=r.document,o=t,n=o.currentScript;r.DocumentFragment;let a=r.HTMLTemplateElement,s=r.Node,i=r.Element,d=r.NodeFilter,l=r.NamedNodeMap;l===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;let u=r.DOMParser,f=r.trustedTypes,p=i.prototype,m=pn(p,"cloneNode"),y=pn(p,"remove"),h=pn(p,"nextSibling"),T=pn(p,"childNodes"),M=pn(p,"parentNode"),k=pn(p,"shadowRoot"),L=pn(p,"attributes"),x=s&&s.prototype?pn(s.prototype,"nodeType"):null,w=s&&s.prototype?pn(s.prototype,"nodeName"):null;if(typeof a=="function"){let re=t.createElement("template");re.content&&re.content.ownerDocument&&(t=re.content.ownerDocument)}let v,E="",H,I=!1,P=0,z=function(){if(P>0)throw ma('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},j=function(A){z(),P++;try{return v.createHTML(A)}finally{P--}},ie=function(A){z(),P++;try{return v.createScriptURL(A)}finally{P--}},ve=function(){return I||(H=R0(f,n),I=!0),H},Xe=t,Ae=Xe.implementation,We=Xe.createNodeIterator,Me=Xe.createDocumentFragment,Ue=Xe.getElementsByTagName,Be=o.importNode,Z=kh();e.isSupported=typeof Eh=="function"&&typeof M=="function"&&Ae&&Ae.createHTMLDocument!==void 0;let ne=y0,me=b0,be=v0,ye=C0,Y=w0,ge=A0,Oe=S0,ce=M0,ae=Th,Q=null,Tt=Nt({},[...Ch,...Sd,...Td,...Md,...wh]),Ye=null,De=Nt({},[...Ah,...kd,...Sh,...Ui]),le=Object.seal(Va(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),nt=null,Re=null,K=Object.seal(Va(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),he=!0,it=!0,Pt=!1,te=!0,_e=!1,Ar=!0,Rt=!1,dr=!1,Yr=!1,zr=!1,O=!1,fe=!1,Ie=!0,Je=!1,qe="user-content-",ze=!0,lt=!1,Mt={},Dt=null,or=Nt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),X=null,wt=Nt({},["audio","video","img","source","image","track"]),ct=null,Ce=Nt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),de="http://www.w3.org/1998/Math/MathML",rt="http://www.w3.org/2000/svg",Ft="http://www.w3.org/1999/xhtml",zt=Ft,Pr=!1,vr=null,xt=Nt({},[de,rt,Ft],Ad),It=Kr(["mi","mo","mn","ms","mtext"]),tt=Nt({},It),jt=Kr(["annotation-xml"]),cr=Nt({},jt),Dr=Nt({},["title","style","font","a","script"]),hr=null,Sr=["application/xhtml+xml","text/html"],Oo="text/html",je=null,Tr=null,io=t.createElement("form"),_o=function(A){return A instanceof RegExp||A instanceof Function},lo=function(){let A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Tr&&Tr===A)return;(!A||typeof A!="object")&&(A={}),A=vo(A),hr=Sr.indexOf(A.PARSER_MEDIA_TYPE)===-1?Oo:A.PARSER_MEDIA_TYPE,je=hr==="application/xhtml+xml"?Ad:qs,Q=Nn(A,"ALLOWED_TAGS",Tt,{transform:je}),Ye=Nn(A,"ALLOWED_ATTR",De,{transform:je}),vr=Nn(A,"ALLOWED_NAMESPACES",xt,{transform:Ad}),ct=Nn(A,"ADD_URI_SAFE_ATTR",Ce,{transform:je,base:Ce}),X=Nn(A,"ADD_DATA_URI_TAGS",wt,{transform:je,base:wt}),Dt=Nn(A,"FORBID_CONTENTS",or,{transform:je}),nt=Nn(A,"FORBID_TAGS",vo({}),{transform:je}),Re=Nn(A,"FORBID_ATTR",vo({}),{transform:je}),Mt=Co(A,"USE_PROFILES")?A.USE_PROFILES&&typeof A.USE_PROFILES=="object"?vo(A.USE_PROFILES):A.USE_PROFILES:!1,he=A.ALLOW_ARIA_ATTR!==!1,it=A.ALLOW_DATA_ATTR!==!1,Pt=A.ALLOW_UNKNOWN_PROTOCOLS||!1,te=A.ALLOW_SELF_CLOSE_IN_ATTR!==!1,_e=A.SAFE_FOR_TEMPLATES||!1,Ar=A.SAFE_FOR_XML!==!1,Rt=A.WHOLE_DOCUMENT||!1,zr=A.RETURN_DOM||!1,O=A.RETURN_DOM_FRAGMENT||!1,fe=A.RETURN_TRUSTED_TYPE||!1,Yr=A.FORCE_BODY||!1,Ie=A.SANITIZE_DOM!==!1,Je=A.SANITIZE_NAMED_PROPS||!1,ze=A.KEEP_CONTENT!==!1,lt=A.IN_PLACE||!1,ae=g0(A.ALLOWED_URI_REGEXP)?A.ALLOWED_URI_REGEXP:Th,zt=typeof A.NAMESPACE=="string"?A.NAMESPACE:Ft,tt=Co(A,"MATHML_TEXT_INTEGRATION_POINTS")&&A.MATHML_TEXT_INTEGRATION_POINTS&&typeof A.MATHML_TEXT_INTEGRATION_POINTS=="object"?vo(A.MATHML_TEXT_INTEGRATION_POINTS):Nt({},It),cr=Co(A,"HTML_INTEGRATION_POINTS")&&A.HTML_INTEGRATION_POINTS&&typeof A.HTML_INTEGRATION_POINTS=="object"?vo(A.HTML_INTEGRATION_POINTS):Nt({},jt);let _=Co(A,"CUSTOM_ELEMENT_HANDLING")&&A.CUSTOM_ELEMENT_HANDLING&&typeof A.CUSTOM_ELEMENT_HANDLING=="object"?vo(A.CUSTOM_ELEMENT_HANDLING):Va(null);if(le=Va(null),Co(_,"tagNameCheck")&&_o(_.tagNameCheck)&&(le.tagNameCheck=_.tagNameCheck),Co(_,"attributeNameCheck")&&_o(_.attributeNameCheck)&&(le.attributeNameCheck=_.attributeNameCheck),Co(_,"allowCustomizedBuiltInElements")&&typeof _.allowCustomizedBuiltInElements=="boolean"&&(le.allowCustomizedBuiltInElements=_.allowCustomizedBuiltInElements),Xr(le),_e&&(it=!1),O&&(zr=!0),Mt&&(Q=Nt({},wh),Ye=Va(null),Mt.html===!0&&(Nt(Q,Ch),Nt(Ye,Ah)),Mt.svg===!0&&(Nt(Q,Sd),Nt(Ye,kd),Nt(Ye,Ui)),Mt.svgFilters===!0&&(Nt(Q,Td),Nt(Ye,kd),Nt(Ye,Ui)),Mt.mathMl===!0&&(Nt(Q,Md),Nt(Ye,Sh),Nt(Ye,Ui))),K.tagCheck=null,K.attributeCheck=null,Co(A,"ADD_TAGS")&&(typeof A.ADD_TAGS=="function"?K.tagCheck=A.ADD_TAGS:Fn(A.ADD_TAGS)&&(Q===Tt&&(Q=vo(Q)),Nt(Q,A.ADD_TAGS,je))),Co(A,"ADD_ATTR")&&(typeof A.ADD_ATTR=="function"?K.attributeCheck=A.ADD_ATTR:Fn(A.ADD_ATTR)&&(Ye===De&&(Ye=vo(Ye)),Nt(Ye,A.ADD_ATTR,je))),Co(A,"ADD_URI_SAFE_ATTR")&&Fn(A.ADD_URI_SAFE_ATTR)&&Nt(ct,A.ADD_URI_SAFE_ATTR,je),Co(A,"FORBID_CONTENTS")&&Fn(A.FORBID_CONTENTS)&&(Dt===or&&(Dt=vo(Dt)),Nt(Dt,A.FORBID_CONTENTS,je)),Co(A,"ADD_FORBID_CONTENTS")&&Fn(A.ADD_FORBID_CONTENTS)&&(Dt===or&&(Dt=vo(Dt)),Nt(Dt,A.ADD_FORBID_CONTENTS,je)),ze&&(Q["#text"]=!0),Rt&&Nt(Q,["html","head","body"]),Q.table&&(Nt(Q,["tbody"]),delete nt.tbody),A.TRUSTED_TYPES_POLICY){if(typeof A.TRUSTED_TYPES_POLICY.createHTML!="function")throw ma('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof A.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ma('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let ue=v;v=A.TRUSTED_TYPES_POLICY;try{E=j("")}catch($){throw v=ue,$}}else A.TRUSTED_TYPES_POLICY===null?(v=void 0,E=""):(v===void 0&&(v=ve()),v&&typeof E=="string"&&(E=j("")));(Z.uponSanitizeElement.length>0||Z.uponSanitizeAttribute.length>0)&&Q===Tt&&(Q=vo(Q)),Z.uponSanitizeAttribute.length>0&&Ye===De&&(Ye=vo(Ye)),Kr&&Kr(A),Tr=A},At=Nt({},[...Sd,...Td,...h0]),rn=Nt({},[...Md,...x0]),No=function(A,_,ue){return _.namespaceURI===Ft?A==="svg":_.namespaceURI===de?A==="svg"&&(ue==="annotation-xml"||tt[ue]):!!At[A]},mn=function(A,_,ue){return _.namespaceURI===Ft?A==="math":_.namespaceURI===rt?A==="math"&&cr[ue]:!!rn[A]},Jr=function(A,_,ue){return _.namespaceURI===rt&&!cr[ue]||_.namespaceURI===de&&!tt[ue]?!1:!rn[A]&&(Dr[A]||!At[A])},Ln=function(A){let _=M(A);(!_||!_.tagName)&&(_={namespaceURI:zt,tagName:"template"});let ue=qs(A.tagName),$=qs(_.tagName);return vr[A.namespaceURI]?A.namespaceURI===rt?No(ue,_,$):A.namespaceURI===de?mn(ue,_,$):A.namespaceURI===Ft?Jr(ue,_,$):!!(hr==="application/xhtml+xml"&&vr[A.namespaceURI]):!1},$r=function(A){$a(e.removed,{element:A});try{M(A).removeChild(A)}catch{if(y(A),!M(A))throw ma("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Fo=function(A){let _=T(A);if(_){let $=[];Ns(_,at=>{$a($,at)}),Ns($,at=>{try{y(at)}catch{}})}let ue=L(A);if(ue)for(let $=ue.length-1;$>=0;--$){let at=ue[$],ut=at&&at.name;if(typeof ut=="string")try{A.removeAttribute(ut)}catch{}}},mt=function(A,_){try{$a(e.removed,{attribute:_.getAttributeNode(A),from:_})}catch{$a(e.removed,{attribute:null,from:_})}if(_.removeAttribute(A),A==="is")if(zr||O)try{$r(_)}catch{}else try{_.setAttribute(A,"")}catch{}},co=function(A){let _=L(A);if(_)for(let ue=_.length-1;ue>=0;--ue){let $=_[ue],at=$&&$.name;if(!(typeof at!="string"||Ye[je(at)]))try{A.removeAttribute(at)}catch{}}},po=function(A){let _=[A];for(;_.length>0;){let ue=_.pop();(x?x(ue):ue.nodeType)===cn.element&&co(ue);let at=T(ue);if(at)for(let ut=at.length-1;ut>=0;--ut)_.push(at[ut])}},Or=function(A){let _=null,ue=null;if(Yr)A="<remove></remove>"+A;else{let ut=xh(A,/^[\r\n\t ]+/);ue=ut&&ut[0]}hr==="application/xhtml+xml"&&zt===Ft&&(A='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+A+"</body></html>");let $=v?j(A):A;if(zt===Ft)try{_=new u().parseFromString($,hr)}catch{}if(!_||!_.documentElement){_=Ae.createDocument(zt,"template",null);try{_.documentElement.innerHTML=Pr?E:$}catch{}}let at=_.body||_.documentElement;return A&&ue&&at.insertBefore(t.createTextNode(ue),at.childNodes[0]||null),zt===Ft?Ue.call(_,Rt?"html":"body")[0]:Rt?_.documentElement:at},Wt=function(A){return We.call(A.ownerDocument||A,A,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Vr=function(A){return A=Fs(A,ne," "),A=Fs(A,me," "),A=Fs(A,be," "),A},Zr=function(A){var _;A.normalize();let ue=We.call(A.ownerDocument||A,A,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null),$=ue.nextNode();for(;$;)$.data=Vr($.data),$=ue.nextNode();let at=(_=A.querySelectorAll)===null||_===void 0?void 0:_.call(A,"template");at&&Ns(at,ut=>{uo(ut.content)&&Zr(ut.content)})},_r=function(A){let _=w?w(A):null;return typeof _!="string"||je(_)!=="form"?!1:typeof A.nodeName!="string"||typeof A.textContent!="string"||typeof A.removeChild!="function"||A.attributes!==L(A)||typeof A.removeAttribute!="function"||typeof A.setAttribute!="function"||typeof A.namespaceURI!="string"||typeof A.insertBefore!="function"||typeof A.hasChildNodes!="function"||A.nodeType!==x(A)||A.childNodes!==T(A)},uo=function(A){if(!x||typeof A!="object"||A===null)return!1;try{return x(A)===cn.documentFragment}catch{return!1}},fo=function(A){if(!x||typeof A!="object"||A===null)return!1;try{return typeof x(A)=="number"}catch{return!1}};function Nr(re,A,_){re.length!==0&&Ns(re,ue=>{ue.call(e,A,_,Tr)})}let mo=function(A,_){return!!(Ar&&A.hasChildNodes()&&!fo(A.firstElementChild)&&Gr(Mh,A.textContent)&&Gr(Mh,A.innerHTML)||Ar&&A.namespaceURI===Ft&&_==="style"&&fo(A.firstElementChild)||A.nodeType===cn.processingInstruction||Ar&&A.nodeType===cn.comment&&Gr(k0,A.data))},$t=function(A,_){if(!nt[_]&&Uo(_)&&(le.tagNameCheck instanceof RegExp&&Gr(le.tagNameCheck,_)||le.tagNameCheck instanceof Function&&le.tagNameCheck(_)))return!1;if(ze&&!Dt[_]){let ue=M(A),$=T(A);if($&&ue){let at=$.length;for(let ut=at-1;ut>=0;--ut){let U=lt?$[ut]:m($[ut],!0);ue.insertBefore(U,h(A))}}}return $r(A),!0},Fr=function(A){if(Nr(Z.beforeSanitizeElements,A,null),_r(A))return $r(A),!0;let _=je(w?w(A):A.nodeName);if(Nr(Z.uponSanitizeElement,A,{tagName:_,allowedTags:Q}),mo(A,_))return $r(A),!0;if(nt[_]||!(K.tagCheck instanceof Function&&K.tagCheck(_))&&!Q[_])return $t(A,_);if((x?x(A):A.nodeType)===cn.element&&!Ln(A)||(_==="noscript"||_==="noembed"||_==="noframes")&&Gr(E0,A.innerHTML))return $r(A),!0;if(_e&&A.nodeType===cn.text){let $=Vr(A.textContent);A.textContent!==$&&($a(e.removed,{element:A.cloneNode()}),A.textContent=$)}return Nr(Z.afterSanitizeElements,A,null),!1},go=function(A,_,ue){if(Re[_]||Ie&&(_==="id"||_==="name")&&(ue in t||ue in io))return!1;let $=Ye[_]||K.attributeCheck instanceof Function&&K.attributeCheck(_,A);if(!(it&&Gr(ye,_))){if(!(he&&Gr(Y,_))){if($){if(!ct[_]){if(!Gr(ae,Fs(ue,Oe,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&A!=="script"&&yh(ue,"data:")===0&&X[A])){if(!(Pt&&!Gr(ge,Fs(ue,Oe,"")))){if(ue)return!1}}}}}else if(!(Uo(A)&&(le.tagNameCheck instanceof RegExp&&Gr(le.tagNameCheck,A)||le.tagNameCheck instanceof Function&&le.tagNameCheck(A))&&(le.attributeNameCheck instanceof RegExp&&Gr(le.attributeNameCheck,_)||le.attributeNameCheck instanceof Function&&le.attributeNameCheck(_,A))||_==="is"&&le.allowCustomizedBuiltInElements&&(le.tagNameCheck instanceof RegExp&&Gr(le.tagNameCheck,ue)||le.tagNameCheck instanceof Function&&le.tagNameCheck(ue))))return!1}}return!0},on=Nt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Uo=function(A){return!on[qs(A)]&&Gr(ce,A)},nn=function(A,_,ue,$){if(v&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!ue)switch(f.getAttributeType(A,_)){case"TrustedHTML":return j($);case"TrustedScriptURL":return ie($)}return $},qo=function(A,_,ue,$){try{ue?A.setAttributeNS(ue,_,$):A.setAttribute(_,$),_r(A)?$r(A):hh(e.removed)}catch{mt(_,A)}},eo=function(A){Nr(Z.beforeSanitizeAttributes,A,null);let _=A.attributes;if(!_||_r(A))return;let ue={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ye,forceKeepAttr:void 0},$=_.length,at=je(A.nodeName);for(;$--;){let ut=_[$],U=ut.name,nr=ut.namespaceURI,mr=ut.value,Cr=je(U),ko=mr,sr=U==="value"?ko:d0(ko);if(ue.attrName=Cr,ue.attrValue=sr,ue.keepAttr=!0,ue.forceKeepAttr=void 0,Nr(Z.uponSanitizeAttribute,A,ue),sr=ue.attrValue,Je&&(Cr==="id"||Cr==="name")&&yh(sr,qe)!==0&&(mt(U,A),sr=qe+sr),Ar&&Gr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,sr)){mt(U,A);continue}if(Cr==="attributename"&&xh(sr,"href")){mt(U,A);continue}if(!ue.forceKeepAttr){if(!ue.keepAttr){mt(U,A);continue}if(!te&&Gr(L0,sr)){mt(U,A);continue}if(_e&&(sr=Vr(sr)),!go(at,Cr,sr)){mt(U,A);continue}sr=nn(at,Cr,nr,sr),sr!==ko&&qo(A,U,nr,sr)}}Nr(Z.afterSanitizeAttributes,A,null)},to=function(A){let _=null,ue=Wt(A);for(Nr(Z.beforeSanitizeShadowDOM,A,null);_=ue.nextNode();)if(Nr(Z.uponSanitizeShadowNode,_,null),Fr(_),eo(_),uo(_.content)&&to(_.content),(x?x(_):_.nodeType)===cn.element){let at=k(_);uo(at)&&(gt(at),to(at))}Nr(Z.afterSanitizeShadowDOM,A,null)},gt=function(A){let _=[{node:A,shadow:null}];for(;_.length>0;){let ue=_.pop();if(ue.shadow){to(ue.shadow);continue}let $=ue.node,ut=(x?x($):$.nodeType)===cn.element,U=T($);if(U)for(let nr=U.length-1;nr>=0;--nr)_.push({node:U[nr],shadow:null});if(ut){let nr=w?w($):null;if(typeof nr=="string"&&je(nr)==="template"){let mr=$.content;uo(mr)&&_.push({node:mr,shadow:null})}}if(ut){let nr=k($);uo(nr)&&_.push({node:null,shadow:nr},{node:nr,shadow:null})}}};return e.sanitize=function(re){let A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,ue=null,$=null,at=null;if(Pr=!re,Pr&&(re="<!-->"),typeof re!="string"&&!fo(re)&&(re=m0(re),typeof re!="string"))throw ma("dirty is not a string, aborting");if(!e.isSupported)return re;dr||lo(A),e.removed=[];let ut=lt&&typeof re!="string"&&fo(re);if(ut){let mr=w?w(re):re.nodeName;if(typeof mr=="string"){let Cr=je(mr);if(!Q[Cr]||nt[Cr])throw ma("root node is forbidden and cannot be sanitized in-place")}if(_r(re))throw ma("root node is clobbered and cannot be sanitized in-place");try{gt(re)}catch(Cr){throw Fo(re),Cr}}else if(fo(re))_=Or("<!---->"),ue=_.ownerDocument.importNode(re,!0),ue.nodeType===cn.element&&ue.nodeName==="BODY"||ue.nodeName==="HTML"?_=ue:_.appendChild(ue),gt(ue);else{if(!zr&&!_e&&!Rt&&re.indexOf("<")===-1)return v&&fe?j(re):re;if(_=Or(re),!_)return zr?null:fe?E:""}_&&Yr&&$r(_.firstChild);let U=Wt(ut?re:_);try{for(;$=U.nextNode();)Fr($),eo($),uo($.content)&&to($.content)}catch(mr){throw ut&&Fo(re),mr}if(ut)return Ns(e.removed,mr=>{mr.element&&po(mr.element)}),_e&&Zr(re),re;if(zr){if(_e&&Zr(_),O)for(at=Me.call(_.ownerDocument);_.firstChild;)at.appendChild(_.firstChild);else at=_;return(Ye.shadowroot||Ye.shadowrootmode)&&(at=Be.call(o,at,!0)),at}let nr=Rt?_.outerHTML:_.innerHTML;return Rt&&Q["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&Gr(T0,_.ownerDocument.doctype.name)&&(nr="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
|
|
49
|
+
`+nr),_e&&(nr=Vr(nr)),v&&fe?j(nr):nr},e.setConfig=function(){let re=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};lo(re),dr=!0},e.clearConfig=function(){Tr=null,dr=!1,v=H,E=""},e.isValidAttribute=function(re,A,_){Tr||lo({});let ue=je(re),$=je(A);return go(ue,$,_)},e.addHook=function(re,A){typeof A=="function"&&$a(Z[re],A)},e.removeHook=function(re,A){if(A!==void 0){let _=i0(Z[re],A);return _===-1?void 0:l0(Z[re],_,1)[0]}return hh(Z[re])},e.removeHooks=function(re){Z[re]=[]},e.removeAllHooks=function(){Z=kh()},e}var Rh=Ph();var I0={ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","hr","div","span","ul","ol","li","dl","dt","dd","strong","em","b","i","u","s","del","ins","mark","small","sub","sup","abbr","kbd","var","samp","code","a","img","blockquote","pre","details","summary","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","input","label","select","option","textarea","button"],ALLOWED_ATTR:["href","src","alt","title","target","rel","loading","width","height","colspan","rowspan","scope","class","id","type","name","value","placeholder","disabled","checked","for","aria-label","aria-hidden","aria-expanded","role","tabindex","data-tv-form","data-message-id","data-persona-component-directive","data-preserve-animation","data-persona-instance"]},H0=/^data:image\/(?:png|jpe?g|gif|webp|bmp|x-icon|avif)/i,Pd=()=>{let r=Rh(typeof window!="undefined"?window:void 0);return r.addHook("uponSanitizeAttribute",(e,t)=>{if(t.attrName==="src"||t.attrName==="href"){let o=t.attrValue;o.toLowerCase().startsWith("data:")&&!H0.test(o)&&(t.attrValue="",t.keepAttr=!1)}}),e=>r.sanitize(e,I0)},ja=r=>r===!1?null:typeof r=="function"?r:Pd();var Cn="webmcp:",Rd=new Map,Ih=r=>{var e;Rd.clear();for(let t of r){let o=(e=t.title)==null?void 0:e.trim();o&&Rd.set(t.name,o)}},Hd=r=>Rd.get(zi(r)),qi={warn(r,...e){typeof console!="undefined"&&typeof console.warn=="function"&&console.warn(`[Persona/WebMCP] ${r}`,...e)}},Id=null,Wh=r=>{Id=r};function Bh(r){if(r.length===0)return"0:empty";let e=r.map(t=>{var o,n;return[t.name,(o=t.description)!=null?o:"",t.parametersSchema?JSON.stringify(t.parametersSchema):"",(n=t.origin)!=null?n:"",t.annotations?JSON.stringify(t.annotations):""].join("")}).sort();return`${r.length}:${W0(e.join(""))}`}function Hh(r,e){let t=3735928559^e,o=1103547991^e;for(let n=0;n<r.length;n++){let a=r.charCodeAt(n);t=Math.imul(t^a,2654435761),o=Math.imul(o^a,1597334677)}return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(o^o>>>13,3266489909),o=Math.imul(o^o>>>16,2246822507),o^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&o)+(t>>>0)}function W0(r){let e=Hh(r,0).toString(36),t=Hh(r,2654435761).toString(36);return`${e}.${t}`}var Ga=class{constructor(e){this.config=e;this.installed=!1;this.readyPromise=null;this.incompatibleContextWarned=!1;var t;this.confirmHandler=(t=e.onConfirm)!=null?t:null,this.timeoutMs=3e4}setConfirmHandler(e){this.confirmHandler=e}isOperational(){return this.config.enabled!==!0||!this.installed?!1:this.getModelContext()!==null}async snapshotForDispatch(){if(await this.ensureReady(),this.config.enabled!==!0)return[];let e=this.getModelContext();if(!e)return[];let t;try{t=await e.getTools()}catch(n){return qi.warn("getTools() threw \u2014 shipping an empty WebMCP snapshot.",n),[]}Ih(t);let o=typeof location!="undefined"?location.origin:"";return t.filter(n=>this.passesClientAllowlist(n.name)).map(n=>{let a={name:n.name,description:n.description,origin:"webmcp",...o?{pageOrigin:o}:{}},s=D0(n.inputSchema);return s&&(a.parametersSchema=s),a})}async executeToolCall(e,t,o){if(await this.ensureReady(),this.config.enabled!==!0)return Zo("WebMCP is not enabled on this widget.");let n=this.getModelContext();if(!n){let y=typeof document!="undefined"&&!!document.modelContext;return Zo(y?"WebMCP is not operational: document.modelContext is present but does not expose the strict getTools()/executeTool() surface (likely a different or older WebMCP polyfill).":"WebMCP bridge is not operational on this page (document.modelContext not available).")}let a=zi(e),s;try{s=await n.getTools()}catch(y){let h=y instanceof Error?y.message:String(y);return Zo(`Failed to read WebMCP registry: ${h}`)}Ih(s);let i=s.find(y=>y.name===a);if(!i)return Zo(`WebMCP tool not registered on this page: ${a}`);if(!this.passesClientAllowlist(a))return Zo(`WebMCP tool not allowed by client allowlist: ${a}`);if(o!=null&&o.aborted)return Zo("Aborted by cancel()");let d=Hd(a),l={toolName:a,args:t,description:i.description,...d?{title:d}:{},reason:"gate"};if(!await this.requestConfirm(l))return Zo("User declined the tool call.");if(o!=null&&o.aborted)return Zo("Aborted by cancel()");let u=new AbortController,f=!1,p=setTimeout(()=>{f=!0,u.abort()},this.timeoutMs),m=()=>u.abort();o&&(o.aborted?u.abort():o.addEventListener("abort",m,{once:!0}));try{let y=await n.executeTool(i,F0(t),{signal:u.signal});return O0(y)}catch(y){if(f)return Zo(`WebMCP tool '${a}' timed out after ${this.timeoutMs}ms`);if(o!=null&&o.aborted)return Zo("Aborted by cancel()");let h=y instanceof Error?y.message:String(y);return Zo(h)}finally{clearTimeout(p),o&&o.removeEventListener("abort",m)}}ensureReady(){return this.config.enabled!==!0?Promise.resolve():(this.readyPromise||(this.readyPromise=this.install()),this.readyPromise)}async install(){try{if(this.getModelContext()){this.installed=!0;return}(Id?await Id():await import("@mcp-b/webmcp-polyfill")).initializeWebMCPPolyfill(),this.installed=!0}catch(e){qi.warn("Failed to load @mcp-b/webmcp-polyfill \u2014 WebMCP consumption disabled.",e),this.installed=!1}}getModelContext(){if(typeof document=="undefined")return null;let e=document.modelContext;if(!e||typeof e!="object")return null;let t=e;return typeof t.getTools!="function"||typeof t.executeTool!="function"?(this.incompatibleContextWarned||(this.incompatibleContextWarned=!0,qi.warn("document.modelContext is present but does not expose getTools()/executeTool() \u2014 WebMCP consumption is disabled. Another (incompatible or older) WebMCP polyfill likely installed document.modelContext before Persona. Remove it, or use a polyfill implementing the strict standard surface (e.g. @mcp-b/webmcp-polyfill).")),null):e}async requestConfirm(e){var o;let t=(o=this.confirmHandler)!=null?o:_0;try{return await t(e)}catch(n){return qi.warn(`Confirm handler threw for WebMCP tool '${e.toolName}'; declining.`,n),!1}}passesClientAllowlist(e){let t=this.config.allowlist;return!t||t.length===0?!0:t.some(o=>B0(e,o))}},zi=r=>r.startsWith(Cn)?r.slice(Cn.length):r,ga=r=>r.startsWith(Cn),B0=(r,e)=>{if(e==="*")return!0;let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return new RegExp("^"+t.replace(/\*/g,".*")+"$").test(r)},D0=r=>{if(!(r===void 0||r===""))try{let e=JSON.parse(r);return e!==null&&typeof e=="object"?e:void 0}catch{return}},O0=r=>{if(r==null)return{content:[{type:"text",text:""}]};let e;try{e=JSON.parse(r)}catch{return{content:[{type:"text",text:r}]}}return e!==null&&typeof e=="object"&&Array.isArray(e.content)?e:{content:[{type:"text",text:typeof e=="string"?e:U0(e)}]}},Zo=r=>({isError:!0,content:[{type:"text",text:r}]}),_0=async r=>{if(typeof window=="undefined"||typeof window.confirm!="function")return!1;let e=N0(r.args),t=`Allow the AI to call ${r.toolName}`+(e?`
|
|
49
50
|
|
|
50
51
|
Arguments:
|
|
51
52
|
${e}`:"")+(r.description?`
|
|
52
53
|
|
|
53
|
-
${r.description}`:"");return window.confirm(t)},v0=r=>{if(r==null)return"";try{let e=JSON.stringify(r,null,2);return e.length>500?e.slice(0,500)+"\u2026":e}catch{return String(r)}},C0=r=>{if(r===void 0)return"{}";try{let e=JSON.stringify(r);return e===void 0?"{}":e}catch{return"{}"}},w0=r=>{if(r===void 0)return"";try{return JSON.stringify(r)}catch{return String(r)}};var Do=Li(zi(),1);var v=(r,e)=>{let t=document.createElement(r);return e&&(t.className=e),t},ro=(r,e,t)=>{let n=r.createElement(e);return t&&(n.className=t),n};var Os="ask_user_question",Fs=8,Ua="data-persona-ask-sheet-for",k0="Other",E0="Other\u2026",Rh="Type your own answer here",Ih="Send",L0="Next",P0="Back",R0="Submit all",I0="Skip",H0=3,Hd="data-ask-current-index",Wd="data-ask-question-count",Hh="data-ask-answers",Bd="data-ask-grouped",Wh="data-ask-layout",W0=r=>r.layout==="pills"?"pills":"rows",B0=r=>r.getAttribute(Wh)==="pills"?"pills":"rows",Ph=!1,Bh=r=>r.replace(/["\\]/g,"\\$&"),ho=r=>r.variant==="tool"&&!!r.toolCall&&r.toolCall.name===Os,$i=r=>{var e,t;return(t=(e=r==null?void 0:r.features)==null?void 0:e.askUserQuestion)!=null?t:{}},xo=r=>{let e=r.toolCall;if(!e)return{payload:null,complete:!1};let t=e.status==="complete";if(e.args&&typeof e.args=="object")return{payload:e.args,complete:t};let n=e.chunks;if(!n||n.length===0)return{payload:null,complete:t};try{let o=n.join(""),a=(0,Do.parse)(o,Do.STR|Do.OBJ|Do.ARR);if(a&&typeof a=="object")return{payload:a,complete:t}}catch{}return{payload:null,complete:t}},Ns=r=>{let e=Array.isArray(r==null?void 0:r.questions)?r.questions:[];return e.length>Fs&&!Ph&&(Ph=!0,typeof console!="undefined"&&console.warn(`[AgentWidget] ask_user_question received ${e.length} questions; truncating to ${Fs}.`)),e.slice(0,Fs)},D0=r=>{var e;return(e=Ns(r)[0])!=null?e:null},F0=(r,e)=>{var t;return(t=Ns(r)[e])!=null?t:null},Dh=(r,e)=>{let t=e.styles;t&&(t.sheetBackground&&r.style.setProperty("--persona-ask-sheet-bg",t.sheetBackground),t.sheetBorder&&r.style.setProperty("--persona-ask-sheet-border",t.sheetBorder),t.sheetShadow&&r.style.setProperty("--persona-ask-sheet-shadow",t.sheetShadow),t.pillBackground&&r.style.setProperty("--persona-ask-pill-bg",t.pillBackground),t.pillBackgroundSelected&&r.style.setProperty("--persona-ask-pill-bg-selected",t.pillBackgroundSelected),t.pillTextColor&&r.style.setProperty("--persona-ask-pill-fg",t.pillTextColor),t.pillTextColorSelected&&r.style.setProperty("--persona-ask-pill-fg-selected",t.pillTextColorSelected),t.pillBorderRadius&&r.style.setProperty("--persona-ask-pill-radius",t.pillBorderRadius),t.customInputBackground&&r.style.setProperty("--persona-ask-input-bg",t.customInputBackground))},Fh=(r,e,t)=>{if(r!=="rows")return null;let n=v("span","persona-ask-row-affordance");if(n.setAttribute("aria-hidden","true"),e){let o=v("span","persona-ask-row-check");n.appendChild(o)}else{let o=v("span","persona-ask-row-badge");o.textContent=String(t+1),n.appendChild(o)}return n},O0=(r,e,t,n)=>{let a=v("button",t==="rows"?"persona-ask-pill persona-ask-row persona-pointer-events-auto":"persona-ask-pill persona-pointer-events-auto");if(a.type="button",a.setAttribute("role",n?"checkbox":"button"),a.setAttribute("aria-pressed","false"),a.setAttribute("data-ask-user-action","pick"),a.setAttribute("data-option-index",String(e)),a.setAttribute("data-option-label",r.label),t==="rows"){let s=v("span","persona-ask-row-content"),i=v("span","persona-ask-row-label");if(i.textContent=r.label,s.appendChild(i),r.description){let l=v("span","persona-ask-row-description");l.textContent=r.description,s.appendChild(l)}a.appendChild(s);let d=Fh(t,n,e);d&&a.appendChild(d)}else a.textContent=r.label,r.description&&(a.title=r.description);return a},N0=r=>{let t=v("span",r==="rows"?"persona-ask-pill persona-ask-row persona-ask-pill-skeleton persona-pointer-events-none":"persona-ask-pill persona-ask-pill-skeleton persona-pointer-events-none");return t.setAttribute("aria-hidden","true"),t},_0=(r,e,t,n)=>{var u,m,p;let a=v("div",n==="rows"?"persona-ask-pills persona-ask-pills--rows persona-flex persona-flex-col persona-gap-2":"persona-ask-pills persona-flex persona-flex-wrap persona-gap-2");a.setAttribute("role","group"),a.setAttribute("data-ask-pill-list","true");let s=!!(r!=null&&r.multiSelect),d=(Array.isArray(r==null?void 0:r.options)?r.options:[]).filter(f=>f&&typeof f.label=="string"&&f.label.length>0);if(d.length===0&&!t){for(let f=0;f<H0;f++)a.appendChild(N0(n));return a}if(d.forEach((f,b)=>{a.appendChild(O0(f,b,n,s))}),(r==null?void 0:r.allowFreeText)!==!1){let f=n==="rows"?k0:E0;if(n==="rows"){let b=v("div","persona-ask-pill persona-ask-row persona-ask-row--other persona-ask-pill-custom persona-pointer-events-auto");b.setAttribute("data-ask-user-action","focus-free-text"),b.setAttribute("data-option-index",String(d.length)),b.setAttribute("data-ask-other-row","true");let h=v("span","persona-ask-row-content"),S=document.createElement("input");S.type="text",S.className="persona-ask-row-input persona-flex-1 persona-pointer-events-auto",S.placeholder=(u=e.freeTextPlaceholder)!=null?u:Rh,S.setAttribute("data-ask-free-text-input","true"),S.setAttribute("aria-label",(m=e.freeTextLabel)!=null?m:f),h.appendChild(S),b.appendChild(h);let T=Fh(n,s,d.length);T&&b.appendChild(T),a.appendChild(b)}else{let b=v("button","persona-ask-pill persona-ask-pill-custom persona-pointer-events-auto");b.type="button",b.setAttribute("data-ask-user-action","open-free-text"),b.textContent=(p=e.freeTextLabel)!=null?p:f,a.appendChild(b)}}return a},Oh=(r,e)=>{var a,s;let n=v("div",e==="rows"?"persona-ask-free-text persona-ask-free-text--rows persona-flex persona-gap-2 persona-mt-2":"persona-ask-free-text persona-hidden persona-flex persona-gap-2 persona-mt-2");n.setAttribute("data-ask-free-text-row","true");let o=document.createElement("input");if(o.type="text",o.className="persona-ask-free-text-input persona-flex-1 persona-pointer-events-auto",o.placeholder=(a=r.freeTextPlaceholder)!=null?a:Rh,o.setAttribute("data-ask-free-text-input","true"),n.appendChild(o),e!=="rows"){let i=v("button","persona-ask-free-text-submit persona-pointer-events-auto");i.type="button",i.textContent=(s=r.submitLabel)!=null?s:Ih,i.setAttribute("data-ask-user-action","submit-free-text"),n.appendChild(i)}return n},U0=r=>{var n;let e=v("div","persona-ask-multi-actions persona-flex persona-justify-end persona-mt-2");e.setAttribute("data-ask-multi-actions","true");let t=v("button","persona-ask-multi-submit persona-pointer-events-auto");return t.type="button",t.textContent=(n=r.submitLabel)!=null?n:Ih,t.setAttribute("data-ask-user-action","submit-multi"),t.disabled=!0,e.appendChild(t),e},q0=(r,e,t)=>{var l,u,m,p;let n=v("div","persona-ask-nav persona-flex persona-justify-between persona-items-center persona-gap-2 persona-mt-2");n.setAttribute("data-ask-nav-row","true");let o=v("button","persona-ask-nav-back persona-pointer-events-auto");o.type="button",o.textContent=(l=t.backLabel)!=null?l:P0,o.setAttribute("data-ask-user-action","back"),o.disabled=r===0,n.appendChild(o);let a=v("div","persona-ask-nav-right persona-flex persona-items-center persona-gap-2"),s=v("button","persona-ask-nav-skip persona-pointer-events-auto");s.type="button",s.textContent=(u=t.skipLabel)!=null?u:I0,s.setAttribute("data-ask-user-action","skip"),a.appendChild(s);let i=v("button","persona-ask-nav-next persona-pointer-events-auto");i.type="button";let d=r===e-1;return i.textContent=d?(m=t.submitAllLabel)!=null?m:R0:(p=t.nextLabel)!=null?p:L0,i.setAttribute("data-ask-user-action",d?"submit-all":"next"),i.disabled=!0,a.appendChild(i),n.appendChild(a),n},ca=r=>{let e=r.getAttribute(Hh);if(!e)return{};try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}},Nh=(r,e)=>{r.setAttribute(Hh,JSON.stringify(e))},Wn=r=>{var t;let e=Number((t=r.getAttribute(Hd))!=null?t:"0");return Number.isFinite(e)?Math.max(0,Math.floor(e)):0},z0=(r,e)=>{r.setAttribute(Hd,String(Math.max(0,Math.floor(e))))},qa=r=>{var t;let e=Number((t=r.getAttribute(Wd))!=null?t:"1");return Number.isFinite(e)?Math.max(1,Math.floor(e)):1},Fo=r=>r.getAttribute(Bd)==="true",$0=(r,e)=>{var o;let t=(o=r.agentMetadata)==null?void 0:o.askUserQuestionAnswers;if(!t||typeof t!="object")return{};let n={};return e.forEach((a,s)=>{let i=typeof(a==null?void 0:a.question)=="string"?a.question:"";if(i&&Object.prototype.hasOwnProperty.call(t,i)){let d=t[i];(typeof d=="string"||Array.isArray(d))&&(n[s]=d)}}),n},V0=(r,e)=>{var n;let t=(n=r.agentMetadata)==null?void 0:n.askUserQuestionIndex;return typeof t!="number"||!Number.isFinite(t)?0:Math.max(0,Math.min(e-1,Math.floor(t)))},Vi=(r,e)=>{let{payload:t}=xo(e),n=Ns(t),o=ca(r),a={},s=new Set;return n.forEach((i,d)=>{let l=typeof(i==null?void 0:i.question)=="string"?i.question:"";l&&(s.has(l)&&typeof console!="undefined"&&console.warn(`[AgentWidget] ask_user_question has duplicate question text "${l}"; later answer wins.`),s.add(l),Object.prototype.hasOwnProperty.call(o,d)&&(a[l]=o[d]))}),a},_h=r=>{let e=ca(r),t=Wn(r),n=e[t],o=new Set;typeof n=="string"?o.add(n):Array.isArray(n)&&n.forEach(d=>o.add(d));let a=r.querySelectorAll('[data-ask-user-action="pick"][data-option-label]');a.forEach(d=>{var m;let l=(m=d.getAttribute("data-option-label"))!=null?m:"",u=o.has(l);d.setAttribute("aria-pressed",u?"true":"false"),d.classList.toggle("persona-ask-pill-selected",u)});let s=new Set(Array.from(a).map(d=>{var l;return(l=d.getAttribute("data-option-label"))!=null?l:""})),i=r.querySelector('[data-ask-free-text-input="true"]');if(i)if(typeof n=="string"&&n.length>0&&!s.has(n)){i.value=n;let d=i.closest('[data-ask-free-text-row="true"]');d==null||d.classList.remove("persona-hidden")}else i.value=""},Uh=r=>{if(!Fo(r))return;let e=ca(r),t=Wn(r),n=e[t],o=typeof n=="string"&&n.length>0||Array.isArray(n)&&n.length>0,a=r.querySelector('[data-ask-user-action="next"], [data-ask-user-action="submit-all"]');a&&(a.disabled=!o);let s=r.querySelector('[data-ask-user-action="submit-multi"]');if(s){let i=Array.from(r.querySelectorAll('[aria-pressed="true"][data-option-label]'));s.disabled=i.length===0}},Dd=(r,e,t)=>{let n=$i(t),o=B0(r),{payload:a,complete:s}=xo(e),i=Fo(r),d=Wn(r),l=qa(r),u=i?F0(a,d):D0(a),m=!!(u!=null&&u.multiSelect),p=r.querySelector('[data-ask-step-inline="true"]');p&&(p.textContent=i?`${d+1}/${l}`:"");let f=r.querySelector('[data-ask-stepper="true"]');f&&f.remove();let b=r.querySelector('[data-ask-question="true"]');if(b){let M=typeof(u==null?void 0:u.question)=="string"?u.question:"";b.textContent=M,b.classList.toggle("persona-ask-question-skeleton",!M&&!s)}let h=r.querySelector('[data-ask-pill-list="true"]');if(h){let M=_0(u,n,s,o);h.replaceWith(M)}if(o!=="rows"){let M=r.querySelector('[data-ask-free-text-row="true"]');M&&M.replaceWith(Oh(n,o))}let S=r.querySelector('[data-ask-multi-actions="true"]');!i&&m&&!S?r.appendChild(U0(n)):(!m||i)&&S&&S.remove(),r.setAttribute("data-multi-select",m?"true":"false");let T=r.querySelector('[data-ask-nav-row="true"]');if(i){let M=q0(d,l,n);T?T.replaceWith(M):r.appendChild(M)}else T&&T.remove();_h(r),Uh(r)},j0=(r,e,t)=>{let n=$i(e),o=W0(n),a=r.toolCall.id,s=Ns(t),i=Math.max(1,s.length),d=i>1,l=$0(r,s),u=d?V0(r,i):0,m=v("div",["persona-ask-sheet",`persona-ask-sheet--${o}`,"persona-pointer-events-auto","persona-ask-sheet-enter"].join(" "));m.setAttribute(Ua,a),m.setAttribute("data-tool-call-id",a),m.setAttribute("data-message-id",r.id),m.setAttribute(Wd,String(i)),m.setAttribute(Hd,String(u)),m.setAttribute(Bd,d?"true":"false"),m.setAttribute(Wh,o),Nh(m,l),m.setAttribute("role","group"),m.setAttribute("aria-label","Suggested answers"),n.slideInMs!==void 0&&m.style.setProperty("--persona-ask-sheet-duration",`${n.slideInMs}ms`),Dh(m,n);let p=v("div","persona-ask-sheet-header persona-flex persona-items-center persona-gap-3"),f=v("div","persona-ask-sheet-question persona-flex-1");f.setAttribute("data-ask-question","true"),f.textContent="",p.appendChild(f);let b=v("span","persona-ask-sheet-step-inline");b.setAttribute("data-ask-step-inline","true"),b.textContent="",p.appendChild(b),m.appendChild(p);let S=v("div",o==="rows"?"persona-ask-pills persona-ask-pills--rows persona-flex persona-flex-col persona-gap-2":"persona-ask-pills persona-flex persona-flex-wrap persona-gap-2");return S.setAttribute("data-ask-pill-list","true"),S.setAttribute("role","group"),m.appendChild(S),o!=="rows"&&m.appendChild(Oh(n,o)),Dd(m,r,e),requestAnimationFrame(()=>{requestAnimationFrame(()=>m.classList.remove("persona-ask-sheet-enter"))}),m},G0=(r,e,t)=>{let{payload:n}=xo(e),o=Math.max(1,Ns(n).length);o>qa(r)&&(r.setAttribute(Wd,String(o)),o>1&&!Fo(r)&&r.setAttribute(Bd,"true")),Dd(r,e,t)},qh=(r,e)=>{let t=v("div","persona-ask-stub persona-inline-flex persona-items-center persona-gap-2");t.id=`bubble-${r.id}`,t.setAttribute("data-message-id",r.id),t.setAttribute("data-bubble-type","ask-user-question");let n=$i(e);Dh(t,n);let o=v("span","persona-ask-stub-label"),{complete:a}=xo(r);return o.textContent=a?"Awaiting your response\u2026":"Preparing options\u2026",t.appendChild(o),t},za=(r,e,t)=>{if(!t||!ho(r)||$i(e).enabled===!1)return;let o=r.toolCall.id;t.querySelectorAll(`[${Ua}]`).forEach(l=>{l.getAttribute(Ua)!==o&&l.remove()});let s=t.querySelector(`[${Ua}="${Bh(o)}"]`);if(s){G0(s,r,e);return}let{payload:i}=xo(r),d=j0(r,e,i);t.appendChild(d)},Oo=(r,e)=>{if(!r)return;let t=e?`[${Ua}="${Bh(e)}"]`:`[${Ua}]`;r.querySelectorAll(t).forEach(o=>{o.classList.add("persona-ask-sheet-leave");let a=Number.parseInt(getComputedStyle(o).getPropertyValue("--persona-ask-sheet-duration")||"180",10);setTimeout(()=>o.remove(),Number.isFinite(a)?a:180)})},Fd=r=>Array.from(r.querySelectorAll('[aria-pressed="true"][data-option-label]')).map(e=>e.getAttribute("data-option-label")).filter(e=>typeof e=="string"&&e.length>0),No=(r,e)=>{let t=ca(r),n=Wn(r);typeof e=="string"&&e.length===0||Array.isArray(e)&&e.length===0?delete t[n]:t[n]=e,Nh(r,t),_h(r),Uh(r)},ji=(r,e,t,n)=>{let o=qa(r),a=Math.max(0,Math.min(o-1,n));z0(r,a),Dd(r,e,t)};var Vn="suggest_replies";var Od={type:"object",properties:{suggestions:{type:"array",minItems:1,maxItems:4,description:"1-4 short, distinct follow-up replies, phrased in the user's voice.",items:{type:"string",minLength:1,maxLength:60}}},required:["suggestions"],additionalProperties:!1},Gi={name:Vn,description:`Offer the user tappable quick-reply suggestions for their next message. Call at most once per turn, as the LAST action after your reply text is complete. Each suggestion is sent verbatim as the user's next message, so phrase suggestions in the user's voice (e.g. "Tell me more about pricing"). Keep them short and distinct. The result only confirms the suggestions were shown \u2014 do not add further commentary after calling this tool; end your turn.`,parametersSchema:Od,origin:"sdk",annotations:{readOnlyHint:!0}},Nd=()=>({content:[{type:"text",text:"Suggestions shown to the user."}]}),_s=r=>{var e;return r.variant==="tool"&&((e=r.toolCall)==null?void 0:e.name)===Vn},_d=r=>{let e=r;if(typeof e=="string")try{e=JSON.parse(e)}catch{return[]}let t=e==null?void 0:e.suggestions;if(!Array.isArray(t))return[];let n=t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>o.length>0);return n.length>4?(console.warn(`[persona] suggest_replies: ${n.length} suggestions exceeds the cap of 4; extra suggestions dropped.`),n.slice(0,4)):n},Ki=r=>{var e;for(let t=r.length-1;t>=0;t--){let n=r[t];if(n.role==="user")return null;if(!_s(n))continue;let o=_d((e=n.toolCall)==null?void 0:e.args);return o.length>0?o:null}return null},zh=r=>{var t;let e=(t=r==null?void 0:r.features)==null?void 0:t.suggestReplies;return(e==null?void 0:e.expose)===!0&&e.enabled!==!1};var Ud={type:"object",properties:{questions:{type:"array",minItems:1,maxItems:Fs,description:"Questions to ask the user. Prefer a single question.",items:{type:"object",properties:{question:{type:"string",description:"The complete question, ending with a question mark."},header:{type:"string",maxLength:12,description:'Short topic label, e.g. "Auth method".'},options:{type:"array",minItems:2,maxItems:4,description:'2-4 distinct choices. Do NOT add an "Other" option \u2014 free text is automatic.',items:{type:"object",properties:{label:{type:"string",description:"Concise choice text (1-5 words)."},description:{type:"string",description:"What the option means or implies."}},required:["label"],additionalProperties:!1}},multiSelect:{type:"boolean",description:"Allow selecting multiple options. Default false."},allowFreeText:{type:"boolean",description:"Show a free-text input. Default true."}},required:["question","options"],additionalProperties:!1}}},required:["questions"],additionalProperties:!1},qd={name:Os,description:"Ask the user multiple-choice questions and wait for their answers. Use only when blocked on a decision that is the user's to make \u2014 a preference, a choice between valid approaches, or information you cannot infer. Each question offers 2-4 options plus an automatic free-text input. The result maps each question to its answer (an array when multiSelect); a question absent from the result was skipped.",parametersSchema:Ud,origin:"sdk",annotations:{readOnlyHint:!0}},Us=r=>{var n;let e=[],t=(n=r==null?void 0:r.features)==null?void 0:n.askUserQuestion;return(t==null?void 0:t.expose)===!0&&t.enabled!==!1&&e.push(qd),zh(r)&&e.push(Gi),e};var bo=Li(zi(),1),Xi=r=>r.replace(/\\n/g,`
|
|
54
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")
|
|
55
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}catch{return a[1]}let s=/"text"\s*:\s*"((?:[^"\\]|\\.)*)/,i=
|
|
56
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}catch{return i[1]}return null};return{getExtractedText:()=>r,processChunk:async n=>{if(n.length<=e)return r!==null?{text:r,raw:n}:null;let o=n.trim();if(!o.startsWith("{")&&!o.startsWith("["))return null;let a=t(n);return a!==null&&(r=a),e=n.length,r!==null?{text:r,raw:n}:null},close:async()=>{}}},pa=r=>{try{let e=JSON.parse(r);if(e&&typeof e=="object"&&typeof e.text=="string")return e.text}catch{return null}return null},Zi=()=>{let r={processChunk:e=>null,getExtractedText:()=>null};return r.__isPlainTextParser=!0,r},el=()=>{var e;let r=Q0();return{processChunk:async t=>{let n=t.trim();return!n.startsWith("{")&&!n.startsWith("[")?null:r.processChunk(t)},getExtractedText:r.getExtractedText.bind(r),close:(e=r.close)==null?void 0:e.bind(r)}},tl=()=>{let r=null,e=0;return{getExtractedText:()=>r,processChunk:t=>{let n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;if(t.length<=e)return r!==null||r===""?{text:r||"",raw:t}:null;try{let o=(0,bo.parse)(t,bo.STR|bo.OBJ);o&&typeof o=="object"&&(o.component&&typeof o.component=="string"?r=typeof o.text=="string"?Xi(o.text):"":o.type==="init"&&o.form?r="":typeof o.text=="string"&&(r=Xi(o.text)))}catch{}return e=t.length,r!==null?{text:r,raw:t}:null},close:()=>{}}},jh=r=>{let e=null,t=0,o=r||(a=>{if(!a||typeof a!="object")return null;let s=i=>typeof i=="string"?Xi(i):null;if(a.component&&typeof a.component=="string")return typeof a.text=="string"?Xi(a.text):"";if(a.type==="init"&&a.form)return"";if(a.action)switch(a.action){case"nav_then_click":return s(a.on_load_text)||s(a.text)||null;case"message":case"message_and_click":case"checkout":return s(a.text)||null;default:return s(a.text)||s(a.display_text)||s(a.message)||null}return s(a.text)||s(a.display_text)||s(a.message)||s(a.content)||null});return{getExtractedText:()=>e,processChunk:a=>{let s=a.trim();if(!s.startsWith("{")&&!s.startsWith("["))return null;if(a.length<=t)return e!==null?{text:e,raw:a}:null;try{let i=(0,bo.parse)(a,bo.STR|bo.OBJ),d=o(i);d!==null&&(e=d)}catch{}return t=a.length,{text:e||"",raw:a}},close:()=>{}}},rl=()=>{let r=null;return{processChunk:e=>{if(!e.trim().startsWith("<"))return null;let n=e.match(/<text[^>]*>([\s\S]*?)<\/text>/);return n&&n[1]?(r=n[1],{text:r,raw:e}):null},getExtractedText:()=>r}};var nl=class{constructor(e,t=50){this.nextExpectedSeq=null;this.buffer=new Map;this.flushTimer=null;this.emitter=e,this.gapTimeoutMs=t}push(e,t){var a,s,i;let n=(i=(a=t==null?void 0:t.seq)!=null?a:t==null?void 0:t.sequenceIndex)!=null?i:(s=t==null?void 0:t.agentContext)==null?void 0:s.seq;if(n==null){this.buffer.size>0&&this.flushAll(),this.emitter(e,t);return}if(this.nextExpectedSeq===null&&(this.nextExpectedSeq=1),n===this.nextExpectedSeq){this.emitter(e,t),this.nextExpectedSeq=n+1,this.drainConsecutive();return}if(n<this.nextExpectedSeq){this.emitter(e,t);return}let o=this.buffer.get(n);o!==void 0&&(typeof console!="undefined"&&typeof console.warn=="function"&&console.warn(`[persona] SequenceReorderBuffer: duplicate seq=${n} (${o.payloadType} vs ${e}); emitting earlier event out-of-order to avoid loss`),this.emitter(o.payloadType,o.payload)),this.buffer.set(n,{payloadType:e,payload:t,seq:n}),this.startGapTimer()}drainConsecutive(){for(;this.buffer.has(this.nextExpectedSeq);){let e=this.buffer.get(this.nextExpectedSeq);this.buffer.delete(this.nextExpectedSeq),this.emitter(e.payloadType,e.payload),this.nextExpectedSeq++}this.buffer.size===0&&this.clearGapTimer()}startGapTimer(){this.flushTimer===null&&(this.flushTimer=setTimeout(()=>{this.flushAll()},this.gapTimeoutMs))}clearGapTimer(){this.flushTimer!==null&&(clearTimeout(this.flushTimer),this.flushTimer=null)}flushAll(){if(this.clearGapTimer(),this.buffer.size===0)return;let e=[...this.buffer.entries()].sort((t,n)=>t[0]-n[0]);for(let[t,n]of e)this.buffer.delete(t),this.emitter(n.payloadType,n.payload);e.length>0&&(this.nextExpectedSeq=e[e.length-1][0]+1)}destroy(){this.clearGapTimer(),this.buffer.clear()}flushPending(){this.flushAll()}};var J0="https://api.runtype.com/v1/dispatch",ol="https://api.runtype.com";function Y0(r){var a,s;let e=r.toLowerCase(),n={"application/pdf":"pdf","application/json":"json","application/zip":"zip","text/plain":"txt","text/csv":"csv","text/markdown":"md"}[e];if(n)return`attachment.${n}`;let o=e.indexOf("/");if(o>0){let i=(s=(a=e.slice(o+1).split(";")[0])==null?void 0:a.trim())!=null?s:"";if(i&&i!=="octet-stream"&&/^[a-z0-9.+-]+$/i.test(i))return`attachment.${i}`}return"attachment"}var $d=r=>!!(r.contentParts&&r.contentParts.length>0||r.llmContent&&r.llmContent.trim().length>0||r.rawContent&&r.rawContent.trim().length>0||r.content&&r.content.trim().length>0);function Z0(r){switch(r){case"json":return tl;case"regex-json":return el;case"xml":return rl;default:return Zi}}var Gh=r=>r.startsWith("{")||r.startsWith("[")||r.startsWith("<");function ev(r,e){if(!r)return e;let t=r.trim(),n=e.trim();if(t.length===0)return e;if(n.length===0)return r;let o=Gh(t);if(!Gh(n))return r;if(!o||n===t||n.startsWith(t))return e;let s=pa(r);return pa(e)!==null&&s===null?e:r}var ua=class{constructor(e={}){this.config=e;this.clientSession=null;this.sessionInitPromise=null;this.lastSentClientToolsFingerprint=null;this.clientToolsFingerprintSessionId=null;var t,n,o,a;this.apiUrl=(t=e.apiUrl)!=null?t:J0,this.headers={"Content-Type":"application/json",...e.headers},this.debug=!!e.debug,this.createStreamParser=(n=e.streamParser)!=null?n:Z0(e.parserType),this.contextProviders=(o=e.contextProviders)!=null?o:[],this.requestMiddleware=e.requestMiddleware,this.customFetch=e.customFetch,this.parseSSEEvent=e.parseSSEEvent,this.getHeaders=e.getHeaders,this.webMcpBridge=((a=e.webmcp)==null?void 0:a.enabled)===!0?new _a(e.webmcp):null}updateConfig(e){this.config=e}setSSEEventCallback(e){this.onSSEEvent=e}setWebMcpConfirmHandler(e){var t;(t=this.webMcpBridge)==null||t.setConfirmHandler(e)}isWebMcpOperational(){var e;return((e=this.webMcpBridge)==null?void 0:e.isOperational())===!0}executeWebMcpToolCall(e,t,n){return this.webMcpBridge?this.webMcpBridge.executeToolCall(e,t,n):null}getSSEEventCallback(){return this.onSSEEvent}isClientTokenMode(){return!!this.config.clientToken}isAgentMode(){return!!this.config.agent}getClientApiUrl(e){var n;return`${((n=this.config.apiUrl)==null?void 0:n.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||ol}/v1/client/${e}`}getClientSession(){return this.clientSession}async initSession(){var e,t;if(!this.isClientTokenMode())throw new Error("initSession() only available in client token mode");if(this.clientSession&&new Date<this.clientSession.expiresAt)return this.clientSession;if(this.sessionInitPromise)return this.sessionInitPromise;this.sessionInitPromise=this._doInitSession();try{let n=await this.sessionInitPromise;return this.clientSession=n,this.resetClientToolsFingerprint(),(t=(e=this.config).onSessionInit)==null||t.call(e,n),n}finally{this.sessionInitPromise=null}}async _doInitSession(){var a,s;let e=((s=(a=this.config).getStoredSessionId)==null?void 0:s.call(a))||null,t={token:this.config.clientToken,...this.config.flowId&&{flowId:this.config.flowId},...e&&{sessionId:e}},n=await fetch(this.getClientApiUrl("init"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){let i=await n.json().catch(()=>({error:"Session initialization failed"}));throw n.status===401?new Error(`Invalid client token: ${i.hint||i.error}`):n.status===403?new Error(`Origin not allowed: ${i.hint||i.error}`):new Error(i.error||"Failed to initialize session")}let o=await n.json();return this.config.setStoredSessionId&&this.config.setStoredSessionId(o.sessionId),{sessionId:o.sessionId,expiresAt:new Date(o.expiresAt),flow:o.flow,config:{welcomeMessage:o.config.welcomeMessage,placeholder:o.config.placeholder,theme:o.config.theme}}}clearClientSession(){this.clientSession=null,this.sessionInitPromise=null,this.resetClientToolsFingerprint()}resetClientToolsFingerprint(){this.lastSentClientToolsFingerprint=null,this.clientToolsFingerprintSessionId=null}getFeedbackApiUrl(){var t;return`${((t=this.config.apiUrl)==null?void 0:t.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||ol}/v1/client/feedback`}async sendFeedback(e){var a,s;if(!this.isClientTokenMode())throw new Error("sendFeedback() only available in client token mode");if(!this.getClientSession())throw new Error("No active session. Please initialize session first.");if(["upvote","downvote","copy"].includes(e.type)&&!e.messageId)throw new Error(`messageId is required for ${e.type} feedback type`);if(e.type==="csat"&&(e.rating===void 0||e.rating<1||e.rating>5))throw new Error("CSAT rating must be between 1 and 5");if(e.type==="nps"&&(e.rating===void 0||e.rating<0||e.rating>10))throw new Error("NPS rating must be between 0 and 10");this.debug&&console.debug("[AgentWidgetClient] sending feedback",e);let o=await fetch(this.getFeedbackApiUrl(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok){let i=await o.json().catch(()=>({error:"Feedback submission failed"}));throw o.status===401?(this.clientSession=null,(s=(a=this.config).onSessionExpired)==null||s.call(a),new Error("Session expired. Please refresh to continue.")):new Error(i.error||"Failed to submit feedback")}}async submitMessageFeedback(e,t){let n=this.getClientSession();if(!n)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:n.sessionId,messageId:e,type:t})}async submitCSATFeedback(e,t){let n=this.getClientSession();if(!n)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:n.sessionId,type:"csat",rating:e,comment:t})}async submitNPSFeedback(e,t){let n=this.getClientSession();if(!n)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:n.sessionId,type:"nps",rating:e,comment:t})}async dispatch(e,t){return this.isAgentMode()?this.dispatchAgent(e,t):this.isClientTokenMode()?this.dispatchClientToken(e,t):this.dispatchProxy(e,t)}async dispatchClientToken(e,t){var o,a,s,i;let n=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>n.abort()),t({type:"status",status:"connecting"});try{let d=await this.initSession();if(new Date>=new Date(d.expiresAt.getTime()-6e4)){this.clearClientSession(),(a=(o=this.config).onSessionExpired)==null||a.call(o);let x=new Error("Session expired. Please refresh to continue.");throw t({type:"error",error:x}),x}let l=await this.buildPayload(e.messages),u=l.metadata?Object.fromEntries(Object.entries(l.metadata).filter(([x])=>x!=="sessionId"&&x!=="session_id")):void 0,m={sessionId:d.sessionId,messages:e.messages.filter($d).map(x=>{var C,w,E;return{id:x.id,role:x.role,content:(E=(w=(C=x.contentParts)!=null?C:x.llmContent)!=null?w:x.rawContent)!=null?E:x.content}}),...e.assistantMessageId&&{assistantMessageId:e.assistantMessageId},...u&&Object.keys(u).length>0&&{metadata:u},...l.inputs&&Object.keys(l.inputs).length>0&&{inputs:l.inputs},...l.context&&{context:l.context}},p=l.clientTools,f=!!(p&&p.length>0),b=f?Eh(p):void 0,h=this.clientToolsFingerprintSessionId===d.sessionId,S=f&&h&&this.lastSentClientToolsFingerprint===b,T=!1,M=null,k;for(let x=0;;x++){let w={...m,...f&&(T||!S)&&p?{clientTools:p}:{},...b?{clientToolsFingerprint:b}:{}};if(this.debug&&console.debug("[AgentWidgetClient] client token dispatch",w),k=await fetch(this.getClientApiUrl("chat"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w),signal:n.signal}),k.status===409&&x===0&&f){let E=await k.json().catch(()=>null);if((E==null?void 0:E.error)==="client_tools_resend_required"){T=!0,this.lastSentClientToolsFingerprint=null;continue}M=E!=null?E:{error:"Chat request failed"}}break}if(!k.ok){let x=M!=null?M:await k.json().catch(()=>({error:"Chat request failed"}));if(k.status===401){this.clearClientSession(),(i=(s=this.config).onSessionExpired)==null||i.call(s);let w=new Error("Session expired. Please refresh to continue.");throw t({type:"error",error:w}),w}if(k.status===429){let w=new Error(x.hint||"Message limit reached for this session.");throw t({type:"error",error:w}),w}let C=new Error(x.error||"Failed to send message");throw t({type:"error",error:C}),C}if(!k.body){let x=new Error("No response body received");throw t({type:"error",error:x}),x}this.lastSentClientToolsFingerprint=b!=null?b:null,this.clientToolsFingerprintSessionId=d.sessionId,t({type:"status",status:"connected"});try{await this.streamResponse(k.body,t,e.assistantMessageId)}finally{t({type:"status",status:"idle"})}}catch(d){let l=d instanceof Error?d:new Error(String(d));throw!l.message.includes("Session expired")&&!l.message.includes("Message limit")&&t({type:"error",error:l}),l}}async dispatchProxy(e,t){let n=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>n.abort()),t({type:"status",status:"connecting"});let o=await this.buildPayload(e.messages);this.debug&&console.debug("[AgentWidgetClient] dispatch payload",o);let a={...this.headers};if(this.getHeaders)try{let i=await this.getHeaders();a={...a,...i}}catch(i){typeof console!="undefined"&&console.error("[AgentWidget] getHeaders error:",i)}let s;if(this.customFetch)try{s=await this.customFetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(o),signal:n.signal},o)}catch(i){let d=i instanceof Error?i:new Error(String(i));throw t({type:"error",error:d}),d}else s=await fetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(o),signal:n.signal});if(!s.ok||!s.body){let i=new Error(`Chat backend request failed: ${s.status} ${s.statusText}`);throw t({type:"error",error:i}),i}t({type:"status",status:"connected"});try{await this.streamResponse(s.body,t)}finally{t({type:"status",status:"idle"})}}async dispatchAgent(e,t){let n=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>n.abort()),t({type:"status",status:"connecting"});let o=await this.buildAgentPayload(e.messages);this.debug&&console.debug("[AgentWidgetClient] agent dispatch payload",o);let a={...this.headers};if(this.getHeaders)try{let i=await this.getHeaders();a={...a,...i}}catch(i){typeof console!="undefined"&&console.error("[AgentWidget] getHeaders error:",i)}let s;if(this.customFetch)try{s=await this.customFetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(o),signal:n.signal},o)}catch(i){let d=i instanceof Error?i:new Error(String(i));throw t({type:"error",error:d}),d}else s=await fetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(o),signal:n.signal});if(!s.ok||!s.body){let i=new Error(`Agent execution request failed: ${s.status} ${s.statusText}`);throw t({type:"error",error:i}),i}t({type:"status",status:"connected"});try{await this.streamResponse(s.body,t,e.assistantMessageId)}finally{t({type:"status",status:"idle"})}}async processStream(e,t,n){t({type:"status",status:"connected"});try{await this.streamResponse(e,t,n)}finally{t({type:"status",status:"idle"})}}async resolveApproval(e,t){var s;let o=`${((s=this.config.apiUrl)==null?void 0:s.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||ol}/v1/agents/${e.agentId}/approve`,a={"Content-Type":"application/json",...this.headers};return this.getHeaders&&Object.assign(a,await this.getHeaders()),fetch(o,{method:"POST",headers:a,body:JSON.stringify({executionId:e.executionId,approvalId:e.approvalId,decision:t,streamResponse:!0})})}async resumeFlow(e,t,n){var l,u;let o=this.isClientTokenMode(),a=o?this.getClientApiUrl("resume"):`${((l=this.config.apiUrl)==null?void 0:l.replace(/\/+$/,""))||ol}/resume`,s;o&&(s=(await this.initSession()).sessionId);let i={"Content-Type":"application/json",...this.headers};this.getHeaders&&Object.assign(i,await this.getHeaders());let d={executionId:e,toolOutputs:t,streamResponse:(u=n==null?void 0:n.streamResponse)!=null?u:!0};return s&&(d.sessionId=s),fetch(a,{method:"POST",headers:i,body:JSON.stringify(d),signal:n==null?void 0:n.signal})}async buildAgentPayload(e){var a,s;if(!this.config.agent)throw new Error("Agent configuration required for agent mode");let t=e.slice().filter($d).filter(i=>i.role==="user"||i.role==="assistant"||i.role==="system").filter(i=>!i.variant||i.variant==="assistant").sort((i,d)=>{let l=new Date(i.createdAt).getTime(),u=new Date(d.createdAt).getTime();return l-u}).map(i=>{var d,l,u;return{role:i.role,content:(u=(l=(d=i.contentParts)!=null?d:i.llmContent)!=null?l:i.rawContent)!=null?u:i.content,createdAt:i.createdAt}}),n={agent:this.config.agent,messages:t,options:{streamResponse:!0,recordMode:"virtual",...this.config.agentOptions}},o=[...Us(this.config),...(s=await((a=this.webMcpBridge)==null?void 0:a.snapshotForDispatch()))!=null?s:[]];if(o.length>0&&(n.clientTools=o),this.contextProviders.length){let i={};await Promise.all(this.contextProviders.map(async d=>{try{let l=await d({messages:e,config:this.config});l&&typeof l=="object"&&Object.assign(i,l)}catch(l){typeof console!="undefined"&&console.warn("[AgentWidget] Context provider failed:",l)}})),Object.keys(i).length&&(n.context=i)}return n}async buildPayload(e){var a,s;let n={messages:e.slice().filter($d).sort((i,d)=>{let l=new Date(i.createdAt).getTime(),u=new Date(d.createdAt).getTime();return l-u}).map(i=>{var d,l,u;return{role:i.role,content:(u=(l=(d=i.contentParts)!=null?d:i.llmContent)!=null?l:i.rawContent)!=null?u:i.content,createdAt:i.createdAt}}),...this.config.flowId&&{flowId:this.config.flowId}},o=[...Us(this.config),...(s=await((a=this.webMcpBridge)==null?void 0:a.snapshotForDispatch()))!=null?s:[]];if(o.length>0&&(n.clientTools=o),this.contextProviders.length){let i={};await Promise.all(this.contextProviders.map(async d=>{try{let l=await d({messages:e,config:this.config});l&&typeof l=="object"&&Object.assign(i,l)}catch(l){typeof console!="undefined"&&console.warn("[AgentWidget] Context provider failed:",l)}})),Object.keys(i).length&&(n.context=i)}if(this.requestMiddleware)try{let i=await this.requestMiddleware({payload:{...n},config:this.config});if(i&&typeof i=="object"){let d=i;return n.clientTools!==void 0&&!("clientTools"in d)&&(d.clientTools=n.clientTools),d}}catch(i){typeof console!="undefined"&&console.error("[AgentWidget] Request middleware error:",i)}return n}async handleCustomSSEEvent(e,t,n,o,a,s){if(!this.parseSSEEvent)return!1;try{let i=await this.parseSSEEvent(e);if(i===null)return!1;let d=u=>{let m={id:`assistant-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"assistant",sequence:a(),...u!==void 0&&{partId:u}};return n.current=m,o(m),m},l=u=>n.current?n.current:d(u);if(i.text!==void 0){i.partId!==void 0&&s.current!==null&&i.partId!==s.current&&(n.current&&(n.current.streaming=!1,o(n.current)),d(i.partId)),i.partId!==void 0&&(s.current=i.partId);let u=l(i.partId);i.partId!==void 0&&!u.partId&&(u.partId=i.partId),u.content+=i.text,o(u)}return i.done&&(n.current&&(n.current.streaming=!1,o(n.current)),s.current=null,t({type:"status",status:"idle"})),i.error&&(s.current=null,t({type:"error",error:new Error(i.error)})),!0}catch(i){return typeof console!="undefined"&&console.error("[AgentWidget] parseSSEEvent error:",i),!1}}async streamResponse(e,t,n){var Bt,or,hr,sn;let o=e.getReader(),a=new TextDecoder,s="",i=Date.now(),d=0,l=()=>i+d++,u=F=>{let fe=F.reasoning?{...F.reasoning,chunks:[...F.reasoning.chunks]}:void 0,Ie=F.toolCall?{...F.toolCall,chunks:F.toolCall.chunks?[...F.toolCall.chunks]:void 0}:void 0,Xe=F.tools?F.tools.map(Fe=>({...Fe,chunks:Fe.chunks?[...Fe.chunks]:void 0})):void 0;return{...F,reasoning:fe,toolCall:Ie,tools:Xe}},m=F=>{if(F.role!=="assistant"||F.variant)return!0;let fe=Array.isArray(F.contentParts)&&F.contentParts.length>0,Ie=typeof F.rawContent=="string"&&F.rawContent.trim()!=="";return typeof F.content=="string"&&F.content.trim()!==""||fe||Ie||!!F.stopReason},p=F=>{m(F)&&t({type:"message",message:u(F)})},f=null,b=null,h={current:null},S={current:null},T=!1,M=new Map,k=new Map,x=new Map,C=new Map,w={lastId:null,byStep:new Map},E={lastId:null,byCall:new Map},H=(F,fe,Ie="")=>`${F}::${fe}::${Ie}`,I=(F,fe)=>`${F}::${fe}::`,L=(F,fe,Ie,Xe)=>{let Fe=H(F,fe,Ie),Ne=x.get(Fe);if(Ne)return Ne;let Ye=Ie?`-${Ie}`:"",At={id:`nested-${F}-${fe}${Ye}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l(),...Ie?{partId:Ie}:{},agentMetadata:{executionId:Xe,parentToolId:F,parentStepId:fe}};return x.set(Fe,At),p(At),At},O=F=>{if(F==null)return null;try{return String(F)}catch{return null}},$=F=>{var fe,Ie,Xe,Fe,Ne;return O((Ne=(Fe=(Xe=(Ie=(fe=F.stepId)!=null?fe:F.step_id)!=null?Ie:F.step)!=null?Xe:F.parentId)!=null?Fe:F.flowStepId)!=null?Ne:F.flow_step_id)},te=F=>{var fe,Ie,Xe,Fe,Ne,Ye,At;return O((At=(Ye=(Ne=(Fe=(Xe=(Ie=(fe=F.callId)!=null?fe:F.call_id)!=null?Ie:F.requestId)!=null?Xe:F.request_id)!=null?Fe:F.toolCallId)!=null?Ne:F.tool_call_id)!=null?Ye:F.stepId)!=null?At:F.step_id)},xe=n,Je=!1,we=()=>{if(f)return f;let F;return!Je&&xe?(F=xe,Je=!0):xe&&S.current?F=`${xe}_${S.current}`:F=`assistant-${Date.now()}-${Math.random().toString(16).slice(2)}`,f={id:F,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l()},p(f),f},De=(F,fe)=>{w.lastId=fe,F&&w.byStep.set(F,fe)},Ae=(F,fe)=>{var Ne;let Ie=(Ne=F.reasoningId)!=null?Ne:F.id,Xe=$(F);if(Ie){let Ye=String(Ie);return De(Xe,Ye),Ye}if(Xe){let Ye=w.byStep.get(Xe);if(Ye)return w.lastId=Ye,Ye}if(w.lastId&&!fe)return w.lastId;if(!fe)return null;let Fe=`reason-${l()}`;return De(Xe,Fe),Fe},qe=F=>{let fe=M.get(F);if(fe)return fe;let Ie={id:`reason-${F}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"reasoning",sequence:l(),reasoning:{id:F,status:"streaming",chunks:[]}};return M.set(F,Ie),p(Ie),Ie},He=(F,fe)=>{E.lastId=fe,F&&E.byCall.set(F,fe)},J=new Set,re=new Map,Q=new Set,ge=new Map,Z=F=>{if(!F)return!1;let fe=F.replace(/_+/g,"_").replace(/^_|_$/g,"");return fe==="emit_artifact_markdown"||fe==="emit_artifact_component"},G=(F,fe)=>{var Ne;let Ie=(Ne=F.toolId)!=null?Ne:F.id,Xe=te(F);if(Ie){let Ye=String(Ie);return He(Xe,Ye),Ye}if(Xe){let Ye=E.byCall.get(Xe);if(Ye)return E.lastId=Ye,Ye}if(E.lastId&&!fe)return E.lastId;if(!fe)return null;let Fe=`tool-${l()}`;return He(Xe,Fe),Fe},pe=F=>{let fe=k.get(F);if(fe)return fe;let Ie={id:`tool-${F}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"tool",sequence:l(),toolCall:{id:F,status:"pending"}};return k.set(F,Ie),p(Ie),Ie},ke=F=>{if(typeof F=="number"&&Number.isFinite(F))return F;if(typeof F=="string"){let fe=Number(F);if(!Number.isNaN(fe)&&Number.isFinite(fe))return fe;let Ie=Date.parse(F);if(!Number.isNaN(Ie))return Ie}return Date.now()},le=F=>{if(typeof F=="string")return F;if(F==null)return"";try{return JSON.stringify(F)}catch{return String(F)}},ne=new Map,de=new Map,Et=new Map,wt=new Map,We=null,he=(F,fe,Ie)=>{var At;let Xe=Et.get(F);Xe||(Xe=[],Et.set(F,Xe));let Fe=0,Ne=Xe.length;for(;Fe<Ne;){let Xt=Fe+Ne>>>1;Xe[Xt].seq<fe?Fe=Xt+1:Ne=Xt}((At=Xe[Fe])==null?void 0:At.seq)===fe?Xe[Fe]={seq:fe,text:Ie}:Xe.splice(Fe,0,{seq:fe,text:Ie});let Ye="";for(let Xt=0;Xt<Xe.length;Xt++)Ye+=Xe[Xt].text;return Ye},at=(F,fe)=>{let Ie=le(fe),Xe=de.get(F.id),Fe=ev(Xe,Ie);F.rawContent=Fe;let Ne=ne.get(F.id),Ye=mt=>{var ye;let it=(ye=F.content)!=null?ye:"";mt.trim()!==""&&(it.trim().length===0||mt.startsWith(it)||mt.trimStart().startsWith(it.trim()))&&(F.content=mt)},At=()=>{var mt;if(Ne){let it=(mt=Ne.close)==null?void 0:mt.call(Ne);it instanceof Promise&&it.catch(()=>{})}ne.delete(F.id),de.delete(F.id),F.streaming=!1,p(F)};if(!Ne){Ye(Ie),At();return}let Xt=pa(Fe);if(Xt!==null&&Xt.trim()!==""){Ye(Xt),At();return}let ar=mt=>{var ie;let it=typeof mt=="string"?mt:(ie=mt==null?void 0:mt.text)!=null?ie:null;if(it!==null&&it.trim()!=="")return it;let ye=Ne.getExtractedText();return ye!==null&&ye.trim()!==""?ye:Ie},K;try{K=Ne.processChunk(Fe)}catch{Ye(Ie),At();return}if(K instanceof Promise){K.then(mt=>{Ye(ar(mt)),At()}).catch(()=>{Ye(Ie),At()});return}Ye(ar(K)),At()},Re=[],j=!1,ue,nt=()=>{j||(j=!0,queueMicrotask(()=>{j=!1,ue()}))},Rt=new nl((F,fe)=>{Re.push({payloadType:F,payload:fe}),nt()}),ee=null,Ge=new Map,Fr=(Bt=this.config.iterationDisplay)!=null?Bt:"separate";for(ue=()=>{var F,fe,Ie,Xe,Fe,Ne,Ye,At,Xt,ar,K,mt,it,ye,ie,st,pr,pt,yr,Rr,ut,Lt,tt,zt,vr,sr,ur,Mr,un,St,qr,xr,Mn,ln,yt,Gn,kn,_e,R,se,Ee,Ot,et,Nt,Yt,lr,vt,zr,$t,$r,Dn,oo,Ao,fn,Vt,Qr,En,So,ao,To,Kn,mn,Fn,Tt,Cr,wr,gn,Mo,ve,On,Ln,q,Sa,Xn,so,io,Qn,Nn,as,hn,xn,_n,Un,Vo,lo,Vr,Jn,Ta,jo,Ma,fi,ka,mi,Ea,Pt,ss,Pn,dn,gi,hi,La,co,is,ko,ls,ds,cs,ps,cn,Pa,Yn,Zn,us,xi,fs,ms,Go,bi,yi,vi,Ci,sd,Ko,Eo,wi,gs,Lo,Ai,hs,Po,xs,Si,po,Ti,Ro,jt,Ra,Ia;for(let Xo=0;Xo<Re.length;Xo++){let je=Re[Xo].payloadType,P=Re[Xo].payload;if(je==="reason_start"){let z=(F=Ae(P,!0))!=null?F:`reason-${l()}`,B=qe(z);B.reasoning=(fe=B.reasoning)!=null?fe:{id:z,status:"streaming",chunks:[]},B.reasoning.startedAt=(Xe=B.reasoning.startedAt)!=null?Xe:ke((Ie=P.startedAt)!=null?Ie:P.timestamp),B.reasoning.completedAt=void 0,B.reasoning.durationMs=void 0,B.streaming=!0,B.reasoning.status="streaming",p(B)}else if(je==="reason_delta"||je==="reason_chunk"){let z=(Ne=(Fe=Ae(P,!1))!=null?Fe:Ae(P,!0))!=null?Ne:`reason-${l()}`,B=qe(z);B.reasoning=(Ye=B.reasoning)!=null?Ye:{id:z,status:"streaming",chunks:[]},B.reasoning.startedAt=(Xt=B.reasoning.startedAt)!=null?Xt:ke((At=P.startedAt)!=null?At:P.timestamp);let oe=(mt=(K=(ar=P.reasoningText)!=null?ar:P.text)!=null?K:P.delta)!=null?mt:"";if(oe&&P.hidden!==!0){let ce=typeof P.sequenceIndex=="number"?P.sequenceIndex:void 0;if(ce!==void 0){let X=he(z,ce,String(oe));B.reasoning.chunks=[X]}else B.reasoning.chunks.push(String(oe))}if(B.reasoning.status=P.done?"complete":"streaming",P.done){B.reasoning.completedAt=ke((it=P.completedAt)!=null?it:P.timestamp);let ce=(ye=B.reasoning.startedAt)!=null?ye:Date.now();B.reasoning.durationMs=Math.max(0,((ie=B.reasoning.completedAt)!=null?ie:Date.now())-ce)}B.streaming=B.reasoning.status!=="complete",p(B)}else if(je==="reason_complete"){let z=(pr=(st=Ae(P,!1))!=null?st:Ae(P,!0))!=null?pr:`reason-${l()}`,B=M.get(z);if(B!=null&&B.reasoning){B.reasoning.status="complete",B.reasoning.completedAt=ke((pt=P.completedAt)!=null?pt:P.timestamp);let ce=(yr=B.reasoning.startedAt)!=null?yr:Date.now();B.reasoning.durationMs=Math.max(0,((Rr=B.reasoning.completedAt)!=null?Rr:Date.now())-ce),B.streaming=!1,p(B)}let oe=$(P);oe&&w.byStep.delete(oe)}else if(je==="tool_start"){let z=(ut=G(P,!0))!=null?ut:`tool-${l()}`,B=(Lt=P.toolName)!=null?Lt:P.name;if(Z(B)){J.add(z);continue}let oe=pe(z),ce=(tt=oe.toolCall)!=null?tt:{id:z,status:"pending"};ce.name=B!=null?B:ce.name,ce.status="running",P.args!==void 0?ce.args=P.args:P.parameters!==void 0&&(ce.args=P.parameters),ce.startedAt=(vr=ce.startedAt)!=null?vr:ke((zt=P.startedAt)!=null?zt:P.timestamp),ce.completedAt=void 0,ce.durationMs=void 0,oe.toolCall=ce,oe.streaming=!0;let X=P.agentContext;(X||P.executionId)&&(oe.agentMetadata={executionId:(sr=X==null?void 0:X.executionId)!=null?sr:P.executionId,iteration:(ur=X==null?void 0:X.iteration)!=null?ur:P.iteration}),p(oe)}else if(je==="tool_chunk"||je==="tool_delta"){let z=(un=(Mr=G(P,!1))!=null?Mr:G(P,!0))!=null?un:`tool-${l()}`;if(J.has(z))continue;let B=pe(z),oe=(St=B.toolCall)!=null?St:{id:z,status:"running"};oe.startedAt=(xr=oe.startedAt)!=null?xr:ke((qr=P.startedAt)!=null?qr:P.timestamp);let ce=(yt=(ln=(Mn=P.text)!=null?Mn:P.delta)!=null?ln:P.message)!=null?yt:"";ce&&(oe.chunks=(Gn=oe.chunks)!=null?Gn:[],oe.chunks.push(String(ce))),oe.status="running",B.toolCall=oe,B.streaming=!0;let X=P.agentContext;(X||P.executionId)&&(B.agentMetadata=(R=B.agentMetadata)!=null?R:{executionId:(kn=X==null?void 0:X.executionId)!=null?kn:P.executionId,iteration:(_e=X==null?void 0:X.iteration)!=null?_e:P.iteration}),p(B)}else if(je==="tool_complete"){let z=(Ee=(se=G(P,!1))!=null?se:G(P,!0))!=null?Ee:`tool-${l()}`;if(J.has(z)){J.delete(z);continue}let B=pe(z),oe=(Ot=B.toolCall)!=null?Ot:{id:z,status:"running"};oe.status="complete",P.result!==void 0&&(oe.result=P.result),typeof P.duration=="number"&&(oe.duration=P.duration),oe.completedAt=ke((et=P.completedAt)!=null?et:P.timestamp);let ce=(Nt=P.duration)!=null?Nt:P.executionTime;if(typeof ce=="number")oe.durationMs=ce;else{let $e=(Yt=oe.startedAt)!=null?Yt:Date.now();oe.durationMs=Math.max(0,((lr=oe.completedAt)!=null?lr:Date.now())-$e)}B.toolCall=oe,B.streaming=!1;let X=P.agentContext;(X||P.executionId)&&(B.agentMetadata=($t=B.agentMetadata)!=null?$t:{executionId:(vt=X==null?void 0:X.executionId)!=null?vt:P.executionId,iteration:(zr=X==null?void 0:X.iteration)!=null?zr:P.iteration}),p(B);let Le=te(P);Le&&E.byCall.delete(Le)}else if(je==="step_await"&&P.awaitReason==="local_tool_required"&&P.toolName){let z=typeof P.toolCallId=="string"&&P.toolCallId.length>0?P.toolCallId:void 0,B=($r=z!=null?z:P.toolId)!=null?$r:`local-${l()}`,oe=pe(B),ce=P.toolName,X=da(ce),Le=(Dn=oe.toolCall)!=null?Dn:{id:B,status:"pending"};Le.name=ce,Le.args=P.parameters,Le.status=X?"running":"complete",Le.chunks=(oo=Le.chunks)!=null?oo:[],Le.startedAt=(fn=Le.startedAt)!=null?fn:ke((Ao=P.startedAt)!=null?Ao:P.timestamp),X?(Le.completedAt=void 0,Le.duration=void 0,Le.durationMs=void 0):Le.completedAt=(Vt=Le.completedAt)!=null?Vt:Le.startedAt,oe.toolCall=Le,oe.streaming=!1,oe.agentMetadata={...oe.agentMetadata,executionId:(En=P.executionId)!=null?En:(Qr=oe.agentMetadata)==null?void 0:Qr.executionId,awaitingLocalTool:!0,...z?{webMcpToolCallId:z}:{}},p(oe)}else if(je==="text_start"){if((So=P.toolContext)!=null&&So.toolId)continue;let z=P.partId;if(z!==void 0&&S.current!==null&&z!==S.current){let B=f;B&&(B.streaming=!1,p(B),We=B,f=null,T=!0)}z!==void 0&&(S.current=z)}else if(je==="text_end"){if((ao=P.toolContext)!=null&&ao.toolId)continue;let z=f;z&&(z.streaming=!1,p(z),We=z,f=null,T=!0)}else if(je==="step_chunk"||je==="step_delta"){let z=P.stepType,B=P.executionType;if(z==="tool"||B==="context")continue;let oe=P.toolContext;if(oe!=null&&oe.toolId){let $e=String((Kn=(To=P.id)!=null?To:oe.stepId)!=null?Kn:`step-${l()}`),gt=P.partId!==void 0&&P.partId!==null?String(P.partId):"",lt=`${oe.toolId}::${$e}`,qt=C.get(lt);if(gt!==""&&qt!==void 0&&qt!==""&&qt!==gt){let ft=x.get(H(oe.toolId,$e,qt));ft&&ft.streaming!==!1&&(ft.streaming=!1,p(ft))}gt!==""&&C.set(lt,gt);let Zt=L(oe.toolId,$e,gt,oe.executionId),Ir=(Cr=(Tt=(Fn=(mn=P.text)!=null?mn:P.delta)!=null?Fn:P.content)!=null?Tt:P.chunk)!=null?Cr:"";Ir&&(Zt.content+=String(Ir),Zt.streaming=!0,p(Zt)),P.isComplete&&(Zt.streaming=!1,p(Zt));continue}let ce=P.partId;if(ce!==void 0&&S.current!==null&&ce!==S.current){let $e=f;$e&&($e.streaming=!1,p($e),We=$e,f=null,T=!0)}ce!==void 0&&(S.current=ce);let X=ce!==void 0&&(wr=wt.get(ce))!=null?wr:we();ce!==void 0&&(X.partId||(X.partId=ce),wt.set(ce,X));let Le=(On=(ve=(Mo=(gn=P.text)!=null?gn:P.delta)!=null?Mo:P.content)!=null?ve:P.chunk)!=null?On:"";if(Le){let $e=typeof P.seq=="number"?P.seq:void 0,gt=ce!=null?ce:X.id,lt=$e!==void 0?he(gt,$e,String(Le)):((Ln=de.get(X.id))!=null?Ln:"")+Le;X.rawContent=lt,ne.has(X.id)||ne.set(X.id,this.createStreamParser());let qt=ne.get(X.id),Zt=lt.trim().startsWith("{")||lt.trim().startsWith("[");if(Zt&&de.set(X.id,lt),qt.__isPlainTextParser===!0){X.content=$e!==void 0?lt:X.content+Le,de.delete(X.id),ne.delete(X.id),X.rawContent=void 0,p(X);continue}let ft=qt.processChunk(lt);if(ft instanceof Promise)ft.then(Mt=>{var Ze;let br=typeof Mt=="string"?Mt:(Ze=Mt==null?void 0:Mt.text)!=null?Ze:null;if(br!==null&&br.trim()!=="")X.content=br,p(X);else if(!Zt&&!lt.trim().startsWith("<")){let _r=f,fr=_r&&_r.id===X.id?_r:X;fr.id===X.id&&(fr.content=$e!==void 0?lt:fr.content+Le,de.delete(fr.id),ne.delete(fr.id),fr.rawContent=void 0,p(fr))}}).catch(()=>{X.content=$e!==void 0?lt:X.content+Le,de.delete(X.id),ne.delete(X.id),X.rawContent=void 0,p(X)});else{let Mt=typeof ft=="string"?ft:(q=ft==null?void 0:ft.text)!=null?q:null;Mt!==null&&Mt.trim()!==""?(X.content=Mt,p(X)):!Zt&&!lt.trim().startsWith("<")&&(X.content=$e!==void 0?lt:X.content+Le,de.delete(X.id),ne.delete(X.id),X.rawContent=void 0,p(X))}}if(P.isComplete){let $e=(Xn=(Sa=P.result)==null?void 0:Sa.response)!=null?Xn:X.content;if($e){let gt=de.get(X.id),lt=gt!=null?gt:le($e);X.rawContent=lt;let qt=ne.get(X.id),Zt=null,Ir=!1;if(qt&&(Zt=qt.getExtractedText(),Zt===null&&(Zt=pa(lt)),Zt===null)){let ft=qt.processChunk(lt);ft instanceof Promise?(Ir=!0,ft.then(Mt=>{var Ze;let br=typeof Mt=="string"?Mt:(Ze=Mt==null?void 0:Mt.text)!=null?Ze:null;if(br!==null){let _r=f;_r&&_r.id===X.id&&(_r.content=br,_r.streaming=!1,ne.delete(_r.id),de.delete(_r.id),p(_r))}})):Zt=typeof ft=="string"?ft:(so=ft==null?void 0:ft.text)!=null?so:null}if(!Ir){Zt!==null&&Zt.trim()!==""?X.content=Zt:de.has(X.id)||(X.content=le($e));let ft=ne.get(X.id);if(ft){let Mt=(io=ft.close)==null?void 0:io.call(ft);Mt instanceof Promise&&Mt.catch(()=>{}),ne.delete(X.id)}de.delete(X.id),X.streaming=!1,p(X)}}}}else if(je==="step_complete"){let z=P.stepType,B=P.executionType;if(z==="tool"||B==="context")continue;let oe=P.toolContext;if(oe!=null&&oe.toolId){let $e=String((Nn=(Qn=P.id)!=null?Qn:oe.stepId)!=null?Nn:"");if($e){let gt=I(oe.toolId,$e);for(let[lt,qt]of x)lt.startsWith(gt)&&qt.streaming!==!1&&(qt.streaming=!1,p(qt));C.delete(`${oe.toolId}::${$e}`)}continue}let ce=P.stopReason;if(T){if(f!==null){let lt=f;ce&&(lt.stopReason=ce),ne.delete(lt.id),de.delete(lt.id),lt.streaming!==!1&&(lt.streaming=!1,p(lt))}let $e=(as=P.result)==null?void 0:as.response,gt=We;gt&&(ce&&(gt.stopReason=ce),$e!=null?at(gt,$e):(ne.delete(gt.id),de.delete(gt.id))),We=null;continue}let X=(hn=P.result)==null?void 0:hn.response,Le=we();if(ce&&(Le.stopReason=ce),X!=null){let $e=ne.get(Le.id),gt=!1,lt=!1;if($e){let qt=$e.getExtractedText(),Zt=de.get(Le.id),Ir=Zt!=null?Zt:le(X);if(Le.rawContent=Ir,qt!==null&&qt.trim()!=="")Le.content=qt,gt=!0;else{let ft=pa(Ir);if(ft!==null)Le.content=ft,gt=!0;else{let Mt=$e.processChunk(Ir);if(Mt instanceof Promise)lt=!0,Mt.then(br=>{var _r;let Ze=typeof br=="string"?br:(_r=br==null?void 0:br.text)!=null?_r:null;if(Ze!==null&&Ze.trim()!==""){let fr=f;fr&&fr.id===Le.id&&(fr.content=Ze,fr.streaming=!1,ne.delete(fr.id),de.delete(fr.id),p(fr))}else{let fr=$e.getExtractedText(),Or=f;Or&&Or.id===Le.id&&(fr!==null&&fr.trim()!==""?Or.content=fr:de.has(Or.id)||(Or.content=le(X)),Or.streaming=!1,ne.delete(Or.id),de.delete(Or.id),p(Or))}});else{let br=typeof Mt=="string"?Mt:(xn=Mt==null?void 0:Mt.text)!=null?xn:null;if(br!==null&&br.trim()!=="")Le.content=br,gt=!0;else{let Ze=$e.getExtractedText();Ze!==null&&Ze.trim()!==""&&(Le.content=Ze,gt=!0)}}}}}if(!lt){if(!Le.rawContent){let qt=de.get(Le.id);Le.rawContent=qt!=null?qt:le(X)}if(!gt&&!de.has(Le.id)&&(Le.content=le(X)),$e){let qt=(_n=$e.close)==null?void 0:_n.call($e);qt instanceof Promise&&qt.catch(()=>{})}ne.delete(Le.id),de.delete(Le.id),Le.streaming=!1,p(Le)}}else ne.delete(Le.id),de.delete(Le.id),Le.streaming=!1,p(Le)}else if(je==="flow_complete"){let z=(Un=P.result)==null?void 0:Un.response;if(T){if(f!==null){let B=f;ne.delete(B.id),de.delete(B.id),B.streaming!==!1&&(B.streaming=!1,p(B))}}else if(z!=null){let B=we(),oe=de.get(B.id),ce=oe!=null?oe:le(z);B.rawContent=ce;let X=le(z),Le=ne.get(B.id);if(Le){let lt=pa(ce);if(lt!==null)X=lt;else{let qt=Le.processChunk(ce);qt instanceof Promise&&qt.then(Ir=>{var Mt;let ft=typeof Ir=="string"?Ir:(Mt=Ir==null?void 0:Ir.text)!=null?Mt:null;ft!==null&&(B.content=ft,B.streaming=!1,p(B))});let Zt=Le.getExtractedText();Zt!==null&&(X=Zt)}}ne.delete(B.id),de.delete(B.id);let $e=X!==B.content,gt=B.streaming!==!1;$e&&(B.content=X),B.streaming=!1,($e||gt)&&p(B)}else if(f!==null){let B=f;ne.delete(B.id),de.delete(B.id),B.streaming!==!1&&(B.streaming=!1,p(B))}t({type:"status",status:"idle"})}else if(je==="agent_start")ee={executionId:P.executionId,agentId:(Vo=P.agentId)!=null?Vo:"virtual",agentName:(lo=P.agentName)!=null?lo:"",status:"running",currentIteration:0,maxTurns:(Vr=P.maxTurns)!=null?Vr:1,startedAt:ke(P.startedAt)};else if(je==="agent_iteration_start"){if(ee&&(ee.currentIteration=P.iteration),Fr==="separate"&&P.iteration>1){let z=f;z&&(z.streaming=!1,p(z),Ge.set(P.iteration-1,z),f=null)}}else if(je==="agent_turn_start")b=null;else if(je==="agent_turn_delta"){if(P.contentType==="text"){let z=we();z.content+=(Jn=P.delta)!=null?Jn:"",z.agentMetadata={executionId:P.executionId,iteration:P.iteration,turnId:P.turnId,agentName:ee==null?void 0:ee.agentName},b=z,p(z)}else if(P.contentType==="thinking"){let z=(Ta=P.turnId)!=null?Ta:`agent-think-${P.iteration}`,B=qe(z);B.reasoning=(jo=B.reasoning)!=null?jo:{id:z,status:"streaming",chunks:[]},B.reasoning.chunks.push((Ma=P.delta)!=null?Ma:""),B.agentMetadata={executionId:P.executionId,iteration:P.iteration,turnId:P.turnId},p(B)}else if(P.contentType==="tool_input"){let z=(fi=P.toolCallId)!=null?fi:E.lastId;if(z){let B=k.get(z);B!=null&&B.toolCall&&(B.toolCall.chunks=(ka=B.toolCall.chunks)!=null?ka:[],B.toolCall.chunks.push((mi=P.delta)!=null?mi:""),p(B))}}}else if(je==="agent_turn_complete"){let z=P.turnId;if(z){let ce=M.get(z);if(ce!=null&&ce.reasoning){ce.reasoning.status="complete",ce.reasoning.completedAt=ke(P.completedAt);let X=(Ea=ce.reasoning.startedAt)!=null?Ea:Date.now();ce.reasoning.durationMs=Math.max(0,((Pt=ce.reasoning.completedAt)!=null?Pt:Date.now())-X),ce.streaming=!1,p(ce)}}let B=P.stopReason,oe=f!=null?f:b;if(B&&oe!==null){let ce=P.turnId;(!ce||((ss=oe.agentMetadata)==null?void 0:ss.turnId)===ce)&&(oe.stopReason=B,p(oe))}}else if(je==="agent_tool_start"){f&&(f.streaming=!1,p(f),f=null);let z=(Pn=P.toolCallId)!=null?Pn:`agent-tool-${l()}`;He(te(P),z);let B=pe(z),oe=(dn=B.toolCall)!=null?dn:{id:z,status:"pending",name:void 0,args:void 0,chunks:void 0,result:void 0,duration:void 0,startedAt:void 0,completedAt:void 0,durationMs:void 0};oe.name=(hi=(gi=P.toolName)!=null?gi:P.name)!=null?hi:oe.name,oe.status="running",P.parameters!==void 0&&(oe.args=P.parameters),oe.startedAt=ke((La=P.startedAt)!=null?La:P.timestamp),B.toolCall=oe,B.streaming=!0,B.agentMetadata={executionId:P.executionId,iteration:P.iteration},p(B)}else if(je==="agent_tool_delta"){let z=(co=P.toolCallId)!=null?co:E.lastId;if(z){let B=(is=k.get(z))!=null?is:pe(z);B.toolCall&&(B.toolCall.chunks=(ko=B.toolCall.chunks)!=null?ko:[],B.toolCall.chunks.push((ls=P.delta)!=null?ls:""),B.toolCall.status="running",B.streaming=!0,p(B))}}else if(je==="agent_tool_complete"){let z=(ds=P.toolCallId)!=null?ds:E.lastId;if(z){let B=(cs=k.get(z))!=null?cs:pe(z);if(B.toolCall){B.toolCall.status="complete",P.result!==void 0&&(B.toolCall.result=P.result),typeof P.executionTime=="number"&&(B.toolCall.durationMs=P.executionTime),B.toolCall.completedAt=ke((ps=P.completedAt)!=null?ps:P.timestamp),B.streaming=!1,p(B);let oe=te(P);oe&&E.byCall.delete(oe)}}}else if(je==="agent_media"){let z=Array.isArray(P.media)?P.media:[],B=[];for(let oe of z){if(!oe||typeof oe!="object")continue;let ce=oe,X=typeof ce.type=="string"?ce.type:void 0,Le=typeof ce.mediaType=="string"?ce.mediaType.toLowerCase():"",$e=null,gt="";if(X==="media"){let lt=typeof ce.data=="string"?ce.data:void 0;if(!lt)continue;gt=Le.length>0?Le:"application/octet-stream",$e=`data:${gt};base64,${lt}`}else if(X==="image-url"){let lt=typeof ce.url=="string"?ce.url:void 0;if(!lt)continue;gt=Le,$e=lt}else if(X==="file-url"){let lt=typeof ce.url=="string"?ce.url:void 0;if(!lt)continue;gt=Le,$e=lt}else continue;if($e)if(X==="image-url"||gt.startsWith("image/"))B.push({type:"image",image:$e,...gt?{mimeType:gt}:{}});else if(gt.startsWith("audio/"))B.push({type:"audio",audio:$e,mimeType:gt});else if(gt.startsWith("video/"))B.push({type:"video",video:$e,mimeType:gt});else{let lt=gt||"application/octet-stream";B.push({type:"file",data:$e,mimeType:lt,filename:Y0(lt)})}}if(B.length>0){let oe=l(),ce=P.toolCallId,Le={id:`agent-media-${typeof ce=="string"&&ce.length>0?`${ce}-${oe}`:String(oe)}`,role:"assistant",content:"",contentParts:B,createdAt:new Date().toISOString(),streaming:!1,sequence:oe,agentMetadata:{executionId:P.executionId,iteration:P.iteration}};p(Le);let $e=f;$e&&($e.streaming=!1,p($e)),f=null,h.current=null}}else if(je!=="agent_iteration_complete"){if(je==="agent_reflection"||je==="agent_reflect"){let z=`agent-reflection-${P.executionId}-${P.iteration}`,B={id:z,role:"assistant",content:(cn=P.reflection)!=null?cn:"",createdAt:new Date().toISOString(),streaming:!1,variant:"reasoning",sequence:l(),reasoning:{id:z,status:"complete",chunks:[(Pa=P.reflection)!=null?Pa:""]},agentMetadata:{executionId:P.executionId,iteration:P.iteration}};p(B)}else if(je==="agent_complete"){ee&&(ee.status=P.success?"complete":"error",ee.completedAt=ke(P.completedAt),ee.stopReason=P.stopReason);let z=f;z&&(z.streaming=!1,p(z)),t({type:"status",status:"idle"})}else if(je==="agent_error"){let z=typeof P.error=="string"?P.error:(Zn=(Yn=P.error)==null?void 0:Yn.message)!=null?Zn:"Agent execution error";P.recoverable?typeof console!="undefined"&&console.warn("[AgentWidget] Recoverable agent error:",z):t({type:"error",error:new Error(z)})}else if(je!=="agent_ping"){if(je==="agent_approval_start"){let z=(us=P.approvalId)!=null?us:`approval-${l()}`,B={id:`approval-${z}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:z,status:"pending",agentId:(xi=ee==null?void 0:ee.agentId)!=null?xi:"virtual",executionId:(ms=(fs=P.executionId)!=null?fs:ee==null?void 0:ee.executionId)!=null?ms:"",toolName:(Go=P.toolName)!=null?Go:"",toolType:P.toolType,description:(yi=P.description)!=null?yi:`Execute ${(bi=P.toolName)!=null?bi:"tool"}`,...typeof P.reason=="string"&&P.reason?{reason:P.reason}:{},parameters:P.parameters}};p(B)}else if(je==="step_await"&&P.awaitReason==="approval_required"){let z=(vi=P.approvalId)!=null?vi:`approval-${l()}`,B={id:`approval-${z}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:z,status:"pending",agentId:(Ci=ee==null?void 0:ee.agentId)!=null?Ci:"virtual",executionId:(Ko=(sd=P.executionId)!=null?sd:ee==null?void 0:ee.executionId)!=null?Ko:"",toolName:(Eo=P.toolName)!=null?Eo:"",toolType:P.toolType,description:(gs=P.description)!=null?gs:`Execute ${(wi=P.toolName)!=null?wi:"tool"}`,...typeof P.reason=="string"&&P.reason?{reason:P.reason}:{},parameters:P.parameters}};p(B)}else if(je==="agent_approval_complete"){let z=P.approvalId;if(z){let oe={id:`approval-${z}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:z,status:(Lo=P.decision)!=null?Lo:"approved",agentId:(Ai=ee==null?void 0:ee.agentId)!=null?Ai:"virtual",executionId:(Po=(hs=P.executionId)!=null?hs:ee==null?void 0:ee.executionId)!=null?Po:"",toolName:(xs=P.toolName)!=null?xs:"",description:(Si=P.description)!=null?Si:"",resolvedAt:Date.now()}};p(oe)}}else if(je==="artifact_start"||je==="artifact_delta"||je==="artifact_update"||je==="artifact_complete"){if(je==="artifact_start"){let z=P.artifactType,B=String(P.id),oe=typeof P.title=="string"?P.title:void 0;if(t({type:"artifact_start",id:B,artifactType:z,title:oe,component:typeof P.component=="string"?P.component:void 0}),ge.set(B,{markdown:"",title:oe}),!Q.has(B)){Q.add(B);let ce={id:`artifact-ref-${B}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l(),rawContent:JSON.stringify({component:"PersonaArtifactCard",props:{artifactId:B,title:oe,artifactType:z,status:"streaming"}})};re.set(B,ce),p(ce)}}else if(je==="artifact_delta"){let z=String(P.id),B=typeof P.delta=="string"?P.delta:String((po=P.delta)!=null?po:"");t({type:"artifact_delta",id:z,artDelta:B});let oe=ge.get(z);oe&&(oe.markdown+=B)}else if(je==="artifact_update"){let z=P.props&&typeof P.props=="object"&&!Array.isArray(P.props)?P.props:{};t({type:"artifact_update",id:String(P.id),props:z,component:typeof P.component=="string"?P.component:void 0})}else if(je==="artifact_complete"){let z=String(P.id);t({type:"artifact_complete",id:z});let B=re.get(z);if(B){B.streaming=!1;try{let oe=JSON.parse((Ti=B.rawContent)!=null?Ti:"{}");if(oe.props){oe.props.status="complete";let ce=ge.get(z);ce!=null&&ce.markdown&&(oe.props.markdown=ce.markdown)}B.rawContent=JSON.stringify(oe)}catch{}ge.delete(z),p(B),re.delete(z)}}}else if(je==="transcript_insert"){let z=P.message;if(!z||typeof z!="object")continue;let B=String((Ro=z.id)!=null?Ro:`msg-${l()}`),oe=z.role,X={id:B,role:oe==="user"?"user":oe==="system"?"system":"assistant",content:typeof z.content=="string"?z.content:"",rawContent:typeof z.rawContent=="string"?z.rawContent:void 0,createdAt:typeof z.createdAt=="string"?z.createdAt:new Date().toISOString(),streaming:z.streaming===!0,...typeof z.variant=="string"?{variant:z.variant}:{},sequence:l()};if(p(X),X.rawContent)try{let Le=JSON.parse(X.rawContent),$e=(jt=Le==null?void 0:Le.props)==null?void 0:jt.artifactId;typeof $e=="string"&&Q.add($e)}catch{}f=null,h.current=null,ne.delete(B),de.delete(B)}else if(je==="error"||je==="step_error"||je==="dispatch_error"||je==="flow_error"){let z=null;if(P.error instanceof Error)z=P.error;else if(je==="dispatch_error"){let B=(Ra=P.message)!=null?Ra:P.error;B!=null&&B!==""&&(z=new Error(String(B)))}else if(je==="step_error"||je==="flow_error"){let B=P.error;typeof B=="string"&&B!==""?z=new Error(B):B!=null&&typeof B=="object"&&"message"in B&&(z=new Error(String((Ia=B.message)!=null?Ia:B)))}else je==="error"&&P.error!=null&&P.error!==""&&(z=new Error(String(P.error)));if(z){t({type:"error",error:z});let B=f;B&&B.streaming&&(B.streaming=!1,p(B)),t({type:"status",status:"idle"})}}}}}Re.length=0};;){let{done:F,value:fe}=await o.read();if(F)break;s+=a.decode(fe,{stream:!0});let Ie=s.split(`
|
|
54
|
+
${r.description}`:"");return window.confirm(t)},N0=r=>{if(r==null)return"";try{let e=JSON.stringify(r,null,2);return e.length>500?e.slice(0,500)+"\u2026":e}catch{return String(r)}},F0=r=>{if(r===void 0)return"{}";try{let e=JSON.stringify(r);return e===void 0?"{}":e}catch{return"{}"}},U0=r=>{if(r===void 0)return"";try{return JSON.stringify(r)}catch{return String(r)}};var Un=Bi(ji(),1);var C=(r,e)=>{let t=document.createElement(r);return e&&(t.className=e),t},un=(r,e,t)=>{let o=r.createElement(e);return t&&(o.className=t),o};var $s="ask_user_question",zs=8,Ka="data-persona-ask-sheet-for",j0="Other",G0="Other\u2026",_h="Type your own answer here",Nh="Send",K0="Next",X0="Back",Q0="Submit all",Y0="Skip",J0=3,Bd="data-ask-current-index",Dd="data-ask-question-count",Fh="data-ask-answers",Od="data-ask-grouped",Uh="data-ask-layout",Z0=r=>r.layout==="pills"?"pills":"rows",ev=r=>r.getAttribute(Uh)==="pills"?"pills":"rows",Oh=!1,qh=r=>r.replace(/["\\]/g,"\\$&"),wn=r=>r.variant==="tool"&&!!r.toolCall&&r.toolCall.name===$s,Gi=r=>{var e,t;return(t=(e=r==null?void 0:r.features)==null?void 0:e.askUserQuestion)!=null?t:{}},An=r=>{let e=r.toolCall;if(!e)return{payload:null,complete:!1};let t=e.status==="complete";if(e.args&&typeof e.args=="object")return{payload:e.args,complete:t};let o=e.chunks;if(!o||o.length===0)return{payload:null,complete:t};try{let n=o.join(""),a=(0,Un.parse)(n,Un.STR|Un.OBJ|Un.ARR);if(a&&typeof a=="object")return{payload:a,complete:t}}catch{}return{payload:null,complete:t}},Vs=r=>{let e=Array.isArray(r==null?void 0:r.questions)?r.questions:[];return e.length>zs&&!Oh&&(Oh=!0,typeof console!="undefined"&&console.warn(`[AgentWidget] ask_user_question received ${e.length} questions; truncating to ${zs}.`)),e.slice(0,zs)},tv=r=>{var e;return(e=Vs(r)[0])!=null?e:null},rv=(r,e)=>{var t;return(t=Vs(r)[e])!=null?t:null},zh=(r,e)=>{let t=e.styles;t&&(t.sheetBackground&&r.style.setProperty("--persona-ask-sheet-bg",t.sheetBackground),t.sheetBorder&&r.style.setProperty("--persona-ask-sheet-border",t.sheetBorder),t.sheetShadow&&r.style.setProperty("--persona-ask-sheet-shadow",t.sheetShadow),t.pillBackground&&r.style.setProperty("--persona-ask-pill-bg",t.pillBackground),t.pillBackgroundSelected&&r.style.setProperty("--persona-ask-pill-bg-selected",t.pillBackgroundSelected),t.pillTextColor&&r.style.setProperty("--persona-ask-pill-fg",t.pillTextColor),t.pillTextColorSelected&&r.style.setProperty("--persona-ask-pill-fg-selected",t.pillTextColorSelected),t.pillBorderRadius&&r.style.setProperty("--persona-ask-pill-radius",t.pillBorderRadius),t.customInputBackground&&r.style.setProperty("--persona-ask-input-bg",t.customInputBackground))},$h=(r,e,t)=>{if(r!=="rows")return null;let o=C("span","persona-ask-row-affordance");if(o.setAttribute("aria-hidden","true"),e){let n=C("span","persona-ask-row-check");o.appendChild(n)}else{let n=C("span","persona-ask-row-badge");n.textContent=String(t+1),o.appendChild(n)}return o},ov=(r,e,t,o)=>{let a=C("button",t==="rows"?"persona-ask-pill persona-ask-row persona-pointer-events-auto":"persona-ask-pill persona-pointer-events-auto");if(a.type="button",a.setAttribute("role",o?"checkbox":"button"),a.setAttribute("aria-pressed","false"),a.setAttribute("data-ask-user-action","pick"),a.setAttribute("data-option-index",String(e)),a.setAttribute("data-option-label",r.label),t==="rows"){let s=C("span","persona-ask-row-content"),i=C("span","persona-ask-row-label");if(i.textContent=r.label,s.appendChild(i),r.description){let l=C("span","persona-ask-row-description");l.textContent=r.description,s.appendChild(l)}a.appendChild(s);let d=$h(t,o,e);d&&a.appendChild(d)}else a.textContent=r.label,r.description&&(a.title=r.description);return a},nv=r=>{let t=C("span",r==="rows"?"persona-ask-pill persona-ask-row persona-ask-pill-skeleton persona-pointer-events-none":"persona-ask-pill persona-ask-pill-skeleton persona-pointer-events-none");return t.setAttribute("aria-hidden","true"),t},av=(r,e,t,o)=>{var u,f,p;let a=C("div",o==="rows"?"persona-ask-pills persona-ask-pills--rows persona-flex persona-flex-col persona-gap-2":"persona-ask-pills persona-flex persona-flex-wrap persona-gap-2");a.setAttribute("role","group"),a.setAttribute("data-ask-pill-list","true");let s=!!(r!=null&&r.multiSelect),d=(Array.isArray(r==null?void 0:r.options)?r.options:[]).filter(m=>m&&typeof m.label=="string"&&m.label.length>0);if(d.length===0&&!t){for(let m=0;m<J0;m++)a.appendChild(nv(o));return a}if(d.forEach((m,y)=>{a.appendChild(ov(m,y,o,s))}),(r==null?void 0:r.allowFreeText)!==!1){let m=o==="rows"?j0:G0;if(o==="rows"){let y=C("div","persona-ask-pill persona-ask-row persona-ask-row--other persona-ask-pill-custom persona-pointer-events-auto");y.setAttribute("data-ask-user-action","focus-free-text"),y.setAttribute("data-option-index",String(d.length)),y.setAttribute("data-ask-other-row","true");let h=C("span","persona-ask-row-content"),T=document.createElement("input");T.type="text",T.className="persona-ask-row-input persona-flex-1 persona-pointer-events-auto",T.placeholder=(u=e.freeTextPlaceholder)!=null?u:_h,T.setAttribute("data-ask-free-text-input","true"),T.setAttribute("aria-label",(f=e.freeTextLabel)!=null?f:m),h.appendChild(T),y.appendChild(h);let M=$h(o,s,d.length);M&&y.appendChild(M),a.appendChild(y)}else{let y=C("button","persona-ask-pill persona-ask-pill-custom persona-pointer-events-auto");y.type="button",y.setAttribute("data-ask-user-action","open-free-text"),y.textContent=(p=e.freeTextLabel)!=null?p:m,a.appendChild(y)}}return a},Vh=(r,e)=>{var a,s;let o=C("div",e==="rows"?"persona-ask-free-text persona-ask-free-text--rows persona-flex persona-gap-2 persona-mt-2":"persona-ask-free-text persona-hidden persona-flex persona-gap-2 persona-mt-2");o.setAttribute("data-ask-free-text-row","true");let n=document.createElement("input");if(n.type="text",n.className="persona-ask-free-text-input persona-flex-1 persona-pointer-events-auto",n.placeholder=(a=r.freeTextPlaceholder)!=null?a:_h,n.setAttribute("data-ask-free-text-input","true"),o.appendChild(n),e!=="rows"){let i=C("button","persona-ask-free-text-submit persona-pointer-events-auto");i.type="button",i.textContent=(s=r.submitLabel)!=null?s:Nh,i.setAttribute("data-ask-user-action","submit-free-text"),o.appendChild(i)}return o},sv=r=>{var o;let e=C("div","persona-ask-multi-actions persona-flex persona-justify-end persona-mt-2");e.setAttribute("data-ask-multi-actions","true");let t=C("button","persona-ask-multi-submit persona-pointer-events-auto");return t.type="button",t.textContent=(o=r.submitLabel)!=null?o:Nh,t.setAttribute("data-ask-user-action","submit-multi"),t.disabled=!0,e.appendChild(t),e},iv=(r,e,t)=>{var l,u,f,p;let o=C("div","persona-ask-nav persona-flex persona-justify-between persona-items-center persona-gap-2 persona-mt-2");o.setAttribute("data-ask-nav-row","true");let n=C("button","persona-ask-nav-back persona-pointer-events-auto");n.type="button",n.textContent=(l=t.backLabel)!=null?l:X0,n.setAttribute("data-ask-user-action","back"),n.disabled=r===0,o.appendChild(n);let a=C("div","persona-ask-nav-right persona-flex persona-items-center persona-gap-2"),s=C("button","persona-ask-nav-skip persona-pointer-events-auto");s.type="button",s.textContent=(u=t.skipLabel)!=null?u:Y0,s.setAttribute("data-ask-user-action","skip"),a.appendChild(s);let i=C("button","persona-ask-nav-next persona-pointer-events-auto");i.type="button";let d=r===e-1;return i.textContent=d?(f=t.submitAllLabel)!=null?f:Q0:(p=t.nextLabel)!=null?p:K0,i.setAttribute("data-ask-user-action",d?"submit-all":"next"),i.disabled=!0,a.appendChild(i),o.appendChild(a),o},ha=r=>{let e=r.getAttribute(Fh);if(!e)return{};try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}},jh=(r,e)=>{r.setAttribute(Fh,JSON.stringify(e))},jo=r=>{var t;let e=Number((t=r.getAttribute(Bd))!=null?t:"0");return Number.isFinite(e)?Math.max(0,Math.floor(e)):0},lv=(r,e)=>{r.setAttribute(Bd,String(Math.max(0,Math.floor(e))))},Xa=r=>{var t;let e=Number((t=r.getAttribute(Dd))!=null?t:"1");return Number.isFinite(e)?Math.max(1,Math.floor(e)):1},qn=r=>r.getAttribute(Od)==="true",dv=(r,e)=>{var n;let t=(n=r.agentMetadata)==null?void 0:n.askUserQuestionAnswers;if(!t||typeof t!="object")return{};let o={};return e.forEach((a,s)=>{let i=typeof(a==null?void 0:a.question)=="string"?a.question:"";if(i&&Object.prototype.hasOwnProperty.call(t,i)){let d=t[i];(typeof d=="string"||Array.isArray(d))&&(o[s]=d)}}),o},cv=(r,e)=>{var o;let t=(o=r.agentMetadata)==null?void 0:o.askUserQuestionIndex;return typeof t!="number"||!Number.isFinite(t)?0:Math.max(0,Math.min(e-1,Math.floor(t)))},Ki=(r,e)=>{let{payload:t}=An(e),o=Vs(t),n=ha(r),a={},s=new Set;return o.forEach((i,d)=>{let l=typeof(i==null?void 0:i.question)=="string"?i.question:"";l&&(s.has(l)&&typeof console!="undefined"&&console.warn(`[AgentWidget] ask_user_question has duplicate question text "${l}"; later answer wins.`),s.add(l),Object.prototype.hasOwnProperty.call(n,d)&&(a[l]=n[d]))}),a},Gh=r=>{let e=ha(r),t=jo(r),o=e[t],n=new Set;typeof o=="string"?n.add(o):Array.isArray(o)&&o.forEach(d=>n.add(d));let a=r.querySelectorAll('[data-ask-user-action="pick"][data-option-label]');a.forEach(d=>{var f;let l=(f=d.getAttribute("data-option-label"))!=null?f:"",u=n.has(l);d.setAttribute("aria-pressed",u?"true":"false"),d.classList.toggle("persona-ask-pill-selected",u)});let s=new Set(Array.from(a).map(d=>{var l;return(l=d.getAttribute("data-option-label"))!=null?l:""})),i=r.querySelector('[data-ask-free-text-input="true"]');if(i)if(typeof o=="string"&&o.length>0&&!s.has(o)){i.value=o;let d=i.closest('[data-ask-free-text-row="true"]');d==null||d.classList.remove("persona-hidden")}else i.value=""},Kh=r=>{if(!qn(r))return;let e=ha(r),t=jo(r),o=e[t],n=typeof o=="string"&&o.length>0||Array.isArray(o)&&o.length>0,a=r.querySelector('[data-ask-user-action="next"], [data-ask-user-action="submit-all"]');a&&(a.disabled=!n);let s=r.querySelector('[data-ask-user-action="submit-multi"]');if(s){let i=Array.from(r.querySelectorAll('[aria-pressed="true"][data-option-label]'));s.disabled=i.length===0}},_d=(r,e,t)=>{let o=Gi(t),n=ev(r),{payload:a,complete:s}=An(e),i=qn(r),d=jo(r),l=Xa(r),u=i?rv(a,d):tv(a),f=!!(u!=null&&u.multiSelect),p=r.querySelector('[data-ask-step-inline="true"]');p&&(p.textContent=i?`${d+1}/${l}`:"");let m=r.querySelector('[data-ask-stepper="true"]');m&&m.remove();let y=r.querySelector('[data-ask-question="true"]');if(y){let k=typeof(u==null?void 0:u.question)=="string"?u.question:"";y.textContent=k,y.classList.toggle("persona-ask-question-skeleton",!k&&!s)}let h=r.querySelector('[data-ask-pill-list="true"]');if(h){let k=av(u,o,s,n);h.replaceWith(k)}if(n!=="rows"){let k=r.querySelector('[data-ask-free-text-row="true"]');k&&k.replaceWith(Vh(o,n))}let T=r.querySelector('[data-ask-multi-actions="true"]');!i&&f&&!T?r.appendChild(sv(o)):(!f||i)&&T&&T.remove(),r.setAttribute("data-multi-select",f?"true":"false");let M=r.querySelector('[data-ask-nav-row="true"]');if(i){let k=iv(d,l,o);M?M.replaceWith(k):r.appendChild(k)}else M&&M.remove();Gh(r),Kh(r)},pv=(r,e,t)=>{let o=Gi(e),n=Z0(o),a=r.toolCall.id,s=Vs(t),i=Math.max(1,s.length),d=i>1,l=dv(r,s),u=d?cv(r,i):0,f=C("div",["persona-ask-sheet",`persona-ask-sheet--${n}`,"persona-pointer-events-auto","persona-ask-sheet-enter"].join(" "));f.setAttribute(Ka,a),f.setAttribute("data-tool-call-id",a),f.setAttribute("data-message-id",r.id),f.setAttribute(Dd,String(i)),f.setAttribute(Bd,String(u)),f.setAttribute(Od,d?"true":"false"),f.setAttribute(Uh,n),jh(f,l),f.setAttribute("role","group"),f.setAttribute("aria-label","Suggested answers"),o.slideInMs!==void 0&&f.style.setProperty("--persona-ask-sheet-duration",`${o.slideInMs}ms`),zh(f,o);let p=C("div","persona-ask-sheet-header persona-flex persona-items-center persona-gap-3"),m=C("div","persona-ask-sheet-question persona-flex-1");m.setAttribute("data-ask-question","true"),m.textContent="",p.appendChild(m);let y=C("span","persona-ask-sheet-step-inline");y.setAttribute("data-ask-step-inline","true"),y.textContent="",p.appendChild(y),f.appendChild(p);let T=C("div",n==="rows"?"persona-ask-pills persona-ask-pills--rows persona-flex persona-flex-col persona-gap-2":"persona-ask-pills persona-flex persona-flex-wrap persona-gap-2");return T.setAttribute("data-ask-pill-list","true"),T.setAttribute("role","group"),f.appendChild(T),n!=="rows"&&f.appendChild(Vh(o,n)),_d(f,r,e),requestAnimationFrame(()=>{requestAnimationFrame(()=>f.classList.remove("persona-ask-sheet-enter"))}),f},uv=(r,e,t)=>{let{payload:o}=An(e),n=Math.max(1,Vs(o).length);n>Xa(r)&&(r.setAttribute(Dd,String(n)),n>1&&!qn(r)&&r.setAttribute(Od,"true")),_d(r,e,t)},Xh=(r,e)=>{let t=C("div","persona-ask-stub persona-inline-flex persona-items-center persona-gap-2");t.id=`bubble-${r.id}`,t.setAttribute("data-message-id",r.id),t.setAttribute("data-bubble-type","ask-user-question");let o=Gi(e);zh(t,o);let n=C("span","persona-ask-stub-label"),{complete:a}=An(r);return n.textContent=a?"Awaiting your response\u2026":"Preparing options\u2026",t.appendChild(n),t},Qa=(r,e,t)=>{if(!t||!wn(r)||Gi(e).enabled===!1)return;let n=r.toolCall.id;t.querySelectorAll(`[${Ka}]`).forEach(l=>{l.getAttribute(Ka)!==n&&l.remove()});let s=t.querySelector(`[${Ka}="${qh(n)}"]`);if(s){uv(s,r,e);return}let{payload:i}=An(r),d=pv(r,e,i);t.appendChild(d)},zn=(r,e)=>{if(!r)return;let t=e?`[${Ka}="${qh(e)}"]`:`[${Ka}]`;r.querySelectorAll(t).forEach(n=>{n.classList.add("persona-ask-sheet-leave");let a=Number.parseInt(getComputedStyle(n).getPropertyValue("--persona-ask-sheet-duration")||"180",10);setTimeout(()=>n.remove(),Number.isFinite(a)?a:180)})},Nd=r=>Array.from(r.querySelectorAll('[aria-pressed="true"][data-option-label]')).map(e=>e.getAttribute("data-option-label")).filter(e=>typeof e=="string"&&e.length>0),$n=(r,e)=>{let t=ha(r),o=jo(r);typeof e=="string"&&e.length===0||Array.isArray(e)&&e.length===0?delete t[o]:t[o]=e,jh(r,t),Gh(r),Kh(r)},Xi=(r,e,t,o)=>{let n=Xa(r),a=Math.max(0,Math.min(n-1,o));lv(r,a),_d(r,e,t)};var en="suggest_replies";var Fd={type:"object",properties:{suggestions:{type:"array",minItems:1,maxItems:4,description:"1-4 short, distinct follow-up replies, phrased in the user's voice.",items:{type:"string",minLength:1,maxLength:60}}},required:["suggestions"],additionalProperties:!1},Qi={name:en,description:`Offer the user tappable quick-reply suggestions for their next message. Call at most once per turn, as the LAST action after your reply text is complete. Each suggestion is sent verbatim as the user's next message, so phrase suggestions in the user's voice (e.g. "Tell me more about pricing"). Keep them short and distinct. The result only confirms the suggestions were shown \u2014 do not add further commentary after calling this tool; end your turn.`,parametersSchema:Fd,origin:"sdk",annotations:{readOnlyHint:!0}},Ud=()=>({content:[{type:"text",text:"Suggestions shown to the user."}]}),js=r=>{var e;return r.variant==="tool"&&((e=r.toolCall)==null?void 0:e.name)===en},qd=r=>{let e=r;if(typeof e=="string")try{e=JSON.parse(e)}catch{return[]}let t=e==null?void 0:e.suggestions;if(!Array.isArray(t))return[];let o=t.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return o.length>4?(console.warn(`[persona] suggest_replies: ${o.length} suggestions exceeds the cap of 4; extra suggestions dropped.`),o.slice(0,4)):o},Yi=r=>{var e;for(let t=r.length-1;t>=0;t--){let o=r[t];if(o.role==="user")return null;if(!js(o))continue;let n=qd((e=o.toolCall)==null?void 0:e.args);return n.length>0?n:null}return null},Qh=r=>{var t;let e=(t=r==null?void 0:r.features)==null?void 0:t.suggestReplies;return(e==null?void 0:e.expose)===!0&&e.enabled!==!1};var zd={type:"object",properties:{questions:{type:"array",minItems:1,maxItems:zs,description:"Questions to ask the user. Prefer a single question.",items:{type:"object",properties:{question:{type:"string",description:"The complete question, ending with a question mark."},header:{type:"string",maxLength:12,description:'Short topic label, e.g. "Auth method".'},options:{type:"array",minItems:2,maxItems:4,description:'2-4 distinct choices. Do NOT add an "Other" option \u2014 free text is automatic.',items:{type:"object",properties:{label:{type:"string",description:"Concise choice text (1-5 words)."},description:{type:"string",description:"What the option means or implies."}},required:["label"],additionalProperties:!1}},multiSelect:{type:"boolean",description:"Allow selecting multiple options. Default false."},allowFreeText:{type:"boolean",description:"Show a free-text input. Default true."}},required:["question","options"],additionalProperties:!1}}},required:["questions"],additionalProperties:!1},$d={name:$s,description:"Ask the user multiple-choice questions and wait for their answers. Use only when blocked on a decision that is the user's to make \u2014 a preference, a choice between valid approaches, or information you cannot infer. Each question offers 2-4 options plus an automatic free-text input. The result maps each question to its answer (an array when multiSelect); a question absent from the result was skipped.",parametersSchema:zd,origin:"sdk",annotations:{readOnlyHint:!0}},Gs=r=>{var o;let e=[],t=(o=r==null?void 0:r.features)==null?void 0:o.askUserQuestion;return(t==null?void 0:t.expose)===!0&&t.enabled!==!1&&e.push($d),Qh(r)&&e.push(Qi),e};var Sn=Bi(ji(),1),Ji=r=>r.replace(/\\n/g,`
|
|
55
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\"),Ya=r=>{if(r===null)return"null";if(r===void 0)return"";if(typeof r=="string")return r;if(typeof r=="number"||typeof r=="boolean")return String(r);try{return JSON.stringify(r,null,2)}catch{return String(r)}},fv=r=>{var s,i;let e=(s=r.completedAt)!=null?s:Date.now(),t=(i=r.startedAt)!=null?i:e,n=(r.durationMs!==void 0?r.durationMs:Math.max(0,e-t))/1e3;return n<.1?"Thought for <0.1 seconds":`Thought for ${n>=10?Math.round(n).toString():n.toFixed(1).replace(/\.0$/,"")} seconds`},Yh=r=>r.status==="complete"?fv(r):r.status==="pending"?"Waiting":"",mv=r=>{var n,a,s;let t=(typeof r.duration=="number"?r.duration:typeof r.durationMs=="number"?r.durationMs:Math.max(0,((n=r.completedAt)!=null?n:Date.now())-((s=(a=r.startedAt)!=null?a:r.completedAt)!=null?s:Date.now())))/1e3;return t<.1?"Used tool for <0.1 seconds":`Used tool for ${t>=10?Math.round(t).toString():t.toFixed(1).replace(/\.0$/,"")} seconds`};var Jh=r=>r.status==="complete"?mv(r):"Using tool...",Zi=r=>{let e=r/1e3;return e<.1?"<0.1s":e>=10?`${Math.round(e)}s`:`${e.toFixed(1).replace(/\.0$/,"")}s`},Xs=r=>{var t,o,n;let e=typeof r.duration=="number"?r.duration:typeof r.durationMs=="number"?r.durationMs:Math.max(0,((t=r.completedAt)!=null?t:Date.now())-((n=(o=r.startedAt)!=null?o:r.completedAt)!=null?n:Date.now()));return Zi(e)},el=r=>{var t,o,n;let e=r.durationMs!==void 0?r.durationMs:Math.max(0,((t=r.completedAt)!=null?t:Date.now())-((n=(o=r.startedAt)!=null?o:r.completedAt)!=null?n:Date.now()));return Zi(e)},Vd=(r,e,t)=>{var a;if(!e)return t;let o=((a=r.name)==null?void 0:a.trim())||"tool",n=Xs(r);return e.replace(/\{toolName\}/g,o).replace(/\{duration\}/g,n)},tl=(r,e)=>{let t=r.replace(/\{toolName\}/g,e),o=[],n=/\*\*(.+?)\*\*|\*(.+?)\*|~(.+?)~/g,a=0,s;for(;(s=n.exec(t))!==null;)s.index>a&&Ks(o,t.slice(a,s.index),[]),s[1]!==void 0?Ks(o,s[1],["bold"]):s[2]!==void 0?Ks(o,s[2],["italic"]):s[3]!==void 0&&Ks(o,s[3],["dim"]),a=s.index+s[0].length;return a<t.length&&Ks(o,t.slice(a),[]),o},Ks=(r,e,t)=>{let o=e.split("{duration}");for(let n=0;n<o.length;n++)o[n]&&r.push({text:o[n],styles:t}),n<o.length-1&&r.push({text:"{duration}",styles:t,isDuration:!0})},gv=()=>{let r=null,e=0,t=o=>{let n=/"text"\s*:\s*"((?:[^"\\]|\\.|")*?)"/,a=o.match(n);if(a&&a[1])try{return a[1].replace(/\\n/g,`
|
|
56
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}catch{return a[1]}let s=/"text"\s*:\s*"((?:[^"\\]|\\.)*)/,i=o.match(s);if(i&&i[1])try{return i[1].replace(/\\n/g,`
|
|
57
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}catch{return i[1]}return null};return{getExtractedText:()=>r,processChunk:async o=>{if(o.length<=e)return r!==null?{text:r,raw:o}:null;let n=o.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;let a=t(o);return a!==null&&(r=a),e=o.length,r!==null?{text:r,raw:o}:null},close:async()=>{}}},xa=r=>{try{let e=JSON.parse(r);if(e&&typeof e=="object"&&typeof e.text=="string")return e.text}catch{return null}return null},rl=()=>{let r={processChunk:e=>null,getExtractedText:()=>null};return r.__isPlainTextParser=!0,r},ol=()=>{var e;let r=gv();return{processChunk:async t=>{let o=t.trim();return!o.startsWith("{")&&!o.startsWith("[")?null:r.processChunk(t)},getExtractedText:r.getExtractedText.bind(r),close:(e=r.close)==null?void 0:e.bind(r)}},nl=()=>{let r=null,e=0;return{getExtractedText:()=>r,processChunk:t=>{let o=t.trim();if(!o.startsWith("{")&&!o.startsWith("["))return null;if(t.length<=e)return r!==null||r===""?{text:r||"",raw:t}:null;try{let n=(0,Sn.parse)(t,Sn.STR|Sn.OBJ);n&&typeof n=="object"&&(n.component&&typeof n.component=="string"?r=typeof n.text=="string"?Ji(n.text):"":n.type==="init"&&n.form?r="":typeof n.text=="string"&&(r=Ji(n.text)))}catch{}return e=t.length,r!==null?{text:r,raw:t}:null},close:()=>{}}},Zh=r=>{let e=null,t=0,n=r||(a=>{if(!a||typeof a!="object")return null;let s=i=>typeof i=="string"?Ji(i):null;if(a.component&&typeof a.component=="string")return typeof a.text=="string"?Ji(a.text):"";if(a.type==="init"&&a.form)return"";if(a.action)switch(a.action){case"nav_then_click":return s(a.on_load_text)||s(a.text)||null;case"message":case"message_and_click":case"checkout":return s(a.text)||null;default:return s(a.text)||s(a.display_text)||s(a.message)||null}return s(a.text)||s(a.display_text)||s(a.message)||s(a.content)||null});return{getExtractedText:()=>e,processChunk:a=>{let s=a.trim();if(!s.startsWith("{")&&!s.startsWith("["))return null;if(a.length<=t)return e!==null?{text:e,raw:a}:null;try{let i=(0,Sn.parse)(a,Sn.STR|Sn.OBJ),d=n(i);d!==null&&(e=d)}catch{}return t=a.length,{text:e||"",raw:a}},close:()=>{}}},al=()=>{let r=null;return{processChunk:e=>{if(!e.trim().startsWith("<"))return null;let o=e.match(/<text[^>]*>([\s\S]*?)<\/text>/);return o&&o[1]?(r=o[1],{text:r,raw:e}):null},getExtractedText:()=>r}};var sl=class{constructor(e,t=50){this.nextExpectedSeq=null;this.buffer=new Map;this.flushTimer=null;this.emitter=e,this.gapTimeoutMs=t}push(e,t){var a,s,i;let o=(i=(a=t==null?void 0:t.seq)!=null?a:t==null?void 0:t.sequenceIndex)!=null?i:(s=t==null?void 0:t.agentContext)==null?void 0:s.seq;if(o==null){this.buffer.size>0&&this.flushAll(),this.emitter(e,t);return}if(this.nextExpectedSeq===null&&(this.nextExpectedSeq=1),o===this.nextExpectedSeq){this.emitter(e,t),this.nextExpectedSeq=o+1,this.drainConsecutive();return}if(o<this.nextExpectedSeq){this.emitter(e,t);return}let n=this.buffer.get(o);n!==void 0&&(typeof console!="undefined"&&typeof console.warn=="function"&&console.warn(`[persona] SequenceReorderBuffer: duplicate seq=${o} (${n.payloadType} vs ${e}); emitting earlier event out-of-order to avoid loss`),this.emitter(n.payloadType,n.payload)),this.buffer.set(o,{payloadType:e,payload:t,seq:o}),this.startGapTimer()}drainConsecutive(){for(;this.buffer.has(this.nextExpectedSeq);){let e=this.buffer.get(this.nextExpectedSeq);this.buffer.delete(this.nextExpectedSeq),this.emitter(e.payloadType,e.payload),this.nextExpectedSeq++}this.buffer.size===0&&this.clearGapTimer()}startGapTimer(){this.flushTimer===null&&(this.flushTimer=setTimeout(()=>{this.flushAll()},this.gapTimeoutMs))}clearGapTimer(){this.flushTimer!==null&&(clearTimeout(this.flushTimer),this.flushTimer=null)}flushAll(){if(this.clearGapTimer(),this.buffer.size===0)return;let e=[...this.buffer.entries()].sort((t,o)=>t[0]-o[0]);for(let[t,o]of e)this.buffer.delete(t),this.emitter(o.payloadType,o.payload);e.length>0&&(this.nextExpectedSeq=e[e.length-1][0]+1)}destroy(){this.clearGapTimer(),this.buffer.clear()}flushPending(){this.flushAll()}};var hv="https://api.runtype.com/v1/dispatch",il="https://api.runtype.com";function xv(r){var a,s;let e=r.toLowerCase(),o={"application/pdf":"pdf","application/json":"json","application/zip":"zip","text/plain":"txt","text/csv":"csv","text/markdown":"md"}[e];if(o)return`attachment.${o}`;let n=e.indexOf("/");if(n>0){let i=(s=(a=e.slice(n+1).split(";")[0])==null?void 0:a.trim())!=null?s:"";if(i&&i!=="octet-stream"&&/^[a-z0-9.+-]+$/i.test(i))return`attachment.${i}`}return"attachment"}var jd=r=>!!(r.contentParts&&r.contentParts.length>0||r.llmContent&&r.llmContent.trim().length>0||r.rawContent&&r.rawContent.trim().length>0||r.content&&r.content.trim().length>0);function yv(r){switch(r){case"json":return nl;case"regex-json":return ol;case"xml":return al;default:return rl}}var ex=r=>r.startsWith("{")||r.startsWith("[")||r.startsWith("<");function bv(r,e){if(!r)return e;let t=r.trim(),o=e.trim();if(t.length===0)return e;if(o.length===0)return r;let n=ex(t);if(!ex(o))return r;if(!n||o===t||o.startsWith(t))return e;let s=xa(r);return xa(e)!==null&&s===null?e:r}var ya=class{constructor(e={}){this.config=e;this.clientSession=null;this.sessionInitPromise=null;this.lastSentClientToolsFingerprint=null;this.clientToolsFingerprintSessionId=null;var t,o,n,a;this.apiUrl=(t=e.apiUrl)!=null?t:hv,this.headers={"Content-Type":"application/json",...e.headers},this.debug=!!e.debug,this.createStreamParser=(o=e.streamParser)!=null?o:yv(e.parserType),this.contextProviders=(n=e.contextProviders)!=null?n:[],this.requestMiddleware=e.requestMiddleware,this.customFetch=e.customFetch,this.parseSSEEvent=e.parseSSEEvent,this.getHeaders=e.getHeaders,this.webMcpBridge=((a=e.webmcp)==null?void 0:a.enabled)===!0?new Ga(e.webmcp):null}updateConfig(e){this.config=e}setSSEEventCallback(e){this.onSSEEvent=e}setWebMcpConfirmHandler(e){var t;(t=this.webMcpBridge)==null||t.setConfirmHandler(e)}isWebMcpOperational(){var e;return((e=this.webMcpBridge)==null?void 0:e.isOperational())===!0}executeWebMcpToolCall(e,t,o){return this.webMcpBridge?this.webMcpBridge.executeToolCall(e,t,o):null}getSSEEventCallback(){return this.onSSEEvent}isClientTokenMode(){return!!this.config.clientToken}isAgentMode(){return!!this.config.agent}getClientApiUrl(e){var o;return`${((o=this.config.apiUrl)==null?void 0:o.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||il}/v1/client/${e}`}getClientSession(){return this.clientSession}async initSession(){var e,t;if(!this.isClientTokenMode())throw new Error("initSession() only available in client token mode");if(this.clientSession&&new Date<this.clientSession.expiresAt)return this.clientSession;if(this.sessionInitPromise)return this.sessionInitPromise;this.sessionInitPromise=this._doInitSession();try{let o=await this.sessionInitPromise;return this.clientSession=o,this.resetClientToolsFingerprint(),(t=(e=this.config).onSessionInit)==null||t.call(e,o),o}finally{this.sessionInitPromise=null}}async _doInitSession(){var a,s;let e=((s=(a=this.config).getStoredSessionId)==null?void 0:s.call(a))||null,t={token:this.config.clientToken,...this.config.flowId&&{flowId:this.config.flowId},...e&&{sessionId:e}},o=await fetch(this.getClientApiUrl("init"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!o.ok){let i=await o.json().catch(()=>({error:"Session initialization failed"}));throw o.status===401?new Error(`Invalid client token: ${i.hint||i.error}`):o.status===403?new Error(`Origin not allowed: ${i.hint||i.error}`):new Error(i.error||"Failed to initialize session")}let n=await o.json();return this.config.setStoredSessionId&&this.config.setStoredSessionId(n.sessionId),{sessionId:n.sessionId,expiresAt:new Date(n.expiresAt),flow:n.flow,config:{welcomeMessage:n.config.welcomeMessage,placeholder:n.config.placeholder,theme:n.config.theme}}}clearClientSession(){this.clientSession=null,this.sessionInitPromise=null,this.resetClientToolsFingerprint()}resetClientToolsFingerprint(){this.lastSentClientToolsFingerprint=null,this.clientToolsFingerprintSessionId=null}getFeedbackApiUrl(){var t;return`${((t=this.config.apiUrl)==null?void 0:t.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||il}/v1/client/feedback`}async sendFeedback(e){var a,s;if(!this.isClientTokenMode())throw new Error("sendFeedback() only available in client token mode");if(!this.getClientSession())throw new Error("No active session. Please initialize session first.");if(["upvote","downvote","copy"].includes(e.type)&&!e.messageId)throw new Error(`messageId is required for ${e.type} feedback type`);if(e.type==="csat"&&(e.rating===void 0||e.rating<1||e.rating>5))throw new Error("CSAT rating must be between 1 and 5");if(e.type==="nps"&&(e.rating===void 0||e.rating<0||e.rating>10))throw new Error("NPS rating must be between 0 and 10");this.debug&&console.debug("[AgentWidgetClient] sending feedback",e);let n=await fetch(this.getFeedbackApiUrl(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){let i=await n.json().catch(()=>({error:"Feedback submission failed"}));throw n.status===401?(this.clientSession=null,(s=(a=this.config).onSessionExpired)==null||s.call(a),new Error("Session expired. Please refresh to continue.")):new Error(i.error||"Failed to submit feedback")}}async submitMessageFeedback(e,t){let o=this.getClientSession();if(!o)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:o.sessionId,messageId:e,type:t})}async submitCSATFeedback(e,t){let o=this.getClientSession();if(!o)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:o.sessionId,type:"csat",rating:e,comment:t})}async submitNPSFeedback(e,t){let o=this.getClientSession();if(!o)throw new Error("No active session. Please initialize session first.");return this.sendFeedback({sessionId:o.sessionId,type:"nps",rating:e,comment:t})}async dispatch(e,t){return this.isAgentMode()?this.dispatchAgent(e,t):this.isClientTokenMode()?this.dispatchClientToken(e,t):this.dispatchProxy(e,t)}async dispatchClientToken(e,t){var n,a,s,i;let o=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>o.abort()),t({type:"status",status:"connecting"});try{let d=await this.initSession();if(new Date>=new Date(d.expiresAt.getTime()-6e4)){this.clearClientSession(),(a=(n=this.config).onSessionExpired)==null||a.call(n);let x=new Error("Session expired. Please refresh to continue.");throw t({type:"error",error:x}),x}let l=await this.buildPayload(e.messages),u=l.metadata?Object.fromEntries(Object.entries(l.metadata).filter(([x])=>x!=="sessionId"&&x!=="session_id")):void 0,f={sessionId:d.sessionId,messages:e.messages.filter(jd).map(x=>{var w,v,E;return{id:x.id,role:x.role,content:(E=(v=(w=x.contentParts)!=null?w:x.llmContent)!=null?v:x.rawContent)!=null?E:x.content}}),...e.assistantMessageId&&{assistantMessageId:e.assistantMessageId},...u&&Object.keys(u).length>0&&{metadata:u},...l.inputs&&Object.keys(l.inputs).length>0&&{inputs:l.inputs},...l.context&&{context:l.context}},p=l.clientTools,m=!!(p&&p.length>0),y=m?Bh(p):void 0,h=this.clientToolsFingerprintSessionId===d.sessionId,T=m&&h&&this.lastSentClientToolsFingerprint===y,M=!1,k=null,L;for(let x=0;;x++){let v={...f,...m&&(M||!T)&&p?{clientTools:p}:{},...y?{clientToolsFingerprint:y}:{}};if(this.debug&&console.debug("[AgentWidgetClient] client token dispatch",v),L=await fetch(this.getClientApiUrl("chat"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v),signal:o.signal}),L.status===409&&x===0&&m){let E=await L.json().catch(()=>null);if((E==null?void 0:E.error)==="client_tools_resend_required"){M=!0,this.lastSentClientToolsFingerprint=null;continue}k=E!=null?E:{error:"Chat request failed"}}break}if(!L.ok){let x=k!=null?k:await L.json().catch(()=>({error:"Chat request failed"}));if(L.status===401){this.clearClientSession(),(i=(s=this.config).onSessionExpired)==null||i.call(s);let v=new Error("Session expired. Please refresh to continue.");throw t({type:"error",error:v}),v}if(L.status===429){let v=new Error(x.hint||"Message limit reached for this session.");throw t({type:"error",error:v}),v}let w=new Error(x.error||"Failed to send message");throw t({type:"error",error:w}),w}if(!L.body){let x=new Error("No response body received");throw t({type:"error",error:x}),x}this.lastSentClientToolsFingerprint=y!=null?y:null,this.clientToolsFingerprintSessionId=d.sessionId,t({type:"status",status:"connected"});try{await this.streamResponse(L.body,t,e.assistantMessageId)}finally{t({type:"status",status:"idle"})}}catch(d){let l=d instanceof Error?d:new Error(String(d));throw!l.message.includes("Session expired")&&!l.message.includes("Message limit")&&t({type:"error",error:l}),l}}async dispatchProxy(e,t){let o=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>o.abort()),t({type:"status",status:"connecting"});let n=await this.buildPayload(e.messages);this.debug&&console.debug("[AgentWidgetClient] dispatch payload",n);let a={...this.headers};if(this.getHeaders)try{let i=await this.getHeaders();a={...a,...i}}catch(i){typeof console!="undefined"&&console.error("[AgentWidget] getHeaders error:",i)}let s;if(this.customFetch)try{s=await this.customFetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(n),signal:o.signal},n)}catch(i){let d=i instanceof Error?i:new Error(String(i));throw t({type:"error",error:d}),d}else s=await fetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(n),signal:o.signal});if(!s.ok||!s.body){let i=new Error(`Chat backend request failed: ${s.status} ${s.statusText}`);throw t({type:"error",error:i}),i}t({type:"status",status:"connected"});try{await this.streamResponse(s.body,t)}finally{t({type:"status",status:"idle"})}}async dispatchAgent(e,t){let o=new AbortController;e.signal&&e.signal.addEventListener("abort",()=>o.abort()),t({type:"status",status:"connecting"});let n=await this.buildAgentPayload(e.messages);this.debug&&console.debug("[AgentWidgetClient] agent dispatch payload",n);let a={...this.headers};if(this.getHeaders)try{let i=await this.getHeaders();a={...a,...i}}catch(i){typeof console!="undefined"&&console.error("[AgentWidget] getHeaders error:",i)}let s;if(this.customFetch)try{s=await this.customFetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(n),signal:o.signal},n)}catch(i){let d=i instanceof Error?i:new Error(String(i));throw t({type:"error",error:d}),d}else s=await fetch(this.apiUrl,{method:"POST",headers:a,body:JSON.stringify(n),signal:o.signal});if(!s.ok||!s.body){let i=new Error(`Agent execution request failed: ${s.status} ${s.statusText}`);throw t({type:"error",error:i}),i}t({type:"status",status:"connected"});try{await this.streamResponse(s.body,t,e.assistantMessageId)}finally{t({type:"status",status:"idle"})}}async processStream(e,t,o){t({type:"status",status:"connected"});try{await this.streamResponse(e,t,o)}finally{t({type:"status",status:"idle"})}}async resolveApproval(e,t){var s;let n=`${((s=this.config.apiUrl)==null?void 0:s.replace(/\/+$/,"").replace(/\/v1\/dispatch$/,""))||il}/v1/agents/${e.agentId}/approve`,a={"Content-Type":"application/json",...this.headers};return this.getHeaders&&Object.assign(a,await this.getHeaders()),fetch(n,{method:"POST",headers:a,body:JSON.stringify({executionId:e.executionId,approvalId:e.approvalId,decision:t,streamResponse:!0})})}async resumeFlow(e,t,o){var l,u;let n=this.isClientTokenMode(),a=n?this.getClientApiUrl("resume"):`${((l=this.config.apiUrl)==null?void 0:l.replace(/\/+$/,""))||il}/resume`,s;n&&(s=(await this.initSession()).sessionId);let i={"Content-Type":"application/json",...this.headers};this.getHeaders&&Object.assign(i,await this.getHeaders());let d={executionId:e,toolOutputs:t,streamResponse:(u=o==null?void 0:o.streamResponse)!=null?u:!0};return s&&(d.sessionId=s),fetch(a,{method:"POST",headers:i,body:JSON.stringify(d),signal:o==null?void 0:o.signal})}async buildAgentPayload(e){var a,s;if(!this.config.agent)throw new Error("Agent configuration required for agent mode");let t=e.slice().filter(jd).filter(i=>i.role==="user"||i.role==="assistant"||i.role==="system").filter(i=>!i.variant||i.variant==="assistant").sort((i,d)=>{let l=new Date(i.createdAt).getTime(),u=new Date(d.createdAt).getTime();return l-u}).map(i=>{var d,l,u;return{role:i.role,content:(u=(l=(d=i.contentParts)!=null?d:i.llmContent)!=null?l:i.rawContent)!=null?u:i.content,createdAt:i.createdAt}}),o={agent:this.config.agent,messages:t,options:{streamResponse:!0,recordMode:"virtual",...this.config.agentOptions}},n=[...Gs(this.config),...(s=await((a=this.webMcpBridge)==null?void 0:a.snapshotForDispatch()))!=null?s:[]];if(n.length>0&&(o.clientTools=n),this.contextProviders.length){let i={};await Promise.all(this.contextProviders.map(async d=>{try{let l=await d({messages:e,config:this.config});l&&typeof l=="object"&&Object.assign(i,l)}catch(l){typeof console!="undefined"&&console.warn("[AgentWidget] Context provider failed:",l)}})),Object.keys(i).length&&(o.context=i)}return o}async buildPayload(e){var a,s;let o={messages:e.slice().filter(jd).sort((i,d)=>{let l=new Date(i.createdAt).getTime(),u=new Date(d.createdAt).getTime();return l-u}).map(i=>{var d,l,u;return{role:i.role,content:(u=(l=(d=i.contentParts)!=null?d:i.llmContent)!=null?l:i.rawContent)!=null?u:i.content,createdAt:i.createdAt}}),...this.config.flowId&&{flowId:this.config.flowId}},n=[...Gs(this.config),...(s=await((a=this.webMcpBridge)==null?void 0:a.snapshotForDispatch()))!=null?s:[]];if(n.length>0&&(o.clientTools=n),this.contextProviders.length){let i={};await Promise.all(this.contextProviders.map(async d=>{try{let l=await d({messages:e,config:this.config});l&&typeof l=="object"&&Object.assign(i,l)}catch(l){typeof console!="undefined"&&console.warn("[AgentWidget] Context provider failed:",l)}})),Object.keys(i).length&&(o.context=i)}if(this.requestMiddleware)try{let i=await this.requestMiddleware({payload:{...o},config:this.config});if(i&&typeof i=="object"){let d=i;return o.clientTools!==void 0&&!("clientTools"in d)&&(d.clientTools=o.clientTools),d}}catch(i){typeof console!="undefined"&&console.error("[AgentWidget] Request middleware error:",i)}return o}async handleCustomSSEEvent(e,t,o,n,a,s){if(!this.parseSSEEvent)return!1;try{let i=await this.parseSSEEvent(e);if(i===null)return!1;let d=u=>{let f={id:`assistant-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"assistant",sequence:a(),...u!==void 0&&{partId:u}};return o.current=f,n(f),f},l=u=>o.current?o.current:d(u);if(i.text!==void 0){i.partId!==void 0&&s.current!==null&&i.partId!==s.current&&(o.current&&(o.current.streaming=!1,n(o.current)),d(i.partId)),i.partId!==void 0&&(s.current=i.partId);let u=l(i.partId);i.partId!==void 0&&!u.partId&&(u.partId=i.partId),u.content+=i.text,n(u)}return i.done&&(o.current&&(o.current.streaming=!1,n(o.current)),s.current=null,t({type:"status",status:"idle"})),i.error&&(s.current=null,t({type:"error",error:new Error(i.error)})),!0}catch(i){return typeof console!="undefined"&&console.error("[AgentWidget] parseSSEEvent error:",i),!1}}async streamResponse(e,t,o){var Rt,dr,Yr,zr;let n=e.getReader(),a=new TextDecoder,s="",i=Date.now(),d=0,l=()=>i+d++,u=O=>{let fe=O.reasoning?{...O.reasoning,chunks:[...O.reasoning.chunks]}:void 0,Ie=O.toolCall?{...O.toolCall,chunks:O.toolCall.chunks?[...O.toolCall.chunks]:void 0}:void 0,Je=O.tools?O.tools.map(qe=>({...qe,chunks:qe.chunks?[...qe.chunks]:void 0})):void 0;return{...O,reasoning:fe,toolCall:Ie,tools:Je}},f=O=>{if(O.role!=="assistant"||O.variant)return!0;let fe=Array.isArray(O.contentParts)&&O.contentParts.length>0,Ie=typeof O.rawContent=="string"&&O.rawContent.trim()!=="";return typeof O.content=="string"&&O.content.trim()!==""||fe||Ie||!!O.stopReason},p=O=>{f(O)&&t({type:"message",message:u(O)})},m=null,y=null,h={current:null},T={current:null},M=!1,k=new Map,L=new Map,x=new Map,w=new Map,v={lastId:null,byStep:new Map},E={lastId:null,byCall:new Map},H=(O,fe,Ie="")=>`${O}::${fe}::${Ie}`,I=(O,fe)=>`${O}::${fe}::`,P=(O,fe,Ie,Je)=>{let qe=H(O,fe,Ie),ze=x.get(qe);if(ze)return ze;let lt=Ie?`-${Ie}`:"",Mt={id:`nested-${O}-${fe}${lt}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l(),...Ie?{partId:Ie}:{},agentMetadata:{executionId:Je,parentToolId:O,parentStepId:fe}};return x.set(qe,Mt),p(Mt),Mt},z=O=>{if(O==null)return null;try{return String(O)}catch{return null}},j=O=>{var fe,Ie,Je,qe,ze;return z((ze=(qe=(Je=(Ie=(fe=O.stepId)!=null?fe:O.step_id)!=null?Ie:O.step)!=null?Je:O.parentId)!=null?qe:O.flowStepId)!=null?ze:O.flow_step_id)},ie=O=>{var fe,Ie,Je,qe,ze,lt,Mt;return z((Mt=(lt=(ze=(qe=(Je=(Ie=(fe=O.callId)!=null?fe:O.call_id)!=null?Ie:O.requestId)!=null?Je:O.request_id)!=null?qe:O.toolCallId)!=null?ze:O.tool_call_id)!=null?lt:O.stepId)!=null?Mt:O.step_id)},ve=o,Xe=!1,Ae=()=>{if(m)return m;let O;return!Xe&&ve?(O=ve,Xe=!0):ve&&T.current?O=`${ve}_${T.current}`:O=`assistant-${Date.now()}-${Math.random().toString(16).slice(2)}`,m={id:O,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l()},p(m),m},We=(O,fe)=>{v.lastId=fe,O&&v.byStep.set(O,fe)},Me=(O,fe)=>{var ze;let Ie=(ze=O.reasoningId)!=null?ze:O.id,Je=j(O);if(Ie){let lt=String(Ie);return We(Je,lt),lt}if(Je){let lt=v.byStep.get(Je);if(lt)return v.lastId=lt,lt}if(v.lastId&&!fe)return v.lastId;if(!fe)return null;let qe=`reason-${l()}`;return We(Je,qe),qe},Ue=O=>{let fe=k.get(O);if(fe)return fe;let Ie={id:`reason-${O}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"reasoning",sequence:l(),reasoning:{id:O,status:"streaming",chunks:[]}};return k.set(O,Ie),p(Ie),Ie},Be=(O,fe)=>{E.lastId=fe,O&&E.byCall.set(O,fe)},Z=new Set,ne=new Map,me=new Set,be=new Map,ye=O=>{if(!O)return!1;let fe=O.replace(/_+/g,"_").replace(/^_|_$/g,"");return fe==="emit_artifact_markdown"||fe==="emit_artifact_component"},Y=(O,fe)=>{var ze;let Ie=(ze=O.toolId)!=null?ze:O.id,Je=ie(O);if(Ie){let lt=String(Ie);return Be(Je,lt),lt}if(Je){let lt=E.byCall.get(Je);if(lt)return E.lastId=lt,lt}if(E.lastId&&!fe)return E.lastId;if(!fe)return null;let qe=`tool-${l()}`;return Be(Je,qe),qe},ge=O=>{let fe=L.get(O);if(fe)return fe;let Ie={id:`tool-${O}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,variant:"tool",sequence:l(),toolCall:{id:O,status:"pending"}};return L.set(O,Ie),p(Ie),Ie},Oe=O=>{if(typeof O=="number"&&Number.isFinite(O))return O;if(typeof O=="string"){let fe=Number(O);if(!Number.isNaN(fe)&&Number.isFinite(fe))return fe;let Ie=Date.parse(O);if(!Number.isNaN(Ie))return Ie}return Date.now()},ce=O=>{if(typeof O=="string")return O;if(O==null)return"";try{return JSON.stringify(O)}catch{return String(O)}},ae=new Map,Q=new Map,Tt=new Map,Ye=new Map,De=null,le=(O,fe,Ie)=>{var Mt;let Je=Tt.get(O);Je||(Je=[],Tt.set(O,Je));let qe=0,ze=Je.length;for(;qe<ze;){let Dt=qe+ze>>>1;Je[Dt].seq<fe?qe=Dt+1:ze=Dt}((Mt=Je[qe])==null?void 0:Mt.seq)===fe?Je[qe]={seq:fe,text:Ie}:Je.splice(qe,0,{seq:fe,text:Ie});let lt="";for(let Dt=0;Dt<Je.length;Dt++)lt+=Je[Dt].text;return lt},nt=(O,fe)=>{let Ie=ce(fe),Je=Q.get(O.id),qe=bv(Je,Ie);O.rawContent=qe;let ze=ae.get(O.id),lt=wt=>{var Ce;let ct=(Ce=O.content)!=null?Ce:"";wt.trim()!==""&&(ct.trim().length===0||wt.startsWith(ct)||wt.trimStart().startsWith(ct.trim()))&&(O.content=wt)},Mt=()=>{var wt;if(ze){let ct=(wt=ze.close)==null?void 0:wt.call(ze);ct instanceof Promise&&ct.catch(()=>{})}ae.delete(O.id),Q.delete(O.id),O.streaming=!1,p(O)};if(!ze){lt(Ie),Mt();return}let Dt=xa(qe);if(Dt!==null&&Dt.trim()!==""){lt(Dt),Mt();return}let or=wt=>{var de;let ct=typeof wt=="string"?wt:(de=wt==null?void 0:wt.text)!=null?de:null;if(ct!==null&&ct.trim()!=="")return ct;let Ce=ze.getExtractedText();return Ce!==null&&Ce.trim()!==""?Ce:Ie},X;try{X=ze.processChunk(qe)}catch{lt(Ie),Mt();return}if(X instanceof Promise){X.then(wt=>{lt(or(wt)),Mt()}).catch(()=>{lt(Ie),Mt()});return}lt(or(X)),Mt()},Re=[],K=!1,he,it=()=>{K||(K=!0,queueMicrotask(()=>{K=!1,he()}))},Pt=new sl((O,fe)=>{Re.push({payloadType:O,payload:fe}),it()}),te=null,_e=new Map,Ar=(Rt=this.config.iterationDisplay)!=null?Rt:"separate";for(he=()=>{var O,fe,Ie,Je,qe,ze,lt,Mt,Dt,or,X,wt,ct,Ce,de,rt,Ft,zt,Pr,vr,xt,It,tt,jt,cr,Dr,hr,Sr,Oo,je,Tr,io,_o,lo,At,rn,No,mn,Jr,Ln,$r,Fo,mt,co,po,Or,Wt,Vr,Zr,_r,uo,fo,Nr,mo,$t,Fr,go,on,Uo,nn,qo,eo,to,gt,re,A,_,ue,$,at,ut,U,nr,mr,Cr,ko,sr,Ko,us,Eo,Lo,Xo,Qo,Qn,gn,ro,an,Pa,Yn,Ra,bi,Ia,vi,Ha,Lt,fs,zo,So,Ci,wi,Wa,hn,ms,Pn,gs,hs,xs,ys,To,Ba,sn,ln,bs,Ai,vs,Cs,Jn,Si,Ti,Mi,ki,dd,Zn,Rn,Ei,ws,In,Li,As,Hn,Ss,Pi,xn,Ri,Wn,Gt,Da,Oa;for(let ea=0;ea<Re.length;ea++){let Ke=Re[ea].payloadType,R=Re[ea].payload;if(Ke==="reason_start"){let V=(O=Me(R,!0))!=null?O:`reason-${l()}`,B=Ue(V);B.reasoning=(fe=B.reasoning)!=null?fe:{id:V,status:"streaming",chunks:[]},B.reasoning.startedAt=(Je=B.reasoning.startedAt)!=null?Je:Oe((Ie=R.startedAt)!=null?Ie:R.timestamp),B.reasoning.completedAt=void 0,B.reasoning.durationMs=void 0,B.streaming=!0,B.reasoning.status="streaming",p(B)}else if(Ke==="reason_delta"||Ke==="reason_chunk"){let V=(ze=(qe=Me(R,!1))!=null?qe:Me(R,!0))!=null?ze:`reason-${l()}`,B=Ue(V);B.reasoning=(lt=B.reasoning)!=null?lt:{id:V,status:"streaming",chunks:[]},B.reasoning.startedAt=(Dt=B.reasoning.startedAt)!=null?Dt:Oe((Mt=R.startedAt)!=null?Mt:R.timestamp);let oe=(wt=(X=(or=R.reasoningText)!=null?or:R.text)!=null?X:R.delta)!=null?wt:"";if(oe&&R.hidden!==!0){let pe=typeof R.sequenceIndex=="number"?R.sequenceIndex:void 0;if(pe!==void 0){let J=le(V,pe,String(oe));B.reasoning.chunks=[J]}else B.reasoning.chunks.push(String(oe))}if(B.reasoning.status=R.done?"complete":"streaming",R.done){B.reasoning.completedAt=Oe((ct=R.completedAt)!=null?ct:R.timestamp);let pe=(Ce=B.reasoning.startedAt)!=null?Ce:Date.now();B.reasoning.durationMs=Math.max(0,((de=B.reasoning.completedAt)!=null?de:Date.now())-pe)}B.streaming=B.reasoning.status!=="complete",p(B)}else if(Ke==="reason_complete"){let V=(Ft=(rt=Me(R,!1))!=null?rt:Me(R,!0))!=null?Ft:`reason-${l()}`,B=k.get(V);if(B!=null&&B.reasoning){B.reasoning.status="complete",B.reasoning.completedAt=Oe((zt=R.completedAt)!=null?zt:R.timestamp);let pe=(Pr=B.reasoning.startedAt)!=null?Pr:Date.now();B.reasoning.durationMs=Math.max(0,((vr=B.reasoning.completedAt)!=null?vr:Date.now())-pe),B.streaming=!1,p(B)}let oe=j(R);oe&&v.byStep.delete(oe)}else if(Ke==="tool_start"){let V=(xt=Y(R,!0))!=null?xt:`tool-${l()}`,B=(It=R.toolName)!=null?It:R.name;if(ye(B)){Z.add(V);continue}let oe=ge(V),pe=(tt=oe.toolCall)!=null?tt:{id:V,status:"pending"};pe.name=B!=null?B:pe.name,pe.status="running",R.args!==void 0?pe.args=R.args:R.parameters!==void 0&&(pe.args=R.parameters),pe.startedAt=(cr=pe.startedAt)!=null?cr:Oe((jt=R.startedAt)!=null?jt:R.timestamp),pe.completedAt=void 0,pe.durationMs=void 0,oe.toolCall=pe,oe.streaming=!0;let J=R.agentContext;(J||R.executionId)&&(oe.agentMetadata={executionId:(Dr=J==null?void 0:J.executionId)!=null?Dr:R.executionId,iteration:(hr=J==null?void 0:J.iteration)!=null?hr:R.iteration}),p(oe)}else if(Ke==="tool_chunk"||Ke==="tool_delta"){let V=(Oo=(Sr=Y(R,!1))!=null?Sr:Y(R,!0))!=null?Oo:`tool-${l()}`;if(Z.has(V))continue;let B=ge(V),oe=(je=B.toolCall)!=null?je:{id:V,status:"running"};oe.startedAt=(io=oe.startedAt)!=null?io:Oe((Tr=R.startedAt)!=null?Tr:R.timestamp);let pe=(At=(lo=(_o=R.text)!=null?_o:R.delta)!=null?lo:R.message)!=null?At:"";pe&&(oe.chunks=(rn=oe.chunks)!=null?rn:[],oe.chunks.push(String(pe))),oe.status="running",B.toolCall=oe,B.streaming=!0;let J=R.agentContext;(J||R.executionId)&&(B.agentMetadata=(Jr=B.agentMetadata)!=null?Jr:{executionId:(No=J==null?void 0:J.executionId)!=null?No:R.executionId,iteration:(mn=J==null?void 0:J.iteration)!=null?mn:R.iteration}),p(B)}else if(Ke==="tool_complete"){let V=($r=(Ln=Y(R,!1))!=null?Ln:Y(R,!0))!=null?$r:`tool-${l()}`;if(Z.has(V)){Z.delete(V);continue}let B=ge(V),oe=(Fo=B.toolCall)!=null?Fo:{id:V,status:"running"};oe.status="complete",R.result!==void 0&&(oe.result=R.result),typeof R.duration=="number"&&(oe.duration=R.duration),oe.completedAt=Oe((mt=R.completedAt)!=null?mt:R.timestamp);let pe=(co=R.duration)!=null?co:R.executionTime;if(typeof pe=="number")oe.durationMs=pe;else{let Ve=(po=oe.startedAt)!=null?po:Date.now();oe.durationMs=Math.max(0,((Or=oe.completedAt)!=null?Or:Date.now())-Ve)}B.toolCall=oe,B.streaming=!1;let J=R.agentContext;(J||R.executionId)&&(B.agentMetadata=(Zr=B.agentMetadata)!=null?Zr:{executionId:(Wt=J==null?void 0:J.executionId)!=null?Wt:R.executionId,iteration:(Vr=J==null?void 0:J.iteration)!=null?Vr:R.iteration}),p(B);let Le=ie(R);Le&&E.byCall.delete(Le)}else if(Ke==="step_await"&&R.awaitReason==="local_tool_required"&&R.toolName){let V=typeof R.toolCallId=="string"&&R.toolCallId.length>0?R.toolCallId:void 0,B=(_r=V!=null?V:R.toolId)!=null?_r:`local-${l()}`,oe=ge(B),pe=R.toolName,J=ga(pe),Le=(uo=oe.toolCall)!=null?uo:{id:B,status:"pending"};Le.name=pe,Le.args=R.parameters,Le.status=J?"running":"complete",Le.chunks=(fo=Le.chunks)!=null?fo:[],Le.startedAt=(mo=Le.startedAt)!=null?mo:Oe((Nr=R.startedAt)!=null?Nr:R.timestamp),J?(Le.completedAt=void 0,Le.duration=void 0,Le.durationMs=void 0):Le.completedAt=($t=Le.completedAt)!=null?$t:Le.startedAt,oe.toolCall=Le,oe.streaming=!1,oe.agentMetadata={...oe.agentMetadata,executionId:(go=R.executionId)!=null?go:(Fr=oe.agentMetadata)==null?void 0:Fr.executionId,awaitingLocalTool:!0,...V?{webMcpToolCallId:V}:{}},p(oe)}else if(Ke==="text_start"){if((on=R.toolContext)!=null&&on.toolId)continue;let V=R.partId;if(V!==void 0&&T.current!==null&&V!==T.current){let B=m;B&&(B.streaming=!1,p(B),De=B,m=null,M=!0)}V!==void 0&&(T.current=V)}else if(Ke==="text_end"){if((Uo=R.toolContext)!=null&&Uo.toolId)continue;let V=m;V&&(V.streaming=!1,p(V),De=V,m=null,M=!0)}else if(Ke==="step_chunk"||Ke==="step_delta"){let V=R.stepType,B=R.executionType;if(V==="tool"||B==="context")continue;let oe=R.toolContext;if(oe!=null&&oe.toolId){let Ve=String((qo=(nn=R.id)!=null?nn:oe.stepId)!=null?qo:`step-${l()}`),yt=R.partId!==void 0&&R.partId!==null?String(R.partId):"",dt=`${oe.toolId}::${Ve}`,Vt=w.get(dt);if(yt!==""&&Vt!==void 0&&Vt!==""&&Vt!==yt){let ht=x.get(H(oe.toolId,Ve,Vt));ht&&ht.streaming!==!1&&(ht.streaming=!1,p(ht))}yt!==""&&w.set(dt,yt);let Jt=P(oe.toolId,Ve,yt,oe.executionId),Rr=(re=(gt=(to=(eo=R.text)!=null?eo:R.delta)!=null?to:R.content)!=null?gt:R.chunk)!=null?re:"";Rr&&(Jt.content+=String(Rr),Jt.streaming=!0,p(Jt)),R.isComplete&&(Jt.streaming=!1,p(Jt));continue}let pe=R.partId;if(pe!==void 0&&T.current!==null&&pe!==T.current){let Ve=m;Ve&&(Ve.streaming=!1,p(Ve),De=Ve,m=null,M=!0)}pe!==void 0&&(T.current=pe);let J=pe!==void 0&&(A=Ye.get(pe))!=null?A:Ae();pe!==void 0&&(J.partId||(J.partId=pe),Ye.set(pe,J));let Le=(at=($=(ue=(_=R.text)!=null?_:R.delta)!=null?ue:R.content)!=null?$:R.chunk)!=null?at:"";if(Le){let Ve=typeof R.seq=="number"?R.seq:void 0,yt=pe!=null?pe:J.id,dt=Ve!==void 0?le(yt,Ve,String(Le)):((ut=Q.get(J.id))!=null?ut:"")+Le;J.rawContent=dt,ae.has(J.id)||ae.set(J.id,this.createStreamParser());let Vt=ae.get(J.id),Jt=dt.trim().startsWith("{")||dt.trim().startsWith("[");if(Jt&&Q.set(J.id,dt),Vt.__isPlainTextParser===!0){J.content=Ve!==void 0?dt:J.content+Le,Q.delete(J.id),ae.delete(J.id),J.rawContent=void 0,p(J);continue}let ht=Vt.processChunk(dt);if(ht instanceof Promise)ht.then(kt=>{var et;let gr=typeof kt=="string"?kt:(et=kt==null?void 0:kt.text)!=null?et:null;if(gr!==null&&gr.trim()!=="")J.content=gr,p(J);else if(!Jt&&!dt.trim().startsWith("<")){let jr=m,pr=jr&&jr.id===J.id?jr:J;pr.id===J.id&&(pr.content=Ve!==void 0?dt:pr.content+Le,Q.delete(pr.id),ae.delete(pr.id),pr.rawContent=void 0,p(pr))}}).catch(()=>{J.content=Ve!==void 0?dt:J.content+Le,Q.delete(J.id),ae.delete(J.id),J.rawContent=void 0,p(J)});else{let kt=typeof ht=="string"?ht:(U=ht==null?void 0:ht.text)!=null?U:null;kt!==null&&kt.trim()!==""?(J.content=kt,p(J)):!Jt&&!dt.trim().startsWith("<")&&(J.content=Ve!==void 0?dt:J.content+Le,Q.delete(J.id),ae.delete(J.id),J.rawContent=void 0,p(J))}}if(R.isComplete){let Ve=(mr=(nr=R.result)==null?void 0:nr.response)!=null?mr:J.content;if(Ve){let yt=Q.get(J.id),dt=yt!=null?yt:ce(Ve);J.rawContent=dt;let Vt=ae.get(J.id),Jt=null,Rr=!1;if(Vt&&(Jt=Vt.getExtractedText(),Jt===null&&(Jt=xa(dt)),Jt===null)){let ht=Vt.processChunk(dt);ht instanceof Promise?(Rr=!0,ht.then(kt=>{var et;let gr=typeof kt=="string"?kt:(et=kt==null?void 0:kt.text)!=null?et:null;if(gr!==null){let jr=m;jr&&jr.id===J.id&&(jr.content=gr,jr.streaming=!1,ae.delete(jr.id),Q.delete(jr.id),p(jr))}})):Jt=typeof ht=="string"?ht:(Cr=ht==null?void 0:ht.text)!=null?Cr:null}if(!Rr){Jt!==null&&Jt.trim()!==""?J.content=Jt:Q.has(J.id)||(J.content=ce(Ve));let ht=ae.get(J.id);if(ht){let kt=(ko=ht.close)==null?void 0:ko.call(ht);kt instanceof Promise&&kt.catch(()=>{}),ae.delete(J.id)}Q.delete(J.id),J.streaming=!1,p(J)}}}}else if(Ke==="step_complete"){let V=R.stepType,B=R.executionType;if(V==="tool"||B==="context")continue;let oe=R.toolContext;if(oe!=null&&oe.toolId){let Ve=String((Ko=(sr=R.id)!=null?sr:oe.stepId)!=null?Ko:"");if(Ve){let yt=I(oe.toolId,Ve);for(let[dt,Vt]of x)dt.startsWith(yt)&&Vt.streaming!==!1&&(Vt.streaming=!1,p(Vt));w.delete(`${oe.toolId}::${Ve}`)}continue}let pe=R.stopReason;if(M){if(m!==null){let dt=m;pe&&(dt.stopReason=pe),ae.delete(dt.id),Q.delete(dt.id),dt.streaming!==!1&&(dt.streaming=!1,p(dt))}let Ve=(us=R.result)==null?void 0:us.response,yt=De;yt&&(pe&&(yt.stopReason=pe),Ve!=null?nt(yt,Ve):(ae.delete(yt.id),Q.delete(yt.id))),De=null;continue}let J=(Eo=R.result)==null?void 0:Eo.response,Le=Ae();if(pe&&(Le.stopReason=pe),J!=null){let Ve=ae.get(Le.id),yt=!1,dt=!1;if(Ve){let Vt=Ve.getExtractedText(),Jt=Q.get(Le.id),Rr=Jt!=null?Jt:ce(J);if(Le.rawContent=Rr,Vt!==null&&Vt.trim()!=="")Le.content=Vt,yt=!0;else{let ht=xa(Rr);if(ht!==null)Le.content=ht,yt=!0;else{let kt=Ve.processChunk(Rr);if(kt instanceof Promise)dt=!0,kt.then(gr=>{var jr;let et=typeof gr=="string"?gr:(jr=gr==null?void 0:gr.text)!=null?jr:null;if(et!==null&&et.trim()!==""){let pr=m;pr&&pr.id===Le.id&&(pr.content=et,pr.streaming=!1,ae.delete(pr.id),Q.delete(pr.id),p(pr))}else{let pr=Ve.getExtractedText(),Ur=m;Ur&&Ur.id===Le.id&&(pr!==null&&pr.trim()!==""?Ur.content=pr:Q.has(Ur.id)||(Ur.content=ce(J)),Ur.streaming=!1,ae.delete(Ur.id),Q.delete(Ur.id),p(Ur))}});else{let gr=typeof kt=="string"?kt:(Lo=kt==null?void 0:kt.text)!=null?Lo:null;if(gr!==null&&gr.trim()!=="")Le.content=gr,yt=!0;else{let et=Ve.getExtractedText();et!==null&&et.trim()!==""&&(Le.content=et,yt=!0)}}}}}if(!dt){if(!Le.rawContent){let Vt=Q.get(Le.id);Le.rawContent=Vt!=null?Vt:ce(J)}if(!yt&&!Q.has(Le.id)&&(Le.content=ce(J)),Ve){let Vt=(Xo=Ve.close)==null?void 0:Xo.call(Ve);Vt instanceof Promise&&Vt.catch(()=>{})}ae.delete(Le.id),Q.delete(Le.id),Le.streaming=!1,p(Le)}}else ae.delete(Le.id),Q.delete(Le.id),Le.streaming=!1,p(Le)}else if(Ke==="flow_complete"){let V=(Qo=R.result)==null?void 0:Qo.response;if(M){if(m!==null){let B=m;ae.delete(B.id),Q.delete(B.id),B.streaming!==!1&&(B.streaming=!1,p(B))}}else if(V!=null){let B=Ae(),oe=Q.get(B.id),pe=oe!=null?oe:ce(V);B.rawContent=pe;let J=ce(V),Le=ae.get(B.id);if(Le){let dt=xa(pe);if(dt!==null)J=dt;else{let Vt=Le.processChunk(pe);Vt instanceof Promise&&Vt.then(Rr=>{var kt;let ht=typeof Rr=="string"?Rr:(kt=Rr==null?void 0:Rr.text)!=null?kt:null;ht!==null&&(B.content=ht,B.streaming=!1,p(B))});let Jt=Le.getExtractedText();Jt!==null&&(J=Jt)}}ae.delete(B.id),Q.delete(B.id);let Ve=J!==B.content,yt=B.streaming!==!1;Ve&&(B.content=J),B.streaming=!1,(Ve||yt)&&p(B)}else if(m!==null){let B=m;ae.delete(B.id),Q.delete(B.id),B.streaming!==!1&&(B.streaming=!1,p(B))}t({type:"status",status:"idle"})}else if(Ke==="agent_start")te={executionId:R.executionId,agentId:(Qn=R.agentId)!=null?Qn:"virtual",agentName:(gn=R.agentName)!=null?gn:"",status:"running",currentIteration:0,maxTurns:(ro=R.maxTurns)!=null?ro:1,startedAt:Oe(R.startedAt)};else if(Ke==="agent_iteration_start"){if(te&&(te.currentIteration=R.iteration),Ar==="separate"&&R.iteration>1){let V=m;V&&(V.streaming=!1,p(V),_e.set(R.iteration-1,V),m=null)}}else if(Ke==="agent_turn_start")y=null;else if(Ke==="agent_turn_delta"){if(R.contentType==="text"){let V=Ae();V.content+=(an=R.delta)!=null?an:"",V.agentMetadata={executionId:R.executionId,iteration:R.iteration,turnId:R.turnId,agentName:te==null?void 0:te.agentName},y=V,p(V)}else if(R.contentType==="thinking"){let V=(Pa=R.turnId)!=null?Pa:`agent-think-${R.iteration}`,B=Ue(V);B.reasoning=(Yn=B.reasoning)!=null?Yn:{id:V,status:"streaming",chunks:[]},B.reasoning.chunks.push((Ra=R.delta)!=null?Ra:""),B.agentMetadata={executionId:R.executionId,iteration:R.iteration,turnId:R.turnId},p(B)}else if(R.contentType==="tool_input"){let V=(bi=R.toolCallId)!=null?bi:E.lastId;if(V){let B=L.get(V);B!=null&&B.toolCall&&(B.toolCall.chunks=(Ia=B.toolCall.chunks)!=null?Ia:[],B.toolCall.chunks.push((vi=R.delta)!=null?vi:""),p(B))}}}else if(Ke==="agent_turn_complete"){let V=R.turnId;if(V){let pe=k.get(V);if(pe!=null&&pe.reasoning){pe.reasoning.status="complete",pe.reasoning.completedAt=Oe(R.completedAt);let J=(Ha=pe.reasoning.startedAt)!=null?Ha:Date.now();pe.reasoning.durationMs=Math.max(0,((Lt=pe.reasoning.completedAt)!=null?Lt:Date.now())-J),pe.streaming=!1,p(pe)}}let B=R.stopReason,oe=m!=null?m:y;if(B&&oe!==null){let pe=R.turnId;(!pe||((fs=oe.agentMetadata)==null?void 0:fs.turnId)===pe)&&(oe.stopReason=B,p(oe))}}else if(Ke==="agent_tool_start"){m&&(m.streaming=!1,p(m),m=null);let V=(zo=R.toolCallId)!=null?zo:`agent-tool-${l()}`;Be(ie(R),V);let B=ge(V),oe=(So=B.toolCall)!=null?So:{id:V,status:"pending",name:void 0,args:void 0,chunks:void 0,result:void 0,duration:void 0,startedAt:void 0,completedAt:void 0,durationMs:void 0};oe.name=(wi=(Ci=R.toolName)!=null?Ci:R.name)!=null?wi:oe.name,oe.status="running",R.parameters!==void 0&&(oe.args=R.parameters),oe.startedAt=Oe((Wa=R.startedAt)!=null?Wa:R.timestamp),B.toolCall=oe,B.streaming=!0,B.agentMetadata={executionId:R.executionId,iteration:R.iteration},p(B)}else if(Ke==="agent_tool_delta"){let V=(hn=R.toolCallId)!=null?hn:E.lastId;if(V){let B=(ms=L.get(V))!=null?ms:ge(V);B.toolCall&&(B.toolCall.chunks=(Pn=B.toolCall.chunks)!=null?Pn:[],B.toolCall.chunks.push((gs=R.delta)!=null?gs:""),B.toolCall.status="running",B.streaming=!0,p(B))}}else if(Ke==="agent_tool_complete"){let V=(hs=R.toolCallId)!=null?hs:E.lastId;if(V){let B=(xs=L.get(V))!=null?xs:ge(V);if(B.toolCall){B.toolCall.status="complete",R.result!==void 0&&(B.toolCall.result=R.result),typeof R.executionTime=="number"&&(B.toolCall.durationMs=R.executionTime),B.toolCall.completedAt=Oe((ys=R.completedAt)!=null?ys:R.timestamp),B.streaming=!1,p(B);let oe=ie(R);oe&&E.byCall.delete(oe)}}}else if(Ke==="agent_media"){let V=Array.isArray(R.media)?R.media:[],B=[];for(let oe of V){if(!oe||typeof oe!="object")continue;let pe=oe,J=typeof pe.type=="string"?pe.type:void 0,Le=typeof pe.mediaType=="string"?pe.mediaType.toLowerCase():"",Ve=null,yt="";if(J==="media"){let dt=typeof pe.data=="string"?pe.data:void 0;if(!dt)continue;yt=Le.length>0?Le:"application/octet-stream",Ve=`data:${yt};base64,${dt}`}else if(J==="image-url"){let dt=typeof pe.url=="string"?pe.url:void 0;if(!dt)continue;yt=Le,Ve=dt}else if(J==="file-url"){let dt=typeof pe.url=="string"?pe.url:void 0;if(!dt)continue;yt=Le,Ve=dt}else continue;if(Ve)if(J==="image-url"||yt.startsWith("image/"))B.push({type:"image",image:Ve,...yt?{mimeType:yt}:{}});else if(yt.startsWith("audio/"))B.push({type:"audio",audio:Ve,mimeType:yt});else if(yt.startsWith("video/"))B.push({type:"video",video:Ve,mimeType:yt});else{let dt=yt||"application/octet-stream";B.push({type:"file",data:Ve,mimeType:dt,filename:xv(dt)})}}if(B.length>0){let oe=l(),pe=R.toolCallId,Le={id:`agent-media-${typeof pe=="string"&&pe.length>0?`${pe}-${oe}`:String(oe)}`,role:"assistant",content:"",contentParts:B,createdAt:new Date().toISOString(),streaming:!1,sequence:oe,agentMetadata:{executionId:R.executionId,iteration:R.iteration}};p(Le);let Ve=m;Ve&&(Ve.streaming=!1,p(Ve)),m=null,h.current=null}}else if(Ke!=="agent_iteration_complete"){if(Ke==="agent_reflection"||Ke==="agent_reflect"){let V=`agent-reflection-${R.executionId}-${R.iteration}`,B={id:V,role:"assistant",content:(To=R.reflection)!=null?To:"",createdAt:new Date().toISOString(),streaming:!1,variant:"reasoning",sequence:l(),reasoning:{id:V,status:"complete",chunks:[(Ba=R.reflection)!=null?Ba:""]},agentMetadata:{executionId:R.executionId,iteration:R.iteration}};p(B)}else if(Ke==="agent_complete"){te&&(te.status=R.success?"complete":"error",te.completedAt=Oe(R.completedAt),te.stopReason=R.stopReason);let V=m;V&&(V.streaming=!1,p(V)),t({type:"status",status:"idle"})}else if(Ke==="agent_error"){let V=typeof R.error=="string"?R.error:(ln=(sn=R.error)==null?void 0:sn.message)!=null?ln:"Agent execution error";R.recoverable?typeof console!="undefined"&&console.warn("[AgentWidget] Recoverable agent error:",V):t({type:"error",error:new Error(V)})}else if(Ke!=="agent_ping"){if(Ke==="agent_approval_start"){let V=(bs=R.approvalId)!=null?bs:`approval-${l()}`,B={id:`approval-${V}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:V,status:"pending",agentId:(Ai=te==null?void 0:te.agentId)!=null?Ai:"virtual",executionId:(Cs=(vs=R.executionId)!=null?vs:te==null?void 0:te.executionId)!=null?Cs:"",toolName:(Jn=R.toolName)!=null?Jn:"",toolType:R.toolType,description:(Ti=R.description)!=null?Ti:`Execute ${(Si=R.toolName)!=null?Si:"tool"}`,...typeof R.reason=="string"&&R.reason?{reason:R.reason}:{},parameters:R.parameters}};p(B)}else if(Ke==="step_await"&&R.awaitReason==="approval_required"){let V=(Mi=R.approvalId)!=null?Mi:`approval-${l()}`,B={id:`approval-${V}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:V,status:"pending",agentId:(ki=te==null?void 0:te.agentId)!=null?ki:"virtual",executionId:(Zn=(dd=R.executionId)!=null?dd:te==null?void 0:te.executionId)!=null?Zn:"",toolName:(Rn=R.toolName)!=null?Rn:"",toolType:R.toolType,description:(ws=R.description)!=null?ws:`Execute ${(Ei=R.toolName)!=null?Ei:"tool"}`,...typeof R.reason=="string"&&R.reason?{reason:R.reason}:{},parameters:R.parameters}};p(B)}else if(Ke==="agent_approval_complete"){let V=R.approvalId;if(V){let oe={id:`approval-${V}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",sequence:l(),approval:{id:V,status:(In=R.decision)!=null?In:"approved",agentId:(Li=te==null?void 0:te.agentId)!=null?Li:"virtual",executionId:(Hn=(As=R.executionId)!=null?As:te==null?void 0:te.executionId)!=null?Hn:"",toolName:(Ss=R.toolName)!=null?Ss:"",description:(Pi=R.description)!=null?Pi:"",resolvedAt:Date.now()}};p(oe)}}else if(Ke==="artifact_start"||Ke==="artifact_delta"||Ke==="artifact_update"||Ke==="artifact_complete"){if(Ke==="artifact_start"){let V=R.artifactType,B=String(R.id),oe=typeof R.title=="string"?R.title:void 0;if(t({type:"artifact_start",id:B,artifactType:V,title:oe,component:typeof R.component=="string"?R.component:void 0}),be.set(B,{markdown:"",title:oe}),!me.has(B)){me.add(B);let pe={id:`artifact-ref-${B}`,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!0,sequence:l(),rawContent:JSON.stringify({component:"PersonaArtifactCard",props:{artifactId:B,title:oe,artifactType:V,status:"streaming"}})};ne.set(B,pe),p(pe)}}else if(Ke==="artifact_delta"){let V=String(R.id),B=typeof R.delta=="string"?R.delta:String((xn=R.delta)!=null?xn:"");t({type:"artifact_delta",id:V,artDelta:B});let oe=be.get(V);oe&&(oe.markdown+=B)}else if(Ke==="artifact_update"){let V=R.props&&typeof R.props=="object"&&!Array.isArray(R.props)?R.props:{};t({type:"artifact_update",id:String(R.id),props:V,component:typeof R.component=="string"?R.component:void 0})}else if(Ke==="artifact_complete"){let V=String(R.id);t({type:"artifact_complete",id:V});let B=ne.get(V);if(B){B.streaming=!1;try{let oe=JSON.parse((Ri=B.rawContent)!=null?Ri:"{}");if(oe.props){oe.props.status="complete";let pe=be.get(V);pe!=null&&pe.markdown&&(oe.props.markdown=pe.markdown)}B.rawContent=JSON.stringify(oe)}catch{}be.delete(V),p(B),ne.delete(V)}}}else if(Ke==="transcript_insert"){let V=R.message;if(!V||typeof V!="object")continue;let B=String((Wn=V.id)!=null?Wn:`msg-${l()}`),oe=V.role,J={id:B,role:oe==="user"?"user":oe==="system"?"system":"assistant",content:typeof V.content=="string"?V.content:"",rawContent:typeof V.rawContent=="string"?V.rawContent:void 0,createdAt:typeof V.createdAt=="string"?V.createdAt:new Date().toISOString(),streaming:V.streaming===!0,...typeof V.variant=="string"?{variant:V.variant}:{},sequence:l()};if(p(J),J.rawContent)try{let Le=JSON.parse(J.rawContent),Ve=(Gt=Le==null?void 0:Le.props)==null?void 0:Gt.artifactId;typeof Ve=="string"&&me.add(Ve)}catch{}m=null,h.current=null,ae.delete(B),Q.delete(B)}else if(Ke==="error"||Ke==="step_error"||Ke==="dispatch_error"||Ke==="flow_error"){let V=null;if(R.error instanceof Error)V=R.error;else if(Ke==="dispatch_error"){let B=(Da=R.message)!=null?Da:R.error;B!=null&&B!==""&&(V=new Error(String(B)))}else if(Ke==="step_error"||Ke==="flow_error"){let B=R.error;typeof B=="string"&&B!==""?V=new Error(B):B!=null&&typeof B=="object"&&"message"in B&&(V=new Error(String((Oa=B.message)!=null?Oa:B)))}else Ke==="error"&&R.error!=null&&R.error!==""&&(V=new Error(String(R.error)));if(V){t({type:"error",error:V});let B=m;B&&B.streaming&&(B.streaming=!1,p(B)),t({type:"status",status:"idle"})}}}}}Re.length=0};;){let{done:O,value:fe}=await n.read();if(O)break;s+=a.decode(fe,{stream:!0});let Ie=s.split(`
|
|
57
58
|
|
|
58
|
-
`);s=(
|
|
59
|
-
`),Ne="message",Ye="";for(let ar of Fe)ar.startsWith("event:")?Ne=ar.replace("event:","").trim():ar.startsWith("data:")&&(Ye+=ar.replace("data:","").trim());if(!Ye)continue;let At;try{At=JSON.parse(Ye)}catch(ar){t({type:"error",error:ar instanceof Error?ar:new Error("Failed to parse chat stream payload")});continue}let Xt=Ne!=="message"?Ne:(hr=At.type)!=null?hr:"message";if((sn=this.onSSEEvent)==null||sn.call(this,Xt,At),this.parseSSEEvent){h.current=f;let ar=await this.handleCustomSSEEvent(At,t,h,p,l,S);if(h.current&&h.current!==f&&(f=h.current),ar)continue}Rt.push(Xt,At),ue()}}Rt.flushPending(),ue(),Rt.destroy()}};function Kh(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`msg_${r}_${e}`}function Va(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`usr_${r}_${e}`}function fa(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`ast_${r}_${e}`}var al="[Image]";function Xh(r){return typeof r=="string"?[{type:"text",text:r}]:r}function Qh(r){return typeof r=="string"?r:r.filter(e=>e.type==="text").map(e=>e.text).join("")}function Jh(r){return typeof r=="string"?!1:r.some(e=>e.type==="image")}function Yh(r){return typeof r=="string"?[]:r.filter(e=>e.type==="image")}function $s(r){return{type:"text",text:r}}function Zh(r,e){return{type:"image",image:r,...(e==null?void 0:e.mimeType)&&{mimeType:e.mimeType},...(e==null?void 0:e.alt)&&{alt:e.alt}}}async function ex(r){return new Promise((e,t)=>{let n=new FileReader;n.onload=()=>{let o=n.result;e({type:"image",image:o,mimeType:r.type,alt:r.name})},n.onerror=()=>t(new Error("Failed to read file")),n.readAsDataURL(r)})}function tx(r,e=["image/png","image/jpeg","image/gif","image/webp"],t=10*1024*1024){return e.includes(r.type)?r.size>t?{valid:!1,error:`File too large. Maximum size: ${Math.round(t/1048576)}MB`}:{valid:!0}:{valid:!1,error:`Invalid file type. Accepted types: ${e.join(", ")}`}}var rx=["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/bmp"],tv=["application/pdf","text/plain","text/markdown","text/csv","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json"],yo=[...rx,...tv];function rv(r){return rx.includes(r)||r.startsWith("image/")}function sl(r){return rv(r.type)}async function nx(r){return new Promise((e,t)=>{let n=new FileReader;n.onload=()=>{let o=n.result;sl(r)?e({type:"image",image:o,mimeType:r.type,alt:r.name}):e({type:"file",data:o,mimeType:r.type,filename:r.name})},n.onerror=()=>t(new Error("Failed to read file")),n.readAsDataURL(r)})}function ox(r,e=yo,t=10*1024*1024){return e.includes(r.type)?r.size>t?{valid:!1,error:`File too large. Maximum size: ${Math.round(t/1048576)}MB`}:{valid:!0}:{valid:!1,error:`Invalid file type "${r.type}". Accepted types: ${e.join(", ")}`}}function nv(r){let e=r.split(".");return e.length>1?e.pop().toLowerCase():""}function ax(r,e){let t=nv(e).toUpperCase();return{"application/pdf":"PDF","text/plain":"TXT","text/markdown":"MD","text/csv":"CSV","application/msword":"DOC","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.ms-excel":"XLS","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX","application/json":"JSON"}[r]||t||"FILE"}var il=class{constructor(e=24e3){this.ctx=null;this.nextStartTime=0;this.activeSources=[];this.finishedCallbacks=[];this.playing=!1;this.streamEnded=!1;this.pendingCount=0;this.remainder=null;this.sampleRate=e}ensureContext(){if(!this.ctx){let t=typeof window!="undefined"?window:void 0;if(!t)throw new Error("AudioPlaybackManager requires a browser environment");let n=t.AudioContext||t.webkitAudioContext;this.ctx=new n({sampleRate:this.sampleRate})}let e=this.ctx;return e.state==="suspended"&&e.resume(),e}enqueue(e){if(e.length===0)return;let t=e;if(this.remainder){let d=new Uint8Array(this.remainder.length+e.length);d.set(this.remainder),d.set(e,this.remainder.length),t=d,this.remainder=null}if(t.length%2!==0&&(this.remainder=new Uint8Array([t[t.length-1]]),t=t.subarray(0,t.length-1)),t.length===0)return;let n=this.ensureContext(),o=this.pcmToFloat32(t),a=n.createBuffer(1,o.length,this.sampleRate);a.getChannelData(0).set(o);let s=n.createBufferSource();s.buffer=a,s.connect(n.destination);let i=n.currentTime;this.nextStartTime<i&&(this.nextStartTime=i),s.start(this.nextStartTime),this.nextStartTime+=a.duration,this.activeSources.push(s),this.pendingCount++,this.playing=!0,s.onended=()=>{let d=this.activeSources.indexOf(s);d!==-1&&this.activeSources.splice(d,1),this.pendingCount--,this.checkFinished()}}markStreamEnd(){this.streamEnded=!0,this.checkFinished()}flush(){for(let e of this.activeSources)try{e.stop(),e.disconnect()}catch{}this.activeSources=[],this.pendingCount=0,this.nextStartTime=0,this.playing=!1,this.streamEnded=!1,this.finishedCallbacks=[],this.remainder=null}isPlaying(){return this.playing}onFinished(e){this.finishedCallbacks.push(e)}async destroy(){this.flush(),this.ctx&&(await this.ctx.close(),this.ctx=null)}checkFinished(){if(this.streamEnded&&this.pendingCount<=0&&this.playing){this.playing=!1,this.streamEnded=!1;let e=this.finishedCallbacks.slice();this.finishedCallbacks=[];for(let t of e)t()}}pcmToFloat32(e){let t=Math.floor(e.length/2),n=new Float32Array(t),o=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let a=0;a<t;a++){let s=o.getInt16(a*2,!0);n[a]=s/32768}return n}};var ll=class{constructor(){this.sourceNode=null;this.analyserNode=null;this.interval=null;this.conditionStart=null;this.fired=!1}start(e,t,n,o,a){this.stop(),this.fired=!1,this.conditionStart=null,this.sourceNode=e.createMediaStreamSource(t),this.analyserNode=e.createAnalyser(),this.analyserNode.fftSize=2048,this.sourceNode.connect(this.analyserNode);let s=new Float32Array(this.analyserNode.fftSize);this.interval=setInterval(()=>{if(!this.analyserNode||this.fired)return;this.analyserNode.getFloatTimeDomainData(s);let i=0;for(let u=0;u<s.length;u++)i+=s[u]*s[u];let d=Math.sqrt(i/s.length);(n==="silence"?d<o.threshold:d>=o.threshold)?this.conditionStart===null?this.conditionStart=Date.now():Date.now()-this.conditionStart>=o.duration&&(this.fired=!0,a()):this.conditionStart=null},100)}stop(){this.interval&&(clearInterval(this.interval),this.interval=null),this.sourceNode&&(this.sourceNode.disconnect(),this.sourceNode=null),this.analyserNode=null,this.conditionStart=null,this.fired=!1}};var Vs=class{constructor(e){this.config=e;this.type="runtype";this.ws=null;this.audioContext=null;this.w=typeof window!="undefined"?window:void 0;this.mediaRecorder=null;this.resultCallbacks=[];this.errorCallbacks=[];this.statusCallbacks=[];this.processingStartCallbacks=[];this.audioChunks=[];this.isProcessing=!1;this.isSpeaking=!1;this.vad=new ll;this.mediaStream=null;this.currentAudio=null;this.currentAudioUrl=null;this.currentRequestId=null;this.interruptionMode="none";this.playbackManager=null}getInterruptionMode(){return this.interruptionMode}isBargeInActive(){return this.interruptionMode==="barge-in"&&this.mediaStream!==null}async deactivateBargeIn(){this.vad.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null)}async connect(){var e,t,n;if(!(this.ws&&this.ws.readyState===WebSocket.OPEN))try{if(!this.w)throw new Error("Window object not available");let o=this.w;if(!o||!o.location)throw new Error("Window object or location not available");let a=o.location.protocol==="https:"?"wss:":"ws:",s=(e=this.config)==null?void 0:e.host,i=(t=this.config)==null?void 0:t.agentId,d=(n=this.config)==null?void 0:n.clientToken;if(!i||!d)throw new Error("agentId and clientToken are required");if(!s)throw new Error("host must be provided in Runtype voice provider configuration");let l=`${a}//${s}/ws/agents/${i}/voice?token=${d}`;this.ws=new WebSocket(l),this.setupWebSocketHandlers();let u=`${a}//${s}/ws/agents/${i}/voice?token=...`,m=" Check: API running on port 8787? Valid client token? Agent voice enabled? Token allowedOrigins includes this page?";await new Promise((p,f)=>{if(!this.ws)return f(new Error("WebSocket not created"));let b=!1,h=T=>{b||(b=!0,clearTimeout(S),f(new Error(T)))},S=setTimeout(()=>h("WebSocket connection timed out."+m),1e4);this.ws.addEventListener("open",()=>{b||(b=!0,clearTimeout(S),p())},{once:!0}),this.ws.addEventListener("error",()=>{h("WebSocket connection failed to "+u+"."+m)},{once:!0}),this.ws.addEventListener("close",T=>{if(!T.wasClean&&!b){let M=T.code!==1006?` (code ${T.code})`:"";h("WebSocket connection failed"+M+"."+m)}},{once:!0})}),this.sendHeartbeat()}catch(o){throw this.ws=null,this.errorCallbacks.forEach(a=>a(o)),this.statusCallbacks.forEach(a=>a("error")),o}}setupWebSocketHandlers(){this.ws&&(this.ws.onopen=()=>{this.statusCallbacks.forEach(e=>e("connected"))},this.ws.onclose=()=>{this.statusCallbacks.forEach(e=>e("disconnected"))},this.ws.onerror=e=>{this.errorCallbacks.forEach(t=>t(new Error("WebSocket error"))),this.statusCallbacks.forEach(t=>t("error"))},this.ws.binaryType="arraybuffer",this.ws.onmessage=e=>{if(e.data instanceof ArrayBuffer){this.handleAudioChunk(new Uint8Array(e.data));return}try{let t=JSON.parse(e.data);this.handleWebSocketMessage(t)}catch{this.errorCallbacks.forEach(n=>n(new Error("Message parsing failed")))}})}handleWebSocketMessage(e){var t,n;switch(e.type){case"session_config":e.interruptionMode&&(this.interruptionMode=e.interruptionMode);break;case"voice_response":this.isProcessing=!1,this.resultCallbacks.forEach(o=>o({text:e.response.agentResponseText||e.response.transcript,transcript:e.response.transcript,audio:e.response.audio,confidence:.95,provider:"runtype"})),(t=e.response.audio)!=null&&t.base64?(this.isSpeaking=!0,this.statusCallbacks.forEach(o=>o("speaking")),this.playAudio(e.response.audio).catch(o=>this.errorCallbacks.forEach(a=>a(o instanceof Error?o:new Error(String(o)))))):(n=e.response.audio)!=null&&n.base64;break;case"audio_end":if(e.requestId&&e.requestId!==this.currentRequestId)break;this.playbackManager?this.playbackManager.markStreamEnd():(this.isSpeaking=!1,this.isProcessing=!1,this.statusCallbacks.forEach(o=>o("idle")));break;case"cancelled":this.isProcessing=!1;break;case"error":this.errorCallbacks.forEach(o=>o(new Error(e.error))),this.statusCallbacks.forEach(o=>o("error")),this.isProcessing=!1;break;case"pong":break}}handleAudioChunk(e){e.length!==0&&this.currentRequestId&&(this.playbackManager||(this.playbackManager=new il(24e3),this.playbackManager.onFinished(()=>{this.isSpeaking=!1,this.playbackManager=null,this.vad.stop(),this.statusCallbacks.forEach(t=>t("idle"))})),this.isSpeaking||(this.isSpeaking=!0,this.statusCallbacks.forEach(t=>t("speaking")),this.startBargeInMonitoring().catch(()=>{})),this.playbackManager.enqueue(e))}stopPlayback(){!this.isProcessing&&!this.isSpeaking||(this.cancelCurrentPlayback(),this.statusCallbacks.forEach(e=>e("idle")))}cancelCurrentPlayback(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.src="",this.currentAudio=null),this.currentAudioUrl&&(URL.revokeObjectURL(this.currentAudioUrl),this.currentAudioUrl=null),this.playbackManager&&(this.playbackManager.flush(),this.playbackManager=null),this.currentRequestId&&this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"cancel",requestId:this.currentRequestId})),this.currentRequestId=null,this.isProcessing=!1,this.isSpeaking=!1}async startListening(){var e,t,n,o;try{if(this.isProcessing||this.isSpeaking)if(this.interruptionMode!=="none")this.cancelCurrentPlayback();else return;if(!this.mediaStream){let l=this.interruptionMode==="barge-in"?{audio:{echoCancellation:!0,noiseSuppression:!0}}:{audio:!0};this.mediaStream=await navigator.mediaDevices.getUserMedia(l)}let a=this.w;this.audioContext||(this.audioContext=new(a.AudioContext||a.webkitAudioContext));let s=this.audioContext,i=(t=(e=this.config)==null?void 0:e.pauseDuration)!=null?t:2e3,d=(o=(n=this.config)==null?void 0:n.silenceThreshold)!=null?o:.01;this.vad.start(s,this.mediaStream,"silence",{threshold:d,duration:i},()=>this.stopListening()),this.mediaRecorder=new MediaRecorder(this.mediaStream),this.audioChunks=[],this.mediaRecorder.ondataavailable=l=>{l.data.size>0&&this.audioChunks.push(l.data)},this.mediaRecorder.onstop=async()=>{var l;if(this.audioChunks.length>0){this.isProcessing=!0,this.statusCallbacks.forEach(p=>p("processing")),this.processingStartCallbacks.forEach(p=>p());let u=((l=this.mediaRecorder)==null?void 0:l.mimeType)||"audio/webm",m=new Blob(this.audioChunks,{type:u});await this.sendAudio(m),this.audioChunks=[]}},this.mediaRecorder.start(1e3),this.statusCallbacks.forEach(l=>l("listening"))}catch(a){throw this.errorCallbacks.forEach(s=>s(a)),this.statusCallbacks.forEach(s=>s("error")),a}}async stopListening(){this.vad.stop(),this.mediaRecorder&&(this.interruptionMode!=="barge-in"&&this.mediaRecorder.stream.getTracks().forEach(e=>e.stop()),this.mediaRecorder.stop(),this.mediaRecorder=null),this.interruptionMode!=="barge-in"&&(this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null)),this.statusCallbacks.forEach(e=>e("idle"))}async startBargeInMonitoring(){var a,s;if(this.interruptionMode!=="barge-in")return;let e=this.w;if(!this.mediaStream&&e&&(this.mediaStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}})),!this.audioContext&&e&&(this.audioContext=new(e.AudioContext||e.webkitAudioContext)),!this.audioContext||!this.mediaStream)return;let t=this.audioContext,n=(s=(a=this.config)==null?void 0:a.silenceThreshold)!=null?s:.01;this.vad.start(t,this.mediaStream,"speech",{threshold:n,duration:200},()=>this.handleBargeIn())}handleBargeIn(){this.cancelCurrentPlayback(),this.startListening().catch(e=>{this.errorCallbacks.forEach(t=>t(e instanceof Error?e:new Error(String(e))))})}generateRequestId(){return"vreq_"+Math.random().toString(36).substring(2,10)+Date.now().toString(36)}async sendAudio(e){var t;if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.errorCallbacks.forEach(n=>n(new Error("WebSocket not connected"))),this.statusCallbacks.forEach(n=>n("error"));return}try{let n=await this.blobToBase64(e),o=this.getFormatFromMimeType(e.type),a=this.generateRequestId();this.currentRequestId=a,this.ws.send(JSON.stringify({type:"audio_input",audio:n,format:o,sampleRate:16e3,voiceId:(t=this.config)==null?void 0:t.voiceId,requestId:a}))}catch(n){this.errorCallbacks.forEach(o=>o(n)),this.statusCallbacks.forEach(o=>o("error"))}}getFormatFromMimeType(e){return e.includes("wav")?"wav":e.includes("mpeg")||e.includes("mp3")?"mp3":"webm"}blobToBase64(e){return new Promise((t,n)=>{let o=new FileReader;o.onload=()=>{let s=o.result.split(",")[1];t(s)},o.onerror=n,o.readAsDataURL(e)})}async playAudio(e){if(!e.base64)return;let t=atob(e.base64),n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);let o=e.format||"mp3",a=o==="mp3"?"audio/mpeg":`audio/${o}`,s=new Blob([n],{type:a}),i=URL.createObjectURL(s),d=new Audio(i);this.currentAudio=d,this.currentAudioUrl=i,d.onended=()=>{URL.revokeObjectURL(i),this.currentAudio===d&&(this.currentAudio=null,this.currentAudioUrl=null,this.isSpeaking=!1,this.statusCallbacks.forEach(l=>l("idle")))},await d.play()}onResult(e){this.resultCallbacks.push(e)}onError(e){this.errorCallbacks.push(e)}onStatusChange(e){this.statusCallbacks.push(e)}onProcessingStart(e){this.processingStartCallbacks.push(e)}async disconnect(){if(this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.src="",this.currentAudio=null),this.currentAudioUrl&&(URL.revokeObjectURL(this.currentAudioUrl),this.currentAudioUrl=null),this.playbackManager&&(await this.playbackManager.destroy(),this.playbackManager=null),this.currentRequestId=null,this.isSpeaking=!1,this.vad.stop(),await this.stopListening(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null),this.ws){try{this.ws.close()}catch{}this.ws=null}this.statusCallbacks.forEach(e=>e("disconnected"))}sendHeartbeat(){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"ping"}))}};var ma=class{constructor(e={}){this.config=e;this.type="browser";this.recognition=null;this.resultCallbacks=[];this.errorCallbacks=[];this.statusCallbacks=[];this.isListening=!1;this.w=typeof window!="undefined"?window:void 0}async connect(){this.statusCallbacks.forEach(e=>e("connected"))}async startListening(){var e,t;try{if(this.isListening)throw new Error("Already listening");if(!this.w)throw new Error("Window object not available");let n=this.w.SpeechRecognition||this.w.webkitSpeechRecognition;if(!n)throw new Error("Browser speech recognition not supported");this.recognition=new n,this.recognition.lang=((e=this.config)==null?void 0:e.language)||"en-US",this.recognition.continuous=((t=this.config)==null?void 0:t.continuous)||!1,this.recognition.interimResults=!0,this.recognition.onresult=o=>{var i;let a=Array.from(o.results).map(d=>d[0]).map(d=>d.transcript).join(""),s=o.results[o.results.length-1].isFinal;this.resultCallbacks.forEach(d=>d({text:a,confidence:s?.8:.5,provider:"browser"})),s&&!((i=this.config)!=null&&i.continuous)&&this.stopListening()},this.recognition.onerror=o=>{this.errorCallbacks.forEach(a=>a(new Error(o.error))),this.statusCallbacks.forEach(a=>a("error"))},this.recognition.onstart=()=>{this.isListening=!0,this.statusCallbacks.forEach(o=>o("listening"))},this.recognition.onend=()=>{this.isListening=!1,this.statusCallbacks.forEach(o=>o("idle"))},this.recognition.start()}catch(n){throw this.errorCallbacks.forEach(o=>o(n)),this.statusCallbacks.forEach(o=>o("error")),n}}async stopListening(){this.recognition&&(this.recognition.stop(),this.recognition=null),this.isListening=!1,this.statusCallbacks.forEach(e=>e("idle"))}onResult(e){this.resultCallbacks.push(e)}onError(e){this.errorCallbacks.push(e)}onStatusChange(e){this.statusCallbacks.push(e)}async disconnect(){await this.stopListening(),this.statusCallbacks.forEach(e=>e("disconnected"))}static isSupported(){return"SpeechRecognition"in window||"webkitSpeechRecognition"in window}};function ga(r){switch(r.type){case"runtype":if(!r.runtype)throw new Error("Runtype voice provider requires configuration");return new Vs(r.runtype);case"browser":if(!ma.isSupported())throw new Error("Browser speech recognition not supported");return new ma(r.browser||{});case"custom":throw new Error("Custom voice providers not yet implemented");default:throw new Error(`Unknown voice provider type: ${r.type}`)}}function dl(r){if((r==null?void 0:r.type)==="runtype"&&r.runtype)return ga({type:"runtype",runtype:r.runtype});if(ma.isSupported())return ga({type:"browser",browser:(r==null?void 0:r.browser)||{language:"en-US"}});throw new Error("No supported voice providers available")}function js(r){try{return dl(r),!0}catch{return!1}}var ov=["apiUrl","clientToken","flowId","agent","agentOptions","headers","getHeaders","webmcp","streamParser","parserType","contextProviders","requestMiddleware","customFetch","parseSSEEvent","onSessionInit","onSessionExpired","getStoredSessionId","setStoredSessionId"];function av(r,e){return ov.some(t=>r[t]!==e[t])}function sx(r,e){let t=r instanceof Error?r:new Error(String(r));if(typeof e=="string")return e;if(typeof e=="function")return e(t);let n="Sorry \u2014 I couldn't reach the assistant. The chat service didn't respond. Please check that your proxy or backend is running and reachable, then try again.";return t.message?`${n}
|
|
59
|
+
`);s=(dr=Ie.pop())!=null?dr:"";for(let Je of Ie){let qe=Je.split(`
|
|
60
|
+
`),ze="message",lt="";for(let or of qe)or.startsWith("event:")?ze=or.replace("event:","").trim():or.startsWith("data:")&&(lt+=or.replace("data:","").trim());if(!lt)continue;let Mt;try{Mt=JSON.parse(lt)}catch(or){t({type:"error",error:or instanceof Error?or:new Error("Failed to parse chat stream payload")});continue}let Dt=ze!=="message"?ze:(Yr=Mt.type)!=null?Yr:"message";if((zr=this.onSSEEvent)==null||zr.call(this,Dt,Mt),this.parseSSEEvent){h.current=m;let or=await this.handleCustomSSEEvent(Mt,t,h,p,l,T);if(h.current&&h.current!==m&&(m=h.current),or)continue}Pt.push(Dt,Mt),he()}}Pt.flushPending(),he(),Pt.destroy()}};function tx(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`msg_${r}_${e}`}function Ja(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`usr_${r}_${e}`}function ba(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,10);return`ast_${r}_${e}`}var ll="[Image]";function rx(r){return typeof r=="string"?[{type:"text",text:r}]:r}function ox(r){return typeof r=="string"?r:r.filter(e=>e.type==="text").map(e=>e.text).join("")}function nx(r){return typeof r=="string"?!1:r.some(e=>e.type==="image")}function ax(r){return typeof r=="string"?[]:r.filter(e=>e.type==="image")}function Qs(r){return{type:"text",text:r}}function sx(r,e){return{type:"image",image:r,...(e==null?void 0:e.mimeType)&&{mimeType:e.mimeType},...(e==null?void 0:e.alt)&&{alt:e.alt}}}async function ix(r){return new Promise((e,t)=>{let o=new FileReader;o.onload=()=>{let n=o.result;e({type:"image",image:n,mimeType:r.type,alt:r.name})},o.onerror=()=>t(new Error("Failed to read file")),o.readAsDataURL(r)})}function lx(r,e=["image/png","image/jpeg","image/gif","image/webp"],t=10*1024*1024){return e.includes(r.type)?r.size>t?{valid:!1,error:`File too large. Maximum size: ${Math.round(t/1048576)}MB`}:{valid:!0}:{valid:!1,error:`Invalid file type. Accepted types: ${e.join(", ")}`}}var dx=["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/bmp"],vv=["application/pdf","text/plain","text/markdown","text/csv","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json"],Tn=[...dx,...vv];function Cv(r){return dx.includes(r)||r.startsWith("image/")}function dl(r){return Cv(r.type)}async function cx(r){return new Promise((e,t)=>{let o=new FileReader;o.onload=()=>{let n=o.result;dl(r)?e({type:"image",image:n,mimeType:r.type,alt:r.name}):e({type:"file",data:n,mimeType:r.type,filename:r.name})},o.onerror=()=>t(new Error("Failed to read file")),o.readAsDataURL(r)})}function px(r,e=Tn,t=10*1024*1024){return e.includes(r.type)?r.size>t?{valid:!1,error:`File too large. Maximum size: ${Math.round(t/1048576)}MB`}:{valid:!0}:{valid:!1,error:`Invalid file type "${r.type}". Accepted types: ${e.join(", ")}`}}function wv(r){let e=r.split(".");return e.length>1?e.pop().toLowerCase():""}function ux(r,e){let t=wv(e).toUpperCase();return{"application/pdf":"PDF","text/plain":"TXT","text/markdown":"MD","text/csv":"CSV","application/msword":"DOC","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.ms-excel":"XLS","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX","application/json":"JSON"}[r]||t||"FILE"}var cl=class{constructor(e=24e3){this.ctx=null;this.nextStartTime=0;this.activeSources=[];this.finishedCallbacks=[];this.playing=!1;this.streamEnded=!1;this.pendingCount=0;this.remainder=null;this.sampleRate=e}ensureContext(){if(!this.ctx){let t=typeof window!="undefined"?window:void 0;if(!t)throw new Error("AudioPlaybackManager requires a browser environment");let o=t.AudioContext||t.webkitAudioContext;this.ctx=new o({sampleRate:this.sampleRate})}let e=this.ctx;return e.state==="suspended"&&e.resume(),e}enqueue(e){if(e.length===0)return;let t=e;if(this.remainder){let d=new Uint8Array(this.remainder.length+e.length);d.set(this.remainder),d.set(e,this.remainder.length),t=d,this.remainder=null}if(t.length%2!==0&&(this.remainder=new Uint8Array([t[t.length-1]]),t=t.subarray(0,t.length-1)),t.length===0)return;let o=this.ensureContext(),n=this.pcmToFloat32(t),a=o.createBuffer(1,n.length,this.sampleRate);a.getChannelData(0).set(n);let s=o.createBufferSource();s.buffer=a,s.connect(o.destination);let i=o.currentTime;this.nextStartTime<i&&(this.nextStartTime=i),s.start(this.nextStartTime),this.nextStartTime+=a.duration,this.activeSources.push(s),this.pendingCount++,this.playing=!0,s.onended=()=>{let d=this.activeSources.indexOf(s);d!==-1&&this.activeSources.splice(d,1),this.pendingCount--,this.checkFinished()}}markStreamEnd(){this.streamEnded=!0,this.checkFinished()}flush(){for(let e of this.activeSources)try{e.stop(),e.disconnect()}catch{}this.activeSources=[],this.pendingCount=0,this.nextStartTime=0,this.playing=!1,this.streamEnded=!1,this.finishedCallbacks=[],this.remainder=null}isPlaying(){return this.playing}onFinished(e){this.finishedCallbacks.push(e)}async destroy(){this.flush(),this.ctx&&(await this.ctx.close(),this.ctx=null)}checkFinished(){if(this.streamEnded&&this.pendingCount<=0&&this.playing){this.playing=!1,this.streamEnded=!1;let e=this.finishedCallbacks.slice();this.finishedCallbacks=[];for(let t of e)t()}}pcmToFloat32(e){let t=Math.floor(e.length/2),o=new Float32Array(t),n=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let a=0;a<t;a++){let s=n.getInt16(a*2,!0);o[a]=s/32768}return o}};var pl=class{constructor(){this.sourceNode=null;this.analyserNode=null;this.interval=null;this.conditionStart=null;this.fired=!1}start(e,t,o,n,a){this.stop(),this.fired=!1,this.conditionStart=null,this.sourceNode=e.createMediaStreamSource(t),this.analyserNode=e.createAnalyser(),this.analyserNode.fftSize=2048,this.sourceNode.connect(this.analyserNode);let s=new Float32Array(this.analyserNode.fftSize);this.interval=setInterval(()=>{if(!this.analyserNode||this.fired)return;this.analyserNode.getFloatTimeDomainData(s);let i=0;for(let u=0;u<s.length;u++)i+=s[u]*s[u];let d=Math.sqrt(i/s.length);(o==="silence"?d<n.threshold:d>=n.threshold)?this.conditionStart===null?this.conditionStart=Date.now():Date.now()-this.conditionStart>=n.duration&&(this.fired=!0,a()):this.conditionStart=null},100)}stop(){this.interval&&(clearInterval(this.interval),this.interval=null),this.sourceNode&&(this.sourceNode.disconnect(),this.sourceNode=null),this.analyserNode=null,this.conditionStart=null,this.fired=!1}};var Ys=class{constructor(e){this.config=e;this.type="runtype";this.ws=null;this.audioContext=null;this.w=typeof window!="undefined"?window:void 0;this.mediaRecorder=null;this.resultCallbacks=[];this.errorCallbacks=[];this.statusCallbacks=[];this.processingStartCallbacks=[];this.audioChunks=[];this.isProcessing=!1;this.isSpeaking=!1;this.vad=new pl;this.mediaStream=null;this.currentAudio=null;this.currentAudioUrl=null;this.currentRequestId=null;this.interruptionMode="none";this.playbackManager=null}getInterruptionMode(){return this.interruptionMode}isBargeInActive(){return this.interruptionMode==="barge-in"&&this.mediaStream!==null}async deactivateBargeIn(){this.vad.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null)}async connect(){var e,t,o;if(!(this.ws&&this.ws.readyState===WebSocket.OPEN))try{if(!this.w)throw new Error("Window object not available");let n=this.w;if(!n||!n.location)throw new Error("Window object or location not available");let a=n.location.protocol==="https:"?"wss:":"ws:",s=(e=this.config)==null?void 0:e.host,i=(t=this.config)==null?void 0:t.agentId,d=(o=this.config)==null?void 0:o.clientToken;if(!i||!d)throw new Error("agentId and clientToken are required");if(!s)throw new Error("host must be provided in Runtype voice provider configuration");let l=`${a}//${s}/ws/agents/${i}/voice?token=${d}`;this.ws=new WebSocket(l),this.setupWebSocketHandlers();let u=`${a}//${s}/ws/agents/${i}/voice?token=...`,f=" Check: API running on port 8787? Valid client token? Agent voice enabled? Token allowedOrigins includes this page?";await new Promise((p,m)=>{if(!this.ws)return m(new Error("WebSocket not created"));let y=!1,h=M=>{y||(y=!0,clearTimeout(T),m(new Error(M)))},T=setTimeout(()=>h("WebSocket connection timed out."+f),1e4);this.ws.addEventListener("open",()=>{y||(y=!0,clearTimeout(T),p())},{once:!0}),this.ws.addEventListener("error",()=>{h("WebSocket connection failed to "+u+"."+f)},{once:!0}),this.ws.addEventListener("close",M=>{if(!M.wasClean&&!y){let k=M.code!==1006?` (code ${M.code})`:"";h("WebSocket connection failed"+k+"."+f)}},{once:!0})}),this.sendHeartbeat()}catch(n){throw this.ws=null,this.errorCallbacks.forEach(a=>a(n)),this.statusCallbacks.forEach(a=>a("error")),n}}setupWebSocketHandlers(){this.ws&&(this.ws.onopen=()=>{this.statusCallbacks.forEach(e=>e("connected"))},this.ws.onclose=()=>{this.statusCallbacks.forEach(e=>e("disconnected"))},this.ws.onerror=e=>{this.errorCallbacks.forEach(t=>t(new Error("WebSocket error"))),this.statusCallbacks.forEach(t=>t("error"))},this.ws.binaryType="arraybuffer",this.ws.onmessage=e=>{if(e.data instanceof ArrayBuffer){this.handleAudioChunk(new Uint8Array(e.data));return}try{let t=JSON.parse(e.data);this.handleWebSocketMessage(t)}catch{this.errorCallbacks.forEach(o=>o(new Error("Message parsing failed")))}})}handleWebSocketMessage(e){var t,o;switch(e.type){case"session_config":e.interruptionMode&&(this.interruptionMode=e.interruptionMode);break;case"voice_response":this.isProcessing=!1,this.resultCallbacks.forEach(n=>n({text:e.response.agentResponseText||e.response.transcript,transcript:e.response.transcript,audio:e.response.audio,confidence:.95,provider:"runtype"})),(t=e.response.audio)!=null&&t.base64?(this.isSpeaking=!0,this.statusCallbacks.forEach(n=>n("speaking")),this.playAudio(e.response.audio).catch(n=>this.errorCallbacks.forEach(a=>a(n instanceof Error?n:new Error(String(n)))))):(o=e.response.audio)!=null&&o.base64;break;case"audio_end":if(e.requestId&&e.requestId!==this.currentRequestId)break;this.playbackManager?this.playbackManager.markStreamEnd():(this.isSpeaking=!1,this.isProcessing=!1,this.statusCallbacks.forEach(n=>n("idle")));break;case"cancelled":this.isProcessing=!1;break;case"error":this.errorCallbacks.forEach(n=>n(new Error(e.error))),this.statusCallbacks.forEach(n=>n("error")),this.isProcessing=!1;break;case"pong":break}}handleAudioChunk(e){e.length!==0&&this.currentRequestId&&(this.playbackManager||(this.playbackManager=new cl(24e3),this.playbackManager.onFinished(()=>{this.isSpeaking=!1,this.playbackManager=null,this.vad.stop(),this.statusCallbacks.forEach(t=>t("idle"))})),this.isSpeaking||(this.isSpeaking=!0,this.statusCallbacks.forEach(t=>t("speaking")),this.startBargeInMonitoring().catch(()=>{})),this.playbackManager.enqueue(e))}stopPlayback(){!this.isProcessing&&!this.isSpeaking||(this.cancelCurrentPlayback(),this.statusCallbacks.forEach(e=>e("idle")))}cancelCurrentPlayback(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.src="",this.currentAudio=null),this.currentAudioUrl&&(URL.revokeObjectURL(this.currentAudioUrl),this.currentAudioUrl=null),this.playbackManager&&(this.playbackManager.flush(),this.playbackManager=null),this.currentRequestId&&this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"cancel",requestId:this.currentRequestId})),this.currentRequestId=null,this.isProcessing=!1,this.isSpeaking=!1}async startListening(){var e,t,o,n;try{if(this.isProcessing||this.isSpeaking)if(this.interruptionMode!=="none")this.cancelCurrentPlayback();else return;if(!this.mediaStream){let l=this.interruptionMode==="barge-in"?{audio:{echoCancellation:!0,noiseSuppression:!0}}:{audio:!0};this.mediaStream=await navigator.mediaDevices.getUserMedia(l)}let a=this.w;this.audioContext||(this.audioContext=new(a.AudioContext||a.webkitAudioContext));let s=this.audioContext,i=(t=(e=this.config)==null?void 0:e.pauseDuration)!=null?t:2e3,d=(n=(o=this.config)==null?void 0:o.silenceThreshold)!=null?n:.01;this.vad.start(s,this.mediaStream,"silence",{threshold:d,duration:i},()=>this.stopListening()),this.mediaRecorder=new MediaRecorder(this.mediaStream),this.audioChunks=[],this.mediaRecorder.ondataavailable=l=>{l.data.size>0&&this.audioChunks.push(l.data)},this.mediaRecorder.onstop=async()=>{var l;if(this.audioChunks.length>0){this.isProcessing=!0,this.statusCallbacks.forEach(p=>p("processing")),this.processingStartCallbacks.forEach(p=>p());let u=((l=this.mediaRecorder)==null?void 0:l.mimeType)||"audio/webm",f=new Blob(this.audioChunks,{type:u});await this.sendAudio(f),this.audioChunks=[]}},this.mediaRecorder.start(1e3),this.statusCallbacks.forEach(l=>l("listening"))}catch(a){throw this.errorCallbacks.forEach(s=>s(a)),this.statusCallbacks.forEach(s=>s("error")),a}}async stopListening(){this.vad.stop(),this.mediaRecorder&&(this.interruptionMode!=="barge-in"&&this.mediaRecorder.stream.getTracks().forEach(e=>e.stop()),this.mediaRecorder.stop(),this.mediaRecorder=null),this.interruptionMode!=="barge-in"&&(this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null)),this.statusCallbacks.forEach(e=>e("idle"))}async startBargeInMonitoring(){var a,s;if(this.interruptionMode!=="barge-in")return;let e=this.w;if(!this.mediaStream&&e&&(this.mediaStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}})),!this.audioContext&&e&&(this.audioContext=new(e.AudioContext||e.webkitAudioContext)),!this.audioContext||!this.mediaStream)return;let t=this.audioContext,o=(s=(a=this.config)==null?void 0:a.silenceThreshold)!=null?s:.01;this.vad.start(t,this.mediaStream,"speech",{threshold:o,duration:200},()=>this.handleBargeIn())}handleBargeIn(){this.cancelCurrentPlayback(),this.startListening().catch(e=>{this.errorCallbacks.forEach(t=>t(e instanceof Error?e:new Error(String(e))))})}generateRequestId(){return"vreq_"+Math.random().toString(36).substring(2,10)+Date.now().toString(36)}async sendAudio(e){var t;if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.errorCallbacks.forEach(o=>o(new Error("WebSocket not connected"))),this.statusCallbacks.forEach(o=>o("error"));return}try{let o=await this.blobToBase64(e),n=this.getFormatFromMimeType(e.type),a=this.generateRequestId();this.currentRequestId=a,this.ws.send(JSON.stringify({type:"audio_input",audio:o,format:n,sampleRate:16e3,voiceId:(t=this.config)==null?void 0:t.voiceId,requestId:a}))}catch(o){this.errorCallbacks.forEach(n=>n(o)),this.statusCallbacks.forEach(n=>n("error"))}}getFormatFromMimeType(e){return e.includes("wav")?"wav":e.includes("mpeg")||e.includes("mp3")?"mp3":"webm"}blobToBase64(e){return new Promise((t,o)=>{let n=new FileReader;n.onload=()=>{let s=n.result.split(",")[1];t(s)},n.onerror=o,n.readAsDataURL(e)})}async playAudio(e){if(!e.base64)return;let t=atob(e.base64),o=new Uint8Array(t.length);for(let l=0;l<t.length;l++)o[l]=t.charCodeAt(l);let n=e.format||"mp3",a=n==="mp3"?"audio/mpeg":`audio/${n}`,s=new Blob([o],{type:a}),i=URL.createObjectURL(s),d=new Audio(i);this.currentAudio=d,this.currentAudioUrl=i,d.onended=()=>{URL.revokeObjectURL(i),this.currentAudio===d&&(this.currentAudio=null,this.currentAudioUrl=null,this.isSpeaking=!1,this.statusCallbacks.forEach(l=>l("idle")))},await d.play()}onResult(e){this.resultCallbacks.push(e)}onError(e){this.errorCallbacks.push(e)}onStatusChange(e){this.statusCallbacks.push(e)}onProcessingStart(e){this.processingStartCallbacks.push(e)}async disconnect(){if(this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.src="",this.currentAudio=null),this.currentAudioUrl&&(URL.revokeObjectURL(this.currentAudioUrl),this.currentAudioUrl=null),this.playbackManager&&(await this.playbackManager.destroy(),this.playbackManager=null),this.currentRequestId=null,this.isSpeaking=!1,this.vad.stop(),await this.stopListening(),this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.audioContext&&(await this.audioContext.close(),this.audioContext=null),this.ws){try{this.ws.close()}catch{}this.ws=null}this.statusCallbacks.forEach(e=>e("disconnected"))}sendHeartbeat(){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"ping"}))}};var va=class{constructor(e={}){this.config=e;this.type="browser";this.recognition=null;this.resultCallbacks=[];this.errorCallbacks=[];this.statusCallbacks=[];this.isListening=!1;this.w=typeof window!="undefined"?window:void 0}async connect(){this.statusCallbacks.forEach(e=>e("connected"))}async startListening(){var e,t;try{if(this.isListening)throw new Error("Already listening");if(!this.w)throw new Error("Window object not available");let o=this.w.SpeechRecognition||this.w.webkitSpeechRecognition;if(!o)throw new Error("Browser speech recognition not supported");this.recognition=new o,this.recognition.lang=((e=this.config)==null?void 0:e.language)||"en-US",this.recognition.continuous=((t=this.config)==null?void 0:t.continuous)||!1,this.recognition.interimResults=!0,this.recognition.onresult=n=>{var i;let a=Array.from(n.results).map(d=>d[0]).map(d=>d.transcript).join(""),s=n.results[n.results.length-1].isFinal;this.resultCallbacks.forEach(d=>d({text:a,confidence:s?.8:.5,provider:"browser"})),s&&!((i=this.config)!=null&&i.continuous)&&this.stopListening()},this.recognition.onerror=n=>{this.errorCallbacks.forEach(a=>a(new Error(n.error))),this.statusCallbacks.forEach(a=>a("error"))},this.recognition.onstart=()=>{this.isListening=!0,this.statusCallbacks.forEach(n=>n("listening"))},this.recognition.onend=()=>{this.isListening=!1,this.statusCallbacks.forEach(n=>n("idle"))},this.recognition.start()}catch(o){throw this.errorCallbacks.forEach(n=>n(o)),this.statusCallbacks.forEach(n=>n("error")),o}}async stopListening(){this.recognition&&(this.recognition.stop(),this.recognition=null),this.isListening=!1,this.statusCallbacks.forEach(e=>e("idle"))}onResult(e){this.resultCallbacks.push(e)}onError(e){this.errorCallbacks.push(e)}onStatusChange(e){this.statusCallbacks.push(e)}async disconnect(){await this.stopListening(),this.statusCallbacks.forEach(e=>e("disconnected"))}static isSupported(){return"SpeechRecognition"in window||"webkitSpeechRecognition"in window}};function Ca(r){switch(r.type){case"runtype":if(!r.runtype)throw new Error("Runtype voice provider requires configuration");return new Ys(r.runtype);case"browser":if(!va.isSupported())throw new Error("Browser speech recognition not supported");return new va(r.browser||{});case"custom":throw new Error("Custom voice providers not yet implemented");default:throw new Error(`Unknown voice provider type: ${r.type}`)}}function ul(r){if((r==null?void 0:r.type)==="runtype"&&r.runtype)return Ca({type:"runtype",runtype:r.runtype});if(va.isSupported())return Ca({type:"browser",browser:(r==null?void 0:r.browser)||{language:"en-US"}});throw new Error("No supported voice providers available")}function Js(r){try{return ul(r),!0}catch{return!1}}var Av=["apiUrl","clientToken","flowId","agent","agentOptions","headers","getHeaders","webmcp","streamParser","parserType","contextProviders","requestMiddleware","customFetch","parseSSEEvent","onSessionInit","onSessionExpired","getStoredSessionId","setStoredSessionId"];function Sv(r,e){return Av.some(t=>r[t]!==e[t])}function fx(r,e){let t=r instanceof Error?r:new Error(String(r));if(typeof e=="string")return e;if(typeof e=="function")return e(t);let o="Sorry \u2014 I couldn't reach the assistant. The chat service didn't respond. Please check that your proxy or backend is running and reachable, then try again.";return t.message?`${o}
|
|
60
61
|
|
|
61
|
-
_Details: ${t.message}_`:n}var Gs=r=>({isError:!0,content:[{type:"text",text:r}]}),ix=(r,e="WebMCP tool execution failed.")=>r instanceof Error&&r.message?r.message:typeof r=="string"&&r?r:e,lx=r=>da(r)||r===Vn,ja=class r{constructor(e={},t){this.config=e;this.callbacks=t;this.status="idle";this.streaming=!1;this.abortController=null;this.sequenceCounter=Date.now();this.clientSession=null;this.agentExecution=null;this.artifacts=new Map;this.selectedArtifactId=null;this.webMcpInflightKeys=new Set;this.webMcpResolvedKeys=new Set;this.webMcpResolveControllers=new Set;this.webMcpEpoch=0;this.webMcpApprovalResolvers=new Map;this.webMcpApprovalSeq=0;this.webMcpAwaitBatches=new Map;this.voiceProvider=null;this.voiceActive=!1;this.voiceStatus="disconnected";this.pendingVoiceUserMessageId=null;this.pendingVoiceAssistantMessageId=null;this.ttsSpokenMessageIds=new Set;this.handleEvent=e=>{var t,n,o,a,s,i,d,l,u,m;if(e.type==="message"){this.upsertMessage(e.message);let p=e.message.toolCall,f=!!(p!=null&&p.name)&&(da(p.name)||p.name===Vn&&((n=(t=this.config.features)==null?void 0:t.suggestReplies)==null?void 0:n.enabled)!==!1);((o=e.message.agentMetadata)==null?void 0:o.awaitingLocalTool)===!0&&f&&this.enqueueWebMcpAwait(e.message),(a=e.message.agentMetadata)!=null&&a.executionId&&(this.agentExecution?e.message.agentMetadata.iteration!==void 0&&(this.agentExecution.currentIteration=e.message.agentMetadata.iteration):this.agentExecution={executionId:e.message.agentMetadata.executionId,agentId:"",agentName:(s=e.message.agentMetadata.agentName)!=null?s:"",status:"running",currentIteration:(i=e.message.agentMetadata.iteration)!=null?i:0,maxTurns:0})}else if(e.type==="status"){if(this.setStatus(e.status),e.status==="connecting")this.setStreaming(!0);else if(e.status==="idle"||e.status==="error"){this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null);let p=this.webMcpAwaitBatches.size>0||this.webMcpResolveControllers.size>0;((d=this.agentExecution)==null?void 0:d.status)==="running"&&(e.status==="error"?this.agentExecution.status="error":p||(this.agentExecution.status="complete")),this.scheduleWebMcpBatchFlush()}}else e.type==="error"?(this.setStatus("error"),this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null),((l=this.agentExecution)==null?void 0:l.status)==="running"&&(this.agentExecution.status="error"),(m=(u=this.callbacks).onError)==null||m.call(u,e.error)):(e.type==="artifact_start"||e.type==="artifact_delta"||e.type==="artifact_update"||e.type==="artifact_complete")&&this.applyArtifactStreamEvent(e)};var n,o;this.messages=[...(n=e.initialMessages)!=null?n:[]].map(a=>{var s;return{...a,sequence:(s=a.sequence)!=null?s:this.nextSequence()}}),this.messages=this.sortMessages(this.messages),this.client=new ua(e),this.wireDefaultWebMcpConfirm();for(let a of(o=e.initialArtifacts)!=null?o:[])this.artifacts.set(a.id,{...a,status:"complete"});e.initialSelectedArtifactId!=null&&(this.selectedArtifactId=e.initialSelectedArtifactId),this.messages.length&&this.callbacks.onMessagesChanged([...this.messages]),this.artifacts.size>0&&this.emitArtifactsState(),this.callbacks.onStatusChanged(this.status)}setSSEEventCallback(e){this.client.setSSEEventCallback(e)}isClientTokenMode(){return this.client.isClientTokenMode()}isAgentMode(){return this.client.isAgentMode()}getAgentExecution(){return this.agentExecution}isAgentExecuting(){var e;return((e=this.agentExecution)==null?void 0:e.status)==="running"}isVoiceSupported(){var e;return js((e=this.config.voiceRecognition)==null?void 0:e.provider)}isVoiceActive(){return this.voiceActive}getVoiceStatus(){return this.voiceStatus}getVoiceInterruptionMode(){var e;return(e=this.voiceProvider)!=null&&e.getInterruptionMode?this.voiceProvider.getInterruptionMode():"none"}stopVoicePlayback(){var e;(e=this.voiceProvider)!=null&&e.stopPlayback&&this.voiceProvider.stopPlayback()}isBargeInActive(){var e,t,n;return(n=(t=(e=this.voiceProvider)==null?void 0:e.isBargeInActive)==null?void 0:t.call(e))!=null?n:!1}async deactivateBargeIn(){var e;(e=this.voiceProvider)!=null&&e.deactivateBargeIn&&await this.voiceProvider.deactivateBargeIn()}setupVoice(e){var t,n,o;try{let a=e||this.getVoiceConfigFromConfig();if(!a)throw new Error("Voice configuration not provided");this.voiceProvider=ga(a);let s=(t=this.config.voiceRecognition)!=null?t:{},i=(n=s.processingText)!=null?n:"\u{1F3A4} Processing voice...",d=(o=s.processingErrorText)!=null?o:"Voice processing failed. Please try again.";this.voiceProvider.onProcessingStart&&this.voiceProvider.onProcessingStart(()=>{let l=this.injectMessage({role:"user",content:i,streaming:!1,voiceProcessing:!0});this.pendingVoiceUserMessageId=l.id;let u=this.injectMessage({role:"assistant",content:"",streaming:!0,voiceProcessing:!0});this.pendingVoiceAssistantMessageId=u.id,this.setStreaming(!0)}),this.voiceProvider.onResult(l=>{var u,m,p,f,b,h;if(l.provider==="browser")l.text&&l.text.trim()&&this.sendMessage(l.text,{viaVoice:!0});else if(l.provider==="runtype"){this.pendingVoiceUserMessageId&&((u=l.transcript)!=null&&u.trim())?this.upsertMessage({id:this.pendingVoiceUserMessageId,role:"user",content:l.transcript.trim(),createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}):(m=l.transcript)!=null&&m.trim()&&this.injectUserMessage({content:l.transcript.trim()}),this.pendingVoiceAssistantMessageId&&((p=l.text)!=null&&p.trim())?this.upsertMessage({id:this.pendingVoiceAssistantMessageId,role:"assistant",content:l.text.trim(),createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}):(f=l.text)!=null&&f.trim()&&this.injectAssistantMessage({content:l.text.trim()});{let S=(h=this.pendingVoiceAssistantMessageId)!=null?h:(b=[...this.messages].reverse().find(T=>T.role==="assistant"))==null?void 0:b.id;S&&this.ttsSpokenMessageIds.add(S)}this.setStreaming(!1),this.pendingVoiceUserMessageId=null,this.pendingVoiceAssistantMessageId=null}}),this.voiceProvider.onError(l=>{console.error("Voice error:",l),this.pendingVoiceAssistantMessageId&&(this.upsertMessage({id:this.pendingVoiceAssistantMessageId,role:"assistant",content:d,createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}),this.setStreaming(!1),this.pendingVoiceUserMessageId=null,this.pendingVoiceAssistantMessageId=null)}),this.voiceProvider.onStatusChange(l=>{var u,m;this.voiceStatus=l,this.voiceActive=l==="listening",(m=(u=this.callbacks).onVoiceStatusChanged)==null||m.call(u,l)}),this.voiceProvider.connect()}catch(a){console.error("Failed to setup voice:",a)}}async toggleVoice(){if(!this.voiceProvider){console.error("Voice not configured");return}if(this.voiceActive)await this.voiceProvider.stopListening();else{this.stopSpeaking();try{await this.voiceProvider.startListening()}catch(e){console.error("Failed to start voice:",e)}}}cleanupVoice(){this.voiceProvider&&(this.voiceProvider.disconnect(),this.voiceProvider=null),this.voiceActive=!1,this.voiceStatus="disconnected"}getVoiceConfigFromConfig(){var t,n,o,a,s,i,d,l,u;if(!((t=this.config.voiceRecognition)!=null&&t.provider))return;let e=this.config.voiceRecognition.provider;switch(e.type){case"runtype":return{type:"runtype",runtype:{agentId:((n=e.runtype)==null?void 0:n.agentId)||"",clientToken:((o=e.runtype)==null?void 0:o.clientToken)||"",host:(a=e.runtype)==null?void 0:a.host,voiceId:(s=e.runtype)==null?void 0:s.voiceId,pauseDuration:(i=e.runtype)==null?void 0:i.pauseDuration,silenceThreshold:(d=e.runtype)==null?void 0:d.silenceThreshold}};case"browser":return{type:"browser",browser:{language:((l=e.browser)==null?void 0:l.language)||"en-US",continuous:(u=e.browser)==null?void 0:u.continuous}};default:return}}async initClientSession(){var e,t;if(!this.isClientTokenMode())return null;try{let n=await this.client.initSession();return this.setClientSession(n),n}catch(n){return(t=(e=this.callbacks).onError)==null||t.call(e,n instanceof Error?n:new Error(String(n))),null}}setClientSession(e){if(this.clientSession=e,e.config.welcomeMessage&&this.messages.length===0){let t={id:`welcome-${Date.now()}`,role:"assistant",content:e.config.welcomeMessage,createdAt:new Date().toISOString(),sequence:this.nextSequence()};this.appendMessage(t)}}getClientSession(){var e;return(e=this.clientSession)!=null?e:this.client.getClientSession()}isSessionValid(){let e=this.getClientSession();return e?new Date<e.expiresAt:!1}clearClientSession(){this.clientSession=null,this.client.clearClientSession()}getClient(){return this.client}async submitMessageFeedback(e,t){return this.client.submitMessageFeedback(e,t)}async submitCSATFeedback(e,t){return this.client.submitCSATFeedback(e,t)}async submitNPSFeedback(e,t){return this.client.submitNPSFeedback(e,t)}updateConfig(e){let t={...this.config,...e};if(!av(this.config,t)){this.config=t,this.client.updateConfig(t);return}this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear();let n=this.client.getSSEEventCallback();this.config=t,this.client=new ua(this.config),this.wireDefaultWebMcpConfirm(),n&&this.client.setSSEEventCallback(n)}getMessages(){return[...this.messages]}getStatus(){return this.status}isStreaming(){return this.streaming}injectTestEvent(e){this.handleEvent(e)}injectMessage(e){let{role:t,content:n,llmContent:o,contentParts:a,id:s,createdAt:i,sequence:d,streaming:l=!1,voiceProcessing:u,rawContent:m}=e,f={id:s!=null?s:t==="user"?Va():t==="assistant"?fa():`system-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:t,content:n,createdAt:i!=null?i:new Date().toISOString(),sequence:d!=null?d:this.nextSequence(),streaming:l,...o!==void 0&&{llmContent:o},...a!==void 0&&{contentParts:a},...u!==void 0&&{voiceProcessing:u},...m!==void 0&&{rawContent:m}};return this.upsertMessage(f),f}injectAssistantMessage(e){return this.injectMessage({...e,role:"assistant"})}injectUserMessage(e){return this.injectMessage({...e,role:"user"})}injectSystemMessage(e){return this.injectMessage({...e,role:"system"})}injectMessageBatch(e){let t=[];for(let n of e){let{role:o,content:a,llmContent:s,contentParts:i,id:d,createdAt:l,sequence:u,streaming:m=!1,voiceProcessing:p,rawContent:f}=n,h={id:d!=null?d:o==="user"?Va():o==="assistant"?fa():`system-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:o,content:a,createdAt:l!=null?l:new Date().toISOString(),sequence:u!=null?u:this.nextSequence(),streaming:m,...s!==void 0&&{llmContent:s},...i!==void 0&&{contentParts:i},...p!==void 0&&{voiceProcessing:p},...f!==void 0&&{rawContent:f}};t.push(h)}return this.messages=this.sortMessages([...this.messages,...t]),this.callbacks.onMessagesChanged([...this.messages]),t}injectComponentDirective(e){let{component:t,props:n={},text:o="",llmContent:a,id:s,createdAt:i,sequence:d}=e,l={text:o,component:t,props:n};return this.injectMessage({role:"assistant",content:o,rawContent:JSON.stringify(l),...a!==void 0&&{llmContent:a},...s!==void 0&&{id:s},...i!==void 0&&{createdAt:i},...d!==void 0&&{sequence:d}})}async sendMessage(e,t){var l,u,m,p,f;let n=e.trim();if(!n&&(!(t!=null&&t.contentParts)||t.contentParts.length===0))return;this.stopSpeaking(),(l=this.abortController)==null||l.abort(),this.abortWebMcpResolves();let o=Va(),a=fa(),s={id:o,role:"user",content:n||al,createdAt:new Date().toISOString(),sequence:this.nextSequence(),viaVoice:(t==null?void 0:t.viaVoice)||!1,...(t==null?void 0:t.contentParts)&&t.contentParts.length>0&&{contentParts:t.contentParts}};this.appendMessage(s),this.setStreaming(!0);let i=new AbortController;this.abortController=i;let d=[...this.messages];try{await this.client.dispatch({messages:d,signal:i.signal,assistantMessageId:a},this.handleEvent)}catch(b){let h=b instanceof Error&&(b.name==="AbortError"||b.message.includes("aborted")||b.message.includes("abort"));if(!h){let S=sx(b,this.config.errorMessage);if(S){let T={id:a,role:"assistant",createdAt:new Date().toISOString(),content:S,sequence:this.nextSequence()};this.appendMessage(T)}}this.setStatus("idle"),this.setStreaming(!1),this.abortController=null,h||(b instanceof Error?(m=(u=this.callbacks).onError)==null||m.call(u,b):(f=(p=this.callbacks).onError)==null||f.call(p,new Error(String(b))))}}async continueConversation(){var o,a,s,i,d;if(this.streaming)return;(o=this.abortController)==null||o.abort();let e=fa();this.setStreaming(!0);let t=new AbortController;this.abortController=t;let n=[...this.messages];try{await this.client.dispatch({messages:n,signal:t.signal,assistantMessageId:e},this.handleEvent)}catch(l){let u=l instanceof Error&&(l.name==="AbortError"||l.message.includes("aborted")||l.message.includes("abort"));if(!u){let m=sx(l,this.config.errorMessage);if(m){let p={id:e,role:"assistant",createdAt:new Date().toISOString(),content:m,sequence:this.nextSequence()};this.appendMessage(p)}}this.setStatus("idle"),this.setStreaming(!1),this.abortController=null,u||(l instanceof Error?(s=(a=this.callbacks).onError)==null||s.call(a,l):(d=(i=this.callbacks).onError)==null||d.call(i,new Error(String(l))))}}async connectStream(e,t){var o,a,s;if(this.streaming&&!(t!=null&&t.allowReentry))return;t!=null&&t.allowReentry||(o=this.abortController)==null||o.abort();let n=!1;for(let i of this.messages)i.streaming&&(i.streaming=!1,n=!0);n&&this.callbacks.onMessagesChanged([...this.messages]),this.setStreaming(!0);try{await this.client.processStream(e,this.handleEvent,t==null?void 0:t.assistantMessageId)}catch(i){this.setStatus("error"),this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null),(s=(a=this.callbacks).onError)==null||s.call(a,i instanceof Error?i:new Error(String(i)))}}wireDefaultWebMcpConfirm(){let e=this.config.webmcp;(e==null?void 0:e.enabled)===!0&&!e.onConfirm&&this.client.setWebMcpConfirmHandler(t=>this.requestWebMcpApproval(t))}requestWebMcpApproval(e){var o,a,s;try{if(((a=(o=this.config.webmcp)==null?void 0:o.autoApprove)==null?void 0:a.call(o,e))===!0)return Promise.resolve(!0)}catch{}let t={id:`webmcp-${++this.webMcpApprovalSeq}`,status:"pending",agentId:"",executionId:"",toolName:e.toolName,toolType:"webmcp",description:(s=e.description)!=null?s:`Allow the assistant to run ${e.toolName}?`,parameters:e.args},n=`approval-${t.id}`;return this.upsertMessage({id:n,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",approval:t}),new Promise(i=>{this.webMcpApprovalResolvers.set(n,i)})}resolveWebMcpApproval(e,t){let n=this.webMcpApprovalResolvers.get(e);if(!n)return;this.webMcpApprovalResolvers.delete(e);let o=this.messages.find(a=>a.id===e);o!=null&&o.approval&&this.upsertMessage({...o,approval:{...o.approval,status:t,resolvedAt:Date.now()}}),n(t==="approved")}async resolveApproval(e,t,n){var u,m,p,f,b;let o=`approval-${e.id}`,a={...e,status:t,resolvedAt:Date.now()},s=this.messages.find(h=>h.id===o),i={id:o,role:"assistant",content:"",createdAt:(u=s==null?void 0:s.createdAt)!=null?u:new Date().toISOString(),...(s==null?void 0:s.sequence)!==void 0?{sequence:s.sequence}:{},streaming:!1,variant:"approval",approval:a};this.upsertMessage(i),(m=this.abortController)==null||m.abort(),this.abortController=new AbortController,this.setStreaming(!0);let d=this.config.approval,l=d&&typeof d=="object"?d.onDecision:void 0;try{let h;if(l?h=await l({approvalId:e.id,executionId:e.executionId,agentId:e.agentId,toolName:e.toolName},t,n):h=await this.client.resolveApproval({agentId:e.agentId,executionId:e.executionId,approvalId:e.id},t),h){let S=null;if(h instanceof Response){if(!h.ok){let T=await h.json().catch(()=>null);throw new Error((p=T==null?void 0:T.error)!=null?p:`Approval request failed: ${h.status}`)}S=h.body}else h instanceof ReadableStream&&(S=h);S?await this.connectStream(S,{allowReentry:!0}):(t==="denied"&&this.appendMessage({id:`denial-${e.id}`,role:"assistant",content:"Tool execution was denied by user.",createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()}),this.setStreaming(!1),this.abortController=null)}else this.setStreaming(!1),this.abortController=null}catch(h){let S=h instanceof Error&&(h.name==="AbortError"||h.message.includes("aborted")||h.message.includes("abort"));this.setStreaming(!1),this.abortController=null,S||(b=(f=this.callbacks).onError)==null||b.call(f,h instanceof Error?h:new Error(String(h)))}}persistAskUserQuestionProgress(e,t){let n=this.messages.find(o=>o.id===e.id);n&&this.upsertMessage({...n,agentMetadata:{...n.agentMetadata,askUserQuestionAnswers:t.answers,askUserQuestionIndex:t.currentIndex}})}markAskUserQuestionResolved(e,t){let n=this.messages.find(o=>o.id===e.id);n&&this.upsertMessage({...n,agentMetadata:{...n.agentMetadata,awaitingLocalTool:!1,askUserQuestionAnswered:!0,...t?{askUserQuestionAnswers:t}:{}}})}async resolveAskUserQuestion(e,t){var u,m,p,f,b,h,S,T,M,k,x,C;let n=this.messages.find(w=>w.id===e.id);if(((u=n==null?void 0:n.agentMetadata)==null?void 0:u.askUserQuestionAnswered)===!0)return;let o=(m=e.agentMetadata)==null?void 0:m.executionId,a=(p=e.toolCall)==null?void 0:p.name;if(!o||!a){(b=(f=this.callbacks).onError)==null||b.call(f,new Error("resolveAskUserQuestion: message is missing executionId or toolCall.name"));return}let s=typeof t=="string"?void 0:t;if(s===void 0&&typeof t=="string"){let w=(h=e.toolCall)==null?void 0:h.args,E=Array.isArray(w==null?void 0:w.questions)?w.questions:[];if(E.length===1){let H=typeof((S=E[0])==null?void 0:S.question)=="string"?E[0].question:"";H&&(s={[H]:t})}}this.markAskUserQuestionResolved(e,s),(T=this.abortController)==null||T.abort(),this.abortController=new AbortController,this.setStreaming(!0);let i=e.toolCall.id,d=(M=e.toolCall)==null?void 0:M.args,l=Array.isArray(d==null?void 0:d.questions)?d.questions:[];if(l.length===0){let w=typeof t=="string"?t:Object.entries(t).map(([E,H])=>`${E}: ${Array.isArray(H)?H.join(", "):H}`).join(" | ");this.appendMessage({id:`ask-user-answer-${i}`,role:"user",content:w,createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()})}else{let w=s!=null?s:{};l.forEach((E,H)=>{let I=typeof(E==null?void 0:E.question)=="string"?E.question:"";if(!I)return;let L=w[I],O=Array.isArray(L)?L.join(", "):typeof L=="string"?L:"";this.appendMessage({id:`ask-user-q-${i}-${H}`,role:"assistant",content:I,createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()}),this.appendMessage({id:`ask-user-a-${i}-${H}`,role:"user",content:O||"*Skipped*",createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()})})}try{let w=await this.client.resumeFlow(o,{[a]:t});if(!w.ok){let E=await w.json().catch(()=>null);throw new Error((k=E==null?void 0:E.error)!=null?k:`Resume failed: ${w.status}`)}w.body?await this.connectStream(w.body,{allowReentry:!0}):(this.setStreaming(!1),this.abortController=null)}catch(w){let E=w instanceof Error&&(w.name==="AbortError"||w.message.includes("aborted")||w.message.includes("abort"));this.setStreaming(!1),this.abortController=null,E||(C=(x=this.callbacks).onError)==null||C.call(x,w instanceof Error?w:new Error(String(w)))}}enqueueWebMcpAwait(e){var a,s;let t=(a=e.agentMetadata)==null?void 0:a.executionId,n=(s=e.toolCall)==null?void 0:s.id;if(!t||!n){let i=this.webMcpEpoch;queueMicrotask(()=>{i===this.webMcpEpoch&&this.resolveWebMcpToolCall(e)});return}let o=this.webMcpAwaitBatches.get(t);o||(o={snapshots:[],seen:new Set},this.webMcpAwaitBatches.set(t,o)),!o.seen.has(n)&&(o.seen.add(n),o.snapshots.push(e))}scheduleWebMcpBatchFlush(){if(this.webMcpAwaitBatches.size===0)return;let e=this.webMcpEpoch;queueMicrotask(()=>{if(e===this.webMcpEpoch)for(let t of[...this.webMcpAwaitBatches.keys()])this.flushWebMcpAwaitBatch(t)})}flushWebMcpAwaitBatch(e){let t=this.webMcpAwaitBatches.get(e);if(!t)return;this.webMcpAwaitBatches.delete(e);let{snapshots:n}=t;n.length===1?this.resolveWebMcpToolCall(n[0]):n.length>1&&this.resolveWebMcpToolCallBatch(e,n)}resolveWebMcpToolStartedAt(e){var o,a;let t=this.messages.find(s=>s.id===e.id),n=[(o=t==null?void 0:t.toolCall)==null?void 0:o.startedAt,(a=e.toolCall)==null?void 0:a.startedAt];for(let s of n)if(typeof s=="number"&&Number.isFinite(s))return s;return Date.now()}isSuggestRepliesAlreadyResolved(e){var n,o;if(((n=e.toolCall)==null?void 0:n.name)!==Vn)return!1;let t=this.messages.find(a=>a.id===e.id);return((o=(t!=null?t:e).agentMetadata)==null?void 0:o.suggestRepliesResolved)===!0}markWebMcpToolRunning(e){let t=this.resolveWebMcpToolStartedAt(e);return this.upsertMessage({...e,streaming:!0,agentMetadata:{...e.agentMetadata,awaitingLocalTool:!1},toolCall:e.toolCall?{...e.toolCall,status:"running",startedAt:t,completedAt:void 0,duration:void 0,durationMs:void 0}:e.toolCall}),t}markWebMcpToolComplete(e,t,n,o=Date.now(),a){this.messages.some(s=>s.id===e.id)&&this.upsertMessage({...e,streaming:!1,agentMetadata:{...e.agentMetadata,awaitingLocalTool:!1,...a},toolCall:e.toolCall?{...e.toolCall,status:"complete",result:t,startedAt:n,completedAt:o,duration:void 0,durationMs:Math.max(0,o-n)}:e.toolCall})}async resolveWebMcpToolCallBatch(e,t){var d,l,u,m;let n=[],o=[],a=new AbortController;this.webMcpResolveControllers.add(a),this.setStreaming(!0);let s=await Promise.all(t.map(async p=>{var C,w,E,H,I,L,O;let f=(C=p.toolCall)==null?void 0:C.name,b=(w=p.toolCall)==null?void 0:w.id;if(!f||!b)return null;let h=`${e}:${b}`;if(this.webMcpInflightKeys.has(h)||this.webMcpResolvedKeys.has(h)||this.isSuggestRepliesAlreadyResolved(p))return null;this.webMcpInflightKeys.add(h),n.push(h);let S=this.markWebMcpToolRunning(p),T=(H=(E=p.agentMetadata)==null?void 0:E.webMcpToolCallId)!=null?H:f;if(f===Vn)return{dedupeKey:h,resumeKey:T,output:Nd(),toolMessage:p,startedAt:S,completedAt:Date.now()};let M=new AbortController;this.webMcpResolveControllers.add(M),o.push(M);let k=this.client.executeWebMcpToolCall(f,(I=p.toolCall)==null?void 0:I.args,M.signal),x;if(!k)x={isError:!0,content:[{type:"text",text:"WebMCP not enabled on this widget."}]};else try{x=await k}catch($){let te=$ instanceof Error&&($.name==="AbortError"||$.message.includes("aborted")||$.message.includes("abort"));return te||(O=(L=this.callbacks).onError)==null||O.call(L,$ instanceof Error?$:new Error(String($))),this.markWebMcpToolComplete(p,Gs(te?"Aborted by cancel()":ix($)),S),this.webMcpInflightKeys.delete(h),null}return M.signal.aborted?(this.markWebMcpToolComplete(p,Gs("Aborted by cancel()"),S),this.webMcpInflightKeys.delete(h),null):{dedupeKey:h,resumeKey:T,output:x,toolMessage:p,startedAt:S,completedAt:Date.now()}})),i=[];try{if(i=s.filter(b=>b!==null),i.length===0)return;let p={};for(let b of i)p[b.resumeKey]=b.output;let f=await this.client.resumeFlow(e,p,{signal:a.signal});if(!f.ok){let b=await f.json().catch(()=>null);throw new Error((d=b==null?void 0:b.error)!=null?d:`Resume failed: ${f.status}`)}for(let b of i)this.webMcpResolvedKeys.add(b.dedupeKey),this.markWebMcpToolComplete(b.toolMessage,b.output,b.startedAt,b.completedAt,((l=b.toolMessage.toolCall)==null?void 0:l.name)===Vn?{suggestRepliesResolved:!0}:void 0);f.body&&await this.connectStream(f.body,{allowReentry:!0})}catch(p){if(!(p instanceof Error&&(p.name==="AbortError"||p.message.includes("aborted")||p.message.includes("abort"))))(m=(u=this.callbacks).onError)==null||m.call(u,p instanceof Error?p:new Error(String(p)));else for(let b of i)this.markWebMcpToolComplete(b.toolMessage,Gs("Aborted by cancel()"),b.startedAt)}finally{for(let p of n)this.webMcpInflightKeys.delete(p);for(let p of o)this.webMcpResolveControllers.delete(p);this.webMcpResolveControllers.delete(a),this.webMcpResolveControllers.size===0&&!this.abortController&&this.setStreaming(!1)}}async resolveWebMcpToolCall(e){var b,h,S,T,M,k,x,C,w,E,H,I;let t=(b=e.agentMetadata)==null?void 0:b.executionId,n=(h=e.toolCall)==null?void 0:h.name,o=(S=e.toolCall)==null?void 0:S.id;if(!t){(M=(T=this.callbacks).onError)==null||M.call(T,new Error("WebMCP step_await missing executionId \u2014 dispatch left paused."));return}if(!n)return;if(!o){let L=`${t}:__no_tool_id__:${n}`;if(this.webMcpInflightKeys.has(L)||this.webMcpResolvedKeys.has(L))return;this.webMcpInflightKeys.add(L);try{await this.resumeWithToolOutput(t,n,{isError:!0,content:[{type:"text",text:"WebMCP step_await missing toolCall.id \u2014 cannot execute the page tool."}]}),this.webMcpResolvedKeys.add(L)}catch(O){(x=(k=this.callbacks).onError)==null||x.call(k,O instanceof Error?O:new Error(String(O)))}finally{this.webMcpInflightKeys.delete(L)}return}let a=`${t}:${o}`;if(this.webMcpInflightKeys.has(a)||this.webMcpResolvedKeys.has(a)||this.isSuggestRepliesAlreadyResolved(e))return;this.webMcpInflightKeys.add(a);let s=this.markWebMcpToolRunning(e),i=new AbortController;this.webMcpResolveControllers.add(i);let{signal:d}=i;this.setStreaming(!0);let l=n===Vn,u=(C=e.toolCall)==null?void 0:C.args,m=l?null:this.client.executeWebMcpToolCall(n,u,d),p="execute",f=s;try{let L;if(l?L=Nd():m?L=await m:L={isError:!0,content:[{type:"text",text:"WebMCP not enabled on this widget."}]},f=Date.now(),d.aborted){this.markWebMcpToolComplete(e,Gs("Aborted by cancel()"),s);return}let O=(E=(w=e.agentMetadata)==null?void 0:w.webMcpToolCallId)!=null?E:n;p="resume",await this.resumeWithToolOutput(t,O,L,{onHttpOk:()=>{this.webMcpResolvedKeys.add(a),this.markWebMcpToolComplete(e,L,s,f,l?{suggestRepliesResolved:!0}:void 0)},signal:d})}catch(L){let O=L instanceof Error&&(L.name==="AbortError"||L.message.includes("aborted")||L.message.includes("abort"));(p==="execute"||O||d.aborted)&&this.markWebMcpToolComplete(e,Gs(O||d.aborted?"Aborted by cancel()":ix(L)),s),O||(I=(H=this.callbacks).onError)==null||I.call(H,L instanceof Error?L:new Error(String(L)))}finally{this.webMcpInflightKeys.delete(a),this.webMcpResolveControllers.delete(i),this.webMcpResolveControllers.size===0&&!this.abortController&&this.setStreaming(!1)}}async resumeWithToolOutput(e,t,n,o){var s,i;let a=await this.client.resumeFlow(e,{[t]:n},{signal:o==null?void 0:o.signal});if(!a.ok){let d=await a.json().catch(()=>null);throw new Error((s=d==null?void 0:d.error)!=null?s:`Resume failed: ${a.status}`)}(i=o==null?void 0:o.onHttpOk)==null||i.call(o),a.body?await this.connectStream(a.body,{allowReentry:!0}):this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null)}abortWebMcpResolves(){for(let e of this.webMcpResolveControllers)e.abort();this.webMcpResolveControllers.clear();for(let e of[...this.webMcpApprovalResolvers.keys()])this.resolveWebMcpApproval(e,"denied");this.webMcpAwaitBatches.clear(),this.webMcpEpoch++}cancel(){var e;(e=this.abortController)==null||e.abort(),this.abortController=null,this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.stopSpeaking(),this.stopVoicePlayback(),this.setStreaming(!1),this.setStatus("idle")}clearMessages(){var e;this.stopSpeaking(),(e=this.abortController)==null||e.abort(),this.abortController=null,this.abortWebMcpResolves(),this.messages=[],this.agentExecution=null,this.clearArtifactState(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear(),this.client.resetClientToolsFingerprint(),this.setStreaming(!1),this.setStatus("idle"),this.callbacks.onMessagesChanged([...this.messages])}getArtifacts(){return[...this.artifacts.values()]}getArtifactById(e){return this.artifacts.get(e)}getSelectedArtifactId(){return this.selectedArtifactId}selectArtifact(e){this.selectedArtifactId=e,this.emitArtifactsState()}clearArtifacts(){this.clearArtifactState()}upsertArtifact(e){var o;let t=e.id||`art_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,9)}`;if(e.artifactType==="markdown"){let a={id:t,artifactType:"markdown",title:e.title,status:"complete",markdown:e.content};return this.artifacts.set(t,a),this.selectedArtifactId=t,this.emitArtifactsState(),a}let n={id:t,artifactType:"component",title:e.title,status:"complete",component:e.component,props:(o=e.props)!=null?o:{}};return this.artifacts.set(t,n),this.selectedArtifactId=t,this.emitArtifactsState(),n}clearArtifactState(){this.artifacts.size===0&&this.selectedArtifactId===null||(this.artifacts.clear(),this.selectedArtifactId=null,this.emitArtifactsState())}emitArtifactsState(){var e,t;(t=(e=this.callbacks).onArtifactsState)==null||t.call(e,{artifacts:[...this.artifacts.values()],selectedId:this.selectedArtifactId})}applyArtifactStreamEvent(e){var t,n;switch(e.type){case"artifact_start":{e.artifactType==="markdown"?this.artifacts.set(e.id,{id:e.id,artifactType:"markdown",title:e.title,status:"streaming",markdown:""}):this.artifacts.set(e.id,{id:e.id,artifactType:"component",title:e.title,status:"streaming",component:(t=e.component)!=null?t:"",props:{}}),this.selectedArtifactId=e.id;break}case"artifact_delta":{let o=this.artifacts.get(e.id);(o==null?void 0:o.artifactType)==="markdown"&&(o.markdown=((n=o.markdown)!=null?n:"")+e.artDelta);break}case"artifact_update":{let o=this.artifacts.get(e.id);(o==null?void 0:o.artifactType)==="component"&&(o.props={...o.props,...e.props},e.component&&(o.component=e.component));break}case"artifact_complete":{let o=this.artifacts.get(e.id);o&&(o.status="complete");break}default:return}this.emitArtifactsState()}hydrateMessages(e){var t;(t=this.abortController)==null||t.abort(),this.abortController=null,this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear(),this.messages=this.sortMessages(e.map(n=>{var o;return{...n,streaming:!1,sequence:(o=n.sequence)!=null?o:this.nextSequence()}})),this.setStreaming(!1),this.setStatus("idle"),this.callbacks.onMessagesChanged([...this.messages])}hydrateArtifacts(e,t=null){this.artifacts.clear();for(let n of e)this.artifacts.set(n.id,{...n,status:"complete"});this.selectedArtifactId=t,this.emitArtifactsState()}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.onStatusChanged(e))}setStreaming(e){if(this.streaming===e)return;let t=this.streaming;this.streaming=e,this.callbacks.onStreamingChanged(e),t&&!e&&this.speakLatestAssistantMessage()}speakLatestAssistantMessage(){let e=this.config.textToSpeech;if(!(e!=null&&e.enabled)||!(!e.provider||e.provider==="browser"||e.provider==="runtype"&&e.browserFallback))return;let n=[...this.messages].reverse().find(a=>a.role==="assistant"&&a.content&&!a.voiceProcessing);if(!n)return;if(this.ttsSpokenMessageIds.has(n.id)){this.ttsSpokenMessageIds.delete(n.id);return}let o=n.content;o.trim()&&this.speak(o,e)}speak(e,t){if(typeof window=="undefined"||!("speechSynthesis"in window))return;let n=window.speechSynthesis;n.cancel();let o=new SpeechSynthesisUtterance(e),a=n.getVoices();if(t.voice){let s=a.find(i=>i.name===t.voice);s&&(o.voice=s)}else a.length>0&&(o.voice=t.pickVoice?t.pickVoice(a):r.pickBestVoice(a));t.rate!==void 0&&(o.rate=t.rate),t.pitch!==void 0&&(o.pitch=t.pitch),setTimeout(()=>n.speak(o),50)}static pickBestVoice(e){var n;let t=["Microsoft Jenny Online (Natural) - English (United States)","Microsoft Aria Online (Natural) - English (United States)","Microsoft Guy Online (Natural) - English (United States)","Google US English","Google UK English Female","Ava (Premium)","Evan (Enhanced)","Samantha (Enhanced)","Samantha","Daniel","Karen","Microsoft David Desktop - English (United States)","Microsoft Zira Desktop - English (United States)"];for(let o of t){let a=e.find(s=>s.name===o);if(a)return a}return(n=e.find(o=>o.lang.startsWith("en")))!=null?n:e[0]}stopSpeaking(){typeof window!="undefined"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}appendMessage(e){let t=this.ensureSequence(e);this.messages=this.sortMessages([...this.messages,t]),this.callbacks.onMessagesChanged([...this.messages])}upsertMessage(e){let t=this.ensureSequence(e),n=this.messages.findIndex(o=>o.id===t.id);if(n===-1){this.appendMessage(t);return}this.messages=this.messages.map((o,a)=>{var u,m,p,f,b,h,S,T,M,k,x,C,w,E,H;if(a!==n)return o;let s={...o,...t};if(((u=o.agentMetadata)==null?void 0:u.askUserQuestionAnswered)===!0&&t.agentMetadata&&(s.agentMetadata={...t.agentMetadata,askUserQuestionAnswered:!0,...o.agentMetadata.askUserQuestionAnswers?{askUserQuestionAnswers:o.agentMetadata.askUserQuestionAnswers}:{},awaitingLocalTool:!1}),((m=o.agentMetadata)==null?void 0:m.suggestRepliesResolved)===!0&&t.agentMetadata&&(s.agentMetadata={...(p=s.agentMetadata)!=null?p:t.agentMetadata,suggestRepliesResolved:!0,awaitingLocalTool:!1}),o.approval&&t.approval&&o.approval.id===t.approval.id){let I=o.approval,L=t.approval;s.approval={...I,...L,executionId:L.executionId||I.executionId,toolName:L.toolName||I.toolName,description:L.description||I.description,toolType:(f=L.toolType)!=null?f:I.toolType,reason:(b=L.reason)!=null?b:I.reason,parameters:(h=L.parameters)!=null?h:I.parameters}}let i=(S=t.toolCall)==null?void 0:S.name,d=(T=t.agentMetadata)==null?void 0:T.executionId,l=(M=t.toolCall)==null?void 0:M.id;if(i&&lx(i)&&d&&l&&((k=t.agentMetadata)==null?void 0:k.awaitingLocalTool)===!0){let I=`${d}:${l}`,L=this.webMcpInflightKeys.has(I),O=this.webMcpResolvedKeys.has(I),$=(x=o.toolCall)==null?void 0:x.name,te=((C=o.agentMetadata)==null?void 0:C.executionId)===d&&((w=o.toolCall)==null?void 0:w.id)===l&&$!==void 0&&lx($)&&((E=o.toolCall)==null?void 0:E.status)==="complete";(L||O||te)&&(s.agentMetadata={...(H=s.agentMetadata)!=null?H:{},awaitingLocalTool:!1},s.toolCall=o.toolCall,s.streaming=o.streaming)}return s}),this.messages=this.sortMessages(this.messages),this.callbacks.onMessagesChanged([...this.messages])}ensureSequence(e){return e.sequence!==void 0?{...e}:{...e,sequence:this.nextSequence()}}nextSequence(){return this.sequenceCounter++}sortMessages(e){return[...e].sort((t,n)=>{var d,l;let o=new Date(t.createdAt).getTime(),a=new Date(n.createdAt).getTime();if(!Number.isNaN(o)&&!Number.isNaN(a)&&o!==a)return o-a;let s=(d=t.sequence)!=null?d:0,i=(l=n.sequence)!=null?l:0;return s!==i?s-i:t.id.localeCompare(n.id)})}};var Vd=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];var jd=[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]];var Gd=[["path",{d:"m12 19-7-7 7-7"}],["path",{d:"M19 12H5"}]];var Kd=[["path",{d:"M5 12h14"}],["path",{d:"m12 5 7 7-7 7"}]];var Xd=[["path",{d:"M7 7h10v10"}],["path",{d:"M7 17 17 7"}]];var Qd=[["path",{d:"m5 12 7-7 7 7"}],["path",{d:"M12 19V5"}]];var Jd=[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"}]];var Yd=[["path",{d:"M4.929 4.929 19.07 19.071"}],["circle",{cx:"12",cy:"12",r:"10"}]];var Zd=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];var ec=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"}]];var tc=[["path",{d:"M12 8V4H8"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}],["path",{d:"M2 14h2"}],["path",{d:"M20 14h2"}],["path",{d:"M15 13v2"}],["path",{d:"M9 13v2"}]];var rc=[["path",{d:"M12 10h.01"}],["path",{d:"M12 14h.01"}],["path",{d:"M12 6h.01"}],["path",{d:"M16 10h.01"}],["path",{d:"M16 14h.01"}],["path",{d:"M16 6h.01"}],["path",{d:"M8 10h.01"}],["path",{d:"M8 14h.01"}],["path",{d:"M8 6h.01"}],["path",{d:"M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2"}]];var nc=[["path",{d:"M8 2v4"}],["path",{d:"M16 2v4"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}],["path",{d:"M3 10h18"}],["path",{d:"M8 14h.01"}],["path",{d:"M12 14h.01"}],["path",{d:"M16 14h.01"}],["path",{d:"M8 18h.01"}],["path",{d:"M12 18h.01"}],["path",{d:"M16 18h.01"}]];var oc=[["path",{d:"M8 2v4"}],["path",{d:"M16 2v4"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}],["path",{d:"M3 10h18"}]];var ac=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z"}],["circle",{cx:"12",cy:"13",r:"3"}]];var sc=[["path",{d:"M20 6 9 17l-5-5"}]];var ic=[["path",{d:"m6 9 6 6 6-6"}]];var lc=[["path",{d:"m15 18-6-6 6-6"}]];var dc=[["path",{d:"m9 18 6-6-6-6"}]];var cc=[["path",{d:"m18 15-6-6-6 6"}]];var cl=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m9 12 2 2 4-4"}]];var pl=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m15 9-6 6"}],["path",{d:"m9 9 6 6"}]];var pc=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var uc=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}]];var fc=[["path",{d:"M12 6v6l4 2"}],["circle",{cx:"12",cy:"12",r:"10"}]];var mc=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]];var gc=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10"}]];var hc=[["line",{x1:"12",x2:"12",y1:"2",y2:"22"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"}]];var xc=[["path",{d:"M12 15V3"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}],["path",{d:"m7 10 5 5 5-5"}]];var ul=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"12",cy:"5",r:"1"}],["circle",{cx:"12",cy:"19",r:"1"}]];var fl=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"19",cy:"12",r:"1"}],["circle",{cx:"5",cy:"12",r:"1"}]];var bc=[["path",{d:"M15 3h6v6"}],["path",{d:"M10 14 21 3"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}]];var yc=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}],["path",{d:"m2 2 20 20"}]];var vc=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}],["circle",{cx:"12",cy:"12",r:"3"}]];var Cc=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 12.5 8 15l2 2.5"}],["path",{d:"m14 12.5 2 2.5-2 2.5"}]];var wc=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M8 13h2"}],["path",{d:"M14 13h2"}],["path",{d:"M8 17h2"}],["path",{d:"M14 17h2"}]];var Ac=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];var Sc=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}]];var Tc=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1"}]];var Mc=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M7 3v18"}],["path",{d:"M3 7.5h4"}],["path",{d:"M3 12h18"}],["path",{d:"M3 16.5h4"}],["path",{d:"M17 3v18"}],["path",{d:"M17 7.5h4"}],["path",{d:"M17 16.5h4"}]];var kc=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528"}]];var Ec=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}]];var Lc=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"}]];var ml=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"}]];var Pc=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1"}],["path",{d:"M12 8v13"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5"}]];var Rc=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}],["path",{d:"M2 12h20"}]];var Ic=[["line",{x1:"4",x2:"20",y1:"9",y2:"9"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21"}]];var Hc=[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"}]];var Wc=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"}]];var Bc=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}],["path",{d:"M3 3v5h5"}],["path",{d:"M12 7v5l4 2"}]];var gl=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}]];var Dc=[["path",{d:"M16 5h6"}],["path",{d:"M19 2v6"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}],["circle",{cx:"9",cy:"9",r:"2"}]];var Fc=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}],["circle",{cx:"9",cy:"9",r:"2"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}]];var Oc=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 16v-4"}],["path",{d:"M12 8h.01"}]];var Nc=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4"}],["path",{d:"m21 2-9.6 9.6"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5"}]];var _c=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}]];var hl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56"}]];var Uc=[["path",{d:"M12 2v4"}],["path",{d:"m16.2 7.8 2.9-2.9"}],["path",{d:"M18 12h4"}],["path",{d:"m16.2 16.2 2.9 2.9"}],["path",{d:"M12 18v4"}],["path",{d:"m4.9 19.1 2.9-2.9"}],["path",{d:"M2 12h4"}],["path",{d:"m4.9 4.9 2.9 2.9"}]];var qc=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]];var zc=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}]];var $c=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"}],["circle",{cx:"12",cy:"10",r:"3"}]];var Vc=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"}]];var jc=[["path",{d:"M4 5h16"}],["path",{d:"M4 12h16"}],["path",{d:"M4 19h16"}]];var Gc=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"}]];var Kc=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"}]];var Xc=[["path",{d:"M12 19v3"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"}]];var Qc=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"}]];var Jc=[["path",{d:"M5 12h14"}]];var Yc=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21"}]];var Zc=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"}]];var ep=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z"}],["path",{d:"M12 22V12"}],["polyline",{points:"3.29 7 12 12 20.71 7"}],["path",{d:"m7.5 4.27 9 5.15"}]];var tp=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"}]];var rp=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1"}]];var np=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}],["path",{d:"m15 5 4 4"}]];var op=[["line",{x1:"19",x2:"5",y1:"5",y2:"19"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5"}]];var ap=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384"}]];var sp=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]];var ip=[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]];var lp=[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}],["path",{d:"M12 17.5v-11"}]];var dp=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}],["path",{d:"M8 16H3v5"}]];var cp=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}]];var pp=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7"}]];var up=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var fp=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"}],["path",{d:"m21.854 2.147-10.94 10.939"}]];var mp=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];var gp=[["path",{d:"M12 2v13"}],["path",{d:"m16 6-4-4-4 4"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"}]];var hp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"M12 8v4"}],["path",{d:"M12 16h.01"}]];var xp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m9 12 2 2 4-4"}]];var xl=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m14.5 9.5-5 5"}],["path",{d:"m9.5 9.5 5 5"}]];var bp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}]];var yp=[["path",{d:"M16 10a4 4 0 0 1-8 0"}],["path",{d:"M3.103 6.034h17.794"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z"}]];var vp=[["circle",{cx:"8",cy:"21",r:"1"}],["circle",{cx:"19",cy:"21",r:"1"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"}]];var Cp=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2"}],["path",{d:"M12 18h.01"}]];var bl=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"}],["path",{d:"M20 2v4"}],["path",{d:"M22 4h-4"}],["circle",{cx:"4",cy:"20",r:"2"}]];var wp=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];var Ap=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"}]];var Sp=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05"}]];var Tp=[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M12 2v2"}],["path",{d:"M12 20v2"}],["path",{d:"m4.93 4.93 1.41 1.41"}],["path",{d:"m17.66 17.66 1.41 1.41"}],["path",{d:"M2 12h2"}],["path",{d:"M20 12h2"}],["path",{d:"m6.34 17.66-1.41 1.41"}],["path",{d:"m19.07 4.93-1.41 1.41"}]];var Mp=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor"}]];var kp=[["path",{d:"M17 14V2"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"}]];var Ep=[["path",{d:"M7 10v12"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"}]];var Lp=[["line",{x1:"10",x2:"14",y1:"2",y2:"2"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11"}],["circle",{cx:"12",cy:"14",r:"8"}]];var Pp=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var Rp=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var yl=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}],["path",{d:"M12 9v4"}],["path",{d:"M12 17h.01"}]];var Ip=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2"}],["path",{d:"M15 18H9"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14"}],["circle",{cx:"17",cy:"18",r:"2"}],["circle",{cx:"7",cy:"18",r:"2"}]];var Hp=[["path",{d:"M12 3v12"}],["path",{d:"m17 8-5-5-5 5"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}]];var Wp=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}],["circle",{cx:"12",cy:"7",r:"4"}]];var Bp=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"}],["path",{d:"M16 9a5 5 0 0 1 0 6"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728"}]];var Dp=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15"}]];var Fp=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"}]];var Op=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var Np=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];var sv={activity:Vd,"arrow-down":jd,"arrow-up":Qd,"arrow-up-right":Xd,bot:tc,"chevron-down":ic,"chevron-up":cc,"chevron-right":dc,"chevron-left":lc,check:sc,clipboard:uc,"clipboard-copy":pc,copy:mc,file:Sc,"file-code":Cc,"file-spreadsheet":wc,"file-text":Ac,"image-plus":Dc,loader:Uc,"loader-circle":hl,mic:Xc,paperclip:tp,"refresh-cw":dp,search:up,send:fp,"shield-alert":hp,"shield-check":xp,"shield-x":xl,square:wp,"thumbs-down":kp,"thumbs-up":Ep,upload:Hp,"volume-2":Bp,x:Op,user:Wp,mail:zc,phone:ap,calendar:oc,clock:fc,building:rc,"map-pin":$c,lock:qc,key:Nc,"credit-card":gc,"at-sign":Jd,hash:Ic,globe:Rc,link:_c,"circle-check":cl,"circle-x":pl,"triangle-alert":yl,info:Oc,ban:Yd,shield:bp,"arrow-left":Gd,"arrow-right":Kd,"external-link":bc,ellipsis:fl,"ellipsis-vertical":ul,menu:jc,house:gl,plus:ip,minus:Jc,pencil:np,trash:Rp,"trash-2":Pp,save:pp,download:xc,share:gp,funnel:ml,settings:mp,"rotate-cw":cp,maximize:Vc,minimize:Qc,"shopping-cart":vp,"shopping-bag":yp,package:ep,truck:Ip,tag:Mp,gift:Pc,receipt:lp,wallet:Fp,store:Sp,"dollar-sign":hc,percent:op,play:sp,pause:rp,"volume-x":Dp,camera:ac,image:Fc,film:Mc,headphones:Hc,"message-circle":Gc,"message-square":Kc,bell:Zd,heart:Wc,star:Ap,eye:vc,"eye-off":yc,bookmark:ec,"calendar-days":nc,history:Bc,timer:Lp,folder:Lc,"folder-open":Ec,files:Tc,sparkles:bl,zap:Np,sun:Tp,moon:Zc,flag:kc,monitor:Yc,smartphone:Cp},Me=(r,e=24,t="currentColor",n=2)=>{let o=sv[r];return o?iv(o,e,t,n):(console.warn(`Lucide icon "${r}" is not in the Persona registry. Add it to packages/widget/src/utils/icons.ts (see docs/icon-registry-shortlist.md).`),null)};function iv(r,e,t,n){if(!Array.isArray(r))return null;let o=document.createElementNS("http://www.w3.org/2000/svg","svg");return o.setAttribute("width",String(e)),o.setAttribute("height",String(e)),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none"),o.setAttribute("stroke",t),o.setAttribute("stroke-width",String(n)),o.setAttribute("stroke-linecap","round"),o.setAttribute("stroke-linejoin","round"),o.setAttribute("aria-hidden","true"),r.forEach(a=>{if(!Array.isArray(a)||a.length<2)return;let s=a[0],i=a[1];if(!i)return;let d=document.createElementNS("http://www.w3.org/2000/svg",s);Object.entries(i).forEach(([l,u])=>{l!=="stroke"&&d.setAttribute(l,String(u))}),o.appendChild(d)}),o}var vl={allowedTypes:yo,maxFileSize:10*1024*1024,maxFiles:4};function lv(){return`attach_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function dv(r){return r==="application/pdf"||r.startsWith("text/")||r.includes("word")?"file-text":r.includes("excel")||r.includes("spreadsheet")?"file-spreadsheet":r==="application/json"?"file-code":"file"}var ha=class r{constructor(e={}){this.attachments=[];this.previewsContainer=null;var t,n,o;this.config={allowedTypes:(t=e.allowedTypes)!=null?t:vl.allowedTypes,maxFileSize:(n=e.maxFileSize)!=null?n:vl.maxFileSize,maxFiles:(o=e.maxFiles)!=null?o:vl.maxFiles,onFileRejected:e.onFileRejected,onAttachmentsChange:e.onAttachmentsChange}}setPreviewsContainer(e){this.previewsContainer=e}updateConfig(e){e.allowedTypes!==void 0&&(this.config.allowedTypes=e.allowedTypes.length>0?e.allowedTypes:vl.allowedTypes),e.maxFileSize!==void 0&&(this.config.maxFileSize=e.maxFileSize),e.maxFiles!==void 0&&(this.config.maxFiles=e.maxFiles),e.onFileRejected!==void 0&&(this.config.onFileRejected=e.onFileRejected),e.onAttachmentsChange!==void 0&&(this.config.onAttachmentsChange=e.onAttachmentsChange)}getAttachments(){return[...this.attachments]}getContentParts(){return this.attachments.map(e=>e.contentPart)}hasAttachments(){return this.attachments.length>0}count(){return this.attachments.length}async handleFileSelect(e){!e||e.length===0||await this.handleFiles(Array.from(e))}async handleFiles(e){var t,n,o,a,s,i,d;if(e.length){for(let l of e){if(this.attachments.length>=this.config.maxFiles){(n=(t=this.config).onFileRejected)==null||n.call(t,l,"count");continue}let u=ox(l,this.config.allowedTypes,this.config.maxFileSize);if(!u.valid){let m=(o=u.error)!=null&&o.includes("type")?"type":"size";(s=(a=this.config).onFileRejected)==null||s.call(a,l,m);continue}try{let m=await nx(l),p=sl(l)?URL.createObjectURL(l):null,f={id:lv(),file:l,previewUrl:p,contentPart:m};this.attachments.push(f),this.renderPreview(f)}catch(m){console.error("[AttachmentManager] Failed to process file:",m)}}this.updatePreviewsVisibility(),(d=(i=this.config).onAttachmentsChange)==null||d.call(i,this.getAttachments())}}removeAttachment(e){var a,s,i;let t=this.attachments.findIndex(d=>d.id===e);if(t===-1)return;let n=this.attachments[t];n.previewUrl&&URL.revokeObjectURL(n.previewUrl),this.attachments.splice(t,1);let o=(a=this.previewsContainer)==null?void 0:a.querySelector(`[data-attachment-id="${e}"]`);o&&o.remove(),this.updatePreviewsVisibility(),(i=(s=this.config).onAttachmentsChange)==null||i.call(s,this.getAttachments())}clearAttachments(){var e,t;for(let n of this.attachments)n.previewUrl&&URL.revokeObjectURL(n.previewUrl);this.attachments=[],this.previewsContainer&&(this.previewsContainer.innerHTML=""),this.updatePreviewsVisibility(),(t=(e=this.config).onAttachmentsChange)==null||t.call(e,this.getAttachments())}renderPreview(e){if(!this.previewsContainer)return;let t=sl(e.file),n=v("div","persona-attachment-preview persona-relative persona-inline-block");if(n.setAttribute("data-attachment-id",e.id),n.style.width="48px",n.style.height="48px",t&&e.previewUrl){let s=v("img");s.src=e.previewUrl,s.alt=e.file.name,s.className="persona-w-full persona-h-full persona-object-cover persona-rounded-lg persona-border persona-border-gray-200",s.style.width="48px",s.style.height="48px",s.style.objectFit="cover",s.style.borderRadius="8px",n.appendChild(s)}else{let s=v("div");s.style.width="48px",s.style.height="48px",s.style.borderRadius="8px",s.style.backgroundColor="var(--persona-container, #f3f4f6)",s.style.border="1px solid var(--persona-border, #e5e7eb)",s.style.display="flex",s.style.flexDirection="column",s.style.alignItems="center",s.style.justifyContent="center",s.style.gap="2px",s.style.overflow="hidden";let i=dv(e.file.type),d=Me(i,20,"var(--persona-muted, #6b7280)",1.5);d&&s.appendChild(d);let l=v("span");l.textContent=ax(e.file.type,e.file.name),l.style.fontSize="8px",l.style.fontWeight="600",l.style.color="var(--persona-muted, #6b7280)",l.style.textTransform="uppercase",l.style.lineHeight="1",s.appendChild(l),n.appendChild(s)}let o=v("button","persona-attachment-remove persona-absolute persona-flex persona-items-center persona-justify-center");o.type="button",o.setAttribute("aria-label","Remove attachment"),o.style.position="absolute",o.style.top="-4px",o.style.right="-4px",o.style.width="18px",o.style.height="18px",o.style.borderRadius="50%",o.style.backgroundColor="var(--persona-palette-colors-black-alpha-60, rgba(0, 0, 0, 0.6))",o.style.border="none",o.style.cursor="pointer",o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center",o.style.padding="0";let a=Me("x",10,"var(--persona-text-inverse, #ffffff)",2);a?o.appendChild(a):(o.textContent="\xD7",o.style.color="var(--persona-text-inverse, #ffffff)",o.style.fontSize="14px",o.style.lineHeight="1"),o.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.removeAttachment(e.id)}),n.appendChild(o),this.previewsContainer.appendChild(n)}updatePreviewsVisibility(){this.previewsContainer&&(this.previewsContainer.style.display=this.attachments.length>0?"flex":"none")}static fromConfig(e,t){return new r({allowedTypes:e==null?void 0:e.allowedTypes,maxFileSize:e==null?void 0:e.maxFileSize,maxFiles:e==null?void 0:e.maxFiles,onFileRejected:e==null?void 0:e.onFileRejected,onAttachmentsChange:t})}};var dx=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function Ks(r,e){if(!r)return e;if(!e)return r;let t={...r};for(let[n,o]of Object.entries(e)){let a=t[n];dx(a)&&dx(o)?t[n]=Ks(a,o):t[n]=o}return t}var An="min(440px, calc(100vw - 24px))",Cl="440px",Kt={apiUrl:"https://api.runtype.com/api/chat/dispatch",clientToken:void 0,theme:void 0,darkTheme:void 0,colorScheme:"light",launcher:{enabled:!0,mountMode:"floating",dock:{side:"right",width:"420px"},title:"Chat Assistant",subtitle:"Here to help you get answers fast",agentIconText:"\u{1F4AC}",agentIconName:"bot",headerIconName:"bot",position:"bottom-right",width:An,heightOffset:0,autoExpand:!1,callToActionIconHidden:!1,agentIconSize:"40px",headerIconSize:"40px",closeButtonSize:"32px",closeButtonPaddingX:"0px",closeButtonPaddingY:"0px",callToActionIconName:"arrow-up-right",callToActionIconText:"",callToActionIconSize:"32px",callToActionIconPadding:"5px",callToActionIconColor:void 0,callToActionIconBackgroundColor:void 0,closeButtonBackgroundColor:"transparent",clearChat:{backgroundColor:"transparent",borderColor:"transparent",enabled:!0,placement:"inline",iconName:"refresh-cw",size:"32px",showTooltip:!0,tooltipText:"Clear chat",paddingX:"0px",paddingY:"0px"},headerIconHidden:!1,border:void 0,shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"},copy:{welcomeTitle:"Hello \u{1F44B}",welcomeSubtitle:"Ask anything about your account or products.",inputPlaceholder:"How can I help...",sendButtonLabel:"Send"},sendButton:{borderWidth:"0px",paddingX:"12px",paddingY:"10px",borderColor:void 0,useIcon:!0,iconText:"\u2191",size:"40px",showTooltip:!0,tooltipText:"Send message",iconName:"send"},statusIndicator:{visible:!0,idleText:"Online",connectingText:"Connecting\u2026",connectedText:"Streaming\u2026",errorText:"Offline"},voiceRecognition:{enabled:!0,pauseDuration:2e3,iconName:"mic",iconSize:"39px",borderWidth:"0px",paddingX:"9px",paddingY:"14px",iconColor:void 0,backgroundColor:"transparent",borderColor:"transparent",recordingIconColor:void 0,recordingBackgroundColor:void 0,recordingBorderColor:"transparent",showTooltip:!0,tooltipText:"Start voice recognition"},features:{showReasoning:!0,showToolCalls:!0,scrollToBottom:{enabled:!0,iconName:"arrow-down",label:""},scrollBehavior:{mode:"follow",anchorTopOffset:16},toolCallDisplay:{collapsedMode:"tool-call",activePreview:!1,grouped:!1,previewMaxLines:3,expandable:!0,loadingAnimation:"none"},reasoningDisplay:{activePreview:!1,previewMaxLines:3,expandable:!0,loadingAnimation:"none"},streamAnimation:{type:"none",placeholder:"none",speed:120,duration:1800},askUserQuestion:{enabled:!0,slideInMs:180,freeTextLabel:"Other\u2026",freeTextPlaceholder:"Type your answer\u2026",submitLabel:"Send"}},suggestionChips:["What can you help me with?","Tell me about your features","How does this work?"],suggestionChipsConfig:{fontFamily:"sans-serif",fontWeight:"500",paddingX:"12px",paddingY:"6px"},layout:{header:{layout:"default",showIcon:!0,showTitle:!0,showSubtitle:!0,showCloseButton:!0,showClearChat:!0},messages:{layout:"bubble",avatar:{show:!1,position:"left"},timestamp:{show:!1,position:"below"},groupConsecutive:!1},slots:{}},markdown:{options:{gfm:!0,breaks:!0},disableDefaultStyles:!1},messageActions:{enabled:!0,showCopy:!0,showUpvote:!1,showDownvote:!1,visibility:"hover",align:"right",layout:"pill-inside"},debug:!1};function cx(r,e){if(!(!r&&!e))return r?e?Ks(r,e):r:e}function wl(r){var e,t,n,o,a,s,i,d,l,u,m,p,f,b,h,S,T,M,k,x,C;return r?{...Kt,...r,theme:cx(Kt.theme,r.theme),darkTheme:cx(Kt.darkTheme,r.darkTheme),launcher:{...Kt.launcher,...r.launcher,dock:{...(e=Kt.launcher)==null?void 0:e.dock,...(t=r.launcher)==null?void 0:t.dock},clearChat:{...(n=Kt.launcher)==null?void 0:n.clearChat,...(o=r.launcher)==null?void 0:o.clearChat}},copy:{...Kt.copy,...r.copy},sendButton:{...Kt.sendButton,...r.sendButton},statusIndicator:{...Kt.statusIndicator,...r.statusIndicator},voiceRecognition:{...Kt.voiceRecognition,...r.voiceRecognition},features:(()=>{var J,re,Q,ge,Z,G,pe,ke,le,ne;let w=(J=Kt.features)==null?void 0:J.artifacts,E=(re=r.features)==null?void 0:re.artifacts,H=(Q=Kt.features)==null?void 0:Q.scrollToBottom,I=(ge=r.features)==null?void 0:ge.scrollToBottom,L=(Z=Kt.features)==null?void 0:Z.scrollBehavior,O=(G=r.features)==null?void 0:G.scrollBehavior,$=(pe=Kt.features)==null?void 0:pe.streamAnimation,te=(ke=r.features)==null?void 0:ke.streamAnimation,xe=(le=Kt.features)==null?void 0:le.askUserQuestion,Je=(ne=r.features)==null?void 0:ne.askUserQuestion,we=w===void 0&&E===void 0?void 0:{...w,...E,layout:{...w==null?void 0:w.layout,...E==null?void 0:E.layout}},De=H===void 0&&I===void 0?void 0:{...H,...I},Ae=L===void 0&&O===void 0?void 0:{...L,...O},qe=$===void 0&&te===void 0?void 0:{...$,...te},He=xe===void 0&&Je===void 0?void 0:{...xe,...Je,styles:{...xe==null?void 0:xe.styles,...Je==null?void 0:Je.styles}};return{...Kt.features,...r.features,...De!==void 0?{scrollToBottom:De}:{},...Ae!==void 0?{scrollBehavior:Ae}:{},...we!==void 0?{artifacts:we}:{},...qe!==void 0?{streamAnimation:qe}:{},...He!==void 0?{askUserQuestion:He}:{}}})(),suggestionChips:(a=r.suggestionChips)!=null?a:Kt.suggestionChips,suggestionChipsConfig:{...Kt.suggestionChipsConfig,...r.suggestionChipsConfig},layout:{...Kt.layout,...r.layout,header:{...(s=Kt.layout)==null?void 0:s.header,...(i=r.layout)==null?void 0:i.header},messages:{...(d=Kt.layout)==null?void 0:d.messages,...(l=r.layout)==null?void 0:l.messages,avatar:{...(m=(u=Kt.layout)==null?void 0:u.messages)==null?void 0:m.avatar,...(f=(p=r.layout)==null?void 0:p.messages)==null?void 0:f.avatar},timestamp:{...(h=(b=Kt.layout)==null?void 0:b.messages)==null?void 0:h.timestamp,...(T=(S=r.layout)==null?void 0:S.messages)==null?void 0:T.timestamp}},slots:{...(M=Kt.layout)==null?void 0:M.slots,...(k=r.layout)==null?void 0:k.slots}},markdown:{...Kt.markdown,...r.markdown,options:{...(x=Kt.markdown)==null?void 0:x.options,...(C=r.markdown)==null?void 0:C.options}},messageActions:{...Kt.messageActions,...r.messageActions}}:Kt}var _p={colors:{primary:{50:"#ffffff",100:"#f5f5f5",200:"#d4d4d4",300:"#a3a3a3",400:"#737373",500:"#171717",600:"#0f0f0f",700:"#0a0a0a",800:"#050505",900:"#030303",950:"#000000"},secondary:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},accent:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},success:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},warning:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},error:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"},info:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"}},spacing:{0:"0px",1:"0.25rem",2:"0.5rem",3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",8:"2rem",10:"2.5rem",12:"3rem",16:"4rem",20:"5rem",24:"6rem",32:"8rem",40:"10rem",48:"12rem",56:"14rem",64:"16rem"},typography:{fontFamily:{sans:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',serif:'Georgia, Cambria, "Times New Roman", Times, serif',mono:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},fontWeight:{normal:"400",medium:"500",semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5",relaxed:"1.625"}},shadows:{none:"none",sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",xl:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)","2xl":"0 25px 50px -12px rgb(0 0 0 / 0.25)"},borders:{none:"none",sm:"1px solid",md:"2px solid",lg:"4px solid"},radius:{none:"0px",sm:"0.125rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem",full:"9999px"}},Up={colors:{primary:"palette.colors.primary.500",secondary:"palette.colors.secondary.500",accent:"palette.colors.primary.600",surface:"palette.colors.gray.50",background:"palette.colors.gray.50",container:"palette.colors.gray.50",text:"palette.colors.gray.900",textMuted:"palette.colors.gray.500",textInverse:"palette.colors.gray.50",border:"palette.colors.gray.200",divider:"palette.colors.gray.200",interactive:{default:"palette.colors.primary.600",hover:"palette.colors.primary.700",focus:"palette.colors.primary.600",active:"palette.colors.primary.600",disabled:"palette.colors.gray.300"},feedback:{success:"palette.colors.success.500",warning:"palette.colors.warning.500",error:"palette.colors.error.500",info:"palette.colors.info.500"}},spacing:{xs:"palette.spacing.1",sm:"palette.spacing.2",md:"palette.spacing.4",lg:"palette.spacing.6",xl:"palette.spacing.8","2xl":"palette.spacing.10"},typography:{fontFamily:"palette.typography.fontFamily.sans",fontSize:"palette.typography.fontSize.base",fontWeight:"palette.typography.fontWeight.normal",lineHeight:"palette.typography.lineHeight.normal"}},qp={button:{primary:{background:"palette.colors.primary.500",foreground:"palette.colors.primary.50",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md"},secondary:{background:"semantic.colors.surface",foreground:"semantic.colors.secondary",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md"},ghost:{background:"transparent",foreground:"semantic.colors.text",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"}},input:{background:"palette.colors.gray.50",placeholder:"palette.colors.gray.400",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md",focus:{border:"palette.colors.gray.400",ring:"palette.colors.gray.400"}},launcher:{background:"palette.colors.primary.500",foreground:"palette.colors.primary.50",border:"palette.colors.gray.200",size:"60px",iconSize:"28px",borderRadius:"palette.radius.full",shadow:"palette.shadows.lg"},panel:{width:An,maxWidth:Cl,height:"600px",maxHeight:"calc(100vh - 80px)",borderRadius:"palette.radius.xl",shadow:"palette.shadows.xl"},header:{background:"palette.colors.primary.500",border:"palette.colors.primary.600",borderRadius:"palette.radius.xl palette.radius.xl 0 0",padding:"semantic.spacing.md",iconBackground:"palette.colors.primary.600",iconForeground:"palette.colors.primary.50",titleForeground:"palette.colors.primary.50",subtitleForeground:"palette.colors.primary.200",actionIconForeground:"palette.colors.primary.200"},message:{user:{background:"palette.colors.primary.500",text:"palette.colors.primary.50",borderRadius:"palette.radius.lg",shadow:"palette.shadows.sm"},assistant:{background:"palette.colors.gray.50",text:"palette.colors.gray.900",borderRadius:"palette.radius.lg",border:"palette.colors.gray.200",shadow:"palette.shadows.sm"},border:"semantic.colors.border"},introCard:{background:"semantic.colors.surface",borderRadius:"palette.radius.2xl",padding:"semantic.spacing.lg",shadow:"0 5px 15px rgba(15, 23, 42, 0.08)"},toolBubble:{shadow:"palette.shadows.sm"},reasoningBubble:{shadow:"palette.shadows.sm"},composer:{shadow:"palette.shadows.none"},markdown:{inlineCode:{background:"palette.colors.gray.50",foreground:"palette.colors.gray.900"},link:{foreground:"palette.colors.primary.600"},prose:{fontFamily:"inherit"},codeBlock:{background:"semantic.colors.container",borderColor:"semantic.colors.border",textColor:"inherit"},table:{headerBackground:"semantic.colors.container",borderColor:"semantic.colors.border"},hr:{color:"semantic.colors.divider"},blockquote:{borderColor:"palette.colors.gray.900",background:"transparent",textColor:"palette.colors.gray.500"}},collapsibleWidget:{container:"palette.colors.gray.50",surface:"semantic.colors.surface",border:"semantic.colors.border"},voice:{recording:{indicator:"palette.colors.error.500",background:"palette.colors.error.50",border:"palette.colors.error.200"},processing:{icon:"palette.colors.primary.500",background:"palette.colors.primary.50"},speaking:{icon:"palette.colors.success.500"}},approval:{requested:{background:"palette.colors.warning.50",border:"palette.colors.warning.200",text:"palette.colors.gray.900",shadow:"0 5px 15px rgba(15, 23, 42, 0.08)"},approve:{background:"palette.colors.success.500",foreground:"palette.colors.gray.50",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"},deny:{background:"palette.colors.error.500",foreground:"palette.colors.gray.50",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"}},attachment:{image:{background:"palette.colors.gray.100",border:"palette.colors.gray.200"}},scrollToBottom:{background:"components.button.primary.background",foreground:"components.button.primary.foreground",border:"semantic.colors.primary",size:"40px",borderRadius:"palette.radius.full",shadow:"palette.shadows.sm",padding:"0.5rem 0.875rem",gap:"0.5rem",fontSize:"0.875rem",iconSize:"14px"},artifact:{pane:{background:"semantic.colors.container",toolbarBackground:"semantic.colors.container"}}};function Ga(r,e){if(!e.startsWith("palette.")&&!e.startsWith("semantic.")&&!e.startsWith("components."))return e;let t=e.split("."),n=r;for(let o of t){if(n==null)return;n=n[o]}return typeof n=="string"&&(n.startsWith("palette.")||n.startsWith("semantic.")||n.startsWith("components."))?Ga(r,n):n}function Al(r){let e={};function t(n,o){for(let[a,s]of Object.entries(n)){let i=`${o}.${a}`;if(typeof s=="string"){let d=Ga(r,s);d!==void 0&&(e[i]={path:i,value:d,type:o.includes("color")?"color":o.includes("spacing")?"spacing":o.includes("typography")?"typography":o.includes("shadow")?"shadow":o.includes("border")?"border":"color"})}else typeof s=="object"&&s!==null&&t(s,i)}}return t(r.palette,"palette"),t(r.semantic,"semantic"),t(r.components,"components"),e}function zp(r){let e=[],t=[];return r.palette||e.push({path:"palette",message:"Theme must include a palette",severity:"error"}),r.semantic||t.push({path:"semantic",message:"No semantic tokens defined - defaults will be used",severity:"warning"}),r.components||t.push({path:"components",message:"No component tokens defined - defaults will be used",severity:"warning"}),{valid:e.length===0,errors:e,warnings:t}}function px(r,e){let t={...r};for(let[n,o]of Object.entries(e)){let a=t[n];a&&typeof a=="object"&&!Array.isArray(a)&&o&&typeof o=="object"&&!Array.isArray(o)?t[n]=px(a,o):t[n]=o}return t}function cv(r,e){return e?px(r,e):r}function Ka(r,e={}){var o,a,s,i,d,l,u,m,p,f,b,h,S;let t={palette:_p,semantic:Up,components:qp},n={palette:{...t.palette,...r==null?void 0:r.palette,colors:{...t.palette.colors,...(o=r==null?void 0:r.palette)==null?void 0:o.colors},spacing:{...t.palette.spacing,...(a=r==null?void 0:r.palette)==null?void 0:a.spacing},typography:{...t.palette.typography,...(s=r==null?void 0:r.palette)==null?void 0:s.typography},shadows:{...t.palette.shadows,...(i=r==null?void 0:r.palette)==null?void 0:i.shadows},borders:{...t.palette.borders,...(d=r==null?void 0:r.palette)==null?void 0:d.borders},radius:{...t.palette.radius,...(l=r==null?void 0:r.palette)==null?void 0:l.radius}},semantic:{...t.semantic,...r==null?void 0:r.semantic,colors:{...t.semantic.colors,...(u=r==null?void 0:r.semantic)==null?void 0:u.colors,interactive:{...t.semantic.colors.interactive,...(p=(m=r==null?void 0:r.semantic)==null?void 0:m.colors)==null?void 0:p.interactive},feedback:{...t.semantic.colors.feedback,...(b=(f=r==null?void 0:r.semantic)==null?void 0:f.colors)==null?void 0:b.feedback}},spacing:{...t.semantic.spacing,...(h=r==null?void 0:r.semantic)==null?void 0:h.spacing},typography:{...t.semantic.typography,...(S=r==null?void 0:r.semantic)==null?void 0:S.typography}},components:cv(t.components,r==null?void 0:r.components)};if(e.validate!==!1){let T=zp(n);if(!T.valid)throw new Error(`Theme validation failed: ${T.errors.map(M=>M.message).join(", ")}`)}if(e.plugins)for(let T of e.plugins)n=T.transform(n);return n}function Sl(r){var h,S,T,M,k,x,C,w,E,H,I,L,O,$,te,xe,Je,we,De,Ae,qe,He,J,re,Q,ge,Z,G,pe,ke,le,ne,de,Et,wt,We,he,at,Re,j,ue,nt,Rt,ee,Ge,Fr,Bt,or,hr,sn,F,fe,Ie,Xe,Fe,Ne,Ye,At,Xt,ar,K,mt,it,ye,ie,st,pr,pt,yr,Rr,ut,Lt,tt,zt,vr,sr,ur,Mr,un,St,qr,xr,Mn,ln,yt,Gn,kn,_e,R,se,Ee,Ot,et,Nt,Yt,lr,vt,zr,$t,$r,Dn,oo,Ao,fn,Vt,Qr,En,So,ao,To,Kn,mn,Fn,Tt,Cr,wr,gn,Mo;let e=Al(r),t={};for(let[ve,On]of Object.entries(e)){let Ln=ve.replace(/\./g,"-");t[`--persona-${Ln}`]=On.value}t["--persona-primary"]=(h=t["--persona-semantic-colors-primary"])!=null?h:t["--persona-palette-colors-primary-500"],t["--persona-secondary"]=(S=t["--persona-semantic-colors-secondary"])!=null?S:t["--persona-palette-colors-secondary-500"],t["--persona-accent"]=(T=t["--persona-semantic-colors-accent"])!=null?T:t["--persona-palette-colors-accent-500"],t["--persona-surface"]=(M=t["--persona-semantic-colors-surface"])!=null?M:t["--persona-palette-colors-gray-50"],t["--persona-background"]=(k=t["--persona-semantic-colors-background"])!=null?k:t["--persona-palette-colors-gray-50"],t["--persona-container"]=(x=t["--persona-semantic-colors-container"])!=null?x:t["--persona-palette-colors-gray-100"],t["--persona-text"]=(C=t["--persona-semantic-colors-text"])!=null?C:t["--persona-palette-colors-gray-900"],t["--persona-text-muted"]=(w=t["--persona-semantic-colors-text-muted"])!=null?w:t["--persona-palette-colors-gray-500"],t["--persona-text-inverse"]=(E=t["--persona-semantic-colors-text-inverse"])!=null?E:t["--persona-palette-colors-gray-50"],t["--persona-border"]=(H=t["--persona-semantic-colors-border"])!=null?H:t["--persona-palette-colors-gray-200"],t["--persona-divider"]=(I=t["--persona-semantic-colors-divider"])!=null?I:t["--persona-palette-colors-gray-200"],t["--persona-muted"]=t["--persona-text-muted"],t["--persona-voice-recording-indicator"]=(L=t["--persona-components-voice-recording-indicator"])!=null?L:t["--persona-palette-colors-error-500"],t["--persona-voice-recording-bg"]=(O=t["--persona-components-voice-recording-background"])!=null?O:t["--persona-palette-colors-error-50"],t["--persona-voice-processing-icon"]=($=t["--persona-components-voice-processing-icon"])!=null?$:t["--persona-palette-colors-primary-500"],t["--persona-voice-speaking-icon"]=(te=t["--persona-components-voice-speaking-icon"])!=null?te:t["--persona-palette-colors-success-500"],t["--persona-approval-bg"]=(xe=t["--persona-components-approval-requested-background"])!=null?xe:t["--persona-palette-colors-warning-50"],t["--persona-approval-border"]=(Je=t["--persona-components-approval-requested-border"])!=null?Je:t["--persona-palette-colors-warning-200"],t["--persona-approval-text"]=(we=t["--persona-components-approval-requested-text"])!=null?we:t["--persona-palette-colors-gray-900"],t["--persona-approval-shadow"]=(De=t["--persona-components-approval-requested-shadow"])!=null?De:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-approval-approve-bg"]=(Ae=t["--persona-components-approval-approve-background"])!=null?Ae:t["--persona-palette-colors-success-500"],t["--persona-approval-deny-bg"]=(qe=t["--persona-components-approval-deny-background"])!=null?qe:t["--persona-palette-colors-error-500"],t["--persona-attachment-image-bg"]=(He=t["--persona-components-attachment-image-background"])!=null?He:t["--persona-palette-colors-gray-100"],t["--persona-attachment-image-border"]=(J=t["--persona-components-attachment-image-border"])!=null?J:t["--persona-palette-colors-gray-200"],t["--persona-font-family"]=(re=t["--persona-semantic-typography-fontFamily"])!=null?re:t["--persona-palette-typography-fontFamily-sans"],t["--persona-font-size"]=(Q=t["--persona-semantic-typography-fontSize"])!=null?Q:t["--persona-palette-typography-fontSize-base"],t["--persona-font-weight"]=(ge=t["--persona-semantic-typography-fontWeight"])!=null?ge:t["--persona-palette-typography-fontWeight-normal"],t["--persona-line-height"]=(Z=t["--persona-semantic-typography-lineHeight"])!=null?Z:t["--persona-palette-typography-lineHeight-normal"],t["--persona-input-font-family"]=t["--persona-font-family"],t["--persona-input-font-weight"]=t["--persona-font-weight"],t["--persona-radius-sm"]=(G=t["--persona-palette-radius-sm"])!=null?G:"0.125rem",t["--persona-radius-md"]=(pe=t["--persona-palette-radius-md"])!=null?pe:"0.375rem",t["--persona-radius-lg"]=(ke=t["--persona-palette-radius-lg"])!=null?ke:"0.5rem",t["--persona-radius-xl"]=(le=t["--persona-palette-radius-xl"])!=null?le:"0.75rem",t["--persona-radius-full"]=(ne=t["--persona-palette-radius-full"])!=null?ne:"9999px",t["--persona-launcher-radius"]=(Et=(de=t["--persona-components-launcher-borderRadius"])!=null?de:t["--persona-palette-radius-full"])!=null?Et:"9999px",t["--persona-launcher-bg"]=(wt=t["--persona-components-launcher-background"])!=null?wt:t["--persona-primary"],t["--persona-launcher-fg"]=(We=t["--persona-components-launcher-foreground"])!=null?We:t["--persona-text-inverse"],t["--persona-launcher-border"]=(he=t["--persona-components-launcher-border"])!=null?he:t["--persona-border"],t["--persona-button-primary-bg"]=(at=t["--persona-components-button-primary-background"])!=null?at:t["--persona-primary"],t["--persona-button-primary-fg"]=(Re=t["--persona-components-button-primary-foreground"])!=null?Re:t["--persona-text-inverse"],t["--persona-button-radius"]=(ue=(j=t["--persona-components-button-primary-borderRadius"])!=null?j:t["--persona-palette-radius-full"])!=null?ue:"9999px",t["--persona-panel-radius"]=(Rt=(nt=t["--persona-components-panel-borderRadius"])!=null?nt:t["--persona-radius-xl"])!=null?Rt:"0.75rem",t["--persona-panel-border"]=(ee=t["--persona-components-panel-border"])!=null?ee:`1px solid ${t["--persona-border"]}`,t["--persona-panel-shadow"]=(Fr=(Ge=t["--persona-components-panel-shadow"])!=null?Ge:t["--persona-palette-shadows-xl"])!=null?Fr:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",t["--persona-launcher-shadow"]=(Bt=t["--persona-components-launcher-shadow"])!=null?Bt:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",t["--persona-input-radius"]=(hr=(or=t["--persona-components-input-borderRadius"])!=null?or:t["--persona-radius-lg"])!=null?hr:"0.5rem",t["--persona-message-user-radius"]=(F=(sn=t["--persona-components-message-user-borderRadius"])!=null?sn:t["--persona-radius-lg"])!=null?F:"0.5rem",t["--persona-message-assistant-radius"]=(Ie=(fe=t["--persona-components-message-assistant-borderRadius"])!=null?fe:t["--persona-radius-lg"])!=null?Ie:"0.5rem",t["--persona-header-bg"]=(Xe=t["--persona-components-header-background"])!=null?Xe:t["--persona-surface"],t["--persona-header-border"]=(Fe=t["--persona-components-header-border"])!=null?Fe:t["--persona-divider"],t["--persona-header-icon-bg"]=(Ne=t["--persona-components-header-iconBackground"])!=null?Ne:t["--persona-primary"],t["--persona-header-icon-fg"]=(Ye=t["--persona-components-header-iconForeground"])!=null?Ye:t["--persona-text-inverse"],t["--persona-header-title-fg"]=(At=t["--persona-components-header-titleForeground"])!=null?At:t["--persona-primary"],t["--persona-header-subtitle-fg"]=(Xt=t["--persona-components-header-subtitleForeground"])!=null?Xt:t["--persona-text-muted"],t["--persona-header-action-icon-fg"]=(ar=t["--persona-components-header-actionIconForeground"])!=null?ar:t["--persona-muted"];let n=(K=r.components)==null?void 0:K.header;n!=null&&n.shadow&&(t["--persona-header-shadow"]=n.shadow),n!=null&&n.borderBottom&&(t["--persona-header-border-bottom"]=n.borderBottom);let o=(mt=r.components)==null?void 0:mt.introCard;t["--persona-intro-card-bg"]=(it=t["--persona-components-introCard-background"])!=null?it:t["--persona-surface"],t["--persona-intro-card-radius"]=(ye=t["--persona-components-introCard-borderRadius"])!=null?ye:"1rem",t["--persona-intro-card-padding"]=(ie=t["--persona-components-introCard-padding"])!=null?ie:"1.5rem",t["--persona-intro-card-shadow"]=(pr=(st=o==null?void 0:o.shadow)!=null?st:t["--persona-components-introCard-shadow"])!=null?pr:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-input-background"]=(pt=t["--persona-components-input-background"])!=null?pt:t["--persona-surface"],t["--persona-input-placeholder"]=(yr=t["--persona-components-input-placeholder"])!=null?yr:t["--persona-text-muted"],t["--persona-message-user-bg"]=(Rr=t["--persona-components-message-user-background"])!=null?Rr:t["--persona-accent"],t["--persona-message-user-text"]=(ut=t["--persona-components-message-user-text"])!=null?ut:t["--persona-text-inverse"],t["--persona-message-user-shadow"]=(Lt=t["--persona-components-message-user-shadow"])!=null?Lt:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-message-assistant-bg"]=(tt=t["--persona-components-message-assistant-background"])!=null?tt:t["--persona-surface"],t["--persona-message-assistant-text"]=(zt=t["--persona-components-message-assistant-text"])!=null?zt:t["--persona-text"],t["--persona-message-assistant-border"]=(vr=t["--persona-components-message-assistant-border"])!=null?vr:t["--persona-border"],t["--persona-message-assistant-shadow"]=(sr=t["--persona-components-message-assistant-shadow"])!=null?sr:"0 1px 2px 0 rgb(0 0 0 / 0.05)",t["--persona-scroll-to-bottom-bg"]=(Mr=(ur=t["--persona-components-scrollToBottom-background"])!=null?ur:t["--persona-button-primary-bg"])!=null?Mr:t["--persona-accent"],t["--persona-scroll-to-bottom-fg"]=(St=(un=t["--persona-components-scrollToBottom-foreground"])!=null?un:t["--persona-button-primary-fg"])!=null?St:t["--persona-text-inverse"],t["--persona-scroll-to-bottom-border"]=(qr=t["--persona-components-scrollToBottom-border"])!=null?qr:t["--persona-primary"],t["--persona-scroll-to-bottom-size"]=(xr=t["--persona-components-scrollToBottom-size"])!=null?xr:"40px",t["--persona-scroll-to-bottom-radius"]=(yt=(ln=(Mn=t["--persona-components-scrollToBottom-borderRadius"])!=null?Mn:t["--persona-button-radius"])!=null?ln:t["--persona-radius-full"])!=null?yt:"9999px",t["--persona-scroll-to-bottom-shadow"]=(kn=(Gn=t["--persona-components-scrollToBottom-shadow"])!=null?Gn:t["--persona-palette-shadows-sm"])!=null?kn:"0 1px 2px 0 rgb(0 0 0 / 0.05)",t["--persona-scroll-to-bottom-padding"]=(_e=t["--persona-components-scrollToBottom-padding"])!=null?_e:"0.5rem 0.875rem",t["--persona-scroll-to-bottom-gap"]=(R=t["--persona-components-scrollToBottom-gap"])!=null?R:"0.5rem",t["--persona-scroll-to-bottom-font-size"]=(Ee=(se=t["--persona-components-scrollToBottom-fontSize"])!=null?se:t["--persona-palette-typography-fontSize-sm"])!=null?Ee:"0.875rem",t["--persona-scroll-to-bottom-icon-size"]=(Ot=t["--persona-components-scrollToBottom-iconSize"])!=null?Ot:"14px",t["--persona-tool-bubble-shadow"]=(et=t["--persona-components-toolBubble-shadow"])!=null?et:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-reasoning-bubble-shadow"]=(Nt=t["--persona-components-reasoningBubble-shadow"])!=null?Nt:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-composer-shadow"]=(Yt=t["--persona-components-composer-shadow"])!=null?Yt:"none",t["--persona-md-inline-code-bg"]=(lr=t["--persona-components-markdown-inlineCode-background"])!=null?lr:t["--persona-container"],t["--persona-md-inline-code-color"]=(vt=t["--persona-components-markdown-inlineCode-foreground"])!=null?vt:t["--persona-text"],t["--persona-md-link-color"]=($t=(zr=t["--persona-components-markdown-link-foreground"])!=null?zr:t["--persona-accent"])!=null?$t:"#0f0f0f";let a=t["--persona-components-markdown-heading-h1-fontSize"];a&&(t["--persona-md-h1-size"]=a);let s=t["--persona-components-markdown-heading-h1-fontWeight"];s&&(t["--persona-md-h1-weight"]=s);let i=t["--persona-components-markdown-heading-h2-fontSize"];i&&(t["--persona-md-h2-size"]=i);let d=t["--persona-components-markdown-heading-h2-fontWeight"];d&&(t["--persona-md-h2-weight"]=d);let l=t["--persona-components-markdown-prose-fontFamily"];l&&l!=="inherit"&&(t["--persona-md-prose-font-family"]=l),t["--persona-md-code-block-bg"]=($r=t["--persona-components-markdown-codeBlock-background"])!=null?$r:t["--persona-container"],t["--persona-md-code-block-border-color"]=(Dn=t["--persona-components-markdown-codeBlock-borderColor"])!=null?Dn:t["--persona-border"],t["--persona-md-code-block-text-color"]=(oo=t["--persona-components-markdown-codeBlock-textColor"])!=null?oo:"inherit",t["--persona-md-table-header-bg"]=(Ao=t["--persona-components-markdown-table-headerBackground"])!=null?Ao:t["--persona-container"],t["--persona-md-table-border-color"]=(fn=t["--persona-components-markdown-table-borderColor"])!=null?fn:t["--persona-border"],t["--persona-md-hr-color"]=(Vt=t["--persona-components-markdown-hr-color"])!=null?Vt:t["--persona-divider"],t["--persona-md-blockquote-border-color"]=(Qr=t["--persona-components-markdown-blockquote-borderColor"])!=null?Qr:t["--persona-palette-colors-gray-900"],t["--persona-md-blockquote-bg"]=(En=t["--persona-components-markdown-blockquote-background"])!=null?En:"transparent",t["--persona-md-blockquote-text-color"]=(So=t["--persona-components-markdown-blockquote-textColor"])!=null?So:t["--persona-palette-colors-gray-500"],t["--cw-container"]=(ao=t["--persona-components-collapsibleWidget-container"])!=null?ao:t["--persona-surface"],t["--cw-surface"]=(To=t["--persona-components-collapsibleWidget-surface"])!=null?To:t["--persona-surface"],t["--cw-border"]=(Kn=t["--persona-components-collapsibleWidget-border"])!=null?Kn:t["--persona-border"],t["--persona-message-border"]=(mn=t["--persona-components-message-border"])!=null?mn:t["--persona-border"];let u=r.components,m=u==null?void 0:u.iconButton;m&&(m.background&&(t["--persona-icon-btn-bg"]=m.background),m.border&&(t["--persona-icon-btn-border"]=m.border),m.color&&(t["--persona-icon-btn-color"]=m.color),m.padding&&(t["--persona-icon-btn-padding"]=m.padding),m.borderRadius&&(t["--persona-icon-btn-radius"]=m.borderRadius),m.hoverBackground&&(t["--persona-icon-btn-hover-bg"]=m.hoverBackground),m.hoverColor&&(t["--persona-icon-btn-hover-color"]=m.hoverColor),m.activeBackground&&(t["--persona-icon-btn-active-bg"]=m.activeBackground),m.activeBorder&&(t["--persona-icon-btn-active-border"]=m.activeBorder));let p=u==null?void 0:u.labelButton;p&&(p.background&&(t["--persona-label-btn-bg"]=p.background),p.border&&(t["--persona-label-btn-border"]=p.border),p.color&&(t["--persona-label-btn-color"]=p.color),p.padding&&(t["--persona-label-btn-padding"]=p.padding),p.borderRadius&&(t["--persona-label-btn-radius"]=p.borderRadius),p.hoverBackground&&(t["--persona-label-btn-hover-bg"]=p.hoverBackground),p.fontSize&&(t["--persona-label-btn-font-size"]=p.fontSize),p.gap&&(t["--persona-label-btn-gap"]=p.gap));let f=u==null?void 0:u.toggleGroup;f&&(f.gap&&(t["--persona-toggle-group-gap"]=f.gap),f.borderRadius&&(t["--persona-toggle-group-radius"]=f.borderRadius));let b=u==null?void 0:u.artifact;if(b!=null&&b.toolbar){let ve=b.toolbar;ve.iconHoverColor&&(t["--persona-artifact-toolbar-icon-hover-color"]=ve.iconHoverColor),ve.iconHoverBackground&&(t["--persona-artifact-toolbar-icon-hover-bg"]=ve.iconHoverBackground),ve.iconPadding&&(t["--persona-artifact-toolbar-icon-padding"]=ve.iconPadding),ve.iconBorderRadius&&(t["--persona-artifact-toolbar-icon-radius"]=ve.iconBorderRadius),ve.iconBorder&&(t["--persona-artifact-toolbar-icon-border"]=ve.iconBorder),ve.toggleGroupGap&&(t["--persona-artifact-toolbar-toggle-group-gap"]=ve.toggleGroupGap),ve.toggleBorderRadius&&(t["--persona-artifact-toolbar-toggle-radius"]=ve.toggleBorderRadius),ve.copyBackground&&(t["--persona-artifact-toolbar-copy-bg"]=ve.copyBackground),ve.copyBorder&&(t["--persona-artifact-toolbar-copy-border"]=ve.copyBorder),ve.copyColor&&(t["--persona-artifact-toolbar-copy-color"]=ve.copyColor),ve.copyBorderRadius&&(t["--persona-artifact-toolbar-copy-radius"]=ve.copyBorderRadius),ve.copyPadding&&(t["--persona-artifact-toolbar-copy-padding"]=ve.copyPadding),ve.copyMenuBackground&&(t["--persona-artifact-toolbar-copy-menu-bg"]=ve.copyMenuBackground,t["--persona-dropdown-bg"]=(Fn=t["--persona-dropdown-bg"])!=null?Fn:ve.copyMenuBackground),ve.copyMenuBorder&&(t["--persona-artifact-toolbar-copy-menu-border"]=ve.copyMenuBorder,t["--persona-dropdown-border"]=(Tt=t["--persona-dropdown-border"])!=null?Tt:ve.copyMenuBorder),ve.copyMenuShadow&&(t["--persona-artifact-toolbar-copy-menu-shadow"]=ve.copyMenuShadow,t["--persona-dropdown-shadow"]=(Cr=t["--persona-dropdown-shadow"])!=null?Cr:ve.copyMenuShadow),ve.copyMenuBorderRadius&&(t["--persona-artifact-toolbar-copy-menu-radius"]=ve.copyMenuBorderRadius,t["--persona-dropdown-radius"]=(wr=t["--persona-dropdown-radius"])!=null?wr:ve.copyMenuBorderRadius),ve.copyMenuItemHoverBackground&&(t["--persona-artifact-toolbar-copy-menu-item-hover-bg"]=ve.copyMenuItemHoverBackground,t["--persona-dropdown-item-hover-bg"]=(gn=t["--persona-dropdown-item-hover-bg"])!=null?gn:ve.copyMenuItemHoverBackground),ve.iconBackground&&(t["--persona-artifact-toolbar-icon-bg"]=ve.iconBackground),ve.toolbarBorder&&(t["--persona-artifact-toolbar-border"]=ve.toolbarBorder)}if(b!=null&&b.tab){let ve=b.tab;ve.background&&(t["--persona-artifact-tab-bg"]=ve.background),ve.activeBackground&&(t["--persona-artifact-tab-active-bg"]=ve.activeBackground),ve.activeBorder&&(t["--persona-artifact-tab-active-border"]=ve.activeBorder),ve.borderRadius&&(t["--persona-artifact-tab-radius"]=ve.borderRadius),ve.textColor&&(t["--persona-artifact-tab-color"]=ve.textColor),ve.hoverBackground&&(t["--persona-artifact-tab-hover-bg"]=ve.hoverBackground),ve.listBackground&&(t["--persona-artifact-tab-list-bg"]=ve.listBackground),ve.listBorderColor&&(t["--persona-artifact-tab-list-border-color"]=ve.listBorderColor),ve.listPadding&&(t["--persona-artifact-tab-list-padding"]=ve.listPadding)}if(b!=null&&b.pane){let ve=b.pane;if(ve.toolbarBackground){let On=(Mo=Ga(r,ve.toolbarBackground))!=null?Mo:ve.toolbarBackground;t["--persona-artifact-toolbar-bg"]=On}}return t}var ux={header:"Widget header bar",messages:"Message list area","user-message":"User message bubble","assistant-message":"Assistant message bubble",composer:"Footer / composer area",container:"Main widget container","artifact-pane":"Artifact sidebar","artifact-toolbar":"Artifact toolbar"};var pv={colors:{primary:{50:"#ffffff",100:"#f5f5f5",200:"#d4d4d4",300:"#a3a3a3",400:"#737373",500:"#171717",600:"#0f0f0f",700:"#0a0a0a",800:"#050505",900:"#030303",950:"#000000"},secondary:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},accent:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},success:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},warning:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},error:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"}}},fx=r=>{if(!(!r||typeof r!="object"||Array.isArray(r)))return r},Xs=()=>{var r;return typeof document!="undefined"&&document.documentElement.classList.contains("dark")||typeof window!="undefined"&&((r=window.matchMedia)!=null&&r.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light"},uv=r=>{var t;let e=(t=r==null?void 0:r.colorScheme)!=null?t:"light";return e==="light"?"light":e==="dark"?"dark":Xs()},$p=r=>uv(r),fv=r=>Ka(r),mv=r=>{var t;let e=Ka(void 0,{validate:!1});return Ka({...r,palette:{...e.palette,colors:{...pv.colors,...(t=r==null?void 0:r.palette)==null?void 0:t.colors}}},{validate:!1})},Xa=r=>{let e=$p(r),t=fx(r==null?void 0:r.theme),n=fx(r==null?void 0:r.darkTheme);return e==="dark"?mv(Ks(t!=null?t:{},n!=null?n:{})):fv(t)},gv=r=>Sl(r),_o=(r,e)=>{let t=Xa(e),n=gv(t);for(let[o,a]of Object.entries(n))r.style.setProperty(o,a)},Tl=r=>{let e=[];if(typeof document!="undefined"&&typeof MutationObserver!="undefined"){let t=new MutationObserver(()=>{r(Xs())});t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),e.push(()=>t.disconnect())}if(typeof window!="undefined"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>r(Xs());t.addEventListener?(t.addEventListener("change",n),e.push(()=>t.removeEventListener("change",n))):t.addListener&&(t.addListener(n),e.push(()=>t.removeListener(n)))}return()=>{e.forEach(t=>t())}};var mx=(function(){"use strict";let r=()=>{},e={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:r,afterNodeAdded:r,beforeNodeMorphed:r,afterNodeMorphed:r,beforeNodeRemoved:r,afterNodeRemoved:r,beforeAttributeUpdated:r},head:{style:"merge",shouldPreserve:p=>p.getAttribute("im-preserve")==="true",shouldReAppend:p=>p.getAttribute("im-re-append")==="true",shouldRemove:r,afterHeadMorphed:r},restoreFocus:!0};function t(p,f,b={}){p=u(p);let h=m(f),S=l(p,h,b),T=o(S,()=>i(S,p,h,M=>M.morphStyle==="innerHTML"?(a(M,p,h),Array.from(p.childNodes)):n(M,p,h)));return S.pantry.remove(),T}function n(p,f,b){let h=m(f);return a(p,h,b,f,f.nextSibling),Array.from(h.childNodes)}function o(p,f){var k;if(!p.config.restoreFocus)return f();let b=document.activeElement;if(!(b instanceof HTMLInputElement||b instanceof HTMLTextAreaElement))return f();let{id:h,selectionStart:S,selectionEnd:T}=b,M=f();return h&&h!==((k=document.activeElement)==null?void 0:k.getAttribute("id"))&&(b=p.target.querySelector(`[id="${h}"]`),b==null||b.focus()),b&&!b.selectionEnd&&T&&b.setSelectionRange(S,T),M}let a=(function(){function p(x,C,w,E=null,H=null){C instanceof HTMLTemplateElement&&w instanceof HTMLTemplateElement&&(C=C.content,w=w.content),E||(E=C.firstChild);for(let I of w.childNodes){if(E&&E!=H){let O=b(x,I,E,H);if(O){O!==E&&S(x,E,O),s(O,I,x),E=O.nextSibling;continue}}if(I instanceof Element){let O=I.getAttribute("id");if(x.persistentIds.has(O)){let $=T(C,O,E,x);s($,I,x),E=$.nextSibling;continue}}let L=f(C,I,E,x);L&&(E=L.nextSibling)}for(;E&&E!=H;){let I=E;E=E.nextSibling,h(x,I)}}function f(x,C,w,E){if(E.callbacks.beforeNodeAdded(C)===!1)return null;if(E.idMap.has(C)){let H=document.createElement(C.tagName);return x.insertBefore(H,w),s(H,C,E),E.callbacks.afterNodeAdded(H),H}else{let H=document.importNode(C,!0);return x.insertBefore(H,w),E.callbacks.afterNodeAdded(H),H}}let b=(function(){function x(E,H,I,L){let O=null,$=H.nextSibling,te=0,xe=I;for(;xe&&xe!=L;){if(w(xe,H)){if(C(E,xe,H))return xe;O===null&&(E.idMap.has(xe)||(O=xe))}if(O===null&&$&&w(xe,$)&&(te++,$=$.nextSibling,te>=2&&(O=void 0)),E.activeElementAndParents.includes(xe))break;xe=xe.nextSibling}return O||null}function C(E,H,I){let L=E.idMap.get(H),O=E.idMap.get(I);if(!O||!L)return!1;for(let $ of L)if(O.has($))return!0;return!1}function w(E,H){var O,$,te;let I=E,L=H;return I.nodeType===L.nodeType&&I.tagName===L.tagName&&(!((O=I.getAttribute)!=null&&O.call(I,"id"))||(($=I.getAttribute)==null?void 0:$.call(I,"id"))===((te=L.getAttribute)==null?void 0:te.call(L,"id")))}return x})();function h(x,C){var w;if(x.idMap.has(C))k(x.pantry,C,null);else{if(x.callbacks.beforeNodeRemoved(C)===!1)return;(w=C.parentNode)==null||w.removeChild(C),x.callbacks.afterNodeRemoved(C)}}function S(x,C,w){let E=C;for(;E&&E!==w;){let H=E;E=E.nextSibling,h(x,H)}return E}function T(x,C,w,E){var I,L;let H=((L=(I=E.target).getAttribute)==null?void 0:L.call(I,"id"))===C&&E.target||E.target.querySelector(`[id="${C}"]`)||E.pantry.querySelector(`[id="${C}"]`);return M(H,E),k(x,H,w),H}function M(x,C){let w=x.getAttribute("id");for(;x=x.parentNode;){let E=C.idMap.get(x);E&&(E.delete(w),E.size||C.idMap.delete(x))}}function k(x,C,w){if(x.moveBefore)try{x.moveBefore(C,w)}catch{x.insertBefore(C,w)}else x.insertBefore(C,w)}return p})(),s=(function(){function p(M,k,x){return x.ignoreActive&&M===document.activeElement?null:(x.callbacks.beforeNodeMorphed(M,k)===!1||(M instanceof HTMLHeadElement&&x.head.ignore||(M instanceof HTMLHeadElement&&x.head.style!=="morph"?d(M,k,x):(f(M,k,x),T(M,x)||a(x,M,k))),x.callbacks.afterNodeMorphed(M,k)),M)}function f(M,k,x){let C=k.nodeType;if(C===1){let w=M,E=k,H=w.attributes,I=E.attributes;for(let L of I)S(L.name,w,"update",x)||w.getAttribute(L.name)!==L.value&&w.setAttribute(L.name,L.value);for(let L=H.length-1;0<=L;L--){let O=H[L];if(O&&!E.hasAttribute(O.name)){if(S(O.name,w,"remove",x))continue;w.removeAttribute(O.name)}}T(w,x)||b(w,E,x)}(C===8||C===3)&&M.nodeValue!==k.nodeValue&&(M.nodeValue=k.nodeValue)}function b(M,k,x){if(M instanceof HTMLInputElement&&k instanceof HTMLInputElement&&k.type!=="file"){let C=k.value,w=M.value;h(M,k,"checked",x),h(M,k,"disabled",x),k.hasAttribute("value")?w!==C&&(S("value",M,"update",x)||(M.setAttribute("value",C),M.value=C)):S("value",M,"remove",x)||(M.value="",M.removeAttribute("value"))}else if(M instanceof HTMLOptionElement&&k instanceof HTMLOptionElement)h(M,k,"selected",x);else if(M instanceof HTMLTextAreaElement&&k instanceof HTMLTextAreaElement){let C=k.value,w=M.value;if(S("value",M,"update",x))return;C!==w&&(M.value=C),M.firstChild&&M.firstChild.nodeValue!==C&&(M.firstChild.nodeValue=C)}}function h(M,k,x,C){let w=k[x],E=M[x];if(w!==E){let H=S(x,M,"update",C);H||(M[x]=k[x]),w?H||M.setAttribute(x,""):S(x,M,"remove",C)||M.removeAttribute(x)}}function S(M,k,x,C){return M==="value"&&C.ignoreActiveValue&&k===document.activeElement?!0:C.callbacks.beforeAttributeUpdated(M,k,x)===!1}function T(M,k){return!!k.ignoreActiveValue&&M===document.activeElement&&M!==document.body}return p})();function i(p,f,b,h){if(p.head.block){let S=f.querySelector("head"),T=b.querySelector("head");if(S&&T){let M=d(S,T,p);return Promise.all(M).then(()=>{let k=Object.assign(p,{head:{block:!1,ignore:!0}});return h(k)})}}return h(p)}function d(p,f,b){let h=[],S=[],T=[],M=[],k=new Map;for(let C of f.children)k.set(C.outerHTML,C);for(let C of p.children){let w=k.has(C.outerHTML),E=b.head.shouldReAppend(C),H=b.head.shouldPreserve(C);w||H?E?S.push(C):(k.delete(C.outerHTML),T.push(C)):b.head.style==="append"?E&&(S.push(C),M.push(C)):b.head.shouldRemove(C)!==!1&&S.push(C)}M.push(...k.values());let x=[];for(let C of M){let w=document.createRange().createContextualFragment(C.outerHTML).firstChild;if(b.callbacks.beforeNodeAdded(w)!==!1){if("href"in w&&w.href||"src"in w&&w.src){let E,H=new Promise(function(I){E=I});w.addEventListener("load",function(){E()}),x.push(H)}p.appendChild(w),b.callbacks.afterNodeAdded(w),h.push(w)}}for(let C of S)b.callbacks.beforeNodeRemoved(C)!==!1&&(p.removeChild(C),b.callbacks.afterNodeRemoved(C));return b.head.afterHeadMorphed(p,{added:h,kept:T,removed:S}),x}let l=(function(){function p(x,C,w){let{persistentIds:E,idMap:H}=M(x,C),I=f(w),L=I.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(L))throw`Do not understand how to morph style ${L}`;return{target:x,newContent:C,config:I,morphStyle:L,ignoreActive:I.ignoreActive,ignoreActiveValue:I.ignoreActiveValue,restoreFocus:I.restoreFocus,idMap:H,persistentIds:E,pantry:b(),activeElementAndParents:h(x),callbacks:I.callbacks,head:I.head}}function f(x){let C=Object.assign({},e);return Object.assign(C,x),C.callbacks=Object.assign({},e.callbacks,x.callbacks),C.head=Object.assign({},e.head,x.head),C}function b(){let x=document.createElement("div");return x.hidden=!0,document.body.insertAdjacentElement("afterend",x),x}function h(x){let C=[],w=document.activeElement;if((w==null?void 0:w.tagName)!=="BODY"&&x.contains(w))for(;w&&(C.push(w),w!==x);)w=w.parentElement;return C}function S(x){var w;let C=Array.from(x.querySelectorAll("[id]"));return(w=x.getAttribute)!=null&&w.call(x,"id")&&C.push(x),C}function T(x,C,w,E){for(let H of E){let I=H.getAttribute("id");if(C.has(I)){let L=H;for(;L;){let O=x.get(L);if(O==null&&(O=new Set,x.set(L,O)),O.add(I),L===w)break;L=L.parentElement}}}}function M(x,C){let w=S(x),E=S(C),H=k(w,E),I=new Map;T(I,H,x,w);let L=C.__idiomorphRoot||C;return T(I,H,L,E),{persistentIds:H,idMap:I}}function k(x,C){let w=new Set,E=new Map;for(let{id:I,tagName:L}of x)E.has(I)?w.add(I):E.set(I,L);let H=new Set;for(let{id:I,tagName:L}of C)H.has(I)?w.add(I):E.get(I)===L&&H.add(I);for(let I of w)H.delete(I);return H}return p})(),{normalizeElement:u,normalizeParent:m}=(function(){let p=new WeakSet;function f(T){return T instanceof Document?T.documentElement:T}function b(T){if(T==null)return document.createElement("div");if(typeof T=="string")return b(S(T));if(p.has(T))return T;if(T instanceof Node){if(T.parentNode)return new h(T);{let M=document.createElement("div");return M.append(T),M}}else{let M=document.createElement("div");for(let k of[...T])M.append(k);return M}}class h{constructor(M){this.originalNode=M,this.realParentNode=M.parentNode,this.previousSibling=M.previousSibling,this.nextSibling=M.nextSibling}get childNodes(){let M=[],k=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;k&&k!=this.nextSibling;)M.push(k),k=k.nextSibling;return M}querySelectorAll(M){return this.childNodes.reduce((k,x)=>{if(x instanceof Element){x.matches(M)&&k.push(x);let C=x.querySelectorAll(M);for(let w=0;w<C.length;w++)k.push(C[w])}return k},[])}insertBefore(M,k){return this.realParentNode.insertBefore(M,k)}moveBefore(M,k){return this.realParentNode.moveBefore(M,k)}get __idiomorphRoot(){return this.originalNode}}function S(T){let M=new DOMParser,k=T.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(k.match(/<\/html>/)||k.match(/<\/head>/)||k.match(/<\/body>/)){let x=M.parseFromString(T,"text/html");if(k.match(/<\/html>/))return p.add(x),x;{let C=x.firstChild;return C&&p.add(C),C}}else{let C=M.parseFromString("<body><template>"+T+"</template></body>","text/html").body.querySelector("template").content;return p.add(C),C}}return{normalizeElement:f,normalizeParent:b}})();return{morph:t,defaults:e}})();var Ml=(r,e,t={})=>{let{preserveTypingAnimation:n=!0}=t;mx.morph(r,e.innerHTML,{morphStyle:"innerHTML",callbacks:{beforeNodeMorphed(o,a){var s,i;if(o instanceof HTMLElement&&n){if(o.classList.contains("persona-animate-typing")||o.hasAttribute("data-preserve-runtime"))return!1;if(o.hasAttribute("data-preserve-animation")){if(a instanceof HTMLElement&&!a.hasAttribute("data-preserve-animation"))return;if(a instanceof HTMLElement&&a.hasAttribute("data-preserve-animation")){let d=(s=o.textContent)!=null?s:"",l=(i=a.textContent)!=null?i:"";if(d!==l)return}return!1}}}}})};var kl={index:-1,draft:""};function gx(r){let{direction:e,history:t,currentValue:n,atStart:o,state:a}=r,s=a.index!==-1;if(t.length===0)return{handled:!1,state:a};if(e==="up"){if(!s&&!o)return{handled:!1,state:a};if(!s){let i=t.length-1;return{handled:!0,value:t[i],state:{index:i,draft:n}}}if(a.index>0){let i=a.index-1;return{handled:!0,value:t[i],state:{index:i,draft:a.draft}}}return{handled:!0,state:a}}if(!s)return{handled:!1,state:a};if(a.index<t.length-1){let i=a.index+1;return{handled:!0,value:t[i],state:{index:i,draft:a.draft}}}return{handled:!0,value:a.draft,state:{...kl}}}function hx(r,e){var t,n,o,a,s,i,d,l,u,m,p,f,b,h,S,T,M,k,x,C,w,E,H,I,L,O,$,te,xe,Je,we,De,Ae,qe,He,J,re,Q;return[r.id,r.role,(n=(t=r.content)==null?void 0:t.length)!=null?n:0,(a=(o=r.content)==null?void 0:o.slice(-32))!=null?a:"",r.streaming?"1":"0",(s=r.variant)!=null?s:"",(d=(i=r.rawContent)==null?void 0:i.length)!=null?d:0,(u=(l=r.llmContent)==null?void 0:l.length)!=null?u:0,(p=(m=r.approval)==null?void 0:m.status)!=null?p:"",(b=(f=r.toolCall)==null?void 0:f.status)!=null?b:"",(S=(h=r.toolCall)==null?void 0:h.name)!=null?S:"",(k=(M=(T=r.toolCall)==null?void 0:T.chunks)==null?void 0:M.length)!=null?k:0,(E=(w=(C=(x=r.toolCall)==null?void 0:x.chunks)==null?void 0:C[r.toolCall.chunks.length-1])==null?void 0:w.slice(-32))!=null?E:"",typeof((H=r.toolCall)==null?void 0:H.args)=="string"?r.toolCall.args.length:(I=r.toolCall)!=null&&I.args?JSON.stringify(r.toolCall.args).length:0,($=(O=(L=r.reasoning)==null?void 0:L.chunks)==null?void 0:O.length)!=null?$:0,(we=(Je=(xe=(te=r.reasoning)==null?void 0:te.chunks)==null?void 0:xe[r.reasoning.chunks.length-1])==null?void 0:Je.length)!=null?we:0,(He=(qe=(Ae=(De=r.reasoning)==null?void 0:De.chunks)==null?void 0:Ae[r.reasoning.chunks.length-1])==null?void 0:qe.slice(-32))!=null?He:"",(re=(J=r.contentParts)==null?void 0:J.length)!=null?re:0,(Q=r.stopReason)!=null?Q:"",e].join("\0")}function xx(){return new Map}function bx(r,e,t){let n=r.get(e);return n&&n.fingerprint===t?n.wrapper:null}function yx(r,e,t,n){r.set(e,{fingerprint:t,wrapper:n})}function vx(r,e){for(let t of r.keys())e.has(t)||r.delete(t)}function El(r=!0){let e=r;return{isFollowing:()=>e,pause:()=>e?(e=!1,!0):!1,resume:()=>e?!1:(e=!0,!0)}}function vo(r){return Math.max(0,r.scrollHeight-r.clientHeight)}function xa(r,e){return vo(r)-r.scrollTop<=e}function Ll(r){let{following:e,currentScrollTop:t,lastScrollTop:n,nearBottom:o,userScrollThreshold:a,isAutoScrolling:s=!1,pauseOnUpwardScroll:i=!1,pauseWhenAwayFromBottom:d=!0,resumeRequiresDownwardScroll:l=!1}=r,u=t-n;return s||Math.abs(u)<a?{action:"none",delta:u,nextLastScrollTop:t}:!e&&o&&(!l||u>0)?{action:"resume",delta:u,nextLastScrollTop:t}:e&&i&&u<0?{action:"pause",delta:u,nextLastScrollTop:t}:e&&d&&!o?{action:"pause",delta:u,nextLastScrollTop:t}:{action:"none",delta:u,nextLastScrollTop:t}}function Pl(r){let{following:e,deltaY:t,nearBottom:n=!1,resumeWhenNearBottom:o=!1}=r;return e&&t<0?"pause":!e&&o&&t>0&&n?"resume":"none"}function Cx(r,e){return!r||r.isCollapsed?!1:e.contains(r.anchorNode)||e.contains(r.focusNode)}function wx(r){let e=Math.max(0,r.anchorOffsetTop-r.topOffset),t=Math.max(0,e+r.viewportHeight-r.contentHeight);return{targetScrollTop:e,spacerHeight:t}}function Ax(r){let e=Math.max(0,r.currentContentHeight-r.contentHeightAtAnchor);return Math.max(0,r.initialSpacerHeight-e)}var Kr={idle:"Online",connecting:"Connecting\u2026",connected:"Streaming\u2026",error:"Offline"},Xr=1e5,Uo=Xr+1;var Qs={type:"none",placeholder:"none",speed:120,duration:1800,buffer:"none"},hv=["pre","code","a","script","style"],Rl=r=>{var e,t,n,o,a;return{type:(e=r==null?void 0:r.type)!=null?e:Qs.type,placeholder:(t=r==null?void 0:r.placeholder)!=null?t:Qs.placeholder,speed:(n=r==null?void 0:r.speed)!=null?n:Qs.speed,duration:(o=r==null?void 0:r.duration)!=null?o:Qs.duration,buffer:(a=r==null?void 0:r.buffer)!=null?a:Qs.buffer}},Tx=[{name:"typewriter",containerClass:"persona-stream-typewriter",wrap:"char",useCaret:!0},{name:"pop-bubble",bubbleClass:"persona-stream-pop",wrap:"none"},{name:"letter-rise",containerClass:"persona-stream-letter-rise",wrap:"char"},{name:"word-fade",containerClass:"persona-stream-word-fade",wrap:"word"}],Js=new Map;for(let r of Tx)Js.set(r.name,r);var ba=r=>{Js.set(r.name,r)},Gp=r=>{Tx.some(e=>e.name===r)||Js.delete(r)},Kp=()=>Array.from(Js.keys()),Ys=(r,e)=>{var t,n;return r==="none"?null:e&&Object.prototype.hasOwnProperty.call(e,r)?(t=e[r])!=null?t:null:(n=Js.get(r))!=null?n:null},Il=(r,e,t,n,o)=>{if(!o)return r;if(t!=null&&t.bufferContent)return t.bufferContent(r,n);if(!r)return r;if(e==="word"){let a=r.search(/\s(?=\S*$)/);return a<0?"":r.slice(0,a)}if(e==="line"){let a=r.lastIndexOf(`
|
|
62
|
-
`);return a<0?"":r.slice(0,a)}return r},
|
|
62
|
+
_Details: ${t.message}_`:o}var Zs=r=>({isError:!0,content:[{type:"text",text:r}]}),mx=(r,e="WebMCP tool execution failed.")=>r instanceof Error&&r.message?r.message:typeof r=="string"&&r?r:e,gx=r=>ga(r)||r===en,Za=class r{constructor(e={},t){this.config=e;this.callbacks=t;this.status="idle";this.streaming=!1;this.abortController=null;this.sequenceCounter=Date.now();this.clientSession=null;this.agentExecution=null;this.artifacts=new Map;this.selectedArtifactId=null;this.webMcpInflightKeys=new Set;this.webMcpResolvedKeys=new Set;this.webMcpResolveControllers=new Set;this.webMcpEpoch=0;this.webMcpApprovalResolvers=new Map;this.webMcpApprovalSeq=0;this.webMcpAwaitBatches=new Map;this.voiceProvider=null;this.voiceActive=!1;this.voiceStatus="disconnected";this.pendingVoiceUserMessageId=null;this.pendingVoiceAssistantMessageId=null;this.ttsSpokenMessageIds=new Set;this.handleEvent=e=>{var t,o,n,a,s,i,d,l,u,f;if(e.type==="message"){this.upsertMessage(e.message);let p=e.message.toolCall,m=!!(p!=null&&p.name)&&(ga(p.name)||p.name===en&&((o=(t=this.config.features)==null?void 0:t.suggestReplies)==null?void 0:o.enabled)!==!1);((n=e.message.agentMetadata)==null?void 0:n.awaitingLocalTool)===!0&&m&&this.enqueueWebMcpAwait(e.message),(a=e.message.agentMetadata)!=null&&a.executionId&&(this.agentExecution?e.message.agentMetadata.iteration!==void 0&&(this.agentExecution.currentIteration=e.message.agentMetadata.iteration):this.agentExecution={executionId:e.message.agentMetadata.executionId,agentId:"",agentName:(s=e.message.agentMetadata.agentName)!=null?s:"",status:"running",currentIteration:(i=e.message.agentMetadata.iteration)!=null?i:0,maxTurns:0})}else if(e.type==="status"){if(this.setStatus(e.status),e.status==="connecting")this.setStreaming(!0);else if(e.status==="idle"||e.status==="error"){this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null);let p=this.webMcpAwaitBatches.size>0||this.webMcpResolveControllers.size>0;((d=this.agentExecution)==null?void 0:d.status)==="running"&&(e.status==="error"?this.agentExecution.status="error":p||(this.agentExecution.status="complete")),this.scheduleWebMcpBatchFlush()}}else e.type==="error"?(this.setStatus("error"),this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null),((l=this.agentExecution)==null?void 0:l.status)==="running"&&(this.agentExecution.status="error"),(f=(u=this.callbacks).onError)==null||f.call(u,e.error)):(e.type==="artifact_start"||e.type==="artifact_delta"||e.type==="artifact_update"||e.type==="artifact_complete")&&this.applyArtifactStreamEvent(e)};var o,n;this.messages=[...(o=e.initialMessages)!=null?o:[]].map(a=>{var s;return{...a,sequence:(s=a.sequence)!=null?s:this.nextSequence()}}),this.messages=this.sortMessages(this.messages),this.client=new ya(e),this.wireDefaultWebMcpConfirm();for(let a of(n=e.initialArtifacts)!=null?n:[])this.artifacts.set(a.id,{...a,status:"complete"});e.initialSelectedArtifactId!=null&&(this.selectedArtifactId=e.initialSelectedArtifactId),this.messages.length&&this.callbacks.onMessagesChanged([...this.messages]),this.artifacts.size>0&&this.emitArtifactsState(),this.callbacks.onStatusChanged(this.status)}setSSEEventCallback(e){this.client.setSSEEventCallback(e)}isClientTokenMode(){return this.client.isClientTokenMode()}isAgentMode(){return this.client.isAgentMode()}getAgentExecution(){return this.agentExecution}isAgentExecuting(){var e;return((e=this.agentExecution)==null?void 0:e.status)==="running"}isVoiceSupported(){var e;return Js((e=this.config.voiceRecognition)==null?void 0:e.provider)}isVoiceActive(){return this.voiceActive}getVoiceStatus(){return this.voiceStatus}getVoiceInterruptionMode(){var e;return(e=this.voiceProvider)!=null&&e.getInterruptionMode?this.voiceProvider.getInterruptionMode():"none"}stopVoicePlayback(){var e;(e=this.voiceProvider)!=null&&e.stopPlayback&&this.voiceProvider.stopPlayback()}isBargeInActive(){var e,t,o;return(o=(t=(e=this.voiceProvider)==null?void 0:e.isBargeInActive)==null?void 0:t.call(e))!=null?o:!1}async deactivateBargeIn(){var e;(e=this.voiceProvider)!=null&&e.deactivateBargeIn&&await this.voiceProvider.deactivateBargeIn()}setupVoice(e){var t,o,n;try{let a=e||this.getVoiceConfigFromConfig();if(!a)throw new Error("Voice configuration not provided");this.voiceProvider=Ca(a);let s=(t=this.config.voiceRecognition)!=null?t:{},i=(o=s.processingText)!=null?o:"\u{1F3A4} Processing voice...",d=(n=s.processingErrorText)!=null?n:"Voice processing failed. Please try again.";this.voiceProvider.onProcessingStart&&this.voiceProvider.onProcessingStart(()=>{let l=this.injectMessage({role:"user",content:i,streaming:!1,voiceProcessing:!0});this.pendingVoiceUserMessageId=l.id;let u=this.injectMessage({role:"assistant",content:"",streaming:!0,voiceProcessing:!0});this.pendingVoiceAssistantMessageId=u.id,this.setStreaming(!0)}),this.voiceProvider.onResult(l=>{var u,f,p,m,y,h;if(l.provider==="browser")l.text&&l.text.trim()&&this.sendMessage(l.text,{viaVoice:!0});else if(l.provider==="runtype"){this.pendingVoiceUserMessageId&&((u=l.transcript)!=null&&u.trim())?this.upsertMessage({id:this.pendingVoiceUserMessageId,role:"user",content:l.transcript.trim(),createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}):(f=l.transcript)!=null&&f.trim()&&this.injectUserMessage({content:l.transcript.trim()}),this.pendingVoiceAssistantMessageId&&((p=l.text)!=null&&p.trim())?this.upsertMessage({id:this.pendingVoiceAssistantMessageId,role:"assistant",content:l.text.trim(),createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}):(m=l.text)!=null&&m.trim()&&this.injectAssistantMessage({content:l.text.trim()});{let T=(h=this.pendingVoiceAssistantMessageId)!=null?h:(y=[...this.messages].reverse().find(M=>M.role==="assistant"))==null?void 0:y.id;T&&this.ttsSpokenMessageIds.add(T)}this.setStreaming(!1),this.pendingVoiceUserMessageId=null,this.pendingVoiceAssistantMessageId=null}}),this.voiceProvider.onError(l=>{console.error("Voice error:",l),this.pendingVoiceAssistantMessageId&&(this.upsertMessage({id:this.pendingVoiceAssistantMessageId,role:"assistant",content:d,createdAt:new Date().toISOString(),streaming:!1,voiceProcessing:!1}),this.setStreaming(!1),this.pendingVoiceUserMessageId=null,this.pendingVoiceAssistantMessageId=null)}),this.voiceProvider.onStatusChange(l=>{var u,f;this.voiceStatus=l,this.voiceActive=l==="listening",(f=(u=this.callbacks).onVoiceStatusChanged)==null||f.call(u,l)}),this.voiceProvider.connect()}catch(a){console.error("Failed to setup voice:",a)}}async toggleVoice(){if(!this.voiceProvider){console.error("Voice not configured");return}if(this.voiceActive)await this.voiceProvider.stopListening();else{this.stopSpeaking();try{await this.voiceProvider.startListening()}catch(e){console.error("Failed to start voice:",e)}}}cleanupVoice(){this.voiceProvider&&(this.voiceProvider.disconnect(),this.voiceProvider=null),this.voiceActive=!1,this.voiceStatus="disconnected"}getVoiceConfigFromConfig(){var t,o,n,a,s,i,d,l,u;if(!((t=this.config.voiceRecognition)!=null&&t.provider))return;let e=this.config.voiceRecognition.provider;switch(e.type){case"runtype":return{type:"runtype",runtype:{agentId:((o=e.runtype)==null?void 0:o.agentId)||"",clientToken:((n=e.runtype)==null?void 0:n.clientToken)||"",host:(a=e.runtype)==null?void 0:a.host,voiceId:(s=e.runtype)==null?void 0:s.voiceId,pauseDuration:(i=e.runtype)==null?void 0:i.pauseDuration,silenceThreshold:(d=e.runtype)==null?void 0:d.silenceThreshold}};case"browser":return{type:"browser",browser:{language:((l=e.browser)==null?void 0:l.language)||"en-US",continuous:(u=e.browser)==null?void 0:u.continuous}};default:return}}async initClientSession(){var e,t;if(!this.isClientTokenMode())return null;try{let o=await this.client.initSession();return this.setClientSession(o),o}catch(o){return(t=(e=this.callbacks).onError)==null||t.call(e,o instanceof Error?o:new Error(String(o))),null}}setClientSession(e){if(this.clientSession=e,e.config.welcomeMessage&&this.messages.length===0){let t={id:`welcome-${Date.now()}`,role:"assistant",content:e.config.welcomeMessage,createdAt:new Date().toISOString(),sequence:this.nextSequence()};this.appendMessage(t)}}getClientSession(){var e;return(e=this.clientSession)!=null?e:this.client.getClientSession()}isSessionValid(){let e=this.getClientSession();return e?new Date<e.expiresAt:!1}clearClientSession(){this.clientSession=null,this.client.clearClientSession()}getClient(){return this.client}async submitMessageFeedback(e,t){return this.client.submitMessageFeedback(e,t)}async submitCSATFeedback(e,t){return this.client.submitCSATFeedback(e,t)}async submitNPSFeedback(e,t){return this.client.submitNPSFeedback(e,t)}updateConfig(e){let t={...this.config,...e};if(!Sv(this.config,t)){this.config=t,this.client.updateConfig(t);return}this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear();let o=this.client.getSSEEventCallback();this.config=t,this.client=new ya(this.config),this.wireDefaultWebMcpConfirm(),o&&this.client.setSSEEventCallback(o)}getMessages(){return[...this.messages]}getStatus(){return this.status}isStreaming(){return this.streaming}injectTestEvent(e){this.handleEvent(e)}injectMessage(e){let{role:t,content:o,llmContent:n,contentParts:a,id:s,createdAt:i,sequence:d,streaming:l=!1,voiceProcessing:u,rawContent:f}=e,m={id:s!=null?s:t==="user"?Ja():t==="assistant"?ba():`system-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:t,content:o,createdAt:i!=null?i:new Date().toISOString(),sequence:d!=null?d:this.nextSequence(),streaming:l,...n!==void 0&&{llmContent:n},...a!==void 0&&{contentParts:a},...u!==void 0&&{voiceProcessing:u},...f!==void 0&&{rawContent:f}};return this.upsertMessage(m),m}injectAssistantMessage(e){return this.injectMessage({...e,role:"assistant"})}injectUserMessage(e){return this.injectMessage({...e,role:"user"})}injectSystemMessage(e){return this.injectMessage({...e,role:"system"})}injectMessageBatch(e){let t=[];for(let o of e){let{role:n,content:a,llmContent:s,contentParts:i,id:d,createdAt:l,sequence:u,streaming:f=!1,voiceProcessing:p,rawContent:m}=o,h={id:d!=null?d:n==="user"?Ja():n==="assistant"?ba():`system-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:n,content:a,createdAt:l!=null?l:new Date().toISOString(),sequence:u!=null?u:this.nextSequence(),streaming:f,...s!==void 0&&{llmContent:s},...i!==void 0&&{contentParts:i},...p!==void 0&&{voiceProcessing:p},...m!==void 0&&{rawContent:m}};t.push(h)}return this.messages=this.sortMessages([...this.messages,...t]),this.callbacks.onMessagesChanged([...this.messages]),t}injectComponentDirective(e){let{component:t,props:o={},text:n="",llmContent:a,id:s,createdAt:i,sequence:d}=e,l={text:n,component:t,props:o};return this.injectMessage({role:"assistant",content:n,rawContent:JSON.stringify(l),...a!==void 0&&{llmContent:a},...s!==void 0&&{id:s},...i!==void 0&&{createdAt:i},...d!==void 0&&{sequence:d}})}async sendMessage(e,t){var l,u,f,p,m;let o=e.trim();if(!o&&(!(t!=null&&t.contentParts)||t.contentParts.length===0))return;this.stopSpeaking(),(l=this.abortController)==null||l.abort(),this.abortWebMcpResolves();let n=Ja(),a=ba(),s={id:n,role:"user",content:o||ll,createdAt:new Date().toISOString(),sequence:this.nextSequence(),viaVoice:(t==null?void 0:t.viaVoice)||!1,...(t==null?void 0:t.contentParts)&&t.contentParts.length>0&&{contentParts:t.contentParts}};this.appendMessage(s),this.setStreaming(!0);let i=new AbortController;this.abortController=i;let d=[...this.messages];try{await this.client.dispatch({messages:d,signal:i.signal,assistantMessageId:a},this.handleEvent)}catch(y){let h=y instanceof Error&&(y.name==="AbortError"||y.message.includes("aborted")||y.message.includes("abort"));if(!h){let T=fx(y,this.config.errorMessage);if(T){let M={id:a,role:"assistant",createdAt:new Date().toISOString(),content:T,sequence:this.nextSequence()};this.appendMessage(M)}}this.setStatus("idle"),this.setStreaming(!1),this.abortController=null,h||(y instanceof Error?(f=(u=this.callbacks).onError)==null||f.call(u,y):(m=(p=this.callbacks).onError)==null||m.call(p,new Error(String(y))))}}async continueConversation(){var n,a,s,i,d;if(this.streaming)return;(n=this.abortController)==null||n.abort();let e=ba();this.setStreaming(!0);let t=new AbortController;this.abortController=t;let o=[...this.messages];try{await this.client.dispatch({messages:o,signal:t.signal,assistantMessageId:e},this.handleEvent)}catch(l){let u=l instanceof Error&&(l.name==="AbortError"||l.message.includes("aborted")||l.message.includes("abort"));if(!u){let f=fx(l,this.config.errorMessage);if(f){let p={id:e,role:"assistant",createdAt:new Date().toISOString(),content:f,sequence:this.nextSequence()};this.appendMessage(p)}}this.setStatus("idle"),this.setStreaming(!1),this.abortController=null,u||(l instanceof Error?(s=(a=this.callbacks).onError)==null||s.call(a,l):(d=(i=this.callbacks).onError)==null||d.call(i,new Error(String(l))))}}async connectStream(e,t){var n,a,s;if(this.streaming&&!(t!=null&&t.allowReentry))return;t!=null&&t.allowReentry||(n=this.abortController)==null||n.abort();let o=!1;for(let i of this.messages)i.streaming&&(i.streaming=!1,o=!0);o&&this.callbacks.onMessagesChanged([...this.messages]),this.setStreaming(!0);try{await this.client.processStream(e,this.handleEvent,t==null?void 0:t.assistantMessageId)}catch(i){this.setStatus("error"),this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null),(s=(a=this.callbacks).onError)==null||s.call(a,i instanceof Error?i:new Error(String(i)))}}wireDefaultWebMcpConfirm(){let e=this.config.webmcp;(e==null?void 0:e.enabled)===!0&&!e.onConfirm&&this.client.setWebMcpConfirmHandler(t=>this.requestWebMcpApproval(t))}requestWebMcpApproval(e){var n,a,s;try{if(((a=(n=this.config.webmcp)==null?void 0:n.autoApprove)==null?void 0:a.call(n,e))===!0)return Promise.resolve(!0)}catch{}let t={id:`webmcp-${++this.webMcpApprovalSeq}`,status:"pending",agentId:"",executionId:"",toolName:e.toolName,toolType:"webmcp",description:(s=e.description)!=null?s:`Allow the assistant to run ${e.toolName}?`,parameters:e.args},o=`approval-${t.id}`;return this.upsertMessage({id:o,role:"assistant",content:"",createdAt:new Date().toISOString(),streaming:!1,variant:"approval",approval:t}),new Promise(i=>{this.webMcpApprovalResolvers.set(o,i)})}resolveWebMcpApproval(e,t){let o=this.webMcpApprovalResolvers.get(e);if(!o)return;this.webMcpApprovalResolvers.delete(e);let n=this.messages.find(a=>a.id===e);n!=null&&n.approval&&this.upsertMessage({...n,approval:{...n.approval,status:t,resolvedAt:Date.now()}}),o(t==="approved")}async resolveApproval(e,t,o){var u,f,p,m,y;let n=`approval-${e.id}`,a={...e,status:t,resolvedAt:Date.now()},s=this.messages.find(h=>h.id===n),i={id:n,role:"assistant",content:"",createdAt:(u=s==null?void 0:s.createdAt)!=null?u:new Date().toISOString(),...(s==null?void 0:s.sequence)!==void 0?{sequence:s.sequence}:{},streaming:!1,variant:"approval",approval:a};this.upsertMessage(i),(f=this.abortController)==null||f.abort(),this.abortController=new AbortController,this.setStreaming(!0);let d=this.config.approval,l=d&&typeof d=="object"?d.onDecision:void 0;try{let h;if(l?h=await l({approvalId:e.id,executionId:e.executionId,agentId:e.agentId,toolName:e.toolName},t,o):h=await this.client.resolveApproval({agentId:e.agentId,executionId:e.executionId,approvalId:e.id},t),h){let T=null;if(h instanceof Response){if(!h.ok){let M=await h.json().catch(()=>null);throw new Error((p=M==null?void 0:M.error)!=null?p:`Approval request failed: ${h.status}`)}T=h.body}else h instanceof ReadableStream&&(T=h);T?await this.connectStream(T,{allowReentry:!0}):(t==="denied"&&this.appendMessage({id:`denial-${e.id}`,role:"assistant",content:"Tool execution was denied by user.",createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()}),this.setStreaming(!1),this.abortController=null)}else this.setStreaming(!1),this.abortController=null}catch(h){let T=h instanceof Error&&(h.name==="AbortError"||h.message.includes("aborted")||h.message.includes("abort"));this.setStreaming(!1),this.abortController=null,T||(y=(m=this.callbacks).onError)==null||y.call(m,h instanceof Error?h:new Error(String(h)))}}persistAskUserQuestionProgress(e,t){let o=this.messages.find(n=>n.id===e.id);o&&this.upsertMessage({...o,agentMetadata:{...o.agentMetadata,askUserQuestionAnswers:t.answers,askUserQuestionIndex:t.currentIndex}})}markAskUserQuestionResolved(e,t){let o=this.messages.find(n=>n.id===e.id);o&&this.upsertMessage({...o,agentMetadata:{...o.agentMetadata,awaitingLocalTool:!1,askUserQuestionAnswered:!0,...t?{askUserQuestionAnswers:t}:{}}})}async resolveAskUserQuestion(e,t){var u,f,p,m,y,h,T,M,k,L,x,w;let o=this.messages.find(v=>v.id===e.id);if(((u=o==null?void 0:o.agentMetadata)==null?void 0:u.askUserQuestionAnswered)===!0)return;let n=(f=e.agentMetadata)==null?void 0:f.executionId,a=(p=e.toolCall)==null?void 0:p.name;if(!n||!a){(y=(m=this.callbacks).onError)==null||y.call(m,new Error("resolveAskUserQuestion: message is missing executionId or toolCall.name"));return}let s=typeof t=="string"?void 0:t;if(s===void 0&&typeof t=="string"){let v=(h=e.toolCall)==null?void 0:h.args,E=Array.isArray(v==null?void 0:v.questions)?v.questions:[];if(E.length===1){let H=typeof((T=E[0])==null?void 0:T.question)=="string"?E[0].question:"";H&&(s={[H]:t})}}this.markAskUserQuestionResolved(e,s),(M=this.abortController)==null||M.abort(),this.abortController=new AbortController,this.setStreaming(!0);let i=e.toolCall.id,d=(k=e.toolCall)==null?void 0:k.args,l=Array.isArray(d==null?void 0:d.questions)?d.questions:[];if(l.length===0){let v=typeof t=="string"?t:Object.entries(t).map(([E,H])=>`${E}: ${Array.isArray(H)?H.join(", "):H}`).join(" | ");this.appendMessage({id:`ask-user-answer-${i}`,role:"user",content:v,createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()})}else{let v=s!=null?s:{};l.forEach((E,H)=>{let I=typeof(E==null?void 0:E.question)=="string"?E.question:"";if(!I)return;let P=v[I],z=Array.isArray(P)?P.join(", "):typeof P=="string"?P:"";this.appendMessage({id:`ask-user-q-${i}-${H}`,role:"assistant",content:I,createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()}),this.appendMessage({id:`ask-user-a-${i}-${H}`,role:"user",content:z||"*Skipped*",createdAt:new Date().toISOString(),streaming:!1,sequence:this.nextSequence()})})}try{let v=await this.client.resumeFlow(n,{[a]:t});if(!v.ok){let E=await v.json().catch(()=>null);throw new Error((L=E==null?void 0:E.error)!=null?L:`Resume failed: ${v.status}`)}v.body?await this.connectStream(v.body,{allowReentry:!0}):(this.setStreaming(!1),this.abortController=null)}catch(v){let E=v instanceof Error&&(v.name==="AbortError"||v.message.includes("aborted")||v.message.includes("abort"));this.setStreaming(!1),this.abortController=null,E||(w=(x=this.callbacks).onError)==null||w.call(x,v instanceof Error?v:new Error(String(v)))}}enqueueWebMcpAwait(e){var a,s;let t=(a=e.agentMetadata)==null?void 0:a.executionId,o=(s=e.toolCall)==null?void 0:s.id;if(!t||!o){let i=this.webMcpEpoch;queueMicrotask(()=>{i===this.webMcpEpoch&&this.resolveWebMcpToolCall(e)});return}let n=this.webMcpAwaitBatches.get(t);n||(n={snapshots:[],seen:new Set},this.webMcpAwaitBatches.set(t,n)),!n.seen.has(o)&&(n.seen.add(o),n.snapshots.push(e))}scheduleWebMcpBatchFlush(){if(this.webMcpAwaitBatches.size===0)return;let e=this.webMcpEpoch;queueMicrotask(()=>{if(e===this.webMcpEpoch)for(let t of[...this.webMcpAwaitBatches.keys()])this.flushWebMcpAwaitBatch(t)})}flushWebMcpAwaitBatch(e){let t=this.webMcpAwaitBatches.get(e);if(!t)return;this.webMcpAwaitBatches.delete(e);let{snapshots:o}=t;o.length===1?this.resolveWebMcpToolCall(o[0]):o.length>1&&this.resolveWebMcpToolCallBatch(e,o)}resolveWebMcpToolStartedAt(e){var n,a;let t=this.messages.find(s=>s.id===e.id),o=[(n=t==null?void 0:t.toolCall)==null?void 0:n.startedAt,(a=e.toolCall)==null?void 0:a.startedAt];for(let s of o)if(typeof s=="number"&&Number.isFinite(s))return s;return Date.now()}isSuggestRepliesAlreadyResolved(e){var o,n;if(((o=e.toolCall)==null?void 0:o.name)!==en)return!1;let t=this.messages.find(a=>a.id===e.id);return((n=(t!=null?t:e).agentMetadata)==null?void 0:n.suggestRepliesResolved)===!0}markWebMcpToolRunning(e){let t=this.resolveWebMcpToolStartedAt(e);return this.upsertMessage({...e,streaming:!0,agentMetadata:{...e.agentMetadata,awaitingLocalTool:!1},toolCall:e.toolCall?{...e.toolCall,status:"running",startedAt:t,completedAt:void 0,duration:void 0,durationMs:void 0}:e.toolCall}),t}markWebMcpToolComplete(e,t,o,n=Date.now(),a){this.messages.some(s=>s.id===e.id)&&this.upsertMessage({...e,streaming:!1,agentMetadata:{...e.agentMetadata,awaitingLocalTool:!1,...a},toolCall:e.toolCall?{...e.toolCall,status:"complete",result:t,startedAt:o,completedAt:n,duration:void 0,durationMs:Math.max(0,n-o)}:e.toolCall})}async resolveWebMcpToolCallBatch(e,t){var d,l,u,f;let o=[],n=[],a=new AbortController;this.webMcpResolveControllers.add(a),this.setStreaming(!0);let s=await Promise.all(t.map(async p=>{var w,v,E,H,I,P,z;let m=(w=p.toolCall)==null?void 0:w.name,y=(v=p.toolCall)==null?void 0:v.id;if(!m||!y)return null;let h=`${e}:${y}`;if(this.webMcpInflightKeys.has(h)||this.webMcpResolvedKeys.has(h)||this.isSuggestRepliesAlreadyResolved(p))return null;this.webMcpInflightKeys.add(h),o.push(h);let T=this.markWebMcpToolRunning(p),M=(H=(E=p.agentMetadata)==null?void 0:E.webMcpToolCallId)!=null?H:m;if(m===en)return{dedupeKey:h,resumeKey:M,output:Ud(),toolMessage:p,startedAt:T,completedAt:Date.now()};let k=new AbortController;this.webMcpResolveControllers.add(k),n.push(k);let L=this.client.executeWebMcpToolCall(m,(I=p.toolCall)==null?void 0:I.args,k.signal),x;if(!L)x={isError:!0,content:[{type:"text",text:"WebMCP not enabled on this widget."}]};else try{x=await L}catch(j){let ie=j instanceof Error&&(j.name==="AbortError"||j.message.includes("aborted")||j.message.includes("abort"));return ie||(z=(P=this.callbacks).onError)==null||z.call(P,j instanceof Error?j:new Error(String(j))),this.markWebMcpToolComplete(p,Zs(ie?"Aborted by cancel()":mx(j)),T),this.webMcpInflightKeys.delete(h),null}return k.signal.aborted?(this.markWebMcpToolComplete(p,Zs("Aborted by cancel()"),T),this.webMcpInflightKeys.delete(h),null):{dedupeKey:h,resumeKey:M,output:x,toolMessage:p,startedAt:T,completedAt:Date.now()}})),i=[];try{if(i=s.filter(y=>y!==null),i.length===0)return;let p={};for(let y of i)p[y.resumeKey]=y.output;let m=await this.client.resumeFlow(e,p,{signal:a.signal});if(!m.ok){let y=await m.json().catch(()=>null);throw new Error((d=y==null?void 0:y.error)!=null?d:`Resume failed: ${m.status}`)}for(let y of i)this.webMcpResolvedKeys.add(y.dedupeKey),this.markWebMcpToolComplete(y.toolMessage,y.output,y.startedAt,y.completedAt,((l=y.toolMessage.toolCall)==null?void 0:l.name)===en?{suggestRepliesResolved:!0}:void 0);m.body&&await this.connectStream(m.body,{allowReentry:!0})}catch(p){if(!(p instanceof Error&&(p.name==="AbortError"||p.message.includes("aborted")||p.message.includes("abort"))))(f=(u=this.callbacks).onError)==null||f.call(u,p instanceof Error?p:new Error(String(p)));else for(let y of i)this.markWebMcpToolComplete(y.toolMessage,Zs("Aborted by cancel()"),y.startedAt)}finally{for(let p of o)this.webMcpInflightKeys.delete(p);for(let p of n)this.webMcpResolveControllers.delete(p);this.webMcpResolveControllers.delete(a),this.webMcpResolveControllers.size===0&&!this.abortController&&this.setStreaming(!1)}}async resolveWebMcpToolCall(e){var y,h,T,M,k,L,x,w,v,E,H,I;let t=(y=e.agentMetadata)==null?void 0:y.executionId,o=(h=e.toolCall)==null?void 0:h.name,n=(T=e.toolCall)==null?void 0:T.id;if(!t){(k=(M=this.callbacks).onError)==null||k.call(M,new Error("WebMCP step_await missing executionId \u2014 dispatch left paused."));return}if(!o)return;if(!n){let P=`${t}:__no_tool_id__:${o}`;if(this.webMcpInflightKeys.has(P)||this.webMcpResolvedKeys.has(P))return;this.webMcpInflightKeys.add(P);try{await this.resumeWithToolOutput(t,o,{isError:!0,content:[{type:"text",text:"WebMCP step_await missing toolCall.id \u2014 cannot execute the page tool."}]}),this.webMcpResolvedKeys.add(P)}catch(z){(x=(L=this.callbacks).onError)==null||x.call(L,z instanceof Error?z:new Error(String(z)))}finally{this.webMcpInflightKeys.delete(P)}return}let a=`${t}:${n}`;if(this.webMcpInflightKeys.has(a)||this.webMcpResolvedKeys.has(a)||this.isSuggestRepliesAlreadyResolved(e))return;this.webMcpInflightKeys.add(a);let s=this.markWebMcpToolRunning(e),i=new AbortController;this.webMcpResolveControllers.add(i);let{signal:d}=i;this.setStreaming(!0);let l=o===en,u=(w=e.toolCall)==null?void 0:w.args,f=l?null:this.client.executeWebMcpToolCall(o,u,d),p="execute",m=s;try{let P;if(l?P=Ud():f?P=await f:P={isError:!0,content:[{type:"text",text:"WebMCP not enabled on this widget."}]},m=Date.now(),d.aborted){this.markWebMcpToolComplete(e,Zs("Aborted by cancel()"),s);return}let z=(E=(v=e.agentMetadata)==null?void 0:v.webMcpToolCallId)!=null?E:o;p="resume",await this.resumeWithToolOutput(t,z,P,{onHttpOk:()=>{this.webMcpResolvedKeys.add(a),this.markWebMcpToolComplete(e,P,s,m,l?{suggestRepliesResolved:!0}:void 0)},signal:d})}catch(P){let z=P instanceof Error&&(P.name==="AbortError"||P.message.includes("aborted")||P.message.includes("abort"));(p==="execute"||z||d.aborted)&&this.markWebMcpToolComplete(e,Zs(z||d.aborted?"Aborted by cancel()":mx(P)),s),z||(I=(H=this.callbacks).onError)==null||I.call(H,P instanceof Error?P:new Error(String(P)))}finally{this.webMcpInflightKeys.delete(a),this.webMcpResolveControllers.delete(i),this.webMcpResolveControllers.size===0&&!this.abortController&&this.setStreaming(!1)}}async resumeWithToolOutput(e,t,o,n){var s,i;let a=await this.client.resumeFlow(e,{[t]:o},{signal:n==null?void 0:n.signal});if(!a.ok){let d=await a.json().catch(()=>null);throw new Error((s=d==null?void 0:d.error)!=null?s:`Resume failed: ${a.status}`)}(i=n==null?void 0:n.onHttpOk)==null||i.call(n),a.body?await this.connectStream(a.body,{allowReentry:!0}):this.webMcpResolveControllers.size===0&&(this.setStreaming(!1),this.abortController=null)}abortWebMcpResolves(){for(let e of this.webMcpResolveControllers)e.abort();this.webMcpResolveControllers.clear();for(let e of[...this.webMcpApprovalResolvers.keys()])this.resolveWebMcpApproval(e,"denied");this.webMcpAwaitBatches.clear(),this.webMcpEpoch++}cancel(){var e;(e=this.abortController)==null||e.abort(),this.abortController=null,this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.stopSpeaking(),this.stopVoicePlayback(),this.setStreaming(!1),this.setStatus("idle")}clearMessages(){var e;this.stopSpeaking(),(e=this.abortController)==null||e.abort(),this.abortController=null,this.abortWebMcpResolves(),this.messages=[],this.agentExecution=null,this.clearArtifactState(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear(),this.client.resetClientToolsFingerprint(),this.setStreaming(!1),this.setStatus("idle"),this.callbacks.onMessagesChanged([...this.messages])}getArtifacts(){return[...this.artifacts.values()]}getArtifactById(e){return this.artifacts.get(e)}getSelectedArtifactId(){return this.selectedArtifactId}selectArtifact(e){this.selectedArtifactId=e,this.emitArtifactsState()}clearArtifacts(){this.clearArtifactState()}upsertArtifact(e){var n;let t=e.id||`art_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,9)}`;if(e.artifactType==="markdown"){let a={id:t,artifactType:"markdown",title:e.title,status:"complete",markdown:e.content};return this.artifacts.set(t,a),this.selectedArtifactId=t,this.emitArtifactsState(),a}let o={id:t,artifactType:"component",title:e.title,status:"complete",component:e.component,props:(n=e.props)!=null?n:{}};return this.artifacts.set(t,o),this.selectedArtifactId=t,this.emitArtifactsState(),o}clearArtifactState(){this.artifacts.size===0&&this.selectedArtifactId===null||(this.artifacts.clear(),this.selectedArtifactId=null,this.emitArtifactsState())}emitArtifactsState(){var e,t;(t=(e=this.callbacks).onArtifactsState)==null||t.call(e,{artifacts:[...this.artifacts.values()],selectedId:this.selectedArtifactId})}applyArtifactStreamEvent(e){var t,o;switch(e.type){case"artifact_start":{e.artifactType==="markdown"?this.artifacts.set(e.id,{id:e.id,artifactType:"markdown",title:e.title,status:"streaming",markdown:""}):this.artifacts.set(e.id,{id:e.id,artifactType:"component",title:e.title,status:"streaming",component:(t=e.component)!=null?t:"",props:{}}),this.selectedArtifactId=e.id;break}case"artifact_delta":{let n=this.artifacts.get(e.id);(n==null?void 0:n.artifactType)==="markdown"&&(n.markdown=((o=n.markdown)!=null?o:"")+e.artDelta);break}case"artifact_update":{let n=this.artifacts.get(e.id);(n==null?void 0:n.artifactType)==="component"&&(n.props={...n.props,...e.props},e.component&&(n.component=e.component));break}case"artifact_complete":{let n=this.artifacts.get(e.id);n&&(n.status="complete");break}default:return}this.emitArtifactsState()}hydrateMessages(e){var t;(t=this.abortController)==null||t.abort(),this.abortController=null,this.abortWebMcpResolves(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear(),this.messages=this.sortMessages(e.map(o=>{var n;return{...o,streaming:!1,sequence:(n=o.sequence)!=null?n:this.nextSequence()}})),this.setStreaming(!1),this.setStatus("idle"),this.callbacks.onMessagesChanged([...this.messages])}hydrateArtifacts(e,t=null){this.artifacts.clear();for(let o of e)this.artifacts.set(o.id,{...o,status:"complete"});this.selectedArtifactId=t,this.emitArtifactsState()}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.onStatusChanged(e))}setStreaming(e){if(this.streaming===e)return;let t=this.streaming;this.streaming=e,this.callbacks.onStreamingChanged(e),t&&!e&&this.speakLatestAssistantMessage()}speakLatestAssistantMessage(){let e=this.config.textToSpeech;if(!(e!=null&&e.enabled)||!(!e.provider||e.provider==="browser"||e.provider==="runtype"&&e.browserFallback))return;let o=[...this.messages].reverse().find(a=>a.role==="assistant"&&a.content&&!a.voiceProcessing);if(!o)return;if(this.ttsSpokenMessageIds.has(o.id)){this.ttsSpokenMessageIds.delete(o.id);return}let n=o.content;n.trim()&&this.speak(n,e)}speak(e,t){if(typeof window=="undefined"||!("speechSynthesis"in window))return;let o=window.speechSynthesis;o.cancel();let n=new SpeechSynthesisUtterance(e),a=o.getVoices();if(t.voice){let s=a.find(i=>i.name===t.voice);s&&(n.voice=s)}else a.length>0&&(n.voice=t.pickVoice?t.pickVoice(a):r.pickBestVoice(a));t.rate!==void 0&&(n.rate=t.rate),t.pitch!==void 0&&(n.pitch=t.pitch),setTimeout(()=>o.speak(n),50)}static pickBestVoice(e){var o;let t=["Microsoft Jenny Online (Natural) - English (United States)","Microsoft Aria Online (Natural) - English (United States)","Microsoft Guy Online (Natural) - English (United States)","Google US English","Google UK English Female","Ava (Premium)","Evan (Enhanced)","Samantha (Enhanced)","Samantha","Daniel","Karen","Microsoft David Desktop - English (United States)","Microsoft Zira Desktop - English (United States)"];for(let n of t){let a=e.find(s=>s.name===n);if(a)return a}return(o=e.find(n=>n.lang.startsWith("en")))!=null?o:e[0]}stopSpeaking(){typeof window!="undefined"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}appendMessage(e){let t=this.ensureSequence(e);this.messages=this.sortMessages([...this.messages,t]),this.callbacks.onMessagesChanged([...this.messages])}upsertMessage(e){let t=this.ensureSequence(e),o=this.messages.findIndex(n=>n.id===t.id);if(o===-1){this.appendMessage(t);return}this.messages=this.messages.map((n,a)=>{var u,f,p,m,y,h,T,M,k,L,x,w,v,E,H;if(a!==o)return n;let s={...n,...t};if(((u=n.agentMetadata)==null?void 0:u.askUserQuestionAnswered)===!0&&t.agentMetadata&&(s.agentMetadata={...t.agentMetadata,askUserQuestionAnswered:!0,...n.agentMetadata.askUserQuestionAnswers?{askUserQuestionAnswers:n.agentMetadata.askUserQuestionAnswers}:{},awaitingLocalTool:!1}),((f=n.agentMetadata)==null?void 0:f.suggestRepliesResolved)===!0&&t.agentMetadata&&(s.agentMetadata={...(p=s.agentMetadata)!=null?p:t.agentMetadata,suggestRepliesResolved:!0,awaitingLocalTool:!1}),n.approval&&t.approval&&n.approval.id===t.approval.id){let I=n.approval,P=t.approval;s.approval={...I,...P,executionId:P.executionId||I.executionId,toolName:P.toolName||I.toolName,description:P.description||I.description,toolType:(m=P.toolType)!=null?m:I.toolType,reason:(y=P.reason)!=null?y:I.reason,parameters:(h=P.parameters)!=null?h:I.parameters}}let i=(T=t.toolCall)==null?void 0:T.name,d=(M=t.agentMetadata)==null?void 0:M.executionId,l=(k=t.toolCall)==null?void 0:k.id;if(i&&gx(i)&&d&&l&&((L=t.agentMetadata)==null?void 0:L.awaitingLocalTool)===!0){let I=`${d}:${l}`,P=this.webMcpInflightKeys.has(I),z=this.webMcpResolvedKeys.has(I),j=(x=n.toolCall)==null?void 0:x.name,ie=((w=n.agentMetadata)==null?void 0:w.executionId)===d&&((v=n.toolCall)==null?void 0:v.id)===l&&j!==void 0&&gx(j)&&((E=n.toolCall)==null?void 0:E.status)==="complete";(P||z||ie)&&(s.agentMetadata={...(H=s.agentMetadata)!=null?H:{},awaitingLocalTool:!1},s.toolCall=n.toolCall,s.streaming=n.streaming)}return s}),this.messages=this.sortMessages(this.messages),this.callbacks.onMessagesChanged([...this.messages])}ensureSequence(e){return e.sequence!==void 0?{...e}:{...e,sequence:this.nextSequence()}}nextSequence(){return this.sequenceCounter++}sortMessages(e){return[...e].sort((t,o)=>{var d,l;let n=new Date(t.createdAt).getTime(),a=new Date(o.createdAt).getTime();if(!Number.isNaN(n)&&!Number.isNaN(a)&&n!==a)return n-a;let s=(d=t.sequence)!=null?d:0,i=(l=o.sequence)!=null?l:0;return s!==i?s-i:t.id.localeCompare(o.id)})}};var Gd=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];var Kd=[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]];var Xd=[["path",{d:"m12 19-7-7 7-7"}],["path",{d:"M19 12H5"}]];var Qd=[["path",{d:"M5 12h14"}],["path",{d:"m12 5 7 7-7 7"}]];var Yd=[["path",{d:"M7 7h10v10"}],["path",{d:"M7 17 17 7"}]];var Jd=[["path",{d:"m5 12 7-7 7 7"}],["path",{d:"M12 19V5"}]];var Zd=[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"}]];var ec=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M4.929 4.929 19.07 19.071"}]];var tc=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];var rc=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z"}]];var oc=[["path",{d:"M12 8V4H8"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}],["path",{d:"M2 14h2"}],["path",{d:"M20 14h2"}],["path",{d:"M15 13v2"}],["path",{d:"M9 13v2"}]];var nc=[["path",{d:"M12 10h.01"}],["path",{d:"M12 14h.01"}],["path",{d:"M12 6h.01"}],["path",{d:"M16 10h.01"}],["path",{d:"M16 14h.01"}],["path",{d:"M16 6h.01"}],["path",{d:"M8 10h.01"}],["path",{d:"M8 14h.01"}],["path",{d:"M8 6h.01"}],["path",{d:"M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2"}]];var ac=[["path",{d:"M8 2v4"}],["path",{d:"M16 2v4"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}],["path",{d:"M3 10h18"}],["path",{d:"M8 14h.01"}],["path",{d:"M12 14h.01"}],["path",{d:"M16 14h.01"}],["path",{d:"M8 18h.01"}],["path",{d:"M12 18h.01"}],["path",{d:"M16 18h.01"}]];var sc=[["path",{d:"M8 2v4"}],["path",{d:"M16 2v4"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}],["path",{d:"M3 10h18"}]];var ic=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z"}],["circle",{cx:"12",cy:"13",r:"3"}]];var lc=[["path",{d:"M20 6 9 17l-5-5"}]];var dc=[["path",{d:"m6 9 6 6 6-6"}]];var cc=[["path",{d:"m15 18-6-6 6-6"}]];var pc=[["path",{d:"m9 18 6-6-6-6"}]];var uc=[["path",{d:"m18 15-6-6-6 6"}]];var fl=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m9 12 2 2 4-4"}]];var ml=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m15 9-6 6"}],["path",{d:"m9 9 6 6"}]];var fc=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var mc=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}]];var gc=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];var hc=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]];var xc=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10"}]];var yc=[["line",{x1:"12",x2:"12",y1:"2",y2:"22"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"}]];var bc=[["path",{d:"M12 15V3"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}],["path",{d:"m7 10 5 5 5-5"}]];var gl=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"12",cy:"5",r:"1"}],["circle",{cx:"12",cy:"19",r:"1"}]];var hl=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"19",cy:"12",r:"1"}],["circle",{cx:"5",cy:"12",r:"1"}]];var vc=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}],["path",{d:"m2 2 20 20"}]];var Cc=[["path",{d:"M15 3h6v6"}],["path",{d:"M10 14 21 3"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}]];var wc=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}],["circle",{cx:"12",cy:"12",r:"3"}]];var Ac=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 12.5 8 15l2 2.5"}],["path",{d:"m14 12.5 2 2.5-2 2.5"}]];var Sc=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M8 13h2"}],["path",{d:"M14 13h2"}],["path",{d:"M8 17h2"}],["path",{d:"M14 17h2"}]];var Tc=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];var Mc=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}]];var kc=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1"}]];var Ec=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M7 3v18"}],["path",{d:"M3 7.5h4"}],["path",{d:"M3 12h18"}],["path",{d:"M3 16.5h4"}],["path",{d:"M17 3v18"}],["path",{d:"M17 7.5h4"}],["path",{d:"M17 16.5h4"}]];var Lc=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528"}]];var Pc=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}]];var Rc=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"}]];var xl=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"}]];var Ic=[["path",{d:"M12 7v14"}],["path",{d:"M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8"}],["path",{d:"M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5"}],["rect",{x:"3",y:"7",width:"18",height:"4",rx:"1"}]];var Hc=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}],["path",{d:"M2 12h20"}]];var Wc=[["line",{x1:"4",x2:"20",y1:"9",y2:"9"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21"}]];var Bc=[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"}]];var Dc=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"}]];var Oc=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}],["path",{d:"M3 3v5h5"}],["path",{d:"M12 7v5l4 2"}]];var yl=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}]];var _c=[["path",{d:"M16 5h6"}],["path",{d:"M19 2v6"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}],["circle",{cx:"9",cy:"9",r:"2"}]];var Nc=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}],["circle",{cx:"9",cy:"9",r:"2"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}]];var Fc=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 16v-4"}],["path",{d:"M12 8h.01"}]];var Uc=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4"}],["path",{d:"m21 2-9.6 9.6"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5"}]];var qc=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}]];var bl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56"}]];var zc=[["path",{d:"M12 2v4"}],["path",{d:"m16.2 7.8 2.9-2.9"}],["path",{d:"M18 12h4"}],["path",{d:"m16.2 16.2 2.9 2.9"}],["path",{d:"M12 18v4"}],["path",{d:"m4.9 19.1 2.9-2.9"}],["path",{d:"M2 12h4"}],["path",{d:"m4.9 4.9 2.9 2.9"}]];var $c=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]];var Vc=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}]];var jc=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"}],["circle",{cx:"12",cy:"10",r:"3"}]];var Gc=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"}]];var Kc=[["path",{d:"M4 5h16"}],["path",{d:"M4 12h16"}],["path",{d:"M4 19h16"}]];var Xc=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"}]];var Qc=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"}]];var Yc=[["path",{d:"M12 19v3"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"}]];var Jc=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"}]];var Zc=[["path",{d:"M5 12h14"}]];var ep=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21"}]];var tp=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"}]];var rp=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z"}],["path",{d:"M12 22V12"}],["polyline",{points:"3.29 7 12 12 20.71 7"}],["path",{d:"m7.5 4.27 9 5.15"}]];var op=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"}]];var np=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1"}]];var ap=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}],["path",{d:"m15 5 4 4"}]];var sp=[["line",{x1:"19",x2:"5",y1:"5",y2:"19"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5"}]];var ip=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384"}]];var lp=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]];var dp=[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]];var cp=[["path",{d:"M12 17V7"}],["path",{d:"M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8"}],["path",{d:"M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z"}]];var pp=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}],["path",{d:"M8 16H3v5"}]];var up=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}]];var fp=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7"}]];var mp=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var gp=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"}],["path",{d:"m21.854 2.147-10.94 10.939"}]];var hp=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];var xp=[["path",{d:"M12 2v13"}],["path",{d:"m16 6-4-4-4 4"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"}]];var yp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"M12 8v4"}],["path",{d:"M12 16h.01"}]];var bp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m9 12 2 2 4-4"}]];var vl=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m14.5 9.5-5 5"}],["path",{d:"m9.5 9.5 5 5"}]];var vp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}]];var Cp=[["path",{d:"M16 10a4 4 0 0 1-8 0"}],["path",{d:"M3.103 6.034h17.794"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z"}]];var wp=[["circle",{cx:"8",cy:"21",r:"1"}],["circle",{cx:"19",cy:"21",r:"1"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"}]];var Ap=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2"}],["path",{d:"M12 18h.01"}]];var Cl=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"}],["path",{d:"M20 2v4"}],["path",{d:"M22 4h-4"}],["circle",{cx:"4",cy:"20",r:"2"}]];var Sp=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];var Tp=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"}]];var Mp=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05"}]];var kp=[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M12 2v2"}],["path",{d:"M12 20v2"}],["path",{d:"m4.93 4.93 1.41 1.41"}],["path",{d:"m17.66 17.66 1.41 1.41"}],["path",{d:"M2 12h2"}],["path",{d:"M20 12h2"}],["path",{d:"m6.34 17.66-1.41 1.41"}],["path",{d:"m19.07 4.93-1.41 1.41"}]];var Ep=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor"}]];var Lp=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"}],["path",{d:"M17 14V2"}]];var Pp=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"}],["path",{d:"M7 10v12"}]];var Rp=[["line",{x1:"10",x2:"14",y1:"2",y2:"2"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11"}],["circle",{cx:"12",cy:"14",r:"8"}]];var Ip=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var Hp=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var wl=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}],["path",{d:"M12 9v4"}],["path",{d:"M12 17h.01"}]];var Wp=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2"}],["path",{d:"M15 18H9"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14"}],["circle",{cx:"17",cy:"18",r:"2"}],["circle",{cx:"7",cy:"18",r:"2"}]];var Bp=[["path",{d:"M12 3v12"}],["path",{d:"m17 8-5-5-5 5"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}]];var Dp=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}],["circle",{cx:"12",cy:"7",r:"4"}]];var Op=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"}],["path",{d:"M16 9a5 5 0 0 1 0 6"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728"}]];var _p=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15"}]];var Np=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"}]];var Fp=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var Up=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];var Tv={activity:Gd,"arrow-down":Kd,"arrow-up":Jd,"arrow-up-right":Yd,bot:oc,"chevron-down":dc,"chevron-up":uc,"chevron-right":pc,"chevron-left":cc,check:lc,clipboard:mc,"clipboard-copy":fc,copy:hc,file:Mc,"file-code":Ac,"file-spreadsheet":Sc,"file-text":Tc,"image-plus":_c,loader:zc,"loader-circle":bl,mic:Yc,paperclip:op,"refresh-cw":pp,search:mp,send:gp,"shield-alert":yp,"shield-check":bp,"shield-x":vl,square:Sp,"thumbs-down":Lp,"thumbs-up":Pp,upload:Bp,"volume-2":Op,x:Fp,user:Dp,mail:Vc,phone:ip,calendar:sc,clock:gc,building:nc,"map-pin":jc,lock:$c,key:Uc,"credit-card":xc,"at-sign":Zd,hash:Wc,globe:Hc,link:qc,"circle-check":fl,"circle-x":ml,"triangle-alert":wl,info:Fc,ban:ec,shield:vp,"arrow-left":Xd,"arrow-right":Qd,"external-link":Cc,ellipsis:hl,"ellipsis-vertical":gl,menu:Kc,house:yl,plus:dp,minus:Zc,pencil:ap,trash:Hp,"trash-2":Ip,save:fp,download:bc,share:xp,funnel:xl,settings:hp,"rotate-cw":up,maximize:Gc,minimize:Jc,"shopping-cart":wp,"shopping-bag":Cp,package:rp,truck:Wp,tag:Ep,gift:Ic,receipt:cp,wallet:Np,store:Mp,"dollar-sign":yc,percent:sp,play:lp,pause:np,"volume-x":_p,camera:ic,image:Nc,film:Ec,headphones:Bc,"message-circle":Xc,"message-square":Qc,bell:tc,heart:Dc,star:Tp,eye:wc,"eye-off":vc,bookmark:rc,"calendar-days":ac,history:Oc,timer:Rp,folder:Rc,"folder-open":Pc,files:kc,sparkles:Cl,zap:Up,sun:kp,moon:tp,flag:Lc,monitor:ep,smartphone:Ap},Ee=(r,e=24,t="currentColor",o=2)=>{let n=Tv[r];return n?Mv(n,e,t,o):(console.warn(`Lucide icon "${r}" is not in the Persona registry. Add it to packages/widget/src/utils/icons.ts (see docs/icon-registry-shortlist.md).`),null)};function Mv(r,e,t,o){if(!Array.isArray(r))return null;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("width",String(e)),n.setAttribute("height",String(e)),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("fill","none"),n.setAttribute("stroke",t),n.setAttribute("stroke-width",String(o)),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),r.forEach(a=>{if(!Array.isArray(a)||a.length<2)return;let s=a[0],i=a[1];if(!i)return;let d=document.createElementNS("http://www.w3.org/2000/svg",s);Object.entries(i).forEach(([l,u])=>{l!=="stroke"&&d.setAttribute(l,String(u))}),n.appendChild(d)}),n}var Al={allowedTypes:Tn,maxFileSize:10*1024*1024,maxFiles:4};function kv(){return`attach_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function Ev(r){return r==="application/pdf"||r.startsWith("text/")||r.includes("word")?"file-text":r.includes("excel")||r.includes("spreadsheet")?"file-spreadsheet":r==="application/json"?"file-code":"file"}var wa=class r{constructor(e={}){this.attachments=[];this.previewsContainer=null;var t,o,n;this.config={allowedTypes:(t=e.allowedTypes)!=null?t:Al.allowedTypes,maxFileSize:(o=e.maxFileSize)!=null?o:Al.maxFileSize,maxFiles:(n=e.maxFiles)!=null?n:Al.maxFiles,onFileRejected:e.onFileRejected,onAttachmentsChange:e.onAttachmentsChange}}setPreviewsContainer(e){this.previewsContainer=e}updateConfig(e){e.allowedTypes!==void 0&&(this.config.allowedTypes=e.allowedTypes.length>0?e.allowedTypes:Al.allowedTypes),e.maxFileSize!==void 0&&(this.config.maxFileSize=e.maxFileSize),e.maxFiles!==void 0&&(this.config.maxFiles=e.maxFiles),e.onFileRejected!==void 0&&(this.config.onFileRejected=e.onFileRejected),e.onAttachmentsChange!==void 0&&(this.config.onAttachmentsChange=e.onAttachmentsChange)}getAttachments(){return[...this.attachments]}getContentParts(){return this.attachments.map(e=>e.contentPart)}hasAttachments(){return this.attachments.length>0}count(){return this.attachments.length}async handleFileSelect(e){!e||e.length===0||await this.handleFiles(Array.from(e))}async handleFiles(e){var t,o,n,a,s,i,d;if(e.length){for(let l of e){if(this.attachments.length>=this.config.maxFiles){(o=(t=this.config).onFileRejected)==null||o.call(t,l,"count");continue}let u=px(l,this.config.allowedTypes,this.config.maxFileSize);if(!u.valid){let f=(n=u.error)!=null&&n.includes("type")?"type":"size";(s=(a=this.config).onFileRejected)==null||s.call(a,l,f);continue}try{let f=await cx(l),p=dl(l)?URL.createObjectURL(l):null,m={id:kv(),file:l,previewUrl:p,contentPart:f};this.attachments.push(m),this.renderPreview(m)}catch(f){console.error("[AttachmentManager] Failed to process file:",f)}}this.updatePreviewsVisibility(),(d=(i=this.config).onAttachmentsChange)==null||d.call(i,this.getAttachments())}}removeAttachment(e){var a,s,i;let t=this.attachments.findIndex(d=>d.id===e);if(t===-1)return;let o=this.attachments[t];o.previewUrl&&URL.revokeObjectURL(o.previewUrl),this.attachments.splice(t,1);let n=(a=this.previewsContainer)==null?void 0:a.querySelector(`[data-attachment-id="${e}"]`);n&&n.remove(),this.updatePreviewsVisibility(),(i=(s=this.config).onAttachmentsChange)==null||i.call(s,this.getAttachments())}clearAttachments(){var e,t;for(let o of this.attachments)o.previewUrl&&URL.revokeObjectURL(o.previewUrl);this.attachments=[],this.previewsContainer&&(this.previewsContainer.innerHTML=""),this.updatePreviewsVisibility(),(t=(e=this.config).onAttachmentsChange)==null||t.call(e,this.getAttachments())}renderPreview(e){if(!this.previewsContainer)return;let t=dl(e.file),o=C("div","persona-attachment-preview persona-relative persona-inline-block");if(o.setAttribute("data-attachment-id",e.id),o.style.width="48px",o.style.height="48px",t&&e.previewUrl){let s=C("img");s.src=e.previewUrl,s.alt=e.file.name,s.className="persona-w-full persona-h-full persona-object-cover persona-rounded-lg persona-border persona-border-gray-200",s.style.width="48px",s.style.height="48px",s.style.objectFit="cover",s.style.borderRadius="8px",o.appendChild(s)}else{let s=C("div");s.style.width="48px",s.style.height="48px",s.style.borderRadius="8px",s.style.backgroundColor="var(--persona-container, #f3f4f6)",s.style.border="1px solid var(--persona-border, #e5e7eb)",s.style.display="flex",s.style.flexDirection="column",s.style.alignItems="center",s.style.justifyContent="center",s.style.gap="2px",s.style.overflow="hidden";let i=Ev(e.file.type),d=Ee(i,20,"var(--persona-muted, #6b7280)",1.5);d&&s.appendChild(d);let l=C("span");l.textContent=ux(e.file.type,e.file.name),l.style.fontSize="8px",l.style.fontWeight="600",l.style.color="var(--persona-muted, #6b7280)",l.style.textTransform="uppercase",l.style.lineHeight="1",s.appendChild(l),o.appendChild(s)}let n=C("button","persona-attachment-remove persona-absolute persona-flex persona-items-center persona-justify-center");n.type="button",n.setAttribute("aria-label","Remove attachment"),n.style.position="absolute",n.style.top="-4px",n.style.right="-4px",n.style.width="18px",n.style.height="18px",n.style.borderRadius="50%",n.style.backgroundColor="var(--persona-palette-colors-black-alpha-60, rgba(0, 0, 0, 0.6))",n.style.border="none",n.style.cursor="pointer",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.padding="0";let a=Ee("x",10,"var(--persona-text-inverse, #ffffff)",2);a?n.appendChild(a):(n.textContent="\xD7",n.style.color="var(--persona-text-inverse, #ffffff)",n.style.fontSize="14px",n.style.lineHeight="1"),n.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.removeAttachment(e.id)}),o.appendChild(n),this.previewsContainer.appendChild(o)}updatePreviewsVisibility(){this.previewsContainer&&(this.previewsContainer.style.display=this.attachments.length>0?"flex":"none")}static fromConfig(e,t){return new r({allowedTypes:e==null?void 0:e.allowedTypes,maxFileSize:e==null?void 0:e.maxFileSize,maxFiles:e==null?void 0:e.maxFiles,onFileRejected:e==null?void 0:e.onFileRejected,onAttachmentsChange:t})}};var hx=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function ei(r,e){if(!r)return e;if(!e)return r;let t={...r};for(let[o,n]of Object.entries(e)){let a=t[o];hx(a)&&hx(n)?t[o]=ei(a,n):t[o]=n}return t}var Wo="min(440px, calc(100vw - 24px))",Sl="440px",Xt={apiUrl:"https://api.runtype.com/api/chat/dispatch",clientToken:void 0,theme:void 0,darkTheme:void 0,colorScheme:"light",launcher:{enabled:!0,mountMode:"floating",dock:{side:"right",width:"420px"},title:"Chat Assistant",subtitle:"Here to help you get answers fast",agentIconText:"\u{1F4AC}",agentIconName:"bot",headerIconName:"bot",position:"bottom-right",width:Wo,heightOffset:0,autoExpand:!1,callToActionIconHidden:!1,agentIconSize:"40px",headerIconSize:"40px",closeButtonSize:"32px",closeButtonPaddingX:"0px",closeButtonPaddingY:"0px",callToActionIconName:"arrow-up-right",callToActionIconText:"",callToActionIconSize:"32px",callToActionIconPadding:"5px",callToActionIconColor:void 0,callToActionIconBackgroundColor:void 0,closeButtonBackgroundColor:"transparent",clearChat:{backgroundColor:"transparent",borderColor:"transparent",enabled:!0,placement:"inline",iconName:"refresh-cw",size:"32px",showTooltip:!0,tooltipText:"Clear chat",paddingX:"0px",paddingY:"0px"},headerIconHidden:!1,border:void 0,shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"},copy:{welcomeTitle:"Hello \u{1F44B}",welcomeSubtitle:"Ask anything about your account or products.",inputPlaceholder:"How can I help...",sendButtonLabel:"Send"},sendButton:{borderWidth:"0px",paddingX:"12px",paddingY:"10px",borderColor:void 0,useIcon:!0,iconText:"\u2191",size:"40px",showTooltip:!0,tooltipText:"Send message",iconName:"send"},statusIndicator:{visible:!0,idleText:"Online",connectingText:"Connecting\u2026",connectedText:"Streaming\u2026",errorText:"Offline"},voiceRecognition:{enabled:!0,pauseDuration:2e3,iconName:"mic",iconSize:"39px",borderWidth:"0px",paddingX:"9px",paddingY:"14px",iconColor:void 0,backgroundColor:"transparent",borderColor:"transparent",recordingIconColor:void 0,recordingBackgroundColor:void 0,recordingBorderColor:"transparent",showTooltip:!0,tooltipText:"Start voice recognition"},features:{showReasoning:!0,showToolCalls:!0,scrollToBottom:{enabled:!0,iconName:"arrow-down",label:""},scrollBehavior:{mode:"follow",anchorTopOffset:16},toolCallDisplay:{collapsedMode:"tool-call",activePreview:!1,grouped:!1,previewMaxLines:3,expandable:!0,loadingAnimation:"none"},reasoningDisplay:{activePreview:!1,previewMaxLines:3,expandable:!0,loadingAnimation:"none"},streamAnimation:{type:"none",placeholder:"none",speed:120,duration:1800},askUserQuestion:{enabled:!0,slideInMs:180,freeTextLabel:"Other\u2026",freeTextPlaceholder:"Type your answer\u2026",submitLabel:"Send"}},suggestionChips:["What can you help me with?","Tell me about your features","How does this work?"],suggestionChipsConfig:{fontFamily:"sans-serif",fontWeight:"500",paddingX:"12px",paddingY:"6px"},layout:{header:{layout:"default",showIcon:!0,showTitle:!0,showSubtitle:!0,showCloseButton:!0,showClearChat:!0},messages:{layout:"bubble",avatar:{show:!1,position:"left"},timestamp:{show:!1,position:"below"},groupConsecutive:!1},slots:{}},markdown:{options:{gfm:!0,breaks:!0},disableDefaultStyles:!1},messageActions:{enabled:!0,showCopy:!0,showUpvote:!1,showDownvote:!1,visibility:"hover",align:"right",layout:"pill-inside"},debug:!1};function xx(r,e){if(!(!r&&!e))return r?e?ei(r,e):r:e}function Tl(r){var e,t,o,n,a,s,i,d,l,u,f,p,m,y,h,T,M,k,L,x,w;return r?{...Xt,...r,theme:xx(Xt.theme,r.theme),darkTheme:xx(Xt.darkTheme,r.darkTheme),launcher:{...Xt.launcher,...r.launcher,dock:{...(e=Xt.launcher)==null?void 0:e.dock,...(t=r.launcher)==null?void 0:t.dock},clearChat:{...(o=Xt.launcher)==null?void 0:o.clearChat,...(n=r.launcher)==null?void 0:n.clearChat}},copy:{...Xt.copy,...r.copy},sendButton:{...Xt.sendButton,...r.sendButton},statusIndicator:{...Xt.statusIndicator,...r.statusIndicator},voiceRecognition:{...Xt.voiceRecognition,...r.voiceRecognition},features:(()=>{var Z,ne,me,be,ye,Y,ge,Oe,ce,ae;let v=(Z=Xt.features)==null?void 0:Z.artifacts,E=(ne=r.features)==null?void 0:ne.artifacts,H=(me=Xt.features)==null?void 0:me.scrollToBottom,I=(be=r.features)==null?void 0:be.scrollToBottom,P=(ye=Xt.features)==null?void 0:ye.scrollBehavior,z=(Y=r.features)==null?void 0:Y.scrollBehavior,j=(ge=Xt.features)==null?void 0:ge.streamAnimation,ie=(Oe=r.features)==null?void 0:Oe.streamAnimation,ve=(ce=Xt.features)==null?void 0:ce.askUserQuestion,Xe=(ae=r.features)==null?void 0:ae.askUserQuestion,Ae=v===void 0&&E===void 0?void 0:{...v,...E,layout:{...v==null?void 0:v.layout,...E==null?void 0:E.layout}},We=H===void 0&&I===void 0?void 0:{...H,...I},Me=P===void 0&&z===void 0?void 0:{...P,...z},Ue=j===void 0&&ie===void 0?void 0:{...j,...ie},Be=ve===void 0&&Xe===void 0?void 0:{...ve,...Xe,styles:{...ve==null?void 0:ve.styles,...Xe==null?void 0:Xe.styles}};return{...Xt.features,...r.features,...We!==void 0?{scrollToBottom:We}:{},...Me!==void 0?{scrollBehavior:Me}:{},...Ae!==void 0?{artifacts:Ae}:{},...Ue!==void 0?{streamAnimation:Ue}:{},...Be!==void 0?{askUserQuestion:Be}:{}}})(),suggestionChips:(a=r.suggestionChips)!=null?a:Xt.suggestionChips,suggestionChipsConfig:{...Xt.suggestionChipsConfig,...r.suggestionChipsConfig},layout:{...Xt.layout,...r.layout,header:{...(s=Xt.layout)==null?void 0:s.header,...(i=r.layout)==null?void 0:i.header},messages:{...(d=Xt.layout)==null?void 0:d.messages,...(l=r.layout)==null?void 0:l.messages,avatar:{...(f=(u=Xt.layout)==null?void 0:u.messages)==null?void 0:f.avatar,...(m=(p=r.layout)==null?void 0:p.messages)==null?void 0:m.avatar},timestamp:{...(h=(y=Xt.layout)==null?void 0:y.messages)==null?void 0:h.timestamp,...(M=(T=r.layout)==null?void 0:T.messages)==null?void 0:M.timestamp}},slots:{...(k=Xt.layout)==null?void 0:k.slots,...(L=r.layout)==null?void 0:L.slots}},markdown:{...Xt.markdown,...r.markdown,options:{...(x=Xt.markdown)==null?void 0:x.options,...(w=r.markdown)==null?void 0:w.options}},messageActions:{...Xt.messageActions,...r.messageActions}}:Xt}var qp={colors:{primary:{50:"#ffffff",100:"#f5f5f5",200:"#d4d4d4",300:"#a3a3a3",400:"#737373",500:"#171717",600:"#0f0f0f",700:"#0a0a0a",800:"#050505",900:"#030303",950:"#000000"},secondary:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},accent:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},success:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},warning:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},error:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"},info:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"}},spacing:{0:"0px",1:"0.25rem",2:"0.5rem",3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",8:"2rem",10:"2.5rem",12:"3rem",16:"4rem",20:"5rem",24:"6rem",32:"8rem",40:"10rem",48:"12rem",56:"14rem",64:"16rem"},typography:{fontFamily:{sans:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',serif:'Georgia, Cambria, "Times New Roman", Times, serif',mono:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},fontWeight:{normal:"400",medium:"500",semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5",relaxed:"1.625"}},shadows:{none:"none",sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",xl:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)","2xl":"0 25px 50px -12px rgb(0 0 0 / 0.25)"},borders:{none:"none",sm:"1px solid",md:"2px solid",lg:"4px solid"},radius:{none:"0px",sm:"0.125rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem",full:"9999px"}},zp={colors:{primary:"palette.colors.primary.500",secondary:"palette.colors.secondary.500",accent:"palette.colors.primary.600",surface:"palette.colors.gray.50",background:"palette.colors.gray.50",container:"palette.colors.gray.50",text:"palette.colors.gray.900",textMuted:"palette.colors.gray.500",textInverse:"palette.colors.gray.50",border:"palette.colors.gray.200",divider:"palette.colors.gray.200",interactive:{default:"palette.colors.primary.600",hover:"palette.colors.primary.700",focus:"palette.colors.primary.600",active:"palette.colors.primary.600",disabled:"palette.colors.gray.300"},feedback:{success:"palette.colors.success.500",warning:"palette.colors.warning.500",error:"palette.colors.error.500",info:"palette.colors.info.500"}},spacing:{xs:"palette.spacing.1",sm:"palette.spacing.2",md:"palette.spacing.4",lg:"palette.spacing.6",xl:"palette.spacing.8","2xl":"palette.spacing.10"},typography:{fontFamily:"palette.typography.fontFamily.sans",fontSize:"palette.typography.fontSize.base",fontWeight:"palette.typography.fontWeight.normal",lineHeight:"palette.typography.lineHeight.normal"}},$p={button:{primary:{background:"palette.colors.primary.500",foreground:"palette.colors.primary.50",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md"},secondary:{background:"semantic.colors.surface",foreground:"semantic.colors.secondary",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md"},ghost:{background:"transparent",foreground:"semantic.colors.text",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"}},input:{background:"palette.colors.gray.50",placeholder:"palette.colors.gray.400",borderRadius:"palette.radius.lg",padding:"semantic.spacing.md",focus:{border:"palette.colors.gray.400",ring:"palette.colors.gray.400"}},launcher:{background:"palette.colors.primary.500",foreground:"palette.colors.primary.50",border:"palette.colors.gray.200",size:"60px",iconSize:"28px",borderRadius:"palette.radius.full",shadow:"palette.shadows.lg"},panel:{width:Wo,maxWidth:Sl,height:"600px",maxHeight:"calc(100vh - 80px)",borderRadius:"palette.radius.xl",shadow:"palette.shadows.xl"},header:{background:"palette.colors.primary.500",border:"palette.colors.primary.600",borderRadius:"palette.radius.xl palette.radius.xl 0 0",padding:"semantic.spacing.md",iconBackground:"palette.colors.primary.600",iconForeground:"palette.colors.primary.50",titleForeground:"palette.colors.primary.50",subtitleForeground:"palette.colors.primary.200",actionIconForeground:"palette.colors.primary.200"},message:{user:{background:"palette.colors.primary.500",text:"palette.colors.primary.50",borderRadius:"palette.radius.lg",shadow:"palette.shadows.sm"},assistant:{background:"palette.colors.gray.50",text:"palette.colors.gray.900",borderRadius:"palette.radius.lg",border:"palette.colors.gray.200",shadow:"palette.shadows.sm"},border:"semantic.colors.border"},introCard:{background:"semantic.colors.surface",borderRadius:"palette.radius.2xl",padding:"semantic.spacing.lg",shadow:"0 5px 15px rgba(15, 23, 42, 0.08)"},toolBubble:{shadow:"palette.shadows.sm"},reasoningBubble:{shadow:"palette.shadows.sm"},composer:{shadow:"palette.shadows.none"},markdown:{inlineCode:{background:"palette.colors.gray.50",foreground:"palette.colors.gray.900"},link:{foreground:"palette.colors.primary.600"},prose:{fontFamily:"inherit"},codeBlock:{background:"semantic.colors.container",borderColor:"semantic.colors.border",textColor:"inherit"},table:{headerBackground:"semantic.colors.container",borderColor:"semantic.colors.border"},hr:{color:"semantic.colors.divider"},blockquote:{borderColor:"palette.colors.gray.900",background:"transparent",textColor:"palette.colors.gray.500"}},collapsibleWidget:{container:"palette.colors.gray.50",surface:"semantic.colors.surface",border:"semantic.colors.border"},voice:{recording:{indicator:"palette.colors.error.500",background:"palette.colors.error.50",border:"palette.colors.error.200"},processing:{icon:"palette.colors.primary.500",background:"palette.colors.primary.50"},speaking:{icon:"palette.colors.success.500"}},approval:{requested:{background:"palette.colors.warning.50",border:"palette.colors.warning.200",text:"palette.colors.gray.900",shadow:"0 5px 15px rgba(15, 23, 42, 0.08)"},approve:{background:"palette.colors.success.500",foreground:"palette.colors.gray.50",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"},deny:{background:"palette.colors.error.500",foreground:"palette.colors.gray.50",borderRadius:"palette.radius.md",padding:"semantic.spacing.sm"}},attachment:{image:{background:"palette.colors.gray.100",border:"palette.colors.gray.200"}},scrollToBottom:{background:"components.button.primary.background",foreground:"components.button.primary.foreground",border:"semantic.colors.primary",size:"40px",borderRadius:"palette.radius.full",shadow:"palette.shadows.sm",padding:"0.5rem 0.875rem",gap:"0.5rem",fontSize:"0.875rem",iconSize:"14px"},artifact:{pane:{background:"semantic.colors.container",toolbarBackground:"semantic.colors.container"}}};function es(r,e){if(!e.startsWith("palette.")&&!e.startsWith("semantic.")&&!e.startsWith("components."))return e;let t=e.split("."),o=r;for(let n of t){if(o==null)return;o=o[n]}return typeof o=="string"&&(o.startsWith("palette.")||o.startsWith("semantic.")||o.startsWith("components."))?es(r,o):o}function Ml(r){let e={};function t(o,n){for(let[a,s]of Object.entries(o)){let i=`${n}.${a}`;if(typeof s=="string"){let d=es(r,s);d!==void 0&&(e[i]={path:i,value:d,type:n.includes("color")?"color":n.includes("spacing")?"spacing":n.includes("typography")?"typography":n.includes("shadow")?"shadow":n.includes("border")?"border":"color"})}else typeof s=="object"&&s!==null&&t(s,i)}}return t(r.palette,"palette"),t(r.semantic,"semantic"),t(r.components,"components"),e}function Vp(r){let e=[],t=[];return r.palette||e.push({path:"palette",message:"Theme must include a palette",severity:"error"}),r.semantic||t.push({path:"semantic",message:"No semantic tokens defined - defaults will be used",severity:"warning"}),r.components||t.push({path:"components",message:"No component tokens defined - defaults will be used",severity:"warning"}),{valid:e.length===0,errors:e,warnings:t}}function yx(r,e){let t={...r};for(let[o,n]of Object.entries(e)){let a=t[o];a&&typeof a=="object"&&!Array.isArray(a)&&n&&typeof n=="object"&&!Array.isArray(n)?t[o]=yx(a,n):t[o]=n}return t}function Lv(r,e){return e?yx(r,e):r}function ts(r,e={}){var n,a,s,i,d,l,u,f,p,m,y,h,T;let t={palette:qp,semantic:zp,components:$p},o={palette:{...t.palette,...r==null?void 0:r.palette,colors:{...t.palette.colors,...(n=r==null?void 0:r.palette)==null?void 0:n.colors},spacing:{...t.palette.spacing,...(a=r==null?void 0:r.palette)==null?void 0:a.spacing},typography:{...t.palette.typography,...(s=r==null?void 0:r.palette)==null?void 0:s.typography},shadows:{...t.palette.shadows,...(i=r==null?void 0:r.palette)==null?void 0:i.shadows},borders:{...t.palette.borders,...(d=r==null?void 0:r.palette)==null?void 0:d.borders},radius:{...t.palette.radius,...(l=r==null?void 0:r.palette)==null?void 0:l.radius}},semantic:{...t.semantic,...r==null?void 0:r.semantic,colors:{...t.semantic.colors,...(u=r==null?void 0:r.semantic)==null?void 0:u.colors,interactive:{...t.semantic.colors.interactive,...(p=(f=r==null?void 0:r.semantic)==null?void 0:f.colors)==null?void 0:p.interactive},feedback:{...t.semantic.colors.feedback,...(y=(m=r==null?void 0:r.semantic)==null?void 0:m.colors)==null?void 0:y.feedback}},spacing:{...t.semantic.spacing,...(h=r==null?void 0:r.semantic)==null?void 0:h.spacing},typography:{...t.semantic.typography,...(T=r==null?void 0:r.semantic)==null?void 0:T.typography}},components:Lv(t.components,r==null?void 0:r.components)};if(e.validate!==!1){let M=Vp(o);if(!M.valid)throw new Error(`Theme validation failed: ${M.errors.map(k=>k.message).join(", ")}`)}if(e.plugins)for(let M of e.plugins)o=M.transform(o);return o}function kl(r){var h,T,M,k,L,x,w,v,E,H,I,P,z,j,ie,ve,Xe,Ae,We,Me,Ue,Be,Z,ne,me,be,ye,Y,ge,Oe,ce,ae,Q,Tt,Ye,De,le,nt,Re,K,he,it,Pt,te,_e,Ar,Rt,dr,Yr,zr,O,fe,Ie,Je,qe,ze,lt,Mt,Dt,or,X,wt,ct,Ce,de,rt,Ft,zt,Pr,vr,xt,It,tt,jt,cr,Dr,hr,Sr,Oo,je,Tr,io,_o,lo,At,rn,No,mn,Jr,Ln,$r,Fo,mt,co,po,Or,Wt,Vr,Zr,_r,uo,fo,Nr,mo,$t,Fr,go,on,Uo,nn,qo,eo,to,gt,re,A,_,ue;let e=Ml(r),t={};for(let[$,at]of Object.entries(e)){let ut=$.replace(/\./g,"-");t[`--persona-${ut}`]=at.value}t["--persona-primary"]=(h=t["--persona-semantic-colors-primary"])!=null?h:t["--persona-palette-colors-primary-500"],t["--persona-secondary"]=(T=t["--persona-semantic-colors-secondary"])!=null?T:t["--persona-palette-colors-secondary-500"],t["--persona-accent"]=(M=t["--persona-semantic-colors-accent"])!=null?M:t["--persona-palette-colors-accent-500"],t["--persona-surface"]=(k=t["--persona-semantic-colors-surface"])!=null?k:t["--persona-palette-colors-gray-50"],t["--persona-background"]=(L=t["--persona-semantic-colors-background"])!=null?L:t["--persona-palette-colors-gray-50"],t["--persona-container"]=(x=t["--persona-semantic-colors-container"])!=null?x:t["--persona-palette-colors-gray-100"],t["--persona-text"]=(w=t["--persona-semantic-colors-text"])!=null?w:t["--persona-palette-colors-gray-900"],t["--persona-text-muted"]=(v=t["--persona-semantic-colors-text-muted"])!=null?v:t["--persona-palette-colors-gray-500"],t["--persona-text-inverse"]=(E=t["--persona-semantic-colors-text-inverse"])!=null?E:t["--persona-palette-colors-gray-50"],t["--persona-border"]=(H=t["--persona-semantic-colors-border"])!=null?H:t["--persona-palette-colors-gray-200"],t["--persona-divider"]=(I=t["--persona-semantic-colors-divider"])!=null?I:t["--persona-palette-colors-gray-200"],t["--persona-muted"]=t["--persona-text-muted"],t["--persona-voice-recording-indicator"]=(P=t["--persona-components-voice-recording-indicator"])!=null?P:t["--persona-palette-colors-error-500"],t["--persona-voice-recording-bg"]=(z=t["--persona-components-voice-recording-background"])!=null?z:t["--persona-palette-colors-error-50"],t["--persona-voice-processing-icon"]=(j=t["--persona-components-voice-processing-icon"])!=null?j:t["--persona-palette-colors-primary-500"],t["--persona-voice-speaking-icon"]=(ie=t["--persona-components-voice-speaking-icon"])!=null?ie:t["--persona-palette-colors-success-500"],t["--persona-approval-bg"]=(ve=t["--persona-components-approval-requested-background"])!=null?ve:t["--persona-palette-colors-warning-50"],t["--persona-approval-border"]=(Xe=t["--persona-components-approval-requested-border"])!=null?Xe:t["--persona-palette-colors-warning-200"],t["--persona-approval-text"]=(Ae=t["--persona-components-approval-requested-text"])!=null?Ae:t["--persona-palette-colors-gray-900"],t["--persona-approval-shadow"]=(We=t["--persona-components-approval-requested-shadow"])!=null?We:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-approval-approve-bg"]=(Me=t["--persona-components-approval-approve-background"])!=null?Me:t["--persona-palette-colors-success-500"],t["--persona-approval-deny-bg"]=(Ue=t["--persona-components-approval-deny-background"])!=null?Ue:t["--persona-palette-colors-error-500"],t["--persona-attachment-image-bg"]=(Be=t["--persona-components-attachment-image-background"])!=null?Be:t["--persona-palette-colors-gray-100"],t["--persona-attachment-image-border"]=(Z=t["--persona-components-attachment-image-border"])!=null?Z:t["--persona-palette-colors-gray-200"],t["--persona-font-family"]=(ne=t["--persona-semantic-typography-fontFamily"])!=null?ne:t["--persona-palette-typography-fontFamily-sans"],t["--persona-font-size"]=(me=t["--persona-semantic-typography-fontSize"])!=null?me:t["--persona-palette-typography-fontSize-base"],t["--persona-font-weight"]=(be=t["--persona-semantic-typography-fontWeight"])!=null?be:t["--persona-palette-typography-fontWeight-normal"],t["--persona-line-height"]=(ye=t["--persona-semantic-typography-lineHeight"])!=null?ye:t["--persona-palette-typography-lineHeight-normal"],t["--persona-input-font-family"]=t["--persona-font-family"],t["--persona-input-font-weight"]=t["--persona-font-weight"],t["--persona-radius-sm"]=(Y=t["--persona-palette-radius-sm"])!=null?Y:"0.125rem",t["--persona-radius-md"]=(ge=t["--persona-palette-radius-md"])!=null?ge:"0.375rem",t["--persona-radius-lg"]=(Oe=t["--persona-palette-radius-lg"])!=null?Oe:"0.5rem",t["--persona-radius-xl"]=(ce=t["--persona-palette-radius-xl"])!=null?ce:"0.75rem",t["--persona-radius-full"]=(ae=t["--persona-palette-radius-full"])!=null?ae:"9999px",t["--persona-launcher-radius"]=(Tt=(Q=t["--persona-components-launcher-borderRadius"])!=null?Q:t["--persona-palette-radius-full"])!=null?Tt:"9999px",t["--persona-launcher-bg"]=(Ye=t["--persona-components-launcher-background"])!=null?Ye:t["--persona-primary"],t["--persona-launcher-fg"]=(De=t["--persona-components-launcher-foreground"])!=null?De:t["--persona-text-inverse"],t["--persona-launcher-border"]=(le=t["--persona-components-launcher-border"])!=null?le:t["--persona-border"],t["--persona-button-primary-bg"]=(nt=t["--persona-components-button-primary-background"])!=null?nt:t["--persona-primary"],t["--persona-button-primary-fg"]=(Re=t["--persona-components-button-primary-foreground"])!=null?Re:t["--persona-text-inverse"],t["--persona-button-radius"]=(he=(K=t["--persona-components-button-primary-borderRadius"])!=null?K:t["--persona-palette-radius-full"])!=null?he:"9999px",t["--persona-panel-radius"]=(Pt=(it=t["--persona-components-panel-borderRadius"])!=null?it:t["--persona-radius-xl"])!=null?Pt:"0.75rem",t["--persona-panel-border"]=(te=t["--persona-components-panel-border"])!=null?te:`1px solid ${t["--persona-border"]}`,t["--persona-panel-shadow"]=(Ar=(_e=t["--persona-components-panel-shadow"])!=null?_e:t["--persona-palette-shadows-xl"])!=null?Ar:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",t["--persona-launcher-shadow"]=(Rt=t["--persona-components-launcher-shadow"])!=null?Rt:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",t["--persona-input-radius"]=(Yr=(dr=t["--persona-components-input-borderRadius"])!=null?dr:t["--persona-radius-lg"])!=null?Yr:"0.5rem",t["--persona-message-user-radius"]=(O=(zr=t["--persona-components-message-user-borderRadius"])!=null?zr:t["--persona-radius-lg"])!=null?O:"0.5rem",t["--persona-message-assistant-radius"]=(Ie=(fe=t["--persona-components-message-assistant-borderRadius"])!=null?fe:t["--persona-radius-lg"])!=null?Ie:"0.5rem",t["--persona-header-bg"]=(Je=t["--persona-components-header-background"])!=null?Je:t["--persona-surface"],t["--persona-header-border"]=(qe=t["--persona-components-header-border"])!=null?qe:t["--persona-divider"],t["--persona-header-icon-bg"]=(ze=t["--persona-components-header-iconBackground"])!=null?ze:t["--persona-primary"],t["--persona-header-icon-fg"]=(lt=t["--persona-components-header-iconForeground"])!=null?lt:t["--persona-text-inverse"],t["--persona-header-title-fg"]=(Mt=t["--persona-components-header-titleForeground"])!=null?Mt:t["--persona-primary"],t["--persona-header-subtitle-fg"]=(Dt=t["--persona-components-header-subtitleForeground"])!=null?Dt:t["--persona-text-muted"],t["--persona-header-action-icon-fg"]=(or=t["--persona-components-header-actionIconForeground"])!=null?or:t["--persona-muted"];let o=(X=r.components)==null?void 0:X.header;o!=null&&o.shadow&&(t["--persona-header-shadow"]=o.shadow),o!=null&&o.borderBottom&&(t["--persona-header-border-bottom"]=o.borderBottom);let n=(wt=r.components)==null?void 0:wt.introCard;t["--persona-intro-card-bg"]=(ct=t["--persona-components-introCard-background"])!=null?ct:t["--persona-surface"],t["--persona-intro-card-radius"]=(Ce=t["--persona-components-introCard-borderRadius"])!=null?Ce:"1rem",t["--persona-intro-card-padding"]=(de=t["--persona-components-introCard-padding"])!=null?de:"1.5rem",t["--persona-intro-card-shadow"]=(Ft=(rt=n==null?void 0:n.shadow)!=null?rt:t["--persona-components-introCard-shadow"])!=null?Ft:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-input-background"]=(zt=t["--persona-components-input-background"])!=null?zt:t["--persona-surface"],t["--persona-input-placeholder"]=(Pr=t["--persona-components-input-placeholder"])!=null?Pr:t["--persona-text-muted"],t["--persona-message-user-bg"]=(vr=t["--persona-components-message-user-background"])!=null?vr:t["--persona-accent"],t["--persona-message-user-text"]=(xt=t["--persona-components-message-user-text"])!=null?xt:t["--persona-text-inverse"],t["--persona-message-user-shadow"]=(It=t["--persona-components-message-user-shadow"])!=null?It:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-message-assistant-bg"]=(tt=t["--persona-components-message-assistant-background"])!=null?tt:t["--persona-surface"],t["--persona-message-assistant-text"]=(jt=t["--persona-components-message-assistant-text"])!=null?jt:t["--persona-text"],t["--persona-message-assistant-border"]=(cr=t["--persona-components-message-assistant-border"])!=null?cr:t["--persona-border"],t["--persona-message-assistant-shadow"]=(Dr=t["--persona-components-message-assistant-shadow"])!=null?Dr:"0 1px 2px 0 rgb(0 0 0 / 0.05)",t["--persona-scroll-to-bottom-bg"]=(Sr=(hr=t["--persona-components-scrollToBottom-background"])!=null?hr:t["--persona-button-primary-bg"])!=null?Sr:t["--persona-accent"],t["--persona-scroll-to-bottom-fg"]=(je=(Oo=t["--persona-components-scrollToBottom-foreground"])!=null?Oo:t["--persona-button-primary-fg"])!=null?je:t["--persona-text-inverse"],t["--persona-scroll-to-bottom-border"]=(Tr=t["--persona-components-scrollToBottom-border"])!=null?Tr:t["--persona-primary"],t["--persona-scroll-to-bottom-size"]=(io=t["--persona-components-scrollToBottom-size"])!=null?io:"40px",t["--persona-scroll-to-bottom-radius"]=(At=(lo=(_o=t["--persona-components-scrollToBottom-borderRadius"])!=null?_o:t["--persona-button-radius"])!=null?lo:t["--persona-radius-full"])!=null?At:"9999px",t["--persona-scroll-to-bottom-shadow"]=(No=(rn=t["--persona-components-scrollToBottom-shadow"])!=null?rn:t["--persona-palette-shadows-sm"])!=null?No:"0 1px 2px 0 rgb(0 0 0 / 0.05)",t["--persona-scroll-to-bottom-padding"]=(mn=t["--persona-components-scrollToBottom-padding"])!=null?mn:"0.5rem 0.875rem",t["--persona-scroll-to-bottom-gap"]=(Jr=t["--persona-components-scrollToBottom-gap"])!=null?Jr:"0.5rem",t["--persona-scroll-to-bottom-font-size"]=($r=(Ln=t["--persona-components-scrollToBottom-fontSize"])!=null?Ln:t["--persona-palette-typography-fontSize-sm"])!=null?$r:"0.875rem",t["--persona-scroll-to-bottom-icon-size"]=(Fo=t["--persona-components-scrollToBottom-iconSize"])!=null?Fo:"14px",t["--persona-tool-bubble-shadow"]=(mt=t["--persona-components-toolBubble-shadow"])!=null?mt:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-reasoning-bubble-shadow"]=(co=t["--persona-components-reasoningBubble-shadow"])!=null?co:"0 5px 15px rgba(15, 23, 42, 0.08)",t["--persona-composer-shadow"]=(po=t["--persona-components-composer-shadow"])!=null?po:"none",t["--persona-md-inline-code-bg"]=(Or=t["--persona-components-markdown-inlineCode-background"])!=null?Or:t["--persona-container"],t["--persona-md-inline-code-color"]=(Wt=t["--persona-components-markdown-inlineCode-foreground"])!=null?Wt:t["--persona-text"],t["--persona-md-link-color"]=(Zr=(Vr=t["--persona-components-markdown-link-foreground"])!=null?Vr:t["--persona-accent"])!=null?Zr:"#0f0f0f";let a=t["--persona-components-markdown-heading-h1-fontSize"];a&&(t["--persona-md-h1-size"]=a);let s=t["--persona-components-markdown-heading-h1-fontWeight"];s&&(t["--persona-md-h1-weight"]=s);let i=t["--persona-components-markdown-heading-h2-fontSize"];i&&(t["--persona-md-h2-size"]=i);let d=t["--persona-components-markdown-heading-h2-fontWeight"];d&&(t["--persona-md-h2-weight"]=d);let l=t["--persona-components-markdown-prose-fontFamily"];l&&l!=="inherit"&&(t["--persona-md-prose-font-family"]=l),t["--persona-md-code-block-bg"]=(_r=t["--persona-components-markdown-codeBlock-background"])!=null?_r:t["--persona-container"],t["--persona-md-code-block-border-color"]=(uo=t["--persona-components-markdown-codeBlock-borderColor"])!=null?uo:t["--persona-border"],t["--persona-md-code-block-text-color"]=(fo=t["--persona-components-markdown-codeBlock-textColor"])!=null?fo:"inherit",t["--persona-md-table-header-bg"]=(Nr=t["--persona-components-markdown-table-headerBackground"])!=null?Nr:t["--persona-container"],t["--persona-md-table-border-color"]=(mo=t["--persona-components-markdown-table-borderColor"])!=null?mo:t["--persona-border"],t["--persona-md-hr-color"]=($t=t["--persona-components-markdown-hr-color"])!=null?$t:t["--persona-divider"],t["--persona-md-blockquote-border-color"]=(Fr=t["--persona-components-markdown-blockquote-borderColor"])!=null?Fr:t["--persona-palette-colors-gray-900"],t["--persona-md-blockquote-bg"]=(go=t["--persona-components-markdown-blockquote-background"])!=null?go:"transparent",t["--persona-md-blockquote-text-color"]=(on=t["--persona-components-markdown-blockquote-textColor"])!=null?on:t["--persona-palette-colors-gray-500"],t["--cw-container"]=(Uo=t["--persona-components-collapsibleWidget-container"])!=null?Uo:t["--persona-surface"],t["--cw-surface"]=(nn=t["--persona-components-collapsibleWidget-surface"])!=null?nn:t["--persona-surface"],t["--cw-border"]=(qo=t["--persona-components-collapsibleWidget-border"])!=null?qo:t["--persona-border"],t["--persona-message-border"]=(eo=t["--persona-components-message-border"])!=null?eo:t["--persona-border"];let u=r.components,f=u==null?void 0:u.iconButton;f&&(f.background&&(t["--persona-icon-btn-bg"]=f.background),f.border&&(t["--persona-icon-btn-border"]=f.border),f.color&&(t["--persona-icon-btn-color"]=f.color),f.padding&&(t["--persona-icon-btn-padding"]=f.padding),f.borderRadius&&(t["--persona-icon-btn-radius"]=f.borderRadius),f.hoverBackground&&(t["--persona-icon-btn-hover-bg"]=f.hoverBackground),f.hoverColor&&(t["--persona-icon-btn-hover-color"]=f.hoverColor),f.activeBackground&&(t["--persona-icon-btn-active-bg"]=f.activeBackground),f.activeBorder&&(t["--persona-icon-btn-active-border"]=f.activeBorder));let p=u==null?void 0:u.labelButton;p&&(p.background&&(t["--persona-label-btn-bg"]=p.background),p.border&&(t["--persona-label-btn-border"]=p.border),p.color&&(t["--persona-label-btn-color"]=p.color),p.padding&&(t["--persona-label-btn-padding"]=p.padding),p.borderRadius&&(t["--persona-label-btn-radius"]=p.borderRadius),p.hoverBackground&&(t["--persona-label-btn-hover-bg"]=p.hoverBackground),p.fontSize&&(t["--persona-label-btn-font-size"]=p.fontSize),p.gap&&(t["--persona-label-btn-gap"]=p.gap));let m=u==null?void 0:u.toggleGroup;m&&(m.gap&&(t["--persona-toggle-group-gap"]=m.gap),m.borderRadius&&(t["--persona-toggle-group-radius"]=m.borderRadius));let y=u==null?void 0:u.artifact;if(y!=null&&y.toolbar){let $=y.toolbar;$.iconHoverColor&&(t["--persona-artifact-toolbar-icon-hover-color"]=$.iconHoverColor),$.iconHoverBackground&&(t["--persona-artifact-toolbar-icon-hover-bg"]=$.iconHoverBackground),$.iconPadding&&(t["--persona-artifact-toolbar-icon-padding"]=$.iconPadding),$.iconBorderRadius&&(t["--persona-artifact-toolbar-icon-radius"]=$.iconBorderRadius),$.iconBorder&&(t["--persona-artifact-toolbar-icon-border"]=$.iconBorder),$.toggleGroupGap&&(t["--persona-artifact-toolbar-toggle-group-gap"]=$.toggleGroupGap),$.toggleBorderRadius&&(t["--persona-artifact-toolbar-toggle-radius"]=$.toggleBorderRadius),$.copyBackground&&(t["--persona-artifact-toolbar-copy-bg"]=$.copyBackground),$.copyBorder&&(t["--persona-artifact-toolbar-copy-border"]=$.copyBorder),$.copyColor&&(t["--persona-artifact-toolbar-copy-color"]=$.copyColor),$.copyBorderRadius&&(t["--persona-artifact-toolbar-copy-radius"]=$.copyBorderRadius),$.copyPadding&&(t["--persona-artifact-toolbar-copy-padding"]=$.copyPadding),$.copyMenuBackground&&(t["--persona-artifact-toolbar-copy-menu-bg"]=$.copyMenuBackground,t["--persona-dropdown-bg"]=(to=t["--persona-dropdown-bg"])!=null?to:$.copyMenuBackground),$.copyMenuBorder&&(t["--persona-artifact-toolbar-copy-menu-border"]=$.copyMenuBorder,t["--persona-dropdown-border"]=(gt=t["--persona-dropdown-border"])!=null?gt:$.copyMenuBorder),$.copyMenuShadow&&(t["--persona-artifact-toolbar-copy-menu-shadow"]=$.copyMenuShadow,t["--persona-dropdown-shadow"]=(re=t["--persona-dropdown-shadow"])!=null?re:$.copyMenuShadow),$.copyMenuBorderRadius&&(t["--persona-artifact-toolbar-copy-menu-radius"]=$.copyMenuBorderRadius,t["--persona-dropdown-radius"]=(A=t["--persona-dropdown-radius"])!=null?A:$.copyMenuBorderRadius),$.copyMenuItemHoverBackground&&(t["--persona-artifact-toolbar-copy-menu-item-hover-bg"]=$.copyMenuItemHoverBackground,t["--persona-dropdown-item-hover-bg"]=(_=t["--persona-dropdown-item-hover-bg"])!=null?_:$.copyMenuItemHoverBackground),$.iconBackground&&(t["--persona-artifact-toolbar-icon-bg"]=$.iconBackground),$.toolbarBorder&&(t["--persona-artifact-toolbar-border"]=$.toolbarBorder)}if(y!=null&&y.tab){let $=y.tab;$.background&&(t["--persona-artifact-tab-bg"]=$.background),$.activeBackground&&(t["--persona-artifact-tab-active-bg"]=$.activeBackground),$.activeBorder&&(t["--persona-artifact-tab-active-border"]=$.activeBorder),$.borderRadius&&(t["--persona-artifact-tab-radius"]=$.borderRadius),$.textColor&&(t["--persona-artifact-tab-color"]=$.textColor),$.hoverBackground&&(t["--persona-artifact-tab-hover-bg"]=$.hoverBackground),$.listBackground&&(t["--persona-artifact-tab-list-bg"]=$.listBackground),$.listBorderColor&&(t["--persona-artifact-tab-list-border-color"]=$.listBorderColor),$.listPadding&&(t["--persona-artifact-tab-list-padding"]=$.listPadding)}if(y!=null&&y.pane){let $=y.pane;if($.toolbarBackground){let at=(ue=es(r,$.toolbarBackground))!=null?ue:$.toolbarBackground;t["--persona-artifact-toolbar-bg"]=at}}return t}var bx={header:"Widget header bar",messages:"Message list area","user-message":"User message bubble","assistant-message":"Assistant message bubble",composer:"Footer / composer area",container:"Main widget container","artifact-pane":"Artifact sidebar","artifact-toolbar":"Artifact toolbar"};var Pv={colors:{primary:{50:"#ffffff",100:"#f5f5f5",200:"#d4d4d4",300:"#a3a3a3",400:"#737373",500:"#171717",600:"#0f0f0f",700:"#0a0a0a",800:"#050505",900:"#030303",950:"#000000"},secondary:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},accent:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},success:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},warning:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},error:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"}}},vx=r=>{if(!(!r||typeof r!="object"||Array.isArray(r)))return r},ti=()=>{var r;return typeof document!="undefined"&&document.documentElement.classList.contains("dark")||typeof window!="undefined"&&((r=window.matchMedia)!=null&&r.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light"},Rv=r=>{var t;let e=(t=r==null?void 0:r.colorScheme)!=null?t:"light";return e==="light"?"light":e==="dark"?"dark":ti()},jp=r=>Rv(r),Iv=r=>ts(r),Hv=r=>{var t;let e=ts(void 0,{validate:!1});return ts({...r,palette:{...e.palette,colors:{...Pv.colors,...(t=r==null?void 0:r.palette)==null?void 0:t.colors}}},{validate:!1})},rs=r=>{let e=jp(r),t=vx(r==null?void 0:r.theme),o=vx(r==null?void 0:r.darkTheme);return e==="dark"?Hv(ei(t!=null?t:{},o!=null?o:{})):Iv(t)},Wv=r=>kl(r),Vn=(r,e)=>{let t=rs(e),o=Wv(t);for(let[n,a]of Object.entries(o))r.style.setProperty(n,a)},El=r=>{let e=[];if(typeof document!="undefined"&&typeof MutationObserver!="undefined"){let t=new MutationObserver(()=>{r(ti())});t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),e.push(()=>t.disconnect())}if(typeof window!="undefined"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>r(ti());t.addEventListener?(t.addEventListener("change",o),e.push(()=>t.removeEventListener("change",o))):t.addListener&&(t.addListener(o),e.push(()=>t.removeListener(o)))}return()=>{e.forEach(t=>t())}};var Cx=(function(){"use strict";let r=()=>{},e={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:r,afterNodeAdded:r,beforeNodeMorphed:r,afterNodeMorphed:r,beforeNodeRemoved:r,afterNodeRemoved:r,beforeAttributeUpdated:r},head:{style:"merge",shouldPreserve:p=>p.getAttribute("im-preserve")==="true",shouldReAppend:p=>p.getAttribute("im-re-append")==="true",shouldRemove:r,afterHeadMorphed:r},restoreFocus:!0};function t(p,m,y={}){p=u(p);let h=f(m),T=l(p,h,y),M=n(T,()=>i(T,p,h,k=>k.morphStyle==="innerHTML"?(a(k,p,h),Array.from(p.childNodes)):o(k,p,h)));return T.pantry.remove(),M}function o(p,m,y){let h=f(m);return a(p,h,y,m,m.nextSibling),Array.from(h.childNodes)}function n(p,m){var L;if(!p.config.restoreFocus)return m();let y=document.activeElement;if(!(y instanceof HTMLInputElement||y instanceof HTMLTextAreaElement))return m();let{id:h,selectionStart:T,selectionEnd:M}=y,k=m();return h&&h!==((L=document.activeElement)==null?void 0:L.getAttribute("id"))&&(y=p.target.querySelector(`[id="${h}"]`),y==null||y.focus()),y&&!y.selectionEnd&&M&&y.setSelectionRange(T,M),k}let a=(function(){function p(x,w,v,E=null,H=null){w instanceof HTMLTemplateElement&&v instanceof HTMLTemplateElement&&(w=w.content,v=v.content),E||(E=w.firstChild);for(let I of v.childNodes){if(E&&E!=H){let z=y(x,I,E,H);if(z){z!==E&&T(x,E,z),s(z,I,x),E=z.nextSibling;continue}}if(I instanceof Element){let z=I.getAttribute("id");if(x.persistentIds.has(z)){let j=M(w,z,E,x);s(j,I,x),E=j.nextSibling;continue}}let P=m(w,I,E,x);P&&(E=P.nextSibling)}for(;E&&E!=H;){let I=E;E=E.nextSibling,h(x,I)}}function m(x,w,v,E){if(E.callbacks.beforeNodeAdded(w)===!1)return null;if(E.idMap.has(w)){let H=document.createElement(w.tagName);return x.insertBefore(H,v),s(H,w,E),E.callbacks.afterNodeAdded(H),H}else{let H=document.importNode(w,!0);return x.insertBefore(H,v),E.callbacks.afterNodeAdded(H),H}}let y=(function(){function x(E,H,I,P){let z=null,j=H.nextSibling,ie=0,ve=I;for(;ve&&ve!=P;){if(v(ve,H)){if(w(E,ve,H))return ve;z===null&&(E.idMap.has(ve)||(z=ve))}if(z===null&&j&&v(ve,j)&&(ie++,j=j.nextSibling,ie>=2&&(z=void 0)),E.activeElementAndParents.includes(ve))break;ve=ve.nextSibling}return z||null}function w(E,H,I){let P=E.idMap.get(H),z=E.idMap.get(I);if(!z||!P)return!1;for(let j of P)if(z.has(j))return!0;return!1}function v(E,H){var z,j,ie;let I=E,P=H;return I.nodeType===P.nodeType&&I.tagName===P.tagName&&(!((z=I.getAttribute)!=null&&z.call(I,"id"))||((j=I.getAttribute)==null?void 0:j.call(I,"id"))===((ie=P.getAttribute)==null?void 0:ie.call(P,"id")))}return x})();function h(x,w){var v;if(x.idMap.has(w))L(x.pantry,w,null);else{if(x.callbacks.beforeNodeRemoved(w)===!1)return;(v=w.parentNode)==null||v.removeChild(w),x.callbacks.afterNodeRemoved(w)}}function T(x,w,v){let E=w;for(;E&&E!==v;){let H=E;E=E.nextSibling,h(x,H)}return E}function M(x,w,v,E){var I,P;let H=((P=(I=E.target).getAttribute)==null?void 0:P.call(I,"id"))===w&&E.target||E.target.querySelector(`[id="${w}"]`)||E.pantry.querySelector(`[id="${w}"]`);return k(H,E),L(x,H,v),H}function k(x,w){let v=x.getAttribute("id");for(;x=x.parentNode;){let E=w.idMap.get(x);E&&(E.delete(v),E.size||w.idMap.delete(x))}}function L(x,w,v){if(x.moveBefore)try{x.moveBefore(w,v)}catch{x.insertBefore(w,v)}else x.insertBefore(w,v)}return p})(),s=(function(){function p(k,L,x){return x.ignoreActive&&k===document.activeElement?null:(x.callbacks.beforeNodeMorphed(k,L)===!1||(k instanceof HTMLHeadElement&&x.head.ignore||(k instanceof HTMLHeadElement&&x.head.style!=="morph"?d(k,L,x):(m(k,L,x),M(k,x)||a(x,k,L))),x.callbacks.afterNodeMorphed(k,L)),k)}function m(k,L,x){let w=L.nodeType;if(w===1){let v=k,E=L,H=v.attributes,I=E.attributes;for(let P of I)T(P.name,v,"update",x)||v.getAttribute(P.name)!==P.value&&v.setAttribute(P.name,P.value);for(let P=H.length-1;0<=P;P--){let z=H[P];if(z&&!E.hasAttribute(z.name)){if(T(z.name,v,"remove",x))continue;v.removeAttribute(z.name)}}M(v,x)||y(v,E,x)}(w===8||w===3)&&k.nodeValue!==L.nodeValue&&(k.nodeValue=L.nodeValue)}function y(k,L,x){if(k instanceof HTMLInputElement&&L instanceof HTMLInputElement&&L.type!=="file"){let w=L.value,v=k.value;h(k,L,"checked",x),h(k,L,"disabled",x),L.hasAttribute("value")?v!==w&&(T("value",k,"update",x)||(k.setAttribute("value",w),k.value=w)):T("value",k,"remove",x)||(k.value="",k.removeAttribute("value"))}else if(k instanceof HTMLOptionElement&&L instanceof HTMLOptionElement)h(k,L,"selected",x);else if(k instanceof HTMLTextAreaElement&&L instanceof HTMLTextAreaElement){let w=L.value,v=k.value;if(T("value",k,"update",x))return;w!==v&&(k.value=w),k.firstChild&&k.firstChild.nodeValue!==w&&(k.firstChild.nodeValue=w)}}function h(k,L,x,w){let v=L[x],E=k[x];if(v!==E){let H=T(x,k,"update",w);H||(k[x]=L[x]),v?H||k.setAttribute(x,""):T(x,k,"remove",w)||k.removeAttribute(x)}}function T(k,L,x,w){return k==="value"&&w.ignoreActiveValue&&L===document.activeElement?!0:w.callbacks.beforeAttributeUpdated(k,L,x)===!1}function M(k,L){return!!L.ignoreActiveValue&&k===document.activeElement&&k!==document.body}return p})();function i(p,m,y,h){if(p.head.block){let T=m.querySelector("head"),M=y.querySelector("head");if(T&&M){let k=d(T,M,p);return Promise.all(k).then(()=>{let L=Object.assign(p,{head:{block:!1,ignore:!0}});return h(L)})}}return h(p)}function d(p,m,y){let h=[],T=[],M=[],k=[],L=new Map;for(let w of m.children)L.set(w.outerHTML,w);for(let w of p.children){let v=L.has(w.outerHTML),E=y.head.shouldReAppend(w),H=y.head.shouldPreserve(w);v||H?E?T.push(w):(L.delete(w.outerHTML),M.push(w)):y.head.style==="append"?E&&(T.push(w),k.push(w)):y.head.shouldRemove(w)!==!1&&T.push(w)}k.push(...L.values());let x=[];for(let w of k){let v=document.createRange().createContextualFragment(w.outerHTML).firstChild;if(y.callbacks.beforeNodeAdded(v)!==!1){if("href"in v&&v.href||"src"in v&&v.src){let E,H=new Promise(function(I){E=I});v.addEventListener("load",function(){E()}),x.push(H)}p.appendChild(v),y.callbacks.afterNodeAdded(v),h.push(v)}}for(let w of T)y.callbacks.beforeNodeRemoved(w)!==!1&&(p.removeChild(w),y.callbacks.afterNodeRemoved(w));return y.head.afterHeadMorphed(p,{added:h,kept:M,removed:T}),x}let l=(function(){function p(x,w,v){let{persistentIds:E,idMap:H}=k(x,w),I=m(v),P=I.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(P))throw`Do not understand how to morph style ${P}`;return{target:x,newContent:w,config:I,morphStyle:P,ignoreActive:I.ignoreActive,ignoreActiveValue:I.ignoreActiveValue,restoreFocus:I.restoreFocus,idMap:H,persistentIds:E,pantry:y(),activeElementAndParents:h(x),callbacks:I.callbacks,head:I.head}}function m(x){let w=Object.assign({},e);return Object.assign(w,x),w.callbacks=Object.assign({},e.callbacks,x.callbacks),w.head=Object.assign({},e.head,x.head),w}function y(){let x=document.createElement("div");return x.hidden=!0,document.body.insertAdjacentElement("afterend",x),x}function h(x){let w=[],v=document.activeElement;if((v==null?void 0:v.tagName)!=="BODY"&&x.contains(v))for(;v&&(w.push(v),v!==x);)v=v.parentElement;return w}function T(x){var v;let w=Array.from(x.querySelectorAll("[id]"));return(v=x.getAttribute)!=null&&v.call(x,"id")&&w.push(x),w}function M(x,w,v,E){for(let H of E){let I=H.getAttribute("id");if(w.has(I)){let P=H;for(;P;){let z=x.get(P);if(z==null&&(z=new Set,x.set(P,z)),z.add(I),P===v)break;P=P.parentElement}}}}function k(x,w){let v=T(x),E=T(w),H=L(v,E),I=new Map;M(I,H,x,v);let P=w.__idiomorphRoot||w;return M(I,H,P,E),{persistentIds:H,idMap:I}}function L(x,w){let v=new Set,E=new Map;for(let{id:I,tagName:P}of x)E.has(I)?v.add(I):E.set(I,P);let H=new Set;for(let{id:I,tagName:P}of w)H.has(I)?v.add(I):E.get(I)===P&&H.add(I);for(let I of v)H.delete(I);return H}return p})(),{normalizeElement:u,normalizeParent:f}=(function(){let p=new WeakSet;function m(M){return M instanceof Document?M.documentElement:M}function y(M){if(M==null)return document.createElement("div");if(typeof M=="string")return y(T(M));if(p.has(M))return M;if(M instanceof Node){if(M.parentNode)return new h(M);{let k=document.createElement("div");return k.append(M),k}}else{let k=document.createElement("div");for(let L of[...M])k.append(L);return k}}class h{constructor(k){this.originalNode=k,this.realParentNode=k.parentNode,this.previousSibling=k.previousSibling,this.nextSibling=k.nextSibling}get childNodes(){let k=[],L=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;L&&L!=this.nextSibling;)k.push(L),L=L.nextSibling;return k}querySelectorAll(k){return this.childNodes.reduce((L,x)=>{if(x instanceof Element){x.matches(k)&&L.push(x);let w=x.querySelectorAll(k);for(let v=0;v<w.length;v++)L.push(w[v])}return L},[])}insertBefore(k,L){return this.realParentNode.insertBefore(k,L)}moveBefore(k,L){return this.realParentNode.moveBefore(k,L)}get __idiomorphRoot(){return this.originalNode}}function T(M){let k=new DOMParser,L=M.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(L.match(/<\/html>/)||L.match(/<\/head>/)||L.match(/<\/body>/)){let x=k.parseFromString(M,"text/html");if(L.match(/<\/html>/))return p.add(x),x;{let w=x.firstChild;return w&&p.add(w),w}}else{let w=k.parseFromString("<body><template>"+M+"</template></body>","text/html").body.querySelector("template").content;return p.add(w),w}}return{normalizeElement:m,normalizeParent:y}})();return{morph:t,defaults:e}})();var Ll=(r,e,t={})=>{let{preserveTypingAnimation:o=!0}=t;Cx.morph(r,e.innerHTML,{morphStyle:"innerHTML",callbacks:{beforeNodeMorphed(n,a){var s,i;if(n instanceof HTMLElement&&o){if(n.classList.contains("persona-animate-typing")||n.hasAttribute("data-preserve-runtime"))return!1;if(n.hasAttribute("data-preserve-animation")){if(a instanceof HTMLElement&&!a.hasAttribute("data-preserve-animation"))return;if(a instanceof HTMLElement&&a.hasAttribute("data-preserve-animation")){let d=(s=n.textContent)!=null?s:"",l=(i=a.textContent)!=null?i:"";if(d!==l)return}return!1}}}}})};var Pl={index:-1,draft:""};function wx(r){let{direction:e,history:t,currentValue:o,atStart:n,state:a}=r,s=a.index!==-1;if(t.length===0)return{handled:!1,state:a};if(e==="up"){if(!s&&!n)return{handled:!1,state:a};if(!s){let i=t.length-1;return{handled:!0,value:t[i],state:{index:i,draft:o}}}if(a.index>0){let i=a.index-1;return{handled:!0,value:t[i],state:{index:i,draft:a.draft}}}return{handled:!0,state:a}}if(!s)return{handled:!1,state:a};if(a.index<t.length-1){let i=a.index+1;return{handled:!0,value:t[i],state:{index:i,draft:a.draft}}}return{handled:!0,value:a.draft,state:{...Pl}}}function Ax(r,e){var t,o,n,a,s,i,d,l,u,f,p,m,y,h,T,M,k,L,x,w,v,E,H,I,P,z,j,ie,ve,Xe,Ae,We,Me,Ue,Be,Z,ne,me;return[r.id,r.role,(o=(t=r.content)==null?void 0:t.length)!=null?o:0,(a=(n=r.content)==null?void 0:n.slice(-32))!=null?a:"",r.streaming?"1":"0",(s=r.variant)!=null?s:"",(d=(i=r.rawContent)==null?void 0:i.length)!=null?d:0,(u=(l=r.llmContent)==null?void 0:l.length)!=null?u:0,(p=(f=r.approval)==null?void 0:f.status)!=null?p:"",(y=(m=r.toolCall)==null?void 0:m.status)!=null?y:"",(T=(h=r.toolCall)==null?void 0:h.name)!=null?T:"",(L=(k=(M=r.toolCall)==null?void 0:M.chunks)==null?void 0:k.length)!=null?L:0,(E=(v=(w=(x=r.toolCall)==null?void 0:x.chunks)==null?void 0:w[r.toolCall.chunks.length-1])==null?void 0:v.slice(-32))!=null?E:"",typeof((H=r.toolCall)==null?void 0:H.args)=="string"?r.toolCall.args.length:(I=r.toolCall)!=null&&I.args?JSON.stringify(r.toolCall.args).length:0,(j=(z=(P=r.reasoning)==null?void 0:P.chunks)==null?void 0:z.length)!=null?j:0,(Ae=(Xe=(ve=(ie=r.reasoning)==null?void 0:ie.chunks)==null?void 0:ve[r.reasoning.chunks.length-1])==null?void 0:Xe.length)!=null?Ae:0,(Be=(Ue=(Me=(We=r.reasoning)==null?void 0:We.chunks)==null?void 0:Me[r.reasoning.chunks.length-1])==null?void 0:Ue.slice(-32))!=null?Be:"",(ne=(Z=r.contentParts)==null?void 0:Z.length)!=null?ne:0,(me=r.stopReason)!=null?me:"",e].join("\0")}function Sx(){return new Map}function Tx(r,e,t){let o=r.get(e);return o&&o.fingerprint===t?o.wrapper:null}function Mx(r,e,t,o){r.set(e,{fingerprint:t,wrapper:o})}function kx(r,e){for(let t of r.keys())e.has(t)||r.delete(t)}function Rl(r=!0){let e=r;return{isFollowing:()=>e,pause:()=>e?(e=!1,!0):!1,resume:()=>e?!1:(e=!0,!0)}}function Mn(r){return Math.max(0,r.scrollHeight-r.clientHeight)}function Aa(r,e){return Mn(r)-r.scrollTop<=e}function Il(r){let{following:e,currentScrollTop:t,lastScrollTop:o,nearBottom:n,userScrollThreshold:a,isAutoScrolling:s=!1,pauseOnUpwardScroll:i=!1,pauseWhenAwayFromBottom:d=!0,resumeRequiresDownwardScroll:l=!1}=r,u=t-o;return s||Math.abs(u)<a?{action:"none",delta:u,nextLastScrollTop:t}:!e&&n&&(!l||u>0)?{action:"resume",delta:u,nextLastScrollTop:t}:e&&i&&u<0?{action:"pause",delta:u,nextLastScrollTop:t}:e&&d&&!n?{action:"pause",delta:u,nextLastScrollTop:t}:{action:"none",delta:u,nextLastScrollTop:t}}function Hl(r){let{following:e,deltaY:t,nearBottom:o=!1,resumeWhenNearBottom:n=!1}=r;return e&&t<0?"pause":!e&&n&&t>0&&o?"resume":"none"}function Ex(r,e){return!r||r.isCollapsed?!1:e.contains(r.anchorNode)||e.contains(r.focusNode)}function Lx(r){let e=Math.max(0,r.anchorOffsetTop-r.topOffset),t=Math.max(0,e+r.viewportHeight-r.contentHeight);return{targetScrollTop:e,spacerHeight:t}}function Px(r){let e=Math.max(0,r.currentContentHeight-r.contentHeightAtAnchor);return Math.max(0,r.initialSpacerHeight-e)}var ao={idle:"Online",connecting:"Connecting\u2026",connected:"Streaming\u2026",error:"Offline"},so=1e5,jn=so+1;var ri={type:"none",placeholder:"none",speed:120,duration:1800,buffer:"none"},Bv=["pre","code","a","script","style"],Wl=r=>{var e,t,o,n,a;return{type:(e=r==null?void 0:r.type)!=null?e:ri.type,placeholder:(t=r==null?void 0:r.placeholder)!=null?t:ri.placeholder,speed:(o=r==null?void 0:r.speed)!=null?o:ri.speed,duration:(n=r==null?void 0:r.duration)!=null?n:ri.duration,buffer:(a=r==null?void 0:r.buffer)!=null?a:ri.buffer}},Ix=[{name:"typewriter",containerClass:"persona-stream-typewriter",wrap:"char",useCaret:!0},{name:"pop-bubble",bubbleClass:"persona-stream-pop",wrap:"none"},{name:"letter-rise",containerClass:"persona-stream-letter-rise",wrap:"char"},{name:"word-fade",containerClass:"persona-stream-word-fade",wrap:"word"}],oi=new Map;for(let r of Ix)oi.set(r.name,r);var Sa=r=>{oi.set(r.name,r)},Xp=r=>{Ix.some(e=>e.name===r)||oi.delete(r)},Qp=()=>Array.from(oi.keys()),ni=(r,e)=>{var t,o;return r==="none"?null:e&&Object.prototype.hasOwnProperty.call(e,r)?(t=e[r])!=null?t:null:(o=oi.get(r))!=null?o:null},Bl=(r,e,t,o,n)=>{if(!n)return r;if(t!=null&&t.bufferContent)return t.bufferContent(r,o);if(!r)return r;if(e==="word"){let a=r.search(/\s(?=\S*$)/);return a<0?"":r.slice(0,a)}if(e==="line"){let a=r.lastIndexOf(`
|
|
63
|
+
`);return a<0?"":r.slice(0,a)}return r},Dv=(r,e,t,o)=>{let n=r.createElement("span");return n.className="persona-stream-char",n.id=`stream-c-${t}-${o}`,n.style.setProperty("--char-index",String(o)),n.textContent=e,n},Ov=(r,e,t,o)=>{let n=r.createElement("span");return n.className="persona-stream-word",n.id=`stream-w-${t}-${o}`,n.style.setProperty("--word-index",String(o)),n.textContent=e,n},Gp=/\s/,_v=(r,e)=>{let t=r.parentNode;for(;t;){if(t.nodeType===1){let o=t;if(e.has(o.tagName.toLowerCase()))return!0}t=t.parentNode}return!1},Nv=(r,e,t)=>{var d;let o=r.ownerDocument,n=r.parentNode;if(!o||!n)return;let a=(d=r.nodeValue)!=null?d:"";if(!a)return;let s=o.createDocumentFragment(),i=0;for(;i<a.length;)if(Gp.test(a[i])){let l=i;for(;l<a.length&&Gp.test(a[l]);)l+=1;s.appendChild(o.createTextNode(a.slice(i,l))),i=l}else{let l=o.createElement("span");l.className="persona-stream-word-group";let u=i;for(;u<a.length&&!Gp.test(a[u]);)l.appendChild(Dv(o,a[u],e,t.value)),t.value+=1,u+=1;s.appendChild(l),i=u}n.replaceChild(s,r)},Fv=(r,e,t)=>{var d;let o=r.ownerDocument,n=r.parentNode;if(!o||!n)return;let a=(d=r.nodeValue)!=null?d:"";if(!a)return;let s=o.createDocumentFragment(),i=a.split(/(\s+)/);for(let l of i)l&&(/^\s+$/.test(l)?s.appendChild(o.createTextNode(l)):(s.appendChild(Ov(o,l,e,t.value)),t.value+=1));n.replaceChild(s,r)},ai=(r,e,t,o)=>{var f,p;if(!r||typeof document=="undefined")return r;let n=document.createElement("div");n.innerHTML=r;let a=new Set(((f=o==null?void 0:o.skipTags)!=null?f:Bv).map(m=>m.toLowerCase())),s=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null),i=[],d=s.nextNode();for(;d;)_v(d,a)||i.push(d),d=s.nextNode();let l={value:(p=o==null?void 0:o.startIndex)!=null?p:0},u=e==="char"?Nv:Fv;for(let m of i)u(m,t,l);return n.innerHTML},Dl=(r=document)=>{let e=r.createElement("span");return e.className="persona-stream-caret",e.setAttribute("aria-hidden","true"),e.setAttribute("data-preserve-animation","stream-caret"),e},si=(r=document)=>{let e=r.createElement("div");e.className="persona-stream-skeleton",e.setAttribute("data-preserve-animation","stream-skeleton"),e.setAttribute("aria-hidden","true");let t=r.createElement("div");return t.className="persona-stream-skeleton-line",e.appendChild(t),e},Rx=new WeakMap,Uv=(r,e)=>{var a;if(!r.styles)return;let t=Rx.get(e);if(t||(t=new Set,Rx.set(e,t)),t.has(r.name)){let s=r.name.replace(/["\\]/g,"\\$&");if(e.querySelector(`style[data-persona-animation="${s}"]`))return;t.delete(r.name)}t.add(r.name);let n=(e instanceof ShadowRoot?e.ownerDocument:(a=e.ownerDocument)!=null?a:document).createElement("style");n.setAttribute("data-persona-animation",r.name),n.textContent=r.styles,e.appendChild(n)},Kp=new WeakMap,qv=(r,e)=>{if(!r.onAttach)return;let t=Kp.get(e);if(t||(t=new Map,Kp.set(e,t)),t.has(r.name))return;let o=r.onAttach(e);t.set(r.name,o)},Hx=r=>{let e=Kp.get(r);if(e){for(let t of e.values())typeof t=="function"&&t();e.clear()}},Yp=(r,e)=>{Uv(r,e),qv(r,e)};function Jp(r,e=so){let t=r.style.position,o=r.style.zIndex,n=r.style.isolation,a=getComputedStyle(r),s=a.position==="static"||a.position==="";return s&&(r.style.position="relative"),r.style.zIndex=String(e),r.style.isolation="isolate",()=>{s&&(r.style.position=t),r.style.zIndex=o,r.style.isolation=n}}var ii=0,Gn=null;function Zp(r=document){var t;if(ii++,ii===1){let o=r.body,a=((t=r.defaultView)!=null?t:window).scrollY||r.documentElement.scrollTop;Gn={originalOverflow:o.style.overflow,originalPosition:o.style.position,originalTop:o.style.top,originalWidth:o.style.width,scrollY:a},o.style.overflow="hidden",o.style.position="fixed",o.style.top=`-${a}px`,o.style.width="100%"}let e=!1;return()=>{var o;if(!e&&(e=!0,ii=Math.max(0,ii-1),ii===0&&Gn)){let n=r.body,a=(o=r.defaultView)!=null?o:window;n.style.overflow=Gn.originalOverflow,n.style.position=Gn.originalPosition,n.style.top=Gn.originalTop,n.style.width=Gn.originalWidth,a.scrollTo(0,Gn.scrollY),Gn=null}}}var li={side:"right",width:"420px",animate:!0,reveal:"resize",maxHeight:"100dvh"},Lr=r=>{var e,t;return((t=(e=r==null?void 0:r.launcher)==null?void 0:e.mountMode)!=null?t:"floating")==="docked"},Kn=r=>{var e,t;return((t=(e=r==null?void 0:r.launcher)==null?void 0:e.mountMode)!=null?t:"floating")==="composer-bar"},Bo=r=>{var t,o,n,a,s,i;let e=(t=r==null?void 0:r.launcher)==null?void 0:t.dock;return{side:(o=e==null?void 0:e.side)!=null?o:li.side,width:(n=e==null?void 0:e.width)!=null?n:li.width,animate:(a=e==null?void 0:e.animate)!=null?a:li.animate,reveal:(s=e==null?void 0:e.reveal)!=null?s:li.reveal,maxHeight:(i=e==null?void 0:e.maxHeight)!=null?i:li.maxHeight}};var tn={"bottom-right":"persona-bottom-6 persona-right-6","bottom-left":"persona-bottom-6 persona-left-6","top-right":"persona-top-6 persona-right-6","top-left":"persona-top-6 persona-left-6"};var di=(r,e)=>{let t=C("button");t.type="button",t.innerHTML=`
|
|
63
64
|
<span class="persona-inline-flex persona-items-center persona-justify-center persona-rounded-full persona-bg-persona-primary persona-text-white" data-role="launcher-icon">\u{1F4AC}</span>
|
|
64
65
|
<img data-role="launcher-image" class="persona-rounded-full persona-object-cover" alt="" style="display:none" />
|
|
65
66
|
<span class="persona-flex persona-min-w-0 persona-flex-1 persona-flex-col persona-items-start persona-text-left">
|
|
@@ -67,14 +68,14 @@ _Details: ${t.message}_`:n}var Gs=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
67
68
|
<span class="persona-block persona-w-full persona-truncate persona-text-xs persona-text-persona-muted" data-role="launcher-subtitle"></span>
|
|
68
69
|
</span>
|
|
69
70
|
<span class="persona-ml-2 persona-grid persona-place-items-center persona-rounded-full persona-bg-persona-primary persona-text-persona-call-to-action" data-role="launcher-call-to-action-icon">\u2197</span>
|
|
70
|
-
`,t.addEventListener("click",e);let n=a=>{var k,x,C,w,E,H,I,L,O,$,te,xe,Je;let s=(k=a.launcher)!=null?k:{},i=Pr(a),d=t.querySelector("[data-role='launcher-title']");if(d){let we=(x=s.title)!=null?x:"Chat Assistant";d.textContent=we,d.setAttribute("title",we)}let l=t.querySelector("[data-role='launcher-subtitle']");if(l){let we=(C=s.subtitle)!=null?C:"Get answers fast";l.textContent=we,l.setAttribute("title",we)}let u=t.querySelector(".persona-flex-col");u&&(s.textHidden||i?u.style.display="none":u.style.display="");let m=t.querySelector("[data-role='launcher-icon']");if(m)if(s.agentIconHidden)m.style.display="none";else{let we=(w=s.agentIconSize)!=null?w:"40px";if(m.style.height=we,m.style.width=we,m.innerHTML="",s.agentIconName){let De=parseFloat(we)||24,Ae=Me(s.agentIconName,De*.6,"var(--persona-text-inverse, #ffffff)",2);Ae?(m.appendChild(Ae),m.style.display=""):(m.textContent=(E=s.agentIconText)!=null?E:"\u{1F4AC}",m.style.display="")}else s.iconUrl?m.style.display="none":(m.textContent=(H=s.agentIconText)!=null?H:"\u{1F4AC}",m.style.display="")}let p=t.querySelector("[data-role='launcher-image']");if(p){let we=(I=s.agentIconSize)!=null?I:"40px";p.style.height=we,p.style.width=we,s.iconUrl&&!s.agentIconName&&!s.agentIconHidden?(p.src=s.iconUrl,p.style.display="block"):p.style.display="none"}let f=t.querySelector("[data-role='launcher-call-to-action-icon']");if(f){let we=(L=s.callToActionIconSize)!=null?L:"32px";f.style.height=we,f.style.width=we,s.callToActionIconBackgroundColor?(f.style.backgroundColor=s.callToActionIconBackgroundColor,f.classList.remove("persona-bg-persona-primary")):(f.style.backgroundColor="",f.classList.add("persona-bg-persona-primary")),s.callToActionIconColor?(f.style.color=s.callToActionIconColor,f.classList.remove("persona-text-persona-call-to-action")):(f.style.color="",f.classList.add("persona-text-persona-call-to-action"));let De=0;if(s.callToActionIconPadding?(f.style.boxSizing="border-box",f.style.padding=s.callToActionIconPadding,De=(parseFloat(s.callToActionIconPadding)||0)*2):(f.style.boxSizing="",f.style.padding=""),s.callToActionIconHidden)f.style.display="none";else if(f.style.display=i?"none":"",f.innerHTML="",s.callToActionIconName){let Ae=parseFloat(we)||24,qe=Math.max(Ae-De,8),He=Me(s.callToActionIconName,qe,"currentColor",2);He?f.appendChild(He):f.textContent=(O=s.callToActionIconText)!=null?O:"\u2197"}else f.textContent=($=s.callToActionIconText)!=null?$:"\u2197"}let b=s.position&&jn[s.position]?jn[s.position]:jn["bottom-right"],h="persona-fixed persona-flex persona-items-center persona-gap-3 persona-rounded-launcher persona-bg-persona-surface persona-py-2.5 persona-pl-3 persona-pr-3 persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer",S="persona-relative persona-mt-4 persona-mb-4 persona-mx-auto persona-flex persona-items-center persona-justify-center persona-rounded-launcher persona-bg-persona-surface persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer";t.className=i?S:`${h} ${b}`,i||(t.style.zIndex=String((te=s.zIndex)!=null?te:Xr));let T="1px solid var(--persona-border, #e5e7eb)",M="var(--persona-launcher-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1))";t.style.border=(xe=s.border)!=null?xe:T,t.style.boxShadow=s.shadow!==void 0?s.shadow.trim()===""?"none":s.shadow:M,i?(t.style.width="0",t.style.minWidth="0",t.style.maxWidth="0",t.style.padding="0",t.style.overflow="hidden",t.style.border="none",t.style.boxShadow="none"):(t.style.width="",t.style.minWidth="",t.style.maxWidth=(Je=s.collapsedMaxWidth)!=null?Je:"",t.style.justifyContent="",t.style.padding="",t.style.overflow="")},o=()=>{t.removeEventListener("click",e),t.remove()};return r&&n(r),{element:t,update:n,destroy:o}};var Sv="persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center",Wl=(r,e={})=>{var h,S,T,M,k,x;let{showClose:t=!0,wrapperClassName:n=Sv,buttonSize:o,iconSize:a="28px"}=e,s=(h=r==null?void 0:r.launcher)!=null?h:{},i=(S=o!=null?o:s.closeButtonSize)!=null?S:"32px",d=v("div",n),l=v("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");l.style.height=i,l.style.width=i,l.type="button";let u=(T=s.closeButtonTooltipText)!=null?T:"Close chat",m=(M=s.closeButtonShowTooltip)!=null?M:!0;l.setAttribute("aria-label",u),l.style.display=t?"":"none";let p=(k=s.closeButtonIconName)!=null?k:"x",f=(x=s.closeButtonIconText)!=null?x:"\xD7";l.style.color=s.closeButtonColor||an.actionIconColor;let b=Me(p,a,"currentColor",1);if(b?(b.style.display="block",l.appendChild(b)):l.textContent=f,s.closeButtonBackgroundColor?(l.style.backgroundColor=s.closeButtonBackgroundColor,l.classList.remove("hover:persona-bg-gray-100")):(l.style.backgroundColor="",l.classList.add("hover:persona-bg-gray-100")),s.closeButtonBorderWidth||s.closeButtonBorderColor){let C=s.closeButtonBorderWidth||"0px",w=s.closeButtonBorderColor||"transparent";l.style.border=`${C} solid ${w}`,l.classList.remove("persona-border-none")}else l.style.border="",l.classList.add("persona-border-none");if(s.closeButtonBorderRadius?(l.style.borderRadius=s.closeButtonBorderRadius,l.classList.remove("persona-rounded-full")):(l.style.borderRadius="",l.classList.add("persona-rounded-full")),s.closeButtonPaddingX?(l.style.paddingLeft=s.closeButtonPaddingX,l.style.paddingRight=s.closeButtonPaddingX):(l.style.paddingLeft="",l.style.paddingRight=""),s.closeButtonPaddingY?(l.style.paddingTop=s.closeButtonPaddingY,l.style.paddingBottom=s.closeButtonPaddingY):(l.style.paddingTop="",l.style.paddingBottom=""),d.appendChild(l),m&&u){let C=null,w=()=>{if(C)return;let H=l.ownerDocument,I=H.body;if(!I)return;C=ro(H,"div","persona-clear-chat-tooltip"),C.textContent=u;let L=ro(H,"div");L.className="persona-clear-chat-tooltip-arrow",C.appendChild(L);let O=l.getBoundingClientRect();C.style.position="fixed",C.style.zIndex=String(Uo),C.style.left=`${O.left+O.width/2}px`,C.style.top=`${O.top-8}px`,C.style.transform="translate(-50%, -100%)",I.appendChild(C)},E=()=>{C&&C.parentNode&&(C.parentNode.removeChild(C),C=null)};d.addEventListener("mouseenter",w),d.addEventListener("mouseleave",E),l.addEventListener("focus",w),l.addEventListener("blur",E),d._cleanupTooltip=()=>{E(),d.removeEventListener("mouseenter",w),d.removeEventListener("mouseleave",E),l.removeEventListener("focus",w),l.removeEventListener("blur",E)}}return{button:l,wrapper:d}},Tv="persona-relative persona-ml-auto persona-clear-chat-button-wrapper",Bl=(r,e={})=>{var C,w,E,H,I,L,O,$,te,xe,Je,we,De;let{wrapperClassName:t=Tv,buttonSize:n,iconSize:o="20px"}=e,s=(w=((C=r==null?void 0:r.launcher)!=null?C:{}).clearChat)!=null?w:{},i=(E=n!=null?n:s.size)!=null?E:"32px",d=(H=s.iconName)!=null?H:"refresh-cw",l=(I=s.iconColor)!=null?I:"",u=(L=s.backgroundColor)!=null?L:"",m=(O=s.borderWidth)!=null?O:"",p=($=s.borderColor)!=null?$:"",f=(te=s.borderRadius)!=null?te:"",b=(xe=s.paddingX)!=null?xe:"",h=(Je=s.paddingY)!=null?Je:"",S=(we=s.tooltipText)!=null?we:"Clear chat",T=(De=s.showTooltip)!=null?De:!0,M=v("div",t),k=v("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");k.style.height=i,k.style.width=i,k.type="button",k.setAttribute("aria-label",S),k.style.color=l||an.actionIconColor;let x=Me(d,o,"currentColor",1);if(x&&(x.style.display="block",k.appendChild(x)),u&&(k.style.backgroundColor=u,k.classList.remove("hover:persona-bg-gray-100")),m||p){let Ae=m||"0px",qe=p||"transparent";k.style.border=`${Ae} solid ${qe}`,k.classList.remove("persona-border-none")}if(f&&(k.style.borderRadius=f,k.classList.remove("persona-rounded-full")),b&&(k.style.paddingLeft=b,k.style.paddingRight=b),h&&(k.style.paddingTop=h,k.style.paddingBottom=h),M.appendChild(k),T&&S){let Ae=null,qe=()=>{if(Ae)return;let J=k.ownerDocument,re=J.body;if(!re)return;Ae=ro(J,"div","persona-clear-chat-tooltip"),Ae.textContent=S;let Q=ro(J,"div");Q.className="persona-clear-chat-tooltip-arrow",Ae.appendChild(Q);let ge=k.getBoundingClientRect();Ae.style.position="fixed",Ae.style.zIndex=String(Uo),Ae.style.left=`${ge.left+ge.width/2}px`,Ae.style.top=`${ge.top-8}px`,Ae.style.transform="translate(-50%, -100%)",re.appendChild(Ae)},He=()=>{Ae&&Ae.parentNode&&(Ae.parentNode.removeChild(Ae),Ae=null)};M.addEventListener("mouseenter",qe),M.addEventListener("mouseleave",He),k.addEventListener("focus",qe),k.addEventListener("blur",He),M._cleanupTooltip=()=>{He(),M.removeEventListener("mouseenter",qe),M.removeEventListener("mouseleave",He),k.removeEventListener("focus",qe),k.removeEventListener("blur",He)}}return{button:k,wrapper:M}};var an={titleColor:"var(--persona-header-title-fg, var(--persona-primary, #0f0f0f))",subtitleColor:"var(--persona-header-subtitle-fg, var(--persona-text-muted, var(--persona-muted, #9ca3af)))",actionIconColor:"var(--persona-header-action-icon-fg, var(--persona-muted, #9ca3af))"},Co=r=>{var C,w,E,H,I,L,O,$,te,xe,Je,we,De,Ae,qe,He;let{config:e,showClose:t=!0}=r,n=v("div","persona-widget-header persona-flex persona-items-center persona-gap-3 persona-px-6 persona-py-5");n.setAttribute("data-persona-theme-zone","header"),n.style.backgroundColor="var(--persona-header-bg, var(--persona-surface, #ffffff))",n.style.borderBottomColor="var(--persona-header-border, var(--persona-divider, #f1f5f9))",n.style.boxShadow="var(--persona-header-shadow, none)",n.style.borderBottom="var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))";let o=(C=e==null?void 0:e.launcher)!=null?C:{},a=(w=o.headerIconSize)!=null?w:"48px",s=(E=o.closeButtonPlacement)!=null?E:"inline",i=(H=o.headerIconHidden)!=null?H:!1,d=o.headerIconName,l=v("div","persona-flex persona-items-center persona-justify-center persona-rounded-xl persona-text-xl");if(l.style.height=a,l.style.width=a,l.style.backgroundColor="var(--persona-header-icon-bg, var(--persona-primary, #0f0f0f))",l.style.color="var(--persona-header-icon-fg, var(--persona-text-inverse, #ffffff))",!i)if(d){let J=parseFloat(a)||24,re=Me(d,J*.6,"currentColor",1);re?l.replaceChildren(re):l.textContent=(L=(I=e==null?void 0:e.launcher)==null?void 0:I.agentIconText)!=null?L:"\u{1F4AC}"}else if((O=e==null?void 0:e.launcher)!=null&&O.iconUrl){let J=v("img");J.src=e.launcher.iconUrl,J.alt="",J.className="persona-rounded-xl persona-object-cover",J.style.height=a,J.style.width=a,l.replaceChildren(J)}else l.textContent=(te=($=e==null?void 0:e.launcher)==null?void 0:$.agentIconText)!=null?te:"\u{1F4AC}";let u=v("div","persona-flex persona-flex-col persona-flex-1 persona-min-w-0"),m=v("span","persona-text-base persona-font-semibold");m.style.color=an.titleColor,m.textContent=(Je=(xe=e==null?void 0:e.launcher)==null?void 0:xe.title)!=null?Je:"Chat Assistant";let p=v("span","persona-text-xs");p.style.color=an.subtitleColor,p.textContent=(De=(we=e==null?void 0:e.launcher)==null?void 0:we.subtitle)!=null?De:"Here to help you get answers fast",u.append(m,p),i?n.append(u):n.append(l,u);let f=(Ae=o.clearChat)!=null?Ae:{},b=(qe=f.enabled)!=null?qe:!0,h=(He=f.placement)!=null?He:"inline",S=null,T=null;if(b){let re=Bl(e,{wrapperClassName:h==="top-right"?"persona-absolute persona-top-4 persona-z-50":"persona-relative persona-ml-auto persona-clear-chat-button-wrapper"});S=re.button,T=re.wrapper,h==="top-right"&&(T.style.right="48px"),h==="inline"&&n.appendChild(T)}let M=s==="top-right"?"persona-absolute persona-top-4 persona-right-4 persona-z-50":b&&h==="inline"?"persona-relative persona-inline-flex persona-items-center persona-justify-center":"persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center",{button:k,wrapper:x}=Wl(e,{showClose:t,wrapperClassName:M});return s!=="top-right"&&n.appendChild(x),{header:n,iconHolder:l,headerTitle:m,headerSubtitle:p,closeButton:k,closeButtonWrapper:x,clearChatButton:S,clearChatButtonWrapper:T}},ya=(r,e,t)=>{var s,i,d,l;let n=(s=t==null?void 0:t.launcher)!=null?s:{},o=(i=n.closeButtonPlacement)!=null?i:"inline",a=(l=(d=n.clearChat)==null?void 0:d.placement)!=null?l:"inline";r.appendChild(e.header),o==="top-right"&&(r.style.position="relative",r.appendChild(e.closeButtonWrapper)),e.clearChatButtonWrapper&&a==="top-right"&&(r.style.position="relative",r.appendChild(e.clearChatButtonWrapper))};function $o(r){let{items:e,onSelect:t,anchor:n,position:o="bottom-left",portal:a}=r,s=v("div","persona-dropdown-menu persona-hidden");s.setAttribute("role","menu"),s.setAttribute("data-persona-theme-zone","dropdown"),a?(s.style.position="fixed",s.style.zIndex=String(Uo)):(s.style.position="absolute",s.style.top="100%",s.style.marginTop="4px",o==="bottom-right"?s.style.right="0":s.style.left="0");for(let f of e){if(f.dividerBefore){let S=document.createElement("hr");s.appendChild(S)}let b=document.createElement("button");if(b.type="button",b.setAttribute("role","menuitem"),b.setAttribute("data-dropdown-item-id",f.id),f.destructive&&b.setAttribute("data-destructive",""),f.icon){let S=Me(f.icon,16,"currentColor",1.5);S&&b.appendChild(S)}let h=document.createElement("span");h.textContent=f.label,b.appendChild(h),b.addEventListener("click",S=>{S.stopPropagation(),u(),t(f.id)}),s.appendChild(b)}let i=null;function d(){if(!a)return;let f=n.getBoundingClientRect();s.style.top=`${f.bottom+4}px`,o==="bottom-right"?(s.style.right=`${window.innerWidth-f.right}px`,s.style.left="auto"):(s.style.left=`${f.left}px`,s.style.right="auto")}function l(){d(),s.classList.remove("persona-hidden"),requestAnimationFrame(()=>{let f=b=>{!s.contains(b.target)&&!n.contains(b.target)&&u()};document.addEventListener("click",f,!0),i=()=>document.removeEventListener("click",f,!0)})}function u(){s.classList.add("persona-hidden"),i==null||i(),i=null}function m(){s.classList.contains("persona-hidden")?l():u()}function p(){u(),s.remove()}return a&&a.appendChild(s),{element:s,show:l,hide:u,toggle:m,destroy:p}}function Dr(r){let{icon:e,label:t,size:n,strokeWidth:o,className:a,onClick:s,aria:i}=r,d=v("button","persona-icon-btn"+(a?" "+a:""));d.type="button",d.setAttribute("aria-label",t),d.title=t;let l=Me(e,n!=null?n:16,"currentColor",o!=null?o:2);if(l&&d.appendChild(l),s&&d.addEventListener("click",s),i)for(let[u,m]of Object.entries(i))d.setAttribute(u,m);return d}function oi(r){let{icon:e,label:t,variant:n="default",size:o="sm",iconSize:a,className:s,onClick:i,aria:d}=r,l="persona-label-btn";n!=="default"&&(l+=" persona-label-btn--"+n),l+=" persona-label-btn--"+o,s&&(l+=" "+s);let u=v("button",l);if(u.type="button",u.setAttribute("aria-label",t),e){let p=Me(e,a!=null?a:14,"currentColor",2);p&&u.appendChild(p)}let m=v("span");if(m.textContent=t,u.appendChild(m),i&&u.addEventListener("click",i),d)for(let[p,f]of Object.entries(d))u.setAttribute(p,f);return u}function kx(r){let{items:e,selectedId:t,onSelect:n,className:o}=r,a=v("div","persona-toggle-group"+(o?" "+o:""));a.setAttribute("role","group");let s=t,i=[];function d(){for(let u of i)u.btn.setAttribute("aria-pressed",u.id===s?"true":"false")}for(let u of e){let m;u.icon?m=Dr({icon:u.icon,label:u.label,onClick:()=>{s=u.id,d(),n(u.id)}}):(m=v("button","persona-icon-btn"),m.type="button",m.setAttribute("aria-label",u.label),m.title=u.label,m.textContent=u.label,m.addEventListener("click",()=>{s=u.id,d(),n(u.id)})),m.setAttribute("aria-pressed",u.id===s?"true":"false"),i.push({id:u.id,btn:m}),a.appendChild(m)}function l(u){s=u,d()}return{element:a,setSelected:l}}function Dl(r){var f,b;let{label:e,icon:t="chevron-down",menuItems:n,onSelect:o,position:a="bottom-left",portal:s,className:i,hover:d}=r,l=v("div","persona-combo-btn"+(i?" "+i:""));l.style.position="relative",l.style.display="inline-flex",l.style.alignItems="center",l.style.cursor="pointer",l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false"),l.setAttribute("aria-label",e);let u=v("span","persona-combo-btn-label");u.textContent=e,l.appendChild(u);let m=Me(t,14,"currentColor",2);m&&(m.style.marginLeft="4px",m.style.opacity="0.6",l.appendChild(m)),d&&(l.style.borderRadius=(f=d.borderRadius)!=null?f:"10px",l.style.padding=(b=d.padding)!=null?b:"6px 4px 6px 12px",l.style.border="1px solid transparent",l.style.transition="background-color 0.15s ease, border-color 0.15s ease",l.addEventListener("mouseenter",()=>{var h,S;l.style.backgroundColor=(h=d.background)!=null?h:"",l.style.borderColor=(S=d.border)!=null?S:""}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="",l.style.borderColor="transparent"}));let p=$o({items:n,onSelect:h=>{l.setAttribute("aria-expanded","false"),o(h)},anchor:l,position:a,portal:s});return s||l.appendChild(p.element),l.addEventListener("click",h=>{h.stopPropagation();let S=!p.element.classList.contains("persona-hidden");l.setAttribute("aria-expanded",S?"false":"true"),p.toggle()}),l.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),l.click())}),{element:l,setLabel:h=>{u.textContent=h,l.setAttribute("aria-label",h)},open:()=>{l.setAttribute("aria-expanded","true"),p.show()},close:()=>{l.setAttribute("aria-expanded","false"),p.hide()},toggle:()=>{let h=!p.element.classList.contains("persona-hidden");l.setAttribute("aria-expanded",h?"false":"true"),p.toggle()},destroy:()=>{p.destroy(),l.remove()}}}var Yp=r=>{var n;let e=Co({config:r.config,showClose:r.showClose,onClose:r.onClose,onClearChat:r.onClearChat}),t=(n=r.layoutHeaderConfig)==null?void 0:n.onTitleClick;if(t){let o=e.headerTitle.parentElement;o&&(o.style.cursor="pointer",o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.addEventListener("click",()=>t()),o.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),t())}))}return e};function Mv(r,e,t){var n,o,a;if(e!=null&&e.length)for(let s of e){let i=v("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-md persona-border-none persona-bg-transparent persona-p-0 persona-text-persona-muted hover:persona-opacity-80");if(i.type="button",i.setAttribute("aria-label",(o=(n=s.ariaLabel)!=null?n:s.label)!=null?o:s.id),s.icon){let d=Me(s.icon,14,"currentColor",2);d&&i.appendChild(d)}else s.label&&(i.textContent=s.label);if((a=s.menuItems)!=null&&a.length){let d=v("div","persona-relative");d.appendChild(i);let l=$o({items:s.menuItems,onSelect:u=>t==null?void 0:t(u),anchor:d,position:"bottom-left"});d.appendChild(l.element),i.addEventListener("click",u=>{u.stopPropagation(),l.toggle()}),r.appendChild(d)}else i.addEventListener("click",()=>t==null?void 0:t(s.id)),r.appendChild(i)}}var Zp=r=>{var M,k,x,C,w,E,H,I,L;let{config:e,showClose:t=!0,onClose:n,layoutHeaderConfig:o,onHeaderAction:a}=r,s=(M=e==null?void 0:e.launcher)!=null?M:{},i=v("div","persona-flex persona-items-center persona-justify-between persona-px-6 persona-py-4");i.setAttribute("data-persona-theme-zone","header"),i.style.backgroundColor="var(--persona-header-bg, var(--persona-surface, #ffffff))",i.style.borderBottomColor="var(--persona-header-border, var(--persona-divider, #f1f5f9))",i.style.boxShadow="var(--persona-header-shadow, none)",i.style.borderBottom="var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))";let d=o==null?void 0:o.titleMenu,l,u;if(d)l=Dl({label:(k=s.title)!=null?k:"Chat Assistant",menuItems:d.menuItems,onSelect:d.onSelect,hover:d.hover,className:""}).element,l.style.color=an.titleColor,u=(x=l.querySelector(".persona-combo-btn-label"))!=null?x:l;else{if(l=v("div","persona-flex persona-min-w-0 persona-flex-1 persona-items-center persona-gap-1"),u=v("span","persona-text-base persona-font-semibold persona-truncate"),u.style.color=an.titleColor,u.textContent=(C=s.title)!=null?C:"Chat Assistant",l.appendChild(u),Mv(l,o==null?void 0:o.trailingActions,(w=o==null?void 0:o.onAction)!=null?w:a),o!=null&&o.onTitleClick){l.style.cursor="pointer",l.setAttribute("role","button"),l.setAttribute("tabindex","0");let $=o.onTitleClick;l.addEventListener("click",te=>{te.target.closest("button")||$()}),l.addEventListener("keydown",te=>{(te.key==="Enter"||te.key===" ")&&(te.preventDefault(),$())})}let O=o==null?void 0:o.titleRowHover;O&&(l.style.borderRadius=(E=O.borderRadius)!=null?E:"10px",l.style.padding=(H=O.padding)!=null?H:"6px 4px 6px 12px",l.style.margin="-6px 0 -6px -12px",l.style.border="1px solid transparent",l.style.transition="background-color 0.15s ease, border-color 0.15s ease",l.style.width="fit-content",l.style.flex="none",l.addEventListener("mouseenter",()=>{var $,te;l.style.backgroundColor=($=O.background)!=null?$:"",l.style.borderColor=(te=O.border)!=null?te:""}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="",l.style.borderColor="transparent"}))}i.appendChild(l);let m=(I=s.closeButtonSize)!=null?I:"32px",p=v("div",""),f=v("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");f.style.height=m,f.style.width=m,f.type="button",f.setAttribute("aria-label","Close chat"),f.style.display=t?"":"none",f.style.color=s.closeButtonColor||an.actionIconColor;let b=(L=s.closeButtonIconName)!=null?L:"x",h=Me(b,"28px","currentColor",1);h?f.appendChild(h):f.textContent="\xD7",n&&f.addEventListener("click",n),p.appendChild(f),i.appendChild(p);let S=v("div");S.style.display="none";let T=v("span");return T.style.display="none",{header:i,iconHolder:S,headerTitle:u,headerSubtitle:T,closeButton:f,closeButtonWrapper:p,clearChatButton:null,clearChatButtonWrapper:null}},Fl={default:Yp,minimal:Zp},eu=r=>{var e;return(e=Fl[r])!=null?e:Fl.default},Qa=(r,e,t)=>{var s,i,d;if(e!=null&&e.render){let l=e.render({config:r,onClose:t==null?void 0:t.onClose,onClearChat:t==null?void 0:t.onClearChat,trailingActions:e.trailingActions,onAction:e.onAction}),u=v("div");u.style.display="none";let m=v("span"),p=v("span"),f=v("button");f.style.display="none";let b=v("div");return b.style.display="none",{header:l,iconHolder:u,headerTitle:m,headerSubtitle:p,closeButton:f,closeButtonWrapper:b,clearChatButton:null,clearChatButtonWrapper:null}}let n=(s=e==null?void 0:e.layout)!=null?s:"default",a=eu(n)({config:r,showClose:(d=(i=e==null?void 0:e.showCloseButton)!=null?i:t==null?void 0:t.showClose)!=null?d:!0,onClose:t==null?void 0:t.onClose,onClearChat:t==null?void 0:t.onClearChat,layoutHeaderConfig:e,onHeaderAction:e==null?void 0:e.onAction});return e&&(e.showIcon===!1&&(a.iconHolder.style.display="none"),e.showTitle===!1&&(a.headerTitle.style.display="none"),e.showSubtitle===!1&&(a.headerSubtitle.style.display="none"),e.showCloseButton===!1&&(a.closeButton.style.display="none"),e.showClearChat===!1&&a.clearChatButtonWrapper&&(a.clearChatButtonWrapper.style.display="none")),a};var Ol=r=>{var s,i;let e=v("textarea");e.setAttribute("data-persona-composer-input",""),e.placeholder=(i=(s=r==null?void 0:r.copy)==null?void 0:s.inputPlaceholder)!=null?i:"Type your message\u2026",e.className="persona-w-full persona-min-h-[24px] persona-resize-none persona-border-none persona-bg-transparent persona-text-sm persona-text-persona-primary focus:persona-outline-none focus:persona-border-none persona-composer-textarea",e.rows=1,e.style.fontFamily='var(--persona-input-font-family, var(--persona-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif))',e.style.fontWeight="var(--persona-input-font-weight, var(--persona-font-weight, 400))";let t=3,n=20;e.style.maxHeight=`${t*n}px`,e.style.overflowY="auto";let o=()=>{let d=parseFloat(e.style.maxHeight);return Number.isFinite(d)&&d>0?d:t*n},a=()=>{e.addEventListener("input",()=>{e.style.height="auto";let d=Math.min(e.scrollHeight,o());e.style.height=`${d}px`})};return e.style.border="none",e.style.outline="none",e.style.borderWidth="0",e.style.borderStyle="none",e.style.borderColor="transparent",e.addEventListener("focus",()=>{e.style.border="none",e.style.outline="none",e.style.borderWidth="0",e.style.borderStyle="none",e.style.borderColor="transparent",e.style.boxShadow="none"}),e.addEventListener("blur",()=>{e.style.border="none",e.style.outline="none"}),{textarea:e,attachAutoResize:a}},Nl=r=>{var C,w,E,H,I,L,O,$,te,xe,Je,we;let e=(C=r==null?void 0:r.sendButton)!=null?C:{},t=(w=e.useIcon)!=null?w:!1,n=(E=e.iconText)!=null?E:"\u2191",o=e.iconName,a=(H=e.stopIconName)!=null?H:"square",s=(I=e.tooltipText)!=null?I:"Send message",i=(L=e.stopTooltipText)!=null?L:"Stop generating",d=($=(O=r==null?void 0:r.copy)==null?void 0:O.sendButtonLabel)!=null?$:"Send",l=(xe=(te=r==null?void 0:r.copy)==null?void 0:te.stopButtonLabel)!=null?xe:"Stop",u=(Je=e.showTooltip)!=null?Je:!1,m=(we=e.size)!=null?we:"40px",p=e.backgroundColor,f=e.textColor,b=v("div","persona-send-button-wrapper"),h=v("button",t?"persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer":"persona-rounded-button persona-bg-persona-accent persona-px-4 persona-py-2 persona-text-sm persona-font-semibold disabled:persona-opacity-50 persona-cursor-pointer");h.type="submit",h.setAttribute("data-persona-composer-submit","");let S=null,T=null;if(t){h.style.width=m,h.style.height=m,h.style.minWidth=m,h.style.minHeight=m,h.style.fontSize="18px",h.style.lineHeight="1",h.innerHTML="",f?h.style.color=f:h.style.color="var(--persona-button-primary-fg, #ffffff)";let De=parseFloat(m)||24,Ae=(f==null?void 0:f.trim())||"currentColor";o?(S=Me(o,De,Ae,2),S?h.appendChild(S):h.textContent=n):h.textContent=n,T=Me(a,De,Ae,2),p?h.style.backgroundColor=p:h.classList.add("persona-bg-persona-primary")}else h.textContent=d,f?h.style.color=f:h.classList.add("persona-text-white");e.borderWidth&&(h.style.borderWidth=e.borderWidth,h.style.borderStyle="solid"),e.borderColor&&(h.style.borderColor=e.borderColor),e.paddingX?(h.style.paddingLeft=e.paddingX,h.style.paddingRight=e.paddingX):(h.style.paddingLeft="",h.style.paddingRight=""),e.paddingY?(h.style.paddingTop=e.paddingY,h.style.paddingBottom=e.paddingY):(h.style.paddingTop="",h.style.paddingBottom="");let M=null;u&&s&&(M=v("div","persona-send-button-tooltip"),M.textContent=s,b.appendChild(M)),h.setAttribute("aria-label",s),b.appendChild(h);let k="send";return{button:h,wrapper:b,setMode:De=>{if(De===k)return;k=De;let Ae=De==="stop"?i:s;if(h.setAttribute("aria-label",Ae),M&&(M.textContent=Ae),t){if(S&&T){let qe=De==="stop"?T:S;h.replaceChildren(qe)}}else h.textContent=De==="stop"?l:d}}},_l=r=>{var M,k,x,C,w,E,H,I,L,O,$,te;let e=(M=r==null?void 0:r.voiceRecognition)!=null?M:{};if(!(e.enabled===!0))return null;let n=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),o=((k=e.provider)==null?void 0:k.type)==="runtype";if(!(n||o))return null;let s=(C=(x=r==null?void 0:r.sendButton)==null?void 0:x.size)!=null?C:"40px",i=v("div","persona-send-button-wrapper"),d=v("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer");d.type="button",d.setAttribute("data-persona-composer-mic",""),d.setAttribute("aria-label","Start voice recognition");let l=(w=e.iconName)!=null?w:"mic",u=(E=e.iconSize)!=null?E:s,m=parseFloat(u)||24,p=(I=e.backgroundColor)!=null?I:(H=r==null?void 0:r.sendButton)==null?void 0:H.backgroundColor,f=(O=e.iconColor)!=null?O:(L=r==null?void 0:r.sendButton)==null?void 0:L.textColor;d.style.width=u,d.style.height=u,d.style.minWidth=u,d.style.minHeight=u,d.style.fontSize="18px",d.style.lineHeight="1",f?d.style.color=f:d.style.color="var(--persona-text, #111827)";let h=Me(l,m,f||"currentColor",1.5);h?d.appendChild(h):d.textContent="\u{1F3A4}",p&&(d.style.backgroundColor=p),e.borderWidth&&(d.style.borderWidth=e.borderWidth,d.style.borderStyle="solid"),e.borderColor&&(d.style.borderColor=e.borderColor),e.paddingX&&(d.style.paddingLeft=e.paddingX,d.style.paddingRight=e.paddingX),e.paddingY&&(d.style.paddingTop=e.paddingY,d.style.paddingBottom=e.paddingY),i.appendChild(d);let S=($=e.tooltipText)!=null?$:"Start voice recognition";if(((te=e.showTooltip)!=null?te:!1)&&S){let xe=v("div","persona-send-button-tooltip");xe.textContent=S,i.appendChild(xe)}return{button:d,wrapper:i}},Ul=r=>{var b,h,S,T,M,k,x,C;let e=(b=r==null?void 0:r.attachments)!=null?b:{};if(e.enabled!==!0)return null;let t=(S=(h=r==null?void 0:r.sendButton)==null?void 0:h.size)!=null?S:"40px",n=v("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2");n.style.display="none";let o=v("input");o.type="file",o.accept=((T=e.allowedTypes)!=null?T:yo).join(","),o.multiple=((M=e.maxFiles)!=null?M:4)>1,o.style.display="none",o.setAttribute("aria-label","Attach files");let a=v("div","persona-send-button-wrapper"),s=v("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button");s.type="button",s.setAttribute("aria-label",(k=e.buttonTooltipText)!=null?k:"Attach file");let i=(x=e.buttonIconName)!=null?x:"paperclip",d=t,l=parseFloat(d)||40,u=Math.round(l*.6);s.style.width=d,s.style.height=d,s.style.minWidth=d,s.style.minHeight=d,s.style.fontSize="18px",s.style.lineHeight="1",s.style.backgroundColor="transparent",s.style.color="var(--persona-primary, #111827)",s.style.border="none",s.style.borderRadius="6px",s.style.transition="background-color 0.15s ease",s.addEventListener("mouseenter",()=>{s.style.backgroundColor="var(--persona-palette-colors-black-alpha-50, rgba(0, 0, 0, 0.05))"}),s.addEventListener("mouseleave",()=>{s.style.backgroundColor="transparent"});let m=Me(i,u,"currentColor",1.5);m?s.appendChild(m):s.textContent="\u{1F4CE}",s.addEventListener("click",w=>{w.preventDefault(),o.click()}),a.appendChild(s);let p=(C=e.buttonTooltipText)!=null?C:"Attach file",f=v("div","persona-send-button-tooltip");return f.textContent=p,a.appendChild(f),{button:s,wrapper:a,input:o,previewsContainer:n}},ql=r=>{var s,i,d;let e=(s=r==null?void 0:r.statusIndicator)!=null?s:{},t=e.align==="left"?"persona-text-left":e.align==="center"?"persona-text-center":"persona-text-right",n=v("div",`persona-mt-2 ${t} persona-text-xs persona-text-persona-muted`);n.setAttribute("data-persona-composer-status","");let o=(i=e.visible)!=null?i:!0;n.style.display=o?"":"none";let a=(d=e.idleText)!=null?d:"Online";if(e.idleLink){let l=v("a");l.href=e.idleLink,l.target="_blank",l.rel="noopener noreferrer",l.textContent=a,l.style.color="inherit",l.style.textDecoration="none",n.appendChild(l)}else n.textContent=a;return n},zl=()=>v("div","persona-mb-3 persona-flex persona-flex-wrap persona-gap-2");var Ja=r=>{var b,h,S,T,M,k;let{config:e}=r,t=v("div","persona-widget-footer persona-border-t-persona-divider persona-bg-persona-surface persona-px-6 persona-py-4");t.setAttribute("data-persona-theme-zone","composer");let n=zl(),o=v("form","persona-widget-composer persona-flex persona-flex-col persona-gap-2 persona-rounded-2xl persona-border persona-border-gray-200 persona-bg-persona-input-background persona-px-4 persona-py-3");o.setAttribute("data-persona-composer-form",""),o.style.outline="none";let{textarea:a,attachAutoResize:s}=Ol(e);s();let i=Nl(e),d=_l(e),l=Ul(e),u=ql(e);l&&(l.previewsContainer.style.gap="8px",o.append(l.previewsContainer,l.input)),o.append(a);let m=v("div","persona-widget-composer__actions persona-flex persona-items-center persona-justify-between persona-w-full"),p=v("div","persona-widget-composer__left-actions persona-flex persona-items-center persona-gap-2"),f=v("div","persona-widget-composer__right-actions persona-flex persona-items-center persona-gap-1");return l&&p.append(l.wrapper),d&&f.append(d.wrapper),f.append(i.wrapper),m.append(p,f),o.append(m),o.addEventListener("click",x=>{x.target!==i.button&&x.target!==i.wrapper&&x.target!==(d==null?void 0:d.button)&&x.target!==(d==null?void 0:d.wrapper)&&x.target!==(l==null?void 0:l.button)&&x.target!==(l==null?void 0:l.wrapper)&&a.focus()}),t.append(n,o,u),{footer:t,suggestions:n,composerForm:o,textarea:a,sendButton:i.button,sendButtonWrapper:i.wrapper,micButton:(b=d==null?void 0:d.button)!=null?b:null,micButtonWrapper:(h=d==null?void 0:d.wrapper)!=null?h:null,statusText:u,attachmentButton:(S=l==null?void 0:l.button)!=null?S:null,attachmentButtonWrapper:(T=l==null?void 0:l.wrapper)!=null?T:null,attachmentInput:(M=l==null?void 0:l.input)!=null?M:null,attachmentPreviewsContainer:(k=l==null?void 0:l.previewsContainer)!=null?k:null,actionsRow:m,leftActions:p,rightActions:f,setSendButtonMode:i.setMode}};var Ex=()=>{let r=v("button","persona-pill-peek");r.type="button",r.setAttribute("data-persona-pill-peek",""),r.setAttribute("aria-label","Show conversation"),r.setAttribute("tabindex","-1");let e=v("span","persona-pill-peek__icon"),t=Me("message-square",16,"currentColor",1.5);t&&e.appendChild(t);let n=v("span","persona-pill-peek__text"),o=v("span","persona-pill-peek__caret"),a=Me("chevron-up",16,"currentColor",1.5);return a&&o.appendChild(a),r.append(e,n,o),{root:r,textNode:n}},Lx=r=>{var b,h,S,T,M,k;let{config:e}=r,t=v("div","persona-widget-footer persona-widget-footer--pill");t.setAttribute("data-persona-theme-zone","composer");let n=zl();n.style.display="none";let o=ql(e);o.style.display="none";let{textarea:a,attachAutoResize:s}=Ol(e);a.style.maxHeight="100px",s();let i=Nl(e),d=_l(e),l=Ul(e);l&&l.previewsContainer.classList.add("persona-pill-composer__previews");let u=v("form","persona-widget-composer persona-pill-composer");u.setAttribute("data-persona-composer-form",""),u.style.outline="none";let m=v("div","persona-widget-composer__left-actions persona-pill-composer__left");l&&m.append(l.wrapper);let p=v("div","persona-widget-composer__right-actions persona-pill-composer__right");d&&p.append(d.wrapper),p.append(i.wrapper),u.addEventListener("click",x=>{x.target!==i.button&&x.target!==i.wrapper&&x.target!==(d==null?void 0:d.button)&&x.target!==(d==null?void 0:d.wrapper)&&x.target!==(l==null?void 0:l.button)&&x.target!==(l==null?void 0:l.wrapper)&&a.focus()}),l&&u.append(l.input),u.append(m,a,p),l&&t.append(l.previewsContainer),t.append(u,n,o);let f=u;return{footer:t,suggestions:n,composerForm:u,textarea:a,sendButton:i.button,sendButtonWrapper:i.wrapper,micButton:(b=d==null?void 0:d.button)!=null?b:null,micButtonWrapper:(h=d==null?void 0:d.wrapper)!=null?h:null,statusText:o,attachmentButton:(S=l==null?void 0:l.button)!=null?S:null,attachmentButtonWrapper:(T=l==null?void 0:l.wrapper)!=null?T:null,attachmentInput:(M=l==null?void 0:l.input)!=null?M:null,attachmentPreviewsContainer:(k=l==null?void 0:l.previewsContainer)!=null?k:null,actionsRow:f,leftActions:m,rightActions:p,setSendButtonMode:i.setMode}};var Px=r=>{var u,m,p,f,b,h,S,T,M,k,x,C,w,E,H,I,L;let e=(m=(u=r==null?void 0:r.launcher)==null?void 0:u.enabled)!=null?m:!0,t=Pr(r);if(zo(r)){let O=(f=(p=r==null?void 0:r.launcher)==null?void 0:p.composerBar)!=null?f:{},$=v("div","persona-widget-wrapper persona-fixed persona-transition");$.setAttribute("data-persona-composer-bar",""),$.dataset.state="collapsed",$.dataset.expandedSize=(b=O.expandedSize)!=null?b:"anchored",$.style.zIndex=String((S=(h=r==null?void 0:r.launcher)==null?void 0:h.zIndex)!=null?S:Xr);let te=v("div","persona-widget-panel persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col");te.style.width="100%",$.appendChild(te);let xe=v("div","persona-widget-pill-root");return xe.setAttribute("data-persona-composer-bar",""),xe.dataset.state="collapsed",xe.dataset.expandedSize=(T=O.expandedSize)!=null?T:"anchored",xe.style.zIndex=String((k=(M=r==null?void 0:r.launcher)==null?void 0:M.zIndex)!=null?k:Xr),{wrapper:$,panel:te,pillRoot:xe}}if(t){let O=v("div","persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col"),$=v("div","persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col");return O.appendChild($),{wrapper:O,panel:$}}if(!e){let O=v("div","persona-relative persona-h-full persona-flex persona-flex-col persona-flex-1 persona-min-h-0"),$=v("div","persona-relative persona-flex-1 persona-flex persona-flex-col persona-min-h-0"),te=(C=(x=r==null?void 0:r.launcher)==null?void 0:x.width)!=null?C:"100%";return O.style.width=te,$.style.width="100%",O.appendChild($),{wrapper:O,panel:$}}let o=(w=r==null?void 0:r.launcher)!=null?w:{},a=o.position&&jn[o.position]?jn[o.position]:jn["bottom-right"],s=v("div",`persona-widget-wrapper persona-fixed ${a} persona-transition`);s.style.zIndex=String((H=(E=r==null?void 0:r.launcher)==null?void 0:E.zIndex)!=null?H:Xr);let i=v("div","persona-widget-panel persona-relative persona-min-h-[320px]"),d=(L=(I=r==null?void 0:r.launcher)==null?void 0:I.width)!=null?L:r==null?void 0:r.launcherWidth,l=d!=null?d:An;return i.style.width=l,i.style.maxWidth=l,s.appendChild(i),{wrapper:s,panel:i}},kv=(r,e)=>{var x,C,w,E,H,I,L,O,$;let t=v("div","persona-widget-container persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary");t.setAttribute("data-persona-theme-zone","container");let{button:n,wrapper:o}=Wl(r,{showClose:e,wrapperClassName:"persona-composer-bar-close",buttonSize:"16px",iconSize:"14px"});o.style.position="absolute",o.style.top="8px",o.style.right="8px",o.style.zIndex="10";let a=(w=(C=(x=r==null?void 0:r.launcher)==null?void 0:x.clearChat)==null?void 0:C.enabled)!=null?w:!0,s=null,i=null;if(a){let te=Bl(r,{wrapperClassName:"persona-composer-bar-clear-chat",buttonSize:"16px",iconSize:"14px"});s=te.button,i=te.wrapper,i.style.position="absolute",i.style.top="8px",i.style.right="32px",i.style.zIndex="10"}let d=v("span","persona-widget-header");d.setAttribute("data-persona-theme-zone","header"),d.style.display="none";let l=v("div","persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6");l.style.paddingTop="48px",l.id="persona-scroll-container",l.setAttribute("data-persona-theme-zone","messages"),l.style.setProperty("scrollbar-gutter","stable");let u=v("div","persona-rounded-2xl persona-bg-persona-surface persona-p-6");u.style.boxShadow="var(--persona-intro-card-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",u.setAttribute("data-persona-intro-card","");let m=v("h2","persona-text-lg persona-font-semibold persona-text-persona-primary");m.textContent=(H=(E=r==null?void 0:r.copy)==null?void 0:E.welcomeTitle)!=null?H:"Hello \u{1F44B}";let p=v("p","persona-mt-2 persona-text-sm persona-text-persona-muted");p.textContent=(L=(I=r==null?void 0:r.copy)==null?void 0:I.welcomeSubtitle)!=null?L:"Ask anything about your account or products.",u.append(m,p);let f=v("div","persona-flex persona-flex-col persona-gap-3"),b=(O=r==null?void 0:r.layout)==null?void 0:O.contentMaxWidth;b&&(f.style.maxWidth=b,f.style.marginLeft="auto",f.style.marginRight="auto",f.style.width="100%"),(($=r==null?void 0:r.copy)==null?void 0:$.showWelcomeCard)!==!1||(u.style.display="none",l.classList.remove("persona-gap-6"),l.classList.add("persona-gap-3")),l.append(u,f);let S=v("div","persona-composer-overlay persona-pointer-events-none");S.setAttribute("data-persona-composer-overlay",""),S.style.position="absolute",S.style.left="0",S.style.right="0",S.style.bottom="0",S.style.zIndex="20";let T=Lx({config:r}),{root:M,textNode:k}=Ex();return t.append(d,o,l,S),i&&t.appendChild(i),{container:t,body:l,messagesWrapper:f,composerOverlay:S,suggestions:T.suggestions,textarea:T.textarea,sendButton:T.sendButton,sendButtonWrapper:T.sendButtonWrapper,micButton:T.micButton,micButtonWrapper:T.micButtonWrapper,composerForm:T.composerForm,statusText:T.statusText,introTitle:m,introSubtitle:p,closeButton:n,closeButtonWrapper:o,clearChatButton:s,clearChatButtonWrapper:i,iconHolder:v("span"),headerTitle:v("span"),headerSubtitle:v("span"),header:d,footer:T.footer,attachmentButton:T.attachmentButton,attachmentButtonWrapper:T.attachmentButtonWrapper,attachmentInput:T.attachmentInput,attachmentPreviewsContainer:T.attachmentPreviewsContainer,actionsRow:T.actionsRow,leftActions:T.leftActions,rightActions:T.rightActions,setSendButtonMode:T.setSendButtonMode,peekBanner:M,peekTextNode:k}},Rx=(r,e=!0)=>{var S,T,M,k,x,C,w,E,H;if(zo(r))return kv(r,e);let t=v("div","persona-widget-container persona-flex persona-h-full persona-w-full persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary persona-bg-persona-surface persona-rounded-2xl persona-overflow-hidden persona-border persona-border-persona-border");t.setAttribute("data-persona-theme-zone","container");let n=(S=r==null?void 0:r.layout)==null?void 0:S.header,o=((T=r==null?void 0:r.layout)==null?void 0:T.showHeader)!==!1,a=n?Qa(r,n,{showClose:e}):Co({config:r,showClose:e}),s=v("div","persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6");s.id="persona-scroll-container",s.setAttribute("data-persona-theme-zone","messages"),s.style.setProperty("scrollbar-gutter","stable");let i=v("div","persona-rounded-2xl persona-bg-persona-surface persona-p-6");i.style.boxShadow=Pr(r)?"none":"var(--persona-intro-card-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))";let d=v("h2","persona-text-lg persona-font-semibold persona-text-persona-primary");d.textContent=(k=(M=r==null?void 0:r.copy)==null?void 0:M.welcomeTitle)!=null?k:"Hello \u{1F44B}";let l=v("p","persona-mt-2 persona-text-sm persona-text-persona-muted");l.textContent=(C=(x=r==null?void 0:r.copy)==null?void 0:x.welcomeSubtitle)!=null?C:"Ask anything about your account or products.",i.append(d,l);let u=v("div","persona-flex persona-flex-col persona-gap-3"),m=(w=r==null?void 0:r.layout)==null?void 0:w.contentMaxWidth;m&&(u.style.maxWidth=m,u.style.marginLeft="auto",u.style.marginRight="auto",u.style.width="100%"),i.setAttribute("data-persona-intro-card",""),((E=r==null?void 0:r.copy)==null?void 0:E.showWelcomeCard)!==!1||(i.style.display="none",s.classList.remove("persona-gap-6"),s.classList.add("persona-gap-3")),s.append(i,u);let f=Ja({config:r}),b=((H=r==null?void 0:r.layout)==null?void 0:H.showFooter)!==!1;o?ya(t,a,r):(a.header.style.display="none",ya(t,a,r)),t.append(s);let h=v("div","persona-composer-overlay persona-pointer-events-none");return h.setAttribute("data-persona-composer-overlay",""),h.style.position="absolute",h.style.left="0",h.style.right="0",h.style.bottom="0",h.style.zIndex="20",b||(f.footer.style.display="none"),t.append(f.footer),t.append(h),{container:t,body:s,messagesWrapper:u,composerOverlay:h,suggestions:f.suggestions,textarea:f.textarea,sendButton:f.sendButton,sendButtonWrapper:f.sendButtonWrapper,micButton:f.micButton,micButtonWrapper:f.micButtonWrapper,composerForm:f.composerForm,statusText:f.statusText,introTitle:d,introSubtitle:l,closeButton:a.closeButton,closeButtonWrapper:a.closeButtonWrapper,clearChatButton:a.clearChatButton,clearChatButtonWrapper:a.clearChatButtonWrapper,iconHolder:a.iconHolder,headerTitle:a.headerTitle,headerSubtitle:a.headerSubtitle,header:a.header,footer:f.footer,attachmentButton:f.attachmentButton,attachmentButtonWrapper:f.attachmentButtonWrapper,attachmentInput:f.attachmentInput,attachmentPreviewsContainer:f.attachmentPreviewsContainer,actionsRow:f.actionsRow,leftActions:f.leftActions,rightActions:f.rightActions,setSendButtonMode:f.setSendButtonMode}};var Ev=r=>{switch(r){case"max_tool_calls":return"Stopped after calling a tool. Send a follow-up to continue.";case"length":return"Response cut off as max tokens reached. Ask for more to continue.";case"content_filter":return"The provider filtered this response.";case"error":return"Something went wrong generating this response.";default:return null}},Lv=(r,e)=>{if(!r)return null;let t=Ev(r);if(t===null)return null;let n=e==null?void 0:e[r],o=n!==void 0?n:t;return o||null},Pv=(r,e)=>{let t=v("div","persona-message-stop-reason persona-text-xs persona-mt-2 persona-italic");return t.setAttribute("data-stop-reason",r),t.setAttribute("role","note"),t.style.opacity="0.75",t.textContent=e,t},Rv=r=>{let e=r.toLowerCase();return e.startsWith("data:image/svg+xml")?!1:!!(/^(?:https?|blob):/i.test(r)||e.startsWith("data:image/")||!r.includes(":"))},tu=r=>{let e=r.toLowerCase();return e.startsWith("javascript:")||e.startsWith("data:text/html")||e.startsWith("data:text/javascript")||e.startsWith("data:text/xml")||e.startsWith("data:application/xhtml")||e.startsWith("data:image/svg+xml")?!1:!!(/^(?:https?|blob):/i.test(r)||e.startsWith("data:")||!r.includes(":"))},ru=320,Hx=320,Iv=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="image"&&typeof e.image=="string"&&e.image.trim().length>0),Hv=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="audio"&&typeof e.audio=="string"&&e.audio.trim().length>0),Wv=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="video"&&typeof e.video=="string"&&e.video.trim().length>0),Bv=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="file"&&typeof e.data=="string"&&e.data.trim().length>0),Dv=(r,e,t)=>{if(r.length===0)return null;try{let n=v("div","persona-flex persona-flex-col persona-gap-2");n.setAttribute("data-message-attachments","images"),e&&(n.style.marginBottom="8px");let o=0,a=!1,s=()=>{a||(a=!0,n.remove(),t==null||t())};return r.forEach((i,d)=>{var m;let l=v("img");l.alt=((m=i.alt)==null?void 0:m.trim())||`Attached image ${d+1}`,l.loading="lazy",l.decoding="async",l.referrerPolicy="no-referrer",l.style.display="block",l.style.width="100%",l.style.maxWidth=`${ru}px`,l.style.maxHeight=`${Hx}px`,l.style.height="auto",l.style.objectFit="contain",l.style.borderRadius="10px",l.style.backgroundColor="var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))",l.style.border="1px solid var(--persona-attachment-image-border, var(--persona-border, #e5e7eb))";let u=!1;o+=1,l.addEventListener("error",()=>{u||(u=!0,o=Math.max(0,o-1),l.remove(),o===0&&s())}),l.addEventListener("load",()=>{u=!0}),Rv(i.image)?(l.src=i.image,n.appendChild(l)):(u=!0,o=Math.max(0,o-1),l.remove())}),o===0?(s(),null):n}catch{return t==null||t(),null}},Fv=r=>{if(r.length===0)return null;try{let e=v("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","audio");let t=0;return r.forEach(n=>{if(!tu(n.audio))return;let o=v("audio");o.controls=!0,o.preload="metadata",o.src=n.audio,o.style.display="block",o.style.width="100%",o.style.maxWidth=`${ru}px`,e.appendChild(o),t+=1}),t===0?(e.remove(),null):e}catch{return null}},Ov=r=>{if(r.length===0)return null;try{let e=v("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","video");let t=0;return r.forEach(n=>{if(!tu(n.video))return;let o=v("video");o.controls=!0,o.preload="metadata",o.src=n.video,o.style.display="block",o.style.width="100%",o.style.maxWidth=`${ru}px`,o.style.maxHeight=`${Hx}px`,o.style.borderRadius="10px",o.style.backgroundColor="var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))",e.appendChild(o),t+=1}),t===0?(e.remove(),null):e}catch{return null}},Nv=r=>{if(r.length===0)return null;try{let e=v("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","files");let t=0;return r.forEach(n=>{if(!tu(n.data))return;let o=v("a");o.href=n.data,o.download=n.filename,o.target="_blank",o.rel="noopener noreferrer",o.textContent=n.filename,o.className="persona-message-file-attachment",o.style.display="inline-flex",o.style.alignItems="center",o.style.gap="6px",o.style.padding="6px 10px",o.style.borderRadius="8px",o.style.fontSize="0.875rem",o.style.textDecoration="underline",o.style.backgroundColor="var(--persona-attachment-file-bg, var(--persona-container, #f3f4f6))",o.style.border="1px solid var(--persona-attachment-file-border, var(--persona-border, #e5e7eb))",o.style.color="inherit",e.appendChild(o),t+=1}),t===0?(e.remove(),null):e}catch{return null}},va=()=>{let r=document.createElement("div");r.className="persona-flex persona-items-center persona-space-x-1 persona-h-5 persona-mt-2";let e=document.createElement("div");e.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",e.style.backgroundColor="currentColor",e.style.opacity="0.4",e.style.animationDelay="0ms";let t=document.createElement("div");t.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",t.style.backgroundColor="currentColor",t.style.opacity="0.4",t.style.animationDelay="250ms";let n=document.createElement("div");n.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",n.style.backgroundColor="currentColor",n.style.opacity="0.4",n.style.animationDelay="500ms";let o=document.createElement("span");return o.className="persona-sr-only",o.textContent="Loading",r.appendChild(e),r.appendChild(t),r.appendChild(n),r.appendChild(o),r},nu=(r,e,t)=>{let n={config:t!=null?t:{},streaming:!0,location:r,defaultRenderer:va};if(e){let o=e(n);if(o!==null)return o}return va()},_v=(r,e)=>{let t=v("div","persona-flex-shrink-0 persona-w-8 persona-h-8 persona-rounded-full persona-flex persona-items-center persona-justify-center persona-text-sm"),n=e==="user"?r.userAvatar:r.assistantAvatar;if(n)if(n.startsWith("http")||n.startsWith("/")||n.startsWith("data:")){let o=v("img");o.src=n,o.alt=e==="user"?"User":"Assistant",o.className="persona-w-full persona-h-full persona-rounded-full persona-object-cover",t.appendChild(o)}else t.textContent=n,t.classList.add(e==="user"?"persona-bg-persona-accent":"persona-bg-persona-primary","persona-text-white");else t.textContent=e==="user"?"U":"A",t.classList.add(e==="user"?"persona-bg-persona-accent":"persona-bg-persona-primary","persona-text-white");return t},Ix=(r,e)=>{let t=v("div","persona-text-xs persona-text-persona-muted"),n=new Date(r.createdAt);return e.format?t.textContent=e.format(n):t.textContent=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),t},Uv=(r,e="bubble")=>{let t=["persona-message-bubble","persona-max-w-[85%]"];switch(e){case"flat":r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-text-persona-primary","persona-py-2"):t.push("persona-message-assistant-bubble","persona-text-persona-primary","persona-py-2");break;case"minimal":t.push("persona-text-sm","persona-leading-relaxed"),r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-bg-persona-accent","persona-text-white","persona-px-3","persona-py-2","persona-rounded-lg"):t.push("persona-message-assistant-bubble","persona-bg-persona-surface","persona-text-persona-primary","persona-px-3","persona-py-2","persona-rounded-lg");break;default:t.push("persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm"),r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-bg-persona-accent","persona-text-white","persona-px-5","persona-py-3"):t.push("persona-message-assistant-bubble","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-px-5","persona-py-3");break}return t},ou=(r,e,t)=>{var f,b,h,S,T,M;let n=(f=e.showCopy)!=null?f:!0,o=(b=e.showUpvote)!=null?b:!0,a=(h=e.showDownvote)!=null?h:!0;if(!n&&!o&&!a){let k=v("div");return k.style.display="none",k.id=`actions-${r.id}`,k.setAttribute("data-actions-for",r.id),k}let s=(S=e.visibility)!=null?S:"hover",i=(T=e.align)!=null?T:"right",d=(M=e.layout)!=null?M:"pill-inside",l={left:"persona-message-actions-left",center:"persona-message-actions-center",right:"persona-message-actions-right"}[i],u={"pill-inside":"persona-message-actions-pill","row-inside":"persona-message-actions-row"}[d],m=v("div",`persona-message-actions persona-flex persona-items-center persona-gap-1 persona-mt-2 ${l} ${u} ${s==="hover"?"persona-message-actions-hover":""}`);m.id=`actions-${r.id}`,m.setAttribute("data-actions-for",r.id);let p=(k,x,C)=>{let w=Dr({icon:k,label:x,size:14,className:"persona-message-action-btn"});return w.setAttribute("data-action",C),w};return n&&m.appendChild(p("copy","Copy message","copy")),o&&m.appendChild(p("thumbs-up","Upvote","upvote")),a&&m.appendChild(p("thumbs-down","Downvote","downvote")),m},Ya=(r,e,t,n,o,a)=>{var J,re,Q,ge,Z,G,pe,ke,le,ne,de,Et,wt,We,he,at,Re;let s=t!=null?t:{},i=(J=s.layout)!=null?J:"bubble",d=s.avatar,l=s.timestamp,u=(re=d==null?void 0:d.show)!=null?re:!1,m=(Q=l==null?void 0:l.show)!=null?Q:!1,p=(ge=d==null?void 0:d.position)!=null?ge:"left",f=(Z=l==null?void 0:l.position)!=null?Z:"below",b=Uv(r.role,i),h=v("div",b.join(" "));h.id=`bubble-${r.id}`,h.setAttribute("data-message-id",r.id),h.setAttribute("data-persona-theme-zone",r.role==="user"?"user-message":"assistant-message"),r.role==="user"?(h.style.backgroundColor="var(--persona-message-user-bg, var(--persona-accent))",h.style.color="var(--persona-message-user-text, white)"):r.role==="assistant"&&(h.style.backgroundColor="var(--persona-message-assistant-bg, var(--persona-surface))",h.style.color="var(--persona-message-assistant-text, var(--persona-text))");let S=Iv(r),T=(pe=(G=r.content)==null?void 0:G.trim())!=null?pe:"",k=S.length>0&&T===al,x=Rl((le=(ke=a==null?void 0:a.widgetConfig)==null?void 0:ke.features)==null?void 0:le.streamAnimation),C=(Et=(de=(ne=a==null?void 0:a.widgetConfig)==null?void 0:ne.features)==null?void 0:de.streamAnimation)==null?void 0:Et.plugins,w=r.role==="assistant"&&x.type!=="none"?Ys(x.type,C):null,E=r.role==="assistant"&&((wt=w==null?void 0:w.isAnimating)==null?void 0:wt.call(w,r))===!0,H=r.role==="assistant"&&w!==null&&(!!r.streaming||E);H&&(w!=null&&w.bubbleClass)&&h.classList.add(w.bubbleClass);let I=document.createElement("div");I.classList.add("persona-message-content"),H&&w&&(w.containerClass&&I.classList.add(w.containerClass),I.style.setProperty("--persona-stream-step",`${x.speed}ms`),I.style.setProperty("--persona-stream-duration",`${x.duration}ms`));let L=H?Il((We=r.content)!=null?We:"",x.buffer,w,r,!!r.streaming):(he=r.content)!=null?he:"",O=e({text:L,message:r,streaming:!!r.streaming,raw:r.rawContent}),$=O;H&&(w==null?void 0:w.wrap)==="char"?$=Zs(O,"char",r.id,{skipTags:w.skipTags}):H&&(w==null?void 0:w.wrap)==="word"&&($=Zs(O,"word",r.id,{skipTags:w.skipTags}));let te=null;if(k?(te=document.createElement("div"),te.innerHTML=$,te.style.display="none",I.appendChild(te)):I.innerHTML=$,H&&(w!=null&&w.useCaret)&&!k&&T){let j=Hl(),ue=I.querySelectorAll(".persona-stream-char, .persona-stream-word"),nt=ue[ue.length-1];if(nt!=null&&nt.parentNode)nt.parentNode.insertBefore(j,nt.nextSibling);else{let Rt=I.lastElementChild;Rt?Rt.appendChild(j):I.appendChild(j)}}if(m&&f==="inline"&&r.createdAt){let j=Ix(r,l);j.classList.add("persona-ml-2","persona-inline"),I.appendChild(j)}if(S.length>0){let j=Dv(S,!k&&!!T,()=>{k&&te&&(te.style.display="")});j?h.appendChild(j):k&&te&&(te.style.display="")}let xe=Hv(r);if(xe.length>0){let j=Fv(xe);j&&h.appendChild(j)}let Je=Wv(r);if(Je.length>0){let j=Ov(Je);j&&h.appendChild(j)}let we=Bv(r);if(we.length>0){let j=Nv(we);j&&h.appendChild(j)}if(h.appendChild(I),m&&f==="below"&&r.createdAt){let j=Ix(r,l);j.classList.add("persona-mt-1"),h.appendChild(j)}let De=r.role==="assistant"?Lv(r.stopReason,(Re=(at=a==null?void 0:a.widgetConfig)==null?void 0:at.copy)==null?void 0:Re.stopReasonNotice):null;if(r.streaming&&r.role==="assistant"){let j=!!(L&&L.trim()),ue=x.placeholder==="skeleton",nt=ue&&x.buffer==="line"&&j;if(j)nt&&h.appendChild(ei());else if(ue)h.appendChild(ei());else{let Rt=nu("inline",a==null?void 0:a.loadingIndicatorRenderer,a==null?void 0:a.widgetConfig);Rt&&h.appendChild(Rt)}}if(De&&r.stopReason&&!r.streaming&&(T||(I.style.display="none"),h.appendChild(Pv(r.stopReason,De))),r.role==="assistant"&&!r.streaming&&r.content&&r.content.trim()&&(n==null?void 0:n.enabled)!==!1&&n){let j=ou(r,n,o);h.appendChild(j)}if(!u||r.role==="system")return h;let qe=v("div",`persona-flex persona-gap-2 ${r.role==="user"?"persona-flex-row-reverse":""}`),He=_v(d,r.role);return p==="right"||p==="left"&&r.role==="user"?qe.append(h,He):qe.append(He,h),h.classList.remove("persona-max-w-[85%]"),h.classList.add("persona-max-w-[calc(85%-2.5rem)]"),qe},Wx=(r,e,t,n,o,a)=>{let s=t!=null?t:{};return r.role==="user"&&s.renderUserMessage?s.renderUserMessage({message:r,config:{},streaming:!!r.streaming}):r.role==="assistant"&&s.renderAssistantMessage?s.renderAssistantMessage({message:r,config:{},streaming:!!r.streaming}):Ya(r,e,t,n,o,a)};var Za=new Set,qv=(r,e)=>e==null?!1:typeof e=="string"?(r.textContent=e,!0):(r.appendChild(e),!0),zv=(r,e)=>{var n,o;let t=(o=(n=r.reasoning)==null?void 0:n.chunks.join("").trim())!=null?o:"";return t?t.split(/\r?\n/).map(a=>a.trim()).filter(Boolean).slice(0,e).join(`
|
|
71
|
-
`):""},
|
|
72
|
-
`);let
|
|
73
|
-
`):""},jv=(r,e)=>{var u,m,p,f,b;let t=r.toolCall,n=(u=e==null?void 0:e.features)==null?void 0:u.toolCallDisplay,o=(m=n==null?void 0:n.collapsedMode)!=null?m:"tool-call",a=Vv(r,(p=n==null?void 0:n.previewMaxLines)!=null?p:3),s=t?Vh(t):"";if(!t)return{summary:s,previewText:a,isActive:!1};let i=t.status!=="complete",d=(f=e==null?void 0:e.toolCall)!=null?f:{},l=s;return o==="tool-name"?l=((b=t.name)==null?void 0:b.trim())||s:o==="tool-preview"&&a&&(l=a),i&&d.activeTextTemplate?l=zd(t,d.activeTextTemplate,l):!i&&d.completeTextTemplate&&(l=zd(t,d.completeTextTemplate,l)),{summary:l,previewText:a,isActive:i}},Dx=(r,e,t)=>{var u;let n=es.has(r),o=(u=t==null?void 0:t.toolCall)!=null?u:{},a=e.querySelector('button[data-expand-header="true"]'),s=e.querySelector(".persona-border-t"),i=e.querySelector('[data-persona-collapsed-preview="tool"]');if(!a||!s)return;a.setAttribute("aria-expanded",n?"true":"false");let d=a.querySelector(".persona-ml-auto"),l=d==null?void 0:d.querySelector(":scope > .persona-flex.persona-items-center");if(l){l.innerHTML="";let m=o.toggleTextColor||o.headerTextColor||"currentColor",p=Me(n?"chevron-up":"chevron-down",16,m,2);p?l.appendChild(p):l.textContent=n?"Hide":"Show"}s.style.display=n?"":"none",i&&(i.style.display=n?"none":i.textContent||i.childNodes.length?"":"none")},su=(r,e)=>{var $,te,xe,Je,we,De,Ae,qe,He;let t=r.toolCall,n=($=e==null?void 0:e.toolCall)!=null?$:{},o=v("div",["persona-message-bubble","persona-tool-bubble","persona-w-full","persona-max-w-[85%]","persona-rounded-2xl","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-shadow-sm","persona-overflow-hidden","persona-px-0","persona-py-0"].join(" "));if(o.id=`bubble-${r.id}`,o.setAttribute("data-message-id",r.id),n.backgroundColor&&(o.style.backgroundColor=n.backgroundColor),n.borderColor&&(o.style.borderColor=n.borderColor),n.borderWidth&&(o.style.borderWidth=n.borderWidth),n.borderRadius&&(o.style.borderRadius=n.borderRadius),o.style.boxShadow=n.shadow!==void 0?n.shadow.trim()===""?"none":n.shadow:"var(--persona-tool-bubble-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",!t)return o;let a=(xe=(te=e==null?void 0:e.features)==null?void 0:te.toolCallDisplay)!=null?xe:{},s=a.expandable!==!1,i=s&&es.has(r.id),{summary:d,previewText:l,isActive:u}=jv(r,e),m=v("button",s?"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none":"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-default persona-border-none");m.type="button",s&&(m.setAttribute("aria-expanded",i?"true":"false"),m.setAttribute("data-expand-header","true")),m.setAttribute("data-bubble-type","tool"),n.headerBackgroundColor&&(m.style.backgroundColor=n.headerBackgroundColor),n.headerPaddingX&&(m.style.paddingLeft=n.headerPaddingX,m.style.paddingRight=n.headerPaddingX),n.headerPaddingY&&(m.style.paddingTop=n.headerPaddingY,m.style.paddingBottom=n.headerPaddingY);let p=v("div","persona-flex persona-flex-col persona-text-left"),f=v("span","persona-text-xs persona-text-persona-primary");n.headerTextColor&&(f.style.color=n.headerTextColor);let b=String((Je=t.startedAt)!=null?Je:Date.now()),h=()=>{let J=v("span","");return J.setAttribute("data-tool-elapsed",b),J.textContent=zs(t),J},S=(De=n.renderCollapsedSummary)==null?void 0:De.call(n,{message:r,toolCall:t,defaultSummary:d,previewText:l,collapsedMode:(we=a.collapsedMode)!=null?we:"tool-call",isActive:u,config:e!=null?e:{},elapsed:zs(t),createElapsedElement:h});typeof S=="string"&&S.trim()?(f.textContent=S,p.appendChild(f)):S instanceof HTMLElement?p.appendChild(S):(f.textContent=d,p.appendChild(f));let T=(Ae=a.loadingAnimation)!=null?Ae:"none",M=n.activeTextTemplate,k=n.completeTextTemplate,x=u?M:k,C=S instanceof HTMLElement,w=(J,re,Q)=>{let ge=Q;for(let Z of re){let G=v("span","persona-tool-char");G.style.setProperty("--char-index",String(ge)),G.textContent=Z===" "?"\xA0":Z,J.appendChild(G),ge++}return ge},E=(J,re)=>{var G;f.textContent="";let Q=((G=t.name)==null?void 0:G.trim())||"tool",ge=Yi(J,Q),Z=0;for(let pe of ge){let ke=pe.styles.length>0?(()=>{let le=v("span",pe.styles.map(ne=>`persona-tool-text-${ne}`).join(" "));return f.appendChild(le),le})():f;if(pe.isDuration&&u)ke.appendChild(h());else{let le=pe.isDuration?zs(t):pe.text;re?Z=w(ke,le,Z):ke.appendChild(document.createTextNode(le))}}};if(!C)if(u&&T!=="none"){let J=(qe=n.loadingAnimationDuration)!=null?qe:2e3;if(f.setAttribute("data-preserve-animation","true"),T==="pulse")f.classList.add("persona-tool-loading-pulse"),f.style.setProperty("--persona-tool-anim-duration",`${J}ms`),x&&E(x,!1);else if(f.classList.add(`persona-tool-loading-${T}`),f.style.setProperty("--persona-tool-anim-duration",`${J}ms`),T==="shimmer-color"&&(n.loadingAnimationColor&&f.style.setProperty("--persona-tool-anim-color",n.loadingAnimationColor),n.loadingAnimationSecondaryColor&&f.style.setProperty("--persona-tool-anim-secondary-color",n.loadingAnimationSecondaryColor)),x)E(x,!0);else{let re=f.textContent||d;f.textContent="",w(f,re,0)}}else x&&E(x,!1);let H=null;if(s){H=v("div","persona-flex persona-items-center");let J=n.toggleTextColor||n.headerTextColor||"currentColor",re=Me(i?"chevron-up":"chevron-down",16,J,2);re?H.appendChild(re):H.textContent=i?"Hide":"Show";let Q=v("div","persona-flex persona-items-center persona-gap-2 persona-ml-auto");Q.append(H),m.append(p,Q)}else m.append(p);let I=v("div","persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted");if(I.setAttribute("data-persona-collapsed-preview","tool"),I.style.display="none",I.style.whiteSpace="pre-wrap",!i&&u&&a.activePreview&&l){let J=(He=n.renderCollapsedPreview)==null?void 0:He.call(n,{message:r,toolCall:t,defaultPreview:l,isActive:u,config:e!=null?e:{}});$v(I,J)||(I.textContent=l),I.style.display=""}if(!i&&u&&a.activeMinHeight&&(o.style.minHeight=a.activeMinHeight),!s)return o.append(m,I),o;let L=v("div","persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-space-y-3 persona-px-4 persona-py-3");if(L.style.display=i?"":"none",n.contentBackgroundColor&&(L.style.backgroundColor=n.contentBackgroundColor),n.contentTextColor&&(L.style.color=n.contentTextColor),n.contentPaddingX&&(L.style.paddingLeft=n.contentPaddingX,L.style.paddingRight=n.contentPaddingX),n.contentPaddingY&&(L.style.paddingTop=n.contentPaddingY,L.style.paddingBottom=n.contentPaddingY),t.name){let J=v("div","persona-text-xs persona-text-persona-muted persona-italic");n.contentTextColor?J.style.color=n.contentTextColor:n.headerTextColor&&(J.style.color=n.headerTextColor),J.textContent=t.name,L.appendChild(J)}if(t.args!==void 0){let J=v("div","persona-space-y-1"),re=v("div","persona-text-xs persona-text-persona-muted");n.labelTextColor&&(re.style.color=n.labelTextColor),re.textContent="Arguments";let Q=v("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");Q.style.fontSize="0.75rem",Q.style.lineHeight="1rem",n.codeBlockBackgroundColor&&(Q.style.backgroundColor=n.codeBlockBackgroundColor),n.codeBlockBorderColor&&(Q.style.borderColor=n.codeBlockBorderColor),n.codeBlockTextColor&&(Q.style.color=n.codeBlockTextColor),Q.textContent=$a(t.args),J.append(re,Q),L.appendChild(J)}if(t.chunks&&t.chunks.length){let J=v("div","persona-space-y-1"),re=v("div","persona-text-xs persona-text-persona-muted");n.labelTextColor&&(re.style.color=n.labelTextColor),re.textContent="Activity";let Q=v("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");Q.style.fontSize="0.75rem",Q.style.lineHeight="1rem",n.codeBlockBackgroundColor&&(Q.style.backgroundColor=n.codeBlockBackgroundColor),n.codeBlockBorderColor&&(Q.style.borderColor=n.codeBlockBorderColor),n.codeBlockTextColor&&(Q.style.color=n.codeBlockTextColor),Q.textContent=t.chunks.join(""),J.append(re,Q),L.appendChild(J)}if(t.status==="complete"&&t.result!==void 0){let J=v("div","persona-space-y-1"),re=v("div","persona-text-xs persona-text-persona-muted");n.labelTextColor&&(re.style.color=n.labelTextColor),re.textContent="Result";let Q=v("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");Q.style.fontSize="0.75rem",Q.style.lineHeight="1rem",n.codeBlockBackgroundColor&&(Q.style.backgroundColor=n.codeBlockBackgroundColor),n.codeBlockBorderColor&&(Q.style.borderColor=n.codeBlockBorderColor),n.codeBlockTextColor&&(Q.style.color=n.codeBlockTextColor),Q.textContent=$a(t.result),J.append(re,Q),L.appendChild(J)}if(t.status==="complete"&&typeof t.duration=="number"){let J=v("div","persona-text-xs persona-text-persona-muted");n.contentTextColor&&(J.style.color=n.contentTextColor),J.textContent=`Duration: ${t.duration}ms`,L.appendChild(J)}return(()=>{if(m.setAttribute("aria-expanded",i?"true":"false"),H){H.innerHTML="";let J=n.toggleTextColor||n.headerTextColor||"currentColor",re=Me(i?"chevron-up":"chevron-down",16,J,2);re?H.appendChild(re):H.textContent=i?"Hide":"Show"}L.style.display=i?"":"none",I.style.display=i?"none":I.textContent||I.childNodes.length?"":"none"})(),o.append(m,I,L),o};var $l=new Map,Gv=r=>{let t=(r.startsWith(go)?r.slice(go.length):r).replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_\-\s.]+/).filter(Boolean);if(t.length===0)return r;let n=t.join(" ").toLowerCase();return n.charAt(0).toUpperCase()+n.slice(1)},Fx=r=>(r==null?void 0:r.approval)!==!1?r==null?void 0:r.approval:void 0,Ox=(r,e)=>{var n,o,a;let t=(o=(n=Fx(e))==null?void 0:n.detailsDisplay)!=null?o:"collapsed";return(a=$l.get(r))!=null?a:t==="expanded"},Nx=(r,e,t)=>{var s,i;let n=Fx(t);r.setAttribute("aria-expanded",e?"true":"false");let o=r.querySelector("[data-approval-details-label]");o&&(o.textContent=e?(s=n==null?void 0:n.hideDetailsLabel)!=null?s:"Hide details":(i=n==null?void 0:n.showDetailsLabel)!=null?i:"Show details");let a=r.querySelector("[data-approval-details-chevron]");if(a){a.innerHTML="";let d=Me(e?"chevron-up":"chevron-down",14,"currentColor",2);d&&a.appendChild(d)}},_x=(r,e,t)=>{let n=e.querySelector('button[data-bubble-type="approval"]'),o=e.querySelector("[data-approval-details]");if(!n||!o)return;let a=Ox(r,t);Nx(n,a,t),o.style.display=a?"":"none"};var Vl=(r,e)=>{var E,H,I,L,O,$,te,xe,Je,we,De,Ae,qe,He,J;let t=r.approval,n=(e==null?void 0:e.approval)!==!1?e==null?void 0:e.approval:void 0,o=(t==null?void 0:t.status)==="pending",a=v("div",["persona-approval-bubble","persona-w-full","persona-max-w-[85%]","persona-rounded-2xl","persona-border","persona-shadow-sm","persona-overflow-hidden"].join(" "));if(a.id=`bubble-${r.id}`,a.setAttribute("data-message-id",r.id),a.style.backgroundColor=(E=n==null?void 0:n.backgroundColor)!=null?E:"var(--persona-approval-bg, #fefce8)",a.style.borderColor=(H=n==null?void 0:n.borderColor)!=null?H:"var(--persona-approval-border, #fef08a)",a.style.boxShadow=(n==null?void 0:n.shadow)!==void 0?n.shadow.trim()===""?"none":n.shadow:"var(--persona-approval-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",!t)return a;let s=v("div","persona-flex persona-items-start persona-gap-3 persona-px-4 persona-py-3"),i=v("div","persona-flex-shrink-0 persona-mt-0.5");i.setAttribute("data-approval-icon","true");let d=t.status==="denied"?"shield-x":t.status==="timeout"?"shield-alert":"shield-check",l=t.status==="approved"?"var(--persona-feedback-success, #16a34a)":t.status==="denied"?"var(--persona-feedback-error, #dc2626)":t.status==="timeout"?"var(--persona-feedback-warning, #ca8a04)":(I=n==null?void 0:n.titleColor)!=null?I:"currentColor",u=Me(d,20,l,2);u&&i.appendChild(u);let m=v("div","persona-flex-1 persona-min-w-0"),p=v("div","persona-flex persona-items-center persona-gap-2"),f=v("span","persona-text-sm persona-font-medium persona-text-persona-primary");if(n!=null&&n.titleColor&&(f.style.color=n.titleColor),f.textContent=(L=n==null?void 0:n.title)!=null?L:"Approval Required",p.appendChild(f),!o){let re=v("span","persona-inline-flex persona-items-center persona-px-2 persona-py-0.5 persona-rounded-full persona-text-xs persona-font-medium");re.setAttribute("data-approval-status",t.status),t.status==="approved"?(re.style.backgroundColor="var(--persona-palette-colors-success-100, #dcfce7)",re.style.color="var(--persona-palette-colors-success-700, #15803d)",re.textContent="Approved"):t.status==="denied"?(re.style.backgroundColor="var(--persona-palette-colors-error-100, #fee2e2)",re.style.color="var(--persona-palette-colors-error-700, #b91c1c)",re.textContent="Denied"):t.status==="timeout"&&(re.style.backgroundColor="var(--persona-palette-colors-warning-100, #fef3c7)",re.style.color="var(--persona-palette-colors-warning-700, #b45309)",re.textContent="Timeout"),p.appendChild(re)}m.appendChild(p);let h=t.toolType==="webmcp"||t.toolName.startsWith(go)?Rd(t.toolName):void 0,S=(O=n==null?void 0:n.formatDescription)==null?void 0:O.call(n,{toolName:t.toolName,toolType:t.toolType,description:t.description,parameters:t.parameters,...h?{displayTitle:h}:{},...t.reason?{reason:t.reason}:{}}),T=!t.toolName,M=S||(T?t.description:`The assistant wants to use \u201C${h!=null?h:Gv(t.toolName)}\u201D.`),k=v("p","persona-text-sm persona-mt-0.5 persona-text-persona-muted");if(k.setAttribute("data-approval-summary","true"),n!=null&&n.descriptionColor&&(k.style.color=n.descriptionColor),k.textContent=M,m.appendChild(k),t.reason){let re=v("p","persona-text-sm persona-mt-1 persona-text-persona-muted");re.setAttribute("data-approval-reason","true"),n!=null&&n.reasonColor?re.style.color=n.reasonColor:n!=null&&n.descriptionColor&&(re.style.color=n.descriptionColor);let Q=v("span","persona-font-medium");Q.textContent=`${($=n==null?void 0:n.reasonLabel)!=null?$:"Agent's stated reason:"} `,re.appendChild(Q),re.appendChild(document.createTextNode(t.reason)),m.appendChild(re)}let x=(te=n==null?void 0:n.detailsDisplay)!=null?te:"collapsed",C=!!t.description&&!T,w=C||!!t.parameters;if(x!=="hidden"&&w){let re=Ox(r.id,e),Q=v("button","persona-inline-flex persona-items-center persona-gap-1 persona-mt-1 persona-p-0 persona-border-none persona-bg-transparent persona-text-xs persona-font-medium persona-cursor-pointer persona-text-persona-muted");Q.type="button",Q.setAttribute("data-expand-header","true"),Q.setAttribute("data-bubble-type","approval"),n!=null&&n.descriptionColor&&(Q.style.color=n.descriptionColor);let ge=v("span");ge.setAttribute("data-approval-details-label","true");let Z=v("span","persona-inline-flex persona-items-center");Z.setAttribute("data-approval-details-chevron","true"),Q.append(ge,Z),Nx(Q,re,e),m.appendChild(Q);let G=v("div");if(G.setAttribute("data-approval-details","true"),G.style.display=re?"":"none",C){let pe=v("p","persona-text-sm persona-mt-1 persona-text-persona-muted");n!=null&&n.descriptionColor&&(pe.style.color=n.descriptionColor),pe.textContent=t.description,G.appendChild(pe)}if(t.parameters){let pe=v("pre","persona-mt-2 persona-text-xs persona-p-2 persona-rounded persona-overflow-x-auto persona-max-h-32 persona-bg-persona-container persona-text-persona-primary");n!=null&&n.parameterBackgroundColor&&(pe.style.backgroundColor=n.parameterBackgroundColor),n!=null&&n.parameterTextColor&&(pe.style.color=n.parameterTextColor),pe.style.fontSize="0.75rem",pe.style.lineHeight="1rem",pe.textContent=$a(t.parameters),G.appendChild(pe)}m.appendChild(G)}if(o){let re=v("div","persona-flex persona-gap-2 persona-mt-2");re.setAttribute("data-approval-buttons","true");let Q=v("button","persona-inline-flex persona-items-center persona-px-3 persona-py-1.5 persona-rounded-md persona-text-xs persona-font-medium persona-border-none persona-cursor-pointer");Q.type="button",Q.style.backgroundColor=(xe=n==null?void 0:n.approveButtonColor)!=null?xe:"var(--persona-approval-approve-bg, #22c55e)",Q.style.color=(Je=n==null?void 0:n.approveButtonTextColor)!=null?Je:"#ffffff",Q.setAttribute("data-approval-action","approve");let ge=Me("shield-check",14,(we=n==null?void 0:n.approveButtonTextColor)!=null?we:"#ffffff",2);ge&&(ge.style.marginRight="4px",Q.appendChild(ge));let Z=document.createTextNode((De=n==null?void 0:n.approveLabel)!=null?De:"Approve");Q.appendChild(Z);let G=v("button","persona-inline-flex persona-items-center persona-px-3 persona-py-1.5 persona-rounded-md persona-text-xs persona-font-medium persona-cursor-pointer");G.type="button",G.style.backgroundColor=(Ae=n==null?void 0:n.denyButtonColor)!=null?Ae:"transparent",G.style.color=(qe=n==null?void 0:n.denyButtonTextColor)!=null?qe:"var(--persona-feedback-error, #dc2626)",G.style.border=`1px solid ${n!=null&&n.denyButtonTextColor?n.denyButtonTextColor:"var(--persona-palette-colors-error-200, #fca5a5)"}`,G.setAttribute("data-approval-action","deny");let pe=Me("shield-x",14,(He=n==null?void 0:n.denyButtonTextColor)!=null?He:"var(--persona-feedback-error, #dc2626)",2);pe&&(pe.style.marginRight="4px",G.appendChild(pe));let ke=document.createTextNode((J=n==null?void 0:n.denyLabel)!=null?J:"Deny");G.appendChild(ke),re.append(Q,G),m.appendChild(re)}return s.append(i,m),a.appendChild(s),a};var Ux=r=>{let e=[],t=null;return{buttons:e,render:(o,a,s,i,d,l)=>{r.innerHTML="",e.length=0;let u=(l==null?void 0:l.agentPushed)===!0;if(u||(t=null),!o||!o.length||!u&&(i!=null?i:a?a.getMessages():[]).some(S=>S.role==="user"))return;let m=document.createDocumentFragment(),p=a?a.isStreaming():!1,f=b=>{switch(b){case"serif":return'Georgia, "Times New Roman", Times, serif';case"mono":return'"Courier New", Courier, "Lucida Console", Monaco, monospace';default:return'-apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif'}};if(o.forEach(b=>{let h=v("button","persona-rounded-button persona-bg-persona-surface persona-px-3 persona-py-1.5 persona-text-xs persona-font-medium persona-text-persona-primary hover:persona-opacity-80 persona-cursor-pointer persona-border persona-border-persona-border");h.type="button",h.textContent=b,h.disabled=p,d!=null&&d.fontFamily&&(h.style.fontFamily=f(d.fontFamily)),d!=null&&d.fontWeight&&(h.style.fontWeight=d.fontWeight),d!=null&&d.paddingX&&(h.style.paddingLeft=d.paddingX,h.style.paddingRight=d.paddingX),d!=null&&d.paddingY&&(h.style.paddingTop=d.paddingY,h.style.paddingBottom=d.paddingY),h.addEventListener("click",()=>{!a||a.isStreaming()||(s.value="",u&&r.dispatchEvent(new CustomEvent("persona:suggestReplies:selected",{detail:{suggestion:b},bubbles:!0,composed:!0})),a.sendMessage(b))}),m.appendChild(h),e.push(h)}),r.appendChild(m),u){let b=JSON.stringify(o);b!==t&&(t=b,r.dispatchEvent(new CustomEvent("persona:suggestReplies:shown",{detail:{suggestions:[...o]},bubbles:!0,composed:!0})))}}}};var ai=class{constructor(e=2e3,t=null){this.head=0;this.count=0;this.totalCaptured=0;this.eventTypesSet=new Set;this.maxSize=e,this.buffer=new Array(e),this.store=t}push(e){var t;this.buffer[this.head]=e,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.totalCaptured++,this.eventTypesSet.add(e.type),(t=this.store)==null||t.put(e)}getAll(){return this.count===0?[]:this.count<this.maxSize?this.buffer.slice(0,this.count):[...this.buffer.slice(this.head,this.maxSize),...this.buffer.slice(0,this.head)]}async restore(){if(!this.store)return 0;let e=await this.store.getAll();if(e.length===0)return 0;let t=e.length>this.maxSize?e.slice(e.length-this.maxSize):e;for(let n of t)this.buffer[this.head]=n,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.eventTypesSet.add(n.type);return this.totalCaptured=e.length,t.length}getAllFromStore(){return this.store?this.store.getAll():Promise.resolve(this.getAll())}getRecent(e){let t=this.getAll();return e>=t.length?t:t.slice(t.length-e)}getSize(){return this.count}getTotalCaptured(){return this.totalCaptured}getEvictedCount(){return this.totalCaptured-this.count}clear(){var e;this.buffer=new Array(this.maxSize),this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),(e=this.store)==null||e.clear()}destroy(){var e;this.buffer=[],this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),(e=this.store)==null||e.destroy()}getEventTypes(){return Array.from(this.eventTypesSet)}};var si=class{constructor(e="persona-event-stream",t="events"){this.db=null;this.pendingWrites=[];this.flushScheduled=!1;this.isDestroyed=!1;this.dbName=e,this.storeName=t}open(){return new Promise((e,t)=>{try{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let o=n.result;o.objectStoreNames.contains(this.storeName)||o.createObjectStore(this.storeName,{keyPath:"id"}).createIndex("timestamp","timestamp",{unique:!1})},n.onsuccess=()=>{this.db=n.result,e()},n.onerror=()=>{t(n.error)}}catch(n){t(n)}})}put(e){!this.db||this.isDestroyed||(this.pendingWrites.push(e),this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushWrites())))}putBatch(e){if(!(!this.db||this.isDestroyed||e.length===0))try{let n=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let o of e)n.put(o)}catch{}}getAll(){return new Promise((e,t)=>{if(!this.db){e([]);return}try{let s=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).index("timestamp").getAll();s.onsuccess=()=>{e(s.result)},s.onerror=()=>{t(s.error)}}catch(n){t(n)}})}getCount(){return new Promise((e,t)=>{if(!this.db){e(0);return}try{let a=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).count();a.onsuccess=()=>{e(a.result)},a.onerror=()=>{t(a.error)}}catch(n){t(n)}})}clear(){return new Promise((e,t)=>{if(!this.db){e();return}this.pendingWrites=[];try{let a=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).clear();a.onsuccess=()=>{e()},a.onerror=()=>{t(a.error)}}catch(n){t(n)}})}close(){this.db&&(this.db.close(),this.db=null)}destroy(){return this.isDestroyed=!0,this.pendingWrites=[],this.close(),new Promise((e,t)=>{try{let n=indexedDB.deleteDatabase(this.dbName);n.onsuccess=()=>{e()},n.onerror=()=>{t(n.error)}}catch(n){t(n)}})}flushWrites(){if(this.flushScheduled=!1,!this.db||this.isDestroyed||this.pendingWrites.length===0)return;let e=this.pendingWrites;this.pendingWrites=[];try{let n=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let o of e)n.put(o)}catch{}}};var Kv=new Set(["flow_start","flow_run_start","agent_start","dispatch_start","run_start"]),Xv=new Set(["step_start","execution_start"]),Qv=new Set(["step_delta","step_chunk","chunk","agent_turn_delta"]),Jv=new Set(["step_complete","agent_turn_complete"]),Yv=new Set(["flow_complete","agent_complete"]),qx=new Set(["step_error","flow_error","agent_error","dispatch_error","error"]),$x=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),Tn=r=>typeof r=="number"&&Number.isFinite(r)?r:void 0,Ca=(r,e)=>{let t=r[e];return $x(t)?t:void 0};function iu(r){return r>0?Math.max(1,Math.ceil(r/4)):0}function jl(r,e){if(!(r<=0||e===void 0||e<250))return r/(e/1e3)}function Zv(r,e){return typeof e.type=="string"?e.type:r}function eC(r){return typeof r.text=="string"?r.text:typeof r.delta=="string"?r.delta:typeof r.content=="string"?r.content:typeof r.chunk=="string"?r.chunk:""}function tC(r,e){return r==="step_delta"||r==="step_chunk"?e.stepType!=="tool"&&e.executionType!=="context":r!=="agent_turn_delta"?!0:(typeof e.contentType=="string"?e.contentType:typeof e.content_type=="string"?e.content_type:void 0)==="text"}function zx(r){var n,o,a,s,i;let e=Ca(r,"result"),t=[Ca(r,"tokens"),Ca(r,"totalTokens"),e?Ca(e,"tokens"):void 0,Ca(r,"usage"),e?Ca(e,"usage"):void 0];for(let d of t){if(!d)continue;let l=(o=(n=Tn(d.output))!=null?n:Tn(d.outputTokens))!=null?o:Tn(d.completionTokens);if(l!==void 0)return l}return(i=(a=Tn(r.outputTokens))!=null?a:Tn(r.completionTokens))!=null?i:e?(s=Tn(e.outputTokens))!=null?s:Tn(e.completionTokens):void 0}function rC(r){var t,n,o,a,s;let e=Ca(r,"result");return(s=(o=(n=(t=Tn(r.executionTime))!=null?t:Tn(r.executionTimeMs))!=null?n:Tn(r.execution_time))!=null?o:Tn(r.duration))!=null?s:e?(a=Tn(e.executionTime))!=null?a:Tn(e.executionTimeMs):void 0}function nC(){return typeof performance!="undefined"&&typeof performance.now=="function"?performance.now():Date.now()}var ii=class{constructor(e=nC){this.metric={status:"idle"};this.run=null;this.now=e}getMetric(){let e=this.run;if(e&&this.metric.status==="running"&&e.firstDeltaAt!==void 0&&this.metric.outputTokens!==void 0){let t=this.now()-e.firstDeltaAt;return{...this.metric,durationMs:t,tokensPerSecond:jl(this.metric.outputTokens,t)}}return this.metric}reset(){this.run=null,this.metric={status:"idle"}}startRun(e){this.run={startedAt:e,visibleCharCount:0,exactOutputTokens:0},this.metric={status:"running"}}processEvent(e,t){var a;if(!$x(t)){qx.has(e)&&this.run&&(this.run=null,this.metric={status:"error"});return}let n=Zv(e,t),o=this.now();if(Kv.has(n)){this.startRun(o);return}if(Xv.has(n)){this.run||this.startRun(o);return}if(Qv.has(n)){if(!tC(n,t))return;let s=eC(t);if(!s)return;this.run||this.startRun(o);let i=this.run;(a=i.firstDeltaAt)!=null||(i.firstDeltaAt=o),i.visibleCharCount+=s.length;let d=i.exactOutputTokens+iu(i.visibleCharCount),l=o-i.firstDeltaAt;this.metric={status:"running",tokensPerSecond:jl(d,l),outputTokens:d,durationMs:l,source:i.exactOutputTokens>0?"usage":"estimate"};return}if(Jv.has(n)){if(!this.run)return;let s=this.run,i=zx(t);i!==void 0&&(s.exactOutputTokens+=i,s.visibleCharCount=0);let d=s.exactOutputTokens>0,l=s.exactOutputTokens+iu(s.visibleCharCount),u=this.resolveDuration(s,t,o);this.metric={status:"running",tokensPerSecond:jl(l,u),outputTokens:l,durationMs:u,source:d?"usage":"estimate"};return}if(Yv.has(n)){if(!this.run)return;let s=this.run,i=zx(t),d=i!=null?i:s.exactOutputTokens+iu(s.visibleCharCount),l=i!==void 0||s.exactOutputTokens>0?"usage":"estimate",u=this.resolveDuration(s,t,o);this.metric={status:"complete",tokensPerSecond:jl(d,u),outputTokens:d,durationMs:u,source:l},this.run=null;return}if(qx.has(n)){if(!this.run)return;this.run=null,this.metric={status:"error"}}}resolveDuration(e,t,n){let o=e.firstDeltaAt!==void 0?n-e.firstDeltaAt:void 0;if(o!==void 0&&o>=250)return o;let a=rC(t);return a!=null?a:n-e.startedAt}};function ts(r,e){e&&e.split(/\s+/).forEach(t=>t&&r.classList.add(t))}var oC={flow_:{bg:"var(--persona-palette-colors-success-100, #dcfce7)",text:"var(--persona-palette-colors-success-700, #166534)"},step_:{bg:"var(--persona-palette-colors-primary-100, #f5f5f5)",text:"var(--persona-palette-colors-primary-700, #0a0a0a)"},reason_:{bg:"var(--persona-palette-colors-warning-100, #ffedd5)",text:"var(--persona-palette-colors-warning-700, #9a3412)"},tool_:{bg:"var(--persona-palette-colors-purple-100, #f3e8ff)",text:"var(--persona-palette-colors-purple-700, #6b21a8)"},agent_:{bg:"var(--persona-palette-colors-teal-100, #ccfbf1)",text:"var(--persona-palette-colors-teal-700, #115e59)"},error:{bg:"var(--persona-palette-colors-error-100, #fecaca)",text:"var(--persona-palette-colors-error-700, #991b1b)"}},aC={bg:"var(--persona-palette-colors-gray-100, #f3f4f6)",text:"var(--persona-palette-colors-gray-600, #4b5563)"},sC=["flowName","stepName","reasoningText","text","name","tool","toolName"],iC=100;function lC(r,e){let t={...oC,...e};if(t[r])return t[r];for(let n of Object.keys(t))if(n.endsWith("_")&&r.startsWith(n))return t[n];return aC}function dC(r,e){return`+${((r-e)/1e3).toFixed(3)}s`}function cC(r){let e=new Date(r),t=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0"),a=String(e.getMilliseconds()).padStart(3,"0");return`${t}:${n}:${o}.${a}`}function pC(r,e){try{let t=JSON.parse(r);if(typeof t!="object"||t===null)return null;for(let n of e){let o=n.split("."),a=t;for(let s of o)if(a&&typeof a=="object"&&a!==null)a=a[s];else{a=void 0;break}if(typeof a=="string"&&a.trim())return a.trim()}}catch{}return null}function uC(r){var e;return(e=navigator.clipboard)!=null&&e.writeText?navigator.clipboard.writeText(r):new Promise(t=>{let n=document.createElement("textarea");n.value=r,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),t()})}function fC(r){let e;try{e=JSON.parse(r.payload)}catch{e=r.payload}return JSON.stringify({type:r.type,timestamp:new Date(r.timestamp).toISOString(),payload:e},null,2)}function mC(r){return r.tokensPerSecond===void 0||!Number.isFinite(r.tokensPerSecond)?"-- tok/s":`${r.tokensPerSecond.toFixed(1)} tok/s`}function gC(r){let e=[];return r.outputTokens!==void 0&&e.push(`${r.outputTokens.toLocaleString()} tok`),r.durationMs!==void 0&&e.push(`${(r.durationMs/1e3).toFixed(2)}s`),r.source&&e.push(r.source),e.join(" \xB7 ")}function hC(r,e,t){let n,o;try{o=JSON.parse(r.payload),n=JSON.stringify(o,null,2)}catch{o=r.payload,n=r.payload}let a=e.find(i=>i.renderEventStreamPayload);if(a!=null&&a.renderEventStreamPayload&&t){let i=a.renderEventStreamPayload({event:r,config:t,defaultRenderer:()=>s(),parsedPayload:o});if(i)return i}return s();function s(){let i=v("div","persona-bg-persona-container persona-border-t persona-border-persona-divider persona-px-3 persona-py-2 persona-ml-4 persona-mr-3 persona-mb-1 persona-rounded-b persona-overflow-auto persona-max-h-[300px]"),d=v("pre","persona-m-0 persona-whitespace-pre-wrap persona-break-all persona-text-[11px] persona-text-persona-secondary persona-font-mono");return d.textContent=n,i.appendChild(d),i}}function lu(r,e,t,n,o,a,s,i){var p;let d=o.has(r.id),l=v("div","persona-border-b persona-border-persona-divider persona-text-xs");ts(l,(p=n.classNames)==null?void 0:p.eventRow);let u=s.find(f=>f.renderEventStreamRow);if(u!=null&&u.renderEventStreamRow&&i){let f=u.renderEventStreamRow({event:r,index:e,config:i,defaultRenderer:()=>m(),isExpanded:d,onToggleExpand:()=>a(r.id)});if(f)return l.appendChild(f),l}return l.appendChild(m()),l;function m(){var $,te;let f=v("div",""),b=v("div","persona-flex persona-items-center persona-gap-2 persona-px-3 persona-py-3 hover:persona-bg-persona-container persona-cursor-pointer persona-group");b.setAttribute("data-event-id",r.id);let h=v("span","persona-flex-shrink-0 persona-text-persona-muted persona-w-4 persona-text-center persona-flex persona-items-center persona-justify-center"),S=Me(d?"chevron-down":"chevron-right","14px","currentColor",2);S&&h.appendChild(S);let T=v("span","persona-text-[11px] persona-text-persona-muted persona-whitespace-nowrap persona-flex-shrink-0 persona-font-mono persona-w-[70px]"),M=($=n.timestampFormat)!=null?$:"relative";T.textContent=M==="relative"?dC(r.timestamp,t):cC(r.timestamp);let k=null;n.showSequenceNumbers!==!1&&(k=v("span","persona-text-[11px] persona-text-persona-muted persona-font-mono persona-flex-shrink-0 persona-w-[28px] persona-text-right"),k.textContent=String(e+1));let x=lC(r.type,n.badgeColors),C=v("span","persona-inline-flex persona-items-center persona-px-2 persona-py-0.5 persona-rounded persona-text-[11px] persona-font-mono persona-font-medium persona-whitespace-nowrap persona-flex-shrink-0 persona-border");C.style.backgroundColor=x.bg,C.style.color=x.text,C.style.borderColor=x.text+"50",C.textContent=r.type;let w=(te=n.descriptionFields)!=null?te:sC,E=pC(r.payload,w),H=null;E&&(H=v("span","persona-text-[11px] persona-text-persona-secondary persona-truncate persona-min-w-0"),H.textContent=E);let I=v("div","persona-flex-1 persona-min-w-0"),L=v("button","persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-flex-shrink-0 persona-border-none persona-bg-transparent persona-p-0"),O=Me("clipboard","12px","currentColor",1.5);return O&&L.appendChild(O),L.addEventListener("click",async xe=>{xe.stopPropagation(),await uC(fC(r)),L.innerHTML="";let Je=Me("check","12px","currentColor",1.5);Je&&L.appendChild(Je),setTimeout(()=>{L.innerHTML="";let we=Me("clipboard","12px","currentColor",1.5);we&&L.appendChild(we)},1500)}),b.appendChild(h),b.appendChild(T),k&&b.appendChild(k),b.appendChild(C),H&&b.appendChild(H),b.appendChild(I),b.appendChild(L),f.appendChild(b),d&&f.appendChild(hC(r,s,i)),f}}function Vx(r){var b,h,S,T,M;let{buffer:e,getFullHistory:t,onClose:n,config:o,plugins:a=[],getThroughput:s}=r,i=(b=o==null?void 0:o.features)==null?void 0:b.scrollToBottom,d=(i==null?void 0:i.enabled)!==!1,l=(h=i==null?void 0:i.iconName)!=null?h:"arrow-down",u=(S=i==null?void 0:i.label)!=null?S:"",m=(M=(T=o==null?void 0:o.features)==null?void 0:T.eventStream)!=null?M:{},p=a.find(k=>k.renderEventStreamView);if(p!=null&&p.renderEventStreamView&&o){let k=p.renderEventStreamView({config:o,events:e.getAll(),defaultRenderer:()=>f().element,onClose:n});if(k)return{element:k,update:()=>{},destroy:()=>{}}}return f();function f(){let k=m.classNames,x=v("div","persona-event-stream-view persona-flex persona-flex-col persona-flex-1 persona-min-h-0");ts(x,k==null?void 0:k.panel);let C=[],w="",E="",H=null,I=[],L={},O=0,$=El(),te=0,xe=0,Je=!1,we=null,De=!1,Ae=0,qe=new Set,He=new Map,J="",re="",Q=null,ge,Z,G,pe,ke,le=null,ne=null,de=null;function Et(){let ye=v("div","persona-relative persona-flex persona-flex-col persona-flex-shrink-0"),ie=v("div","persona-flex persona-items-center persona-gap-2 persona-px-4 persona-py-3 persona-pb-0 persona-border-persona-divider persona-bg-persona-surface persona-overflow-hidden");ts(ie,k==null?void 0:k.headerBar);let st=v("span","persona-text-sm persona-font-medium persona-text-persona-primary persona-whitespace-nowrap");if(st.textContent="Events",ge=v("span","persona-text-[11px] persona-font-mono persona-bg-persona-container persona-text-persona-muted persona-px-2 persona-py-0.5 persona-rounded persona-border persona-border-persona-border"),ge.textContent="0",s){ne=v("div","persona-relative persona-flex persona-items-center persona-gap-1.5 persona-whitespace-nowrap persona-ml-1"),ne.style.cursor="help";let sr=v("span","persona-text-sm persona-font-medium persona-text-persona-primary persona-whitespace-nowrap");sr.textContent="Throughput",le=v("span","persona-text-[11px] persona-font-mono persona-bg-persona-container persona-text-persona-muted persona-px-2 persona-py-0.5 persona-rounded persona-border persona-border-persona-border persona-tabular-nums"),le.textContent="-- tok/s",de=v("div","persona-absolute persona-z-50 persona-whitespace-nowrap persona-rounded persona-border persona-border-persona-border persona-bg-persona-container persona-text-persona-primary persona-text-[11px] persona-font-mono persona-px-2 persona-py-1 persona-shadow"),de.style.display="none",de.style.pointerEvents="none";let ur=ne,Mr=de,un=()=>{if(!Mr.textContent)return;let qr=ur.getBoundingClientRect(),xr=ye.getBoundingClientRect();Mr.style.left=`${qr.left-xr.left}px`,Mr.style.top=`${qr.bottom-xr.top+4}px`,Mr.style.display="block"},St=()=>{Mr.style.display="none"};ne.addEventListener("mouseenter",un),ne.addEventListener("mouseleave",St),ne.appendChild(sr),ne.appendChild(le)}let pr=v("div","persona-flex-1");Z=v("select","persona-text-xs persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded persona-px-2.5 persona-py-1 persona-text-persona-primary persona-cursor-pointer");let pt=v("option","");pt.value="",pt.textContent="All events",Z.appendChild(pt),G=v("button","persona-inline-flex persona-items-center persona-gap-1.5 persona-rounded persona-text-xs persona-text-persona-muted hover:persona-bg-persona-container hover:persona-text-persona-primary persona-cursor-pointer persona-border persona-border-persona-border persona-bg-persona-surface persona-flex-shrink-0 persona-px-2.5 persona-py-1"),G.type="button",G.title="Copy All";let Rr=Me("clipboard-copy","12px","currentColor",1.5);Rr&&G.appendChild(Rr);let ut=v("span","persona-text-xs");ut.textContent="Copy All",G.appendChild(ut),ie.appendChild(st),ie.appendChild(ge),ne&&ie.appendChild(ne),ie.appendChild(pr),ie.appendChild(Z),ie.appendChild(G);let Lt=v("div","persona-relative persona-px-4 persona-py-2.5 persona-border-b persona-border-persona-divider persona-bg-persona-surface");ts(Lt,k==null?void 0:k.searchBar);let tt=Me("search","14px","var(--persona-muted, #9ca3af)",1.5),zt=v("span","persona-absolute persona-left-6 persona-top-1/2 persona--translate-y-1/2 persona-pointer-events-none persona-flex persona-items-center");tt&&zt.appendChild(tt),pe=v("input","persona-text-sm persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded-md persona-pl-8 persona-pr-3 persona-py-1 persona-w-full persona-text-persona-primary"),ts(pe,k==null?void 0:k.searchInput),pe.type="text",pe.placeholder="Search event payloads...",ke=v("button","persona-absolute persona-right-5 persona-top-1/2 persona--translate-y-1/2 persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-0 persona-leading-none"),ke.type="button",ke.style.display="none";let vr=Me("x","12px","currentColor",2);return vr&&ke.appendChild(vr),Lt.appendChild(zt),Lt.appendChild(pe),Lt.appendChild(ke),ye.appendChild(ie),ye.appendChild(Lt),de&&ye.appendChild(de),ye}let wt,We=a.find(ye=>ye.renderEventStreamToolbar);if(We!=null&&We.renderEventStreamToolbar&&o){let ye=We.renderEventStreamToolbar({config:o,defaultRenderer:()=>Et(),eventCount:e.getSize(),filteredCount:0,onFilterChange:ie=>{w=ie,or(),F()},onSearchChange:ie=>{E=ie,or(),F()}});wt=ye!=null?ye:Et()}else wt=Et();let he=v("div","persona-text-xs persona-text-persona-muted persona-text-center persona-py-0.5 persona-px-4 persona-bg-persona-container persona-border-b persona-border-persona-divider persona-italic persona-flex-shrink-0");he.style.display="none";function at(){if(!s||!le||!ne)return;let ye=s();le.textContent=mC(ye);let ie=gC(ye);de&&(de.textContent=ie,ie||(de.style.display="none")),ie?ne.setAttribute("aria-label",ie):ne.removeAttribute("aria-label")}let Re=v("div","persona-flex-1 persona-min-h-0 persona-relative"),j=v("div","persona-event-stream-list persona-overflow-y-auto persona-min-h-0");j.style.height="100%";let ue=v("div","persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-transform persona--translate-x-1/2 persona-cursor-pointer persona-z-10 persona-text-xs");ts(ue,k==null?void 0:k.scrollIndicator),ue.style.display="none",ue.setAttribute("data-persona-scroll-to-bottom-has-label",u?"true":"false");let nt=Me(l,"14px","currentColor",2);nt&&ue.appendChild(nt);let Rt=v("span","");Rt.textContent=u,ue.appendChild(Rt);let ee=v("div","persona-flex persona-items-center persona-justify-center persona-h-full persona-text-sm persona-text-persona-muted");ee.style.display="none",Re.appendChild(j),Re.appendChild(ee),Re.appendChild(ue),x.setAttribute("tabindex","0"),x.appendChild(wt),x.appendChild(he),x.appendChild(Re);function Ge(){let ye=e.getAll(),ie={};for(let ut of ye)ie[ut.type]=(ie[ut.type]||0)+1;let st=Object.keys(ie).sort(),pr=st.length!==I.length||!st.every((ut,Lt)=>ut===I[Lt]),pt=!pr&&st.some(ut=>ie[ut]!==L[ut]),yr=ye.length!==Object.values(L).reduce((ut,Lt)=>ut+Lt,0);if(!pr&&!pt&&!yr||(I=st,L=ie,!Z))return;let Rr=Z.value;if(Z.options[0].textContent="All events",pr){for(;Z.options.length>1;)Z.remove(1);for(let ut of st){let Lt=v("option","");Lt.value=ut,Lt.textContent=`${ut} (${ie[ut]||0})`,Z.appendChild(Lt)}Rr&&st.includes(Rr)?Z.value=Rr:Rr&&(Z.value="",w="")}else for(let ut=1;ut<Z.options.length;ut++){let Lt=Z.options[ut];Lt.textContent=`${Lt.value} (${ie[Lt.value]||0})`}}function Fr(){let ye=e.getAll();if(w&&(ye=ye.filter(ie=>ie.type===w)),E){let ie=E.toLowerCase();ye=ye.filter(st=>st.type.toLowerCase().includes(ie)||st.payload.toLowerCase().includes(ie))}return ye}function Bt(){return w!==""||E!==""}function or(){O=0,te=0,$.resume(),ue.style.display="none"}function hr(ye){qe.has(ye)?qe.delete(ye):qe.add(ye),Q=ye;let ie=j.scrollTop,st=$.isFollowing();De=!0,$.pause(),F(),j.scrollTop=ie,st&&$.resume(),De=!1}function sn(){return xa(j,50)}function F(){xe=Date.now(),Je=!1,at(),Ge();let ye=e.getEvictedCount();ye>0?(he.textContent=`${ye.toLocaleString()} older events truncated`,he.style.display=""):he.style.display="none",C=Fr();let ie=C.length,st=e.getSize()>0;ge&&(ge.textContent=String(e.getSize())),ie===0&&st&&Bt()?(ee.textContent=E?`No events matching '${E}'`:"No events matching filter",ee.style.display="",j.style.display="none"):(ee.style.display="none",j.style.display=""),G&&(G.title=Bt()?`Copy Filtered (${ie})`:"Copy All"),d&&!$.isFollowing()&&ie>O&&(te+=ie-O,Rt.textContent=u?`${u}${te>0?` (${te})`:""}`:"",ue.style.display=""),O=ie;let pr=e.getAll(),pt=pr.length>0?pr[0].timestamp:0,yr=new Set(C.map(Lt=>Lt.id));for(let Lt of qe)yr.has(Lt)||qe.delete(Lt);let Rr=w!==J||E!==re,ut=He.size===0&&C.length>0;if(Rr||ut||C.length===0){j.innerHTML="",He.clear();let Lt=document.createDocumentFragment();for(let tt=0;tt<C.length;tt++){let zt=lu(C[tt],tt,pt,m,qe,hr,a,o);He.set(C[tt].id,zt),Lt.appendChild(zt)}j.appendChild(Lt),J=w,re=E,Q=null}else{if(Q!==null){let tt=He.get(Q);if(tt&&tt.parentNode===j){let zt=C.findIndex(vr=>vr.id===Q);if(zt>=0){let vr=lu(C[zt],zt,pt,m,qe,hr,a,o);j.insertBefore(vr,tt),tt.remove(),He.set(Q,vr)}}Q=null}let Lt=new Set(C.map(tt=>tt.id));for(let[tt,zt]of He)Lt.has(tt)||(zt.remove(),He.delete(tt));for(let tt=0;tt<C.length;tt++){let zt=C[tt];if(!He.has(zt.id)){let vr=lu(zt,tt,pt,m,qe,hr,a,o);He.set(zt.id,vr),j.appendChild(vr)}}}$.isFollowing()&&(j.scrollTop=j.scrollHeight)}function fe(){if(Date.now()-xe>=iC){we!==null&&(cancelAnimationFrame(we),we=null),F();return}Je||(Je=!0,we=requestAnimationFrame(()=>{we=null,F()}))}let Ie=(ye,ie)=>{if(!G)return;G.innerHTML="";let st=Me(ye,"12px","currentColor",1.5);st&&G.appendChild(st);let pr=v("span","persona-text-xs");pr.textContent="Copy All",G.appendChild(pr),setTimeout(()=>{G.innerHTML="";let pt=Me("clipboard-copy","12px","currentColor",1.5);pt&&G.appendChild(pt);let yr=v("span","persona-text-xs");yr.textContent="Copy All",G.appendChild(yr),G.disabled=!1},ie)},Xe=async()=>{if(G){G.disabled=!0;try{let ye;Bt()?ye=C:t?(ye=await t(),ye.length===0&&(ye=e.getAll())):ye=e.getAll();let ie=ye.map(st=>{try{return JSON.parse(st.payload)}catch{return st.payload}});await navigator.clipboard.writeText(JSON.stringify(ie,null,2)),Ie("check",1500)}catch{Ie("x",1500)}}},Fe=()=>{Z&&(w=Z.value,or(),F())},Ne=()=>{!pe||!ke||(ke.style.display=pe.value?"":"none",H&&clearTimeout(H),H=setTimeout(()=>{E=pe.value,or(),F()},150))},Ye=()=>{!pe||!ke||(pe.value="",E="",ke.style.display="none",H&&clearTimeout(H),or(),F())},At=()=>{if(De)return;let ye=j.scrollTop,{action:ie,nextLastScrollTop:st}=Ll({following:$.isFollowing(),currentScrollTop:ye,lastScrollTop:Ae,nearBottom:sn(),userScrollThreshold:1,resumeRequiresDownwardScroll:!0});Ae=st,ie==="resume"?($.resume(),te=0,ue.style.display="none"):ie==="pause"&&($.pause(),d&&(Rt.textContent=u,ue.style.display=""))},Xt=ye=>{let ie=Pl({following:$.isFollowing(),deltaY:ye.deltaY,nearBottom:sn(),resumeWhenNearBottom:!0});ie==="pause"?($.pause(),d&&(Rt.textContent=u,ue.style.display="")):ie==="resume"&&($.resume(),te=0,ue.style.display="none")},ar=()=>{d&&(j.scrollTop=j.scrollHeight,$.resume(),te=0,ue.style.display="none")},K=ye=>{let ie=ye.target;if(!ie||ie.closest("button"))return;let st=ie.closest("[data-event-id]");if(!st)return;let pr=st.getAttribute("data-event-id");pr&&hr(pr)},mt=ye=>{if((ye.metaKey||ye.ctrlKey)&&ye.key==="f"){ye.preventDefault(),pe==null||pe.focus(),pe==null||pe.select();return}ye.key==="Escape"&&(pe&&document.activeElement===pe?(Ye(),pe.blur(),x.focus()):n&&n())};G&&G.addEventListener("click",Xe),Z&&Z.addEventListener("change",Fe),pe&&pe.addEventListener("input",Ne),ke&&ke.addEventListener("click",Ye),j.addEventListener("scroll",At),j.addEventListener("wheel",Xt,{passive:!0}),j.addEventListener("click",K),ue.addEventListener("click",ar),x.addEventListener("keydown",mt);function it(){H&&clearTimeout(H),we!==null&&(cancelAnimationFrame(we),we=null),Je=!1,He.clear(),G&&G.removeEventListener("click",Xe),Z&&Z.removeEventListener("change",Fe),pe&&pe.removeEventListener("input",Ne),ke&&ke.removeEventListener("click",Ye),j.removeEventListener("scroll",At),j.removeEventListener("wheel",Xt),j.removeEventListener("click",K),ue.removeEventListener("click",ar),x.removeEventListener("keydown",mt)}return{element:x,update:fe,destroy:it}}}function jx(r,e){let t=typeof r.title=="string"&&r.title?r.title:"Untitled artifact",n=typeof r.artifactId=="string"?r.artifactId:"",o=r.status==="streaming"?"streaming":"complete",s=(typeof r.artifactType=="string"?r.artifactType:"markdown")==="component"?"Component":"Document",i=document.createElement("div");i.className="persona-flex persona-w-full persona-max-w-full persona-items-center persona-gap-3 persona-rounded-xl persona-px-4 persona-py-3",i.style.border="1px solid var(--persona-border, #e5e7eb)",i.style.backgroundColor="var(--persona-surface, #ffffff)",i.style.cursor="pointer",i.tabIndex=0,i.setAttribute("role","button"),i.setAttribute("aria-label",`Open ${t} in artifact panel`),n&&i.setAttribute("data-open-artifact",n);let d=document.createElement("div");d.className="persona-flex persona-h-10 persona-w-10 persona-flex-shrink-0 persona-items-center persona-justify-center persona-rounded-lg",d.style.border="1px solid var(--persona-border, #e5e7eb)",d.style.color="var(--persona-muted, #9ca3af)",d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>';let l=document.createElement("div");l.className="persona-min-w-0 persona-flex-1 persona-flex persona-flex-col persona-gap-0.5";let u=document.createElement("div");u.className="persona-truncate persona-text-sm persona-font-medium",u.style.color="var(--persona-text, #1f2937)",u.textContent=t;let m=document.createElement("div");if(m.className="persona-text-xs persona-flex persona-items-center persona-gap-1.5",m.style.color="var(--persona-muted, #9ca3af)",o==="streaming"){let p=document.createElement("span");p.className="persona-inline-block persona-w-1.5 persona-h-1.5 persona-rounded-full",p.style.backgroundColor="var(--persona-primary, #171717)",p.style.animation="persona-pulse 1.5s ease-in-out infinite",m.appendChild(p);let f=document.createElement("span");f.textContent=`Generating ${s.toLowerCase()}...`,m.appendChild(f)}else m.textContent=s;if(l.append(u,m),i.append(d,l),o==="complete"){let p=document.createElement("button");p.type="button",p.textContent="Download",p.title=`Download ${t}`,p.className="persona-flex-shrink-0 persona-rounded-md persona-px-3 persona-py-1.5 persona-text-xs persona-font-medium",p.style.border="1px solid var(--persona-border, #e5e7eb)",p.style.color="var(--persona-text, #1f2937)",p.style.backgroundColor="transparent",p.style.cursor="pointer",p.setAttribute("data-download-artifact",n),i.append(p)}return i}var Gx=(r,e)=>{var n,o,a;let t=(a=(o=(n=e==null?void 0:e.config)==null?void 0:n.features)==null?void 0:o.artifacts)==null?void 0:a.renderCard;if(t){let s=typeof r.title=="string"&&r.title?r.title:"Untitled artifact",i=typeof r.artifactId=="string"?r.artifactId:"",d=r.status==="streaming"?"streaming":"complete",l=typeof r.artifactType=="string"?r.artifactType:"markdown",u=t({artifact:{artifactId:i,title:s,artifactType:l,status:d},config:e.config,defaultRenderer:()=>jx(r,e)});if(u)return u}return jx(r,e)};var du=class{constructor(){this.components=new Map}register(e,t){this.components.has(e)&&console.warn(`[ComponentRegistry] Component "${e}" is already registered. Overwriting.`),this.components.set(e,t)}unregister(e){this.components.delete(e)}get(e){return this.components.get(e)}has(e){return this.components.has(e)}getAllNames(){return Array.from(this.components.keys())}clear(){this.components.clear()}registerAll(e){Object.entries(e).forEach(([t,n])=>{this.register(t,n)})}},wo=new du;wo.register("PersonaArtifactCard",Gx);function xC(r){var o;let e=v("div","persona-rounded-lg persona-border persona-border-persona-border persona-p-3 persona-text-persona-primary"),t=v("div","persona-font-semibold persona-text-sm persona-mb-2");t.textContent=r.component?`Component: ${r.component}`:"Component";let n=v("pre","persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-overflow-x-auto");return n.textContent=JSON.stringify((o=r.props)!=null?o:{},null,2),e.appendChild(t),e.appendChild(n),e}function Kx(r,e){var Z,G,pe,ke;let t=(G=(Z=r.features)==null?void 0:Z.artifacts)==null?void 0:G.layout,o=((pe=t==null?void 0:t.toolbarPreset)!=null?pe:"default")==="document",a=(ke=t==null?void 0:t.panePadding)==null?void 0:ke.trim(),s=r.markdown?ia(r.markdown):null,i=Na(r.sanitize),d=le=>{let ne=s?s(le):la(le);return i?i(ne):ne},l=typeof document!="undefined"?v("div","persona-artifact-backdrop persona-fixed persona-inset-0 persona-z-[55] persona-bg-black/30 persona-hidden md:persona-hidden"):null,u=()=>{l==null||l.classList.add("persona-hidden"),m.classList.remove("persona-artifact-drawer-open"),O==null||O.hide()};l&&l.addEventListener("click",()=>{var le;u(),(le=e.onDismiss)==null||le.call(e)});let m=v("aside","persona-artifact-pane persona-flex persona-flex-col persona-min-h-0 persona-min-w-0 persona-bg-persona-surface persona-text-persona-primary persona-border-l persona-border-persona-border");m.setAttribute("data-persona-theme-zone","artifact-pane"),o&&m.classList.add("persona-artifact-pane-document");let p=v("div","persona-artifact-toolbar persona-flex persona-items-center persona-justify-between persona-gap-2 persona-px-2 persona-py-2 persona-border-b persona-border-persona-border persona-shrink-0");p.setAttribute("data-persona-theme-zone","artifact-toolbar"),o&&p.classList.add("persona-artifact-toolbar-document");let f=v("span","persona-text-xs persona-font-medium persona-truncate");f.textContent="Artifacts";let b=v("button","persona-rounded-md persona-border persona-border-persona-border persona-px-2 persona-py-1 persona-text-xs persona-bg-persona-surface");b.type="button",b.textContent="Close",b.setAttribute("aria-label","Close artifacts panel"),b.addEventListener("click",()=>{var le;u(),(le=e.onDismiss)==null||le.call(e)});let h="rendered",S=v("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0 persona-artifact-toggle-group"),T=o?Dr({icon:"eye",label:"Rendered view",className:"persona-artifact-doc-icon-btn persona-artifact-view-btn"}):Dr({icon:"eye",label:"Rendered view"}),M=o?Dr({icon:"code-2",label:"Source",className:"persona-artifact-doc-icon-btn persona-artifact-code-btn"}):Dr({icon:"code-2",label:"Source"}),k=v("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0"),x=(t==null?void 0:t.documentToolbarShowCopyLabel)===!0,C=(t==null?void 0:t.documentToolbarShowCopyChevron)===!0,w=t==null?void 0:t.documentToolbarCopyMenuItems,E=!!(C&&w&&w.length>0),H=null,I,L=null,O=null;if(o&&(x||C)&&!E){if(I=x?oi({icon:"copy",label:"Copy",iconSize:14,className:"persona-artifact-doc-copy-btn"}):Dr({icon:"copy",label:"Copy",className:"persona-artifact-doc-copy-btn"}),C){let le=Me("chevron-down",14,"currentColor",2);le&&I.appendChild(le)}}else o&&E?(H=v("div","persona-relative persona-inline-flex persona-items-center persona-gap-0 persona-rounded-md"),I=x?oi({icon:"copy",label:"Copy",iconSize:14,className:"persona-artifact-doc-copy-btn"}):Dr({icon:"copy",label:"Copy",className:"persona-artifact-doc-copy-btn"}),L=Dr({icon:"chevron-down",label:"More copy options",size:14,className:"persona-artifact-doc-copy-menu-chevron persona-artifact-doc-icon-btn",aria:{"aria-haspopup":"true","aria-expanded":"false"}}),H.append(I,L)):o?I=Dr({icon:"copy",label:"Copy",className:"persona-artifact-doc-icon-btn"}):I=Dr({icon:"copy",label:"Copy"});let $=o?Dr({icon:"refresh-cw",label:"Refresh",className:"persona-artifact-doc-icon-btn"}):Dr({icon:"refresh-cw",label:"Refresh"}),te=o?Dr({icon:"x",label:"Close",className:"persona-artifact-doc-icon-btn"}):Dr({icon:"x",label:"Close"}),xe=()=>{var wt,We,he;let le=(wt=He.find(at=>at.id===J))!=null?wt:He[He.length-1],ne=(We=le==null?void 0:le.id)!=null?We:null,de=(le==null?void 0:le.artifactType)==="markdown"&&(he=le.markdown)!=null?he:"",Et=le?JSON.stringify({component:le.component,props:le.props},null,2):"";return{markdown:de,jsonPayload:Et,id:ne}},Je=async()=>{var wt;let{markdown:le,jsonPayload:ne}=xe(),de=(wt=He.find(We=>We.id===J))!=null?wt:He[He.length-1],Et=(de==null?void 0:de.artifactType)==="markdown"?le:de?ne:"";try{await navigator.clipboard.writeText(Et)}catch{}};if(I.addEventListener("click",async()=>{let le=t==null?void 0:t.onDocumentToolbarCopyMenuSelect;if(le&&E){let{markdown:ne,jsonPayload:de,id:Et}=xe();try{await le({actionId:"primary",artifactId:Et,markdown:ne,jsonPayload:de})}catch{}return}await Je()}),L&&(w!=null&&w.length)){let le=()=>{var de;return(de=m.closest("[data-persona-root]"))!=null?de:document.body},ne=()=>{O=$o({items:w.map(de=>({id:de.id,label:de.label})),onSelect:async de=>{let{markdown:Et,jsonPayload:wt,id:We}=xe(),he=t==null?void 0:t.onDocumentToolbarCopyMenuSelect;try{he?await he({actionId:de,artifactId:We,markdown:Et,jsonPayload:wt}):de==="markdown"||de==="md"?await navigator.clipboard.writeText(Et):de==="json"||de==="source"?await navigator.clipboard.writeText(wt):await navigator.clipboard.writeText(Et||wt)}catch{}},anchor:H!=null?H:L,position:"bottom-right",portal:le()})};m.isConnected?ne():requestAnimationFrame(ne),L.addEventListener("click",de=>{de.stopPropagation(),O==null||O.toggle()})}$.addEventListener("click",async()=>{var le;try{await((le=t==null?void 0:t.onDocumentToolbarRefresh)==null?void 0:le.call(t))}catch{}Q()}),te.addEventListener("click",()=>{var le;u(),(le=e.onDismiss)==null||le.call(e)});let we=()=>{o&&(T.setAttribute("aria-pressed",h==="rendered"?"true":"false"),M.setAttribute("aria-pressed",h==="source"?"true":"false"))};T.addEventListener("click",()=>{h="rendered",we(),Q()}),M.addEventListener("click",()=>{h="source",we(),Q()});let De=v("span","persona-min-w-0 persona-flex-1 persona-text-xs persona-font-medium persona-text-persona-primary persona-truncate persona-text-center md:persona-text-left");o?(p.replaceChildren(),S.append(T,M),H?k.append(H,$,te):k.append(I,$,te),p.append(S,De,k),we()):(p.appendChild(f),p.appendChild(b)),a&&(p.style.paddingLeft=a,p.style.paddingRight=a);let Ae=v("div","persona-artifact-list persona-shrink-0 persona-flex persona-gap-1 persona-overflow-x-auto persona-p-2 persona-border-b persona-border-persona-border"),qe=v("div","persona-artifact-content persona-flex-1 persona-min-h-0 persona-overflow-y-auto persona-p-3");a&&(Ae.style.paddingLeft=a,Ae.style.paddingRight=a,qe.style.padding=a),m.appendChild(p),m.appendChild(Ae),m.appendChild(qe);let He=[],J=null,re=!1,Q=()=>{var Et,wt,We,he;let le=o&&He.length<=1;Ae.classList.toggle("persona-hidden",le),Ae.replaceChildren();for(let at of He){let Re=v("button","persona-artifact-tab persona-shrink-0 persona-rounded-lg persona-px-2 persona-py-1 persona-text-xs persona-border persona-border-transparent persona-text-persona-primary");Re.type="button",Re.textContent=at.title||at.id.slice(0,8),at.id===J&&Re.classList.add("persona-bg-persona-container","persona-border-persona-border"),Re.addEventListener("click",()=>e.onSelect(at.id)),Ae.appendChild(Re)}qe.replaceChildren();let ne=J&&He.find(at=>at.id===J)||He[He.length-1];if(!ne)return;if(o){let at=ne.artifactType==="markdown"?"MD":(Et=ne.component)!=null?Et:"Component",j=(ne.title||"Document").trim().replace(/\s*·\s*MD\s*$/i,"").trim()||"Document";De.textContent=`${j} \xB7 ${at}`}else f.textContent="Artifacts";if(ne.artifactType==="markdown"){if(o&&h==="source"){let Re=v("pre","persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-break-words persona-text-persona-primary");Re.textContent=(wt=ne.markdown)!=null?wt:"",qe.appendChild(Re);return}let at=v("div","persona-text-sm persona-leading-relaxed persona-markdown-bubble");at.innerHTML=d((We=ne.markdown)!=null?We:""),qe.appendChild(at);return}let de=ne.component?wo.get(ne.component):void 0;if(de){let Re={message:{id:ne.id,role:"assistant",content:"",createdAt:new Date().toISOString()},config:r,updateProps:()=>{}};try{let j=de((he=ne.props)!=null?he:{},Re);if(j){qe.appendChild(j);return}}catch{}}qe.appendChild(xC(ne))},ge=()=>{var ne;let le=He.length>0;if(m.classList.toggle("persona-hidden",!le),l){let de=typeof m.closest=="function"?m.closest("[data-persona-root]"):null,wt=((ne=de==null?void 0:de.classList.contains("persona-artifact-narrow-host"))!=null?ne:!1)||typeof window!="undefined"&&window.matchMedia("(max-width: 640px)").matches;le&&wt&&re?(l.classList.remove("persona-hidden"),m.classList.add("persona-artifact-drawer-open")):(l.classList.add("persona-hidden"),m.classList.remove("persona-artifact-drawer-open"))}};return{element:m,backdrop:l,update(le){var ne,de,Et;He=le.artifacts,J=(Et=(de=le.selectedId)!=null?de:(ne=le.artifacts[le.artifacts.length-1])==null?void 0:ne.id)!=null?Et:null,He.length>0&&(re=!0),Q(),ge()},setMobileOpen(le){re=le,!le&&l?(l.classList.add("persona-hidden"),m.classList.remove("persona-artifact-drawer-open")):ge()}}}function Bn(r){var e,t;return((t=(e=r==null?void 0:r.features)==null?void 0:e.artifacts)==null?void 0:t.enabled)===!0}function Xx(r,e){var a,s,i,d;if(r.classList.remove("persona-artifact-border-full","persona-artifact-border-left"),r.style.removeProperty("--persona-artifact-pane-border"),r.style.removeProperty("--persona-artifact-pane-border-left"),!Bn(e))return;let t=(s=(a=e.features)==null?void 0:a.artifacts)==null?void 0:s.layout,n=(i=t==null?void 0:t.paneBorder)==null?void 0:i.trim(),o=(d=t==null?void 0:t.paneBorderLeft)==null?void 0:d.trim();n?(r.classList.add("persona-artifact-border-full"),r.style.setProperty("--persona-artifact-pane-border",n)):o&&(r.classList.add("persona-artifact-border-left"),r.style.setProperty("--persona-artifact-pane-border-left",o))}function bC(r){r.style.removeProperty("--persona-artifact-doc-toolbar-icon-color"),r.style.removeProperty("--persona-artifact-doc-toggle-active-bg"),r.style.removeProperty("--persona-artifact-doc-toggle-active-border")}function Gl(r,e){var d,l,u,m,p,f,b,h,S,T;if(!Bn(e)){r.style.removeProperty("--persona-artifact-split-gap"),r.style.removeProperty("--persona-artifact-pane-width"),r.style.removeProperty("--persona-artifact-pane-max-width"),r.style.removeProperty("--persona-artifact-pane-min-width"),r.style.removeProperty("--persona-artifact-pane-bg"),r.style.removeProperty("--persona-artifact-pane-padding"),bC(r),Xx(r,e);return}let t=(l=(d=e.features)==null?void 0:d.artifacts)==null?void 0:l.layout;r.style.setProperty("--persona-artifact-split-gap",(u=t==null?void 0:t.splitGap)!=null?u:"0.5rem"),r.style.setProperty("--persona-artifact-pane-width",(m=t==null?void 0:t.paneWidth)!=null?m:"40%"),r.style.setProperty("--persona-artifact-pane-max-width",(p=t==null?void 0:t.paneMaxWidth)!=null?p:"28rem"),t!=null&&t.paneMinWidth?r.style.setProperty("--persona-artifact-pane-min-width",t.paneMinWidth):r.style.removeProperty("--persona-artifact-pane-min-width");let n=(f=t==null?void 0:t.paneBackground)==null?void 0:f.trim();n?r.style.setProperty("--persona-artifact-pane-bg",n):r.style.removeProperty("--persona-artifact-pane-bg");let o=(b=t==null?void 0:t.panePadding)==null?void 0:b.trim();o?r.style.setProperty("--persona-artifact-pane-padding",o):r.style.removeProperty("--persona-artifact-pane-padding");let a=(h=t==null?void 0:t.documentToolbarIconColor)==null?void 0:h.trim();a?r.style.setProperty("--persona-artifact-doc-toolbar-icon-color",a):r.style.removeProperty("--persona-artifact-doc-toolbar-icon-color");let s=(S=t==null?void 0:t.documentToolbarToggleActiveBackground)==null?void 0:S.trim();s?r.style.setProperty("--persona-artifact-doc-toggle-active-bg",s):r.style.removeProperty("--persona-artifact-doc-toggle-active-bg");let i=(T=t==null?void 0:t.documentToolbarToggleActiveBorderColor)==null?void 0:T.trim();i?r.style.setProperty("--persona-artifact-doc-toggle-active-border",i):r.style.removeProperty("--persona-artifact-doc-toggle-active-border"),Xx(r,e)}var Qx=["panel","seamless"];function Kl(r,e){var i,d,l,u,m,p;for(let f of Qx)r.classList.remove(`persona-artifact-appearance-${f}`);if(r.classList.remove("persona-artifact-unified-split"),r.style.removeProperty("--persona-artifact-pane-radius"),r.style.removeProperty("--persona-artifact-pane-shadow"),r.style.removeProperty("--persona-artifact-unified-outer-radius"),!Bn(e))return;let t=(d=(i=e.features)==null?void 0:i.artifacts)==null?void 0:d.layout,n=(l=t==null?void 0:t.paneAppearance)!=null?l:"panel",o=Qx.includes(n)?n:"panel";r.classList.add(`persona-artifact-appearance-${o}`);let a=(u=t==null?void 0:t.paneBorderRadius)==null?void 0:u.trim();a&&r.style.setProperty("--persona-artifact-pane-radius",a);let s=(m=t==null?void 0:t.paneShadow)==null?void 0:m.trim();if(s&&r.style.setProperty("--persona-artifact-pane-shadow",s),(t==null?void 0:t.unifiedSplitChrome)===!0){r.classList.add("persona-artifact-unified-split");let f=((p=t.unifiedSplitOuterRadius)==null?void 0:p.trim())||a;f&&r.style.setProperty("--persona-artifact-unified-outer-radius",f)}}function Jx(r,e){var t,n,o;return!e||!Bn(r)?!1:((o=(n=(t=r.features)==null?void 0:t.artifacts)==null?void 0:n.layout)==null?void 0:o.expandLauncherPanelWhenOpen)!==!1}function yC(r,e){if(!(r!=null&&r.trim()))return e;let t=/^(\d+(?:\.\d+)?)px\s*$/i.exec(r.trim());return t?Math.max(0,Number(t[1])):e}function vC(r){if(!(r!=null&&r.trim()))return null;let e=/^(\d+(?:\.\d+)?)px\s*$/i.exec(r.trim());return e?Math.max(0,Number(e[1])):null}function CC(r,e,t){return t<e?e:Math.min(t,Math.max(e,r))}function wC(r,e,t,n){let o=r-n-2*e-t;return Math.max(0,o)}function Yx(r,e){var s;let n=(s=(e.getComputedStyle(r).gap||"0px").trim().split(/\s+/)[0])!=null?s:"0px",o=/^([\d.]+)px$/i.exec(n);if(o)return Number(o[1]);let a=/^([\d.]+)/.exec(n);return a?Number(a[1]):8}function Zx(r,e,t,n,o,a){let s=yC(o,200),i=wC(e,t,n,200);i=Math.max(s,i);let d=vC(a);return d!==null&&(i=Math.min(i,d)),CC(r,s,i)}var eb={init:{title:"Schedule a Demo",description:"Share the basics and we'll follow up with a confirmation.",fields:[{name:"name",label:"Full name",placeholder:"Jane Doe",required:!0},{name:"email",label:"Work email",placeholder:"jane@example.com",type:"email",required:!0},{name:"notes",label:"What would you like to cover?",type:"textarea"}],submitLabel:"Submit details"},followup:{title:"Additional Information",description:"Provide any extra details to tailor the next steps.",fields:[{name:"company",label:"Company",placeholder:"Acme Inc."},{name:"context",label:"Context",type:"textarea",placeholder:"Share more about your use case"}],submitLabel:"Send"}},cu=(r,e,t,n)=>{let o=r.querySelectorAll("[data-tv-form]");o.length&&o.forEach(a=>{var b,h,S;if(a.dataset.enhanced==="true")return;let s=(b=a.dataset.tvForm)!=null?b:"init";a.dataset.enhanced="true";let i=(h=eb[s])!=null?h:eb.init;a.classList.add("persona-form-card","persona-space-y-4");let d=v("div","persona-space-y-1"),l=v("h3","persona-text-base persona-font-semibold persona-text-persona-primary");if(l.textContent=i.title,d.appendChild(l),i.description){let T=v("p","persona-text-sm persona-text-persona-muted");T.textContent=i.description,d.appendChild(T)}let u=document.createElement("form");u.className="persona-form-grid persona-space-y-3",i.fields.forEach(T=>{var w,E;let M=v("label","persona-form-field persona-flex persona-flex-col persona-gap-1");M.htmlFor=`${e.id}-${s}-${T.name}`;let k=v("span","persona-text-xs persona-font-medium persona-text-persona-muted");k.textContent=T.label,M.appendChild(k);let x=(w=T.type)!=null?w:"text",C;x==="textarea"?(C=document.createElement("textarea"),C.rows=3):(C=document.createElement("input"),C.type=x),C.className="persona-rounded-xl persona-border persona-border-gray-200 persona-bg-white persona-px-3 persona-py-2 persona-text-sm persona-text-persona-primary focus:persona-outline-none focus:persona-border-persona-primary",C.id=`${e.id}-${s}-${T.name}`,C.name=T.name,C.placeholder=(E=T.placeholder)!=null?E:"",T.required&&(C.required=!0),M.appendChild(C),u.appendChild(M)});let m=v("div","persona-flex persona-items-center persona-justify-between persona-gap-2"),p=v("div","persona-text-xs persona-text-persona-muted persona-min-h-[1.5rem]"),f=v("button","persona-inline-flex persona-items-center persona-rounded-full persona-bg-persona-primary persona-px-4 persona-py-2 persona-text-sm persona-font-semibold persona-text-white disabled:persona-opacity-60 persona-cursor-pointer");f.type="submit",f.textContent=(S=i.submitLabel)!=null?S:"Submit",m.appendChild(p),m.appendChild(f),u.appendChild(m),a.replaceChildren(d,u),u.addEventListener("submit",async T=>{var C,w;T.preventDefault();let M=(C=t.formEndpoint)!=null?C:"/form",k=new FormData(u),x={};k.forEach((E,H)=>{x[H]=E}),x.type=s,f.disabled=!0,p.textContent="Submitting\u2026";try{let E=await fetch(M,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!E.ok)throw new Error(`Form submission failed (${E.status})`);let H=await E.json();p.textContent=(w=H.message)!=null?w:"Thanks! We'll be in touch soon.",H.success&&H.nextPrompt&&await n.sendMessage(String(H.nextPrompt))}catch(E){p.textContent=E instanceof Error?E.message:"Something went wrong. Please try again."}finally{f.disabled=!1}})})};var pu=class{constructor(){this.plugins=new Map}register(e){var t;this.plugins.has(e.id)&&console.warn(`Plugin "${e.id}" is already registered. Overwriting.`),this.plugins.set(e.id,e),(t=e.onRegister)==null||t.call(e)}unregister(e){var n;let t=this.plugins.get(e);t&&((n=t.onUnregister)==null||n.call(t),this.plugins.delete(e))}getAll(){return Array.from(this.plugins.values()).sort((e,t)=>{var n,o;return((n=t.priority)!=null?n:0)-((o=e.priority)!=null?o:0)})}getForInstance(e){let t=this.getAll();if(!e||e.length===0)return t;let n=new Set(e.map(a=>a.id));return[...t.filter(a=>!n.has(a.id)),...e].sort((a,s)=>{var i,d;return((i=s.priority)!=null?i:0)-((d=a.priority)!=null?d:0)})}clear(){this.plugins.forEach(e=>{var t;return(t=e.onUnregister)==null?void 0:t.call(e)}),this.plugins.clear()}},li=new pu;var tb=()=>{let r=new Map,e=(o,a)=>(r.has(o)||r.set(o,new Set),r.get(o).add(a),()=>t(o,a)),t=(o,a)=>{var s;(s=r.get(o))==null||s.delete(a)};return{on:e,off:t,emit:(o,a)=>{var s;(s=r.get(o))==null||s.forEach(i=>{try{i(a)}catch(d){typeof console!="undefined"&&console.error("[AgentWidget] Event handler error:",d)}})}}};var AC=r=>{let e=r.match(/```(?:json)?\s*([\s\S]*?)```/i);return e?e[1]:r},SC=r=>{let e=r.trim(),t=e.indexOf("{");if(t===-1)return null;let n=0;for(let o=t;o<e.length;o+=1){let a=e[o];if(a==="{"&&(n+=1),a==="}"&&(n-=1,n===0))return e.slice(t,o+1)}return null},di=({text:r})=>{if(!r||!r.includes("{"))return null;try{let e=AC(r),t=SC(e);if(!t)return null;let n=JSON.parse(t);if(!n||typeof n!="object"||!n.action)return null;let{action:o,...a}=n;return{type:String(o),payload:a,raw:n}}catch{return null}},uu=r=>typeof r=="string"?r:r==null?"":String(r),wa={message:r=>r.type!=="message"?void 0:{handled:!0,displayText:uu(r.payload.text)},messageAndClick:(r,e)=>{var o;if(r.type!=="message_and_click")return;let t=r.payload,n=uu(t.element);if(n&&((o=e.document)!=null&&o.querySelector)){let a=e.document.querySelector(n);a?setTimeout(()=>{a.click()},400):typeof console!="undefined"&&console.warn("[AgentWidget] Element not found for selector:",n)}return{handled:!0,displayText:uu(t.text)}}},rb=r=>Array.isArray(r)?r.map(e=>String(e)):[],ci=r=>{let e=new Set(rb(r.getSessionMetadata().processedActionMessageIds)),t=()=>{e=new Set(rb(r.getSessionMetadata().processedActionMessageIds))},n=()=>{let a=Array.from(e);r.updateSessionMetadata(s=>({...s,processedActionMessageIds:a}))};return{process:a=>{if(a.streaming||a.message.role!=="assistant"||!a.text||e.has(a.message.id))return null;let s=typeof a.raw=="string"&&a.raw||typeof a.message.rawContent=="string"&&a.message.rawContent||typeof a.text=="string"&&a.text||null;!s&&typeof a.text=="string"&&a.text.trim().startsWith("{")&&typeof console!="undefined"&&console.warn("[AgentWidget] Structured response detected but no raw payload was provided. Ensure your stream parser returns { text, raw }.");let i=s?r.parsers.reduce((l,u)=>l||(u==null?void 0:u({text:s,message:a.message}))||null,null):null;if(!i)return null;e.add(a.message.id),n();let d={action:i,message:a.message};r.emit("action:detected",d);for(let l of r.handlers)if(l)try{let u=()=>{r.emit("action:resubmit",d)},m=l(i,{message:a.message,metadata:r.getSessionMetadata(),updateMetadata:r.updateSessionMetadata,document:r.documentRef,triggerResubmit:u});if(!m)continue;if(m.handled){let p=m.persistMessage!==!1;return{text:m.displayText!==void 0?m.displayText:"",persist:p,resubmit:m.resubmit}}}catch(u){typeof console!="undefined"&&console.error("[AgentWidget] Action handler error:",u)}return{text:"",persist:!0}},syncFromMetadata:t}};var TC=r=>{if(!r)return null;try{return JSON.parse(r)}catch(e){return typeof console!="undefined"&&console.error("[AgentWidget] Failed to parse stored state:",e),null}},MC=r=>r.map(e=>({...e,streaming:!1})),kC=r=>r.map(e=>({...e,status:"complete"})),Xl=(r="persona-state")=>{let e=()=>typeof window=="undefined"||!window.localStorage?null:window.localStorage;return{load:()=>{let t=e();return t?TC(t.getItem(r)):null},save:t=>{let n=e();if(n)try{let o={...t,messages:t.messages?MC(t.messages):void 0,artifacts:t.artifacts?kC(t.artifacts):void 0};n.setItem(r,JSON.stringify(o))}catch(o){typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",o)}},clear:()=>{let t=e();if(t)try{t.removeItem(r)}catch(n){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear stored state:",n)}}}};var rs=Li(zi(),1);function EC(r){if(!r||typeof r!="object"||!("component"in r))return!1;let e=r.component;return typeof e=="string"&&e.length>0}function LC(r,e){if(!EC(r))return null;let t=r.props&&typeof r.props=="object"&&r.props!==null?r.props:{};return{component:r.component,props:t,raw:e}}function Ql(){let r=null,e=0;return{getExtractedDirective:()=>r,processChunk:t=>{let n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;if(t.length<=e)return r;try{let o=(0,rs.parse)(t,rs.STR|rs.OBJ),a=LC(o,t);a&&(r=a)}catch{}return e=t.length,r},reset:()=>{r=null,e=0}}}function nb(r){return typeof r=="object"&&r!==null&&"component"in r&&typeof r.component=="string"&&"props"in r&&typeof r.props=="object"}function Jl(r,e){let{config:t,message:n,onPropsUpdate:o}=e,a=wo.get(r.component);if(!a)return console.warn(`[ComponentMiddleware] Component "${r.component}" not found in registry. Falling back to default rendering.`),null;let s={message:n,config:t,updateProps:i=>{o&&o(i)}};try{return a(r.props,s)}catch(i){return console.error(`[ComponentMiddleware] Error rendering component "${r.component}":`,i),null}}function ob(){let r=Ql();return{processChunk:e=>r.processChunk(e),getDirective:()=>r.getExtractedDirective(),reset:()=>{r.reset()}}}function ab(r){if(typeof r.rawContent=="string"&&r.rawContent.length>0)return r.rawContent;if(typeof r.content=="string"){let e=r.content.trim();if(e.startsWith("{")||e.startsWith("["))return r.content}return null}function Yl(r){let e=ab(r);if(!e)return!1;try{let t=JSON.parse(e);return typeof t=="object"&&t!==null&&"component"in t&&typeof t.component=="string"}catch{return!1}}function Zl(r){let e=ab(r);if(!e)return null;try{let t=JSON.parse(e);if(typeof t=="object"&&t!==null&&"component"in t&&typeof t.component=="string"){let n=t;return{component:n.component,props:n.props&&typeof n.props=="object"&&n.props!==null?n.props:{},raw:e}}}catch{}return null}var PC=["Very dissatisfied","Dissatisfied","Neutral","Satisfied","Very satisfied"];function ed(r){let{onSubmit:e,onDismiss:t,title:n="How satisfied are you?",subtitle:o="Please rate your experience",commentPlaceholder:a="Share your thoughts (optional)...",submitText:s="Submit",skipText:i="Skip",showComment:d=!0,ratingLabels:l=PC}=r,u=document.createElement("div");u.className="persona-feedback-container persona-feedback-csat",u.setAttribute("role","dialog"),u.setAttribute("aria-label","Customer satisfaction feedback");let m=null,p=document.createElement("div");p.className="persona-feedback-content";let f=document.createElement("div");f.className="persona-feedback-header";let b=document.createElement("h3");b.className="persona-feedback-title",b.textContent=n,f.appendChild(b);let h=document.createElement("p");h.className="persona-feedback-subtitle",h.textContent=o,f.appendChild(h),p.appendChild(f);let S=document.createElement("div");S.className="persona-feedback-rating persona-feedback-rating-csat",S.setAttribute("role","radiogroup"),S.setAttribute("aria-label","Satisfaction rating from 1 to 5");let T=[];for(let w=1;w<=5;w++){let E=document.createElement("button");E.type="button",E.className="persona-feedback-rating-btn persona-feedback-star-btn",E.setAttribute("role","radio"),E.setAttribute("aria-checked","false"),E.setAttribute("aria-label",`${w} star${w>1?"s":""}: ${l[w-1]}`),E.title=l[w-1],E.dataset.rating=String(w),E.innerHTML=`
|
|
71
|
+
`,t.addEventListener("click",e);let o=a=>{var L,x,w,v,E,H,I,P,z,j,ie,ve,Xe;let s=(L=a.launcher)!=null?L:{},i=Lr(a),d=t.querySelector("[data-role='launcher-title']");if(d){let Ae=(x=s.title)!=null?x:"Chat Assistant";d.textContent=Ae,d.setAttribute("title",Ae)}let l=t.querySelector("[data-role='launcher-subtitle']");if(l){let Ae=(w=s.subtitle)!=null?w:"Get answers fast";l.textContent=Ae,l.setAttribute("title",Ae)}let u=t.querySelector(".persona-flex-col");u&&(s.textHidden||i?u.style.display="none":u.style.display="");let f=t.querySelector("[data-role='launcher-icon']");if(f)if(s.agentIconHidden)f.style.display="none";else{let Ae=(v=s.agentIconSize)!=null?v:"40px";if(f.style.height=Ae,f.style.width=Ae,f.innerHTML="",s.agentIconName){let We=parseFloat(Ae)||24,Me=Ee(s.agentIconName,We*.6,"var(--persona-text-inverse, #ffffff)",2);Me?(f.appendChild(Me),f.style.display=""):(f.textContent=(E=s.agentIconText)!=null?E:"\u{1F4AC}",f.style.display="")}else s.iconUrl?f.style.display="none":(f.textContent=(H=s.agentIconText)!=null?H:"\u{1F4AC}",f.style.display="")}let p=t.querySelector("[data-role='launcher-image']");if(p){let Ae=(I=s.agentIconSize)!=null?I:"40px";p.style.height=Ae,p.style.width=Ae,s.iconUrl&&!s.agentIconName&&!s.agentIconHidden?(p.src=s.iconUrl,p.style.display="block"):p.style.display="none"}let m=t.querySelector("[data-role='launcher-call-to-action-icon']");if(m){let Ae=(P=s.callToActionIconSize)!=null?P:"32px";m.style.height=Ae,m.style.width=Ae,s.callToActionIconBackgroundColor?(m.style.backgroundColor=s.callToActionIconBackgroundColor,m.classList.remove("persona-bg-persona-primary")):(m.style.backgroundColor="",m.classList.add("persona-bg-persona-primary")),s.callToActionIconColor?(m.style.color=s.callToActionIconColor,m.classList.remove("persona-text-persona-call-to-action")):(m.style.color="",m.classList.add("persona-text-persona-call-to-action"));let We=0;if(s.callToActionIconPadding?(m.style.boxSizing="border-box",m.style.padding=s.callToActionIconPadding,We=(parseFloat(s.callToActionIconPadding)||0)*2):(m.style.boxSizing="",m.style.padding=""),s.callToActionIconHidden)m.style.display="none";else if(m.style.display=i?"none":"",m.innerHTML="",s.callToActionIconName){let Me=parseFloat(Ae)||24,Ue=Math.max(Me-We,8),Be=Ee(s.callToActionIconName,Ue,"currentColor",2);Be?m.appendChild(Be):m.textContent=(z=s.callToActionIconText)!=null?z:"\u2197"}else m.textContent=(j=s.callToActionIconText)!=null?j:"\u2197"}let y=s.position&&tn[s.position]?tn[s.position]:tn["bottom-right"],h="persona-fixed persona-flex persona-items-center persona-gap-3 persona-rounded-launcher persona-bg-persona-surface persona-py-2.5 persona-pl-3 persona-pr-3 persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer",T="persona-relative persona-mt-4 persona-mb-4 persona-mx-auto persona-flex persona-items-center persona-justify-center persona-rounded-launcher persona-bg-persona-surface persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer";t.className=i?T:`${h} ${y}`,i||(t.style.zIndex=String((ie=s.zIndex)!=null?ie:so));let M="1px solid var(--persona-border, #e5e7eb)",k="var(--persona-launcher-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1))";t.style.border=(ve=s.border)!=null?ve:M,t.style.boxShadow=s.shadow!==void 0?s.shadow.trim()===""?"none":s.shadow:k,i?(t.style.width="0",t.style.minWidth="0",t.style.maxWidth="0",t.style.padding="0",t.style.overflow="hidden",t.style.border="none",t.style.boxShadow="none"):(t.style.width="",t.style.minWidth="",t.style.maxWidth=(Xe=s.collapsedMaxWidth)!=null?Xe:"",t.style.justifyContent="",t.style.padding="",t.style.overflow="")},n=()=>{t.removeEventListener("click",e),t.remove()};return r&&o(r),{element:t,update:o,destroy:n}};var zv="persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center",Ol=(r,e={})=>{var h,T,M,k,L,x;let{showClose:t=!0,wrapperClassName:o=zv,buttonSize:n,iconSize:a="28px"}=e,s=(h=r==null?void 0:r.launcher)!=null?h:{},i=(T=n!=null?n:s.closeButtonSize)!=null?T:"32px",d=C("div",o),l=C("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");l.style.height=i,l.style.width=i,l.type="button";let u=(M=s.closeButtonTooltipText)!=null?M:"Close chat",f=(k=s.closeButtonShowTooltip)!=null?k:!0;l.setAttribute("aria-label",u),l.style.display=t?"":"none";let p=(L=s.closeButtonIconName)!=null?L:"x",m=(x=s.closeButtonIconText)!=null?x:"\xD7";l.style.color=s.closeButtonColor||Ao.actionIconColor;let y=Ee(p,a,"currentColor",1);if(y?(y.style.display="block",l.appendChild(y)):l.textContent=m,s.closeButtonBackgroundColor?(l.style.backgroundColor=s.closeButtonBackgroundColor,l.classList.remove("hover:persona-bg-gray-100")):(l.style.backgroundColor="",l.classList.add("hover:persona-bg-gray-100")),s.closeButtonBorderWidth||s.closeButtonBorderColor){let w=s.closeButtonBorderWidth||"0px",v=s.closeButtonBorderColor||"transparent";l.style.border=`${w} solid ${v}`,l.classList.remove("persona-border-none")}else l.style.border="",l.classList.add("persona-border-none");if(s.closeButtonBorderRadius?(l.style.borderRadius=s.closeButtonBorderRadius,l.classList.remove("persona-rounded-full")):(l.style.borderRadius="",l.classList.add("persona-rounded-full")),s.closeButtonPaddingX?(l.style.paddingLeft=s.closeButtonPaddingX,l.style.paddingRight=s.closeButtonPaddingX):(l.style.paddingLeft="",l.style.paddingRight=""),s.closeButtonPaddingY?(l.style.paddingTop=s.closeButtonPaddingY,l.style.paddingBottom=s.closeButtonPaddingY):(l.style.paddingTop="",l.style.paddingBottom=""),d.appendChild(l),f&&u){let w=null,v=()=>{if(w)return;let H=l.ownerDocument,I=H.body;if(!I)return;w=un(H,"div","persona-clear-chat-tooltip"),w.textContent=u;let P=un(H,"div");P.className="persona-clear-chat-tooltip-arrow",w.appendChild(P);let z=l.getBoundingClientRect();w.style.position="fixed",w.style.zIndex=String(jn),w.style.left=`${z.left+z.width/2}px`,w.style.top=`${z.top-8}px`,w.style.transform="translate(-50%, -100%)",I.appendChild(w)},E=()=>{w&&w.parentNode&&(w.parentNode.removeChild(w),w=null)};d.addEventListener("mouseenter",v),d.addEventListener("mouseleave",E),l.addEventListener("focus",v),l.addEventListener("blur",E),d._cleanupTooltip=()=>{E(),d.removeEventListener("mouseenter",v),d.removeEventListener("mouseleave",E),l.removeEventListener("focus",v),l.removeEventListener("blur",E)}}return{button:l,wrapper:d}},$v="persona-relative persona-ml-auto persona-clear-chat-button-wrapper",_l=(r,e={})=>{var w,v,E,H,I,P,z,j,ie,ve,Xe,Ae,We;let{wrapperClassName:t=$v,buttonSize:o,iconSize:n="20px"}=e,s=(v=((w=r==null?void 0:r.launcher)!=null?w:{}).clearChat)!=null?v:{},i=(E=o!=null?o:s.size)!=null?E:"32px",d=(H=s.iconName)!=null?H:"refresh-cw",l=(I=s.iconColor)!=null?I:"",u=(P=s.backgroundColor)!=null?P:"",f=(z=s.borderWidth)!=null?z:"",p=(j=s.borderColor)!=null?j:"",m=(ie=s.borderRadius)!=null?ie:"",y=(ve=s.paddingX)!=null?ve:"",h=(Xe=s.paddingY)!=null?Xe:"",T=(Ae=s.tooltipText)!=null?Ae:"Clear chat",M=(We=s.showTooltip)!=null?We:!0,k=C("div",t),L=C("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");L.style.height=i,L.style.width=i,L.type="button",L.setAttribute("aria-label",T),L.style.color=l||Ao.actionIconColor;let x=Ee(d,n,"currentColor",1);if(x&&(x.style.display="block",L.appendChild(x)),u&&(L.style.backgroundColor=u,L.classList.remove("hover:persona-bg-gray-100")),f||p){let Me=f||"0px",Ue=p||"transparent";L.style.border=`${Me} solid ${Ue}`,L.classList.remove("persona-border-none")}if(m&&(L.style.borderRadius=m,L.classList.remove("persona-rounded-full")),y&&(L.style.paddingLeft=y,L.style.paddingRight=y),h&&(L.style.paddingTop=h,L.style.paddingBottom=h),k.appendChild(L),M&&T){let Me=null,Ue=()=>{if(Me)return;let Z=L.ownerDocument,ne=Z.body;if(!ne)return;Me=un(Z,"div","persona-clear-chat-tooltip"),Me.textContent=T;let me=un(Z,"div");me.className="persona-clear-chat-tooltip-arrow",Me.appendChild(me);let be=L.getBoundingClientRect();Me.style.position="fixed",Me.style.zIndex=String(jn),Me.style.left=`${be.left+be.width/2}px`,Me.style.top=`${be.top-8}px`,Me.style.transform="translate(-50%, -100%)",ne.appendChild(Me)},Be=()=>{Me&&Me.parentNode&&(Me.parentNode.removeChild(Me),Me=null)};k.addEventListener("mouseenter",Ue),k.addEventListener("mouseleave",Be),L.addEventListener("focus",Ue),L.addEventListener("blur",Be),k._cleanupTooltip=()=>{Be(),k.removeEventListener("mouseenter",Ue),k.removeEventListener("mouseleave",Be),L.removeEventListener("focus",Ue),L.removeEventListener("blur",Be)}}return{button:L,wrapper:k}};var Ao={titleColor:"var(--persona-header-title-fg, var(--persona-primary, #0f0f0f))",subtitleColor:"var(--persona-header-subtitle-fg, var(--persona-text-muted, var(--persona-muted, #9ca3af)))",actionIconColor:"var(--persona-header-action-icon-fg, var(--persona-muted, #9ca3af))"},kn=r=>{var w,v,E,H,I,P,z,j,ie,ve,Xe,Ae,We,Me,Ue,Be;let{config:e,showClose:t=!0}=r,o=C("div","persona-widget-header persona-flex persona-items-center persona-gap-3 persona-px-6 persona-py-5");o.setAttribute("data-persona-theme-zone","header"),o.style.backgroundColor="var(--persona-header-bg, var(--persona-surface, #ffffff))",o.style.borderBottomColor="var(--persona-header-border, var(--persona-divider, #f1f5f9))",o.style.boxShadow="var(--persona-header-shadow, none)",o.style.borderBottom="var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))";let n=(w=e==null?void 0:e.launcher)!=null?w:{},a=(v=n.headerIconSize)!=null?v:"48px",s=(E=n.closeButtonPlacement)!=null?E:"inline",i=(H=n.headerIconHidden)!=null?H:!1,d=n.headerIconName,l=C("div","persona-flex persona-items-center persona-justify-center persona-rounded-xl persona-text-xl");if(l.style.height=a,l.style.width=a,l.style.backgroundColor="var(--persona-header-icon-bg, var(--persona-primary, #0f0f0f))",l.style.color="var(--persona-header-icon-fg, var(--persona-text-inverse, #ffffff))",!i)if(d){let Z=parseFloat(a)||24,ne=Ee(d,Z*.6,"currentColor",1);ne?l.replaceChildren(ne):l.textContent=(P=(I=e==null?void 0:e.launcher)==null?void 0:I.agentIconText)!=null?P:"\u{1F4AC}"}else if((z=e==null?void 0:e.launcher)!=null&&z.iconUrl){let Z=C("img");Z.src=e.launcher.iconUrl,Z.alt="",Z.className="persona-rounded-xl persona-object-cover",Z.style.height=a,Z.style.width=a,l.replaceChildren(Z)}else l.textContent=(ie=(j=e==null?void 0:e.launcher)==null?void 0:j.agentIconText)!=null?ie:"\u{1F4AC}";let u=C("div","persona-flex persona-flex-col persona-flex-1 persona-min-w-0"),f=C("span","persona-text-base persona-font-semibold");f.style.color=Ao.titleColor,f.textContent=(Xe=(ve=e==null?void 0:e.launcher)==null?void 0:ve.title)!=null?Xe:"Chat Assistant";let p=C("span","persona-text-xs");p.style.color=Ao.subtitleColor,p.textContent=(We=(Ae=e==null?void 0:e.launcher)==null?void 0:Ae.subtitle)!=null?We:"Here to help you get answers fast",u.append(f,p),i?o.append(u):o.append(l,u);let m=(Me=n.clearChat)!=null?Me:{},y=(Ue=m.enabled)!=null?Ue:!0,h=(Be=m.placement)!=null?Be:"inline",T=null,M=null;if(y){let ne=_l(e,{wrapperClassName:h==="top-right"?"persona-absolute persona-top-4 persona-z-50":"persona-relative persona-ml-auto persona-clear-chat-button-wrapper"});T=ne.button,M=ne.wrapper,h==="top-right"&&(M.style.right="48px"),h==="inline"&&o.appendChild(M)}let k=s==="top-right"?"persona-absolute persona-top-4 persona-right-4 persona-z-50":y&&h==="inline"?"persona-relative persona-inline-flex persona-items-center persona-justify-center":"persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center",{button:L,wrapper:x}=Ol(e,{showClose:t,wrapperClassName:k});return s!=="top-right"&&o.appendChild(x),{header:o,iconHolder:l,headerTitle:f,headerSubtitle:p,closeButton:L,closeButtonWrapper:x,clearChatButton:T,clearChatButtonWrapper:M}},Ta=(r,e,t)=>{var s,i,d,l;let o=(s=t==null?void 0:t.launcher)!=null?s:{},n=(i=o.closeButtonPlacement)!=null?i:"inline",a=(l=(d=o.clearChat)==null?void 0:d.placement)!=null?l:"inline";r.appendChild(e.header),n==="top-right"&&(r.style.position="relative",r.appendChild(e.closeButtonWrapper)),e.clearChatButtonWrapper&&a==="top-right"&&(r.style.position="relative",r.appendChild(e.clearChatButtonWrapper))};function Xn(r){let{items:e,onSelect:t,anchor:o,position:n="bottom-left",portal:a}=r,s=C("div","persona-dropdown-menu persona-hidden");s.setAttribute("role","menu"),s.setAttribute("data-persona-theme-zone","dropdown"),a?(s.style.position="fixed",s.style.zIndex=String(jn)):(s.style.position="absolute",s.style.top="100%",s.style.marginTop="4px",n==="bottom-right"?s.style.right="0":s.style.left="0");for(let m of e){if(m.dividerBefore){let T=document.createElement("hr");s.appendChild(T)}let y=document.createElement("button");if(y.type="button",y.setAttribute("role","menuitem"),y.setAttribute("data-dropdown-item-id",m.id),m.destructive&&y.setAttribute("data-destructive",""),m.icon){let T=Ee(m.icon,16,"currentColor",1.5);T&&y.appendChild(T)}let h=document.createElement("span");h.textContent=m.label,y.appendChild(h),y.addEventListener("click",T=>{T.stopPropagation(),u(),t(m.id)}),s.appendChild(y)}let i=null;function d(){if(!a)return;let m=o.getBoundingClientRect();s.style.top=`${m.bottom+4}px`,n==="bottom-right"?(s.style.right=`${window.innerWidth-m.right}px`,s.style.left="auto"):(s.style.left=`${m.left}px`,s.style.right="auto")}function l(){d(),s.classList.remove("persona-hidden"),requestAnimationFrame(()=>{let m=y=>{!s.contains(y.target)&&!o.contains(y.target)&&u()};document.addEventListener("click",m,!0),i=()=>document.removeEventListener("click",m,!0)})}function u(){s.classList.add("persona-hidden"),i==null||i(),i=null}function f(){s.classList.contains("persona-hidden")?l():u()}function p(){u(),s.remove()}return a&&a.appendChild(s),{element:s,show:l,hide:u,toggle:f,destroy:p}}function Br(r){let{icon:e,label:t,size:o,strokeWidth:n,className:a,onClick:s,aria:i}=r,d=C("button","persona-icon-btn"+(a?" "+a:""));d.type="button",d.setAttribute("aria-label",t),d.title=t;let l=Ee(e,o!=null?o:16,"currentColor",n!=null?n:2);if(l&&d.appendChild(l),s&&d.addEventListener("click",s),i)for(let[u,f]of Object.entries(i))d.setAttribute(u,f);return d}function ci(r){let{icon:e,label:t,variant:o="default",size:n="sm",iconSize:a,className:s,onClick:i,aria:d}=r,l="persona-label-btn";o!=="default"&&(l+=" persona-label-btn--"+o),l+=" persona-label-btn--"+n,s&&(l+=" "+s);let u=C("button",l);if(u.type="button",u.setAttribute("aria-label",t),e){let p=Ee(e,a!=null?a:14,"currentColor",2);p&&u.appendChild(p)}let f=C("span");if(f.textContent=t,u.appendChild(f),i&&u.addEventListener("click",i),d)for(let[p,m]of Object.entries(d))u.setAttribute(p,m);return u}function Wx(r){let{items:e,selectedId:t,onSelect:o,className:n}=r,a=C("div","persona-toggle-group"+(n?" "+n:""));a.setAttribute("role","group");let s=t,i=[];function d(){for(let u of i)u.btn.setAttribute("aria-pressed",u.id===s?"true":"false")}for(let u of e){let f;u.icon?f=Br({icon:u.icon,label:u.label,onClick:()=>{s=u.id,d(),o(u.id)}}):(f=C("button","persona-icon-btn"),f.type="button",f.setAttribute("aria-label",u.label),f.title=u.label,f.textContent=u.label,f.addEventListener("click",()=>{s=u.id,d(),o(u.id)})),f.setAttribute("aria-pressed",u.id===s?"true":"false"),i.push({id:u.id,btn:f}),a.appendChild(f)}function l(u){s=u,d()}return{element:a,setSelected:l}}function Nl(r){var m,y;let{label:e,icon:t="chevron-down",menuItems:o,onSelect:n,position:a="bottom-left",portal:s,className:i,hover:d}=r,l=C("div","persona-combo-btn"+(i?" "+i:""));l.style.position="relative",l.style.display="inline-flex",l.style.alignItems="center",l.style.cursor="pointer",l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false"),l.setAttribute("aria-label",e);let u=C("span","persona-combo-btn-label");u.textContent=e,l.appendChild(u);let f=Ee(t,14,"currentColor",2);f&&(f.style.marginLeft="4px",f.style.opacity="0.6",l.appendChild(f)),d&&(l.style.borderRadius=(m=d.borderRadius)!=null?m:"10px",l.style.padding=(y=d.padding)!=null?y:"6px 4px 6px 12px",l.style.border="1px solid transparent",l.style.transition="background-color 0.15s ease, border-color 0.15s ease",l.addEventListener("mouseenter",()=>{var h,T;l.style.backgroundColor=(h=d.background)!=null?h:"",l.style.borderColor=(T=d.border)!=null?T:""}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="",l.style.borderColor="transparent"}));let p=Xn({items:o,onSelect:h=>{l.setAttribute("aria-expanded","false"),n(h)},anchor:l,position:a,portal:s});return s||l.appendChild(p.element),l.addEventListener("click",h=>{h.stopPropagation();let T=!p.element.classList.contains("persona-hidden");l.setAttribute("aria-expanded",T?"false":"true"),p.toggle()}),l.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),l.click())}),{element:l,setLabel:h=>{u.textContent=h,l.setAttribute("aria-label",h)},open:()=>{l.setAttribute("aria-expanded","true"),p.show()},close:()=>{l.setAttribute("aria-expanded","false"),p.hide()},toggle:()=>{let h=!p.element.classList.contains("persona-hidden");l.setAttribute("aria-expanded",h?"false":"true"),p.toggle()},destroy:()=>{p.destroy(),l.remove()}}}var eu=r=>{var o;let e=kn({config:r.config,showClose:r.showClose,onClose:r.onClose,onClearChat:r.onClearChat}),t=(o=r.layoutHeaderConfig)==null?void 0:o.onTitleClick;if(t){let n=e.headerTitle.parentElement;n&&(n.style.cursor="pointer",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.addEventListener("click",()=>t()),n.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),t())}))}return e};function Vv(r,e,t){var o,n,a;if(e!=null&&e.length)for(let s of e){let i=C("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-md persona-border-none persona-bg-transparent persona-p-0 persona-text-persona-muted hover:persona-opacity-80");if(i.type="button",i.setAttribute("aria-label",(n=(o=s.ariaLabel)!=null?o:s.label)!=null?n:s.id),s.icon){let d=Ee(s.icon,14,"currentColor",2);d&&i.appendChild(d)}else s.label&&(i.textContent=s.label);if((a=s.menuItems)!=null&&a.length){let d=C("div","persona-relative");d.appendChild(i);let l=Xn({items:s.menuItems,onSelect:u=>t==null?void 0:t(u),anchor:d,position:"bottom-left"});d.appendChild(l.element),i.addEventListener("click",u=>{u.stopPropagation(),l.toggle()}),r.appendChild(d)}else i.addEventListener("click",()=>t==null?void 0:t(s.id)),r.appendChild(i)}}var tu=r=>{var k,L,x,w,v,E,H,I,P;let{config:e,showClose:t=!0,onClose:o,layoutHeaderConfig:n,onHeaderAction:a}=r,s=(k=e==null?void 0:e.launcher)!=null?k:{},i=C("div","persona-flex persona-items-center persona-justify-between persona-px-6 persona-py-4");i.setAttribute("data-persona-theme-zone","header"),i.style.backgroundColor="var(--persona-header-bg, var(--persona-surface, #ffffff))",i.style.borderBottomColor="var(--persona-header-border, var(--persona-divider, #f1f5f9))",i.style.boxShadow="var(--persona-header-shadow, none)",i.style.borderBottom="var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))";let d=n==null?void 0:n.titleMenu,l,u;if(d)l=Nl({label:(L=s.title)!=null?L:"Chat Assistant",menuItems:d.menuItems,onSelect:d.onSelect,hover:d.hover,className:""}).element,l.style.color=Ao.titleColor,u=(x=l.querySelector(".persona-combo-btn-label"))!=null?x:l;else{if(l=C("div","persona-flex persona-min-w-0 persona-flex-1 persona-items-center persona-gap-1"),u=C("span","persona-text-base persona-font-semibold persona-truncate"),u.style.color=Ao.titleColor,u.textContent=(w=s.title)!=null?w:"Chat Assistant",l.appendChild(u),Vv(l,n==null?void 0:n.trailingActions,(v=n==null?void 0:n.onAction)!=null?v:a),n!=null&&n.onTitleClick){l.style.cursor="pointer",l.setAttribute("role","button"),l.setAttribute("tabindex","0");let j=n.onTitleClick;l.addEventListener("click",ie=>{ie.target.closest("button")||j()}),l.addEventListener("keydown",ie=>{(ie.key==="Enter"||ie.key===" ")&&(ie.preventDefault(),j())})}let z=n==null?void 0:n.titleRowHover;z&&(l.style.borderRadius=(E=z.borderRadius)!=null?E:"10px",l.style.padding=(H=z.padding)!=null?H:"6px 4px 6px 12px",l.style.margin="-6px 0 -6px -12px",l.style.border="1px solid transparent",l.style.transition="background-color 0.15s ease, border-color 0.15s ease",l.style.width="fit-content",l.style.flex="none",l.addEventListener("mouseenter",()=>{var j,ie;l.style.backgroundColor=(j=z.background)!=null?j:"",l.style.borderColor=(ie=z.border)!=null?ie:""}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="",l.style.borderColor="transparent"}))}i.appendChild(l);let f=(I=s.closeButtonSize)!=null?I:"32px",p=C("div",""),m=C("button","persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-bg-gray-100 persona-cursor-pointer persona-border-none");m.style.height=f,m.style.width=f,m.type="button",m.setAttribute("aria-label","Close chat"),m.style.display=t?"":"none",m.style.color=s.closeButtonColor||Ao.actionIconColor;let y=(P=s.closeButtonIconName)!=null?P:"x",h=Ee(y,"28px","currentColor",1);h?m.appendChild(h):m.textContent="\xD7",o&&m.addEventListener("click",o),p.appendChild(m),i.appendChild(p);let T=C("div");T.style.display="none";let M=C("span");return M.style.display="none",{header:i,iconHolder:T,headerTitle:u,headerSubtitle:M,closeButton:m,closeButtonWrapper:p,clearChatButton:null,clearChatButtonWrapper:null}},Fl={default:eu,minimal:tu},ru=r=>{var e;return(e=Fl[r])!=null?e:Fl.default},os=(r,e,t)=>{var s,i,d;if(e!=null&&e.render){let l=e.render({config:r,onClose:t==null?void 0:t.onClose,onClearChat:t==null?void 0:t.onClearChat,trailingActions:e.trailingActions,onAction:e.onAction}),u=C("div");u.style.display="none";let f=C("span"),p=C("span"),m=C("button");m.style.display="none";let y=C("div");return y.style.display="none",{header:l,iconHolder:u,headerTitle:f,headerSubtitle:p,closeButton:m,closeButtonWrapper:y,clearChatButton:null,clearChatButtonWrapper:null}}let o=(s=e==null?void 0:e.layout)!=null?s:"default",a=ru(o)({config:r,showClose:(d=(i=e==null?void 0:e.showCloseButton)!=null?i:t==null?void 0:t.showClose)!=null?d:!0,onClose:t==null?void 0:t.onClose,onClearChat:t==null?void 0:t.onClearChat,layoutHeaderConfig:e,onHeaderAction:e==null?void 0:e.onAction});return e&&(e.showIcon===!1&&(a.iconHolder.style.display="none"),e.showTitle===!1&&(a.headerTitle.style.display="none"),e.showSubtitle===!1&&(a.headerSubtitle.style.display="none"),e.showCloseButton===!1&&(a.closeButton.style.display="none"),e.showClearChat===!1&&a.clearChatButtonWrapper&&(a.clearChatButtonWrapper.style.display="none")),a};var Ul=r=>{var s,i;let e=C("textarea");e.setAttribute("data-persona-composer-input",""),e.placeholder=(i=(s=r==null?void 0:r.copy)==null?void 0:s.inputPlaceholder)!=null?i:"Type your message\u2026",e.className="persona-w-full persona-min-h-[24px] persona-resize-none persona-border-none persona-bg-transparent persona-text-sm persona-text-persona-primary focus:persona-outline-none focus:persona-border-none persona-composer-textarea",e.rows=1,e.style.fontFamily='var(--persona-input-font-family, var(--persona-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif))',e.style.fontWeight="var(--persona-input-font-weight, var(--persona-font-weight, 400))";let t=3,o=20;e.style.maxHeight=`${t*o}px`,e.style.overflowY="auto";let n=()=>{let d=parseFloat(e.style.maxHeight);return Number.isFinite(d)&&d>0?d:t*o},a=()=>{e.addEventListener("input",()=>{e.style.height="auto";let d=Math.min(e.scrollHeight,n());e.style.height=`${d}px`})};return e.style.border="none",e.style.outline="none",e.style.borderWidth="0",e.style.borderStyle="none",e.style.borderColor="transparent",e.addEventListener("focus",()=>{e.style.border="none",e.style.outline="none",e.style.borderWidth="0",e.style.borderStyle="none",e.style.borderColor="transparent",e.style.boxShadow="none"}),e.addEventListener("blur",()=>{e.style.border="none",e.style.outline="none"}),{textarea:e,attachAutoResize:a}},ql=r=>{var w,v,E,H,I,P,z,j,ie,ve,Xe,Ae;let e=(w=r==null?void 0:r.sendButton)!=null?w:{},t=(v=e.useIcon)!=null?v:!1,o=(E=e.iconText)!=null?E:"\u2191",n=e.iconName,a=(H=e.stopIconName)!=null?H:"square",s=(I=e.tooltipText)!=null?I:"Send message",i=(P=e.stopTooltipText)!=null?P:"Stop generating",d=(j=(z=r==null?void 0:r.copy)==null?void 0:z.sendButtonLabel)!=null?j:"Send",l=(ve=(ie=r==null?void 0:r.copy)==null?void 0:ie.stopButtonLabel)!=null?ve:"Stop",u=(Xe=e.showTooltip)!=null?Xe:!1,f=(Ae=e.size)!=null?Ae:"40px",p=e.backgroundColor,m=e.textColor,y=C("div","persona-send-button-wrapper"),h=C("button",t?"persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer":"persona-rounded-button persona-bg-persona-accent persona-px-4 persona-py-2 persona-text-sm persona-font-semibold disabled:persona-opacity-50 persona-cursor-pointer");h.type="submit",h.setAttribute("data-persona-composer-submit","");let T=null,M=null;if(t){h.style.width=f,h.style.height=f,h.style.minWidth=f,h.style.minHeight=f,h.style.fontSize="18px",h.style.lineHeight="1",h.innerHTML="",m?h.style.color=m:h.style.color="var(--persona-button-primary-fg, #ffffff)";let We=parseFloat(f)||24,Me=(m==null?void 0:m.trim())||"currentColor";n?(T=Ee(n,We,Me,2),T?h.appendChild(T):h.textContent=o):h.textContent=o,M=Ee(a,We,Me,2),p?h.style.backgroundColor=p:h.classList.add("persona-bg-persona-primary")}else h.textContent=d,m?h.style.color=m:h.classList.add("persona-text-white");e.borderWidth&&(h.style.borderWidth=e.borderWidth,h.style.borderStyle="solid"),e.borderColor&&(h.style.borderColor=e.borderColor),e.paddingX?(h.style.paddingLeft=e.paddingX,h.style.paddingRight=e.paddingX):(h.style.paddingLeft="",h.style.paddingRight=""),e.paddingY?(h.style.paddingTop=e.paddingY,h.style.paddingBottom=e.paddingY):(h.style.paddingTop="",h.style.paddingBottom="");let k=null;u&&s&&(k=C("div","persona-send-button-tooltip"),k.textContent=s,y.appendChild(k)),h.setAttribute("aria-label",s),y.appendChild(h);let L="send";return{button:h,wrapper:y,setMode:We=>{if(We===L)return;L=We;let Me=We==="stop"?i:s;if(h.setAttribute("aria-label",Me),k&&(k.textContent=Me),t){if(T&&M){let Ue=We==="stop"?M:T;h.replaceChildren(Ue)}}else h.textContent=We==="stop"?l:d}}},zl=r=>{var k,L,x,w,v,E,H,I,P,z,j,ie;let e=(k=r==null?void 0:r.voiceRecognition)!=null?k:{};if(!(e.enabled===!0))return null;let o=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),n=((L=e.provider)==null?void 0:L.type)==="runtype";if(!(o||n))return null;let s=(w=(x=r==null?void 0:r.sendButton)==null?void 0:x.size)!=null?w:"40px",i=C("div","persona-send-button-wrapper"),d=C("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer");d.type="button",d.setAttribute("data-persona-composer-mic",""),d.setAttribute("aria-label","Start voice recognition");let l=(v=e.iconName)!=null?v:"mic",u=(E=e.iconSize)!=null?E:s,f=parseFloat(u)||24,p=(I=e.backgroundColor)!=null?I:(H=r==null?void 0:r.sendButton)==null?void 0:H.backgroundColor,m=(z=e.iconColor)!=null?z:(P=r==null?void 0:r.sendButton)==null?void 0:P.textColor;d.style.width=u,d.style.height=u,d.style.minWidth=u,d.style.minHeight=u,d.style.fontSize="18px",d.style.lineHeight="1",m?d.style.color=m:d.style.color="var(--persona-text, #111827)";let h=Ee(l,f,m||"currentColor",1.5);h?d.appendChild(h):d.textContent="\u{1F3A4}",p&&(d.style.backgroundColor=p),e.borderWidth&&(d.style.borderWidth=e.borderWidth,d.style.borderStyle="solid"),e.borderColor&&(d.style.borderColor=e.borderColor),e.paddingX&&(d.style.paddingLeft=e.paddingX,d.style.paddingRight=e.paddingX),e.paddingY&&(d.style.paddingTop=e.paddingY,d.style.paddingBottom=e.paddingY),i.appendChild(d);let T=(j=e.tooltipText)!=null?j:"Start voice recognition";if(((ie=e.showTooltip)!=null?ie:!1)&&T){let ve=C("div","persona-send-button-tooltip");ve.textContent=T,i.appendChild(ve)}return{button:d,wrapper:i}},$l=r=>{var y,h,T,M,k,L,x,w;let e=(y=r==null?void 0:r.attachments)!=null?y:{};if(e.enabled!==!0)return null;let t=(T=(h=r==null?void 0:r.sendButton)==null?void 0:h.size)!=null?T:"40px",o=C("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2");o.style.display="none";let n=C("input");n.type="file",n.accept=((M=e.allowedTypes)!=null?M:Tn).join(","),n.multiple=((k=e.maxFiles)!=null?k:4)>1,n.style.display="none",n.setAttribute("aria-label","Attach files");let a=C("div","persona-send-button-wrapper"),s=C("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button");s.type="button",s.setAttribute("aria-label",(L=e.buttonTooltipText)!=null?L:"Attach file");let i=(x=e.buttonIconName)!=null?x:"paperclip",d=t,l=parseFloat(d)||40,u=Math.round(l*.6);s.style.width=d,s.style.height=d,s.style.minWidth=d,s.style.minHeight=d,s.style.fontSize="18px",s.style.lineHeight="1",s.style.backgroundColor="transparent",s.style.color="var(--persona-primary, #111827)",s.style.border="none",s.style.borderRadius="6px",s.style.transition="background-color 0.15s ease",s.addEventListener("mouseenter",()=>{s.style.backgroundColor="var(--persona-palette-colors-black-alpha-50, rgba(0, 0, 0, 0.05))"}),s.addEventListener("mouseleave",()=>{s.style.backgroundColor="transparent"});let f=Ee(i,u,"currentColor",1.5);f?s.appendChild(f):s.textContent="\u{1F4CE}",s.addEventListener("click",v=>{v.preventDefault(),n.click()}),a.appendChild(s);let p=(w=e.buttonTooltipText)!=null?w:"Attach file",m=C("div","persona-send-button-tooltip");return m.textContent=p,a.appendChild(m),{button:s,wrapper:a,input:n,previewsContainer:o}},Vl=r=>{var s,i,d;let e=(s=r==null?void 0:r.statusIndicator)!=null?s:{},t=e.align==="left"?"persona-text-left":e.align==="center"?"persona-text-center":"persona-text-right",o=C("div",`persona-mt-2 ${t} persona-text-xs persona-text-persona-muted`);o.setAttribute("data-persona-composer-status","");let n=(i=e.visible)!=null?i:!0;o.style.display=n?"":"none";let a=(d=e.idleText)!=null?d:"Online";if(e.idleLink){let l=C("a");l.href=e.idleLink,l.target="_blank",l.rel="noopener noreferrer",l.textContent=a,l.style.color="inherit",l.style.textDecoration="none",o.appendChild(l)}else o.textContent=a;return o},jl=()=>C("div","persona-mb-3 persona-flex persona-flex-wrap persona-gap-2");var ns=r=>{var y,h,T,M,k,L;let{config:e}=r,t=C("div","persona-widget-footer persona-border-t-persona-divider persona-bg-persona-surface persona-px-6 persona-py-4");t.setAttribute("data-persona-theme-zone","composer");let o=jl(),n=C("form","persona-widget-composer persona-flex persona-flex-col persona-gap-2 persona-rounded-2xl persona-border persona-border-gray-200 persona-bg-persona-input-background persona-px-4 persona-py-3");n.setAttribute("data-persona-composer-form",""),n.style.outline="none";let{textarea:a,attachAutoResize:s}=Ul(e);s();let i=ql(e),d=zl(e),l=$l(e),u=Vl(e);l&&(l.previewsContainer.style.gap="8px",n.append(l.previewsContainer,l.input)),n.append(a);let f=C("div","persona-widget-composer__actions persona-flex persona-items-center persona-justify-between persona-w-full"),p=C("div","persona-widget-composer__left-actions persona-flex persona-items-center persona-gap-2"),m=C("div","persona-widget-composer__right-actions persona-flex persona-items-center persona-gap-1");return l&&p.append(l.wrapper),d&&m.append(d.wrapper),m.append(i.wrapper),f.append(p,m),n.append(f),n.addEventListener("click",x=>{x.target!==i.button&&x.target!==i.wrapper&&x.target!==(d==null?void 0:d.button)&&x.target!==(d==null?void 0:d.wrapper)&&x.target!==(l==null?void 0:l.button)&&x.target!==(l==null?void 0:l.wrapper)&&a.focus()}),t.append(o,n,u),{footer:t,suggestions:o,composerForm:n,textarea:a,sendButton:i.button,sendButtonWrapper:i.wrapper,micButton:(y=d==null?void 0:d.button)!=null?y:null,micButtonWrapper:(h=d==null?void 0:d.wrapper)!=null?h:null,statusText:u,attachmentButton:(T=l==null?void 0:l.button)!=null?T:null,attachmentButtonWrapper:(M=l==null?void 0:l.wrapper)!=null?M:null,attachmentInput:(k=l==null?void 0:l.input)!=null?k:null,attachmentPreviewsContainer:(L=l==null?void 0:l.previewsContainer)!=null?L:null,actionsRow:f,leftActions:p,rightActions:m,setSendButtonMode:i.setMode}};var Bx=()=>{let r=C("button","persona-pill-peek");r.type="button",r.setAttribute("data-persona-pill-peek",""),r.setAttribute("aria-label","Show conversation"),r.setAttribute("tabindex","-1");let e=C("span","persona-pill-peek__icon"),t=Ee("message-square",16,"currentColor",1.5);t&&e.appendChild(t);let o=C("span","persona-pill-peek__text"),n=C("span","persona-pill-peek__caret"),a=Ee("chevron-up",16,"currentColor",1.5);return a&&n.appendChild(a),r.append(e,o,n),{root:r,textNode:o}},Dx=r=>{var y,h,T,M,k,L;let{config:e}=r,t=C("div","persona-widget-footer persona-widget-footer--pill");t.setAttribute("data-persona-theme-zone","composer");let o=jl();o.style.display="none";let n=Vl(e);n.style.display="none";let{textarea:a,attachAutoResize:s}=Ul(e);a.style.maxHeight="100px",s();let i=ql(e),d=zl(e),l=$l(e);l&&l.previewsContainer.classList.add("persona-pill-composer__previews");let u=C("form","persona-widget-composer persona-pill-composer");u.setAttribute("data-persona-composer-form",""),u.style.outline="none";let f=C("div","persona-widget-composer__left-actions persona-pill-composer__left");l&&f.append(l.wrapper);let p=C("div","persona-widget-composer__right-actions persona-pill-composer__right");d&&p.append(d.wrapper),p.append(i.wrapper),u.addEventListener("click",x=>{x.target!==i.button&&x.target!==i.wrapper&&x.target!==(d==null?void 0:d.button)&&x.target!==(d==null?void 0:d.wrapper)&&x.target!==(l==null?void 0:l.button)&&x.target!==(l==null?void 0:l.wrapper)&&a.focus()}),l&&u.append(l.input),u.append(f,a,p),l&&t.append(l.previewsContainer),t.append(u,o,n);let m=u;return{footer:t,suggestions:o,composerForm:u,textarea:a,sendButton:i.button,sendButtonWrapper:i.wrapper,micButton:(y=d==null?void 0:d.button)!=null?y:null,micButtonWrapper:(h=d==null?void 0:d.wrapper)!=null?h:null,statusText:n,attachmentButton:(T=l==null?void 0:l.button)!=null?T:null,attachmentButtonWrapper:(M=l==null?void 0:l.wrapper)!=null?M:null,attachmentInput:(k=l==null?void 0:l.input)!=null?k:null,attachmentPreviewsContainer:(L=l==null?void 0:l.previewsContainer)!=null?L:null,actionsRow:m,leftActions:f,rightActions:p,setSendButtonMode:i.setMode}};var Ox=r=>{var u,f,p,m,y,h,T,M,k,L,x,w,v,E,H,I,P;let e=(f=(u=r==null?void 0:r.launcher)==null?void 0:u.enabled)!=null?f:!0,t=Lr(r);if(Kn(r)){let z=(m=(p=r==null?void 0:r.launcher)==null?void 0:p.composerBar)!=null?m:{},j=C("div","persona-widget-wrapper persona-fixed persona-transition");j.setAttribute("data-persona-composer-bar",""),j.dataset.state="collapsed",j.dataset.expandedSize=(y=z.expandedSize)!=null?y:"anchored",j.style.zIndex=String((T=(h=r==null?void 0:r.launcher)==null?void 0:h.zIndex)!=null?T:so);let ie=C("div","persona-widget-panel persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col");ie.style.width="100%",j.appendChild(ie);let ve=C("div","persona-widget-pill-root");return ve.setAttribute("data-persona-composer-bar",""),ve.dataset.state="collapsed",ve.dataset.expandedSize=(M=z.expandedSize)!=null?M:"anchored",ve.style.zIndex=String((L=(k=r==null?void 0:r.launcher)==null?void 0:k.zIndex)!=null?L:so),{wrapper:j,panel:ie,pillRoot:ve}}if(t){let z=C("div","persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col"),j=C("div","persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col");return z.appendChild(j),{wrapper:z,panel:j}}if(!e){let z=C("div","persona-relative persona-h-full persona-flex persona-flex-col persona-flex-1 persona-min-h-0"),j=C("div","persona-relative persona-flex-1 persona-flex persona-flex-col persona-min-h-0"),ie=(w=(x=r==null?void 0:r.launcher)==null?void 0:x.width)!=null?w:"100%";return z.style.width=ie,j.style.width="100%",z.appendChild(j),{wrapper:z,panel:j}}let n=(v=r==null?void 0:r.launcher)!=null?v:{},a=n.position&&tn[n.position]?tn[n.position]:tn["bottom-right"],s=C("div",`persona-widget-wrapper persona-fixed ${a} persona-transition`);s.style.zIndex=String((H=(E=r==null?void 0:r.launcher)==null?void 0:E.zIndex)!=null?H:so);let i=C("div","persona-widget-panel persona-relative persona-min-h-[320px]"),d=(P=(I=r==null?void 0:r.launcher)==null?void 0:I.width)!=null?P:r==null?void 0:r.launcherWidth,l=d!=null?d:Wo;return i.style.width=l,i.style.maxWidth=l,s.appendChild(i),{wrapper:s,panel:i}},jv=(r,e)=>{var x,w,v,E,H,I,P,z,j;let t=C("div","persona-widget-container persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary");t.setAttribute("data-persona-theme-zone","container");let{button:o,wrapper:n}=Ol(r,{showClose:e,wrapperClassName:"persona-composer-bar-close",buttonSize:"16px",iconSize:"14px"});n.style.position="absolute",n.style.top="8px",n.style.right="8px",n.style.zIndex="10";let a=(v=(w=(x=r==null?void 0:r.launcher)==null?void 0:x.clearChat)==null?void 0:w.enabled)!=null?v:!0,s=null,i=null;if(a){let ie=_l(r,{wrapperClassName:"persona-composer-bar-clear-chat",buttonSize:"16px",iconSize:"14px"});s=ie.button,i=ie.wrapper,i.style.position="absolute",i.style.top="8px",i.style.right="32px",i.style.zIndex="10"}let d=C("span","persona-widget-header");d.setAttribute("data-persona-theme-zone","header"),d.style.display="none";let l=C("div","persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6");l.style.paddingTop="48px",l.id="persona-scroll-container",l.setAttribute("data-persona-theme-zone","messages"),l.style.setProperty("scrollbar-gutter","stable");let u=C("div","persona-rounded-2xl persona-bg-persona-surface persona-p-6");u.style.boxShadow="var(--persona-intro-card-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",u.setAttribute("data-persona-intro-card","");let f=C("h2","persona-text-lg persona-font-semibold persona-text-persona-primary");f.textContent=(H=(E=r==null?void 0:r.copy)==null?void 0:E.welcomeTitle)!=null?H:"Hello \u{1F44B}";let p=C("p","persona-mt-2 persona-text-sm persona-text-persona-muted");p.textContent=(P=(I=r==null?void 0:r.copy)==null?void 0:I.welcomeSubtitle)!=null?P:"Ask anything about your account or products.",u.append(f,p);let m=C("div","persona-flex persona-flex-col persona-gap-3"),y=(z=r==null?void 0:r.layout)==null?void 0:z.contentMaxWidth;y&&(m.style.maxWidth=y,m.style.marginLeft="auto",m.style.marginRight="auto",m.style.width="100%"),((j=r==null?void 0:r.copy)==null?void 0:j.showWelcomeCard)!==!1||(u.style.display="none",l.classList.remove("persona-gap-6"),l.classList.add("persona-gap-3")),l.append(u,m);let T=C("div","persona-composer-overlay persona-pointer-events-none");T.setAttribute("data-persona-composer-overlay",""),T.style.position="absolute",T.style.left="0",T.style.right="0",T.style.bottom="0",T.style.zIndex="20";let M=Dx({config:r}),{root:k,textNode:L}=Bx();return t.append(d,n,l,T),i&&t.appendChild(i),{container:t,body:l,messagesWrapper:m,composerOverlay:T,suggestions:M.suggestions,textarea:M.textarea,sendButton:M.sendButton,sendButtonWrapper:M.sendButtonWrapper,micButton:M.micButton,micButtonWrapper:M.micButtonWrapper,composerForm:M.composerForm,statusText:M.statusText,introTitle:f,introSubtitle:p,closeButton:o,closeButtonWrapper:n,clearChatButton:s,clearChatButtonWrapper:i,iconHolder:C("span"),headerTitle:C("span"),headerSubtitle:C("span"),header:d,footer:M.footer,attachmentButton:M.attachmentButton,attachmentButtonWrapper:M.attachmentButtonWrapper,attachmentInput:M.attachmentInput,attachmentPreviewsContainer:M.attachmentPreviewsContainer,actionsRow:M.actionsRow,leftActions:M.leftActions,rightActions:M.rightActions,setSendButtonMode:M.setSendButtonMode,peekBanner:k,peekTextNode:L}},_x=(r,e=!0)=>{var T,M,k,L,x,w,v,E,H;if(Kn(r))return jv(r,e);let t=C("div","persona-widget-container persona-flex persona-h-full persona-w-full persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary persona-bg-persona-surface persona-rounded-2xl persona-overflow-hidden persona-border persona-border-persona-border");t.setAttribute("data-persona-theme-zone","container");let o=(T=r==null?void 0:r.layout)==null?void 0:T.header,n=((M=r==null?void 0:r.layout)==null?void 0:M.showHeader)!==!1,a=o?os(r,o,{showClose:e}):kn({config:r,showClose:e}),s=C("div","persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6");s.id="persona-scroll-container",s.setAttribute("data-persona-theme-zone","messages"),s.style.setProperty("scrollbar-gutter","stable");let i=C("div","persona-rounded-2xl persona-bg-persona-surface persona-p-6");i.style.boxShadow=Lr(r)?"none":"var(--persona-intro-card-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))";let d=C("h2","persona-text-lg persona-font-semibold persona-text-persona-primary");d.textContent=(L=(k=r==null?void 0:r.copy)==null?void 0:k.welcomeTitle)!=null?L:"Hello \u{1F44B}";let l=C("p","persona-mt-2 persona-text-sm persona-text-persona-muted");l.textContent=(w=(x=r==null?void 0:r.copy)==null?void 0:x.welcomeSubtitle)!=null?w:"Ask anything about your account or products.",i.append(d,l);let u=C("div","persona-flex persona-flex-col persona-gap-3"),f=(v=r==null?void 0:r.layout)==null?void 0:v.contentMaxWidth;f&&(u.style.maxWidth=f,u.style.marginLeft="auto",u.style.marginRight="auto",u.style.width="100%"),i.setAttribute("data-persona-intro-card",""),((E=r==null?void 0:r.copy)==null?void 0:E.showWelcomeCard)!==!1||(i.style.display="none",s.classList.remove("persona-gap-6"),s.classList.add("persona-gap-3")),s.append(i,u);let m=ns({config:r}),y=((H=r==null?void 0:r.layout)==null?void 0:H.showFooter)!==!1;n?Ta(t,a,r):(a.header.style.display="none",Ta(t,a,r)),t.append(s);let h=C("div","persona-composer-overlay persona-pointer-events-none");return h.setAttribute("data-persona-composer-overlay",""),h.style.position="absolute",h.style.left="0",h.style.right="0",h.style.bottom="0",h.style.zIndex="20",y||(m.footer.style.display="none"),t.append(m.footer),t.append(h),{container:t,body:s,messagesWrapper:u,composerOverlay:h,suggestions:m.suggestions,textarea:m.textarea,sendButton:m.sendButton,sendButtonWrapper:m.sendButtonWrapper,micButton:m.micButton,micButtonWrapper:m.micButtonWrapper,composerForm:m.composerForm,statusText:m.statusText,introTitle:d,introSubtitle:l,closeButton:a.closeButton,closeButtonWrapper:a.closeButtonWrapper,clearChatButton:a.clearChatButton,clearChatButtonWrapper:a.clearChatButtonWrapper,iconHolder:a.iconHolder,headerTitle:a.headerTitle,headerSubtitle:a.headerSubtitle,header:a.header,footer:m.footer,attachmentButton:m.attachmentButton,attachmentButtonWrapper:m.attachmentButtonWrapper,attachmentInput:m.attachmentInput,attachmentPreviewsContainer:m.attachmentPreviewsContainer,actionsRow:m.actionsRow,leftActions:m.leftActions,rightActions:m.rightActions,setSendButtonMode:m.setSendButtonMode}};var Gv=r=>{switch(r){case"max_tool_calls":return"Stopped after calling a tool. Send a follow-up to continue.";case"length":return"Response cut off as max tokens reached. Ask for more to continue.";case"content_filter":return"The provider filtered this response.";case"error":return"Something went wrong generating this response.";default:return null}},Kv=(r,e)=>{if(!r)return null;let t=Gv(r);if(t===null)return null;let o=e==null?void 0:e[r],n=o!==void 0?o:t;return n||null},Xv=(r,e)=>{let t=C("div","persona-message-stop-reason persona-text-xs persona-mt-2 persona-italic");return t.setAttribute("data-stop-reason",r),t.setAttribute("role","note"),t.style.opacity="0.75",t.textContent=e,t},Qv=r=>{let e=r.toLowerCase();return e.startsWith("data:image/svg+xml")?!1:!!(/^(?:https?|blob):/i.test(r)||e.startsWith("data:image/")||!r.includes(":"))},ou=r=>{let e=r.toLowerCase();return e.startsWith("javascript:")||e.startsWith("data:text/html")||e.startsWith("data:text/javascript")||e.startsWith("data:text/xml")||e.startsWith("data:application/xhtml")||e.startsWith("data:image/svg+xml")?!1:!!(/^(?:https?|blob):/i.test(r)||e.startsWith("data:")||!r.includes(":"))},nu=320,Fx=320,Yv=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="image"&&typeof e.image=="string"&&e.image.trim().length>0),Jv=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="audio"&&typeof e.audio=="string"&&e.audio.trim().length>0),Zv=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="video"&&typeof e.video=="string"&&e.video.trim().length>0),eC=r=>!r.contentParts||r.contentParts.length===0?[]:r.contentParts.filter(e=>e.type==="file"&&typeof e.data=="string"&&e.data.trim().length>0),tC=(r,e,t)=>{if(r.length===0)return null;try{let o=C("div","persona-flex persona-flex-col persona-gap-2");o.setAttribute("data-message-attachments","images"),e&&(o.style.marginBottom="8px");let n=0,a=!1,s=()=>{a||(a=!0,o.remove(),t==null||t())};return r.forEach((i,d)=>{var f;let l=C("img");l.alt=((f=i.alt)==null?void 0:f.trim())||`Attached image ${d+1}`,l.loading="lazy",l.decoding="async",l.referrerPolicy="no-referrer",l.style.display="block",l.style.width="100%",l.style.maxWidth=`${nu}px`,l.style.maxHeight=`${Fx}px`,l.style.height="auto",l.style.objectFit="contain",l.style.borderRadius="10px",l.style.backgroundColor="var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))",l.style.border="1px solid var(--persona-attachment-image-border, var(--persona-border, #e5e7eb))";let u=!1;n+=1,l.addEventListener("error",()=>{u||(u=!0,n=Math.max(0,n-1),l.remove(),n===0&&s())}),l.addEventListener("load",()=>{u=!0}),Qv(i.image)?(l.src=i.image,o.appendChild(l)):(u=!0,n=Math.max(0,n-1),l.remove())}),n===0?(s(),null):o}catch{return t==null||t(),null}},rC=r=>{if(r.length===0)return null;try{let e=C("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","audio");let t=0;return r.forEach(o=>{if(!ou(o.audio))return;let n=C("audio");n.controls=!0,n.preload="metadata",n.src=o.audio,n.style.display="block",n.style.width="100%",n.style.maxWidth=`${nu}px`,e.appendChild(n),t+=1}),t===0?(e.remove(),null):e}catch{return null}},oC=r=>{if(r.length===0)return null;try{let e=C("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","video");let t=0;return r.forEach(o=>{if(!ou(o.video))return;let n=C("video");n.controls=!0,n.preload="metadata",n.src=o.video,n.style.display="block",n.style.width="100%",n.style.maxWidth=`${nu}px`,n.style.maxHeight=`${Fx}px`,n.style.borderRadius="10px",n.style.backgroundColor="var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))",e.appendChild(n),t+=1}),t===0?(e.remove(),null):e}catch{return null}},nC=r=>{if(r.length===0)return null;try{let e=C("div","persona-flex persona-flex-col persona-gap-2");e.setAttribute("data-message-attachments","files");let t=0;return r.forEach(o=>{if(!ou(o.data))return;let n=C("a");n.href=o.data,n.download=o.filename,n.target="_blank",n.rel="noopener noreferrer",n.textContent=o.filename,n.className="persona-message-file-attachment",n.style.display="inline-flex",n.style.alignItems="center",n.style.gap="6px",n.style.padding="6px 10px",n.style.borderRadius="8px",n.style.fontSize="0.875rem",n.style.textDecoration="underline",n.style.backgroundColor="var(--persona-attachment-file-bg, var(--persona-container, #f3f4f6))",n.style.border="1px solid var(--persona-attachment-file-border, var(--persona-border, #e5e7eb))",n.style.color="inherit",e.appendChild(n),t+=1}),t===0?(e.remove(),null):e}catch{return null}},Ma=()=>{let r=document.createElement("div");r.className="persona-flex persona-items-center persona-space-x-1 persona-h-5 persona-mt-2";let e=document.createElement("div");e.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",e.style.backgroundColor="currentColor",e.style.opacity="0.4",e.style.animationDelay="0ms";let t=document.createElement("div");t.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",t.style.backgroundColor="currentColor",t.style.opacity="0.4",t.style.animationDelay="250ms";let o=document.createElement("div");o.className="persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5",o.style.backgroundColor="currentColor",o.style.opacity="0.4",o.style.animationDelay="500ms";let n=document.createElement("span");return n.className="persona-sr-only",n.textContent="Loading",r.appendChild(e),r.appendChild(t),r.appendChild(o),r.appendChild(n),r},au=(r,e,t)=>{let o={config:t!=null?t:{},streaming:!0,location:r,defaultRenderer:Ma};if(e){let n=e(o);if(n!==null)return n}return Ma()},aC=(r,e)=>{let t=C("div","persona-flex-shrink-0 persona-w-8 persona-h-8 persona-rounded-full persona-flex persona-items-center persona-justify-center persona-text-sm"),o=e==="user"?r.userAvatar:r.assistantAvatar;if(o)if(o.startsWith("http")||o.startsWith("/")||o.startsWith("data:")){let n=C("img");n.src=o,n.alt=e==="user"?"User":"Assistant",n.className="persona-w-full persona-h-full persona-rounded-full persona-object-cover",t.appendChild(n)}else t.textContent=o,t.classList.add(e==="user"?"persona-bg-persona-accent":"persona-bg-persona-primary","persona-text-white");else t.textContent=e==="user"?"U":"A",t.classList.add(e==="user"?"persona-bg-persona-accent":"persona-bg-persona-primary","persona-text-white");return t},Nx=(r,e)=>{let t=C("div","persona-text-xs persona-text-persona-muted"),o=new Date(r.createdAt);return e.format?t.textContent=e.format(o):t.textContent=o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),t},sC=(r,e="bubble")=>{let t=["persona-message-bubble","persona-max-w-[85%]"];switch(e){case"flat":r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-text-persona-primary","persona-py-2"):t.push("persona-message-assistant-bubble","persona-text-persona-primary","persona-py-2");break;case"minimal":t.push("persona-text-sm","persona-leading-relaxed"),r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-bg-persona-accent","persona-text-white","persona-px-3","persona-py-2","persona-rounded-lg"):t.push("persona-message-assistant-bubble","persona-bg-persona-surface","persona-text-persona-primary","persona-px-3","persona-py-2","persona-rounded-lg");break;default:t.push("persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm"),r==="user"?t.push("persona-message-user-bubble","persona-ml-auto","persona-bg-persona-accent","persona-text-white","persona-px-5","persona-py-3"):t.push("persona-message-assistant-bubble","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-px-5","persona-py-3");break}return t},su=(r,e,t)=>{var m,y,h,T,M,k;let o=(m=e.showCopy)!=null?m:!0,n=(y=e.showUpvote)!=null?y:!0,a=(h=e.showDownvote)!=null?h:!0;if(!o&&!n&&!a){let L=C("div");return L.style.display="none",L.id=`actions-${r.id}`,L.setAttribute("data-actions-for",r.id),L}let s=(T=e.visibility)!=null?T:"hover",i=(M=e.align)!=null?M:"right",d=(k=e.layout)!=null?k:"pill-inside",l={left:"persona-message-actions-left",center:"persona-message-actions-center",right:"persona-message-actions-right"}[i],u={"pill-inside":"persona-message-actions-pill","row-inside":"persona-message-actions-row"}[d],f=C("div",`persona-message-actions persona-flex persona-items-center persona-gap-1 persona-mt-2 ${l} ${u} ${s==="hover"?"persona-message-actions-hover":""}`);f.id=`actions-${r.id}`,f.setAttribute("data-actions-for",r.id);let p=(L,x,w)=>{let v=Br({icon:L,label:x,size:14,className:"persona-message-action-btn"});return v.setAttribute("data-action",w),v};return o&&f.appendChild(p("copy","Copy message","copy")),n&&f.appendChild(p("thumbs-up","Upvote","upvote")),a&&f.appendChild(p("thumbs-down","Downvote","downvote")),f},as=(r,e,t,o,n,a)=>{var Z,ne,me,be,ye,Y,ge,Oe,ce,ae,Q,Tt,Ye,De,le,nt,Re;let s=t!=null?t:{},i=(Z=s.layout)!=null?Z:"bubble",d=s.avatar,l=s.timestamp,u=(ne=d==null?void 0:d.show)!=null?ne:!1,f=(me=l==null?void 0:l.show)!=null?me:!1,p=(be=d==null?void 0:d.position)!=null?be:"left",m=(ye=l==null?void 0:l.position)!=null?ye:"below",y=sC(r.role,i),h=C("div",y.join(" "));h.id=`bubble-${r.id}`,h.setAttribute("data-message-id",r.id),h.setAttribute("data-persona-theme-zone",r.role==="user"?"user-message":"assistant-message"),r.role==="user"?(h.style.backgroundColor="var(--persona-message-user-bg, var(--persona-accent))",h.style.color="var(--persona-message-user-text, white)"):r.role==="assistant"&&(h.style.backgroundColor="var(--persona-message-assistant-bg, var(--persona-surface))",h.style.color="var(--persona-message-assistant-text, var(--persona-text))");let T=Yv(r),M=(ge=(Y=r.content)==null?void 0:Y.trim())!=null?ge:"",L=T.length>0&&M===ll,x=Wl((ce=(Oe=a==null?void 0:a.widgetConfig)==null?void 0:Oe.features)==null?void 0:ce.streamAnimation),w=(Tt=(Q=(ae=a==null?void 0:a.widgetConfig)==null?void 0:ae.features)==null?void 0:Q.streamAnimation)==null?void 0:Tt.plugins,v=r.role==="assistant"&&x.type!=="none"?ni(x.type,w):null,E=r.role==="assistant"&&((Ye=v==null?void 0:v.isAnimating)==null?void 0:Ye.call(v,r))===!0,H=r.role==="assistant"&&v!==null&&(!!r.streaming||E);H&&(v!=null&&v.bubbleClass)&&h.classList.add(v.bubbleClass);let I=document.createElement("div");I.classList.add("persona-message-content"),H&&v&&(v.containerClass&&I.classList.add(v.containerClass),I.style.setProperty("--persona-stream-step",`${x.speed}ms`),I.style.setProperty("--persona-stream-duration",`${x.duration}ms`));let P=H?Bl((De=r.content)!=null?De:"",x.buffer,v,r,!!r.streaming):(le=r.content)!=null?le:"",z=e({text:P,message:r,streaming:!!r.streaming,raw:r.rawContent}),j=z;H&&(v==null?void 0:v.wrap)==="char"?j=ai(z,"char",r.id,{skipTags:v.skipTags}):H&&(v==null?void 0:v.wrap)==="word"&&(j=ai(z,"word",r.id,{skipTags:v.skipTags}));let ie=null;if(L?(ie=document.createElement("div"),ie.innerHTML=j,ie.style.display="none",I.appendChild(ie)):I.innerHTML=j,H&&(v!=null&&v.useCaret)&&!L&&M){let K=Dl(),he=I.querySelectorAll(".persona-stream-char, .persona-stream-word"),it=he[he.length-1];if(it!=null&&it.parentNode)it.parentNode.insertBefore(K,it.nextSibling);else{let Pt=I.lastElementChild;Pt?Pt.appendChild(K):I.appendChild(K)}}if(f&&m==="inline"&&r.createdAt){let K=Nx(r,l);K.classList.add("persona-ml-2","persona-inline"),I.appendChild(K)}if(T.length>0){let K=tC(T,!L&&!!M,()=>{L&&ie&&(ie.style.display="")});K?h.appendChild(K):L&&ie&&(ie.style.display="")}let ve=Jv(r);if(ve.length>0){let K=rC(ve);K&&h.appendChild(K)}let Xe=Zv(r);if(Xe.length>0){let K=oC(Xe);K&&h.appendChild(K)}let Ae=eC(r);if(Ae.length>0){let K=nC(Ae);K&&h.appendChild(K)}if(h.appendChild(I),f&&m==="below"&&r.createdAt){let K=Nx(r,l);K.classList.add("persona-mt-1"),h.appendChild(K)}let We=r.role==="assistant"?Kv(r.stopReason,(Re=(nt=a==null?void 0:a.widgetConfig)==null?void 0:nt.copy)==null?void 0:Re.stopReasonNotice):null;if(r.streaming&&r.role==="assistant"){let K=!!(P&&P.trim()),he=x.placeholder==="skeleton",it=he&&x.buffer==="line"&&K;if(K)it&&h.appendChild(si());else if(he)h.appendChild(si());else{let Pt=au("inline",a==null?void 0:a.loadingIndicatorRenderer,a==null?void 0:a.widgetConfig);Pt&&h.appendChild(Pt)}}if(We&&r.stopReason&&!r.streaming&&(M||(I.style.display="none"),h.appendChild(Xv(r.stopReason,We))),r.role==="assistant"&&!r.streaming&&r.content&&r.content.trim()&&(o==null?void 0:o.enabled)!==!1&&o){let K=su(r,o,n);h.appendChild(K)}if(!u||r.role==="system")return h;let Ue=C("div",`persona-flex persona-gap-2 ${r.role==="user"?"persona-flex-row-reverse":""}`),Be=aC(d,r.role);return p==="right"||p==="left"&&r.role==="user"?Ue.append(h,Be):Ue.append(Be,h),h.classList.remove("persona-max-w-[85%]"),h.classList.add("persona-max-w-[calc(85%-2.5rem)]"),Ue},Ux=(r,e,t,o,n,a)=>{let s=t!=null?t:{};return r.role==="user"&&s.renderUserMessage?s.renderUserMessage({message:r,config:{},streaming:!!r.streaming}):r.role==="assistant"&&s.renderAssistantMessage?s.renderAssistantMessage({message:r,config:{},streaming:!!r.streaming}):as(r,e,t,o,n,a)};var ss=new Set,iC=(r,e)=>e==null?!1:typeof e=="string"?(r.textContent=e,!0):(r.appendChild(e),!0),lC=(r,e)=>{var o,n;let t=(n=(o=r.reasoning)==null?void 0:o.chunks.join("").trim())!=null?n:"";return t?t.split(/\r?\n/).map(a=>a.trim()).filter(Boolean).slice(0,e).join(`
|
|
72
|
+
`):""},qx=(r,e)=>{let t=ss.has(r),o=e.querySelector('button[data-expand-header="true"]'),n=e.querySelector(".persona-border-t"),a=e.querySelector('[data-persona-collapsed-preview="reasoning"]');if(!o||!n)return;o.setAttribute("aria-expanded",t?"true":"false");let s=o.querySelector(".persona-ml-auto"),i=s==null?void 0:s.querySelector(":scope > .persona-flex.persona-items-center");if(i){i.innerHTML="";let l=Ee(t?"chevron-up":"chevron-down",16,"currentColor",2);l?i.appendChild(l):i.textContent=t?"Hide":"Show"}n.style.display=t?"":"none",a&&(a.style.display=t?"none":a.textContent||a.childNodes.length?"":"none")},iu=(r,e)=>{var Xe,Ae,We,Me,Ue,Be,Z,ne,me,be,ye;let t=r.reasoning,o=C("div",["persona-message-bubble","persona-reasoning-bubble","persona-w-full","persona-max-w-[85%]","persona-rounded-2xl","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-shadow-sm","persona-overflow-hidden","persona-px-0","persona-py-0"].join(" "));if(o.id=`bubble-${r.id}`,o.setAttribute("data-message-id",r.id),!t)return o;let n=(Ae=(Xe=e==null?void 0:e.features)==null?void 0:Xe.reasoningDisplay)!=null?Ae:{},a=n.expandable!==!1,s=a&&ss.has(r.id),i=t.status!=="complete",d=lC(r,(We=n.previewMaxLines)!=null?We:3),l=C("button",a?"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none":"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-default persona-border-none");l.type="button",a&&(l.setAttribute("aria-expanded",s?"true":"false"),l.setAttribute("data-expand-header","true")),l.setAttribute("data-bubble-type","reasoning");let u=C("div","persona-flex persona-flex-col persona-text-left"),f=C("span","persona-text-xs persona-text-persona-primary"),p="Thinking...",m=(Me=e==null?void 0:e.reasoning)!=null?Me:{},y=String((Ue=t.startedAt)!=null?Ue:Date.now()),h=()=>{let Y=C("span","");return Y.setAttribute("data-tool-elapsed",y),Y.textContent=el(t),Y},T=(Be=m.renderCollapsedSummary)==null?void 0:Be.call(m,{message:r,reasoning:t,defaultSummary:p,previewText:d,isActive:i,config:e!=null?e:{},elapsed:el(t),createElapsedElement:h});typeof T=="string"&&T.trim()?(f.textContent=T,u.appendChild(f)):T instanceof HTMLElement?u.appendChild(T):(f.textContent=p,u.appendChild(f));let M=C("span","persona-text-xs persona-text-persona-primary");M.textContent=Yh(t),u.appendChild(M);let k=(Z=n.loadingAnimation)!=null?Z:"none",L=m.activeTextTemplate,x=m.completeTextTemplate,w=i?L:x,v=T instanceof HTMLElement,E=(Y,ge,Oe)=>{let ce=Oe;for(let ae of ge){let Q=C("span","persona-tool-char");Q.style.setProperty("--char-index",String(ce)),Q.textContent=ae===" "?"\xA0":ae,Y.appendChild(Q),ce++}return ce},H=(Y,ge)=>{f.textContent="";let Oe=tl(Y,""),ce=0;for(let ae of Oe){let Q=ae.styles.length>0?(()=>{let Tt=C("span",ae.styles.map(Ye=>`persona-tool-text-${Ye}`).join(" "));return f.appendChild(Tt),Tt})():f;if(ae.isDuration&&i)Q.appendChild(h());else{let Tt=ae.isDuration?el(t):ae.text;ge?ce=E(Q,Tt,ce):Q.appendChild(document.createTextNode(Tt))}}};if(!v&&w)if(M.style.display="none",f.style.display="",i&&k!=="none"){let Y=(ne=m.loadingAnimationDuration)!=null?ne:2e3;f.setAttribute("data-preserve-animation","true"),k==="pulse"?(f.classList.add("persona-tool-loading-pulse"),f.style.setProperty("--persona-tool-anim-duration",`${Y}ms`),H(w,!1)):(f.classList.add(`persona-tool-loading-${k}`),f.style.setProperty("--persona-tool-anim-duration",`${Y}ms`),k==="shimmer-color"&&(m.loadingAnimationColor&&f.style.setProperty("--persona-tool-anim-color",m.loadingAnimationColor),m.loadingAnimationSecondaryColor&&f.style.setProperty("--persona-tool-anim-secondary-color",m.loadingAnimationSecondaryColor)),H(w,!0))}else H(w,!1);else if(!v&&i&&k!=="none"){f.style.display="";let Y=(me=m.loadingAnimationDuration)!=null?me:2e3;if(f.setAttribute("data-preserve-animation","true"),k==="pulse")f.classList.add("persona-tool-loading-pulse"),f.style.setProperty("--persona-tool-anim-duration",`${Y}ms`);else{f.classList.add(`persona-tool-loading-${k}`),f.style.setProperty("--persona-tool-anim-duration",`${Y}ms`),k==="shimmer-color"&&(m.loadingAnimationColor&&f.style.setProperty("--persona-tool-anim-color",m.loadingAnimationColor),m.loadingAnimationSecondaryColor&&f.style.setProperty("--persona-tool-anim-secondary-color",m.loadingAnimationSecondaryColor));let ge=f.textContent||p;f.textContent="",E(f,ge,0)}t.status==="complete"&&(f.style.display="none")}else v||(t.status==="complete"?f.style.display="none":f.style.display="");let I=null;if(a){I=C("div","persona-flex persona-items-center");let ge=Ee(s?"chevron-up":"chevron-down",16,"currentColor",2);ge?I.appendChild(ge):I.textContent=s?"Hide":"Show";let Oe=C("div","persona-flex persona-items-center persona-ml-auto");Oe.append(I),l.append(u,Oe)}else l.append(u);let P=C("div","persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted");if(P.setAttribute("data-persona-collapsed-preview","reasoning"),P.style.display="none",P.style.whiteSpace="pre-wrap",!s&&i&&n.activePreview&&d){let Y=(ye=(be=e==null?void 0:e.reasoning)==null?void 0:be.renderCollapsedPreview)==null?void 0:ye.call(be,{message:r,reasoning:t,defaultPreview:d,isActive:i,config:e!=null?e:{}});iC(P,Y)||(P.textContent=d),P.style.display=""}if(!s&&i&&n.activeMinHeight&&(o.style.minHeight=n.activeMinHeight),!a)return o.append(l,P),o;let z=C("div","persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-px-4 persona-py-3");z.style.display=s?"":"none";let j=t.chunks.join(""),ie=C("div","persona-whitespace-pre-wrap persona-text-xs persona-leading-snug persona-text-persona-muted");return ie.textContent=j||(t.status==="complete"?"No additional context was shared.":"Waiting for details\u2026"),z.appendChild(ie),(()=>{if(l.setAttribute("aria-expanded",s?"true":"false"),I){I.innerHTML="";let ge=Ee(s?"chevron-up":"chevron-down",16,"currentColor",2);ge?I.appendChild(ge):I.textContent=s?"Hide":"Show"}z.style.display=s?"":"none",P.style.display=s?"none":P.textContent||P.childNodes.length?"":"none"})(),o.append(l,P,z),o};var is=new Set,dC=(r,e)=>e==null?!1:typeof e=="string"?(r.textContent=e,!0):(r.appendChild(e),!0),cC=(r,e)=>{var a;let t=r.toolCall;if(!t)return"";let o=((a=t.chunks)!=null?a:[]).join("").trim();if(o)return o.split(/\r?\n/).map(i=>i.trim()).filter(Boolean).slice(-e).join(`
|
|
73
|
+
`);let n=Ya(t.args).trim();return n?n.split(/\r?\n/).map(s=>s.trim()).filter(Boolean).slice(0,e).join(`
|
|
74
|
+
`):""},pC=(r,e)=>{var u,f,p,m,y;let t=r.toolCall,o=(u=e==null?void 0:e.features)==null?void 0:u.toolCallDisplay,n=(f=o==null?void 0:o.collapsedMode)!=null?f:"tool-call",a=cC(r,(p=o==null?void 0:o.previewMaxLines)!=null?p:3),s=t?Jh(t):"";if(!t)return{summary:s,previewText:a,isActive:!1};let i=t.status!=="complete",d=(m=e==null?void 0:e.toolCall)!=null?m:{},l=s;return n==="tool-name"?l=((y=t.name)==null?void 0:y.trim())||s:n==="tool-preview"&&a&&(l=a),i&&d.activeTextTemplate?l=Vd(t,d.activeTextTemplate,l):!i&&d.completeTextTemplate&&(l=Vd(t,d.completeTextTemplate,l)),{summary:l,previewText:a,isActive:i}},zx=(r,e,t)=>{var u;let o=is.has(r),n=(u=t==null?void 0:t.toolCall)!=null?u:{},a=e.querySelector('button[data-expand-header="true"]'),s=e.querySelector(".persona-border-t"),i=e.querySelector('[data-persona-collapsed-preview="tool"]');if(!a||!s)return;a.setAttribute("aria-expanded",o?"true":"false");let d=a.querySelector(".persona-ml-auto"),l=d==null?void 0:d.querySelector(":scope > .persona-flex.persona-items-center");if(l){l.innerHTML="";let f=n.toggleTextColor||n.headerTextColor||"currentColor",p=Ee(o?"chevron-up":"chevron-down",16,f,2);p?l.appendChild(p):l.textContent=o?"Hide":"Show"}s.style.display=o?"":"none",i&&(i.style.display=o?"none":i.textContent||i.childNodes.length?"":"none")},lu=(r,e)=>{var j,ie,ve,Xe,Ae,We,Me,Ue,Be;let t=r.toolCall,o=(j=e==null?void 0:e.toolCall)!=null?j:{},n=C("div",["persona-message-bubble","persona-tool-bubble","persona-w-full","persona-max-w-[85%]","persona-rounded-2xl","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-shadow-sm","persona-overflow-hidden","persona-px-0","persona-py-0"].join(" "));if(n.id=`bubble-${r.id}`,n.setAttribute("data-message-id",r.id),o.backgroundColor&&(n.style.backgroundColor=o.backgroundColor),o.borderColor&&(n.style.borderColor=o.borderColor),o.borderWidth&&(n.style.borderWidth=o.borderWidth),o.borderRadius&&(n.style.borderRadius=o.borderRadius),n.style.boxShadow=o.shadow!==void 0?o.shadow.trim()===""?"none":o.shadow:"var(--persona-tool-bubble-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",!t)return n;let a=(ve=(ie=e==null?void 0:e.features)==null?void 0:ie.toolCallDisplay)!=null?ve:{},s=a.expandable!==!1,i=s&&is.has(r.id),{summary:d,previewText:l,isActive:u}=pC(r,e),f=C("button",s?"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none":"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-default persona-border-none");f.type="button",s&&(f.setAttribute("aria-expanded",i?"true":"false"),f.setAttribute("data-expand-header","true")),f.setAttribute("data-bubble-type","tool"),o.headerBackgroundColor&&(f.style.backgroundColor=o.headerBackgroundColor),o.headerPaddingX&&(f.style.paddingLeft=o.headerPaddingX,f.style.paddingRight=o.headerPaddingX),o.headerPaddingY&&(f.style.paddingTop=o.headerPaddingY,f.style.paddingBottom=o.headerPaddingY);let p=C("div","persona-flex persona-flex-col persona-text-left"),m=C("span","persona-text-xs persona-text-persona-primary");o.headerTextColor&&(m.style.color=o.headerTextColor);let y=String((Xe=t.startedAt)!=null?Xe:Date.now()),h=()=>{let Z=C("span","");return Z.setAttribute("data-tool-elapsed",y),Z.textContent=Xs(t),Z},T=(We=o.renderCollapsedSummary)==null?void 0:We.call(o,{message:r,toolCall:t,defaultSummary:d,previewText:l,collapsedMode:(Ae=a.collapsedMode)!=null?Ae:"tool-call",isActive:u,config:e!=null?e:{},elapsed:Xs(t),createElapsedElement:h});typeof T=="string"&&T.trim()?(m.textContent=T,p.appendChild(m)):T instanceof HTMLElement?p.appendChild(T):(m.textContent=d,p.appendChild(m));let M=(Me=a.loadingAnimation)!=null?Me:"none",k=o.activeTextTemplate,L=o.completeTextTemplate,x=u?k:L,w=T instanceof HTMLElement,v=(Z,ne,me)=>{let be=me;for(let ye of ne){let Y=C("span","persona-tool-char");Y.style.setProperty("--char-index",String(be)),Y.textContent=ye===" "?"\xA0":ye,Z.appendChild(Y),be++}return be},E=(Z,ne)=>{var Y;m.textContent="";let me=((Y=t.name)==null?void 0:Y.trim())||"tool",be=tl(Z,me),ye=0;for(let ge of be){let Oe=ge.styles.length>0?(()=>{let ce=C("span",ge.styles.map(ae=>`persona-tool-text-${ae}`).join(" "));return m.appendChild(ce),ce})():m;if(ge.isDuration&&u)Oe.appendChild(h());else{let ce=ge.isDuration?Xs(t):ge.text;ne?ye=v(Oe,ce,ye):Oe.appendChild(document.createTextNode(ce))}}};if(!w)if(u&&M!=="none"){let Z=(Ue=o.loadingAnimationDuration)!=null?Ue:2e3;if(m.setAttribute("data-preserve-animation","true"),M==="pulse")m.classList.add("persona-tool-loading-pulse"),m.style.setProperty("--persona-tool-anim-duration",`${Z}ms`),x&&E(x,!1);else if(m.classList.add(`persona-tool-loading-${M}`),m.style.setProperty("--persona-tool-anim-duration",`${Z}ms`),M==="shimmer-color"&&(o.loadingAnimationColor&&m.style.setProperty("--persona-tool-anim-color",o.loadingAnimationColor),o.loadingAnimationSecondaryColor&&m.style.setProperty("--persona-tool-anim-secondary-color",o.loadingAnimationSecondaryColor)),x)E(x,!0);else{let ne=m.textContent||d;m.textContent="",v(m,ne,0)}}else x&&E(x,!1);let H=null;if(s){H=C("div","persona-flex persona-items-center");let Z=o.toggleTextColor||o.headerTextColor||"currentColor",ne=Ee(i?"chevron-up":"chevron-down",16,Z,2);ne?H.appendChild(ne):H.textContent=i?"Hide":"Show";let me=C("div","persona-flex persona-items-center persona-gap-2 persona-ml-auto");me.append(H),f.append(p,me)}else f.append(p);let I=C("div","persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted");if(I.setAttribute("data-persona-collapsed-preview","tool"),I.style.display="none",I.style.whiteSpace="pre-wrap",!i&&u&&a.activePreview&&l){let Z=(Be=o.renderCollapsedPreview)==null?void 0:Be.call(o,{message:r,toolCall:t,defaultPreview:l,isActive:u,config:e!=null?e:{}});dC(I,Z)||(I.textContent=l),I.style.display=""}if(!i&&u&&a.activeMinHeight&&(n.style.minHeight=a.activeMinHeight),!s)return n.append(f,I),n;let P=C("div","persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-space-y-3 persona-px-4 persona-py-3");if(P.style.display=i?"":"none",o.contentBackgroundColor&&(P.style.backgroundColor=o.contentBackgroundColor),o.contentTextColor&&(P.style.color=o.contentTextColor),o.contentPaddingX&&(P.style.paddingLeft=o.contentPaddingX,P.style.paddingRight=o.contentPaddingX),o.contentPaddingY&&(P.style.paddingTop=o.contentPaddingY,P.style.paddingBottom=o.contentPaddingY),t.name){let Z=C("div","persona-text-xs persona-text-persona-muted persona-italic");o.contentTextColor?Z.style.color=o.contentTextColor:o.headerTextColor&&(Z.style.color=o.headerTextColor),Z.textContent=t.name,P.appendChild(Z)}if(t.args!==void 0){let Z=C("div","persona-space-y-1"),ne=C("div","persona-text-xs persona-text-persona-muted");o.labelTextColor&&(ne.style.color=o.labelTextColor),ne.textContent="Arguments";let me=C("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");me.style.fontSize="0.75rem",me.style.lineHeight="1rem",o.codeBlockBackgroundColor&&(me.style.backgroundColor=o.codeBlockBackgroundColor),o.codeBlockBorderColor&&(me.style.borderColor=o.codeBlockBorderColor),o.codeBlockTextColor&&(me.style.color=o.codeBlockTextColor),me.textContent=Ya(t.args),Z.append(ne,me),P.appendChild(Z)}if(t.chunks&&t.chunks.length){let Z=C("div","persona-space-y-1"),ne=C("div","persona-text-xs persona-text-persona-muted");o.labelTextColor&&(ne.style.color=o.labelTextColor),ne.textContent="Activity";let me=C("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");me.style.fontSize="0.75rem",me.style.lineHeight="1rem",o.codeBlockBackgroundColor&&(me.style.backgroundColor=o.codeBlockBackgroundColor),o.codeBlockBorderColor&&(me.style.borderColor=o.codeBlockBorderColor),o.codeBlockTextColor&&(me.style.color=o.codeBlockTextColor),me.textContent=t.chunks.join(""),Z.append(ne,me),P.appendChild(Z)}if(t.status==="complete"&&t.result!==void 0){let Z=C("div","persona-space-y-1"),ne=C("div","persona-text-xs persona-text-persona-muted");o.labelTextColor&&(ne.style.color=o.labelTextColor),ne.textContent="Result";let me=C("pre","persona-max-h-48 persona-overflow-auto persona-whitespace-pre-wrap persona-rounded-lg persona-border persona-border-gray-100 persona-bg-white persona-px-3 persona-py-2 persona-text-xs persona-text-persona-primary");me.style.fontSize="0.75rem",me.style.lineHeight="1rem",o.codeBlockBackgroundColor&&(me.style.backgroundColor=o.codeBlockBackgroundColor),o.codeBlockBorderColor&&(me.style.borderColor=o.codeBlockBorderColor),o.codeBlockTextColor&&(me.style.color=o.codeBlockTextColor),me.textContent=Ya(t.result),Z.append(ne,me),P.appendChild(Z)}if(t.status==="complete"&&typeof t.duration=="number"){let Z=C("div","persona-text-xs persona-text-persona-muted");o.contentTextColor&&(Z.style.color=o.contentTextColor),Z.textContent=`Duration: ${t.duration}ms`,P.appendChild(Z)}return(()=>{if(f.setAttribute("aria-expanded",i?"true":"false"),H){H.innerHTML="";let Z=o.toggleTextColor||o.headerTextColor||"currentColor",ne=Ee(i?"chevron-up":"chevron-down",16,Z,2);ne?H.appendChild(ne):H.textContent=i?"Hide":"Show"}P.style.display=i?"":"none",I.style.display=i?"none":I.textContent||I.childNodes.length?"":"none"})(),n.append(f,I,P),n};var Gl=new Map,uC=r=>{let t=(r.startsWith(Cn)?r.slice(Cn.length):r).replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_\-\s.]+/).filter(Boolean);if(t.length===0)return r;let o=t.join(" ").toLowerCase();return o.charAt(0).toUpperCase()+o.slice(1)},$x=r=>(r==null?void 0:r.approval)!==!1?r==null?void 0:r.approval:void 0,Vx=(r,e)=>{var o,n,a;let t=(n=(o=$x(e))==null?void 0:o.detailsDisplay)!=null?n:"collapsed";return(a=Gl.get(r))!=null?a:t==="expanded"},jx=(r,e,t)=>{var s,i;let o=$x(t);r.setAttribute("aria-expanded",e?"true":"false");let n=r.querySelector("[data-approval-details-label]");n&&(n.textContent=e?(s=o==null?void 0:o.hideDetailsLabel)!=null?s:"Hide details":(i=o==null?void 0:o.showDetailsLabel)!=null?i:"Show details");let a=r.querySelector("[data-approval-details-chevron]");if(a){a.innerHTML="";let d=Ee(e?"chevron-up":"chevron-down",14,"currentColor",2);d&&a.appendChild(d)}},Gx=(r,e,t)=>{let o=e.querySelector('button[data-bubble-type="approval"]'),n=e.querySelector("[data-approval-details]");if(!o||!n)return;let a=Vx(r,t);jx(o,a,t),n.style.display=a?"":"none"};var Kl=(r,e)=>{var E,H,I,P,z,j,ie,ve,Xe,Ae,We,Me,Ue,Be,Z;let t=r.approval,o=(e==null?void 0:e.approval)!==!1?e==null?void 0:e.approval:void 0,n=(t==null?void 0:t.status)==="pending",a=C("div",["persona-approval-bubble","persona-w-full","persona-max-w-[85%]","persona-rounded-2xl","persona-border","persona-shadow-sm","persona-overflow-hidden"].join(" "));if(a.id=`bubble-${r.id}`,a.setAttribute("data-message-id",r.id),a.style.backgroundColor=(E=o==null?void 0:o.backgroundColor)!=null?E:"var(--persona-approval-bg, #fefce8)",a.style.borderColor=(H=o==null?void 0:o.borderColor)!=null?H:"var(--persona-approval-border, #fef08a)",a.style.boxShadow=(o==null?void 0:o.shadow)!==void 0?o.shadow.trim()===""?"none":o.shadow:"var(--persona-approval-shadow, 0 5px 15px rgba(15, 23, 42, 0.08))",!t)return a;let s=C("div","persona-flex persona-items-start persona-gap-3 persona-px-4 persona-py-3"),i=C("div","persona-flex-shrink-0 persona-mt-0.5");i.setAttribute("data-approval-icon","true");let d=t.status==="denied"?"shield-x":t.status==="timeout"?"shield-alert":"shield-check",l=t.status==="approved"?"var(--persona-feedback-success, #16a34a)":t.status==="denied"?"var(--persona-feedback-error, #dc2626)":t.status==="timeout"?"var(--persona-feedback-warning, #ca8a04)":(I=o==null?void 0:o.titleColor)!=null?I:"currentColor",u=Ee(d,20,l,2);u&&i.appendChild(u);let f=C("div","persona-flex-1 persona-min-w-0"),p=C("div","persona-flex persona-items-center persona-gap-2"),m=C("span","persona-text-sm persona-font-medium persona-text-persona-primary");if(o!=null&&o.titleColor&&(m.style.color=o.titleColor),m.textContent=(P=o==null?void 0:o.title)!=null?P:"Approval Required",p.appendChild(m),!n){let ne=C("span","persona-inline-flex persona-items-center persona-px-2 persona-py-0.5 persona-rounded-full persona-text-xs persona-font-medium");ne.setAttribute("data-approval-status",t.status),t.status==="approved"?(ne.style.backgroundColor="var(--persona-palette-colors-success-100, #dcfce7)",ne.style.color="var(--persona-palette-colors-success-700, #15803d)",ne.textContent="Approved"):t.status==="denied"?(ne.style.backgroundColor="var(--persona-palette-colors-error-100, #fee2e2)",ne.style.color="var(--persona-palette-colors-error-700, #b91c1c)",ne.textContent="Denied"):t.status==="timeout"&&(ne.style.backgroundColor="var(--persona-palette-colors-warning-100, #fef3c7)",ne.style.color="var(--persona-palette-colors-warning-700, #b45309)",ne.textContent="Timeout"),p.appendChild(ne)}f.appendChild(p);let h=t.toolType==="webmcp"||t.toolName.startsWith(Cn)?Hd(t.toolName):void 0,T=(z=o==null?void 0:o.formatDescription)==null?void 0:z.call(o,{toolName:t.toolName,toolType:t.toolType,description:t.description,parameters:t.parameters,...h?{displayTitle:h}:{},...t.reason?{reason:t.reason}:{}}),M=!t.toolName,k=T||(M?t.description:`The assistant wants to use \u201C${h!=null?h:uC(t.toolName)}\u201D.`),L=C("p","persona-text-sm persona-mt-0.5 persona-text-persona-muted");if(L.setAttribute("data-approval-summary","true"),o!=null&&o.descriptionColor&&(L.style.color=o.descriptionColor),L.textContent=k,f.appendChild(L),t.reason){let ne=C("p","persona-text-sm persona-mt-1 persona-text-persona-muted");ne.setAttribute("data-approval-reason","true"),o!=null&&o.reasonColor?ne.style.color=o.reasonColor:o!=null&&o.descriptionColor&&(ne.style.color=o.descriptionColor);let me=C("span","persona-font-medium");me.textContent=`${(j=o==null?void 0:o.reasonLabel)!=null?j:"Agent's stated reason:"} `,ne.appendChild(me),ne.appendChild(document.createTextNode(t.reason)),f.appendChild(ne)}let x=(ie=o==null?void 0:o.detailsDisplay)!=null?ie:"collapsed",w=!!t.description&&!M,v=w||!!t.parameters;if(x!=="hidden"&&v){let ne=Vx(r.id,e),me=C("button","persona-inline-flex persona-items-center persona-gap-1 persona-mt-1 persona-p-0 persona-border-none persona-bg-transparent persona-text-xs persona-font-medium persona-cursor-pointer persona-text-persona-muted");me.type="button",me.setAttribute("data-expand-header","true"),me.setAttribute("data-bubble-type","approval"),o!=null&&o.descriptionColor&&(me.style.color=o.descriptionColor);let be=C("span");be.setAttribute("data-approval-details-label","true");let ye=C("span","persona-inline-flex persona-items-center");ye.setAttribute("data-approval-details-chevron","true"),me.append(be,ye),jx(me,ne,e),f.appendChild(me);let Y=C("div");if(Y.setAttribute("data-approval-details","true"),Y.style.display=ne?"":"none",w){let ge=C("p","persona-text-sm persona-mt-1 persona-text-persona-muted");o!=null&&o.descriptionColor&&(ge.style.color=o.descriptionColor),ge.textContent=t.description,Y.appendChild(ge)}if(t.parameters){let ge=C("pre","persona-mt-2 persona-text-xs persona-p-2 persona-rounded persona-overflow-x-auto persona-max-h-32 persona-bg-persona-container persona-text-persona-primary");o!=null&&o.parameterBackgroundColor&&(ge.style.backgroundColor=o.parameterBackgroundColor),o!=null&&o.parameterTextColor&&(ge.style.color=o.parameterTextColor),ge.style.fontSize="0.75rem",ge.style.lineHeight="1rem",ge.textContent=Ya(t.parameters),Y.appendChild(ge)}f.appendChild(Y)}if(n){let ne=C("div","persona-flex persona-gap-2 persona-mt-2");ne.setAttribute("data-approval-buttons","true");let me=C("button","persona-inline-flex persona-items-center persona-px-3 persona-py-1.5 persona-rounded-md persona-text-xs persona-font-medium persona-border-none persona-cursor-pointer");me.type="button",me.style.backgroundColor=(ve=o==null?void 0:o.approveButtonColor)!=null?ve:"var(--persona-approval-approve-bg, #22c55e)",me.style.color=(Xe=o==null?void 0:o.approveButtonTextColor)!=null?Xe:"#ffffff",me.setAttribute("data-approval-action","approve");let be=Ee("shield-check",14,(Ae=o==null?void 0:o.approveButtonTextColor)!=null?Ae:"#ffffff",2);be&&(be.style.marginRight="4px",me.appendChild(be));let ye=document.createTextNode((We=o==null?void 0:o.approveLabel)!=null?We:"Approve");me.appendChild(ye);let Y=C("button","persona-inline-flex persona-items-center persona-px-3 persona-py-1.5 persona-rounded-md persona-text-xs persona-font-medium persona-cursor-pointer");Y.type="button",Y.style.backgroundColor=(Me=o==null?void 0:o.denyButtonColor)!=null?Me:"transparent",Y.style.color=(Ue=o==null?void 0:o.denyButtonTextColor)!=null?Ue:"var(--persona-feedback-error, #dc2626)",Y.style.border=`1px solid ${o!=null&&o.denyButtonTextColor?o.denyButtonTextColor:"var(--persona-palette-colors-error-200, #fca5a5)"}`,Y.setAttribute("data-approval-action","deny");let ge=Ee("shield-x",14,(Be=o==null?void 0:o.denyButtonTextColor)!=null?Be:"var(--persona-feedback-error, #dc2626)",2);ge&&(ge.style.marginRight="4px",Y.appendChild(ge));let Oe=document.createTextNode((Z=o==null?void 0:o.denyLabel)!=null?Z:"Deny");Y.appendChild(Oe),ne.append(me,Y),f.appendChild(ne)}return s.append(i,f),a.appendChild(s),a};var Kx=r=>{let e=[],t=null;return{buttons:e,render:(n,a,s,i,d,l)=>{r.innerHTML="",e.length=0;let u=(l==null?void 0:l.agentPushed)===!0;if(u||(t=null),!n||!n.length||!u&&(i!=null?i:a?a.getMessages():[]).some(T=>T.role==="user"))return;let f=document.createDocumentFragment(),p=a?a.isStreaming():!1,m=y=>{switch(y){case"serif":return'Georgia, "Times New Roman", Times, serif';case"mono":return'"Courier New", Courier, "Lucida Console", Monaco, monospace';default:return'-apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif'}};if(n.forEach(y=>{let h=C("button","persona-rounded-button persona-bg-persona-surface persona-px-3 persona-py-1.5 persona-text-xs persona-font-medium persona-text-persona-primary hover:persona-opacity-80 persona-cursor-pointer persona-border persona-border-persona-border");h.type="button",h.textContent=y,h.disabled=p,d!=null&&d.fontFamily&&(h.style.fontFamily=m(d.fontFamily)),d!=null&&d.fontWeight&&(h.style.fontWeight=d.fontWeight),d!=null&&d.paddingX&&(h.style.paddingLeft=d.paddingX,h.style.paddingRight=d.paddingX),d!=null&&d.paddingY&&(h.style.paddingTop=d.paddingY,h.style.paddingBottom=d.paddingY),h.addEventListener("click",()=>{!a||a.isStreaming()||(s.value="",u&&r.dispatchEvent(new CustomEvent("persona:suggestReplies:selected",{detail:{suggestion:y},bubbles:!0,composed:!0})),a.sendMessage(y))}),f.appendChild(h),e.push(h)}),r.appendChild(f),u){let y=JSON.stringify(n);y!==t&&(t=y,r.dispatchEvent(new CustomEvent("persona:suggestReplies:shown",{detail:{suggestions:[...n]},bubbles:!0,composed:!0})))}}}};var pi=class{constructor(e=2e3,t=null){this.head=0;this.count=0;this.totalCaptured=0;this.eventTypesSet=new Set;this.maxSize=e,this.buffer=new Array(e),this.store=t}push(e){var t;this.buffer[this.head]=e,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.totalCaptured++,this.eventTypesSet.add(e.type),(t=this.store)==null||t.put(e)}getAll(){return this.count===0?[]:this.count<this.maxSize?this.buffer.slice(0,this.count):[...this.buffer.slice(this.head,this.maxSize),...this.buffer.slice(0,this.head)]}async restore(){if(!this.store)return 0;let e=await this.store.getAll();if(e.length===0)return 0;let t=e.length>this.maxSize?e.slice(e.length-this.maxSize):e;for(let o of t)this.buffer[this.head]=o,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.eventTypesSet.add(o.type);return this.totalCaptured=e.length,t.length}getAllFromStore(){return this.store?this.store.getAll():Promise.resolve(this.getAll())}getRecent(e){let t=this.getAll();return e>=t.length?t:t.slice(t.length-e)}getSize(){return this.count}getTotalCaptured(){return this.totalCaptured}getEvictedCount(){return this.totalCaptured-this.count}clear(){var e;this.buffer=new Array(this.maxSize),this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),(e=this.store)==null||e.clear()}destroy(){var e;this.buffer=[],this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),(e=this.store)==null||e.destroy()}getEventTypes(){return Array.from(this.eventTypesSet)}};var ui=class{constructor(e="persona-event-stream",t="events"){this.db=null;this.pendingWrites=[];this.flushScheduled=!1;this.isDestroyed=!1;this.dbName=e,this.storeName=t}open(){return new Promise((e,t)=>{try{let o=indexedDB.open(this.dbName,1);o.onupgradeneeded=()=>{let n=o.result;n.objectStoreNames.contains(this.storeName)||n.createObjectStore(this.storeName,{keyPath:"id"}).createIndex("timestamp","timestamp",{unique:!1})},o.onsuccess=()=>{this.db=o.result,e()},o.onerror=()=>{t(o.error)}}catch(o){t(o)}})}put(e){!this.db||this.isDestroyed||(this.pendingWrites.push(e),this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushWrites())))}putBatch(e){if(!(!this.db||this.isDestroyed||e.length===0))try{let o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let n of e)o.put(n)}catch{}}getAll(){return new Promise((e,t)=>{if(!this.db){e([]);return}try{let s=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).index("timestamp").getAll();s.onsuccess=()=>{e(s.result)},s.onerror=()=>{t(s.error)}}catch(o){t(o)}})}getCount(){return new Promise((e,t)=>{if(!this.db){e(0);return}try{let a=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).count();a.onsuccess=()=>{e(a.result)},a.onerror=()=>{t(a.error)}}catch(o){t(o)}})}clear(){return new Promise((e,t)=>{if(!this.db){e();return}this.pendingWrites=[];try{let a=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).clear();a.onsuccess=()=>{e()},a.onerror=()=>{t(a.error)}}catch(o){t(o)}})}close(){this.db&&(this.db.close(),this.db=null)}destroy(){return this.isDestroyed=!0,this.pendingWrites=[],this.close(),new Promise((e,t)=>{try{let o=indexedDB.deleteDatabase(this.dbName);o.onsuccess=()=>{e()},o.onerror=()=>{t(o.error)}}catch(o){t(o)}})}flushWrites(){if(this.flushScheduled=!1,!this.db||this.isDestroyed||this.pendingWrites.length===0)return;let e=this.pendingWrites;this.pendingWrites=[];try{let o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let n of e)o.put(n)}catch{}}};var fC=new Set(["flow_start","flow_run_start","agent_start","dispatch_start","run_start"]),mC=new Set(["step_start","execution_start"]),gC=new Set(["step_delta","step_chunk","chunk","agent_turn_delta"]),hC=new Set(["step_complete","agent_turn_complete"]),xC=new Set(["flow_complete","agent_complete"]),Xx=new Set(["step_error","flow_error","agent_error","dispatch_error","error"]),Yx=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),Do=r=>typeof r=="number"&&Number.isFinite(r)?r:void 0,ka=(r,e)=>{let t=r[e];return Yx(t)?t:void 0};function du(r){return r>0?Math.max(1,Math.ceil(r/4)):0}function Xl(r,e){if(!(r<=0||e===void 0||e<250))return r/(e/1e3)}function yC(r,e){return typeof e.type=="string"?e.type:r}function bC(r){return typeof r.text=="string"?r.text:typeof r.delta=="string"?r.delta:typeof r.content=="string"?r.content:typeof r.chunk=="string"?r.chunk:""}function vC(r,e){return r==="step_delta"||r==="step_chunk"?e.stepType!=="tool"&&e.executionType!=="context":r!=="agent_turn_delta"?!0:(typeof e.contentType=="string"?e.contentType:typeof e.content_type=="string"?e.content_type:void 0)==="text"}function Qx(r){var o,n,a,s,i;let e=ka(r,"result"),t=[ka(r,"tokens"),ka(r,"totalTokens"),e?ka(e,"tokens"):void 0,ka(r,"usage"),e?ka(e,"usage"):void 0];for(let d of t){if(!d)continue;let l=(n=(o=Do(d.output))!=null?o:Do(d.outputTokens))!=null?n:Do(d.completionTokens);if(l!==void 0)return l}return(i=(a=Do(r.outputTokens))!=null?a:Do(r.completionTokens))!=null?i:e?(s=Do(e.outputTokens))!=null?s:Do(e.completionTokens):void 0}function CC(r){var t,o,n,a,s;let e=ka(r,"result");return(s=(n=(o=(t=Do(r.executionTime))!=null?t:Do(r.executionTimeMs))!=null?o:Do(r.execution_time))!=null?n:Do(r.duration))!=null?s:e?(a=Do(e.executionTime))!=null?a:Do(e.executionTimeMs):void 0}function wC(){return typeof performance!="undefined"&&typeof performance.now=="function"?performance.now():Date.now()}var fi=class{constructor(e=wC){this.metric={status:"idle"};this.run=null;this.now=e}getMetric(){let e=this.run;if(e&&this.metric.status==="running"&&e.firstDeltaAt!==void 0&&this.metric.outputTokens!==void 0){let t=this.now()-e.firstDeltaAt;return{...this.metric,durationMs:t,tokensPerSecond:Xl(this.metric.outputTokens,t)}}return this.metric}reset(){this.run=null,this.metric={status:"idle"}}startRun(e){this.run={startedAt:e,visibleCharCount:0,exactOutputTokens:0},this.metric={status:"running"}}processEvent(e,t){var a;if(!Yx(t)){Xx.has(e)&&this.run&&(this.run=null,this.metric={status:"error"});return}let o=yC(e,t),n=this.now();if(fC.has(o)){this.startRun(n);return}if(mC.has(o)){this.run||this.startRun(n);return}if(gC.has(o)){if(!vC(o,t))return;let s=bC(t);if(!s)return;this.run||this.startRun(n);let i=this.run;(a=i.firstDeltaAt)!=null||(i.firstDeltaAt=n),i.visibleCharCount+=s.length;let d=i.exactOutputTokens+du(i.visibleCharCount),l=n-i.firstDeltaAt;this.metric={status:"running",tokensPerSecond:Xl(d,l),outputTokens:d,durationMs:l,source:i.exactOutputTokens>0?"usage":"estimate"};return}if(hC.has(o)){if(!this.run)return;let s=this.run,i=Qx(t);i!==void 0&&(s.exactOutputTokens+=i,s.visibleCharCount=0);let d=s.exactOutputTokens>0,l=s.exactOutputTokens+du(s.visibleCharCount),u=this.resolveDuration(s,t,n);this.metric={status:"running",tokensPerSecond:Xl(l,u),outputTokens:l,durationMs:u,source:d?"usage":"estimate"};return}if(xC.has(o)){if(!this.run)return;let s=this.run,i=Qx(t),d=i!=null?i:s.exactOutputTokens+du(s.visibleCharCount),l=i!==void 0||s.exactOutputTokens>0?"usage":"estimate",u=this.resolveDuration(s,t,n);this.metric={status:"complete",tokensPerSecond:Xl(d,u),outputTokens:d,durationMs:u,source:l},this.run=null;return}if(Xx.has(o)){if(!this.run)return;this.run=null,this.metric={status:"error"}}}resolveDuration(e,t,o){let n=e.firstDeltaAt!==void 0?o-e.firstDeltaAt:void 0;if(n!==void 0&&n>=250)return n;let a=CC(t);return a!=null?a:o-e.startedAt}};function ls(r,e){e&&e.split(/\s+/).forEach(t=>t&&r.classList.add(t))}var AC={flow_:{bg:"var(--persona-palette-colors-success-100, #dcfce7)",text:"var(--persona-palette-colors-success-700, #166534)"},step_:{bg:"var(--persona-palette-colors-primary-100, #f5f5f5)",text:"var(--persona-palette-colors-primary-700, #0a0a0a)"},reason_:{bg:"var(--persona-palette-colors-warning-100, #ffedd5)",text:"var(--persona-palette-colors-warning-700, #9a3412)"},tool_:{bg:"var(--persona-palette-colors-purple-100, #f3e8ff)",text:"var(--persona-palette-colors-purple-700, #6b21a8)"},agent_:{bg:"var(--persona-palette-colors-teal-100, #ccfbf1)",text:"var(--persona-palette-colors-teal-700, #115e59)"},error:{bg:"var(--persona-palette-colors-error-100, #fecaca)",text:"var(--persona-palette-colors-error-700, #991b1b)"}},SC={bg:"var(--persona-palette-colors-gray-100, #f3f4f6)",text:"var(--persona-palette-colors-gray-600, #4b5563)"},TC=["flowName","stepName","reasoningText","text","name","tool","toolName"],MC=100;function kC(r,e){let t={...AC,...e};if(t[r])return t[r];for(let o of Object.keys(t))if(o.endsWith("_")&&r.startsWith(o))return t[o];return SC}function EC(r,e){return`+${((r-e)/1e3).toFixed(3)}s`}function LC(r){let e=new Date(r),t=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),n=String(e.getSeconds()).padStart(2,"0"),a=String(e.getMilliseconds()).padStart(3,"0");return`${t}:${o}:${n}.${a}`}function PC(r,e){try{let t=JSON.parse(r);if(typeof t!="object"||t===null)return null;for(let o of e){let n=o.split("."),a=t;for(let s of n)if(a&&typeof a=="object"&&a!==null)a=a[s];else{a=void 0;break}if(typeof a=="string"&&a.trim())return a.trim()}}catch{}return null}function RC(r){var e;return(e=navigator.clipboard)!=null&&e.writeText?navigator.clipboard.writeText(r):new Promise(t=>{let o=document.createElement("textarea");o.value=r,o.style.position="fixed",o.style.opacity="0",document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o),t()})}function IC(r){let e;try{e=JSON.parse(r.payload)}catch{e=r.payload}return JSON.stringify({type:r.type,timestamp:new Date(r.timestamp).toISOString(),payload:e},null,2)}function HC(r){return r.tokensPerSecond===void 0||!Number.isFinite(r.tokensPerSecond)?"-- tok/s":`${r.tokensPerSecond.toFixed(1)} tok/s`}function WC(r){let e=[];return r.outputTokens!==void 0&&e.push(`${r.outputTokens.toLocaleString()} tok`),r.durationMs!==void 0&&e.push(`${(r.durationMs/1e3).toFixed(2)}s`),r.source&&e.push(r.source),e.join(" \xB7 ")}function BC(r,e,t){let o,n;try{n=JSON.parse(r.payload),o=JSON.stringify(n,null,2)}catch{n=r.payload,o=r.payload}let a=e.find(i=>i.renderEventStreamPayload);if(a!=null&&a.renderEventStreamPayload&&t){let i=a.renderEventStreamPayload({event:r,config:t,defaultRenderer:()=>s(),parsedPayload:n});if(i)return i}return s();function s(){let i=C("div","persona-bg-persona-container persona-border-t persona-border-persona-divider persona-px-3 persona-py-2 persona-ml-4 persona-mr-3 persona-mb-1 persona-rounded-b persona-overflow-auto persona-max-h-[300px]"),d=C("pre","persona-m-0 persona-whitespace-pre-wrap persona-break-all persona-text-[11px] persona-text-persona-secondary persona-font-mono");return d.textContent=o,i.appendChild(d),i}}function cu(r,e,t,o,n,a,s,i){var p;let d=n.has(r.id),l=C("div","persona-border-b persona-border-persona-divider persona-text-xs");ls(l,(p=o.classNames)==null?void 0:p.eventRow);let u=s.find(m=>m.renderEventStreamRow);if(u!=null&&u.renderEventStreamRow&&i){let m=u.renderEventStreamRow({event:r,index:e,config:i,defaultRenderer:()=>f(),isExpanded:d,onToggleExpand:()=>a(r.id)});if(m)return l.appendChild(m),l}return l.appendChild(f()),l;function f(){var j,ie;let m=C("div",""),y=C("div","persona-flex persona-items-center persona-gap-2 persona-px-3 persona-py-3 hover:persona-bg-persona-container persona-cursor-pointer persona-group");y.setAttribute("data-event-id",r.id);let h=C("span","persona-flex-shrink-0 persona-text-persona-muted persona-w-4 persona-text-center persona-flex persona-items-center persona-justify-center"),T=Ee(d?"chevron-down":"chevron-right","14px","currentColor",2);T&&h.appendChild(T);let M=C("span","persona-text-[11px] persona-text-persona-muted persona-whitespace-nowrap persona-flex-shrink-0 persona-font-mono persona-w-[70px]"),k=(j=o.timestampFormat)!=null?j:"relative";M.textContent=k==="relative"?EC(r.timestamp,t):LC(r.timestamp);let L=null;o.showSequenceNumbers!==!1&&(L=C("span","persona-text-[11px] persona-text-persona-muted persona-font-mono persona-flex-shrink-0 persona-w-[28px] persona-text-right"),L.textContent=String(e+1));let x=kC(r.type,o.badgeColors),w=C("span","persona-inline-flex persona-items-center persona-px-2 persona-py-0.5 persona-rounded persona-text-[11px] persona-font-mono persona-font-medium persona-whitespace-nowrap persona-flex-shrink-0 persona-border");w.style.backgroundColor=x.bg,w.style.color=x.text,w.style.borderColor=x.text+"50",w.textContent=r.type;let v=(ie=o.descriptionFields)!=null?ie:TC,E=PC(r.payload,v),H=null;E&&(H=C("span","persona-text-[11px] persona-text-persona-secondary persona-truncate persona-min-w-0"),H.textContent=E);let I=C("div","persona-flex-1 persona-min-w-0"),P=C("button","persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-flex-shrink-0 persona-border-none persona-bg-transparent persona-p-0"),z=Ee("clipboard","12px","currentColor",1.5);return z&&P.appendChild(z),P.addEventListener("click",async ve=>{ve.stopPropagation(),await RC(IC(r)),P.innerHTML="";let Xe=Ee("check","12px","currentColor",1.5);Xe&&P.appendChild(Xe),setTimeout(()=>{P.innerHTML="";let Ae=Ee("clipboard","12px","currentColor",1.5);Ae&&P.appendChild(Ae)},1500)}),y.appendChild(h),y.appendChild(M),L&&y.appendChild(L),y.appendChild(w),H&&y.appendChild(H),y.appendChild(I),y.appendChild(P),m.appendChild(y),d&&m.appendChild(BC(r,s,i)),m}}function Jx(r){var y,h,T,M,k;let{buffer:e,getFullHistory:t,onClose:o,config:n,plugins:a=[],getThroughput:s}=r,i=(y=n==null?void 0:n.features)==null?void 0:y.scrollToBottom,d=(i==null?void 0:i.enabled)!==!1,l=(h=i==null?void 0:i.iconName)!=null?h:"arrow-down",u=(T=i==null?void 0:i.label)!=null?T:"",f=(k=(M=n==null?void 0:n.features)==null?void 0:M.eventStream)!=null?k:{},p=a.find(L=>L.renderEventStreamView);if(p!=null&&p.renderEventStreamView&&n){let L=p.renderEventStreamView({config:n,events:e.getAll(),defaultRenderer:()=>m().element,onClose:o});if(L)return{element:L,update:()=>{},destroy:()=>{}}}return m();function m(){let L=f.classNames,x=C("div","persona-event-stream-view persona-flex persona-flex-col persona-flex-1 persona-min-h-0");ls(x,L==null?void 0:L.panel);let w=[],v="",E="",H=null,I=[],P={},z=0,j=Rl(),ie=0,ve=0,Xe=!1,Ae=null,We=!1,Me=0,Ue=new Set,Be=new Map,Z="",ne="",me=null,be,ye,Y,ge,Oe,ce=null,ae=null,Q=null;function Tt(){let Ce=C("div","persona-relative persona-flex persona-flex-col persona-flex-shrink-0"),de=C("div","persona-flex persona-items-center persona-gap-2 persona-px-4 persona-py-3 persona-pb-0 persona-border-persona-divider persona-bg-persona-surface persona-overflow-hidden");ls(de,L==null?void 0:L.headerBar);let rt=C("span","persona-text-sm persona-font-medium persona-text-persona-primary persona-whitespace-nowrap");if(rt.textContent="Events",be=C("span","persona-text-[11px] persona-font-mono persona-bg-persona-container persona-text-persona-muted persona-px-2 persona-py-0.5 persona-rounded persona-border persona-border-persona-border"),be.textContent="0",s){ae=C("div","persona-relative persona-flex persona-items-center persona-gap-1.5 persona-whitespace-nowrap persona-ml-1"),ae.style.cursor="help";let Dr=C("span","persona-text-sm persona-font-medium persona-text-persona-primary persona-whitespace-nowrap");Dr.textContent="Throughput",ce=C("span","persona-text-[11px] persona-font-mono persona-bg-persona-container persona-text-persona-muted persona-px-2 persona-py-0.5 persona-rounded persona-border persona-border-persona-border persona-tabular-nums"),ce.textContent="-- tok/s",Q=C("div","persona-absolute persona-z-50 persona-whitespace-nowrap persona-rounded persona-border persona-border-persona-border persona-bg-persona-container persona-text-persona-primary persona-text-[11px] persona-font-mono persona-px-2 persona-py-1 persona-shadow"),Q.style.display="none",Q.style.pointerEvents="none";let hr=ae,Sr=Q,Oo=()=>{if(!Sr.textContent)return;let Tr=hr.getBoundingClientRect(),io=Ce.getBoundingClientRect();Sr.style.left=`${Tr.left-io.left}px`,Sr.style.top=`${Tr.bottom-io.top+4}px`,Sr.style.display="block"},je=()=>{Sr.style.display="none"};ae.addEventListener("mouseenter",Oo),ae.addEventListener("mouseleave",je),ae.appendChild(Dr),ae.appendChild(ce)}let Ft=C("div","persona-flex-1");ye=C("select","persona-text-xs persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded persona-px-2.5 persona-py-1 persona-text-persona-primary persona-cursor-pointer");let zt=C("option","");zt.value="",zt.textContent="All events",ye.appendChild(zt),Y=C("button","persona-inline-flex persona-items-center persona-gap-1.5 persona-rounded persona-text-xs persona-text-persona-muted hover:persona-bg-persona-container hover:persona-text-persona-primary persona-cursor-pointer persona-border persona-border-persona-border persona-bg-persona-surface persona-flex-shrink-0 persona-px-2.5 persona-py-1"),Y.type="button",Y.title="Copy All";let vr=Ee("clipboard-copy","12px","currentColor",1.5);vr&&Y.appendChild(vr);let xt=C("span","persona-text-xs");xt.textContent="Copy All",Y.appendChild(xt),de.appendChild(rt),de.appendChild(be),ae&&de.appendChild(ae),de.appendChild(Ft),de.appendChild(ye),de.appendChild(Y);let It=C("div","persona-relative persona-px-4 persona-py-2.5 persona-border-b persona-border-persona-divider persona-bg-persona-surface");ls(It,L==null?void 0:L.searchBar);let tt=Ee("search","14px","var(--persona-muted, #9ca3af)",1.5),jt=C("span","persona-absolute persona-left-6 persona-top-1/2 persona--translate-y-1/2 persona-pointer-events-none persona-flex persona-items-center");tt&&jt.appendChild(tt),ge=C("input","persona-text-sm persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded-md persona-pl-8 persona-pr-3 persona-py-1 persona-w-full persona-text-persona-primary"),ls(ge,L==null?void 0:L.searchInput),ge.type="text",ge.placeholder="Search event payloads...",Oe=C("button","persona-absolute persona-right-5 persona-top-1/2 persona--translate-y-1/2 persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-0 persona-leading-none"),Oe.type="button",Oe.style.display="none";let cr=Ee("x","12px","currentColor",2);return cr&&Oe.appendChild(cr),It.appendChild(jt),It.appendChild(ge),It.appendChild(Oe),Ce.appendChild(de),Ce.appendChild(It),Q&&Ce.appendChild(Q),Ce}let Ye,De=a.find(Ce=>Ce.renderEventStreamToolbar);if(De!=null&&De.renderEventStreamToolbar&&n){let Ce=De.renderEventStreamToolbar({config:n,defaultRenderer:()=>Tt(),eventCount:e.getSize(),filteredCount:0,onFilterChange:de=>{v=de,dr(),O()},onSearchChange:de=>{E=de,dr(),O()}});Ye=Ce!=null?Ce:Tt()}else Ye=Tt();let le=C("div","persona-text-xs persona-text-persona-muted persona-text-center persona-py-0.5 persona-px-4 persona-bg-persona-container persona-border-b persona-border-persona-divider persona-italic persona-flex-shrink-0");le.style.display="none";function nt(){if(!s||!ce||!ae)return;let Ce=s();ce.textContent=HC(Ce);let de=WC(Ce);Q&&(Q.textContent=de,de||(Q.style.display="none")),de?ae.setAttribute("aria-label",de):ae.removeAttribute("aria-label")}let Re=C("div","persona-flex-1 persona-min-h-0 persona-relative"),K=C("div","persona-event-stream-list persona-overflow-y-auto persona-min-h-0");K.style.height="100%";let he=C("div","persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-transform persona--translate-x-1/2 persona-cursor-pointer persona-z-10 persona-text-xs");ls(he,L==null?void 0:L.scrollIndicator),he.style.display="none",he.setAttribute("data-persona-scroll-to-bottom-has-label",u?"true":"false");let it=Ee(l,"14px","currentColor",2);it&&he.appendChild(it);let Pt=C("span","");Pt.textContent=u,he.appendChild(Pt);let te=C("div","persona-flex persona-items-center persona-justify-center persona-h-full persona-text-sm persona-text-persona-muted");te.style.display="none",Re.appendChild(K),Re.appendChild(te),Re.appendChild(he),x.setAttribute("tabindex","0"),x.appendChild(Ye),x.appendChild(le),x.appendChild(Re);function _e(){let Ce=e.getAll(),de={};for(let xt of Ce)de[xt.type]=(de[xt.type]||0)+1;let rt=Object.keys(de).sort(),Ft=rt.length!==I.length||!rt.every((xt,It)=>xt===I[It]),zt=!Ft&&rt.some(xt=>de[xt]!==P[xt]),Pr=Ce.length!==Object.values(P).reduce((xt,It)=>xt+It,0);if(!Ft&&!zt&&!Pr||(I=rt,P=de,!ye))return;let vr=ye.value;if(ye.options[0].textContent="All events",Ft){for(;ye.options.length>1;)ye.remove(1);for(let xt of rt){let It=C("option","");It.value=xt,It.textContent=`${xt} (${de[xt]||0})`,ye.appendChild(It)}vr&&rt.includes(vr)?ye.value=vr:vr&&(ye.value="",v="")}else for(let xt=1;xt<ye.options.length;xt++){let It=ye.options[xt];It.textContent=`${It.value} (${de[It.value]||0})`}}function Ar(){let Ce=e.getAll();if(v&&(Ce=Ce.filter(de=>de.type===v)),E){let de=E.toLowerCase();Ce=Ce.filter(rt=>rt.type.toLowerCase().includes(de)||rt.payload.toLowerCase().includes(de))}return Ce}function Rt(){return v!==""||E!==""}function dr(){z=0,ie=0,j.resume(),he.style.display="none"}function Yr(Ce){Ue.has(Ce)?Ue.delete(Ce):Ue.add(Ce),me=Ce;let de=K.scrollTop,rt=j.isFollowing();We=!0,j.pause(),O(),K.scrollTop=de,rt&&j.resume(),We=!1}function zr(){return Aa(K,50)}function O(){ve=Date.now(),Xe=!1,nt(),_e();let Ce=e.getEvictedCount();Ce>0?(le.textContent=`${Ce.toLocaleString()} older events truncated`,le.style.display=""):le.style.display="none",w=Ar();let de=w.length,rt=e.getSize()>0;be&&(be.textContent=String(e.getSize())),de===0&&rt&&Rt()?(te.textContent=E?`No events matching '${E}'`:"No events matching filter",te.style.display="",K.style.display="none"):(te.style.display="none",K.style.display=""),Y&&(Y.title=Rt()?`Copy Filtered (${de})`:"Copy All"),d&&!j.isFollowing()&&de>z&&(ie+=de-z,Pt.textContent=u?`${u}${ie>0?` (${ie})`:""}`:"",he.style.display=""),z=de;let Ft=e.getAll(),zt=Ft.length>0?Ft[0].timestamp:0,Pr=new Set(w.map(It=>It.id));for(let It of Ue)Pr.has(It)||Ue.delete(It);let vr=v!==Z||E!==ne,xt=Be.size===0&&w.length>0;if(vr||xt||w.length===0){K.innerHTML="",Be.clear();let It=document.createDocumentFragment();for(let tt=0;tt<w.length;tt++){let jt=cu(w[tt],tt,zt,f,Ue,Yr,a,n);Be.set(w[tt].id,jt),It.appendChild(jt)}K.appendChild(It),Z=v,ne=E,me=null}else{if(me!==null){let tt=Be.get(me);if(tt&&tt.parentNode===K){let jt=w.findIndex(cr=>cr.id===me);if(jt>=0){let cr=cu(w[jt],jt,zt,f,Ue,Yr,a,n);K.insertBefore(cr,tt),tt.remove(),Be.set(me,cr)}}me=null}let It=new Set(w.map(tt=>tt.id));for(let[tt,jt]of Be)It.has(tt)||(jt.remove(),Be.delete(tt));for(let tt=0;tt<w.length;tt++){let jt=w[tt];if(!Be.has(jt.id)){let cr=cu(jt,tt,zt,f,Ue,Yr,a,n);Be.set(jt.id,cr),K.appendChild(cr)}}}j.isFollowing()&&(K.scrollTop=K.scrollHeight)}function fe(){if(Date.now()-ve>=MC){Ae!==null&&(cancelAnimationFrame(Ae),Ae=null),O();return}Xe||(Xe=!0,Ae=requestAnimationFrame(()=>{Ae=null,O()}))}let Ie=(Ce,de)=>{if(!Y)return;Y.innerHTML="";let rt=Ee(Ce,"12px","currentColor",1.5);rt&&Y.appendChild(rt);let Ft=C("span","persona-text-xs");Ft.textContent="Copy All",Y.appendChild(Ft),setTimeout(()=>{Y.innerHTML="";let zt=Ee("clipboard-copy","12px","currentColor",1.5);zt&&Y.appendChild(zt);let Pr=C("span","persona-text-xs");Pr.textContent="Copy All",Y.appendChild(Pr),Y.disabled=!1},de)},Je=async()=>{if(Y){Y.disabled=!0;try{let Ce;Rt()?Ce=w:t?(Ce=await t(),Ce.length===0&&(Ce=e.getAll())):Ce=e.getAll();let de=Ce.map(rt=>{try{return JSON.parse(rt.payload)}catch{return rt.payload}});await navigator.clipboard.writeText(JSON.stringify(de,null,2)),Ie("check",1500)}catch{Ie("x",1500)}}},qe=()=>{ye&&(v=ye.value,dr(),O())},ze=()=>{!ge||!Oe||(Oe.style.display=ge.value?"":"none",H&&clearTimeout(H),H=setTimeout(()=>{E=ge.value,dr(),O()},150))},lt=()=>{!ge||!Oe||(ge.value="",E="",Oe.style.display="none",H&&clearTimeout(H),dr(),O())},Mt=()=>{if(We)return;let Ce=K.scrollTop,{action:de,nextLastScrollTop:rt}=Il({following:j.isFollowing(),currentScrollTop:Ce,lastScrollTop:Me,nearBottom:zr(),userScrollThreshold:1,resumeRequiresDownwardScroll:!0});Me=rt,de==="resume"?(j.resume(),ie=0,he.style.display="none"):de==="pause"&&(j.pause(),d&&(Pt.textContent=u,he.style.display=""))},Dt=Ce=>{let de=Hl({following:j.isFollowing(),deltaY:Ce.deltaY,nearBottom:zr(),resumeWhenNearBottom:!0});de==="pause"?(j.pause(),d&&(Pt.textContent=u,he.style.display="")):de==="resume"&&(j.resume(),ie=0,he.style.display="none")},or=()=>{d&&(K.scrollTop=K.scrollHeight,j.resume(),ie=0,he.style.display="none")},X=Ce=>{let de=Ce.target;if(!de||de.closest("button"))return;let rt=de.closest("[data-event-id]");if(!rt)return;let Ft=rt.getAttribute("data-event-id");Ft&&Yr(Ft)},wt=Ce=>{if((Ce.metaKey||Ce.ctrlKey)&&Ce.key==="f"){Ce.preventDefault(),ge==null||ge.focus(),ge==null||ge.select();return}Ce.key==="Escape"&&(ge&&document.activeElement===ge?(lt(),ge.blur(),x.focus()):o&&o())};Y&&Y.addEventListener("click",Je),ye&&ye.addEventListener("change",qe),ge&&ge.addEventListener("input",ze),Oe&&Oe.addEventListener("click",lt),K.addEventListener("scroll",Mt),K.addEventListener("wheel",Dt,{passive:!0}),K.addEventListener("click",X),he.addEventListener("click",or),x.addEventListener("keydown",wt);function ct(){H&&clearTimeout(H),Ae!==null&&(cancelAnimationFrame(Ae),Ae=null),Xe=!1,Be.clear(),Y&&Y.removeEventListener("click",Je),ye&&ye.removeEventListener("change",qe),ge&&ge.removeEventListener("input",ze),Oe&&Oe.removeEventListener("click",lt),K.removeEventListener("scroll",Mt),K.removeEventListener("wheel",Dt),K.removeEventListener("click",X),he.removeEventListener("click",or),x.removeEventListener("keydown",wt)}return{element:x,update:fe,destroy:ct}}}function Zx(r,e){let t=typeof r.title=="string"&&r.title?r.title:"Untitled artifact",o=typeof r.artifactId=="string"?r.artifactId:"",n=r.status==="streaming"?"streaming":"complete",s=(typeof r.artifactType=="string"?r.artifactType:"markdown")==="component"?"Component":"Document",i=document.createElement("div");i.className="persona-flex persona-w-full persona-max-w-full persona-items-center persona-gap-3 persona-rounded-xl persona-px-4 persona-py-3",i.style.border="1px solid var(--persona-border, #e5e7eb)",i.style.backgroundColor="var(--persona-surface, #ffffff)",i.style.cursor="pointer",i.tabIndex=0,i.setAttribute("role","button"),i.setAttribute("aria-label",`Open ${t} in artifact panel`),o&&i.setAttribute("data-open-artifact",o);let d=document.createElement("div");d.className="persona-flex persona-h-10 persona-w-10 persona-flex-shrink-0 persona-items-center persona-justify-center persona-rounded-lg",d.style.border="1px solid var(--persona-border, #e5e7eb)",d.style.color="var(--persona-muted, #9ca3af)",d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>';let l=document.createElement("div");l.className="persona-min-w-0 persona-flex-1 persona-flex persona-flex-col persona-gap-0.5";let u=document.createElement("div");u.className="persona-truncate persona-text-sm persona-font-medium",u.style.color="var(--persona-text, #1f2937)",u.textContent=t;let f=document.createElement("div");if(f.className="persona-text-xs persona-flex persona-items-center persona-gap-1.5",f.style.color="var(--persona-muted, #9ca3af)",n==="streaming"){let p=document.createElement("span");p.className="persona-inline-block persona-w-1.5 persona-h-1.5 persona-rounded-full",p.style.backgroundColor="var(--persona-primary, #171717)",p.style.animation="persona-pulse 1.5s ease-in-out infinite",f.appendChild(p);let m=document.createElement("span");m.textContent=`Generating ${s.toLowerCase()}...`,f.appendChild(m)}else f.textContent=s;if(l.append(u,f),i.append(d,l),n==="complete"){let p=document.createElement("button");p.type="button",p.textContent="Download",p.title=`Download ${t}`,p.className="persona-flex-shrink-0 persona-rounded-md persona-px-3 persona-py-1.5 persona-text-xs persona-font-medium",p.style.border="1px solid var(--persona-border, #e5e7eb)",p.style.color="var(--persona-text, #1f2937)",p.style.backgroundColor="transparent",p.style.cursor="pointer",p.setAttribute("data-download-artifact",o),i.append(p)}return i}var ey=(r,e)=>{var o,n,a;let t=(a=(n=(o=e==null?void 0:e.config)==null?void 0:o.features)==null?void 0:n.artifacts)==null?void 0:a.renderCard;if(t){let s=typeof r.title=="string"&&r.title?r.title:"Untitled artifact",i=typeof r.artifactId=="string"?r.artifactId:"",d=r.status==="streaming"?"streaming":"complete",l=typeof r.artifactType=="string"?r.artifactType:"markdown",u=t({artifact:{artifactId:i,title:s,artifactType:l,status:d},config:e.config,defaultRenderer:()=>Zx(r,e)});if(u)return u}return Zx(r,e)};var pu=class{constructor(){this.components=new Map}register(e,t){this.components.has(e)&&console.warn(`[ComponentRegistry] Component "${e}" is already registered. Overwriting.`),this.components.set(e,t)}unregister(e){this.components.delete(e)}get(e){return this.components.get(e)}has(e){return this.components.has(e)}getAllNames(){return Array.from(this.components.keys())}clear(){this.components.clear()}registerAll(e){Object.entries(e).forEach(([t,o])=>{this.register(t,o)})}},En=new pu;En.register("PersonaArtifactCard",ey);function DC(r){var n;let e=C("div","persona-rounded-lg persona-border persona-border-persona-border persona-p-3 persona-text-persona-primary"),t=C("div","persona-font-semibold persona-text-sm persona-mb-2");t.textContent=r.component?`Component: ${r.component}`:"Component";let o=C("pre","persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-overflow-x-auto");return o.textContent=JSON.stringify((n=r.props)!=null?n:{},null,2),e.appendChild(t),e.appendChild(o),e}function ty(r,e){var ye,Y,ge,Oe;let t=(Y=(ye=r.features)==null?void 0:ye.artifacts)==null?void 0:Y.layout,n=((ge=t==null?void 0:t.toolbarPreset)!=null?ge:"default")==="document",a=(Oe=t==null?void 0:t.panePadding)==null?void 0:Oe.trim(),s=r.markdown?ua(r.markdown):null,i=ja(r.sanitize),d=ce=>{let ae=s?s(ce):fa(ce);return i?i(ae):ae},l=typeof document!="undefined"?C("div","persona-artifact-backdrop persona-fixed persona-inset-0 persona-z-[55] persona-bg-black/30 persona-hidden md:persona-hidden"):null,u=()=>{l==null||l.classList.add("persona-hidden"),f.classList.remove("persona-artifact-drawer-open"),z==null||z.hide()};l&&l.addEventListener("click",()=>{var ce;u(),(ce=e.onDismiss)==null||ce.call(e)});let f=C("aside","persona-artifact-pane persona-flex persona-flex-col persona-min-h-0 persona-min-w-0 persona-bg-persona-surface persona-text-persona-primary persona-border-l persona-border-persona-border");f.setAttribute("data-persona-theme-zone","artifact-pane"),n&&f.classList.add("persona-artifact-pane-document");let p=C("div","persona-artifact-toolbar persona-flex persona-items-center persona-justify-between persona-gap-2 persona-px-2 persona-py-2 persona-border-b persona-border-persona-border persona-shrink-0");p.setAttribute("data-persona-theme-zone","artifact-toolbar"),n&&p.classList.add("persona-artifact-toolbar-document");let m=C("span","persona-text-xs persona-font-medium persona-truncate");m.textContent="Artifacts";let y=C("button","persona-rounded-md persona-border persona-border-persona-border persona-px-2 persona-py-1 persona-text-xs persona-bg-persona-surface");y.type="button",y.textContent="Close",y.setAttribute("aria-label","Close artifacts panel"),y.addEventListener("click",()=>{var ce;u(),(ce=e.onDismiss)==null||ce.call(e)});let h="rendered",T=C("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0 persona-artifact-toggle-group"),M=n?Br({icon:"eye",label:"Rendered view",className:"persona-artifact-doc-icon-btn persona-artifact-view-btn"}):Br({icon:"eye",label:"Rendered view"}),k=n?Br({icon:"code-2",label:"Source",className:"persona-artifact-doc-icon-btn persona-artifact-code-btn"}):Br({icon:"code-2",label:"Source"}),L=C("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0"),x=(t==null?void 0:t.documentToolbarShowCopyLabel)===!0,w=(t==null?void 0:t.documentToolbarShowCopyChevron)===!0,v=t==null?void 0:t.documentToolbarCopyMenuItems,E=!!(w&&v&&v.length>0),H=null,I,P=null,z=null;if(n&&(x||w)&&!E){if(I=x?ci({icon:"copy",label:"Copy",iconSize:14,className:"persona-artifact-doc-copy-btn"}):Br({icon:"copy",label:"Copy",className:"persona-artifact-doc-copy-btn"}),w){let ce=Ee("chevron-down",14,"currentColor",2);ce&&I.appendChild(ce)}}else n&&E?(H=C("div","persona-relative persona-inline-flex persona-items-center persona-gap-0 persona-rounded-md"),I=x?ci({icon:"copy",label:"Copy",iconSize:14,className:"persona-artifact-doc-copy-btn"}):Br({icon:"copy",label:"Copy",className:"persona-artifact-doc-copy-btn"}),P=Br({icon:"chevron-down",label:"More copy options",size:14,className:"persona-artifact-doc-copy-menu-chevron persona-artifact-doc-icon-btn",aria:{"aria-haspopup":"true","aria-expanded":"false"}}),H.append(I,P)):n?I=Br({icon:"copy",label:"Copy",className:"persona-artifact-doc-icon-btn"}):I=Br({icon:"copy",label:"Copy"});let j=n?Br({icon:"refresh-cw",label:"Refresh",className:"persona-artifact-doc-icon-btn"}):Br({icon:"refresh-cw",label:"Refresh"}),ie=n?Br({icon:"x",label:"Close",className:"persona-artifact-doc-icon-btn"}):Br({icon:"x",label:"Close"}),ve=()=>{var Ye,De,le;let ce=(Ye=Be.find(nt=>nt.id===Z))!=null?Ye:Be[Be.length-1],ae=(De=ce==null?void 0:ce.id)!=null?De:null,Q=(ce==null?void 0:ce.artifactType)==="markdown"&&(le=ce.markdown)!=null?le:"",Tt=ce?JSON.stringify({component:ce.component,props:ce.props},null,2):"";return{markdown:Q,jsonPayload:Tt,id:ae}},Xe=async()=>{var Ye;let{markdown:ce,jsonPayload:ae}=ve(),Q=(Ye=Be.find(De=>De.id===Z))!=null?Ye:Be[Be.length-1],Tt=(Q==null?void 0:Q.artifactType)==="markdown"?ce:Q?ae:"";try{await navigator.clipboard.writeText(Tt)}catch{}};if(I.addEventListener("click",async()=>{let ce=t==null?void 0:t.onDocumentToolbarCopyMenuSelect;if(ce&&E){let{markdown:ae,jsonPayload:Q,id:Tt}=ve();try{await ce({actionId:"primary",artifactId:Tt,markdown:ae,jsonPayload:Q})}catch{}return}await Xe()}),P&&(v!=null&&v.length)){let ce=()=>{var Q;return(Q=f.closest("[data-persona-root]"))!=null?Q:document.body},ae=()=>{z=Xn({items:v.map(Q=>({id:Q.id,label:Q.label})),onSelect:async Q=>{let{markdown:Tt,jsonPayload:Ye,id:De}=ve(),le=t==null?void 0:t.onDocumentToolbarCopyMenuSelect;try{le?await le({actionId:Q,artifactId:De,markdown:Tt,jsonPayload:Ye}):Q==="markdown"||Q==="md"?await navigator.clipboard.writeText(Tt):Q==="json"||Q==="source"?await navigator.clipboard.writeText(Ye):await navigator.clipboard.writeText(Tt||Ye)}catch{}},anchor:H!=null?H:P,position:"bottom-right",portal:ce()})};f.isConnected?ae():requestAnimationFrame(ae),P.addEventListener("click",Q=>{Q.stopPropagation(),z==null||z.toggle()})}j.addEventListener("click",async()=>{var ce;try{await((ce=t==null?void 0:t.onDocumentToolbarRefresh)==null?void 0:ce.call(t))}catch{}me()}),ie.addEventListener("click",()=>{var ce;u(),(ce=e.onDismiss)==null||ce.call(e)});let Ae=()=>{n&&(M.setAttribute("aria-pressed",h==="rendered"?"true":"false"),k.setAttribute("aria-pressed",h==="source"?"true":"false"))};M.addEventListener("click",()=>{h="rendered",Ae(),me()}),k.addEventListener("click",()=>{h="source",Ae(),me()});let We=C("span","persona-min-w-0 persona-flex-1 persona-text-xs persona-font-medium persona-text-persona-primary persona-truncate persona-text-center md:persona-text-left");n?(p.replaceChildren(),T.append(M,k),H?L.append(H,j,ie):L.append(I,j,ie),p.append(T,We,L),Ae()):(p.appendChild(m),p.appendChild(y)),a&&(p.style.paddingLeft=a,p.style.paddingRight=a);let Me=C("div","persona-artifact-list persona-shrink-0 persona-flex persona-gap-1 persona-overflow-x-auto persona-p-2 persona-border-b persona-border-persona-border"),Ue=C("div","persona-artifact-content persona-flex-1 persona-min-h-0 persona-overflow-y-auto persona-p-3");a&&(Me.style.paddingLeft=a,Me.style.paddingRight=a,Ue.style.padding=a),f.appendChild(p),f.appendChild(Me),f.appendChild(Ue);let Be=[],Z=null,ne=!1,me=()=>{var Tt,Ye,De,le;let ce=n&&Be.length<=1;Me.classList.toggle("persona-hidden",ce),Me.replaceChildren();for(let nt of Be){let Re=C("button","persona-artifact-tab persona-shrink-0 persona-rounded-lg persona-px-2 persona-py-1 persona-text-xs persona-border persona-border-transparent persona-text-persona-primary");Re.type="button",Re.textContent=nt.title||nt.id.slice(0,8),nt.id===Z&&Re.classList.add("persona-bg-persona-container","persona-border-persona-border"),Re.addEventListener("click",()=>e.onSelect(nt.id)),Me.appendChild(Re)}Ue.replaceChildren();let ae=Z&&Be.find(nt=>nt.id===Z)||Be[Be.length-1];if(!ae)return;if(n){let nt=ae.artifactType==="markdown"?"MD":(Tt=ae.component)!=null?Tt:"Component",K=(ae.title||"Document").trim().replace(/\s*·\s*MD\s*$/i,"").trim()||"Document";We.textContent=`${K} \xB7 ${nt}`}else m.textContent="Artifacts";if(ae.artifactType==="markdown"){if(n&&h==="source"){let Re=C("pre","persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-break-words persona-text-persona-primary");Re.textContent=(Ye=ae.markdown)!=null?Ye:"",Ue.appendChild(Re);return}let nt=C("div","persona-text-sm persona-leading-relaxed persona-markdown-bubble");nt.innerHTML=d((De=ae.markdown)!=null?De:""),Ue.appendChild(nt);return}let Q=ae.component?En.get(ae.component):void 0;if(Q){let Re={message:{id:ae.id,role:"assistant",content:"",createdAt:new Date().toISOString()},config:r,updateProps:()=>{}};try{let K=Q((le=ae.props)!=null?le:{},Re);if(K){Ue.appendChild(K);return}}catch{}}Ue.appendChild(DC(ae))},be=()=>{var ae;let ce=Be.length>0;if(f.classList.toggle("persona-hidden",!ce),l){let Q=typeof f.closest=="function"?f.closest("[data-persona-root]"):null,Ye=((ae=Q==null?void 0:Q.classList.contains("persona-artifact-narrow-host"))!=null?ae:!1)||typeof window!="undefined"&&window.matchMedia("(max-width: 640px)").matches;ce&&Ye&&ne?(l.classList.remove("persona-hidden"),f.classList.add("persona-artifact-drawer-open")):(l.classList.add("persona-hidden"),f.classList.remove("persona-artifact-drawer-open"))}};return{element:f,backdrop:l,update(ce){var ae,Q,Tt;Be=ce.artifacts,Z=(Tt=(Q=ce.selectedId)!=null?Q:(ae=ce.artifacts[ce.artifacts.length-1])==null?void 0:ae.id)!=null?Tt:null,Be.length>0&&(ne=!0),me(),be()},setMobileOpen(ce){ne=ce,!ce&&l?(l.classList.add("persona-hidden"),f.classList.remove("persona-artifact-drawer-open")):be()}}}function Go(r){var e,t;return((t=(e=r==null?void 0:r.features)==null?void 0:e.artifacts)==null?void 0:t.enabled)===!0}function ry(r,e){var a,s,i,d;if(r.classList.remove("persona-artifact-border-full","persona-artifact-border-left"),r.style.removeProperty("--persona-artifact-pane-border"),r.style.removeProperty("--persona-artifact-pane-border-left"),!Go(e))return;let t=(s=(a=e.features)==null?void 0:a.artifacts)==null?void 0:s.layout,o=(i=t==null?void 0:t.paneBorder)==null?void 0:i.trim(),n=(d=t==null?void 0:t.paneBorderLeft)==null?void 0:d.trim();o?(r.classList.add("persona-artifact-border-full"),r.style.setProperty("--persona-artifact-pane-border",o)):n&&(r.classList.add("persona-artifact-border-left"),r.style.setProperty("--persona-artifact-pane-border-left",n))}function OC(r){r.style.removeProperty("--persona-artifact-doc-toolbar-icon-color"),r.style.removeProperty("--persona-artifact-doc-toggle-active-bg"),r.style.removeProperty("--persona-artifact-doc-toggle-active-border")}function Ql(r,e){var d,l,u,f,p,m,y,h,T,M;if(!Go(e)){r.style.removeProperty("--persona-artifact-split-gap"),r.style.removeProperty("--persona-artifact-pane-width"),r.style.removeProperty("--persona-artifact-pane-max-width"),r.style.removeProperty("--persona-artifact-pane-min-width"),r.style.removeProperty("--persona-artifact-pane-bg"),r.style.removeProperty("--persona-artifact-pane-padding"),OC(r),ry(r,e);return}let t=(l=(d=e.features)==null?void 0:d.artifacts)==null?void 0:l.layout;r.style.setProperty("--persona-artifact-split-gap",(u=t==null?void 0:t.splitGap)!=null?u:"0.5rem"),r.style.setProperty("--persona-artifact-pane-width",(f=t==null?void 0:t.paneWidth)!=null?f:"40%"),r.style.setProperty("--persona-artifact-pane-max-width",(p=t==null?void 0:t.paneMaxWidth)!=null?p:"28rem"),t!=null&&t.paneMinWidth?r.style.setProperty("--persona-artifact-pane-min-width",t.paneMinWidth):r.style.removeProperty("--persona-artifact-pane-min-width");let o=(m=t==null?void 0:t.paneBackground)==null?void 0:m.trim();o?r.style.setProperty("--persona-artifact-pane-bg",o):r.style.removeProperty("--persona-artifact-pane-bg");let n=(y=t==null?void 0:t.panePadding)==null?void 0:y.trim();n?r.style.setProperty("--persona-artifact-pane-padding",n):r.style.removeProperty("--persona-artifact-pane-padding");let a=(h=t==null?void 0:t.documentToolbarIconColor)==null?void 0:h.trim();a?r.style.setProperty("--persona-artifact-doc-toolbar-icon-color",a):r.style.removeProperty("--persona-artifact-doc-toolbar-icon-color");let s=(T=t==null?void 0:t.documentToolbarToggleActiveBackground)==null?void 0:T.trim();s?r.style.setProperty("--persona-artifact-doc-toggle-active-bg",s):r.style.removeProperty("--persona-artifact-doc-toggle-active-bg");let i=(M=t==null?void 0:t.documentToolbarToggleActiveBorderColor)==null?void 0:M.trim();i?r.style.setProperty("--persona-artifact-doc-toggle-active-border",i):r.style.removeProperty("--persona-artifact-doc-toggle-active-border"),ry(r,e)}var oy=["panel","seamless"];function Yl(r,e){var i,d,l,u,f,p;for(let m of oy)r.classList.remove(`persona-artifact-appearance-${m}`);if(r.classList.remove("persona-artifact-unified-split"),r.style.removeProperty("--persona-artifact-pane-radius"),r.style.removeProperty("--persona-artifact-pane-shadow"),r.style.removeProperty("--persona-artifact-unified-outer-radius"),!Go(e))return;let t=(d=(i=e.features)==null?void 0:i.artifacts)==null?void 0:d.layout,o=(l=t==null?void 0:t.paneAppearance)!=null?l:"panel",n=oy.includes(o)?o:"panel";r.classList.add(`persona-artifact-appearance-${n}`);let a=(u=t==null?void 0:t.paneBorderRadius)==null?void 0:u.trim();a&&r.style.setProperty("--persona-artifact-pane-radius",a);let s=(f=t==null?void 0:t.paneShadow)==null?void 0:f.trim();if(s&&r.style.setProperty("--persona-artifact-pane-shadow",s),(t==null?void 0:t.unifiedSplitChrome)===!0){r.classList.add("persona-artifact-unified-split");let m=((p=t.unifiedSplitOuterRadius)==null?void 0:p.trim())||a;m&&r.style.setProperty("--persona-artifact-unified-outer-radius",m)}}function ny(r,e){var t,o,n;return!e||!Go(r)?!1:((n=(o=(t=r.features)==null?void 0:t.artifacts)==null?void 0:o.layout)==null?void 0:n.expandLauncherPanelWhenOpen)!==!1}function _C(r,e){if(!(r!=null&&r.trim()))return e;let t=/^(\d+(?:\.\d+)?)px\s*$/i.exec(r.trim());return t?Math.max(0,Number(t[1])):e}function NC(r){if(!(r!=null&&r.trim()))return null;let e=/^(\d+(?:\.\d+)?)px\s*$/i.exec(r.trim());return e?Math.max(0,Number(e[1])):null}function FC(r,e,t){return t<e?e:Math.min(t,Math.max(e,r))}function UC(r,e,t,o){let n=r-o-2*e-t;return Math.max(0,n)}function ay(r,e){var s;let o=(s=(e.getComputedStyle(r).gap||"0px").trim().split(/\s+/)[0])!=null?s:"0px",n=/^([\d.]+)px$/i.exec(o);if(n)return Number(n[1]);let a=/^([\d.]+)/.exec(o);return a?Number(a[1]):8}function sy(r,e,t,o,n,a){let s=_C(n,200),i=UC(e,t,o,200);i=Math.max(s,i);let d=NC(a);return d!==null&&(i=Math.min(i,d)),FC(r,s,i)}var iy={init:{title:"Schedule a Demo",description:"Share the basics and we'll follow up with a confirmation.",fields:[{name:"name",label:"Full name",placeholder:"Jane Doe",required:!0},{name:"email",label:"Work email",placeholder:"jane@example.com",type:"email",required:!0},{name:"notes",label:"What would you like to cover?",type:"textarea"}],submitLabel:"Submit details"},followup:{title:"Additional Information",description:"Provide any extra details to tailor the next steps.",fields:[{name:"company",label:"Company",placeholder:"Acme Inc."},{name:"context",label:"Context",type:"textarea",placeholder:"Share more about your use case"}],submitLabel:"Send"}},uu=(r,e,t,o)=>{let n=r.querySelectorAll("[data-tv-form]");n.length&&n.forEach(a=>{var y,h,T;if(a.dataset.enhanced==="true")return;let s=(y=a.dataset.tvForm)!=null?y:"init";a.dataset.enhanced="true";let i=(h=iy[s])!=null?h:iy.init;a.classList.add("persona-form-card","persona-space-y-4");let d=C("div","persona-space-y-1"),l=C("h3","persona-text-base persona-font-semibold persona-text-persona-primary");if(l.textContent=i.title,d.appendChild(l),i.description){let M=C("p","persona-text-sm persona-text-persona-muted");M.textContent=i.description,d.appendChild(M)}let u=document.createElement("form");u.className="persona-form-grid persona-space-y-3",i.fields.forEach(M=>{var v,E;let k=C("label","persona-form-field persona-flex persona-flex-col persona-gap-1");k.htmlFor=`${e.id}-${s}-${M.name}`;let L=C("span","persona-text-xs persona-font-medium persona-text-persona-muted");L.textContent=M.label,k.appendChild(L);let x=(v=M.type)!=null?v:"text",w;x==="textarea"?(w=document.createElement("textarea"),w.rows=3):(w=document.createElement("input"),w.type=x),w.className="persona-rounded-xl persona-border persona-border-gray-200 persona-bg-white persona-px-3 persona-py-2 persona-text-sm persona-text-persona-primary focus:persona-outline-none focus:persona-border-persona-primary",w.id=`${e.id}-${s}-${M.name}`,w.name=M.name,w.placeholder=(E=M.placeholder)!=null?E:"",M.required&&(w.required=!0),k.appendChild(w),u.appendChild(k)});let f=C("div","persona-flex persona-items-center persona-justify-between persona-gap-2"),p=C("div","persona-text-xs persona-text-persona-muted persona-min-h-[1.5rem]"),m=C("button","persona-inline-flex persona-items-center persona-rounded-full persona-bg-persona-primary persona-px-4 persona-py-2 persona-text-sm persona-font-semibold persona-text-white disabled:persona-opacity-60 persona-cursor-pointer");m.type="submit",m.textContent=(T=i.submitLabel)!=null?T:"Submit",f.appendChild(p),f.appendChild(m),u.appendChild(f),a.replaceChildren(d,u),u.addEventListener("submit",async M=>{var w,v;M.preventDefault();let k=(w=t.formEndpoint)!=null?w:"/form",L=new FormData(u),x={};L.forEach((E,H)=>{x[H]=E}),x.type=s,m.disabled=!0,p.textContent="Submitting\u2026";try{let E=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!E.ok)throw new Error(`Form submission failed (${E.status})`);let H=await E.json();p.textContent=(v=H.message)!=null?v:"Thanks! We'll be in touch soon.",H.success&&H.nextPrompt&&await o.sendMessage(String(H.nextPrompt))}catch(E){p.textContent=E instanceof Error?E.message:"Something went wrong. Please try again."}finally{m.disabled=!1}})})};var fu=class{constructor(){this.plugins=new Map}register(e){var t;this.plugins.has(e.id)&&console.warn(`Plugin "${e.id}" is already registered. Overwriting.`),this.plugins.set(e.id,e),(t=e.onRegister)==null||t.call(e)}unregister(e){var o;let t=this.plugins.get(e);t&&((o=t.onUnregister)==null||o.call(t),this.plugins.delete(e))}getAll(){return Array.from(this.plugins.values()).sort((e,t)=>{var o,n;return((o=t.priority)!=null?o:0)-((n=e.priority)!=null?n:0)})}getForInstance(e){let t=this.getAll();if(!e||e.length===0)return t;let o=new Set(e.map(a=>a.id));return[...t.filter(a=>!o.has(a.id)),...e].sort((a,s)=>{var i,d;return((i=s.priority)!=null?i:0)-((d=a.priority)!=null?d:0)})}clear(){this.plugins.forEach(e=>{var t;return(t=e.onUnregister)==null?void 0:t.call(e)}),this.plugins.clear()}},mi=new fu;var ly=()=>{let r=new Map,e=(n,a)=>(r.has(n)||r.set(n,new Set),r.get(n).add(a),()=>t(n,a)),t=(n,a)=>{var s;(s=r.get(n))==null||s.delete(a)};return{on:e,off:t,emit:(n,a)=>{var s;(s=r.get(n))==null||s.forEach(i=>{try{i(a)}catch(d){typeof console!="undefined"&&console.error("[AgentWidget] Event handler error:",d)}})}}};var qC=r=>{let e=r.match(/```(?:json)?\s*([\s\S]*?)```/i);return e?e[1]:r},zC=r=>{let e=r.trim(),t=e.indexOf("{");if(t===-1)return null;let o=0;for(let n=t;n<e.length;n+=1){let a=e[n];if(a==="{"&&(o+=1),a==="}"&&(o-=1,o===0))return e.slice(t,n+1)}return null},gi=({text:r})=>{if(!r||!r.includes("{"))return null;try{let e=qC(r),t=zC(e);if(!t)return null;let o=JSON.parse(t);if(!o||typeof o!="object"||!o.action)return null;let{action:n,...a}=o;return{type:String(n),payload:a,raw:o}}catch{return null}},mu=r=>typeof r=="string"?r:r==null?"":String(r),Ea={message:r=>r.type!=="message"?void 0:{handled:!0,displayText:mu(r.payload.text)},messageAndClick:(r,e)=>{var n;if(r.type!=="message_and_click")return;let t=r.payload,o=mu(t.element);if(o&&((n=e.document)!=null&&n.querySelector)){let a=e.document.querySelector(o);a?setTimeout(()=>{a.click()},400):typeof console!="undefined"&&console.warn("[AgentWidget] Element not found for selector:",o)}return{handled:!0,displayText:mu(t.text)}}},dy=r=>Array.isArray(r)?r.map(e=>String(e)):[],hi=r=>{let e=new Set(dy(r.getSessionMetadata().processedActionMessageIds)),t=()=>{e=new Set(dy(r.getSessionMetadata().processedActionMessageIds))},o=()=>{let a=Array.from(e);r.updateSessionMetadata(s=>({...s,processedActionMessageIds:a}))};return{process:a=>{if(a.streaming||a.message.role!=="assistant"||!a.text||e.has(a.message.id))return null;let s=typeof a.raw=="string"&&a.raw||typeof a.message.rawContent=="string"&&a.message.rawContent||typeof a.text=="string"&&a.text||null;!s&&typeof a.text=="string"&&a.text.trim().startsWith("{")&&typeof console!="undefined"&&console.warn("[AgentWidget] Structured response detected but no raw payload was provided. Ensure your stream parser returns { text, raw }.");let i=s?r.parsers.reduce((l,u)=>l||(u==null?void 0:u({text:s,message:a.message}))||null,null):null;if(!i)return null;e.add(a.message.id),o();let d={action:i,message:a.message};r.emit("action:detected",d);for(let l of r.handlers)if(l)try{let u=()=>{r.emit("action:resubmit",d)},f=l(i,{message:a.message,metadata:r.getSessionMetadata(),updateMetadata:r.updateSessionMetadata,document:r.documentRef,triggerResubmit:u});if(!f)continue;if(f.handled){let p=f.persistMessage!==!1;return{text:f.displayText!==void 0?f.displayText:"",persist:p,resubmit:f.resubmit}}}catch(u){typeof console!="undefined"&&console.error("[AgentWidget] Action handler error:",u)}return{text:"",persist:!0}},syncFromMetadata:t}};var $C=r=>{if(!r)return null;try{return JSON.parse(r)}catch(e){return typeof console!="undefined"&&console.error("[AgentWidget] Failed to parse stored state:",e),null}},VC=r=>r.map(e=>({...e,streaming:!1})),jC=r=>r.map(e=>({...e,status:"complete"})),Jl=(r="persona-state")=>{let e=()=>typeof window=="undefined"||!window.localStorage?null:window.localStorage;return{load:()=>{let t=e();return t?$C(t.getItem(r)):null},save:t=>{let o=e();if(o)try{let n={...t,messages:t.messages?VC(t.messages):void 0,artifacts:t.artifacts?jC(t.artifacts):void 0};o.setItem(r,JSON.stringify(n))}catch(n){typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",n)}},clear:()=>{let t=e();if(t)try{t.removeItem(r)}catch(o){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear stored state:",o)}}}};var ds=Bi(ji(),1);function GC(r){if(!r||typeof r!="object"||!("component"in r))return!1;let e=r.component;return typeof e=="string"&&e.length>0}function KC(r,e){if(!GC(r))return null;let t=r.props&&typeof r.props=="object"&&r.props!==null?r.props:{};return{component:r.component,props:t,raw:e}}function Zl(){let r=null,e=0;return{getExtractedDirective:()=>r,processChunk:t=>{let o=t.trim();if(!o.startsWith("{")&&!o.startsWith("["))return null;if(t.length<=e)return r;try{let n=(0,ds.parse)(t,ds.STR|ds.OBJ),a=KC(n,t);a&&(r=a)}catch{}return e=t.length,r},reset:()=>{r=null,e=0}}}function cy(r){return typeof r=="object"&&r!==null&&"component"in r&&typeof r.component=="string"&&"props"in r&&typeof r.props=="object"}function ed(r,e){let{config:t,message:o,onPropsUpdate:n}=e,a=En.get(r.component);if(!a)return console.warn(`[ComponentMiddleware] Component "${r.component}" not found in registry. Falling back to default rendering.`),null;let s={message:o,config:t,updateProps:i=>{n&&n(i)}};try{return a(r.props,s)}catch(i){return console.error(`[ComponentMiddleware] Error rendering component "${r.component}":`,i),null}}function py(){let r=Zl();return{processChunk:e=>r.processChunk(e),getDirective:()=>r.getExtractedDirective(),reset:()=>{r.reset()}}}function uy(r){if(typeof r.rawContent=="string"&&r.rawContent.length>0)return r.rawContent;if(typeof r.content=="string"){let e=r.content.trim();if(e.startsWith("{")||e.startsWith("["))return r.content}return null}function td(r){let e=uy(r);if(!e)return!1;try{let t=JSON.parse(e);return typeof t=="object"&&t!==null&&"component"in t&&typeof t.component=="string"}catch{return!1}}function rd(r){let e=uy(r);if(!e)return null;try{let t=JSON.parse(e);if(typeof t=="object"&&t!==null&&"component"in t&&typeof t.component=="string"){let o=t;return{component:o.component,props:o.props&&typeof o.props=="object"&&o.props!==null?o.props:{},raw:e}}}catch{}return null}var XC=["Very dissatisfied","Dissatisfied","Neutral","Satisfied","Very satisfied"];function od(r){let{onSubmit:e,onDismiss:t,title:o="How satisfied are you?",subtitle:n="Please rate your experience",commentPlaceholder:a="Share your thoughts (optional)...",submitText:s="Submit",skipText:i="Skip",showComment:d=!0,ratingLabels:l=XC}=r,u=document.createElement("div");u.className="persona-feedback-container persona-feedback-csat",u.setAttribute("role","dialog"),u.setAttribute("aria-label","Customer satisfaction feedback");let f=null,p=document.createElement("div");p.className="persona-feedback-content";let m=document.createElement("div");m.className="persona-feedback-header";let y=document.createElement("h3");y.className="persona-feedback-title",y.textContent=o,m.appendChild(y);let h=document.createElement("p");h.className="persona-feedback-subtitle",h.textContent=n,m.appendChild(h),p.appendChild(m);let T=document.createElement("div");T.className="persona-feedback-rating persona-feedback-rating-csat",T.setAttribute("role","radiogroup"),T.setAttribute("aria-label","Satisfaction rating from 1 to 5");let M=[];for(let v=1;v<=5;v++){let E=document.createElement("button");E.type="button",E.className="persona-feedback-rating-btn persona-feedback-star-btn",E.setAttribute("role","radio"),E.setAttribute("aria-checked","false"),E.setAttribute("aria-label",`${v} star${v>1?"s":""}: ${l[v-1]}`),E.title=l[v-1],E.dataset.rating=String(v),E.innerHTML=`
|
|
74
75
|
<svg class="persona-feedback-star" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
75
76
|
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>
|
|
76
77
|
</svg>
|
|
77
|
-
`,E.addEventListener("click",()=>{m=w,T.forEach((H,I)=>{let L=I<w;H.classList.toggle("selected",L),H.setAttribute("aria-checked",I===w-1?"true":"false")})}),T.push(E),S.appendChild(E)}p.appendChild(S);let M=null;if(d){let w=document.createElement("div");w.className="persona-feedback-comment-container",M=document.createElement("textarea"),M.className="persona-feedback-comment",M.placeholder=a,M.rows=3,M.setAttribute("aria-label","Additional comments"),w.appendChild(M),p.appendChild(w)}let k=document.createElement("div");k.className="persona-feedback-actions";let x=document.createElement("button");x.type="button",x.className="persona-feedback-btn persona-feedback-btn-skip",x.textContent=i,x.addEventListener("click",()=>{t==null||t(),u.remove()});let C=document.createElement("button");return C.type="button",C.className="persona-feedback-btn persona-feedback-btn-submit",C.textContent=s,C.addEventListener("click",async()=>{if(m===null){S.classList.add("persona-feedback-shake"),setTimeout(()=>S.classList.remove("persona-feedback-shake"),500);return}C.disabled=!0,C.textContent="Submitting...";try{let w=(M==null?void 0:M.value.trim())||void 0;await e(m,w),u.remove()}catch(w){C.disabled=!1,C.textContent=s,console.error("[CSAT Feedback] Failed to submit:",w)}}),k.appendChild(x),k.appendChild(C),p.appendChild(k),u.appendChild(p),u}function td(r){let{onSubmit:e,onDismiss:t,title:n="How likely are you to recommend us?",subtitle:o="On a scale of 0 to 10",commentPlaceholder:a="What could we do better? (optional)...",submitText:s="Submit",skipText:i="Skip",showComment:d=!0,lowLabel:l="Not likely",highLabel:u="Very likely"}=r,m=document.createElement("div");m.className="persona-feedback-container persona-feedback-nps",m.setAttribute("role","dialog"),m.setAttribute("aria-label","Net Promoter Score feedback");let p=null,f=document.createElement("div");f.className="persona-feedback-content";let b=document.createElement("div");b.className="persona-feedback-header";let h=document.createElement("h3");h.className="persona-feedback-title",h.textContent=n,b.appendChild(h);let S=document.createElement("p");S.className="persona-feedback-subtitle",S.textContent=o,b.appendChild(S),f.appendChild(b);let T=document.createElement("div");T.className="persona-feedback-rating persona-feedback-rating-nps",T.setAttribute("role","radiogroup"),T.setAttribute("aria-label","Likelihood rating from 0 to 10");let M=document.createElement("div");M.className="persona-feedback-labels";let k=document.createElement("span");k.className="persona-feedback-label-low",k.textContent=l;let x=document.createElement("span");x.className="persona-feedback-label-high",x.textContent=u,M.appendChild(k),M.appendChild(x);let C=document.createElement("div");C.className="persona-feedback-numbers";let w=[];for(let O=0;O<=10;O++){let $=document.createElement("button");$.type="button",$.className="persona-feedback-rating-btn persona-feedback-number-btn",$.setAttribute("role","radio"),$.setAttribute("aria-checked","false"),$.setAttribute("aria-label",`Rating ${O} out of 10`),$.textContent=String(O),$.dataset.rating=String(O),O<=6?$.classList.add("persona-feedback-detractor"):O<=8?$.classList.add("persona-feedback-passive"):$.classList.add("persona-feedback-promoter"),$.addEventListener("click",()=>{p=O,w.forEach((te,xe)=>{te.classList.toggle("selected",xe===O),te.setAttribute("aria-checked",xe===O?"true":"false")})}),w.push($),C.appendChild($)}T.appendChild(M),T.appendChild(C),f.appendChild(T);let E=null;if(d){let O=document.createElement("div");O.className="persona-feedback-comment-container",E=document.createElement("textarea"),E.className="persona-feedback-comment",E.placeholder=a,E.rows=3,E.setAttribute("aria-label","Additional comments"),O.appendChild(E),f.appendChild(O)}let H=document.createElement("div");H.className="persona-feedback-actions";let I=document.createElement("button");I.type="button",I.className="persona-feedback-btn persona-feedback-btn-skip",I.textContent=i,I.addEventListener("click",()=>{t==null||t(),m.remove()});let L=document.createElement("button");return L.type="button",L.className="persona-feedback-btn persona-feedback-btn-submit",L.textContent=s,L.addEventListener("click",async()=>{if(p===null){C.classList.add("persona-feedback-shake"),setTimeout(()=>C.classList.remove("persona-feedback-shake"),500);return}L.disabled=!0,L.textContent="Submitting...";try{let O=(E==null?void 0:E.value.trim())||void 0;await e(p,O),m.remove()}catch(O){L.disabled=!1,L.textContent=s,console.error("[NPS Feedback] Failed to submit:",O)}}),H.appendChild(I),H.appendChild(L),f.appendChild(H),m.appendChild(f),m}var ns="persona-chat-history",RC=30*1e3,IC={"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","image/bmp":"bmp","image/tiff":"tiff"};function HC(r){var n,o,a;if(!r)return[];let e=[],t=Array.from((n=r.items)!=null?n:[]);for(let s of t){if(s.kind!=="file"||!s.type.startsWith("image/"))continue;let i=s.getAsFile();if(!i)continue;if(i.name){e.push(i);continue}let d=(o=IC[i.type])!=null?o:"png";e.push(new File([i],`clipboard-image-${Date.now()}.${d}`,{type:i.type,lastModified:Date.now()}))}if(e.length>0)return e;for(let s of Array.from((a=r.files)!=null?a:[]))s.type.startsWith("image/")&&e.push(s);return e}function rd(r){if(!r)return!1;let e=r.types;return e?typeof e.contains=="function"?e.contains("Files"):Array.from(e).includes("Files"):!1}function WC(r){var e,t,n,o,a,s,i,d,l;return r?r===!0?{storage:"session",keyPrefix:"persona-",persist:{openState:!0,voiceState:!0,focusInput:!0},clearOnChatClear:!0}:{storage:(e=r.storage)!=null?e:"session",keyPrefix:(t=r.keyPrefix)!=null?t:"persona-",persist:{openState:(o=(n=r.persist)==null?void 0:n.openState)!=null?o:!0,voiceState:(s=(a=r.persist)==null?void 0:a.voiceState)!=null?s:!0,focusInput:(d=(i=r.persist)==null?void 0:i.focusInput)!=null?d:!0},clearOnChatClear:(l=r.clearOnChatClear)!=null?l:!0}:null}function BC(r){try{let e=r==="local"?localStorage:sessionStorage,t="__persist_test__";return e.setItem(t,"1"),e.removeItem(t),e}catch{return null}}var fu=r=>!r||typeof r!="object"?{}:{...r},sb=r=>r.map(e=>({...e,streaming:!1})),ib=(r,e,t)=>{let n=r!=null&&r.markdown?ia(r.markdown):null,o=Na(r==null?void 0:r.sanitize);return r!=null&&r.postprocessMessage&&o&&(r==null?void 0:r.sanitize)===void 0&&console.warn("[Persona] A custom postprocessMessage is active with the default HTML sanitizer. Tags or attributes not in the built-in allowlist will be stripped. To keep custom HTML, set `sanitize: false` or provide a custom sanitize function."),a=>{var l,u,m;let s=(l=a.text)!=null?l:"",i=(u=a.message.rawContent)!=null?u:null;if(e){let p=e.process({text:s,raw:i!=null?i:s,message:a.message,streaming:a.streaming});p!==null&&(s=p.text,p.persist||(a.message.__skipPersist=!0),p.resubmit&&!a.streaming&&t&&t())}let d;return r!=null&&r.postprocessMessage?d=r.postprocessMessage({...a,text:s,raw:(m=i!=null?i:a.text)!=null?m:""}):n?d=n(s):d=la(s),o?o(d):d}};function lb(r){var i,d,l,u;let e=v("div","persona-attachment-drop-overlay");r!=null&&r.background&&e.style.setProperty("--persona-drop-overlay-bg",r.background),(r==null?void 0:r.backdropBlur)!==void 0&&e.style.setProperty("--persona-drop-overlay-blur",r.backdropBlur),r!=null&&r.border&&e.style.setProperty("--persona-drop-overlay-border",r.border),r!=null&&r.borderRadius&&e.style.setProperty("--persona-drop-overlay-radius",r.borderRadius),r!=null&&r.inset&&e.style.setProperty("--persona-drop-overlay-inset",r.inset),r!=null&&r.labelSize&&e.style.setProperty("--persona-drop-overlay-label-size",r.labelSize),r!=null&&r.labelColor&&e.style.setProperty("--persona-drop-overlay-label-color",r.labelColor);let t=(i=r==null?void 0:r.iconName)!=null?i:"upload",n=(d=r==null?void 0:r.iconSize)!=null?d:"48px",o=(l=r==null?void 0:r.iconColor)!=null?l:"rgba(59, 130, 246, 0.6)",a=(u=r==null?void 0:r.iconStrokeWidth)!=null?u:.5,s=Me(t,n,o,a);if(s&&e.appendChild(s),r!=null&&r.label){let m=v("span","persona-drop-overlay-label");m.textContent=r.label,e.appendChild(m)}return e}var nd=(r,e,t)=>{var Vu,ju,Gu,Ku,Xu,Qu,Ju,Yu,Zu,ef,tf,rf,nf,of,af,sf,lf,df,cf,pf,uf,ff,mf,gf,hf,xf,bf,yf,vf,Cf,wf,Af,Sf,Tf,Mf,kf,Ef,Lf,Pf,Rf,If,Hf,Wf,Bf,Df,Ff,Of,Nf,_f,Uf;if(r==null)throw new Error('createAgentExperience: mount must be a non-null HTMLElement (e.g. pass document.getElementById("my-root") after the node exists).');r.id&&!r.getAttribute("data-persona-instance")&&r.setAttribute("data-persona-instance",r.id),r.hasAttribute("data-persona-root")||r.setAttribute("data-persona-root","true");let n=wl(e),o=li.getForInstance(n.plugins);n.components&&wo.registerAll(n.components);let a=tb(),i=n.persistState===!1?null:(Vu=n.storageAdapter)!=null?Vu:Xl(),d={},l=null,u=!1,m=c=>{if(n.onStateLoaded)try{let g=n.onStateLoaded(c);if(g&&typeof g=="object"&&"state"in g){let{state:y,open:A}=g;return A&&(u=!0),y}return g}catch(g){typeof console!="undefined"&&console.error("[AgentWidget] onStateLoaded hook failed:",g)}return c};if(i!=null&&i.load)try{let c=i.load();if(c&&typeof c.then=="function")l=c.then(g=>{let y=g!=null?g:{messages:[],metadata:{}};return m(y)});else{let g=c!=null?c:{messages:[],metadata:{}},y=m(g);y.metadata&&(d=fu(y.metadata)),(ju=y.messages)!=null&&ju.length&&(n={...n,initialMessages:y.messages}),(Gu=y.artifacts)!=null&&Gu.length&&(n={...n,initialArtifacts:y.artifacts,initialSelectedArtifactId:(Ku=y.selectedArtifactId)!=null?Ku:null})}}catch(c){typeof console!="undefined"&&console.error("[AgentWidget] Failed to load stored state:",c)}else if(n.onStateLoaded)try{let c=m({messages:[],metadata:{}});(Xu=c.messages)!=null&&Xu.length&&(n={...n,initialMessages:c.messages})}catch(c){typeof console!="undefined"&&console.error("[AgentWidget] onStateLoaded hook failed:",c)}let p=()=>d,f=c=>{var y;d=(y=c({...d}))!=null?y:{},La()},b=n.actionParsers&&n.actionParsers.length?n.actionParsers:[di],h=n.actionHandlers&&n.actionHandlers.length?n.actionHandlers:[wa.message,wa.messageAndClick],S=ci({parsers:b,handlers:h,getSessionMetadata:p,updateSessionMetadata:f,emit:a.emit,documentRef:typeof document!="undefined"?document:null});S.syncFromMetadata();let T=(Ju=(Qu=n.launcher)==null?void 0:Qu.enabled)!=null?Ju:!0,M=(Zu=(Yu=n.launcher)==null?void 0:Yu.autoExpand)!=null?Zu:!1,k=(ef=n.autoFocusInput)!=null?ef:!1,x=M,C=T,w=(rf=(tf=n.layout)==null?void 0:tf.header)==null?void 0:rf.layout,E=!1,H=()=>zo(n),I=()=>T||H(),L=H()?!1:T?M:!0,O=!1,$=null,te=()=>{O=!0,$&&clearTimeout($),$=setTimeout(()=>{O&&(typeof console!="undefined"&&console.warn("[AgentWidget] Resubmit requested but no injection occurred within 10s"),O=!1)},1e4)},xe=ib(n,S,te),Je=(of=(nf=n.features)==null?void 0:nf.showReasoning)!=null?of:!0,we=(sf=(af=n.features)==null?void 0:af.showToolCalls)!=null?sf:!0,De=(df=(lf=n.features)==null?void 0:lf.showEventStreamToggle)!=null?df:!1,Ae=(pf=(cf=n.features)==null?void 0:cf.scrollToBottom)!=null?pf:{},qe=(ff=(uf=n.features)==null?void 0:uf.scrollBehavior)!=null?ff:{},J=`${(gf=typeof n.persistState=="object"?(mf=n.persistState)==null?void 0:mf.keyPrefix:void 0)!=null?gf:"persona-"}event-stream`,re=De?new si(J):null,Q=(bf=(xf=(hf=n.features)==null?void 0:hf.eventStream)==null?void 0:xf.maxEvents)!=null?bf:2e3,ge=De?new ai(Q,re):null,Z=De?new ii:null,G=null,pe=!1,ke=null,le=0;re==null||re.open().then(()=>ge==null?void 0:ge.restore()).catch(c=>{n.debug&&console.warn("[AgentWidget] IndexedDB not available for event stream:",c)});let ne={onCopy:c=>{var g,y;a.emit("message:copy",c),q!=null&&q.isClientTokenMode()&&q.submitMessageFeedback(c.id,"copy").catch(A=>{n.debug&&console.error("[AgentWidget] Failed to submit copy feedback:",A)}),(y=(g=n.messageActions)==null?void 0:g.onCopy)==null||y.call(g,c)},onFeedback:c=>{var g,y;a.emit("message:feedback",c),q!=null&&q.isClientTokenMode()&&q.submitMessageFeedback(c.messageId,c.type).catch(A=>{n.debug&&console.error("[AgentWidget] Failed to submit feedback:",A)}),(y=(g=n.messageActions)==null?void 0:g.onFeedback)==null||y.call(g,c)}},de=(yf=n.statusIndicator)!=null?yf:{},Et=c=>{var g,y,A,W;return c==="idle"?(g=de.idleText)!=null?g:Kr.idle:c==="connecting"?(y=de.connectingText)!=null?y:Kr.connecting:c==="connected"?(A=de.connectedText)!=null?A:Kr.connected:c==="error"?(W=de.errorText)!=null?W:Kr.error:Kr[c]};function wt(c,g,y,A){if(A==="idle"&&y.idleLink){c.textContent="";let W=document.createElement("a");W.href=y.idleLink,W.target="_blank",W.rel="noopener noreferrer",W.textContent=g,W.style.color="inherit",W.style.textDecoration="none",c.appendChild(W)}else c.textContent=g}let{wrapper:We,panel:he,pillRoot:at}=Px(n),Re=Rx(n,I()),{container:j,body:ue,messagesWrapper:nt,suggestions:Rt,textarea:ee,sendButton:Ge,sendButtonWrapper:Fr,composerForm:Bt,statusText:or,introTitle:hr,introSubtitle:sn,closeButton:F,iconHolder:fe,headerTitle:Ie,headerSubtitle:Xe,header:Fe,footer:Ne,actionsRow:Ye,leftActions:At,rightActions:Xt}=Re,ar=Re.setSendButtonMode,K=Re.micButton,mt=Re.micButtonWrapper,it=Re.attachmentButton,ye=Re.attachmentButtonWrapper,ie=Re.attachmentInput,st=Re.attachmentPreviewsContainer;j.classList.add("persona-relative"),ue.classList.add("persona-relative");let pr=12,pt=()=>{var c;return(c=Ae.label)!=null?c:""},yr=()=>{var c;return(c=Ae.iconName)!=null?c:"arrow-down"},Rr=()=>Ae.enabled!==!1,ut=()=>{var c;return(c=qe.mode)!=null?c:"follow"},Lt=()=>{var c;return(c=qe.anchorTopOffset)!=null?c:16},tt=v("button","persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-z-10 persona-flex persona-items-center persona-gap-1 persona-text-xs persona-transform persona--translate-x-1/2 persona-cursor-pointer");tt.type="button",tt.style.display="none",tt.setAttribute("data-persona-scroll-to-bottom","true");let zt=v("span","persona-flex persona-items-center"),vr=v("span",""),sr=v("span","");sr.setAttribute("data-persona-scroll-to-bottom-count",""),sr.style.display="none",tt.append(zt,vr,sr),j.appendChild(tt);let ur=v("div","persona-stream-anchor-spacer");ur.setAttribute("aria-hidden","true"),ur.setAttribute("data-persona-anchor-spacer",""),ur.style.flexShrink="0",ur.style.pointerEvents="none",ur.style.height="0px",ue.appendChild(ur);let Mr=()=>{let g=Ne.style.display==="none"?0:Ne.offsetHeight;tt.style.bottom=`${g+pr}px`};Mr();let un=()=>{let c=!!pt();tt.setAttribute("aria-label",pt()||"Jump to latest"),tt.title=pt(),tt.setAttribute("data-persona-scroll-to-bottom-has-label",c?"true":"false"),zt.innerHTML="";let g=Me(yr(),"14px","currentColor",2);g?(zt.appendChild(g),zt.style.display=""):zt.style.display="none",vr.textContent=pt(),vr.style.display=c?"":"none"};un();let St=null,qr=null,xr=o.find(c=>c.renderHeader);if(xr!=null&&xr.renderHeader){let c=xr.renderHeader({config:n,defaultRenderer:()=>{let g=Co({config:n,showClose:I()});return ya(j,g,n),g.header},onClose:()=>jt(!1,"user")});if(c){let g=j.querySelector(".persona-border-b-persona-divider");g&&(g.replaceWith(c),Fe=c)}}let Mn=()=>{var g,y,A,W;if(!ge)return;if(pe=!0,!G&&ge&&(G=Vx({buffer:ge,getFullHistory:()=>ge.getAllFromStore(),onClose:()=>ln(),config:n,plugins:o,getThroughput:()=>{var _;return(_=Z==null?void 0:Z.getMetric())!=null?_:{status:"idle"}}})),G&&(ue.style.display="none",(g=Ne.parentNode)==null||g.insertBefore(G.element,Ne),G.update()),yt){yt.style.boxShadow=`inset 0 0 0 1.5px ${an.actionIconColor}`;let _=(W=(A=(y=n.features)==null?void 0:y.eventStream)==null?void 0:A.classNames)==null?void 0:W.toggleButtonActive;_&&_.split(/\s+/).forEach(U=>U&&yt.classList.add(U))}let c=()=>{if(!pe)return;let _=Date.now();_-le>=200&&(G==null||G.update(),le=_),ke=requestAnimationFrame(c)};le=0,ke=requestAnimationFrame(c),cn(),a.emit("eventStream:opened",{timestamp:Date.now()})},ln=()=>{var c,g,y;if(pe){if(pe=!1,G&&G.element.remove(),ue.style.display="",yt){yt.style.boxShadow="";let A=(y=(g=(c=n.features)==null?void 0:c.eventStream)==null?void 0:g.classNames)==null?void 0:y.toggleButtonActive;A&&A.split(/\s+/).forEach(W=>W&&yt.classList.remove(W))}ke!==null&&(cancelAnimationFrame(ke),ke=null),cn(),a.emit("eventStream:closed",{timestamp:Date.now()})}},yt=null;if(De){let c=(Cf=(vf=n.features)==null?void 0:vf.eventStream)==null?void 0:Cf.classNames,g="persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1"+(c!=null&&c.toggleButton?" "+c.toggleButton:"");yt=v("button",g),yt.style.width="28px",yt.style.height="28px",yt.style.color=an.actionIconColor,yt.type="button",yt.setAttribute("aria-label","Event Stream"),yt.title="Event Stream";let y=Me("activity","18px","currentColor",1.5);y&&yt.appendChild(y);let A=Re.clearChatButtonWrapper,W=Re.closeButtonWrapper,_=A||W;_&&_.parentNode===Fe?Fe.insertBefore(yt,_):Fe.appendChild(yt),yt.addEventListener("click",()=>{pe?ln():Mn()})}let Gn=c=>{var A,W,_;let g=n.attachments;if(!(g!=null&&g.enabled))return;let y=c.querySelector(".persona-attachment-previews");if(!y){y=v("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2"),y.style.display="none";let U=c.querySelector("[data-persona-composer-form]");U!=null&&U.parentNode?U.parentNode.insertBefore(y,U):c.insertBefore(y,c.firstChild)}if(!c.querySelector('input[type="file"]')){let U=v("input");U.type="file",U.accept=((A=g.allowedTypes)!=null?A:yo).join(","),U.multiple=((W=g.maxFiles)!=null?W:4)>1,U.style.display="none",U.setAttribute("aria-label",(_=g.buttonTooltipText)!=null?_:"Attach files"),c.appendChild(U)}},kn=o.find(c=>c.renderComposer);if(kn!=null&&kn.renderComposer){let c=n.composer,g=kn.renderComposer({config:n,defaultRenderer:()=>Ja({config:n}).footer,onSubmit:y=>{var U;if(!q||q.isStreaming())return;let A=y.trim(),W=(U=St==null?void 0:St.hasAttachments())!=null?U:!1;if(!A&&!W)return;z();let _;W&&(_=[],_.push(...St.getContentParts()),A&&_.push($s(A))),q.sendMessage(A,{contentParts:_}),W&&St.clearAttachments()},streaming:!1,disabled:!1,openAttachmentPicker:()=>{ie==null||ie.click()},models:c==null?void 0:c.models,selectedModelId:c==null?void 0:c.selectedModelId,onModelChange:y=>{n.composer={...n.composer,selectedModelId:y},n.agent&&(n.agent={...n.agent,model:y})},onVoiceToggle:((wf=n.voiceRecognition)==null?void 0:wf.enabled)===!0?()=>{qr==null||qr()}:void 0});g&&(Ne.replaceWith(g),Ne=g)}let _e=c=>{let g=c.querySelector("[data-persona-composer-form]"),y=c.querySelector("[data-persona-composer-input]"),A=c.querySelector("[data-persona-composer-submit]"),W=c.querySelector("[data-persona-composer-mic]"),_=c.querySelector("[data-persona-composer-status]");g&&(Bt=g),y&&(ee=y),A&&(Ge=A),W&&(K=W,mt=W.parentElement),_&&(or=_);let U=c.querySelector(".persona-mb-3.persona-flex.persona-flex-wrap.persona-gap-2");U&&(Rt=U);let V=c.querySelector(".persona-attachment-button");V&&(it=V,ye=V.parentElement),ie=c.querySelector('input[type="file"]'),st=c.querySelector(".persona-attachment-previews");let N=c.querySelector(".persona-widget-composer .persona-flex.persona-items-center.persona-justify-between");N&&(Ye=N)};Gn(Ne),_e(Ne);let R=(kf=(Af=n.layout)==null?void 0:Af.contentMaxWidth)!=null?kf:H()?(Mf=(Tf=(Sf=n.launcher)==null?void 0:Sf.composerBar)==null?void 0:Tf.contentMaxWidth)!=null?Mf:"720px":void 0;if(R&&(nt.style.maxWidth=R,nt.style.marginLeft="auto",nt.style.marginRight="auto",nt.style.width="100%"),R&&Bt&&!H()&&(Bt.style.maxWidth=R,Bt.style.marginLeft="auto",Bt.style.marginRight="auto"),R&&Rt&&!H()&&(Rt.style.maxWidth=R,Rt.style.marginLeft="auto",Rt.style.marginRight="auto"),R&&st&&!H()&&(st.style.maxWidth=R,st.style.marginLeft="auto",st.style.marginRight="auto"),(Ef=n.attachments)!=null&&Ef.enabled&&ie&&st){St=ha.fromConfig(n.attachments),St.setPreviewsContainer(st),ie.addEventListener("change",y=>{let A=y.target;St==null||St.handleFileSelect(A.files),A.value=""});let c=n.attachments.dropOverlay,g=lb(c);j.appendChild(g)}(()=>{var A,W;let c=(W=(A=n.layout)==null?void 0:A.slots)!=null?W:{},g=_=>{switch(_){case"body-top":return j.querySelector(".persona-rounded-2xl.persona-bg-persona-surface.persona-p-6")||null;case"messages":return nt;case"footer-top":return Rt;case"composer":return Bt;case"footer-bottom":return or;default:return null}},y=(_,U)=>{var V;switch(_){case"header-left":case"header-center":case"header-right":if(_==="header-left")Fe.insertBefore(U,Fe.firstChild);else if(_==="header-right")Fe.appendChild(U);else{let N=Fe.querySelector(".persona-flex-col");N?(V=N.parentNode)==null||V.insertBefore(U,N.nextSibling):Fe.appendChild(U)}break;case"body-top":{let N=ue.querySelector(".persona-rounded-2xl.persona-bg-persona-surface.persona-p-6");N?N.replaceWith(U):ue.insertBefore(U,ue.firstChild);break}case"body-bottom":ue.appendChild(U);break;case"footer-top":Rt.replaceWith(U);break;case"footer-bottom":or.replaceWith(U);break;default:break}};for(let[_,U]of Object.entries(c))if(U)try{let V=U({config:n,defaultContent:()=>g(_)});V&&y(_,V)}catch(V){typeof console!="undefined"&&console.error(`[AgentWidget] Error rendering slot "${_}":`,V)}})();let Ee=c=>{var U,V;let y=c.target.closest('button[data-expand-header="true"]');if(!y)return;let A=y.closest(".persona-reasoning-bubble, .persona-tool-bubble, .persona-approval-bubble");if(!A)return;let W=A.getAttribute("data-message-id");if(!W)return;let _=y.getAttribute("data-bubble-type");if(_==="reasoning")Za.has(W)?Za.delete(W):Za.add(W),Bx(W,A);else if(_==="tool")es.has(W)?es.delete(W):es.add(W),Dx(W,A,n);else if(_==="approval"){let N=n.approval!==!1?n.approval:void 0,Ce=((U=N==null?void 0:N.detailsDisplay)!=null?U:"collapsed")==="expanded",me=(V=$l.get(W))!=null?V:Ce;$l.set(W,!me),_x(W,A,n)}so.delete(W)};nt.addEventListener("pointerdown",c=>{c.target.closest('button[data-expand-header="true"]')&&(c.preventDefault(),Ee(c))}),nt.addEventListener("keydown",c=>{let g=c.target;(c.key==="Enter"||c.key===" ")&&g.closest('button[data-expand-header="true"]')&&(c.preventDefault(),Ee(c))});let Ot=new Map;nt.addEventListener("click",c=>{var U;let y=c.target.closest(".persona-message-action-btn[data-action]");if(!y)return;c.preventDefault(),c.stopPropagation();let A=y.closest("[data-actions-for]");if(!A)return;let W=A.getAttribute("data-actions-for");if(!W)return;let _=y.getAttribute("data-action");if(_==="copy"){let N=q.getMessages().find(Ce=>Ce.id===W);if(N&&ne.onCopy){let Ce=N.content||"";navigator.clipboard.writeText(Ce).then(()=>{y.classList.add("persona-message-action-success");let me=Me("check",14,"currentColor",2);me&&(y.innerHTML="",y.appendChild(me)),setTimeout(()=>{y.classList.remove("persona-message-action-success");let ae=Me("copy",14,"currentColor",2);ae&&(y.innerHTML="",y.appendChild(ae))},2e3)}).catch(me=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to copy message:",me)}),ne.onCopy(N)}}else if(_==="upvote"||_==="downvote"){let N=((U=Ot.get(W))!=null?U:null)===_,Ce=_==="upvote"?"thumbs-up":"thumbs-down";if(N){Ot.delete(W),y.classList.remove("persona-message-action-active");let me=Me(Ce,14,"currentColor",2);me&&(y.innerHTML="",y.appendChild(me))}else{let me=_==="upvote"?"downvote":"upvote",ae=A.querySelector(`[data-action="${me}"]`);if(ae){ae.classList.remove("persona-message-action-active");let Qe=Me(me==="upvote"?"thumbs-up":"thumbs-down",14,"currentColor",2);Qe&&(ae.innerHTML="",ae.appendChild(Qe))}Ot.set(W,_),y.classList.add("persona-message-action-active");let Te=Me(Ce,14,"currentColor",2);Te&&(Te.setAttribute("fill","currentColor"),y.innerHTML="",y.appendChild(Te)),y.classList.remove("persona-message-action-pop"),y.offsetWidth,y.classList.add("persona-message-action-pop");let Se=q.getMessages().find(ct=>ct.id===W);Se&&ne.onFeedback&&ne.onFeedback({type:_,messageId:Se.id,message:Se})}}}),nt.addEventListener("click",c=>{let y=c.target.closest("button[data-approval-action]");if(!y)return;c.preventDefault(),c.stopPropagation();let A=y.closest(".persona-approval-bubble");if(!A)return;let W=A.getAttribute("data-message-id");if(!W)return;let _=y.getAttribute("data-approval-action");if(!_)return;let U=_==="approve"?"approved":"denied",N=q.getMessages().find(me=>me.id===W);if(!(N!=null&&N.approval))return;let Ce=A.querySelector("[data-approval-buttons]");Ce&&Ce.querySelectorAll("button").forEach(ae=>{ae.disabled=!0,ae.style.opacity="0.5",ae.style.cursor="not-allowed"}),N.approval.toolType==="webmcp"?q.resolveWebMcpApproval(W,U):q.resolveApproval(N.approval,U)});let et=null,Nt=null,Yt={artifacts:[],selectedId:null},lr=!1,vt={current:null};nt.addEventListener("click",c=>{var ae,Te,Ve,Se,ct;let y=c.target.closest("[data-download-artifact]");if(!y)return;c.preventDefault(),c.stopPropagation();let A=y.getAttribute("data-download-artifact");if(!A||((Ve=(Te=(ae=n.features)==null?void 0:ae.artifacts)==null?void 0:Te.onArtifactAction)==null?void 0:Ve.call(Te,{type:"download",artifactId:A}))===!0)return;let _=q.getArtifactById(A),U=_==null?void 0:_.markdown,V=(_==null?void 0:_.title)||"artifact";if(!U){let Qe=y.closest("[data-open-artifact]"),ht=Qe==null?void 0:Qe.closest("[data-message-id]"),xt=ht==null?void 0:ht.getAttribute("data-message-id");if(xt){let Pe=q.getMessages().find(Ke=>Ke.id===xt);if(Pe!=null&&Pe.rawContent)try{let Ke=JSON.parse(Pe.rawContent);U=(Se=Ke==null?void 0:Ke.props)==null?void 0:Se.markdown,V=((ct=Ke==null?void 0:Ke.props)==null?void 0:ct.title)||V}catch{}}}if(!U)return;let N=new Blob([U],{type:"text/markdown"}),Ce=URL.createObjectURL(N),me=document.createElement("a");me.href=Ce,me.download=`${V}.md`,me.click(),URL.revokeObjectURL(Ce)}),nt.addEventListener("click",c=>{var _,U,V;let y=c.target.closest("[data-open-artifact]");if(!y)return;let A=y.getAttribute("data-open-artifact");!A||((V=(U=(_=n.features)==null?void 0:_.artifacts)==null?void 0:U.onArtifactAction)==null?void 0:V.call(U,{type:"open",artifactId:A}))===!0||(c.preventDefault(),c.stopPropagation(),lr=!1,q.selectArtifact(A),mn())}),nt.addEventListener("keydown",c=>{if(c.key!=="Enter"&&c.key!==" ")return;let g=c.target;g.hasAttribute("data-open-artifact")&&(c.preventDefault(),g.click())});let zr=Re.composerOverlay,$t=(c,g,y)=>{var V,N,Ce,me;let A=g.trim();if(!A||!vt.current)return;let W=(V=c.getAttribute("data-tool-call-id"))!=null?V:"",_=y.source==="free-text";r.dispatchEvent(new CustomEvent("persona:askUserQuestion:answered",{detail:{toolUseId:W,answer:A,answers:y.structured,values:(N=y.values)!=null?N:y.source==="multi"?A.split(", "):[A],isFreeText:_,source:y.source},bubbles:!0,composed:!0})),Oo(zr,W);let U=vt.current.getMessages().find(ae=>{var Te;return((Te=ae.toolCall)==null?void 0:Te.id)===W});(Ce=U==null?void 0:U.agentMetadata)!=null&&Ce.awaitingLocalTool?vt.current.resolveAskUserQuestion(U,(me=y.structured)!=null?me:A):vt.current.sendMessage(A)},$r=c=>{var W;let g=vt.current;if(!g)return;let y=(W=c.getAttribute("data-tool-call-id"))!=null?W:"",A=g.getMessages().find(_=>{var U;return((U=_.toolCall)==null?void 0:U.id)===y});A&&g.persistAskUserQuestionProgress(A,{answers:Vi(c,A),currentIndex:Wn(c)})},Dn=c=>Object.entries(c).map(([g,y])=>`${g}: ${Array.isArray(y)?y.join(", "):y}`).join(" | "),oo=c=>{var W,_,U;if(((_=(W=n.features)==null?void 0:W.askUserQuestion)==null?void 0:_.groupedAutoAdvance)===!1)return;let g=Wn(c),y=qa(c);if(g>=y-1)return;let A=(U=vt.current)==null?void 0:U.getMessages().find(V=>{var N;return((N=V.toolCall)==null?void 0:N.id)===c.getAttribute("data-tool-call-id")});A&&(ji(c,A,n,g+1),$r(c))};zr.addEventListener("click",c=>{var _,U,V,N,Ce,me,ae,Te,Ve,Se,ct,Qe,ht,xt;let y=c.target.closest("[data-ask-user-action]");if(!y)return;let A=y.closest("[data-persona-ask-sheet-for]");if(!A)return;let W=y.getAttribute("data-ask-user-action");if(c.preventDefault(),c.stopPropagation(),W==="dismiss"){let Be=(_=A.getAttribute("data-tool-call-id"))!=null?_:"";r.dispatchEvent(new CustomEvent("persona:askUserQuestion:dismissed",{detail:{toolUseId:Be},bubbles:!0,composed:!0})),Oo(zr,Be);let Pe=(U=vt.current)==null?void 0:U.getMessages().find(Ke=>{var rt;return((rt=Ke.toolCall)==null?void 0:rt.id)===Be});(V=Pe==null?void 0:Pe.agentMetadata)!=null&&V.awaitingLocalTool&&((N=vt.current)==null||N.markAskUserQuestionResolved(Pe),(Ce=vt.current)==null||Ce.resolveAskUserQuestion(Pe,"(dismissed)"));return}if(W==="pick"){let Be=y.getAttribute("data-option-label");if(!Be)return;let Pe=A.getAttribute("data-multi-select")==="true",Ke=Fo(A);if(Ke&&Pe){let rt=ca(A)[Wn(A)],It=new Set(Array.isArray(rt)?rt:[]);It.has(Be)?It.delete(Be):It.add(Be),No(A,Array.from(It)),$r(A);return}if(Ke){No(A,Be),$r(A),oo(A);return}if(Pe){let rt=y.getAttribute("aria-pressed")==="true";y.setAttribute("aria-pressed",rt?"false":"true"),y.classList.toggle("persona-ask-pill-selected",!rt);let It=A.querySelector('[data-ask-user-action="submit-multi"]');It&&(It.disabled=Fd(A).length===0);return}$t(A,Be,{source:"pick",values:[Be]});return}if(W==="submit-multi"){let Be=Fd(A);if(Be.length===0)return;$t(A,Be.join(", "),{source:"multi",values:Be});return}if(W==="open-free-text"){let Be=A.querySelector('[data-ask-free-text-row="true"]');if(Be){Be.classList.remove("persona-hidden");let Pe=Be.querySelector('[data-ask-free-text-input="true"]');Pe==null||Pe.focus()}return}if(W==="focus-free-text"){let Be=A.querySelector('[data-ask-free-text-input="true"]');Be==null||Be.focus();return}if(W==="submit-free-text"){let Be=A.querySelector('[data-ask-free-text-input="true"]'),Pe=(me=Be==null?void 0:Be.value)!=null?me:"";if(!Pe.trim())return;if(Fo(A)){No(A,Pe.trim()),$r(A),oo(A);return}$t(A,Pe,{source:"free-text"});return}if(W==="next"||W==="back"){if(!vt.current)return;let Be=(ae=A.getAttribute("data-tool-call-id"))!=null?ae:"",Pe=vt.current.getMessages().find(Oe=>{var Ue;return((Ue=Oe.toolCall)==null?void 0:Ue.id)===Be});if(!Pe)return;let Ke=A.querySelector('[data-ask-free-text-input="true"]'),rt=(Ve=(Te=Ke==null?void 0:Ke.value)==null?void 0:Te.trim())!=null?Ve:"";if(rt){let Oe=ca(A)[Wn(A)];(typeof Oe!="string"||Oe!==rt)&&No(A,rt)}let It=W==="next"?1:-1,D=Wn(A)+It;ji(A,Pe,n,D),$r(A);return}if(W==="submit-all"){if(!vt.current)return;let Be=(Se=A.getAttribute("data-tool-call-id"))!=null?Se:"",Pe=vt.current.getMessages().find(Oe=>{var Ue;return((Ue=Oe.toolCall)==null?void 0:Ue.id)===Be});if(!Pe)return;let Ke=A.querySelector('[data-ask-free-text-input="true"]'),rt=(Qe=(ct=Ke==null?void 0:Ke.value)==null?void 0:ct.trim())!=null?Qe:"";rt&&No(A,rt);let It=Vi(A,Pe);vt.current.persistAskUserQuestionProgress(Pe,{answers:It,currentIndex:Wn(A)});let D=Dn(It);$t(A,D||"(submitted)",{source:"submit-all",structured:It});return}if(W==="skip"){if(!vt.current)return;let Be=(ht=A.getAttribute("data-tool-call-id"))!=null?ht:"",Pe=vt.current.getMessages().find(Ue=>{var be;return((be=Ue.toolCall)==null?void 0:be.id)===Be});if(!Pe)return;let Ke=Fo(A),rt=Wn(A),It=qa(A),D=rt>=It-1;if(!Ke){r.dispatchEvent(new CustomEvent("persona:askUserQuestion:dismissed",{detail:{toolUseId:Be},bubbles:!0,composed:!0})),Oo(zr,Be),(xt=Pe.agentMetadata)!=null&&xt.awaitingLocalTool&&(vt.current.markAskUserQuestionResolved(Pe),vt.current.resolveAskUserQuestion(Pe,"(dismissed)"));return}No(A,"");let Oe=A.querySelector('[data-ask-free-text-input="true"]');if(Oe&&(Oe.value=""),D){let Ue=Vi(A,Pe),be=Dn(Ue);$t(A,be||"(skipped)",{source:"submit-all",structured:Ue});return}ji(A,Pe,n,rt+1),$r(A);return}}),zr.addEventListener("keydown",c=>{var _;if(c.key!=="Enter")return;let y=c.target;if(!((_=y.matches)!=null&&_.call(y,'[data-ask-free-text-input="true"]')))return;let A=y.closest("[data-persona-ask-sheet-for]");if(!A)return;c.preventDefault();let W=y.value;if(W.trim()){if(Fo(A)){No(A,W.trim()),$r(A),oo(A);return}$t(A,W,{source:"free-text"})}});let Ao=c=>{if(!/^[1-9]$/.test(c.key)||c.metaKey||c.ctrlKey||c.altKey)return;let g=c.target;if((g==null?void 0:g.tagName)==="INPUT"||(g==null?void 0:g.tagName)==="TEXTAREA"||g!=null&&g.isContentEditable)return;let y=zr.querySelector("[data-persona-ask-sheet-for]");if(!y||y.getAttribute("data-ask-layout")!=="rows"||y.getAttribute("data-multi-select")==="true")return;let A=Number(c.key),_=y.querySelectorAll('[data-ask-pill-list="true"] [data-ask-user-action="pick"], [data-ask-pill-list="true"] [data-ask-user-action="focus-free-text"]')[A-1];_&&(c.preventDefault(),_.click())};document.addEventListener("keydown",Ao);let fn=null,Vt=null,Qr=null,En=null,So=()=>{};function ao(){En==null||En(),En=null}let To=()=>{var U;if(!fn||!Vt)return;let c=r.classList.contains("persona-artifact-appearance-seamless"),y=((U=r.ownerDocument.defaultView)!=null?U:window).innerWidth<=640;if(!c||r.classList.contains("persona-artifact-narrow-host")||y){Vt.style.removeProperty("position"),Vt.style.removeProperty("left"),Vt.style.removeProperty("top"),Vt.style.removeProperty("bottom"),Vt.style.removeProperty("width"),Vt.style.removeProperty("z-index");return}let A=fn.firstElementChild;if(!A||A===Vt)return;let W=10;Vt.style.position="absolute",Vt.style.top="0",Vt.style.bottom="0",Vt.style.width=`${W}px`,Vt.style.zIndex="5";let _=A.offsetWidth-W/2;Vt.style.left=`${Math.max(0,_)}px`},Kn=()=>{},mn=()=>{var y,A,W,_,U;if(!et||!Bn(n))return;Gl(r,n),Kl(r,n),Kn();let c=(_=(W=(A=(y=n.features)==null?void 0:y.artifacts)==null?void 0:A.layout)==null?void 0:W.narrowHostMaxWidth)!=null?_:520,g=he.getBoundingClientRect().width||0;r.classList.toggle("persona-artifact-narrow-host",g>0&&g<=c),et.update(Yt),lr?(et.setMobileOpen(!1),et.element.classList.add("persona-hidden"),(U=et.backdrop)==null||U.classList.add("persona-hidden")):Yt.artifacts.length>0&&(et.element.classList.remove("persona-hidden"),et.setMobileOpen(!0)),So()};if(Bn(n)){he.style.position="relative";let c=v("div","persona-flex persona-flex-1 persona-flex-col persona-min-w-0 persona-min-h-0"),g=v("div","persona-flex persona-h-full persona-w-full persona-min-h-0 persona-artifact-split-root");c.appendChild(j),et=Kx(n,{onSelect:y=>{var A;return(A=vt.current)==null?void 0:A.selectArtifact(y)},onDismiss:()=>{lr=!0,mn()}}),et.element.classList.add("persona-hidden"),fn=g,g.appendChild(c),g.appendChild(et.element),et.backdrop&&he.appendChild(et.backdrop),he.appendChild(g),So=()=>{var A,W,_,U;if(!fn||!et)return;if(!(((_=(W=(A=n.features)==null?void 0:A.artifacts)==null?void 0:W.layout)==null?void 0:_.resizable)===!0)){Qr==null||Qr(),Qr=null,ao(),Vt&&(Vt.remove(),Vt=null),et.element.style.removeProperty("width"),et.element.style.removeProperty("maxWidth");return}if(!Vt){let V=v("div","persona-artifact-split-handle persona-shrink-0 persona-h-full");V.setAttribute("role","separator"),V.setAttribute("aria-orientation","vertical"),V.setAttribute("aria-label","Resize artifacts panel"),V.tabIndex=0;let N=r.ownerDocument,Ce=(U=N.defaultView)!=null?U:window,me=ae=>{var ht,xt;if(!et||ae.button!==0||r.classList.contains("persona-artifact-narrow-host")||Ce.innerWidth<=640)return;ae.preventDefault(),ao();let Te=ae.clientX,Ve=et.element.getBoundingClientRect().width,Se=(xt=(ht=n.features)==null?void 0:ht.artifacts)==null?void 0:xt.layout,ct=Be=>{let Pe=fn.getBoundingClientRect().width,Ke=r.classList.contains("persona-artifact-appearance-seamless"),rt=Ke?0:Yx(fn,Ce),It=Ke?0:V.getBoundingClientRect().width||6,D=Ve-(Be.clientX-Te),Oe=Zx(D,Pe,rt,It,Se==null?void 0:Se.resizableMinWidth,Se==null?void 0:Se.resizableMaxWidth);et.element.style.width=`${Oe}px`,et.element.style.maxWidth="none",To()},Qe=()=>{N.removeEventListener("pointermove",ct),N.removeEventListener("pointerup",Qe),N.removeEventListener("pointercancel",Qe),En=null;try{V.releasePointerCapture(ae.pointerId)}catch{}};En=Qe,N.addEventListener("pointermove",ct),N.addEventListener("pointerup",Qe),N.addEventListener("pointercancel",Qe);try{V.setPointerCapture(ae.pointerId)}catch{}};V.addEventListener("pointerdown",me),Vt=V,fn.insertBefore(V,et.element),Qr=()=>{V.removeEventListener("pointerdown",me)}}if(Vt){let V=Yt.artifacts.length>0&&!lr;Vt.classList.toggle("persona-hidden",!V),To()}},Kn=()=>{var Ce,me,ae,Te,Ve,Se,ct,Qe,ht,xt,Be,Pe,Ke,rt;if(!T||!et||((me=(Ce=n.launcher)==null?void 0:Ce.sidebarMode)!=null?me:!1)||Pr(n)&&Sn(n).reveal==="emerge")return;let A=(ae=r.ownerDocument.defaultView)!=null?ae:window,W=(Ve=(Te=n.launcher)==null?void 0:Te.mobileFullscreen)!=null?Ve:!0,_=(ct=(Se=n.launcher)==null?void 0:Se.mobileBreakpoint)!=null?ct:640;if(W&&A.innerWidth<=_||!Jx(n,T))return;let U=(xt=(ht=(Qe=n.launcher)==null?void 0:Qe.width)!=null?ht:n.launcherWidth)!=null?xt:An,V=(rt=(Ke=(Pe=(Be=n.features)==null?void 0:Be.artifacts)==null?void 0:Pe.layout)==null?void 0:Ke.expandedPanelWidth)!=null?rt:"min(720px, calc(100vw - 24px))";Yt.artifacts.length>0&&!lr?(he.style.width=V,he.style.maxWidth=V):(he.style.width=U,he.style.maxWidth=U)},typeof ResizeObserver!="undefined"&&(Nt=new ResizeObserver(()=>{mn()}),Nt.observe(he))}else he.appendChild(j),H()&&at&&(Re.peekBanner&&at.appendChild(Re.peekBanner),at.appendChild(Ne));r.appendChild(We),at&&r.appendChild(at);let Fn=()=>{var Oe,Ue,be,Qt,Gt,dr,Wt,ir,bn,kr,ot,_t,Lr,In,yn,Qo,Jo,Ba,Da,mr,Yo,Wo,Bo,uo,Zo,qn,dt,Hr;if(H()){he.style.width="100%",he.style.maxWidth="100%";let er=(Ue=(Oe=n.launcher)==null?void 0:Oe.composerBar)!=null?Ue:{},Jt=We.dataset.state==="expanded",kt=(be=er.expandedSize)!=null?be:"anchored";if(!(Jt&&kt!=="fullscreen")){j.style.background="",j.style.border="",j.style.borderRadius="",j.style.overflow="",j.style.boxShadow="";return}let Ft=(Gt=(Qt=n.theme)==null?void 0:Qt.components)==null?void 0:Gt.panel,jr=Xa(n),Jr=(Zr,ea)=>{var Cs;return Zr==null||Zr===""?ea:(Cs=Ga(jr,Zr))!=null?Cs:Zr},eo="1px solid var(--persona-border)",Nr="var(--persona-palette-shadows-xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25))",Yr="var(--persona-panel-radius, var(--persona-radius-xl, 0.75rem))";j.style.background="var(--persona-surface, #ffffff)",j.style.border=Jr(Ft==null?void 0:Ft.border,eo),j.style.borderRadius=Jr(Ft==null?void 0:Ft.borderRadius,Yr),j.style.boxShadow=Jr(Ft==null?void 0:Ft.shadow,Nr),j.style.overflow="hidden";return}let c=Pr(n),g=(Wt=(dr=n.launcher)==null?void 0:dr.sidebarMode)!=null?Wt:!1,y=c||g||((bn=(ir=n.launcher)==null?void 0:ir.fullHeight)!=null?bn:!1),A=((kr=n.launcher)==null?void 0:kr.enabled)===!1,W=(_t=(ot=n.theme)==null?void 0:ot.components)==null?void 0:_t.panel,_=Xa(n),U=(er,Jt)=>{var kt;return er==null||er===""?Jt:(kt=Ga(_,er))!=null?kt:er},V=(Lr=r.ownerDocument.defaultView)!=null?Lr:window,N=(yn=(In=n.launcher)==null?void 0:In.mobileFullscreen)!=null?yn:!0,Ce=(Jo=(Qo=n.launcher)==null?void 0:Qo.mobileBreakpoint)!=null?Jo:640,me=V.innerWidth<=Ce,ae=N&&me&&T,Te=(Da=(Ba=n.launcher)==null?void 0:Ba.position)!=null?Da:"bottom-left",Ve=Te==="bottom-left"||Te==="top-left",Se=(Yo=(mr=n.launcher)==null?void 0:mr.zIndex)!=null?Yo:Xr,ct=g||ae?"none":"1px solid var(--persona-border)",Qe=ae?"none":g?Ve?"var(--persona-palette-shadows-sidebar-left, 2px 0 12px rgba(0, 0, 0, 0.08))":"var(--persona-palette-shadows-sidebar-right, -2px 0 12px rgba(0, 0, 0, 0.08))":"var(--persona-palette-shadows-xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25))";c&&!ae&&(Qe="none",ct="none");let ht=g||ae?"0":"var(--persona-panel-radius, var(--persona-radius-xl, 0.75rem))",xt=U(W==null?void 0:W.border,ct),Be=U(W==null?void 0:W.shadow,Qe),Pe=U(W==null?void 0:W.borderRadius,ht),Ke=ue.scrollTop;r.style.cssText="",We.style.cssText="",he.style.cssText="",j.style.cssText="",ue.style.cssText="",Ne.style.cssText="";let rt=()=>{var Jt;if(Ke<=0)return;((Jt=ue.ownerDocument.defaultView)!=null?Jt:window).requestAnimationFrame(()=>{if(ue.scrollTop===Ke)return;let kt=ue.scrollHeight-ue.clientHeight;kt<=0||(ue.scrollTop=Math.min(Ke,kt))})};if(ae){We.classList.remove("persona-bottom-6","persona-right-6","persona-left-6","persona-top-6","persona-bottom-4","persona-right-4","persona-left-4","persona-top-4"),We.style.cssText=`
|
|
78
|
+
`,E.addEventListener("click",()=>{f=v,M.forEach((H,I)=>{let P=I<v;H.classList.toggle("selected",P),H.setAttribute("aria-checked",I===v-1?"true":"false")})}),M.push(E),T.appendChild(E)}p.appendChild(T);let k=null;if(d){let v=document.createElement("div");v.className="persona-feedback-comment-container",k=document.createElement("textarea"),k.className="persona-feedback-comment",k.placeholder=a,k.rows=3,k.setAttribute("aria-label","Additional comments"),v.appendChild(k),p.appendChild(v)}let L=document.createElement("div");L.className="persona-feedback-actions";let x=document.createElement("button");x.type="button",x.className="persona-feedback-btn persona-feedback-btn-skip",x.textContent=i,x.addEventListener("click",()=>{t==null||t(),u.remove()});let w=document.createElement("button");return w.type="button",w.className="persona-feedback-btn persona-feedback-btn-submit",w.textContent=s,w.addEventListener("click",async()=>{if(f===null){T.classList.add("persona-feedback-shake"),setTimeout(()=>T.classList.remove("persona-feedback-shake"),500);return}w.disabled=!0,w.textContent="Submitting...";try{let v=(k==null?void 0:k.value.trim())||void 0;await e(f,v),u.remove()}catch(v){w.disabled=!1,w.textContent=s,console.error("[CSAT Feedback] Failed to submit:",v)}}),L.appendChild(x),L.appendChild(w),p.appendChild(L),u.appendChild(p),u}function nd(r){let{onSubmit:e,onDismiss:t,title:o="How likely are you to recommend us?",subtitle:n="On a scale of 0 to 10",commentPlaceholder:a="What could we do better? (optional)...",submitText:s="Submit",skipText:i="Skip",showComment:d=!0,lowLabel:l="Not likely",highLabel:u="Very likely"}=r,f=document.createElement("div");f.className="persona-feedback-container persona-feedback-nps",f.setAttribute("role","dialog"),f.setAttribute("aria-label","Net Promoter Score feedback");let p=null,m=document.createElement("div");m.className="persona-feedback-content";let y=document.createElement("div");y.className="persona-feedback-header";let h=document.createElement("h3");h.className="persona-feedback-title",h.textContent=o,y.appendChild(h);let T=document.createElement("p");T.className="persona-feedback-subtitle",T.textContent=n,y.appendChild(T),m.appendChild(y);let M=document.createElement("div");M.className="persona-feedback-rating persona-feedback-rating-nps",M.setAttribute("role","radiogroup"),M.setAttribute("aria-label","Likelihood rating from 0 to 10");let k=document.createElement("div");k.className="persona-feedback-labels";let L=document.createElement("span");L.className="persona-feedback-label-low",L.textContent=l;let x=document.createElement("span");x.className="persona-feedback-label-high",x.textContent=u,k.appendChild(L),k.appendChild(x);let w=document.createElement("div");w.className="persona-feedback-numbers";let v=[];for(let z=0;z<=10;z++){let j=document.createElement("button");j.type="button",j.className="persona-feedback-rating-btn persona-feedback-number-btn",j.setAttribute("role","radio"),j.setAttribute("aria-checked","false"),j.setAttribute("aria-label",`Rating ${z} out of 10`),j.textContent=String(z),j.dataset.rating=String(z),z<=6?j.classList.add("persona-feedback-detractor"):z<=8?j.classList.add("persona-feedback-passive"):j.classList.add("persona-feedback-promoter"),j.addEventListener("click",()=>{p=z,v.forEach((ie,ve)=>{ie.classList.toggle("selected",ve===z),ie.setAttribute("aria-checked",ve===z?"true":"false")})}),v.push(j),w.appendChild(j)}M.appendChild(k),M.appendChild(w),m.appendChild(M);let E=null;if(d){let z=document.createElement("div");z.className="persona-feedback-comment-container",E=document.createElement("textarea"),E.className="persona-feedback-comment",E.placeholder=a,E.rows=3,E.setAttribute("aria-label","Additional comments"),z.appendChild(E),m.appendChild(z)}let H=document.createElement("div");H.className="persona-feedback-actions";let I=document.createElement("button");I.type="button",I.className="persona-feedback-btn persona-feedback-btn-skip",I.textContent=i,I.addEventListener("click",()=>{t==null||t(),f.remove()});let P=document.createElement("button");return P.type="button",P.className="persona-feedback-btn persona-feedback-btn-submit",P.textContent=s,P.addEventListener("click",async()=>{if(p===null){w.classList.add("persona-feedback-shake"),setTimeout(()=>w.classList.remove("persona-feedback-shake"),500);return}P.disabled=!0,P.textContent="Submitting...";try{let z=(E==null?void 0:E.value.trim())||void 0;await e(p,z),f.remove()}catch(z){P.disabled=!1,P.textContent=s,console.error("[NPS Feedback] Failed to submit:",z)}}),H.appendChild(I),H.appendChild(P),m.appendChild(H),f.appendChild(m),f}var cs="persona-chat-history",QC=30*1e3,YC={"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","image/bmp":"bmp","image/tiff":"tiff"};function JC(r){var o,n,a;if(!r)return[];let e=[],t=Array.from((o=r.items)!=null?o:[]);for(let s of t){if(s.kind!=="file"||!s.type.startsWith("image/"))continue;let i=s.getAsFile();if(!i)continue;if(i.name){e.push(i);continue}let d=(n=YC[i.type])!=null?n:"png";e.push(new File([i],`clipboard-image-${Date.now()}.${d}`,{type:i.type,lastModified:Date.now()}))}if(e.length>0)return e;for(let s of Array.from((a=r.files)!=null?a:[]))s.type.startsWith("image/")&&e.push(s);return e}function ad(r){if(!r)return!1;let e=r.types;return e?typeof e.contains=="function"?e.contains("Files"):Array.from(e).includes("Files"):!1}function ZC(r){var e,t,o,n,a,s,i,d,l;return r?r===!0?{storage:"session",keyPrefix:"persona-",persist:{openState:!0,voiceState:!0,focusInput:!0},clearOnChatClear:!0}:{storage:(e=r.storage)!=null?e:"session",keyPrefix:(t=r.keyPrefix)!=null?t:"persona-",persist:{openState:(n=(o=r.persist)==null?void 0:o.openState)!=null?n:!0,voiceState:(s=(a=r.persist)==null?void 0:a.voiceState)!=null?s:!0,focusInput:(d=(i=r.persist)==null?void 0:i.focusInput)!=null?d:!0},clearOnChatClear:(l=r.clearOnChatClear)!=null?l:!0}:null}function ew(r){try{let e=r==="local"?localStorage:sessionStorage,t="__persist_test__";return e.setItem(t,"1"),e.removeItem(t),e}catch{return null}}var gu=r=>!r||typeof r!="object"?{}:{...r},fy=r=>r.map(e=>({...e,streaming:!1})),my=(r,e,t)=>{let o=r!=null&&r.markdown?ua(r.markdown):null,n=ja(r==null?void 0:r.sanitize);return r!=null&&r.postprocessMessage&&n&&(r==null?void 0:r.sanitize)===void 0&&console.warn("[Persona] A custom postprocessMessage is active with the default HTML sanitizer. Tags or attributes not in the built-in allowlist will be stripped. To keep custom HTML, set `sanitize: false` or provide a custom sanitize function."),a=>{var l,u,f;let s=(l=a.text)!=null?l:"",i=(u=a.message.rawContent)!=null?u:null;if(e){let p=e.process({text:s,raw:i!=null?i:s,message:a.message,streaming:a.streaming});p!==null&&(s=p.text,p.persist||(a.message.__skipPersist=!0),p.resubmit&&!a.streaming&&t&&t())}let d;return r!=null&&r.postprocessMessage?d=r.postprocessMessage({...a,text:s,raw:(f=i!=null?i:a.text)!=null?f:""}):o?d=o(s):d=fa(s),n?n(d):d}};function gy(r){var i,d,l,u;let e=C("div","persona-attachment-drop-overlay");r!=null&&r.background&&e.style.setProperty("--persona-drop-overlay-bg",r.background),(r==null?void 0:r.backdropBlur)!==void 0&&e.style.setProperty("--persona-drop-overlay-blur",r.backdropBlur),r!=null&&r.border&&e.style.setProperty("--persona-drop-overlay-border",r.border),r!=null&&r.borderRadius&&e.style.setProperty("--persona-drop-overlay-radius",r.borderRadius),r!=null&&r.inset&&e.style.setProperty("--persona-drop-overlay-inset",r.inset),r!=null&&r.labelSize&&e.style.setProperty("--persona-drop-overlay-label-size",r.labelSize),r!=null&&r.labelColor&&e.style.setProperty("--persona-drop-overlay-label-color",r.labelColor);let t=(i=r==null?void 0:r.iconName)!=null?i:"upload",o=(d=r==null?void 0:r.iconSize)!=null?d:"48px",n=(l=r==null?void 0:r.iconColor)!=null?l:"rgba(59, 130, 246, 0.6)",a=(u=r==null?void 0:r.iconStrokeWidth)!=null?u:.5,s=Ee(t,o,n,a);if(s&&e.appendChild(s),r!=null&&r.label){let f=C("span","persona-drop-overlay-label");f.textContent=r.label,e.appendChild(f)}return e}var sd=(r,e,t)=>{var Gu,Ku,Xu,Qu,Yu,Ju,Zu,ef,tf,rf,of,nf,af,sf,lf,df,cf,pf,uf,ff,mf,gf,hf,xf,yf,bf,vf,Cf,wf,Af,Sf,Tf,Mf,kf,Ef,Lf,Pf,Rf,If,Hf,Wf,Bf,Df,Of,_f,Nf,Ff,Uf,qf,zf;if(r==null)throw new Error('createAgentExperience: mount must be a non-null HTMLElement (e.g. pass document.getElementById("my-root") after the node exists).');r.id&&!r.getAttribute("data-persona-instance")&&r.setAttribute("data-persona-instance",r.id),r.hasAttribute("data-persona-root")||r.setAttribute("data-persona-root","true");let o=Tl(e),n=mi.getForInstance(o.plugins);o.components&&En.registerAll(o.components);let a=ly(),i=o.persistState===!1?null:(Gu=o.storageAdapter)!=null?Gu:Jl(),d={},l=null,u=!1,f=c=>{if(o.onStateLoaded)try{let g=o.onStateLoaded(c);if(g&&typeof g=="object"&&"state"in g){let{state:b,open:S}=g;return S&&(u=!0),b}return g}catch(g){typeof console!="undefined"&&console.error("[AgentWidget] onStateLoaded hook failed:",g)}return c};if(i!=null&&i.load)try{let c=i.load();if(c&&typeof c.then=="function")l=c.then(g=>{let b=g!=null?g:{messages:[],metadata:{}};return f(b)});else{let g=c!=null?c:{messages:[],metadata:{}},b=f(g);b.metadata&&(d=gu(b.metadata)),(Ku=b.messages)!=null&&Ku.length&&(o={...o,initialMessages:b.messages}),(Xu=b.artifacts)!=null&&Xu.length&&(o={...o,initialArtifacts:b.artifacts,initialSelectedArtifactId:(Qu=b.selectedArtifactId)!=null?Qu:null})}}catch(c){typeof console!="undefined"&&console.error("[AgentWidget] Failed to load stored state:",c)}else if(o.onStateLoaded)try{let c=f({messages:[],metadata:{}});(Yu=c.messages)!=null&&Yu.length&&(o={...o,initialMessages:c.messages})}catch(c){typeof console!="undefined"&&console.error("[AgentWidget] onStateLoaded hook failed:",c)}let p=()=>d,m=c=>{var b;d=(b=c({...d}))!=null?b:{},Wa()},y=o.actionParsers&&o.actionParsers.length?o.actionParsers:[gi],h=o.actionHandlers&&o.actionHandlers.length?o.actionHandlers:[Ea.message,Ea.messageAndClick],T=hi({parsers:y,handlers:h,getSessionMetadata:p,updateSessionMetadata:m,emit:a.emit,documentRef:typeof document!="undefined"?document:null});T.syncFromMetadata();let M=(Zu=(Ju=o.launcher)==null?void 0:Ju.enabled)!=null?Zu:!0,k=(tf=(ef=o.launcher)==null?void 0:ef.autoExpand)!=null?tf:!1,L=(rf=o.autoFocusInput)!=null?rf:!1,x=k,w=M,v=(nf=(of=o.layout)==null?void 0:of.header)==null?void 0:nf.layout,E=!1,H=()=>Kn(o),I=()=>M||H(),P=H()?!1:M?k:!0,z=!1,j=null,ie=()=>{z=!0,j&&clearTimeout(j),j=setTimeout(()=>{z&&(typeof console!="undefined"&&console.warn("[AgentWidget] Resubmit requested but no injection occurred within 10s"),z=!1)},1e4)},ve=my(o,T,ie),Xe=(sf=(af=o.features)==null?void 0:af.showReasoning)!=null?sf:!0,Ae=(df=(lf=o.features)==null?void 0:lf.showToolCalls)!=null?df:!0,We=(pf=(cf=o.features)==null?void 0:cf.showEventStreamToggle)!=null?pf:!1,Me=(ff=(uf=o.features)==null?void 0:uf.scrollToBottom)!=null?ff:{},Ue=(gf=(mf=o.features)==null?void 0:mf.scrollBehavior)!=null?gf:{},Z=`${(xf=typeof o.persistState=="object"?(hf=o.persistState)==null?void 0:hf.keyPrefix:void 0)!=null?xf:"persona-"}event-stream`,ne=We?new ui(Z):null,me=(vf=(bf=(yf=o.features)==null?void 0:yf.eventStream)==null?void 0:bf.maxEvents)!=null?vf:2e3,be=We?new pi(me,ne):null,ye=We?new fi:null,Y=null,ge=!1,Oe=null,ce=0;ne==null||ne.open().then(()=>be==null?void 0:be.restore()).catch(c=>{o.debug&&console.warn("[AgentWidget] IndexedDB not available for event stream:",c)});let ae={onCopy:c=>{var g,b;a.emit("message:copy",c),U!=null&&U.isClientTokenMode()&&U.submitMessageFeedback(c.id,"copy").catch(S=>{o.debug&&console.error("[AgentWidget] Failed to submit copy feedback:",S)}),(b=(g=o.messageActions)==null?void 0:g.onCopy)==null||b.call(g,c)},onFeedback:c=>{var g,b;a.emit("message:feedback",c),U!=null&&U.isClientTokenMode()&&U.submitMessageFeedback(c.messageId,c.type).catch(S=>{o.debug&&console.error("[AgentWidget] Failed to submit feedback:",S)}),(b=(g=o.messageActions)==null?void 0:g.onFeedback)==null||b.call(g,c)}},Q=(Cf=o.statusIndicator)!=null?Cf:{},Tt=c=>{var g,b,S,W;return c==="idle"?(g=Q.idleText)!=null?g:ao.idle:c==="connecting"?(b=Q.connectingText)!=null?b:ao.connecting:c==="connected"?(S=Q.connectedText)!=null?S:ao.connected:c==="error"?(W=Q.errorText)!=null?W:ao.error:ao[c]};function Ye(c,g,b,S){if(S==="idle"&&b.idleLink){c.textContent="";let W=document.createElement("a");W.href=b.idleLink,W.target="_blank",W.rel="noopener noreferrer",W.textContent=g,W.style.color="inherit",W.style.textDecoration="none",c.appendChild(W)}else c.textContent=g}let{wrapper:De,panel:le,pillRoot:nt}=Ox(o),Re=_x(o,I()),{container:K,body:he,messagesWrapper:it,suggestions:Pt,textarea:te,sendButton:_e,sendButtonWrapper:Ar,composerForm:Rt,statusText:dr,introTitle:Yr,introSubtitle:zr,closeButton:O,iconHolder:fe,headerTitle:Ie,headerSubtitle:Je,header:qe,footer:ze,actionsRow:lt,leftActions:Mt,rightActions:Dt}=Re,or=Re.setSendButtonMode,X=Re.micButton,wt=Re.micButtonWrapper,ct=Re.attachmentButton,Ce=Re.attachmentButtonWrapper,de=Re.attachmentInput,rt=Re.attachmentPreviewsContainer;K.classList.add("persona-relative"),he.classList.add("persona-relative");let Ft=12,zt=()=>{var c;return(c=Me.label)!=null?c:""},Pr=()=>{var c;return(c=Me.iconName)!=null?c:"arrow-down"},vr=()=>Me.enabled!==!1,xt=()=>{var c;return(c=Ue.mode)!=null?c:"follow"},It=()=>{var c;return(c=Ue.anchorTopOffset)!=null?c:16},tt=C("button","persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-z-10 persona-flex persona-items-center persona-gap-1 persona-text-xs persona-transform persona--translate-x-1/2 persona-cursor-pointer");tt.type="button",tt.style.display="none",tt.setAttribute("data-persona-scroll-to-bottom","true");let jt=C("span","persona-flex persona-items-center"),cr=C("span",""),Dr=C("span","");Dr.setAttribute("data-persona-scroll-to-bottom-count",""),Dr.style.display="none",tt.append(jt,cr,Dr),K.appendChild(tt);let hr=C("div","persona-stream-anchor-spacer");hr.setAttribute("aria-hidden","true"),hr.setAttribute("data-persona-anchor-spacer",""),hr.style.flexShrink="0",hr.style.pointerEvents="none",hr.style.height="0px",he.appendChild(hr);let Sr=()=>{let g=ze.style.display==="none"?0:ze.offsetHeight;tt.style.bottom=`${g+Ft}px`};Sr();let Oo=()=>{let c=!!zt();tt.setAttribute("aria-label",zt()||"Jump to latest"),tt.title=zt(),tt.setAttribute("data-persona-scroll-to-bottom-has-label",c?"true":"false"),jt.innerHTML="";let g=Ee(Pr(),"14px","currentColor",2);g?(jt.appendChild(g),jt.style.display=""):jt.style.display="none",cr.textContent=zt(),cr.style.display=c?"":"none"};Oo();let je=null,Tr=null,io=n.find(c=>c.renderHeader);if(io!=null&&io.renderHeader){let c=io.renderHeader({config:o,defaultRenderer:()=>{let g=kn({config:o,showClose:I()});return Ta(K,g,o),g.header},onClose:()=>Gt(!1,"user")});if(c){let g=K.querySelector(".persona-border-b-persona-divider");g&&(g.replaceWith(c),qe=c)}}let _o=()=>{var g,b,S,W;if(!be)return;if(ge=!0,!Y&&be&&(Y=Jx({buffer:be,getFullHistory:()=>be.getAllFromStore(),onClose:()=>lo(),config:o,plugins:n,getThroughput:()=>{var F;return(F=ye==null?void 0:ye.getMetric())!=null?F:{status:"idle"}}})),Y&&(he.style.display="none",(g=ze.parentNode)==null||g.insertBefore(Y.element,ze),Y.update()),At){At.style.boxShadow=`inset 0 0 0 1.5px ${Ao.actionIconColor}`;let F=(W=(S=(b=o.features)==null?void 0:b.eventStream)==null?void 0:S.classNames)==null?void 0:W.toggleButtonActive;F&&F.split(/\s+/).forEach(q=>q&&At.classList.add(q))}let c=()=>{if(!ge)return;let F=Date.now();F-ce>=200&&(Y==null||Y.update(),ce=F),Oe=requestAnimationFrame(c)};ce=0,Oe=requestAnimationFrame(c),To(),a.emit("eventStream:opened",{timestamp:Date.now()})},lo=()=>{var c,g,b;if(ge){if(ge=!1,Y&&Y.element.remove(),he.style.display="",At){At.style.boxShadow="";let S=(b=(g=(c=o.features)==null?void 0:c.eventStream)==null?void 0:g.classNames)==null?void 0:b.toggleButtonActive;S&&S.split(/\s+/).forEach(W=>W&&At.classList.remove(W))}Oe!==null&&(cancelAnimationFrame(Oe),Oe=null),To(),a.emit("eventStream:closed",{timestamp:Date.now()})}},At=null;if(We){let c=(Af=(wf=o.features)==null?void 0:wf.eventStream)==null?void 0:Af.classNames,g="persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1"+(c!=null&&c.toggleButton?" "+c.toggleButton:"");At=C("button",g),At.style.width="28px",At.style.height="28px",At.style.color=Ao.actionIconColor,At.type="button",At.setAttribute("aria-label","Event Stream"),At.title="Event Stream";let b=Ee("activity","18px","currentColor",1.5);b&&At.appendChild(b);let S=Re.clearChatButtonWrapper,W=Re.closeButtonWrapper,F=S||W;F&&F.parentNode===qe?qe.insertBefore(At,F):qe.appendChild(At),At.addEventListener("click",()=>{ge?lo():_o()})}let rn=c=>{var S,W,F;let g=o.attachments;if(!(g!=null&&g.enabled))return;let b=c.querySelector(".persona-attachment-previews");if(!b){b=C("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2"),b.style.display="none";let q=c.querySelector("[data-persona-composer-form]");q!=null&&q.parentNode?q.parentNode.insertBefore(b,q):c.insertBefore(b,c.firstChild)}if(!c.querySelector('input[type="file"]')){let q=C("input");q.type="file",q.accept=((S=g.allowedTypes)!=null?S:Tn).join(","),q.multiple=((W=g.maxFiles)!=null?W:4)>1,q.style.display="none",q.setAttribute("aria-label",(F=g.buttonTooltipText)!=null?F:"Attach files"),c.appendChild(q)}},No=n.find(c=>c.renderComposer);if(No!=null&&No.renderComposer){let c=o.composer,g=No.renderComposer({config:o,defaultRenderer:()=>ns({config:o}).footer,onSubmit:b=>{var q;if(!U||U.isStreaming())return;let S=b.trim(),W=(q=je==null?void 0:je.hasAttachments())!=null?q:!1;if(!S&&!W)return;V();let F;W&&(F=[],F.push(...je.getContentParts()),S&&F.push(Qs(S))),U.sendMessage(S,{contentParts:F}),W&&je.clearAttachments()},streaming:!1,disabled:!1,openAttachmentPicker:()=>{de==null||de.click()},models:c==null?void 0:c.models,selectedModelId:c==null?void 0:c.selectedModelId,onModelChange:b=>{o.composer={...o.composer,selectedModelId:b},o.agent&&(o.agent={...o.agent,model:b})},onVoiceToggle:((Sf=o.voiceRecognition)==null?void 0:Sf.enabled)===!0?()=>{Tr==null||Tr()}:void 0});g&&(ze.replaceWith(g),ze=g)}let mn=c=>{let g=c.querySelector("[data-persona-composer-form]"),b=c.querySelector("[data-persona-composer-input]"),S=c.querySelector("[data-persona-composer-submit]"),W=c.querySelector("[data-persona-composer-mic]"),F=c.querySelector("[data-persona-composer-status]");g&&(Rt=g),b&&(te=b),S&&(_e=S),W&&(X=W,wt=W.parentElement),F&&(dr=F);let q=c.querySelector(".persona-mb-3.persona-flex.persona-flex-wrap.persona-gap-2");q&&(Pt=q);let G=c.querySelector(".persona-attachment-button");G&&(ct=G,Ce=G.parentElement),de=c.querySelector('input[type="file"]'),rt=c.querySelector(".persona-attachment-previews");let N=c.querySelector(".persona-widget-composer .persona-flex.persona-items-center.persona-justify-between");N&&(lt=N)};rn(ze),mn(ze);let Jr=(Lf=(Tf=o.layout)==null?void 0:Tf.contentMaxWidth)!=null?Lf:H()?(Ef=(kf=(Mf=o.launcher)==null?void 0:Mf.composerBar)==null?void 0:kf.contentMaxWidth)!=null?Ef:"720px":void 0;if(Jr&&(it.style.maxWidth=Jr,it.style.marginLeft="auto",it.style.marginRight="auto",it.style.width="100%"),Jr&&Rt&&!H()&&(Rt.style.maxWidth=Jr,Rt.style.marginLeft="auto",Rt.style.marginRight="auto"),Jr&&Pt&&!H()&&(Pt.style.maxWidth=Jr,Pt.style.marginLeft="auto",Pt.style.marginRight="auto"),Jr&&rt&&!H()&&(rt.style.maxWidth=Jr,rt.style.marginLeft="auto",rt.style.marginRight="auto"),(Pf=o.attachments)!=null&&Pf.enabled&&de&&rt){je=wa.fromConfig(o.attachments),je.setPreviewsContainer(rt),de.addEventListener("change",b=>{let S=b.target;je==null||je.handleFileSelect(S.files),S.value=""});let c=o.attachments.dropOverlay,g=gy(c);K.appendChild(g)}(()=>{var S,W;let c=(W=(S=o.layout)==null?void 0:S.slots)!=null?W:{},g=F=>{switch(F){case"body-top":return K.querySelector(".persona-rounded-2xl.persona-bg-persona-surface.persona-p-6")||null;case"messages":return it;case"footer-top":return Pt;case"composer":return Rt;case"footer-bottom":return dr;default:return null}},b=(F,q)=>{var G;switch(F){case"header-left":case"header-center":case"header-right":if(F==="header-left")qe.insertBefore(q,qe.firstChild);else if(F==="header-right")qe.appendChild(q);else{let N=qe.querySelector(".persona-flex-col");N?(G=N.parentNode)==null||G.insertBefore(q,N.nextSibling):qe.appendChild(q)}break;case"body-top":{let N=he.querySelector(".persona-rounded-2xl.persona-bg-persona-surface.persona-p-6");N?N.replaceWith(q):he.insertBefore(q,he.firstChild);break}case"body-bottom":he.appendChild(q);break;case"footer-top":Pt.replaceWith(q);break;case"footer-bottom":dr.replaceWith(q);break;default:break}};for(let[F,q]of Object.entries(c))if(q)try{let G=q({config:o,defaultContent:()=>g(F)});G&&b(F,G)}catch(G){typeof console!="undefined"&&console.error(`[AgentWidget] Error rendering slot "${F}":`,G)}})();let $r=c=>{var q,G;let b=c.target.closest('button[data-expand-header="true"]');if(!b)return;let S=b.closest(".persona-reasoning-bubble, .persona-tool-bubble, .persona-approval-bubble");if(!S)return;let W=S.getAttribute("data-message-id");if(!W)return;let F=b.getAttribute("data-bubble-type");if(F==="reasoning")ss.has(W)?ss.delete(W):ss.add(W),qx(W,S);else if(F==="tool")is.has(W)?is.delete(W):is.add(W),zx(W,S,o);else if(F==="approval"){let N=o.approval!==!1?o.approval:void 0,Se=((q=N==null?void 0:N.detailsDisplay)!=null?q:"collapsed")==="expanded",xe=(G=Gl.get(W))!=null?G:Se;Gl.set(W,!xe),Gx(W,S,o)}Cr.delete(W)};it.addEventListener("pointerdown",c=>{c.target.closest('button[data-expand-header="true"]')&&(c.preventDefault(),$r(c))}),it.addEventListener("keydown",c=>{let g=c.target;(c.key==="Enter"||c.key===" ")&&g.closest('button[data-expand-header="true"]')&&(c.preventDefault(),$r(c))});let Fo=new Map;it.addEventListener("click",c=>{var q;let b=c.target.closest(".persona-message-action-btn[data-action]");if(!b)return;c.preventDefault(),c.stopPropagation();let S=b.closest("[data-actions-for]");if(!S)return;let W=S.getAttribute("data-actions-for");if(!W)return;let F=b.getAttribute("data-action");if(F==="copy"){let N=U.getMessages().find(Se=>Se.id===W);if(N&&ae.onCopy){let Se=N.content||"";navigator.clipboard.writeText(Se).then(()=>{b.classList.add("persona-message-action-success");let xe=Ee("check",14,"currentColor",2);xe&&(b.innerHTML="",b.appendChild(xe)),setTimeout(()=>{b.classList.remove("persona-message-action-success");let se=Ee("copy",14,"currentColor",2);se&&(b.innerHTML="",b.appendChild(se))},2e3)}).catch(xe=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to copy message:",xe)}),ae.onCopy(N)}}else if(F==="upvote"||F==="downvote"){let N=((q=Fo.get(W))!=null?q:null)===F,Se=F==="upvote"?"thumbs-up":"thumbs-down";if(N){Fo.delete(W),b.classList.remove("persona-message-action-active");let xe=Ee(Se,14,"currentColor",2);xe&&(b.innerHTML="",b.appendChild(xe))}else{let xe=F==="upvote"?"downvote":"upvote",se=S.querySelector(`[data-action="${xe}"]`);if(se){se.classList.remove("persona-message-action-active");let Ze=Ee(xe==="upvote"?"thumbs-up":"thumbs-down",14,"currentColor",2);Ze&&(se.innerHTML="",se.appendChild(Ze))}Fo.set(W,F),b.classList.add("persona-message-action-active");let ke=Ee(Se,14,"currentColor",2);ke&&(ke.setAttribute("fill","currentColor"),b.innerHTML="",b.appendChild(ke)),b.classList.remove("persona-message-action-pop"),b.offsetWidth,b.classList.add("persona-message-action-pop");let Te=U.getMessages().find(ft=>ft.id===W);Te&&ae.onFeedback&&ae.onFeedback({type:F,messageId:Te.id,message:Te})}}}),it.addEventListener("click",c=>{let b=c.target.closest("button[data-approval-action]");if(!b)return;c.preventDefault(),c.stopPropagation();let S=b.closest(".persona-approval-bubble");if(!S)return;let W=S.getAttribute("data-message-id");if(!W)return;let F=b.getAttribute("data-approval-action");if(!F)return;let q=F==="approve"?"approved":"denied",N=U.getMessages().find(xe=>xe.id===W);if(!(N!=null&&N.approval))return;let Se=S.querySelector("[data-approval-buttons]");Se&&Se.querySelectorAll("button").forEach(se=>{se.disabled=!0,se.style.opacity="0.5",se.style.cursor="not-allowed"}),N.approval.toolType==="webmcp"?U.resolveWebMcpApproval(W,q):U.resolveApproval(N.approval,q)});let mt=null,co=null,po={artifacts:[],selectedId:null},Or=!1,Wt={current:null};it.addEventListener("click",c=>{var se,ke,Ge,Te,ft;let b=c.target.closest("[data-download-artifact]");if(!b)return;c.preventDefault(),c.stopPropagation();let S=b.getAttribute("data-download-artifact");if(!S||((Ge=(ke=(se=o.features)==null?void 0:se.artifacts)==null?void 0:ke.onArtifactAction)==null?void 0:Ge.call(ke,{type:"download",artifactId:S}))===!0)return;let F=U.getArtifactById(S),q=F==null?void 0:F.markdown,G=(F==null?void 0:F.title)||"artifact";if(!q){let Ze=b.closest("[data-open-artifact]"),bt=Ze==null?void 0:Ze.closest("[data-message-id]"),vt=bt==null?void 0:bt.getAttribute("data-message-id");if(vt){let Pe=U.getMessages().find(Qe=>Qe.id===vt);if(Pe!=null&&Pe.rawContent)try{let Qe=JSON.parse(Pe.rawContent);q=(Te=Qe==null?void 0:Qe.props)==null?void 0:Te.markdown,G=((ft=Qe==null?void 0:Qe.props)==null?void 0:ft.title)||G}catch{}}}if(!q)return;let N=new Blob([q],{type:"text/markdown"}),Se=URL.createObjectURL(N),xe=document.createElement("a");xe.href=Se,xe.download=`${G}.md`,xe.click(),URL.revokeObjectURL(Se)}),it.addEventListener("click",c=>{var F,q,G;let b=c.target.closest("[data-open-artifact]");if(!b)return;let S=b.getAttribute("data-open-artifact");!S||((G=(q=(F=o.features)==null?void 0:F.artifacts)==null?void 0:q.onArtifactAction)==null?void 0:G.call(q,{type:"open",artifactId:S}))===!0||(c.preventDefault(),c.stopPropagation(),Or=!1,U.selectArtifact(S),eo())}),it.addEventListener("keydown",c=>{if(c.key!=="Enter"&&c.key!==" ")return;let g=c.target;g.hasAttribute("data-open-artifact")&&(c.preventDefault(),g.click())});let Vr=Re.composerOverlay,Zr=(c,g,b)=>{var G,N,Se,xe;let S=g.trim();if(!S||!Wt.current)return;let W=(G=c.getAttribute("data-tool-call-id"))!=null?G:"",F=b.source==="free-text";r.dispatchEvent(new CustomEvent("persona:askUserQuestion:answered",{detail:{toolUseId:W,answer:S,answers:b.structured,values:(N=b.values)!=null?N:b.source==="multi"?S.split(", "):[S],isFreeText:F,source:b.source},bubbles:!0,composed:!0})),zn(Vr,W);let q=Wt.current.getMessages().find(se=>{var ke;return((ke=se.toolCall)==null?void 0:ke.id)===W});(Se=q==null?void 0:q.agentMetadata)!=null&&Se.awaitingLocalTool?Wt.current.resolveAskUserQuestion(q,(xe=b.structured)!=null?xe:S):Wt.current.sendMessage(S)},_r=c=>{var W;let g=Wt.current;if(!g)return;let b=(W=c.getAttribute("data-tool-call-id"))!=null?W:"",S=g.getMessages().find(F=>{var q;return((q=F.toolCall)==null?void 0:q.id)===b});S&&g.persistAskUserQuestionProgress(S,{answers:Ki(c,S),currentIndex:jo(c)})},uo=c=>Object.entries(c).map(([g,b])=>`${g}: ${Array.isArray(b)?b.join(", "):b}`).join(" | "),fo=c=>{var W,F,q;if(((F=(W=o.features)==null?void 0:W.askUserQuestion)==null?void 0:F.groupedAutoAdvance)===!1)return;let g=jo(c),b=Xa(c);if(g>=b-1)return;let S=(q=Wt.current)==null?void 0:q.getMessages().find(G=>{var N;return((N=G.toolCall)==null?void 0:N.id)===c.getAttribute("data-tool-call-id")});S&&(Xi(c,S,o,g+1),_r(c))};Vr.addEventListener("click",c=>{var F,q,G,N,Se,xe,se,ke,Ge,Te,ft,Ze,bt,vt;let b=c.target.closest("[data-ask-user-action]");if(!b)return;let S=b.closest("[data-persona-ask-sheet-for]");if(!S)return;let W=b.getAttribute("data-ask-user-action");if(c.preventDefault(),c.stopPropagation(),W==="dismiss"){let He=(F=S.getAttribute("data-tool-call-id"))!=null?F:"";r.dispatchEvent(new CustomEvent("persona:askUserQuestion:dismissed",{detail:{toolUseId:He},bubbles:!0,composed:!0})),zn(Vr,He);let Pe=(q=Wt.current)==null?void 0:q.getMessages().find(Qe=>{var ot;return((ot=Qe.toolCall)==null?void 0:ot.id)===He});(G=Pe==null?void 0:Pe.agentMetadata)!=null&&G.awaitingLocalTool&&((N=Wt.current)==null||N.markAskUserQuestionResolved(Pe),(Se=Wt.current)==null||Se.resolveAskUserQuestion(Pe,"(dismissed)"));return}if(W==="pick"){let He=b.getAttribute("data-option-label");if(!He)return;let Pe=S.getAttribute("data-multi-select")==="true",Qe=qn(S);if(Qe&&Pe){let ot=ha(S)[jo(S)],Ht=new Set(Array.isArray(ot)?ot:[]);Ht.has(He)?Ht.delete(He):Ht.add(He),$n(S,Array.from(Ht)),_r(S);return}if(Qe){$n(S,He),_r(S),fo(S);return}if(Pe){let ot=b.getAttribute("aria-pressed")==="true";b.setAttribute("aria-pressed",ot?"false":"true"),b.classList.toggle("persona-ask-pill-selected",!ot);let Ht=S.querySelector('[data-ask-user-action="submit-multi"]');Ht&&(Ht.disabled=Nd(S).length===0);return}Zr(S,He,{source:"pick",values:[He]});return}if(W==="submit-multi"){let He=Nd(S);if(He.length===0)return;Zr(S,He.join(", "),{source:"multi",values:He});return}if(W==="open-free-text"){let He=S.querySelector('[data-ask-free-text-row="true"]');if(He){He.classList.remove("persona-hidden");let Pe=He.querySelector('[data-ask-free-text-input="true"]');Pe==null||Pe.focus()}return}if(W==="focus-free-text"){let He=S.querySelector('[data-ask-free-text-input="true"]');He==null||He.focus();return}if(W==="submit-free-text"){let He=S.querySelector('[data-ask-free-text-input="true"]'),Pe=(xe=He==null?void 0:He.value)!=null?xe:"";if(!Pe.trim())return;if(qn(S)){$n(S,Pe.trim()),_r(S),fo(S);return}Zr(S,Pe,{source:"free-text"});return}if(W==="next"||W==="back"){if(!Wt.current)return;let He=(se=S.getAttribute("data-tool-call-id"))!=null?se:"",Pe=Wt.current.getMessages().find(Ne=>{var Fe;return((Fe=Ne.toolCall)==null?void 0:Fe.id)===He});if(!Pe)return;let Qe=S.querySelector('[data-ask-free-text-input="true"]'),ot=(Ge=(ke=Qe==null?void 0:Qe.value)==null?void 0:ke.trim())!=null?Ge:"";if(ot){let Ne=ha(S)[jo(S)];(typeof Ne!="string"||Ne!==ot)&&$n(S,ot)}let Ht=W==="next"?1:-1,D=jo(S)+Ht;Xi(S,Pe,o,D),_r(S);return}if(W==="submit-all"){if(!Wt.current)return;let He=(Te=S.getAttribute("data-tool-call-id"))!=null?Te:"",Pe=Wt.current.getMessages().find(Ne=>{var Fe;return((Fe=Ne.toolCall)==null?void 0:Fe.id)===He});if(!Pe)return;let Qe=S.querySelector('[data-ask-free-text-input="true"]'),ot=(Ze=(ft=Qe==null?void 0:Qe.value)==null?void 0:ft.trim())!=null?Ze:"";ot&&$n(S,ot);let Ht=Ki(S,Pe);Wt.current.persistAskUserQuestionProgress(Pe,{answers:Ht,currentIndex:jo(S)});let D=uo(Ht);Zr(S,D||"(submitted)",{source:"submit-all",structured:Ht});return}if(W==="skip"){if(!Wt.current)return;let He=(bt=S.getAttribute("data-tool-call-id"))!=null?bt:"",Pe=Wt.current.getMessages().find(Fe=>{var we;return((we=Fe.toolCall)==null?void 0:we.id)===He});if(!Pe)return;let Qe=qn(S),ot=jo(S),Ht=Xa(S),D=ot>=Ht-1;if(!Qe){r.dispatchEvent(new CustomEvent("persona:askUserQuestion:dismissed",{detail:{toolUseId:He},bubbles:!0,composed:!0})),zn(Vr,He),(vt=Pe.agentMetadata)!=null&&vt.awaitingLocalTool&&(Wt.current.markAskUserQuestionResolved(Pe),Wt.current.resolveAskUserQuestion(Pe,"(dismissed)"));return}$n(S,"");let Ne=S.querySelector('[data-ask-free-text-input="true"]');if(Ne&&(Ne.value=""),D){let Fe=Ki(S,Pe),we=uo(Fe);Zr(S,we||"(skipped)",{source:"submit-all",structured:Fe});return}Xi(S,Pe,o,ot+1),_r(S);return}}),Vr.addEventListener("keydown",c=>{var F;if(c.key!=="Enter")return;let b=c.target;if(!((F=b.matches)!=null&&F.call(b,'[data-ask-free-text-input="true"]')))return;let S=b.closest("[data-persona-ask-sheet-for]");if(!S)return;c.preventDefault();let W=b.value;if(W.trim()){if(qn(S)){$n(S,W.trim()),_r(S),fo(S);return}Zr(S,W,{source:"free-text"})}});let Nr=c=>{if(!/^[1-9]$/.test(c.key)||c.metaKey||c.ctrlKey||c.altKey)return;let g=c.target;if((g==null?void 0:g.tagName)==="INPUT"||(g==null?void 0:g.tagName)==="TEXTAREA"||g!=null&&g.isContentEditable)return;let b=Vr.querySelector("[data-persona-ask-sheet-for]");if(!b||b.getAttribute("data-ask-layout")!=="rows"||b.getAttribute("data-multi-select")==="true")return;let S=Number(c.key),F=b.querySelectorAll('[data-ask-pill-list="true"] [data-ask-user-action="pick"], [data-ask-pill-list="true"] [data-ask-user-action="focus-free-text"]')[S-1];F&&(c.preventDefault(),F.click())};document.addEventListener("keydown",Nr);let mo=null,$t=null,Fr=null,go=null,on=()=>{};function Uo(){go==null||go(),go=null}let nn=()=>{var q;if(!mo||!$t)return;let c=r.classList.contains("persona-artifact-appearance-seamless"),b=((q=r.ownerDocument.defaultView)!=null?q:window).innerWidth<=640;if(!c||r.classList.contains("persona-artifact-narrow-host")||b){$t.style.removeProperty("position"),$t.style.removeProperty("left"),$t.style.removeProperty("top"),$t.style.removeProperty("bottom"),$t.style.removeProperty("width"),$t.style.removeProperty("z-index");return}let S=mo.firstElementChild;if(!S||S===$t)return;let W=10;$t.style.position="absolute",$t.style.top="0",$t.style.bottom="0",$t.style.width=`${W}px`,$t.style.zIndex="5";let F=S.offsetWidth-W/2;$t.style.left=`${Math.max(0,F)}px`},qo=()=>{},eo=()=>{var b,S,W,F,q;if(!mt||!Go(o))return;Ql(r,o),Yl(r,o),qo();let c=(F=(W=(S=(b=o.features)==null?void 0:b.artifacts)==null?void 0:S.layout)==null?void 0:W.narrowHostMaxWidth)!=null?F:520,g=le.getBoundingClientRect().width||0;r.classList.toggle("persona-artifact-narrow-host",g>0&&g<=c),mt.update(po),Or?(mt.setMobileOpen(!1),mt.element.classList.add("persona-hidden"),(q=mt.backdrop)==null||q.classList.add("persona-hidden")):po.artifacts.length>0&&(mt.element.classList.remove("persona-hidden"),mt.setMobileOpen(!0)),on()};if(Go(o)){le.style.position="relative";let c=C("div","persona-flex persona-flex-1 persona-flex-col persona-min-w-0 persona-min-h-0"),g=C("div","persona-flex persona-h-full persona-w-full persona-min-h-0 persona-artifact-split-root");c.appendChild(K),mt=ty(o,{onSelect:b=>{var S;return(S=Wt.current)==null?void 0:S.selectArtifact(b)},onDismiss:()=>{Or=!0,eo()}}),mt.element.classList.add("persona-hidden"),mo=g,g.appendChild(c),g.appendChild(mt.element),mt.backdrop&&le.appendChild(mt.backdrop),le.appendChild(g),on=()=>{var S,W,F,q;if(!mo||!mt)return;if(!(((F=(W=(S=o.features)==null?void 0:S.artifacts)==null?void 0:W.layout)==null?void 0:F.resizable)===!0)){Fr==null||Fr(),Fr=null,Uo(),$t&&($t.remove(),$t=null),mt.element.style.removeProperty("width"),mt.element.style.removeProperty("maxWidth");return}if(!$t){let G=C("div","persona-artifact-split-handle persona-shrink-0 persona-h-full");G.setAttribute("role","separator"),G.setAttribute("aria-orientation","vertical"),G.setAttribute("aria-label","Resize artifacts panel"),G.tabIndex=0;let N=r.ownerDocument,Se=(q=N.defaultView)!=null?q:window,xe=se=>{var bt,vt;if(!mt||se.button!==0||r.classList.contains("persona-artifact-narrow-host")||Se.innerWidth<=640)return;se.preventDefault(),Uo();let ke=se.clientX,Ge=mt.element.getBoundingClientRect().width,Te=(vt=(bt=o.features)==null?void 0:bt.artifacts)==null?void 0:vt.layout,ft=He=>{let Pe=mo.getBoundingClientRect().width,Qe=r.classList.contains("persona-artifact-appearance-seamless"),ot=Qe?0:ay(mo,Se),Ht=Qe?0:G.getBoundingClientRect().width||6,D=Ge-(He.clientX-ke),Ne=sy(D,Pe,ot,Ht,Te==null?void 0:Te.resizableMinWidth,Te==null?void 0:Te.resizableMaxWidth);mt.element.style.width=`${Ne}px`,mt.element.style.maxWidth="none",nn()},Ze=()=>{N.removeEventListener("pointermove",ft),N.removeEventListener("pointerup",Ze),N.removeEventListener("pointercancel",Ze),go=null;try{G.releasePointerCapture(se.pointerId)}catch{}};go=Ze,N.addEventListener("pointermove",ft),N.addEventListener("pointerup",Ze),N.addEventListener("pointercancel",Ze);try{G.setPointerCapture(se.pointerId)}catch{}};G.addEventListener("pointerdown",xe),$t=G,mo.insertBefore(G,mt.element),Fr=()=>{G.removeEventListener("pointerdown",xe)}}if($t){let G=po.artifacts.length>0&&!Or;$t.classList.toggle("persona-hidden",!G),nn()}},qo=()=>{var Se,xe,se,ke,Ge,Te,ft,Ze,bt,vt,He,Pe,Qe,ot;if(!M||!mt||((xe=(Se=o.launcher)==null?void 0:Se.sidebarMode)!=null?xe:!1)||Lr(o)&&Bo(o).reveal==="emerge")return;let S=(se=r.ownerDocument.defaultView)!=null?se:window,W=(Ge=(ke=o.launcher)==null?void 0:ke.mobileFullscreen)!=null?Ge:!0,F=(ft=(Te=o.launcher)==null?void 0:Te.mobileBreakpoint)!=null?ft:640;if(W&&S.innerWidth<=F||!ny(o,M))return;let q=(vt=(bt=(Ze=o.launcher)==null?void 0:Ze.width)!=null?bt:o.launcherWidth)!=null?vt:Wo,G=(ot=(Qe=(Pe=(He=o.features)==null?void 0:He.artifacts)==null?void 0:Pe.layout)==null?void 0:Qe.expandedPanelWidth)!=null?ot:"min(720px, calc(100vw - 24px))";po.artifacts.length>0&&!Or?(le.style.width=G,le.style.maxWidth=G):(le.style.width=q,le.style.maxWidth=q)},typeof ResizeObserver!="undefined"&&(co=new ResizeObserver(()=>{eo()}),co.observe(le))}else le.appendChild(K),H()&&nt&&(Re.peekBanner&&nt.appendChild(Re.peekBanner),nt.appendChild(ze));r.appendChild(De),nt&&r.appendChild(nt);let to=()=>{var Ne,Fe,we,Qt,Kt,ir,Bt,ar,Po,wr,st,Ut,kr,Vo,Ro,ta,ra,Fa,Ua,ur,oa,On,_n,yn,na,Yo,pt,Ir;if(H()){le.style.width="100%",le.style.maxWidth="100%";let Zt=(Fe=(Ne=o.launcher)==null?void 0:Ne.composerBar)!=null?Fe:{},Yt=De.dataset.state==="expanded",Et=(we=Zt.expandedSize)!=null?we:"anchored";if(!(Yt&&Et!=="fullscreen")){K.style.background="",K.style.border="",K.style.borderRadius="",K.style.overflow="",K.style.boxShadow="";return}let _t=(Kt=(Qt=o.theme)==null?void 0:Qt.components)==null?void 0:Kt.panel,oo=rs(o),ho=(yo,aa)=>{var Es;return yo==null||yo===""?aa:(Es=es(oo,yo))!=null?Es:yo},dn="1px solid var(--persona-border)",qr="var(--persona-palette-shadows-xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25))",xo="var(--persona-panel-radius, var(--persona-radius-xl, 0.75rem))";K.style.background="var(--persona-surface, #ffffff)",K.style.border=ho(_t==null?void 0:_t.border,dn),K.style.borderRadius=ho(_t==null?void 0:_t.borderRadius,xo),K.style.boxShadow=ho(_t==null?void 0:_t.shadow,qr),K.style.overflow="hidden";return}let c=Lr(o),g=(Bt=(ir=o.launcher)==null?void 0:ir.sidebarMode)!=null?Bt:!1,b=c||g||((Po=(ar=o.launcher)==null?void 0:ar.fullHeight)!=null?Po:!1),S=((wr=o.launcher)==null?void 0:wr.enabled)===!1,W=(Ut=(st=o.theme)==null?void 0:st.components)==null?void 0:Ut.panel,F=rs(o),q=(Zt,Yt)=>{var Et;return Zt==null||Zt===""?Yt:(Et=es(F,Zt))!=null?Et:Zt},G=(kr=r.ownerDocument.defaultView)!=null?kr:window,N=(Ro=(Vo=o.launcher)==null?void 0:Vo.mobileFullscreen)!=null?Ro:!0,Se=(ra=(ta=o.launcher)==null?void 0:ta.mobileBreakpoint)!=null?ra:640,xe=G.innerWidth<=Se,se=N&&xe&&M,ke=(Ua=(Fa=o.launcher)==null?void 0:Fa.position)!=null?Ua:"bottom-left",Ge=ke==="bottom-left"||ke==="top-left",Te=(oa=(ur=o.launcher)==null?void 0:ur.zIndex)!=null?oa:so,ft=g||se?"none":"1px solid var(--persona-border)",Ze=se?"none":g?Ge?"var(--persona-palette-shadows-sidebar-left, 2px 0 12px rgba(0, 0, 0, 0.08))":"var(--persona-palette-shadows-sidebar-right, -2px 0 12px rgba(0, 0, 0, 0.08))":"var(--persona-palette-shadows-xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25))";c&&!se&&(Ze="none",ft="none");let bt=g||se?"0":"var(--persona-panel-radius, var(--persona-radius-xl, 0.75rem))",vt=q(W==null?void 0:W.border,ft),He=q(W==null?void 0:W.shadow,Ze),Pe=q(W==null?void 0:W.borderRadius,bt),Qe=he.scrollTop;r.style.cssText="",De.style.cssText="",le.style.cssText="",K.style.cssText="",he.style.cssText="",ze.style.cssText="";let ot=()=>{var Yt;if(Qe<=0)return;((Yt=he.ownerDocument.defaultView)!=null?Yt:window).requestAnimationFrame(()=>{if(he.scrollTop===Qe)return;let Et=he.scrollHeight-he.clientHeight;Et<=0||(he.scrollTop=Math.min(Qe,Et))})};if(se){De.classList.remove("persona-bottom-6","persona-right-6","persona-left-6","persona-top-6","persona-bottom-4","persona-right-4","persona-left-4","persona-top-4"),De.style.cssText=`
|
|
78
79
|
position: fixed !important;
|
|
79
80
|
inset: 0 !important;
|
|
80
81
|
width: 100% !important;
|
|
@@ -84,9 +85,9 @@ _Details: ${t.message}_`:n}var Gs=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
84
85
|
padding: 0 !important;
|
|
85
86
|
display: flex !important;
|
|
86
87
|
flex-direction: column !important;
|
|
87
|
-
z-index: ${
|
|
88
|
+
z-index: ${Te} !important;
|
|
88
89
|
background-color: var(--persona-surface, #ffffff) !important;
|
|
89
|
-
`,
|
|
90
|
+
`,le.style.cssText=`
|
|
90
91
|
position: relative !important;
|
|
91
92
|
display: flex !important;
|
|
92
93
|
flex-direction: column !important;
|
|
@@ -99,7 +100,7 @@ _Details: ${t.message}_`:n}var Gs=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
99
100
|
padding: 0 !important;
|
|
100
101
|
box-shadow: none !important;
|
|
101
102
|
border-radius: 0 !important;
|
|
102
|
-
`,
|
|
103
|
+
`,K.style.cssText=`
|
|
103
104
|
display: flex !important;
|
|
104
105
|
flex-direction: column !important;
|
|
105
106
|
flex: 1 1 0% !important;
|
|
@@ -110,20 +111,20 @@ _Details: ${t.message}_`:n}var Gs=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
110
111
|
overflow: hidden !important;
|
|
111
112
|
border-radius: 0 !important;
|
|
112
113
|
border: none !important;
|
|
113
|
-
`,
|
|
114
|
+
`,he.style.flex="1 1 0%",he.style.minHeight="0",he.style.overflowY="auto",ze.style.flexShrink="0",E=!0,ot();return}let Ht=(_n=(On=o==null?void 0:o.launcher)==null?void 0:On.width)!=null?_n:o==null?void 0:o.launcherWidth,D=Ht!=null?Ht:Wo;if(!g&&!c)S&&b?(le.style.width="100%",le.style.maxWidth="100%"):(le.style.width=D,le.style.maxWidth=D);else if(c)if(Bo(o).reveal==="emerge"){let Yt=Bo(o).width;le.style.width=Yt,le.style.maxWidth=Yt}else le.style.width="100%",le.style.maxWidth="100%";if(qo(),le.style.boxShadow=He,le.style.borderRadius=Pe,K.style.border=vt,K.style.borderRadius=Pe,c&&!se&&(W==null?void 0:W.border)===void 0&&(K.style.border="none",Bo(o).side==="right"?K.style.borderLeft="1px solid var(--persona-border)":K.style.borderRight="1px solid var(--persona-border)"),b&&(r.style.display="flex",r.style.flexDirection="column",r.style.height="100%",r.style.minHeight="0",S&&(r.style.width="100%"),De.style.display="flex",De.style.flexDirection="column",De.style.flex="1 1 0%",De.style.minHeight="0",De.style.maxHeight="100%",De.style.height="100%",S&&(De.style.overflow="hidden"),le.style.display="flex",le.style.flexDirection="column",le.style.flex="1 1 0%",le.style.minHeight="0",le.style.maxHeight="100%",le.style.height="100%",le.style.overflow="hidden",K.style.display="flex",K.style.flexDirection="column",K.style.flex="1 1 0%",K.style.minHeight="0",K.style.maxHeight="100%",K.style.overflow="hidden",he.style.flex="1 1 0%",he.style.minHeight="0",he.style.overflowY="auto",ze.style.flexShrink="0"),De.classList.remove("persona-bottom-6","persona-right-6","persona-left-6","persona-top-6","persona-bottom-4","persona-right-4","persona-left-4","persona-top-4"),!g&&!S&&!c&&((yn=tn[ke])!=null?yn:tn["bottom-right"]).split(" ").forEach(Yt=>De.classList.add(Yt)),g){let Zt=(Yo=(na=o.launcher)==null?void 0:na.sidebarWidth)!=null?Yo:"420px";De.style.cssText=`
|
|
114
115
|
position: fixed !important;
|
|
115
116
|
top: 0 !important;
|
|
116
117
|
bottom: 0 !important;
|
|
117
|
-
width: ${
|
|
118
|
+
width: ${Zt} !important;
|
|
118
119
|
height: 100vh !important;
|
|
119
120
|
max-height: 100vh !important;
|
|
120
121
|
margin: 0 !important;
|
|
121
122
|
padding: 0 !important;
|
|
122
123
|
display: flex !important;
|
|
123
124
|
flex-direction: column !important;
|
|
124
|
-
z-index: ${
|
|
125
|
-
${
|
|
126
|
-
`,
|
|
125
|
+
z-index: ${Te} !important;
|
|
126
|
+
${Ge?"left: 0 !important; right: auto !important;":"left: auto !important; right: 0 !important;"}
|
|
127
|
+
`,le.style.cssText=`
|
|
127
128
|
position: relative !important;
|
|
128
129
|
display: flex !important;
|
|
129
130
|
flex-direction: column !important;
|
|
@@ -134,9 +135,9 @@ _Details: ${t.message}_`:n}var Gs=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
134
135
|
min-height: 0 !important;
|
|
135
136
|
margin: 0 !important;
|
|
136
137
|
padding: 0 !important;
|
|
137
|
-
box-shadow: ${
|
|
138
|
+
box-shadow: ${He} !important;
|
|
138
139
|
border-radius: ${Pe} !important;
|
|
139
|
-
`,
|
|
140
|
+
`,le.style.setProperty("width","100%","important"),le.style.setProperty("max-width","100%","important"),K.style.cssText=`
|
|
140
141
|
display: flex !important;
|
|
141
142
|
flex-direction: column !important;
|
|
142
143
|
flex: 1 1 0% !important;
|
|
@@ -146,28 +147,28 @@ _Details: ${t.message}_`:n}var Gs=r=>({isError:!0,content:[{type:"text",text:r}]
|
|
|
146
147
|
max-height: 100% !important;
|
|
147
148
|
overflow: hidden !important;
|
|
148
149
|
border-radius: ${Pe} !important;
|
|
149
|
-
border: ${
|
|
150
|
-
`,
|
|
150
|
+
border: ${vt} !important;
|
|
151
|
+
`,ze.style.cssText=`
|
|
151
152
|
flex-shrink: 0 !important;
|
|
152
153
|
border-top: none !important;
|
|
153
154
|
padding: 8px 16px 12px 16px !important;
|
|
154
|
-
`}if(!A&&!c){let er="max-height: -moz-available !important; max-height: stretch !important;",Jt=g?"":"padding-top: 1.25em !important;",kt=g?"":`z-index: ${(Hr=(dt=n.launcher)==null?void 0:dt.zIndex)!=null?Hr:Xr} !important;`;We.style.cssText+=er+Jt+kt}rt()};Fn(),_o(r,n),Gl(r,n),Kl(r,n);let Tt=[];Tt.push(()=>{document.removeEventListener("keydown",Ao)});let Cr=null,wr=null;Tt.push(()=>{Cr==null||Cr(),Cr=null,wr==null||wr(),wr=null}),Nt&&Tt.push(()=>{Nt==null||Nt.disconnect(),Nt=null}),Tt.push(()=>{Qr==null||Qr(),Qr=null,ao(),Vt&&(Vt.remove(),Vt=null),et==null||et.element.style.removeProperty("width"),et==null||et.element.style.removeProperty("maxWidth")}),De&&Tt.push(()=>{ke!==null&&(cancelAnimationFrame(ke),ke=null),G==null||G.destroy(),G=null,ge==null||ge.destroy(),ge=null,re=null});let gn=null,Mo=()=>{gn&&(gn(),gn=null),n.colorScheme==="auto"&&(gn=Tl(()=>{_o(r,n)}))};Mo(),Tt.push(()=>{gn&&(gn(),gn=null)});let ve=(Lf=n.features)==null?void 0:Lf.streamAnimation;if(ve!=null&&ve.type&&ve.type!=="none"){let c=Ys(ve.type,ve.plugins);c&&(Xp(c,r),Tt.push(()=>Mx(r)))}let On=Ux(Rt),Ln=null,q,Sa=c=>{var A,W;if(!q)return;let g=c!=null?c:q.getMessages(),y=((W=(A=n.features)==null?void 0:A.suggestReplies)==null?void 0:W.enabled)!==!1?Ki(g):null;y?On.render(y,q,ee,g,n.suggestionChipsConfig,{agentPushed:!0}):g.some(_=>_.role==="user")?On.render([],q,ee,g):On.render(n.suggestionChips,q,ee,g,n.suggestionChipsConfig)},Xn=!1,so=xx(),io=new Map,Qn=new Map,Nn=new Map,as=0,hn=El(),xn=0,_n=null,Un=!1,Vo=!1,lo=0,Vr=null,Jn=null,Ta=!1,jo=!1,Ma=null,fi=4,ka=24,mi=80,Ea=new Map,Pt={active:!1,manuallyDeactivated:!1,lastUserMessageWasVoice:!1,lastUserMessageId:null},ss=(Rf=(Pf=n.voiceRecognition)==null?void 0:Pf.autoResume)!=null?Rf:!1,Pn=c=>{a.emit("voice:state",{active:Pt.active,source:c,timestamp:Date.now()})},dn=()=>{f(c=>({...c,voiceState:{active:Pt.active,timestamp:Date.now(),manuallyDeactivated:Pt.manuallyDeactivated}}))},gi=()=>{var A,W;if(((A=n.voiceRecognition)==null?void 0:A.enabled)===!1)return;let c=fu(d.voiceState),g=!!c.active,y=Number((W=c.timestamp)!=null?W:0);Pt.manuallyDeactivated=!!c.manuallyDeactivated,g&&Date.now()-y<RC&&setTimeout(()=>{var _,U;Pt.active||(Pt.manuallyDeactivated=!1,((U=(_=n.voiceRecognition)==null?void 0:_.provider)==null?void 0:U.type)==="runtype"?q.toggleVoice().then(()=>{Pt.active=q.isVoiceActive(),Pn("restore"),q.isVoiceActive()&&bs()}):fr("restore"))},1e3)},hi=()=>q?sb(q.getMessages()).filter(c=>!c.__skipPersist):[];function La(c){if(!(i!=null&&i.save))return;let y={messages:c?sb(c):q?hi():[],metadata:d,artifacts:Yt.artifacts,selectedArtifactId:Yt.selectedId};try{let A=i.save(y);A instanceof Promise&&A.catch(W=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",W)})}catch(A){typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",A)}}let co=null,is=()=>We.querySelector("#persona-scroll-container")||ue,ko=()=>{co!==null&&(cancelAnimationFrame(co),co=null),Un=!1},ls=()=>{_n!==null&&(cancelAnimationFrame(_n),_n=null),Vo=!1,ko()},ds=()=>{lo>0?(sr.textContent=String(lo),sr.style.display="",tt.setAttribute("aria-label",`${pt()||"Jump to latest"} (${lo} new)`)):(sr.textContent="",sr.style.display="none",tt.setAttribute("aria-label",pt()||"Jump to latest"))},cs=()=>{lo!==0&&(lo=0,ds())},ps=()=>ut()==="follow"?!hn.isFollowing():!xa(ue,ka),cn=()=>{if(!Rr()||pe){tt.parentNode&&tt.remove(),tt.style.display="none";return}tt.parentNode!==j&&j.appendChild(tt),Mr();let g=vo(ue)>0&&ps();g||cs(),tt.style.display=g?"":"none"},Pa=()=>{hn.pause()&&(ls(),cn())},Yn=()=>{hn.resume(),cs(),cn()},Zn=(c=!1)=>{ut()==="follow"&&hn.isFollowing()&&(!c&&!Xn||(_n!==null&&(cancelAnimationFrame(_n),_n=null),Vo=!0,_n=requestAnimationFrame(()=>{_n=null,Vo=!1,hn.isFollowing()&&xi(is(),c?220:140)})))},us=(c,g,y,A=()=>!0)=>{let W=c.scrollTop,_=g(),U=_-W;ko();let V=performance.now();Un=!0;let N=me=>1-Math.pow(1-me,3),Ce=me=>{if(!A()){ko();return}let ae=g();ae!==_&&(_=ae,U=_-W);let Te=me-V,Ve=Math.min(Te/y,1),Se=N(Ve),ct=W+U*Se;c.scrollTop=ct,xn=c.scrollTop,Ve<1?co=requestAnimationFrame(Ce):(c.scrollTop=_,xn=c.scrollTop,co=null,Un=!1)};co=requestAnimationFrame(Ce)},xi=(c,g=500)=>{let y=vo(c)-c.scrollTop;if(Math.abs(y)<1){xn=c.scrollTop;return}if(Math.abs(y)>=mi){ko(),Un=!0,c.scrollTop=vo(c),xn=c.scrollTop,Un=!1;return}us(c,()=>vo(c),g,()=>hn.isFollowing())},fs=()=>{let c=is();Un=!0,c.scrollTop=vo(c),xn=c.scrollTop,Un=!1,cn()},ms=c=>{ur.style.height=`${Math.max(0,Math.round(c))}px`,Vr&&(Vr.spacerHeight=Math.max(0,c))},Go=()=>{Jn!==null&&(cancelAnimationFrame(Jn),Jn=null),ko(),Vr=null,ur.style.height="0px"},bi=c=>{Jn!==null&&cancelAnimationFrame(Jn),Jn=requestAnimationFrame(()=>{var Ce;Jn=null;let g=typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(c):c.replace(/"/g,'\\"'),y=ue.querySelector(`[data-message-id="${g}"]`);if(!y)return;let A=0,W=y;for(;W&&W!==ue;)A+=W.offsetTop,W=W.offsetParent;let _=(Ce=Vr==null?void 0:Vr.spacerHeight)!=null?Ce:0,U=ue.scrollHeight-_,{targetScrollTop:V,spacerHeight:N}=wx({anchorOffsetTop:A,topOffset:Lt(),viewportHeight:ue.clientHeight,contentHeight:U});Vr={initialSpacerHeight:N,contentHeightAtAnchor:U,spacerHeight:N},ms(N),us(ue,()=>V,220)})},yi=()=>{if(ut()==="follow"){if(!hn.isFollowing()||xa(ue,1))return;Zn(!Xn);return}if(Vr&&Vr.initialSpacerHeight>0){let c=ue.scrollHeight-Vr.spacerHeight,g=Ax({initialSpacerHeight:Vr.initialSpacerHeight,contentHeightAtAnchor:Vr.contentHeightAtAnchor,currentContentHeight:c});g!==Vr.spacerHeight&&ms(g)}cn()},vi=c=>{let g=ut();g==="follow"?(Yn(),Zn(!0)):g==="anchor-top"&&bi(c)},Ci=c=>{let g=new Map;c.forEach(y=>{let A=Ea.get(y.id);g.set(y.id,{streaming:y.streaming,role:y.role}),!A&&y.role==="assistant"&&(a.emit("assistant:message",y),!jo&&ut()!=="anchor-top"&&ps()&&(lo+=1,ds(),cn())),y.role==="assistant"&&(A!=null&&A.streaming)&&y.streaming===!1&&a.emit("assistant:complete",y),y.variant==="approval"&&y.approval&&(A?y.approval.status!=="pending"&&a.emit("approval:resolved",{approval:y.approval,decision:y.approval.status}):a.emit("approval:requested",{approval:y.approval,message:y}))}),Ea.clear(),g.forEach((y,A)=>{Ea.set(A,y)})},Ko=(c,g,y)=>{var xt,Be,Pe,Ke,rt,It;let A=document.createElement("div"),_=(()=>{var Oe;let D=o.find(Ue=>Ue.renderLoadingIndicator);if(D!=null&&D.renderLoadingIndicator)return D.renderLoadingIndicator;if((Oe=n.loadingIndicator)!=null&&Oe.render)return n.loadingIndicator.render})(),U=(D,Oe)=>Oe==null?!1:typeof Oe=="string"?(D.textContent=Oe,!0):(D.appendChild(Oe),!0),V=new Set,N=new Set,Ce=o.some(D=>D.renderAskUserQuestion),me=[],ae=[],Te=n.enableComponentStreaming!==!1,Ve=o.some(D=>D.renderApproval)&&n.approval!==!1,Se=[];if(g.forEach(D=>{var ot,_t,Lr,In,yn,Qo,Jo,Ba,Da,mr,Yo,Wo,Bo,uo,Zo,qn;V.add(D.id);let Oe=Ce&&ho(D),Ue=Ve&&D.variant==="approval"&&!!D.approval,be=!Oe&&D.role==="assistant"&&!D.variant&&Te&&Yl(D);if(!Ue&&Nn.has(D.id)){let dt=c.querySelector(`#wrapper-${D.id}`);dt==null||dt.removeAttribute("data-preserve-runtime"),Nn.delete(D.id)}if(!be&&Qn.has(D.id)){let dt=c.querySelector(`#wrapper-${D.id}`);dt==null||dt.removeAttribute("data-preserve-runtime"),Qn.delete(D.id)}let Qt=ho(D)?`:${(ot=D.agentMetadata)!=null&&ot.askUserQuestionAnswered?"a":"u"}:${(_t=D.agentMetadata)!=null&&_t.askUserQuestionAnswers?Object.keys(D.agentMetadata.askUserQuestionAnswers).length:0}`:"",Gt=hx(D,as)+Qt,dr=Oe||Ue||be?null:bx(so,D.id,Gt);if(dr){A.appendChild(dr.cloneNode(!0)),ho(D)&&((Lr=D.toolCall)!=null&&Lr.id)&&((In=D.agentMetadata)==null?void 0:In.awaitingLocalTool)===!0&&!((yn=D.agentMetadata)!=null&&yn.askUserQuestionAnswered)&&(N.add(D.toolCall.id),za(D,n,Re.composerOverlay));return}let Wt=null,ir=o.find(dt=>!!(D.variant==="reasoning"&&dt.renderReasoning||D.variant==="tool"&&dt.renderToolCall||!D.variant&&dt.renderMessage)),bn=(Qo=n.layout)==null?void 0:Qo.messages;if(ho(D)&&((Jo=D.agentMetadata)==null?void 0:Jo.askUserQuestionAnswered)===!0){io.delete(D.id);let dt=c.querySelector(`#wrapper-${D.id}`);dt==null||dt.removeAttribute("data-preserve-runtime");return}if(_s(D)&&((Da=(Ba=n.features)==null?void 0:Ba.suggestReplies)==null?void 0:Da.enabled)!==!1)return;if(ho(D)&&((Yo=(mr=n.features)==null?void 0:mr.askUserQuestion)==null?void 0:Yo.enabled)!==!1){let dt=o.find(Hr=>typeof Hr.renderAskUserQuestion=="function");if(dt&&vt.current){let Hr=io.get(D.id),er=Hr!==Gt,Jt=null;if(er){let{payload:Ft,complete:jr}=xo(D),Jr=D.id,eo=()=>{var Nr;return(Nr=vt.current)==null?void 0:Nr.getMessages().find(Yr=>Yr.id===Jr)};Jt=dt.renderAskUserQuestion({message:D,payload:Ft,complete:jr,resolve:Nr=>{var Zr;let Yr=eo();Yr&&((Zr=vt.current)==null||Zr.resolveAskUserQuestion(Yr,Nr))},dismiss:()=>{var Yr,Zr,ea;let Nr=eo();(Yr=Nr==null?void 0:Nr.agentMetadata)!=null&&Yr.awaitingLocalTool&&((Zr=vt.current)==null||Zr.markAskUserQuestionResolved(Nr),(ea=vt.current)==null||ea.resolveAskUserQuestion(Nr,"(dismissed)"))},config:n})}let kt=Hr!=null;if(er&&Jt===null&&!kt){((Wo=D.agentMetadata)==null?void 0:Wo.awaitingLocalTool)===!0&&!((Bo=D.agentMetadata)!=null&&Bo.askUserQuestionAnswered)&&(N.add(D.toolCall.id),za(D,n,Re.composerOverlay));return}let gr=document.createElement("div");gr.className="persona-flex",gr.id=`wrapper-${D.id}`,gr.setAttribute("data-wrapper-id",D.id),gr.setAttribute("data-ask-plugin-stub","true"),gr.setAttribute("data-preserve-runtime","true"),A.appendChild(gr),me.push({messageId:D.id,fingerprint:Gt,bubble:Jt});return}else{((uo=D.agentMetadata)==null?void 0:uo.awaitingLocalTool)===!0&&!((Zo=D.agentMetadata)!=null&&Zo.askUserQuestionAnswered)&&(N.add(D.toolCall.id),za(D,n,Re.composerOverlay));return}}else if(Ue){let dt=o.find(kt=>typeof kt.renderApproval=="function"),er=Nn.get(D.id)!==Gt,Jt=null;if(er&&(dt!=null&&dt.renderApproval)){let kt=D.id,gr=(Ft,jr)=>{var eo,Nr,Yr;let Jr=(eo=vt.current)==null?void 0:eo.getMessages().find(Zr=>Zr.id===kt);Jr!=null&&Jr.approval&&(Jr.approval.toolType==="webmcp"?(Nr=vt.current)==null||Nr.resolveWebMcpApproval(Jr.id,Ft):(Yr=vt.current)==null||Yr.resolveApproval(Jr.approval,Ft,jr))};Jt=dt.renderApproval({message:D,defaultRenderer:()=>Vl(D,n),config:n,approve:Ft=>gr("approved",Ft),deny:Ft=>gr("denied",Ft)})}if(er&&Jt===null){let kt=c.querySelector(`#wrapper-${D.id}`);kt==null||kt.removeAttribute("data-preserve-runtime"),Nn.delete(D.id),Wt=Vl(D,n)}else{let kt=document.createElement("div");kt.className="persona-flex",kt.id=`wrapper-${D.id}`,kt.setAttribute("data-wrapper-id",D.id),kt.setAttribute("data-approval-plugin-stub","true"),kt.setAttribute("data-preserve-runtime","true"),A.appendChild(kt),Se.push({messageId:D.id,fingerprint:Gt,bubble:Jt});return}}else if(ir)if(D.variant==="reasoning"&&D.reasoning&&ir.renderReasoning){if(!Je)return;Wt=ir.renderReasoning({message:D,defaultRenderer:()=>au(D,n),config:n})}else if(D.variant==="tool"&&D.toolCall&&ir.renderToolCall){if(!we)return;Wt=ir.renderToolCall({message:D,defaultRenderer:()=>su(D,n),config:n})}else ir.renderMessage&&(Wt=ir.renderMessage({message:D,defaultRenderer:()=>{let dt=Ya(D,y,bn,n.messageActions,ne,{loadingIndicatorRenderer:_,widgetConfig:n});return D.role!=="user"&&cu(dt,D,n,q),dt},config:n}));if(!Wt&&be){let dt=Zl(D);if(dt){let Hr=Qn.get(D.id),er=Hr!==Gt,Jt=n.wrapComponentDirectiveInBubble!==!1,kt=null;if(er){let gr=Jl(dt,{config:n,message:D,transform:y});if(gr)if(Jt){let Ft=document.createElement("div");if(Ft.className=["persona-message-bubble","persona-max-w-[85%]","persona-rounded-2xl","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-p-4"].join(" "),Ft.id=`bubble-${D.id}`,Ft.setAttribute("data-message-id",D.id),D.content&&D.content.trim()){let jr=document.createElement("div");jr.className="persona-mb-3 persona-text-sm persona-leading-relaxed",jr.innerHTML=y({text:D.content,message:D,streaming:!!D.streaming,raw:D.rawContent}),Ft.appendChild(jr)}Ft.appendChild(gr),kt=Ft}else{let Ft=document.createElement("div");if(Ft.className="persona-flex persona-flex-col persona-w-full persona-max-w-full persona-gap-3 persona-items-stretch",Ft.id=`bubble-${D.id}`,Ft.setAttribute("data-message-id",D.id),Ft.setAttribute("data-persona-component-directive","true"),D.content&&D.content.trim()){let jr=document.createElement("div");jr.className="persona-text-sm persona-leading-relaxed persona-text-persona-primary persona-w-full",jr.innerHTML=y({text:D.content,message:D,streaming:!!D.streaming,raw:D.rawContent}),Ft.appendChild(jr)}Ft.appendChild(gr),kt=Ft}}if(kt||Hr!=null){let gr=document.createElement("div");gr.className="persona-flex",gr.id=`wrapper-${D.id}`,gr.setAttribute("data-wrapper-id",D.id),gr.setAttribute("data-component-directive-stub","true"),gr.setAttribute("data-preserve-runtime","true"),Jt||gr.classList.add("persona-w-full"),A.appendChild(gr),ae.push({messageId:D.id,fingerprint:Gt,bubble:kt});return}}}if(!Wt)if(D.variant==="reasoning"&&D.reasoning){if(!Je)return;Wt=au(D,n)}else if(D.variant==="tool"&&D.toolCall){if(!we)return;Wt=su(D,n)}else if(D.variant==="approval"&&D.approval){if(n.approval===!1)return;Wt=Vl(D,n)}else{let dt=(qn=n.layout)==null?void 0:qn.messages;dt!=null&&dt.renderUserMessage&&D.role==="user"?Wt=dt.renderUserMessage({message:D,config:n,streaming:!!D.streaming}):dt!=null&&dt.renderAssistantMessage&&D.role==="assistant"?Wt=dt.renderAssistantMessage({message:D,config:n,streaming:!!D.streaming}):Wt=Ya(D,y,dt,n.messageActions,ne,{loadingIndicatorRenderer:_,widgetConfig:n}),D.role!=="user"&&Wt&&cu(Wt,D,n,q)}let kr=document.createElement("div");kr.className="persona-flex",kr.id=`wrapper-${D.id}`,kr.setAttribute("data-wrapper-id",D.id),D.role==="user"&&kr.classList.add("persona-justify-end"),(Wt==null?void 0:Wt.getAttribute("data-persona-component-directive"))==="true"&&kr.classList.add("persona-w-full"),kr.appendChild(Wt),yx(so,D.id,Gt,kr),A.appendChild(kr)}),Re.composerOverlay&&Re.composerOverlay.querySelectorAll("[data-persona-ask-sheet-for]").forEach(Oe=>{let Ue=Oe.getAttribute("data-persona-ask-sheet-for");Ue&&!N.has(Ue)&&Oo(Re.composerOverlay,Ue)}),(Be=(xt=n.features)==null?void 0:xt.toolCallDisplay)!=null&&Be.grouped){let D=[],Oe=[];g.forEach(Ue=>{if(Ue.variant==="tool"&&Ue.toolCall&&we){Oe.push(Ue);return}Oe.length>1&&D.push(Oe),Oe=[]}),Oe.length>1&&D.push(Oe),D.forEach((Ue,be)=>{var ot,_t;let Qt=Ue.map(Lr=>Array.from(A.children).find(In=>In instanceof HTMLElement&&In.getAttribute("data-wrapper-id")===Lr.id)).filter(Lr=>!!Lr);if(Qt.length<2)return;let Gt=document.createElement("div");Gt.className="persona-flex",Gt.id=`wrapper-tool-group-${be}-${Ue[0].id}`,Gt.setAttribute("data-wrapper-id",`tool-group-${be}-${Ue[0].id}`);let dr=document.createElement("div");dr.className="persona-tool-group persona-flex persona-w-full persona-flex-col persona-gap-2",dr.setAttribute("data-persona-tool-group","true");let Wt=document.createElement("div");Wt.className="persona-tool-group-summary persona-text-xs persona-text-persona-muted";let ir=`Called ${Ue.length} tools`,bn=(_t=(ot=n.toolCall)==null?void 0:ot.renderGroupedSummary)==null?void 0:_t.call(ot,{messages:Ue,toolCalls:Ue.map(Lr=>Lr.toolCall).filter(Lr=>!!Lr),defaultSummary:ir,config:n});U(Wt,bn)||(Wt.textContent=ir);let kr=document.createElement("div");kr.className="persona-tool-group-stack persona-flex persona-flex-col",dr.append(Wt,kr),Gt.appendChild(dr),Qt[0].before(Gt),Qt.forEach((Lr,In)=>{let yn=document.createElement("div");yn.className="persona-tool-group-item persona-relative",yn.setAttribute("data-persona-tool-group-item","true"),In<Qt.length-1&&yn.setAttribute("data-persona-tool-group-connector","true"),yn.appendChild(Lr),kr.appendChild(yn)})})}vx(so,V);let ct=g.some(D=>D.role==="assistant"&&D.streaming),Qe=g[g.length-1],ht=(Qe==null?void 0:Qe.role)==="assistant"&&!Qe.streaming&&Qe.variant!=="approval";if(Xn&&g.some(D=>D.role==="user")&&!ct&&!ht){let D={config:n,streaming:!0,location:"standalone",defaultRenderer:va},Oe=o.find(be=>be.renderLoadingIndicator),Ue=null;if(Oe!=null&&Oe.renderLoadingIndicator&&(Ue=Oe.renderLoadingIndicator(D)),Ue===null&&((Pe=n.loadingIndicator)!=null&&Pe.render)&&(Ue=n.loadingIndicator.render(D)),Ue===null&&(Ue=va()),Ue){let be=document.createElement("div"),Qt=((Ke=n.loadingIndicator)==null?void 0:Ke.showBubble)!==!1;be.className=Qt?["persona-max-w-[85%]","persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm","persona-bg-persona-surface","persona-border","persona-text-persona-primary","persona-px-5","persona-py-3"].join(" "):["persona-max-w-[85%]","persona-text-sm","persona-leading-relaxed","persona-text-persona-primary"].join(" "),be.setAttribute("data-typing-indicator","true"),be.style.borderColor="var(--persona-message-assistant-border, var(--persona-border, #e5e7eb))",be.appendChild(Ue);let Gt=document.createElement("div");Gt.className="persona-flex",Gt.id="wrapper-typing-indicator",Gt.setAttribute("data-wrapper-id","typing-indicator"),Gt.appendChild(be),A.appendChild(Gt)}}if(!Xn&&g.length>0){let D=g[g.length-1],Oe={config:n,lastMessage:D,messageCount:g.length},Ue=o.find(Qt=>Qt.renderIdleIndicator),be=null;if(Ue!=null&&Ue.renderIdleIndicator&&(be=Ue.renderIdleIndicator(Oe)),be===null&&((rt=n.loadingIndicator)!=null&&rt.renderIdle)&&(be=n.loadingIndicator.renderIdle(Oe)),be){let Qt=document.createElement("div"),Gt=((It=n.loadingIndicator)==null?void 0:It.showBubble)!==!1;Qt.className=Gt?["persona-max-w-[85%]","persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-px-5","persona-py-3"].join(" "):["persona-max-w-[85%]","persona-text-sm","persona-leading-relaxed","persona-text-persona-primary"].join(" "),Qt.setAttribute("data-idle-indicator","true"),Qt.appendChild(be);let dr=document.createElement("div");dr.className="persona-flex",dr.id="wrapper-idle-indicator",dr.setAttribute("data-wrapper-id","idle-indicator"),dr.appendChild(Qt),A.appendChild(dr)}}if(Ml(c,A),me.length>0)for(let{messageId:D,fingerprint:Oe,bubble:Ue}of me){let be=c.querySelector(`#wrapper-${D}`);be&&Ue!==null&&(be.replaceChildren(Ue),be.setAttribute("data-bubble-fp",Oe),io.set(D,Oe))}if(io.size>0)for(let D of io.keys())V.has(D)||io.delete(D);if(ae.length>0)for(let{messageId:D,fingerprint:Oe,bubble:Ue}of ae){let be=c.querySelector(`#wrapper-${D}`);be&&Ue!==null&&(be.replaceChildren(Ue),be.setAttribute("data-bubble-fp",Oe),Qn.set(D,Oe))}if(Qn.size>0)for(let D of Qn.keys())V.has(D)||Qn.delete(D);if(Se.length>0)for(let{messageId:D,fingerprint:Oe,bubble:Ue}of Se){let be=c.querySelector(`#wrapper-${D}`);be&&Ue!==null&&(be.replaceChildren(Ue),be.setAttribute("data-bubble-fp",Oe),Nn.set(D,Oe))}if(Nn.size>0)for(let D of Nn.keys())V.has(D)||Nn.delete(D)},Eo=null,wi=()=>{var y;if(Eo)return;let c=A=>{let W=A.composedPath();W.includes(We)||at&&W.includes(at)||jt(!1,"user")};Eo=c,((y=r.ownerDocument)!=null?y:document).addEventListener("pointerdown",c,!0)},gs=()=>{var g;if(!Eo)return;((g=r.ownerDocument)!=null?g:document).removeEventListener("pointerdown",Eo,!0),Eo=null};Tt.push(()=>gs());let Lo=null,Ai=()=>{var y;if(Lo)return;let c=A=>{A.key==="Escape"&&(A.isComposing||jt(!1,"user"))};Lo=c,((y=r.ownerDocument)!=null?y:document).addEventListener("keydown",c,!0)},hs=()=>{var g;if(!Lo)return;((g=r.ownerDocument)!=null?g:document).removeEventListener("keydown",Lo,!0),Lo=null};Tt.push(()=>hs());let Po=!1,xs=new Set,Si=()=>{var g,y,A,W;let c=(A=(y=(g=n.launcher)==null?void 0:g.composerBar)==null?void 0:y.peek)==null?void 0:A.streamAnimation;return c||((W=n.features)==null?void 0:W.streamAnimation)},po=()=>{var ht,xt,Be,Pe;if(!H())return;let c=Re.peekBanner,g=Re.peekTextNode;if(!c||!g)return;if(L){c.classList.remove("persona-pill-peek--visible");return}let y=(ht=q==null?void 0:q.getMessages())!=null?ht:[],A;for(let Ke=y.length-1;Ke>=0;Ke--){let rt=y[Ke];if(rt.role==="assistant"&&rt.content){A=rt;break}}if(!A){c.classList.remove("persona-pill-peek--visible");return}let W=A.content,_=!!A.streaming,U=Si(),V=Rl(U),N=V.type!=="none"?Ys(V.type,U==null?void 0:U.plugins):null,Ce=((xt=N==null?void 0:N.isAnimating)==null?void 0:xt.call(N,A))===!0,me=N!==null&&(_||Ce);me&&N&&!xs.has(N.name)&&(Xp(N,r),xs.add(N.name));let ae=me&&(N!=null&&N.containerClass)?N.containerClass:null,Te=(Be=g.dataset.personaPeekStreamClass)!=null?Be:null;Te&&Te!==ae&&(g.classList.remove(Te),delete g.dataset.personaPeekStreamClass),ae&&Te!==ae&&(g.classList.add(ae),g.dataset.personaPeekStreamClass=ae),me?(g.style.setProperty("--persona-stream-step",`${V.speed}ms`),g.style.setProperty("--persona-stream-duration",`${V.duration}ms`)):(g.style.removeProperty("--persona-stream-step"),g.style.removeProperty("--persona-stream-duration"));let Ve=me?Il(W,V.buffer,N,A,_):W;if(me&&V.placeholder==="skeleton"&&_&&(!Ve||!Ve.trim())){let Ke=document.createElement("div"),rt=ei();rt.classList.add("persona-pill-peek__skeleton"),Ke.appendChild(rt),Ml(g,Ke)}else{let Ke=Math.max(0,Ve.length-100),rt=Ve.length>100?Ve.slice(-100):Ve,It=la(rt);if(!me||!N){let D=Ve.length>100?`\u2026${rt}`:rt;g.textContent!==D&&(g.textContent=D)}else{let D=It;(N.wrap==="char"||N.wrap==="word")&&(D=Zs(It,N.wrap,`peek-${A.id}`,{skipTags:N.skipTags,startIndex:Ke}));let Oe=document.createElement("div");if(Oe.innerHTML=D,N.useCaret&&rt.length>0){let Ue=Hl(),be=Oe.querySelectorAll(".persona-stream-char, .persona-stream-word"),Qt=be[be.length-1];Qt!=null&&Qt.parentNode?Qt.parentNode.insertBefore(Ue,Qt.nextSibling):Oe.appendChild(Ue)}Ml(g,Oe),(Pe=N.onAfterRender)==null||Pe.call(N,{container:g,bubble:c,messageId:A.id,message:A,speed:V.speed,duration:V.duration})}}let Qe=Xn||Po;c.classList.toggle("persona-pill-peek--visible",Qe)};if(H()){let c=Re.peekBanner;if(c){let A=W=>{W.preventDefault(),W.stopPropagation(),jt(!0,"user")};c.addEventListener("pointerdown",A),Tt.push(()=>{c.removeEventListener("pointerdown",A)})}let g=()=>{Po||(Po=!0,po())},y=()=>{Po&&(Po=!1,po())};he.addEventListener("pointerenter",g),he.addEventListener("pointerleave",y),Tt.push(()=>{he.removeEventListener("pointerenter",g),he.removeEventListener("pointerleave",y)}),at&&(at.addEventListener("pointerenter",g),at.addEventListener("pointerleave",y),Tt.push(()=>{at.removeEventListener("pointerenter",g),at.removeEventListener("pointerleave",y)}))}let Ti=c=>{var Te,Ve,Se,ct,Qe,ht,xt,Be;let g=(Ve=(Te=n.launcher)==null?void 0:Te.composerBar)!=null?Ve:{},y=(Se=g.expandedSize)!=null?Se:"anchored",A=(ct=g.bottomOffset)!=null?ct:"16px",W=g.collapsedMaxWidth,_=(Qe=g.expandedMaxWidth)!=null?Qe:"880px",U=(ht=g.expandedTopOffset)!=null?ht:"5vh",V=(xt=g.modalMaxWidth)!=null?xt:"880px",N=(Be=g.modalMaxHeight)!=null?Be:"min(90vh, 800px)",Ce="calc(100vw - 32px)",me="var(--persona-pill-area-height, 80px)",ae=We.style;if(ae.left="",ae.right="",ae.top="",ae.bottom="",ae.transform="",ae.width="",ae.maxWidth="",ae.height="",ae.maxHeight="",at){let Pe=at.style;Pe.bottom=A,Pe.width=W!=null?W:""}if(c&&y!=="fullscreen"){if(y==="modal"){ae.top="50%",ae.left="50%",ae.transform="translate(-50%, -50%)",ae.bottom="auto",ae.right="auto",ae.width=V,ae.maxWidth=Ce,ae.maxHeight=N,ae.height=N;return}ae.left="50%",ae.transform="translateX(-50%)",ae.bottom=`calc(${A} + ${me})`,ae.top=U,ae.width=_,ae.maxWidth=Ce}},Ro=()=>{var N,Ce,me,ae,Te,Ve,Se,ct;if(!I())return;if(H()){let ht=(me=((Ce=(N=n.launcher)==null?void 0:N.composerBar)!=null?Ce:{}).expandedSize)!=null?me:"anchored",xt=L?"expanded":"collapsed";We.dataset.state=xt,We.dataset.expandedSize=ht,at&&(at.dataset.state=xt,at.dataset.expandedSize=ht),We.style.removeProperty("display"),We.classList.remove("persona-pointer-events-none","persona-opacity-0"),he.classList.remove("persona-scale-95","persona-opacity-0","persona-scale-100","persona-opacity-100"),Ti(L),j.style.display=L?"flex":"none",Fn(),L?(wi(),Ai()):(gs(),hs()),po();return}let c=Pr(n),g=(ae=r.ownerDocument.defaultView)!=null?ae:window,y=(Ve=(Te=n.launcher)==null?void 0:Te.mobileBreakpoint)!=null?Ve:640,A=(ct=(Se=n.launcher)==null?void 0:Se.mobileFullscreen)!=null?ct:!0,W=g.innerWidth<=y,_=A&&W&&T,U=Sn(n).reveal;L?(We.style.removeProperty("display"),We.style.display=c?"flex":"",We.classList.remove("persona-pointer-events-none","persona-opacity-0"),he.classList.remove("persona-scale-95","persona-opacity-0"),he.classList.add("persona-scale-100","persona-opacity-100"),Ar?Ar.element.style.display="none":Sr&&(Sr.style.display="none")):(c?c&&(U==="overlay"||U==="push")&&!_?(We.style.removeProperty("display"),We.style.display="flex",We.classList.remove("persona-pointer-events-none","persona-opacity-0"),he.classList.remove("persona-scale-100","persona-opacity-100","persona-scale-95","persona-opacity-0")):(We.style.setProperty("display","none","important"),We.classList.remove("persona-pointer-events-none","persona-opacity-0"),he.classList.remove("persona-scale-100","persona-opacity-100","persona-scale-95","persona-opacity-0")):(We.style.display="",We.classList.add("persona-pointer-events-none","persona-opacity-0"),he.classList.remove("persona-scale-100","persona-opacity-100"),he.classList.add("persona-scale-95","persona-opacity-0")),Ar?Ar.element.style.display=c?"none":"":Sr&&(Sr.style.display=c?"none":""))},jt=(c,g="user")=>{var _,U;if(!I()||L===c)return;let y=L;L=c,Ro();let A=(()=>{var Se,ct,Qe,ht,xt,Be,Pe,Ke,rt,It;let V=(ct=(Se=n.launcher)==null?void 0:Se.sidebarMode)!=null?ct:!1,N=(Qe=r.ownerDocument.defaultView)!=null?Qe:window,Ce=(xt=(ht=n.launcher)==null?void 0:ht.mobileFullscreen)!=null?xt:!0,me=(Pe=(Be=n.launcher)==null?void 0:Be.mobileBreakpoint)!=null?Pe:640,ae=N.innerWidth<=me,Te=Pr(n)&&Ce&&ae,Ve=H()&&((It=(rt=(Ke=n.launcher)==null?void 0:Ke.composerBar)==null?void 0:rt.expandedSize)!=null?It:"fullscreen")==="fullscreen";return V||Ce&&ae&&T||Te||Ve})();if(L&&A){if(!Cr){let V=r.getRootNode(),N=V instanceof ShadowRoot?V.host:r.closest(".persona-host");N&&(Cr=Qp(N,(U=(_=n.launcher)==null?void 0:_.zIndex)!=null?U:Xr))}wr||(wr=Jp(r.ownerDocument))}else L||(Cr==null||Cr(),Cr=null,wr==null||wr(),wr=null);L&&(ys(),ut()==="follow"?Zn(!0):fs());let W={open:L,source:g,timestamp:Date.now()};L&&!y?a.emit("widget:opened",W):!L&&y&&a.emit("widget:closed",W),a.emit("widget:state",{open:L,launcherEnabled:T,voiceActive:Pt.active,streaming:q.isStreaming()})},Ra=c=>{ar(c?"stop":"send"),K&&(K.disabled=c),On.buttons.forEach(g=>{g.disabled=c}),Ne.dataset.personaComposerStreaming=c?"true":"false",Ne.querySelectorAll("[data-persona-composer-disable-when-streaming]").forEach(g=>{(g instanceof HTMLButtonElement||g instanceof HTMLInputElement||g instanceof HTMLTextAreaElement||g instanceof HTMLSelectElement)&&(g.disabled=c)})},Ia=()=>{Pt.active||ee&&ee.focus()};a.on("widget:opened",()=>{n.autoFocusInput&&setTimeout(()=>Ia(),200)});let Xo=()=>{var y,A,W,_,U,V,N,Ce,me,ae,Te;hr.textContent=(A=(y=n.copy)==null?void 0:y.welcomeTitle)!=null?A:"Hello \u{1F44B}",sn.textContent=(_=(W=n.copy)==null?void 0:W.welcomeSubtitle)!=null?_:"Ask anything about your account or products.",ee.placeholder=(V=(U=n.copy)==null?void 0:U.inputPlaceholder)!=null?V:"How can I help...";let c=ue.querySelector("[data-persona-intro-card]");if(c){let Ve=((N=n.copy)==null?void 0:N.showWelcomeCard)!==!1;c.style.display=Ve?"":"none",Ve?(ue.classList.remove("persona-gap-3"),ue.classList.add("persona-gap-6")):(ue.classList.remove("persona-gap-6"),ue.classList.add("persona-gap-3"))}!((me=(Ce=n.sendButton)==null?void 0:Ce.useIcon)!=null&&me)&&!(q!=null&&q.isStreaming())&&(Ge.textContent=(Te=(ae=n.copy)==null?void 0:ae.sendButtonLabel)!=null?Te:"Send"),ee.style.fontFamily='var(--persona-input-font-family, var(--persona-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif))',ee.style.fontWeight="var(--persona-input-font-weight, var(--persona-font-weight, 400))"};n.clientToken&&(n={...n,getStoredSessionId:()=>{let c=d.sessionId;return typeof c=="string"?c:null},setStoredSessionId:c=>{f(g=>({...g,sessionId:c}))}});let je=null,P=()=>{je==null&&(je=setInterval(()=>{let c=nt.querySelectorAll("[data-tool-elapsed]");if(c.length===0){clearInterval(je),je=null;return}let g=Date.now();c.forEach(y=>{let A=Number(y.getAttribute("data-tool-elapsed"));A&&(y.textContent=Qi(g-A))})},100))};if(q=new ja(n,{onMessagesChanged(c){var A;Ko(nt,c,xe),P(),Sa(c),Zn(!Xn),Ci(c);let g=[...c].reverse().find(W=>W.role==="user");c.length===0&&Go(),!Ta||jo?(Ta=!0,Ma=(A=g==null?void 0:g.id)!=null?A:null):g&&g.id!==Ma&&(Ma=g.id,vi(g.id));let y=Pt.lastUserMessageId;g&&g.id!==y&&(Pt.lastUserMessageId=g.id,a.emit("user:message",g)),Pt.lastUserMessageWasVoice=!!(g!=null&&g.viaVoice),La(c),po()},onStatusChanged(c){var A;let g=(A=n.statusIndicator)!=null?A:{};wt(or,(W=>{var _,U,V,N;return W==="idle"?(_=g.idleText)!=null?_:Kr.idle:W==="connecting"?(U=g.connectingText)!=null?U:Kr.connecting:W==="connected"?(V=g.connectedText)!=null?V:Kr.connected:W==="error"?(N=g.errorText)!=null?N:Kr.error:Kr[W]})(c),g,c)},onStreamingChanged(c){Xn=c,Ra(c),q&&Ko(nt,q.getMessages(),xe),c||Zn(!0),po()},onVoiceStatusChanged(c){var g,y;if(((y=(g=n.voiceRecognition)==null?void 0:g.provider)==null?void 0:y.type)==="runtype")switch(c){case"listening":break;case"processing":Io(),Xb();break;case"speaking":Io(),Qb();break;default:c==="idle"&&q.isBargeInActive()?(Io(),bs(),K==null||K.setAttribute("aria-label","End voice session")):(Pt.active=!1,Io(),Pn("system"),dn());break}},onArtifactsState(c){Yt=c,mn(),La()}}),vt.current=q,Ta=!0,((Hf=(If=n.voiceRecognition)==null?void 0:If.provider)==null?void 0:Hf.type)==="runtype")try{q.setupVoice()}catch(c){typeof console!="undefined"&&console.warn("[AgentWidget] Runtype voice setup failed:",c)}n.clientToken&&q.initClientSession().catch(c=>{n.debug&&console.warn("[AgentWidget] Pre-init client session failed:",c)}),(ge||n.onSSEEvent)&&q.setSSEEventCallback((c,g)=>{var y;(y=n.onSSEEvent)==null||y.call(n,c,g),Z==null||Z.processEvent(c,g),ge==null||ge.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:c,timestamp:Date.now(),payload:JSON.stringify(g)})}),l&&l.then(c=>{var g,y,A;if(c){if(c.metadata&&(d=fu(c.metadata),S.syncFromMetadata()),(g=c.messages)!=null&&g.length){jo=!0;try{q.hydrateMessages(c.messages)}finally{jo=!1}}(y=c.artifacts)!=null&&y.length&&q.hydrateArtifacts(c.artifacts,(A=c.selectedArtifactId)!=null?A:null)}}).catch(c=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to hydrate stored state:",c)});let z=()=>{var g,y,A;!H()||L||!((A=(y=(g=n.launcher)==null?void 0:g.composerBar)==null?void 0:y.expandOnSubmit)==null||A)||jt(!0,"auto")},B=c=>{var W;if(c.preventDefault(),q.isStreaming()){q.cancel(),Z==null||Z.reset(),G==null||G.update();return}let g=ee.value.trim(),y=(W=St==null?void 0:St.hasAttachments())!=null?W:!1;if(!g&&!y)return;z();let A;y&&(A=[],A.push(...St.getContentParts()),g&&A.push($s(g))),ee.value="",ee.style.height="auto",Le(),q.sendMessage(g,{contentParts:A}),y&&St.clearAttachments()},oe=()=>{var c;return((c=n.features)==null?void 0:c.composerHistory)!==!1},ce={...kl},X=!1,Le=()=>{ce={...kl}},$e=()=>q.getMessages().filter(c=>c.role==="user").map(c=>{var g;return(g=c.content)!=null?g:""}).filter(c=>c.length>0),gt=c=>{if(!ee)return;X=!0,ee.value=c,ee.dispatchEvent(new Event("input",{bubbles:!0})),X=!1;let g=ee.value.length;ee.setSelectionRange(g,g)},lt=()=>{X||Le()},qt=c=>{if(ee){if(oe()&&(c.key==="ArrowUp"||c.key==="ArrowDown")&&!c.shiftKey&&!c.metaKey&&!c.ctrlKey&&!c.altKey&&!c.isComposing){let g=ee.selectionStart===0&&ee.selectionEnd===0,y=gx({direction:c.key==="ArrowUp"?"up":"down",history:$e(),currentValue:ee.value,atStart:g,state:ce});if(ce=y.state,y.handled){c.preventDefault(),y.value!==void 0&>(y.value);return}}if(c.key==="Enter"&&!c.shiftKey){if(q.isStreaming()){c.preventDefault();return}Le(),c.preventDefault(),Ge.click()}}},Zt=c=>{c.key!=="Escape"||c.isComposing||q.isStreaming()&&c.composedPath().includes(j)&&(q.cancel(),Z==null||Z.reset(),G==null||G.update(),Le(),c.preventDefault(),c.stopImmediatePropagation())},Ir=async c=>{var y;if(((y=n.attachments)==null?void 0:y.enabled)!==!0||!St)return;let g=HC(c.clipboardData);g.length!==0&&(c.preventDefault(),await St.handleFiles(g))},ft=null,Mt=!1,br=null,Ze=null,_r=()=>typeof window=="undefined"?null:window.webkitSpeechRecognition||window.SpeechRecognition||null,fr=(c="user")=>{var _,U,V,N,Ce,me,ae;if(Mt||q.isStreaming())return;let g=_r();if(!g)return;ft=new g;let A=(U=((_=n.voiceRecognition)!=null?_:{}).pauseDuration)!=null?U:2e3;ft.continuous=!0,ft.interimResults=!0,ft.lang="en-US";let W=ee.value;ft.onresult=Te=>{let Ve="",Se="";for(let Qe=0;Qe<Te.results.length;Qe++){let ht=Te.results[Qe],xt=ht[0].transcript;ht.isFinal?Ve+=xt+" ":Se=xt}let ct=W+Ve+Se;ee.value=ct,br&&clearTimeout(br),(Ve||Se)&&(br=window.setTimeout(()=>{let Qe=ee.value.trim();Qe&&ft&&Mt&&(Or(),ee.value="",ee.style.height="auto",q.sendMessage(Qe,{viaVoice:!0}))},A))},ft.onerror=Te=>{Te.error!=="no-speech"&&Or()},ft.onend=()=>{if(Mt){let Te=ee.value.trim();Te&&Te!==W.trim()&&(ee.value="",ee.style.height="auto",q.sendMessage(Te,{viaVoice:!0})),Or()}};try{if(ft.start(),Mt=!0,Pt.active=!0,c!=="system"&&(Pt.manuallyDeactivated=!1),Pn(c),dn(),K){let Te=(V=n.voiceRecognition)!=null?V:{};Ze={backgroundColor:K.style.backgroundColor,color:K.style.color,borderColor:K.style.borderColor,iconName:(N=Te.iconName)!=null?N:"mic",iconSize:parseFloat((ae=(me=Te.iconSize)!=null?me:(Ce=n.sendButton)==null?void 0:Ce.size)!=null?ae:"40")||24};let Ve=Te.recordingBackgroundColor,Se=Te.recordingIconColor,ct=Te.recordingBorderColor;if(K.classList.add("persona-voice-recording"),K.style.backgroundColor=Ve!=null?Ve:"var(--persona-voice-recording-bg, #ef4444)",K.style.color=Se!=null?Se:"var(--persona-voice-recording-indicator, #ffffff)",Se){let Qe=K.querySelector("svg");Qe&&Qe.setAttribute("stroke",Se)}ct&&(K.style.borderColor=ct),K.setAttribute("aria-label","Stop voice recognition")}}catch{Or("system")}},Or=(c="user")=>{if(Mt){if(Mt=!1,br&&(clearTimeout(br),br=null),ft){try{ft.stop()}catch{}ft=null}if(Pt.active=!1,Pn(c),dn(),K){if(K.classList.remove("persona-voice-recording"),Ze){K.style.backgroundColor=Ze.backgroundColor,K.style.color=Ze.color,K.style.borderColor=Ze.borderColor;let g=K.querySelector("svg");g&&g.setAttribute("stroke",Ze.color||"currentColor"),Ze=null}K.setAttribute("aria-label","Start voice recognition")}}},Kb=(c,g)=>{var ht,xt,Be,Pe,Ke,rt,It,D;let y=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),A=((ht=c==null?void 0:c.provider)==null?void 0:ht.type)==="runtype";if(!(y||A))return null;let _=v("div","persona-send-button-wrapper"),U=v("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer");U.type="button",U.setAttribute("aria-label","Start voice recognition");let V=(xt=c==null?void 0:c.iconName)!=null?xt:"mic",N=(Be=g==null?void 0:g.size)!=null?Be:"40px",Ce=(Pe=c==null?void 0:c.iconSize)!=null?Pe:N,me=parseFloat(Ce)||24,ae=(Ke=c==null?void 0:c.backgroundColor)!=null?Ke:g==null?void 0:g.backgroundColor,Te=(rt=c==null?void 0:c.iconColor)!=null?rt:g==null?void 0:g.textColor;U.style.width=Ce,U.style.height=Ce,U.style.minWidth=Ce,U.style.minHeight=Ce,U.style.fontSize="18px",U.style.lineHeight="1",Te?U.style.color=Te:U.style.color="var(--persona-text, #111827)";let Se=Me(V,me,Te||"currentColor",1.5);Se?U.appendChild(Se):U.textContent="\u{1F3A4}",ae?U.style.backgroundColor=ae:U.style.backgroundColor="",c!=null&&c.borderWidth&&(U.style.borderWidth=c.borderWidth,U.style.borderStyle="solid"),c!=null&&c.borderColor&&(U.style.borderColor=c.borderColor),c!=null&&c.paddingX&&(U.style.paddingLeft=c.paddingX,U.style.paddingRight=c.paddingX),c!=null&&c.paddingY&&(U.style.paddingTop=c.paddingY,U.style.paddingBottom=c.paddingY),_.appendChild(U);let ct=(It=c==null?void 0:c.tooltipText)!=null?It:"Start voice recognition";if(((D=c==null?void 0:c.showTooltip)!=null?D:!1)&&ct){let Oe=v("div","persona-send-button-tooltip");Oe.textContent=ct,_.appendChild(Oe)}return{micButton:U,micButtonWrapper:_}},id=()=>{var g,y,A,W,_;if(!K||Ze)return;let c=(g=n.voiceRecognition)!=null?g:{};Ze={backgroundColor:K.style.backgroundColor,color:K.style.color,borderColor:K.style.borderColor,iconName:(y=c.iconName)!=null?y:"mic",iconSize:parseFloat((_=(W=c.iconSize)!=null?W:(A=n.sendButton)==null?void 0:A.size)!=null?_:"40")||24}},ld=(c,g)=>{var _,U,V,N,Ce;if(!K)return;let y=K.querySelector("svg");y&&y.remove();let A=(Ce=Ze==null?void 0:Ze.iconSize)!=null?Ce:parseFloat((N=(V=(_=n.voiceRecognition)==null?void 0:_.iconSize)!=null?V:(U=n.sendButton)==null?void 0:U.size)!=null?N:"40")||24,W=Me(c,A,g,1.5);W&&K.appendChild(W)},Mi=()=>{K&&K.classList.remove("persona-voice-recording","persona-voice-processing","persona-voice-speaking")},bs=()=>{var W;if(!K)return;id();let c=(W=n.voiceRecognition)!=null?W:{},g=c.recordingBackgroundColor,y=c.recordingIconColor,A=c.recordingBorderColor;if(Mi(),K.classList.add("persona-voice-recording"),K.style.backgroundColor=g!=null?g:"var(--persona-voice-recording-bg, #ef4444)",K.style.color=y!=null?y:"var(--persona-voice-recording-indicator, #ffffff)",y){let _=K.querySelector("svg");_&&_.setAttribute("stroke",y)}A&&(K.style.borderColor=A),K.setAttribute("aria-label","Stop voice recognition")},Xb=()=>{var V,N,Ce,me,ae,Te,Ve,Se;if(!K)return;id();let c=(V=n.voiceRecognition)!=null?V:{},g=q.getVoiceInterruptionMode(),y=(N=c.processingIconName)!=null?N:"loader",A=(me=(Ce=c.processingIconColor)!=null?Ce:Ze==null?void 0:Ze.color)!=null?me:"",W=(Te=(ae=c.processingBackgroundColor)!=null?ae:Ze==null?void 0:Ze.backgroundColor)!=null?Te:"",_=(Se=(Ve=c.processingBorderColor)!=null?Ve:Ze==null?void 0:Ze.borderColor)!=null?Se:"";Mi(),K.classList.add("persona-voice-processing"),K.style.backgroundColor=W,K.style.borderColor=_;let U=A||"currentColor";K.style.color=U,ld(y,U),K.setAttribute("aria-label","Processing voice input"),g==="none"&&(K.style.cursor="default")},Qb=()=>{var Ce,me,ae,Te,Ve,Se,ct,Qe,ht,xt,Be,Pe;if(!K)return;id();let c=(Ce=n.voiceRecognition)!=null?Ce:{},g=q.getVoiceInterruptionMode(),y=g==="cancel"?"square":g==="barge-in"?"mic":"volume-2",A=(me=c.speakingIconName)!=null?me:y,W=(Se=c.speakingIconColor)!=null?Se:g==="barge-in"?(Te=(ae=c.recordingIconColor)!=null?ae:Ze==null?void 0:Ze.color)!=null?Te:"":(Ve=Ze==null?void 0:Ze.color)!=null?Ve:"",_=(ht=c.speakingBackgroundColor)!=null?ht:g==="barge-in"?(ct=c.recordingBackgroundColor)!=null?ct:"var(--persona-voice-recording-bg, #ef4444)":(Qe=Ze==null?void 0:Ze.backgroundColor)!=null?Qe:"",U=(Pe=c.speakingBorderColor)!=null?Pe:g==="barge-in"?(xt=c.recordingBorderColor)!=null?xt:"":(Be=Ze==null?void 0:Ze.borderColor)!=null?Be:"";Mi(),K.classList.add("persona-voice-speaking"),K.style.backgroundColor=_,K.style.borderColor=U;let V=W||"currentColor";K.style.color=V,ld(A,V);let N=g==="cancel"?"Stop playback and re-record":g==="barge-in"?"Speak to interrupt":"Agent is speaking";K.setAttribute("aria-label",N),g==="none"&&(K.style.cursor="default"),g==="barge-in"&&K.classList.add("persona-voice-recording")},Io=()=>{var c,g,y;K&&(Mi(),Ze&&(K.style.backgroundColor=(c=Ze.backgroundColor)!=null?c:"",K.style.color=(g=Ze.color)!=null?g:"",K.style.borderColor=(y=Ze.borderColor)!=null?y:"",ld(Ze.iconName,Ze.color||"currentColor"),Ze=null),K.style.cursor="",K.setAttribute("aria-label","Start voice recognition"))},ki=()=>{var c,g;if(((g=(c=n.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"){let y=q.getVoiceStatus(),A=q.getVoiceInterruptionMode();if(A==="none"&&(y==="processing"||y==="speaking"))return;if(A==="cancel"&&(y==="processing"||y==="speaking")){q.stopVoicePlayback();return}if(q.isBargeInActive()){q.stopVoicePlayback(),q.deactivateBargeIn().then(()=>{Pt.active=!1,Pt.manuallyDeactivated=!0,dn(),Pn("user"),Io()});return}q.toggleVoice().then(()=>{Pt.active=q.isVoiceActive(),Pt.manuallyDeactivated=!q.isVoiceActive(),dn(),Pn("user"),q.isVoiceActive()?bs():Io()});return}if(Mt){let y=ee.value.trim();Pt.manuallyDeactivated=!0,dn(),Or("user"),y&&(ee.value="",ee.style.height="auto",q.sendMessage(y))}else Pt.manuallyDeactivated=!1,dn(),fr("user")};qr=ki,K&&(K.addEventListener("click",ki),Tt.push(()=>{var c,g;((g=(c=n.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?(q.isVoiceActive()&&q.toggleVoice(),Io()):Or("system"),K&&K.removeEventListener("click",ki)}));let Jb=a.on("assistant:complete",()=>{ss&&(Pt.active||Pt.manuallyDeactivated||ss==="assistant"&&!Pt.lastUserMessageWasVoice||setTimeout(()=>{var c,g;!Pt.active&&!Pt.manuallyDeactivated&&(((g=(c=n.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?q.toggleVoice().then(()=>{Pt.active=q.isVoiceActive(),Pn("auto"),q.isVoiceActive()&&bs()}):fr("auto"))},600))});Tt.push(Jb);let Yb=a.on("action:resubmit",()=>{setTimeout(()=>{q&&!q.isStreaming()&&q.continueConversation()},100)});Tt.push(Yb);let Ha=()=>{jt(!L,"user")},Ar=null,Sr=null;if(T&&!H()){let c=o.find(g=>g.renderLauncher);if(c!=null&&c.renderLauncher){let g=c.renderLauncher({config:n,defaultRenderer:()=>ni(n,Ha).element,onToggle:Ha});g&&(Sr=g)}Sr||(Ar=ni(n,Ha))}Ar?r.appendChild(Ar.element):Sr&&r.appendChild(Sr),Ro(),Sa(),Xo(),Ra(q.isStreaming()),ut()==="follow"?Zn(!0):fs(),gi(),k&&(!T||H()?setTimeout(()=>Ia(),0):L&&setTimeout(()=>Ia(),200));let ys=()=>{var N,Ce,me,ae,Te,Ve,Se,ct,Qe,ht,xt,Be,Pe,Ke,rt,It,D,Oe,Ue,be,Qt,Gt;if(H()){Mr(),Ro();return}let c=Pr(n),g=(Ce=(N=n.launcher)==null?void 0:N.sidebarMode)!=null?Ce:!1,y=c||g||((ae=(me=n.launcher)==null?void 0:me.fullHeight)!=null?ae:!1),A=(Te=r.ownerDocument.defaultView)!=null?Te:window,W=(Se=(Ve=n.launcher)==null?void 0:Ve.mobileFullscreen)!=null?Se:!0,_=(Qe=(ct=n.launcher)==null?void 0:ct.mobileBreakpoint)!=null?Qe:640,U=A.innerWidth<=_,V=W&&U&&T;try{if(V){Fn(),_o(r,n);return}if(E&&(E=!1,Fn(),_o(r,n)),!T&&!c){he.style.height="",he.style.width="";return}if(!g&&!c){let dr=(xt=(ht=n==null?void 0:n.launcher)==null?void 0:ht.width)!=null?xt:n==null?void 0:n.launcherWidth,Wt=dr!=null?dr:An;he.style.width=Wt,he.style.maxWidth=Wt}if(Kn(),!y){let dr=A.innerHeight,Wt=64,ir=(Pe=(Be=n.launcher)==null?void 0:Be.heightOffset)!=null?Pe:0,bn=Math.max(200,dr-Wt),kr=Math.min(640,bn),ot=Math.max(200,kr-ir);he.style.height=`${ot}px`}}finally{if(Mr(),Ro(),L&&T){let Wt=((Ke=r.ownerDocument.defaultView)!=null?Ke:window).innerWidth<=((It=(rt=n.launcher)==null?void 0:rt.mobileBreakpoint)!=null?It:640),ir=(Oe=(D=n.launcher)==null?void 0:D.sidebarMode)!=null?Oe:!1,bn=(be=(Ue=n.launcher)==null?void 0:Ue.mobileFullscreen)!=null?be:!0,kr=Pr(n)&&bn&&Wt,ot=ir||bn&&Wt&&T||kr;if(ot&&!wr){let _t=r.getRootNode(),Lr=_t instanceof ShadowRoot?_t.host:r.closest(".persona-host");Lr&&!Cr&&(Cr=Qp(Lr,(Gt=(Qt=n.launcher)==null?void 0:Qt.zIndex)!=null?Gt:Xr)),wr=Jp(r.ownerDocument)}else ot||(Cr==null||Cr(),Cr=null,wr==null||wr(),wr=null)}}};ys();let Pu=(Wf=r.ownerDocument.defaultView)!=null?Wf:window;if(Pu.addEventListener("resize",ys),Tt.push(()=>Pu.removeEventListener("resize",ys)),typeof ResizeObserver!="undefined"){let c=new ResizeObserver(()=>{Mr()});c.observe(Ne),Tt.push(()=>c.disconnect())}xn=ue.scrollTop;let Ru=vo(ue),Zb=()=>{let c=ue.getRootNode(),g=typeof c.getSelection=="function"?c.getSelection():null;return g!=null?g:ue.ownerDocument.getSelection()},dd=()=>Cx(Zb(),ue),Iu=()=>{let c=ue.scrollTop,g=vo(ue),y=g<Ru;if(Ru=g,ut()!=="follow"){xn=c,cn();return}let{action:A,nextLastScrollTop:W}=Ll({following:hn.isFollowing(),currentScrollTop:c,lastScrollTop:xn,nearBottom:xa(ue,ka),userScrollThreshold:fi,isAutoScrolling:Un||Vo||y,pauseOnUpwardScroll:!0,pauseWhenAwayFromBottom:!1,resumeRequiresDownwardScroll:!0});if(xn=W,A==="resume"){dd()||Yn();return}A==="pause"&&Pa()};if(ue.addEventListener("scroll",Iu,{passive:!0}),Tt.push(()=>ue.removeEventListener("scroll",Iu)),typeof ResizeObserver!="undefined"){let c=new ResizeObserver(()=>{yi()});c.observe(nt),c.observe(ue),Tt.push(()=>c.disconnect())}let Hu=()=>{ut()==="follow"&&hn.isFollowing()&&dd()&&Pa()},Wu=ue.ownerDocument;Wu.addEventListener("selectionchange",Hu),Tt.push(()=>{Wu.removeEventListener("selectionchange",Hu)});let Bu=c=>{if(ut()!=="follow")return;let g=Pl({following:hn.isFollowing(),deltaY:c.deltaY,nearBottom:xa(ue,ka),resumeWhenNearBottom:!0});g==="pause"?Pa():g==="resume"&&!dd()&&Yn()};ue.addEventListener("wheel",Bu,{passive:!0}),Tt.push(()=>ue.removeEventListener("wheel",Bu)),tt.addEventListener("click",()=>{Go(),ue.scrollTop=ue.scrollHeight,xn=ue.scrollTop,Yn(),Zn(!0),cn()}),Tt.push(()=>tt.remove()),Tt.push(()=>{ls(),Go()});let Du=()=>{F&&(Ln&&(F.removeEventListener("click",Ln),Ln=null),I()?(F.style.display="",Ln=()=>{jt(!1,"user")},F.addEventListener("click",Ln)):F.style.display="none")};Du(),(()=>{let{clearChatButton:c}=Re;c&&c.addEventListener("click",()=>{q.clearMessages(),so.clear(),Yn(),Oo(Re.composerOverlay);try{localStorage.removeItem(ns),n.debug&&console.log(`[AgentWidget] Cleared default localStorage key: ${ns}`)}catch(y){console.error("[AgentWidget] Failed to clear default localStorage:",y)}if(n.clearChatHistoryStorageKey&&n.clearChatHistoryStorageKey!==ns)try{localStorage.removeItem(n.clearChatHistoryStorageKey),n.debug&&console.log(`[AgentWidget] Cleared custom localStorage key: ${n.clearChatHistoryStorageKey}`)}catch(y){console.error("[AgentWidget] Failed to clear custom localStorage:",y)}let g=new CustomEvent("persona:clear-chat",{detail:{timestamp:new Date().toISOString()}});if(window.dispatchEvent(g),i!=null&&i.clear)try{let y=i.clear();y instanceof Promise&&y.catch(A=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",A)})}catch(y){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",y)}d={},S.syncFromMetadata(),ge==null||ge.clear(),Z==null||Z.reset(),G==null||G.update()})})(),Bt&&Bt.addEventListener("submit",B),ee==null||ee.addEventListener("keydown",qt),ee==null||ee.addEventListener("input",lt),ee==null||ee.addEventListener("paste",Ir);let Fu=(Bf=r.ownerDocument)!=null?Bf:document;Fu.addEventListener("keydown",Zt,!0);let Ou="persona-attachment-drop-active",vs=0,cd=()=>{vs=0,j.classList.remove(Ou)},Wa=()=>{var c;return((c=n.attachments)==null?void 0:c.enabled)===!0&&St!==null},Nu=c=>{!rd(c.dataTransfer)||!Wa()||(vs++,vs===1&&j.classList.add(Ou))},_u=c=>{!rd(c.dataTransfer)||!Wa()||(vs--,vs<=0&&cd())},Uu=c=>{!rd(c.dataTransfer)||!Wa()||(c.preventDefault(),c.dataTransfer.dropEffect="copy")},qu=c=>{var y;if(!rd(c.dataTransfer)||!Wa())return;c.preventDefault(),c.stopPropagation(),cd();let g=Array.from((y=c.dataTransfer.files)!=null?y:[]);g.length!==0&&St.handleFiles(g)},Ho=!0;j.addEventListener("dragenter",Nu,Ho),j.addEventListener("dragleave",_u,Ho),r.addEventListener("dragover",Uu,Ho),r.addEventListener("drop",qu,Ho);let Ei=r.ownerDocument,zu=c=>{Wa()&&c.preventDefault()},$u=c=>{Wa()&&c.preventDefault()};Ei.addEventListener("dragover",zu),Ei.addEventListener("drop",$u),Tt.push(()=>{Bt&&Bt.removeEventListener("submit",B),ee==null||ee.removeEventListener("keydown",qt),ee==null||ee.removeEventListener("input",lt),ee==null||ee.removeEventListener("paste",Ir),Fu.removeEventListener("keydown",Zt,!0)}),Tt.push(()=>{j.removeEventListener("dragenter",Nu,Ho),j.removeEventListener("dragleave",_u,Ho),r.removeEventListener("dragover",Uu,Ho),r.removeEventListener("drop",qu,Ho),Ei.removeEventListener("dragover",zu),Ei.removeEventListener("drop",$u),cd()}),Tt.push(()=>{q.cancel()}),Ar?Tt.push(()=>{Ar==null||Ar.destroy()}):Sr&&Tt.push(()=>{Sr==null||Sr.remove()});let Er={update(c){var jr,Jr,eo,Nr,Yr,Zr,ea,Cs,qf,zf,$f,Vf,jf,Gf,Kf,Xf,Qf,Jf,Yf,Zf,em,tm,rm,nm,om,am,sm,im,lm,dm,cm,pm,um,fm,mm,gm,hm,xm,bm,ym,vm,Cm,wm,Am,Sm,Tm,Mm,km,Em,Lm,Pm,Rm,Im,Hm,Wm,Bm,Dm,Fm,Om,Nm,_m,Um,qm,zm,$m,Vm,jm,Gm,Km,Xm,Qm,Jm,Ym,Zm,eg,tg,rg,ng,og,ag,sg,ig,lg,dg,cg,pg,ug,fg,mg,gg,hg,xg,bg,yg,vg,Cg,wg,Ag,Sg,Tg,Mg,kg,Eg,Lg,Pg,Rg,Ig,Hg,Wg,Bg,Dg,Fg,Og,Ng,_g;let g=n.toolCall,y=n.messageActions,A=(jr=n.layout)==null?void 0:jr.messages,W=n.colorScheme,_=n.loadingIndicator,U=n.iterationDisplay,V=(Jr=n.features)==null?void 0:Jr.showReasoning,N=(eo=n.features)==null?void 0:eo.showToolCalls,Ce=(Nr=n.features)==null?void 0:Nr.toolCallDisplay,me=(Yr=n.features)==null?void 0:Yr.reasoningDisplay;n={...n,...c},Fn(),_o(r,n),Gl(r,n),Kl(r,n),mn(),n.colorScheme!==W&&Mo();let ae=li.getForInstance(n.plugins);o.length=0,o.push(...ae),T=(ea=(Zr=n.launcher)==null?void 0:Zr.enabled)!=null?ea:!0,M=(qf=(Cs=n.launcher)==null?void 0:Cs.autoExpand)!=null?qf:!1,Je=($f=(zf=n.features)==null?void 0:zf.showReasoning)!=null?$f:!0,we=(jf=(Vf=n.features)==null?void 0:Vf.showToolCalls)!=null?jf:!0,Ae=(Kf=(Gf=n.features)==null?void 0:Gf.scrollToBottom)!=null?Kf:{};let Te=ut();qe=(Qf=(Xf=n.features)==null?void 0:Xf.scrollBehavior)!=null?Qf:{},Te!==ut()&&(Go(),Yn()),un(),cn();let Ve=De;if(De=(Yf=(Jf=n.features)==null?void 0:Jf.showEventStreamToggle)!=null?Yf:!1,De&&!Ve){if(ge||(re=new si(J),ge=new ai(Q,re),Z=Z!=null?Z:new ii,re.open().then(()=>ge==null?void 0:ge.restore()).catch(()=>{}),q.setSSEEventCallback((Y,Dt)=>{var tr;(tr=n.onSSEEvent)==null||tr.call(n,Y,Dt),Z==null||Z.processEvent(Y,Dt),ge.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:Y,timestamp:Date.now(),payload:JSON.stringify(Dt)})})),!yt&&Fe){let Y=(em=(Zf=n.features)==null?void 0:Zf.eventStream)==null?void 0:em.classNames,Dt="persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1"+(Y!=null&&Y.toggleButton?" "+Y.toggleButton:"");yt=v("button",Dt),yt.style.width="28px",yt.style.height="28px",yt.style.color=an.actionIconColor,yt.type="button",yt.setAttribute("aria-label","Event Stream"),yt.title="Event Stream";let tr=Me("activity","18px","currentColor",1.5);tr&&yt.appendChild(tr);let bt=Re.clearChatButtonWrapper,Ut=Re.closeButtonWrapper,Wr=bt||Ut;Wr&&Wr.parentNode===Fe?Fe.insertBefore(yt,Wr):Fe.appendChild(yt),yt.addEventListener("click",()=>{pe?ln():Mn()})}}else!De&&Ve&&(ln(),yt&&(yt.remove(),yt=null),ge==null||ge.clear(),re==null||re.destroy(),ge=null,re=null,Z==null||Z.reset(),Z=null);if(((tm=n.launcher)==null?void 0:tm.enabled)===!1&&Ar&&(Ar.destroy(),Ar=null),((rm=n.launcher)==null?void 0:rm.enabled)===!1&&Sr&&(Sr.remove(),Sr=null),((nm=n.launcher)==null?void 0:nm.enabled)!==!1&&!Ar&&!Sr){let Y=o.find(Dt=>Dt.renderLauncher);if(Y!=null&&Y.renderLauncher){let Dt=Y.renderLauncher({config:n,defaultRenderer:()=>ni(n,Ha).element,onToggle:Ha});Dt&&(Sr=Dt,r.appendChild(Sr))}Sr||(Ar=ni(n,Ha),r.appendChild(Ar.element))}Ar&&Ar.update(n),Ie&&((om=n.launcher)==null?void 0:om.title)!==void 0&&(Ie.textContent=n.launcher.title),Xe&&((am=n.launcher)==null?void 0:am.subtitle)!==void 0&&(Xe.textContent=n.launcher.subtitle);let Se=(sm=n.layout)==null?void 0:sm.header;if((Se==null?void 0:Se.layout)!==w&&Fe){let Y=Se?Qa(n,Se,{showClose:I(),onClose:()=>jt(!1,"user")}):Co({config:n,showClose:I(),onClose:()=>jt(!1,"user")});Fe.replaceWith(Y.header),Fe=Y.header,fe=Y.iconHolder,Ie=Y.headerTitle,Xe=Y.headerSubtitle,F=Y.closeButton,w=Se==null?void 0:Se.layout}else if(Se&&(fe&&(fe.style.display=Se.showIcon===!1?"none":""),Ie&&(Ie.style.display=Se.showTitle===!1?"none":""),Xe&&(Xe.style.display=Se.showSubtitle===!1?"none":""),F&&(F.style.display=Se.showCloseButton===!1?"none":""),Re.clearChatButtonWrapper)){let Y=Se.showClearChat;if(Y!==void 0){Re.clearChatButtonWrapper.style.display=Y?"":"none";let{closeButtonWrapper:Dt}=Re;Dt&&!Dt.classList.contains("persona-absolute")&&(Y?Dt.classList.remove("persona-ml-auto"):Dt.classList.add("persona-ml-auto"))}}let Qe=((im=n.layout)==null?void 0:im.showHeader)!==!1;Fe&&(Fe.style.display=Qe?"":"none");let ht=((lm=n.layout)==null?void 0:lm.showFooter)!==!1;Ne&&(Ne.style.display=ht?"":"none"),Mr(),cn(),T!==C?T?jt(M,"auto"):(L=!0,Ro()):M!==x&&jt(M,"auto"),x=M,C=T,ys(),Du();let Pe=JSON.stringify(c.toolCall)!==JSON.stringify(g),Ke=JSON.stringify(n.messageActions)!==JSON.stringify(y),rt=JSON.stringify((dm=n.layout)==null?void 0:dm.messages)!==JSON.stringify(A),It=((cm=n.loadingIndicator)==null?void 0:cm.render)!==(_==null?void 0:_.render)||((pm=n.loadingIndicator)==null?void 0:pm.renderIdle)!==(_==null?void 0:_.renderIdle)||((um=n.loadingIndicator)==null?void 0:um.showBubble)!==(_==null?void 0:_.showBubble),D=n.iterationDisplay!==U,Oe=((mm=(fm=n.features)==null?void 0:fm.showReasoning)!=null?mm:!0)!==(V!=null?V:!0)||((hm=(gm=n.features)==null?void 0:gm.showToolCalls)!=null?hm:!0)!==(N!=null?N:!0)||JSON.stringify((xm=n.features)==null?void 0:xm.toolCallDisplay)!==JSON.stringify(Ce)||JSON.stringify((bm=n.features)==null?void 0:bm.reasoningDisplay)!==JSON.stringify(me);(Pe||Ke||rt||It||D||Oe)&&q&&(as++,Ko(nt,q.getMessages(),xe));let be=(ym=n.launcher)!=null?ym:{},Qt=(vm=be.headerIconHidden)!=null?vm:!1,Gt=(wm=(Cm=n.layout)==null?void 0:Cm.header)==null?void 0:wm.showIcon,dr=Qt||Gt===!1,Wt=be.headerIconName,ir=(Am=be.headerIconSize)!=null?Am:"48px";if(fe){let Y=j.querySelector(".persona-border-b-persona-divider"),Dt=Y==null?void 0:Y.querySelector(".persona-flex-col");if(dr)fe.style.display="none",Y&&Dt&&!Y.contains(Dt)&&Y.insertBefore(Dt,Y.firstChild);else{if(fe.style.display="",fe.style.height=ir,fe.style.width=ir,Y&&Dt&&(Y.contains(fe)?fe.nextSibling!==Dt&&(fe.remove(),Y.insertBefore(fe,Dt)):Y.insertBefore(fe,Dt)),Wt){let bt=parseFloat(ir)||24,Ut=Me(Wt,bt*.6,"#ffffff",2);Ut?fe.replaceChildren(Ut):fe.textContent=(Sm=be.agentIconText)!=null?Sm:"\u{1F4AC}"}else if(be.iconUrl){let bt=fe.querySelector("img");if(bt)bt.src=be.iconUrl,bt.style.height=ir,bt.style.width=ir;else{let Ut=document.createElement("img");Ut.src=be.iconUrl,Ut.alt="",Ut.className="persona-rounded-xl persona-object-cover",Ut.style.height=ir,Ut.style.width=ir,fe.replaceChildren(Ut)}}else{let bt=fe.querySelector("svg"),Ut=fe.querySelector("img");(bt||Ut)&&fe.replaceChildren(),fe.textContent=(Tm=be.agentIconText)!=null?Tm:"\u{1F4AC}"}let tr=fe.querySelector("img");tr&&(tr.style.height=ir,tr.style.width=ir)}}let bn=(km=(Mm=n.layout)==null?void 0:Mm.header)==null?void 0:km.showTitle,kr=(Lm=(Em=n.layout)==null?void 0:Em.header)==null?void 0:Lm.showSubtitle;if(Ie&&(Ie.style.display=bn===!1?"none":""),Xe&&(Xe.style.display=kr===!1?"none":""),F){((Rm=(Pm=n.layout)==null?void 0:Pm.header)==null?void 0:Rm.showCloseButton)===!1?F.style.display="none":F.style.display="";let Dt=(Im=be.closeButtonSize)!=null?Im:"32px",tr=(Hm=be.closeButtonPlacement)!=null?Hm:"inline";F.style.height=Dt,F.style.width=Dt;let{closeButtonWrapper:bt}=Re,Ut=tr==="top-right",Wr=bt==null?void 0:bt.classList.contains("persona-absolute");if(bt&&Ut!==Wr)if(bt.remove(),Ut)bt.className="persona-absolute persona-top-4 persona-right-4 persona-z-50",j.style.position="relative",j.appendChild(bt);else{let Ct=(Bm=(Wm=be.clearChat)==null?void 0:Wm.placement)!=null?Bm:"inline",Br=(Fm=(Dm=be.clearChat)==null?void 0:Dm.enabled)!=null?Fm:!0;bt.className=Br&&Ct==="inline"?"":"persona-ml-auto";let pn=j.querySelector(".persona-border-b-persona-divider");pn&&pn.appendChild(bt)}if(F.style.color=be.closeButtonColor||an.actionIconColor,be.closeButtonBackgroundColor?(F.style.backgroundColor=be.closeButtonBackgroundColor,F.classList.remove("hover:persona-bg-gray-100")):(F.style.backgroundColor="",F.classList.add("hover:persona-bg-gray-100")),be.closeButtonBorderWidth||be.closeButtonBorderColor){let Ct=be.closeButtonBorderWidth||"0px",Br=be.closeButtonBorderColor||"transparent";F.style.border=`${Ct} solid ${Br}`,F.classList.remove("persona-border-none")}else F.style.border="",F.classList.add("persona-border-none");be.closeButtonBorderRadius?(F.style.borderRadius=be.closeButtonBorderRadius,F.classList.remove("persona-rounded-full")):(F.style.borderRadius="",F.classList.add("persona-rounded-full")),be.closeButtonPaddingX?(F.style.paddingLeft=be.closeButtonPaddingX,F.style.paddingRight=be.closeButtonPaddingX):(F.style.paddingLeft="",F.style.paddingRight=""),be.closeButtonPaddingY?(F.style.paddingTop=be.closeButtonPaddingY,F.style.paddingBottom=be.closeButtonPaddingY):(F.style.paddingTop="",F.style.paddingBottom="");let Gr=(Om=be.closeButtonIconName)!=null?Om:"x",zn=(Nm=be.closeButtonIconText)!=null?Nm:"\xD7";F.innerHTML="";let en=Me(Gr,"28px","currentColor",1);en?F.appendChild(en):F.textContent=zn;let Tr=(_m=be.closeButtonTooltipText)!=null?_m:"Close chat",vn=(Um=be.closeButtonShowTooltip)!=null?Um:!0;if(F.setAttribute("aria-label",Tr),bt&&(bt._cleanupTooltip&&(bt._cleanupTooltip(),delete bt._cleanupTooltip),vn&&Tr)){let Ct=null,Br=()=>{if(Ct||!F)return;let ta=F.ownerDocument,ws=ta.body;if(!ws)return;Ct=ro(ta,"div","persona-clear-chat-tooltip"),Ct.textContent=Tr;let As=ro(ta,"div");As.className="persona-clear-chat-tooltip-arrow",Ct.appendChild(As);let ra=F.getBoundingClientRect();Ct.style.position="fixed",Ct.style.zIndex=String(Uo),Ct.style.left=`${ra.left+ra.width/2}px`,Ct.style.top=`${ra.top-8}px`,Ct.style.transform="translate(-50%, -100%)",ws.appendChild(Ct)},pn=()=>{Ct&&Ct.parentNode&&(Ct.parentNode.removeChild(Ct),Ct=null)};bt.addEventListener("mouseenter",Br),bt.addEventListener("mouseleave",pn),F.addEventListener("focus",Br),F.addEventListener("blur",pn),bt._cleanupTooltip=()=>{pn(),bt&&(bt.removeEventListener("mouseenter",Br),bt.removeEventListener("mouseleave",pn)),F&&(F.removeEventListener("focus",Br),F.removeEventListener("blur",pn))}}}let{clearChatButton:ot,clearChatButtonWrapper:_t}=Re;if(ot){let Y=(qm=be.clearChat)!=null?qm:{},Dt=(zm=Y.enabled)!=null?zm:!0,tr=(Vm=($m=n.layout)==null?void 0:$m.header)==null?void 0:Vm.showClearChat,bt=tr!==void 0?tr:Dt,Ut=(jm=Y.placement)!=null?jm:"inline";if(_t){_t.style.display=bt?"":"none";let{closeButtonWrapper:Wr}=Re;!H()&&Wr&&!Wr.classList.contains("persona-absolute")&&(bt?Wr.classList.remove("persona-ml-auto"):Wr.classList.add("persona-ml-auto"));let Gr=Ut==="top-right",zn=_t.classList.contains("persona-absolute");if(!H()&&Gr!==zn&&bt){if(_t.remove(),Gr)_t.className="persona-absolute persona-top-4 persona-z-50",_t.style.right="48px",j.style.position="relative",j.appendChild(_t);else{_t.className="persona-relative persona-ml-auto persona-clear-chat-button-wrapper",_t.style.right="";let Tr=j.querySelector(".persona-border-b-persona-divider"),vn=Re.closeButtonWrapper;Tr&&vn&&vn.parentElement===Tr?Tr.insertBefore(_t,vn):Tr&&Tr.appendChild(_t)}let en=Re.closeButtonWrapper;en&&!en.classList.contains("persona-absolute")&&(Gr?en.classList.add("persona-ml-auto"):en.classList.remove("persona-ml-auto"))}}if(bt){if(!H()){let Ct=(Gm=Y.size)!=null?Gm:"32px";ot.style.height=Ct,ot.style.width=Ct}let Wr=(Km=Y.iconName)!=null?Km:"refresh-cw",Gr=(Xm=Y.iconColor)!=null?Xm:"";ot.style.color=Gr||an.actionIconColor,ot.innerHTML="";let zn=H()?"14px":"20px",en=Me(Wr,zn,"currentColor",2);if(en&&ot.appendChild(en),Y.backgroundColor?(ot.style.backgroundColor=Y.backgroundColor,ot.classList.remove("hover:persona-bg-gray-100")):(ot.style.backgroundColor="",ot.classList.add("hover:persona-bg-gray-100")),Y.borderWidth||Y.borderColor){let Ct=Y.borderWidth||"0px",Br=Y.borderColor||"transparent";ot.style.border=`${Ct} solid ${Br}`,ot.classList.remove("persona-border-none")}else ot.style.border="",ot.classList.add("persona-border-none");Y.borderRadius?(ot.style.borderRadius=Y.borderRadius,ot.classList.remove("persona-rounded-full")):(ot.style.borderRadius="",ot.classList.add("persona-rounded-full")),Y.paddingX?(ot.style.paddingLeft=Y.paddingX,ot.style.paddingRight=Y.paddingX):(ot.style.paddingLeft="",ot.style.paddingRight=""),Y.paddingY?(ot.style.paddingTop=Y.paddingY,ot.style.paddingBottom=Y.paddingY):(ot.style.paddingTop="",ot.style.paddingBottom="");let Tr=(Qm=Y.tooltipText)!=null?Qm:"Clear chat",vn=(Jm=Y.showTooltip)!=null?Jm:!0;if(ot.setAttribute("aria-label",Tr),_t&&(_t._cleanupTooltip&&(_t._cleanupTooltip(),delete _t._cleanupTooltip),vn&&Tr)){let Ct=null,Br=()=>{if(Ct||!ot)return;let ta=ot.ownerDocument,ws=ta.body;if(!ws)return;Ct=ro(ta,"div","persona-clear-chat-tooltip"),Ct.textContent=Tr;let As=ro(ta,"div");As.className="persona-clear-chat-tooltip-arrow",Ct.appendChild(As);let ra=ot.getBoundingClientRect();Ct.style.position="fixed",Ct.style.zIndex=String(Uo),Ct.style.left=`${ra.left+ra.width/2}px`,Ct.style.top=`${ra.top-8}px`,Ct.style.transform="translate(-50%, -100%)",ws.appendChild(Ct)},pn=()=>{Ct&&Ct.parentNode&&(Ct.parentNode.removeChild(Ct),Ct=null)};_t.addEventListener("mouseenter",Br),_t.addEventListener("mouseleave",pn),ot.addEventListener("focus",Br),ot.addEventListener("blur",pn),_t._cleanupTooltip=()=>{pn(),_t&&(_t.removeEventListener("mouseenter",Br),_t.removeEventListener("mouseleave",pn)),ot&&(ot.removeEventListener("focus",Br),ot.removeEventListener("blur",pn))}}}}let Lr=n.actionParsers&&n.actionParsers.length?n.actionParsers:[di],In=n.actionHandlers&&n.actionHandlers.length?n.actionHandlers:[wa.message,wa.messageAndClick];S=ci({parsers:Lr,handlers:In,getSessionMetadata:p,updateSessionMetadata:f,emit:a.emit,documentRef:typeof document!="undefined"?document:null}),xe=ib(n,S,te),q.updateConfig(n),Ko(nt,q.getMessages(),xe),Sa(),Xo(),Ra(q.isStreaming());let yn=((Ym=n.voiceRecognition)==null?void 0:Ym.enabled)===!0,Qo=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),Jo=((eg=(Zm=n.voiceRecognition)==null?void 0:Zm.provider)==null?void 0:eg.type)==="runtype";if(yn&&(Qo||Jo))if(!K||!mt){let Y=Kb(n.voiceRecognition,n.sendButton);Y&&(K=Y.micButton,mt=Y.micButtonWrapper,Xt.insertBefore(mt,Fr),K.addEventListener("click",ki),K.disabled=q.isStreaming())}else{let Y=(tg=n.voiceRecognition)!=null?tg:{},Dt=(rg=n.sendButton)!=null?rg:{},tr=(ng=Y.iconName)!=null?ng:"mic",bt=(og=Dt.size)!=null?og:"40px",Ut=(ag=Y.iconSize)!=null?ag:bt,Wr=parseFloat(Ut)||24;K.style.width=Ut,K.style.height=Ut,K.style.minWidth=Ut,K.style.minHeight=Ut;let Gr=(ig=(sg=Y.iconColor)!=null?sg:Dt.textColor)!=null?ig:"currentColor";K.innerHTML="";let zn=Me(tr,Wr,Gr,2);zn?K.appendChild(zn):K.textContent="\u{1F3A4}";let en=(lg=Y.backgroundColor)!=null?lg:Dt.backgroundColor;en?K.style.backgroundColor=en:K.style.backgroundColor="",Gr?K.style.color=Gr:K.style.color="var(--persona-text, #111827)",Y.borderWidth?(K.style.borderWidth=Y.borderWidth,K.style.borderStyle="solid"):(K.style.borderWidth="",K.style.borderStyle=""),Y.borderColor?K.style.borderColor=Y.borderColor:K.style.borderColor="",Y.paddingX?(K.style.paddingLeft=Y.paddingX,K.style.paddingRight=Y.paddingX):(K.style.paddingLeft="",K.style.paddingRight=""),Y.paddingY?(K.style.paddingTop=Y.paddingY,K.style.paddingBottom=Y.paddingY):(K.style.paddingTop="",K.style.paddingBottom="");let Tr=mt==null?void 0:mt.querySelector(".persona-send-button-tooltip"),vn=(dg=Y.tooltipText)!=null?dg:"Start voice recognition";if(((cg=Y.showTooltip)!=null?cg:!1)&&vn)if(Tr)Tr.textContent=vn,Tr.style.display="";else{let Br=document.createElement("div");Br.className="persona-send-button-tooltip",Br.textContent=vn,mt==null||mt.insertBefore(Br,K)}else Tr&&(Tr.style.display="none");mt.style.display="",K.disabled=q.isStreaming()}else K&&mt&&(mt.style.display="none",((ug=(pg=n.voiceRecognition)==null?void 0:pg.provider)==null?void 0:ug.type)==="runtype"?q.isVoiceActive()&&q.toggleVoice():Mt&&Or());if(((fg=n.attachments)==null?void 0:fg.enabled)===!0)if(!ye||!it){let Y=(mg=n.attachments)!=null?mg:{},tr=(hg=((gg=n.sendButton)!=null?gg:{}).size)!=null?hg:"40px";st||(st=v("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2"),st.style.display="none",Bt.insertBefore(st,ee)),ie||(ie=document.createElement("input"),ie.type="file",ie.accept=((xg=Y.allowedTypes)!=null?xg:yo).join(","),ie.multiple=((bg=Y.maxFiles)!=null?bg:4)>1,ie.style.display="none",ie.setAttribute("aria-label","Attach files"),Bt.insertBefore(ie,ee)),ye=v("div","persona-send-button-wrapper"),it=v("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button"),it.type="button",it.setAttribute("aria-label",(yg=Y.buttonTooltipText)!=null?yg:"Attach file");let bt=(vg=Y.buttonIconName)!=null?vg:"paperclip",Ut=tr,Wr=parseFloat(Ut)||40,Gr=Math.round(Wr*.6);it.style.width=Ut,it.style.height=Ut,it.style.minWidth=Ut,it.style.minHeight=Ut,it.style.fontSize="18px",it.style.lineHeight="1",it.style.backgroundColor="transparent",it.style.color="var(--persona-primary, #111827)",it.style.border="none",it.style.borderRadius="6px",it.style.transition="background-color 0.15s ease",it.addEventListener("mouseenter",()=>{it.style.backgroundColor="var(--persona-palette-colors-black-alpha-50, rgba(0, 0, 0, 0.05))"}),it.addEventListener("mouseleave",()=>{it.style.backgroundColor="transparent"});let zn=Me(bt,Gr,"currentColor",1.5);zn?it.appendChild(zn):it.textContent="\u{1F4CE}",it.addEventListener("click",vn=>{vn.preventDefault(),ie==null||ie.click()}),ye.appendChild(it);let en=(Cg=Y.buttonTooltipText)!=null?Cg:"Attach file",Tr=v("div","persona-send-button-tooltip");Tr.textContent=en,ye.appendChild(Tr),At.append(ye),!St&&ie&&st&&(St=ha.fromConfig(Y),St.setPreviewsContainer(st),ie.addEventListener("change",async()=>{St&&(ie!=null&&ie.files)&&(await St.handleFileSelect(ie.files),ie.value="")})),j.querySelector(".persona-attachment-drop-overlay")||j.appendChild(lb(Y.dropOverlay))}else{ye.style.display="";let Y=(wg=n.attachments)!=null?wg:{};ie&&(ie.accept=((Ag=Y.allowedTypes)!=null?Ag:yo).join(","),ie.multiple=((Sg=Y.maxFiles)!=null?Sg:4)>1),St&&St.updateConfig({allowedTypes:Y.allowedTypes,maxFileSize:Y.maxFileSize,maxFiles:Y.maxFiles})}else ye&&(ye.style.display="none"),St&&St.clearAttachments(),(Tg=j.querySelector(".persona-attachment-drop-overlay"))==null||Tg.remove();let mr=(Mg=n.sendButton)!=null?Mg:{},Yo=(kg=mr.useIcon)!=null?kg:!1,Wo=(Eg=mr.iconText)!=null?Eg:"\u2191",Bo=mr.iconName,uo=(Lg=mr.tooltipText)!=null?Lg:"Send message",Zo=(Pg=mr.showTooltip)!=null?Pg:!1,qn=(Rg=mr.size)!=null?Rg:"40px",dt=mr.backgroundColor,Hr=mr.textColor;if(Yo){if(Ge.style.width=qn,Ge.style.height=qn,Ge.style.minWidth=qn,Ge.style.minHeight=qn,Ge.style.fontSize="18px",Ge.style.lineHeight="1",Ge.innerHTML="",Hr?Ge.style.color=Hr:Ge.style.color="var(--persona-button-primary-fg, #ffffff)",Bo){let Y=parseFloat(qn)||24,Dt=(Hr==null?void 0:Hr.trim())||"currentColor",tr=Me(Bo,Y,Dt,2);tr?Ge.appendChild(tr):Ge.textContent=Wo}else Ge.textContent=Wo;Ge.className="persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer",dt?(Ge.style.backgroundColor=dt,Ge.classList.remove("persona-bg-persona-primary")):(Ge.style.backgroundColor="",Ge.classList.add("persona-bg-persona-primary"))}else Ge.textContent=(Hg=(Ig=n.copy)==null?void 0:Ig.sendButtonLabel)!=null?Hg:"Send",Ge.style.width="",Ge.style.height="",Ge.style.minWidth="",Ge.style.minHeight="",Ge.style.fontSize="",Ge.style.lineHeight="",Ge.className="persona-rounded-button persona-bg-persona-accent persona-px-4 persona-py-2 persona-text-sm persona-font-semibold persona-text-white disabled:persona-opacity-50 persona-cursor-pointer",dt?(Ge.style.backgroundColor=dt,Ge.classList.remove("persona-bg-persona-accent")):Ge.classList.add("persona-bg-persona-accent"),Hr?Ge.style.color=Hr:Ge.classList.add("persona-text-white");mr.borderWidth?(Ge.style.borderWidth=mr.borderWidth,Ge.style.borderStyle="solid"):(Ge.style.borderWidth="",Ge.style.borderStyle=""),mr.borderColor?Ge.style.borderColor=mr.borderColor:Ge.style.borderColor="",mr.paddingX?(Ge.style.paddingLeft=mr.paddingX,Ge.style.paddingRight=mr.paddingX):(Ge.style.paddingLeft="",Ge.style.paddingRight=""),mr.paddingY?(Ge.style.paddingTop=mr.paddingY,Ge.style.paddingBottom=mr.paddingY):(Ge.style.paddingTop="",Ge.style.paddingBottom="");let er=Fr==null?void 0:Fr.querySelector(".persona-send-button-tooltip");if(Zo&&uo)if(er)er.textContent=uo,er.style.display="";else{let Y=document.createElement("div");Y.className="persona-send-button-tooltip",Y.textContent=uo,Fr==null||Fr.insertBefore(Y,Ge)}else er&&(er.style.display="none");let Jt=(Og=(Wg=n.layout)==null?void 0:Wg.contentMaxWidth)!=null?Og:H()?(Fg=(Dg=(Bg=n.launcher)==null?void 0:Bg.composerBar)==null?void 0:Dg.contentMaxWidth)!=null?Fg:"720px":void 0;Jt?(nt.style.maxWidth=Jt,nt.style.marginLeft="auto",nt.style.marginRight="auto",nt.style.width="100%",Bt&&(Bt.style.maxWidth=Jt,Bt.style.marginLeft="auto",Bt.style.marginRight="auto"),Rt&&(Rt.style.maxWidth=Jt,Rt.style.marginLeft="auto",Rt.style.marginRight="auto")):(nt.style.maxWidth="",nt.style.marginLeft="",nt.style.marginRight="",nt.style.width="",Bt&&(Bt.style.maxWidth="",Bt.style.marginLeft="",Bt.style.marginRight=""),Rt&&(Rt.style.maxWidth="",Rt.style.marginLeft="",Rt.style.marginRight=""));let kt=(Ng=n.statusIndicator)!=null?Ng:{},gr=(_g=kt.visible)!=null?_g:!0;if(or.style.display=gr?"":"none",q){let Y=q.getStatus();wt(or,(tr=>{var bt,Ut,Wr,Gr;return tr==="idle"?(bt=kt.idleText)!=null?bt:Kr.idle:tr==="connecting"?(Ut=kt.connectingText)!=null?Ut:Kr.connecting:tr==="connected"?(Wr=kt.connectedText)!=null?Wr:Kr.connected:tr==="error"?(Gr=kt.errorText)!=null?Gr:Kr.error:Kr[tr]})(Y),kt,Y)}or.classList.remove("persona-text-left","persona-text-center","persona-text-right");let Ft=kt.align==="left"?"persona-text-left":kt.align==="center"?"persona-text-center":"persona-text-right";or.classList.add(Ft)},open(){I()&&jt(!0,"api")},close(){I()&&jt(!1,"api")},toggle(){I()&&jt(!L,"api")},clearChat(){lr=!1,q.clearMessages(),so.clear(),Yn();try{localStorage.removeItem(ns),n.debug&&console.log(`[AgentWidget] Cleared default localStorage key: ${ns}`)}catch(g){console.error("[AgentWidget] Failed to clear default localStorage:",g)}if(n.clearChatHistoryStorageKey&&n.clearChatHistoryStorageKey!==ns)try{localStorage.removeItem(n.clearChatHistoryStorageKey),n.debug&&console.log(`[AgentWidget] Cleared custom localStorage key: ${n.clearChatHistoryStorageKey}`)}catch(g){console.error("[AgentWidget] Failed to clear custom localStorage:",g)}let c=new CustomEvent("persona:clear-chat",{detail:{timestamp:new Date().toISOString()}});if(window.dispatchEvent(c),i!=null&&i.clear)try{let g=i.clear();g instanceof Promise&&g.catch(y=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",y)})}catch(g){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",g)}d={},S.syncFromMetadata(),ge==null||ge.clear(),Z==null||Z.reset(),G==null||G.update()},setMessage(c){return!ee||q.isStreaming()?!1:(!L&&I()&&jt(!0,"system"),ee.value=c,ee.dispatchEvent(new Event("input",{bubbles:!0})),!0)},submitMessage(c){if(q.isStreaming())return!1;let g=(c==null?void 0:c.trim())||ee.value.trim();return g?(!L&&I()&&jt(!0,"system"),ee.value="",ee.style.height="auto",q.sendMessage(g),!0):!1},startVoiceRecognition(){var g,y;return q.isStreaming()?!1:((y=(g=n.voiceRecognition)==null?void 0:g.provider)==null?void 0:y.type)==="runtype"?(q.isVoiceActive()||(!L&&I()&&jt(!0,"system"),Pt.manuallyDeactivated=!1,dn(),q.toggleVoice().then(()=>{Pt.active=q.isVoiceActive(),Pn("user"),q.isVoiceActive()&&bs()})),!0):Mt?!0:_r()?(!L&&I()&&jt(!0,"system"),Pt.manuallyDeactivated=!1,dn(),fr("user"),!0):!1},stopVoiceRecognition(){var c,g;return((g=(c=n.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?q.isVoiceActive()?(q.toggleVoice().then(()=>{Pt.active=!1,Pt.manuallyDeactivated=!0,dn(),Pn("user"),Io()}),!0):!1:Mt?(Pt.manuallyDeactivated=!0,dn(),Or("user"),!0):!1},injectMessage(c){return!L&&I()&&jt(!0,"system"),q.injectMessage(c)},injectAssistantMessage(c){!L&&I()&&jt(!0,"system");let g=q.injectAssistantMessage(c);return O&&(O=!1,$&&(clearTimeout($),$=null),setTimeout(()=>{q&&!q.isStreaming()&&q.continueConversation()},100)),g},injectUserMessage(c){return!L&&I()&&jt(!0,"system"),q.injectUserMessage(c)},injectSystemMessage(c){return!L&&I()&&jt(!0,"system"),q.injectSystemMessage(c)},injectMessageBatch(c){return!L&&I()&&jt(!0,"system"),q.injectMessageBatch(c)},injectComponentDirective(c){return!L&&I()&&jt(!0,"system"),q.injectComponentDirective(c)},injectTestMessage(c){!L&&I()&&jt(!0,"system"),q.injectTestEvent(c)},async connectStream(c,g){return q.connectStream(c,g)},__pushEventStreamEvent(c){ge&&(Z==null||Z.processEvent(c.type,c.payload),ge.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:c.type,timestamp:Date.now(),payload:JSON.stringify(c.payload)}))},showEventStream(){!De||!ge||Mn()},hideEventStream(){pe&&ln()},isEventStreamVisible(){return pe},showArtifacts(){Bn(n)&&(lr=!1,mn(),et==null||et.setMobileOpen(!0))},hideArtifacts(){Bn(n)&&(lr=!0,mn())},upsertArtifact(c){return Bn(n)?(lr=!1,q.upsertArtifact(c)):null},selectArtifact(c){Bn(n)&&q.selectArtifact(c)},clearArtifacts(){Bn(n)&&q.clearArtifacts()},getArtifacts(){var c;return(c=q==null?void 0:q.getArtifacts())!=null?c:[]},getSelectedArtifactId(){var c;return(c=q==null?void 0:q.getSelectedArtifactId())!=null?c:null},focusInput(){return T&&!L&&!H()||!ee?!1:(ee.focus(),!0)},async resolveApproval(c,g,y){let W=q.getMessages().find(_=>{var U;return _.variant==="approval"&&((U=_.approval)==null?void 0:U.id)===c});if(!(W!=null&&W.approval))throw new Error(`Approval not found: ${c}`);if(W.approval.toolType==="webmcp"){q.resolveWebMcpApproval(W.id,g);return}return q.resolveApproval(W.approval,g,y)},getMessages(){return q.getMessages()},getStatus(){return q.getStatus()},getPersistentMetadata(){return{...d}},updatePersistentMetadata(c){f(c)},on(c,g){return a.on(c,g)},off(c,g){a.off(c,g)},isOpen(){return I()&&L},isVoiceActive(){return Pt.active},getState(){return{open:I()&&L,launcherEnabled:T,voiceActive:Pt.active,streaming:q.isStreaming()}},showCSATFeedback(c){!L&&I()&&jt(!0,"system");let g=nt.querySelector(".persona-feedback-container");g&&g.remove();let y=ed({onSubmit:async(A,W)=>{var _;q.isClientTokenMode()&&await q.submitCSATFeedback(A,W),(_=c==null?void 0:c.onSubmit)==null||_.call(c,A,W)},onDismiss:c==null?void 0:c.onDismiss,...c});nt.appendChild(y),y.scrollIntoView({behavior:"smooth",block:"end"})},showNPSFeedback(c){!L&&I()&&jt(!0,"system");let g=nt.querySelector(".persona-feedback-container");g&&g.remove();let y=td({onSubmit:async(A,W)=>{var _;q.isClientTokenMode()&&await q.submitNPSFeedback(A,W),(_=c==null?void 0:c.onSubmit)==null||_.call(c,A,W)},onDismiss:c==null?void 0:c.onDismiss,...c});nt.appendChild(y),y.scrollIntoView({behavior:"smooth",block:"end"})},async submitCSATFeedback(c,g){return q.submitCSATFeedback(c,g)},async submitNPSFeedback(c,g){return q.submitNPSFeedback(c,g)},destroy(){je!=null&&(clearInterval(je),je=null),Tt.forEach(c=>c()),We.remove(),at==null||at.remove(),Ar==null||Ar.destroy(),Sr==null||Sr.remove(),Ln&&F.removeEventListener("click",Ln)}};if((((Df=t==null?void 0:t.debugTools)!=null?Df:!1)||!!n.debug)&&typeof window!="undefined"){let c=window.AgentWidgetBrowser,g={controller:Er,getMessages:Er.getMessages,getStatus:Er.getStatus,getMetadata:Er.getPersistentMetadata,updateMetadata:Er.updatePersistentMetadata,clearHistory:()=>Er.clearChat(),setVoiceActive:y=>y?Er.startVoiceRecognition():Er.stopVoiceRecognition()};window.AgentWidgetBrowser=g,Tt.push(()=>{window.AgentWidgetBrowser===g&&(window.AgentWidgetBrowser=c)})}if(typeof window!="undefined"){let c=r.getAttribute("data-persona-instance")||r.id||"persona-"+Math.random().toString(36).slice(2,8),g=V=>{let N=V.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Er.focusInput()};if(window.addEventListener("persona:focusInput",g),Tt.push(()=>{window.removeEventListener("persona:focusInput",g)}),De){let V=Ce=>{let me=Ce.detail;(!(me!=null&&me.instanceId)||me.instanceId===c)&&Er.showEventStream()},N=Ce=>{let me=Ce.detail;(!(me!=null&&me.instanceId)||me.instanceId===c)&&Er.hideEventStream()};window.addEventListener("persona:showEventStream",V),window.addEventListener("persona:hideEventStream",N),Tt.push(()=>{window.removeEventListener("persona:showEventStream",V),window.removeEventListener("persona:hideEventStream",N)})}let y=V=>{let N=V.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Er.showArtifacts()},A=V=>{let N=V.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Er.hideArtifacts()},W=V=>{let N=V.detail;N!=null&&N.instanceId&&N.instanceId!==c||N!=null&&N.artifact&&Er.upsertArtifact(N.artifact)},_=V=>{let N=V.detail;N!=null&&N.instanceId&&N.instanceId!==c||typeof(N==null?void 0:N.id)=="string"&&Er.selectArtifact(N.id)},U=V=>{let N=V.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Er.clearArtifacts()};window.addEventListener("persona:showArtifacts",y),window.addEventListener("persona:hideArtifacts",A),window.addEventListener("persona:upsertArtifact",W),window.addEventListener("persona:selectArtifact",_),window.addEventListener("persona:clearArtifacts",U),Tt.push(()=>{window.removeEventListener("persona:showArtifacts",y),window.removeEventListener("persona:hideArtifacts",A),window.removeEventListener("persona:upsertArtifact",W),window.removeEventListener("persona:selectArtifact",_),window.removeEventListener("persona:clearArtifacts",U)})}let Rn=WC(n.persistState);if(Rn&&I()){let c=BC(Rn.storage),g=`${Rn.keyPrefix}widget-open`,y=`${Rn.keyPrefix}widget-voice`,A=`${Rn.keyPrefix}widget-voice-mode`;if(c){let W=((Ff=Rn.persist)==null?void 0:Ff.openState)&&c.getItem(g)==="true",_=((Of=Rn.persist)==null?void 0:Of.voiceState)&&c.getItem(y)==="true",U=((Nf=Rn.persist)==null?void 0:Nf.voiceState)&&c.getItem(A)==="true";if(W&&setTimeout(()=>{Er.open(),setTimeout(()=>{var V;if(_||U)Er.startVoiceRecognition();else if((V=Rn.persist)!=null&&V.focusInput){let N=r.querySelector("textarea");N&&N.focus()}},100)},0),(_f=Rn.persist)!=null&&_f.openState&&(a.on("widget:opened",()=>{c.setItem(g,"true")}),a.on("widget:closed",()=>{c.setItem(g,"false")})),(Uf=Rn.persist)!=null&&Uf.voiceState&&(a.on("voice:state",V=>{c.setItem(y,V.active?"true":"false")}),a.on("user:message",V=>{c.setItem(A,V.viaVoice?"true":"false")})),Rn.clearOnChatClear){let V=()=>{c.removeItem(g),c.removeItem(y),c.removeItem(A)},N=()=>V();window.addEventListener("persona:clear-chat",N),Tt.push(()=>{window.removeEventListener("persona:clear-chat",N)})}}}return u&&I()&&setTimeout(()=>{Er.open()},0),po(),Er};var DC=(r,e)=>{let t=r.trim(),n=/^(\d+(?:\.\d+)?)px$/i.exec(t);if(n)return Math.max(0,parseFloat(n[1]));let o=/^(\d+(?:\.\d+)?)%$/i.exec(t);return o?Math.max(0,e*parseFloat(o[1])/100):420},FC=(r,e)=>{if(e===!1){r.style.maxHeight="";return}r.style.maxHeight="100vh",r.style.maxHeight=e},OC=(r,e)=>{e===!1?(r.style.position="relative",r.style.top=""):(r.style.position="sticky",r.style.top="0")},NC=(r,e)=>{let t=r.parentElement;if(!t)return;let n=r.ownerDocument.createElement("div");n.style.cssText="width:0;height:1px;margin:0;padding:0;border:0;visibility:hidden;",t.appendChild(n);let o=n.offsetHeight>0;n.style.height="100%";let a=n.offsetHeight>0;n.remove(),!(!o||a)&&console.warn("[AgentWidget] Docked mode: no ancestor of the dock target provides a definite height, so the dock panel cannot size to your layout."+(e.maxHeight===!1?" The viewport guard is disabled (dock.maxHeight: false), so the panel will grow with the conversation and overflow the viewport.":` Falling back to clamping the panel to ${e.maxHeight} (configurable via launcher.dock.maxHeight).`)+" To size the panel from your layout instead, give the height chain a definite height (e.g. `html, body { height: 100% }`) down to the dock target's parent.")},db=(r,e)=>{var n,o;let t=(o=(n=e==null?void 0:e.launcher)==null?void 0:n.enabled)!=null?o:!0;r.className="persona-host",r.style.height=t?"":"100%",r.style.display=t?"":"flex",r.style.flexDirection=t?"":"column",r.style.flex=t?"":"1 1 auto",r.style.minHeight=t?"":"0"},xu=r=>{r.style.position="",r.style.top="",r.style.bottom="",r.style.left="",r.style.right="",r.style.zIndex="",r.style.transform="",r.style.pointerEvents=""},cb=r=>{r.style.inset="",r.style.width="",r.style.height="",r.style.maxWidth="",r.style.maxHeight="",r.style.minWidth="",xu(r)},mu=r=>{r.style.transition=""},gu=r=>{r.style.display="",r.style.flexDirection="",r.style.flex="",r.style.minHeight="",r.style.minWidth="",r.style.width="",r.style.height="",r.style.alignItems="",r.style.transition="",r.style.transform=""},hu=r=>{r.style.width="",r.style.maxWidth="",r.style.minWidth="",r.style.flex="1 1 auto"},od=(r,e)=>{r.style.width="",r.style.minWidth="",r.style.maxWidth="",r.style.boxSizing="",e.style.alignItems=""},_C=(r,e,t,n,o)=>{o?t.parentElement!==e&&(r.replaceChildren(),e.replaceChildren(t,n),r.appendChild(e)):t.parentElement===e&&(e.replaceChildren(),r.appendChild(t),r.appendChild(n))},UC=(r,e,t,n,o,a)=>{let s=a?e:r;o==="left"?s.firstElementChild!==n&&s.replaceChildren(n,t):s.lastElementChild!==n&&s.replaceChildren(t,n)},pb=(r,e,t,n,o,a,s)=>{var b,h,S,T,M,k;let i=Sn(a),d=i.reveal==="push";_C(r,e,t,n,d),UC(r,e,t,n,i.side,d),r.dataset.personaHostLayout="docked",r.dataset.personaDockSide=i.side,r.dataset.personaDockOpen=s?"true":"false",r.style.width="100%",r.style.maxWidth="100%",r.style.minWidth="0",r.style.height="100%",r.style.minHeight="0",r.style.position="relative",t.style.display="flex",t.style.flexDirection="column",t.style.minHeight="0",t.style.position="relative",o.className="persona-host",o.style.height="100%",o.style.minHeight="0",o.style.display="flex",o.style.flexDirection="column",o.style.flex="1 1 auto";let l=r.ownerDocument.defaultView,u=(h=(b=a==null?void 0:a.launcher)==null?void 0:b.mobileFullscreen)!=null?h:!0,m=(T=(S=a==null?void 0:a.launcher)==null?void 0:S.mobileBreakpoint)!=null?T:640,p=l!=null?l.innerWidth<=m:!1;if(u&&p&&s){r.dataset.personaDockMobileFullscreen="true",r.removeAttribute("data-persona-dock-reveal"),gu(e),mu(n),cb(n),hu(t),od(o,n),r.style.display="flex",r.style.flexDirection="column",r.style.alignItems="stretch",r.style.overflow="hidden",t.style.flex="1 1 auto",t.style.width="100%",t.style.minWidth="0",n.style.display="flex",n.style.flexDirection="column",n.style.position="fixed",n.style.inset="0",n.style.width="100%",n.style.height="100%",n.style.maxWidth="100%",n.style.minWidth="0",n.style.minHeight="0",n.style.overflow="hidden",n.style.zIndex=String((k=(M=a==null?void 0:a.launcher)==null?void 0:M.zIndex)!=null?k:Xr),n.style.transform="none",n.style.transition="none",n.style.pointerEvents="auto",n.style.flex="none",d&&(e.style.display="flex",e.style.flexDirection="column",e.style.width="100%",e.style.height="100%",e.style.minHeight="0",e.style.minWidth="0",e.style.flex="1 1 auto",e.style.alignItems="stretch",e.style.transform="none",e.style.transition="none",t.style.flex="1 1 auto",t.style.width="100%",t.style.maxWidth="100%",t.style.minWidth="0");return}if(r.removeAttribute("data-persona-dock-mobile-fullscreen"),cb(n),FC(n,i.maxHeight),i.reveal==="overlay"){r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="hidden",r.dataset.personaDockReveal="overlay",gu(e),mu(n),hu(t),od(o,n);let x=i.animate?"transform 180ms ease":"none",C=i.side==="right"?"translateX(100%)":"translateX(-100%)",w=s?"translateX(0)":C;n.style.display="flex",n.style.flexDirection="column",n.style.flex="none",n.style.position="absolute",n.style.top="0",n.style.bottom="0",n.style.width=i.width,n.style.maxWidth=i.width,n.style.minWidth=i.width,n.style.minHeight="0",n.style.overflow="hidden",n.style.transition=x,n.style.transform=w,n.style.pointerEvents=s?"auto":"none",n.style.zIndex="2",i.side==="right"?(n.style.right="0",n.style.left=""):(n.style.left="0",n.style.right="")}else if(i.reveal==="push"){r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="hidden",r.dataset.personaDockReveal="push",mu(n),xu(n),od(o,n);let x=DC(i.width,r.clientWidth),C=Math.max(0,r.clientWidth),w=i.animate?"transform 180ms ease":"none",E=i.side==="right"?s?`translateX(-${x}px)`:"translateX(0)":s?"translateX(0)":`translateX(-${x}px)`;e.style.display="flex",e.style.flexDirection="row",e.style.flex="0 0 auto",e.style.minHeight="0",e.style.minWidth="0",e.style.alignItems="stretch",e.style.height="100%",e.style.width=`${C+x}px`,e.style.transition=w,e.style.transform=E,t.style.flex="0 0 auto",t.style.flexGrow="0",t.style.flexShrink="0",t.style.width=`${C}px`,t.style.maxWidth=`${C}px`,t.style.minWidth=`${C}px`,n.style.display="flex",n.style.flexDirection="column",n.style.flex="0 0 auto",n.style.flexShrink="0",n.style.width=i.width,n.style.minWidth=i.width,n.style.maxWidth=i.width,n.style.position="relative",n.style.top="",n.style.overflow="hidden",n.style.transition="none",n.style.pointerEvents=s?"auto":"none"}else{r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="",gu(e),xu(n),hu(t),od(o,n);let x=i.reveal==="emerge";x?r.dataset.personaDockReveal="emerge":r.removeAttribute("data-persona-dock-reveal");let C=s?i.width:"0px",w=i.animate?"width 180ms ease, min-width 180ms ease, max-width 180ms ease, flex-basis 180ms ease":"none",E=!s;n.style.display="flex",n.style.flexDirection="column",n.style.flex=`0 0 ${C}`,n.style.width=C,n.style.maxWidth=C,n.style.minWidth=C,n.style.minHeight="0",OC(n,i.maxHeight),n.style.overflow=x||E?"hidden":"visible",n.style.transition=w,x&&(n.style.alignItems=i.side==="right"?"flex-start":"flex-end",o.style.width=i.width,o.style.minWidth=i.width,o.style.maxWidth=i.width,o.style.boxSizing="border-box")}},qC=(r,e)=>{let t=r.ownerDocument.createElement("div");return db(t,e),r.appendChild(t),{mode:"direct",host:t,shell:null,syncWidgetState:()=>{},updateConfig(n){db(t,n)},destroy(){t.remove()}}},zC=(r,e)=>{var k,x,C,w;let{ownerDocument:t}=r,n=r.parentElement;if(!n)throw new Error("Docked widget target must be attached to the DOM");let o=r.tagName.toUpperCase();if(o==="BODY"||o==="HTML")throw new Error('Docked widget target must be a concrete container element, not "body" or "html"');let a=r.nextSibling,s=t.createElement("div"),i=t.createElement("div"),d=t.createElement("div"),l=t.createElement("aside"),u=t.createElement("div"),m=(x=(k=e==null?void 0:e.launcher)==null?void 0:k.enabled)==null||x?(w=(C=e==null?void 0:e.launcher)==null?void 0:C.autoExpand)!=null?w:!1:!0;i.dataset.personaDockRole="push-track",d.dataset.personaDockRole="content",l.dataset.personaDockRole="panel",u.dataset.personaDockRole="host",l.appendChild(u),n.insertBefore(s,r),d.appendChild(r);let p=null,f=()=>{p==null||p.disconnect(),p=null},b=()=>{f(),Sn(e).reveal==="push"&&typeof ResizeObserver!="undefined"&&(p=new ResizeObserver(()=>{pb(s,i,d,l,u,e,m)}),p.observe(s))},h=!1,S=()=>{pb(s,i,d,l,u,e,m),b(),m&&!h&&s.dataset.personaDockMobileFullscreen!=="true"&&(h=!0,NC(s,Sn(e)))},T=s.ownerDocument.defaultView,M=()=>{S()};return T==null||T.addEventListener("resize",M),Sn(e).reveal==="push"?(i.appendChild(d),i.appendChild(l),s.appendChild(i)):(s.appendChild(d),s.appendChild(l)),S(),{mode:"docked",host:u,shell:s,syncWidgetState(E){let H=E.launcherEnabled?E.open:!0;m!==H&&(m=H,S())},updateConfig(E){var H,I;e=E,((I=(H=e==null?void 0:e.launcher)==null?void 0:H.enabled)!=null?I:!0)===!1&&(m=!0),S()},destroy(){T==null||T.removeEventListener("resize",M),f(),n.isConnected&&(a&&a.parentNode===n?n.insertBefore(r,a):n.appendChild(r)),s.remove()}}},pi=(r,e)=>Pr(e)?zC(r,e):qC(r,e);var bu={},ub=!1,$C=r=>{if(typeof window=="undefined"||typeof document=="undefined")throw new Error("Chat widget can only be mounted in a browser environment");if(typeof r=="string"){let e=document.querySelector(r);if(!e)throw new Error(`Chat widget target "${r}" was not found`);return e}return r},VC=()=>{try{if(typeof bu!="undefined"&&bu.url)return new URL("../widget.css",bu.url).href}catch{}return null},fb=(r,e)=>{let t=VC(),n=()=>{if(!(r instanceof ShadowRoot)||r.querySelector("link[data-persona]"))return;let o=e.head.querySelector("link[data-persona]");if(!o)return;let a=o.cloneNode(!0);r.insertBefore(a,r.firstChild)};if(r instanceof ShadowRoot)if(t){let o=e.createElement("link");o.rel="stylesheet",o.href=t,o.setAttribute("data-persona","true"),r.insertBefore(o,r.firstChild)}else n();else if(!e.head.querySelector("link[data-persona]")&&t){let a=e.createElement("link");a.rel="stylesheet",a.href=t,a.setAttribute("data-persona","true"),e.head.appendChild(a)}},mb=r=>{let e=$C(r.target),t=r.useShadowDom===!0,n=e.ownerDocument,o=r.config,a=pi(e,o),s,i=[],d=(S,T)=>{var C,w;let k=!((w=(C=T==null?void 0:T.launcher)==null?void 0:C.enabled)!=null?w:!0)||Pr(T),x=n.createElement("div");if(x.setAttribute("data-persona-root","true"),k&&(x.style.height="100%",x.style.display="flex",x.style.flexDirection="column",x.style.flex="1",x.style.minHeight="0"),t){let E=S.attachShadow({mode:"open"});E.appendChild(x),fb(E,n)}else S.appendChild(x),fb(S,n);return e.id&&x.setAttribute("data-persona-instance",e.id),x},l=()=>{a.syncWidgetState(s.getState())},u=()=>{i.forEach(S=>S()),i=[s.on("widget:opened",l),s.on("widget:closed",l)],l()},m=()=>{let S=d(a.host,o);s=nd(S,o,{debugTools:r.debugTools}),u()},p=()=>{i.forEach(S=>S()),i=[],s.destroy()};m(),r.onChatReady?r.onChatReady():r.onReady&&(ub||(ub=!0,console.warn("[Persona] `onReady` is deprecated \u2014 use `onChatReady`. `onReady` still works but is removed in the next major.")),r.onReady());let f=S=>{p(),a.destroy(),a=pi(e,S),o=S,m()},b={update(S){var w,E,H,I,L,O;let T={...o,...S,launcher:{...(w=o==null?void 0:o.launcher)!=null?w:{},...(E=S==null?void 0:S.launcher)!=null?E:{},dock:{...(I=(H=o==null?void 0:o.launcher)==null?void 0:H.dock)!=null?I:{},...(O=(L=S==null?void 0:S.launcher)==null?void 0:L.dock)!=null?O:{}}}},M=Pr(o),k=Pr(T),x=zo(o),C=zo(T);if(M!==k||x!==C){f(T);return}o=T,a.updateConfig(o),s.update(S),l()},destroy(){p(),a.destroy(),r.windowKey&&typeof window!="undefined"&&delete window[r.windowKey]}},h=new Proxy(b,{get(S,T,M){if(T==="host")return a.host;if(T in S)return Reflect.get(S,T,M);let k=s[T];return typeof k=="function"?k.bind(s):k}});return r.windowKey&&typeof window!="undefined"&&(window[r.windowKey]=h),h};var yb=new Set(["script","style","noscript","svg","path","meta","link","br","hr"]),jC=new Set(["button","a","input","select","textarea","details","summary"]),GC=new Set(["button","link","menuitem","tab","option","switch","checkbox","radio","combobox","listbox","slider","spinbutton","textbox"]),yu=/\b(product|card|item|listing|result)\b/i,Cu=/\$[\d,]+(?:\.\d{2})?|€[\d,]+(?:\.\d{2})?|£[\d,]+(?:\.\d{2})?|USD\s*[\d,]+(?:\.\d{2})?/i,KC=3e3,XC=100;function vb(r){let e=typeof r.className=="string"?r.className:"";if(yu.test(e)||r.id&&yu.test(r.id))return!0;for(let t=0;t<r.attributes.length;t++){let n=r.attributes[t];if(n.name.startsWith("data-")&&yu.test(n.value))return!0}return!1}function Cb(r){var e;return Cu.test(((e=r.textContent)!=null?e:"").trim())}function wb(r){var t;let e=r.querySelectorAll("a[href]");for(let n=0;n<e.length;n++){let o=(t=e[n].getAttribute("href"))!=null?t:"";if(o&&o!=="#"&&!o.toLowerCase().startsWith("javascript:"))return!0}return!1}function QC(r){return!!r.querySelector('button, [role="button"], input[type="submit"], input[type="button"]')}function gb(r){let e=r.match(Cu);return e?e[0]:null}function hb(r){var n,o,a;let e=(n=r.querySelector(".product-title a, h1 a, h2 a, h3 a, h4 a, .title a, a[href]"))!=null?n:r.querySelector("a[href]");if(e&&((o=e.textContent)!=null&&o.trim())){let s=e.getAttribute("href");return{title:e.textContent.trim(),href:s&&s!=="#"?s:null}}let t=r.querySelector("h1, h2, h3, h4, h5, h6");return(a=t==null?void 0:t.textContent)!=null&&a.trim()?{title:t.textContent.trim(),href:null}:{title:"",href:null}}function JC(r){let e=[],t=n=>{let o=n.trim();o&&!e.includes(o)&&e.push(o)};return r.querySelectorAll("button").forEach(n=>{var o;return t((o=n.textContent)!=null?o:"")}),r.querySelectorAll('[role="button"]').forEach(n=>{var o;return t((o=n.textContent)!=null?o:"")}),r.querySelectorAll('input[type="submit"], input[type="button"]').forEach(n=>{var o;t((o=n.value)!=null?o:"")}),e.slice(0,6)}var YC="commerce-card",ZC="result-card";function xb(r){return!vb(r)||!Cb(r)||!wb(r)&&!QC(r)?0:5200}function bb(r){var n;return!vb(r)||Cb(r)||!wb(r)||((n=r.textContent)!=null?n:"").trim().length<20||!(!!r.querySelector("h1, h2, h3, h4, h5, h6, .title")||!!r.querySelector(".snippet, .description, p"))?0:2800}var wu=[{id:YC,scoreElement(r){return xb(r)},shouldSuppressDescendant(r,e,t){if(e===r||!r.contains(e))return!1;if(t.interactivity==="static"){let n=t.text.trim();return!!(n.length===0||Cu.test(n)&&n.length<32)}return!0},formatSummary(r,e){var d,l,u;if(xb(r)===0)return null;let{title:t,href:n}=hb(r),o=(u=(l=gb(((d=r.textContent)!=null?d:"").trim()))!=null?l:gb(e.text))!=null?u:"",a=JC(r);return[n&&t?`[${t}](${n})${o?` \u2014 ${o}`:""}`:t?`${t}${o?` \u2014 ${o}`:""}`:o||e.text.trim().slice(0,120),`selector: ${e.selector}`,a.length?`actions: ${a.join(", ")}`:""].filter(Boolean).join(`
|
|
155
|
-
`)}},{id:
|
|
156
|
-
`)}}];function
|
|
155
|
+
`}if(!S&&!c){let Zt="max-height: -moz-available !important; max-height: stretch !important;",Yt=g?"":"padding-top: 1.25em !important;",Et=g?"":`z-index: ${(Ir=(pt=o.launcher)==null?void 0:pt.zIndex)!=null?Ir:so} !important;`;De.style.cssText+=Zt+Yt+Et}ot()};to(),Vn(r,o),Ql(r,o),Yl(r,o);let gt=[];gt.push(()=>{document.removeEventListener("keydown",Nr)});let re=null,A=null;gt.push(()=>{re==null||re(),re=null,A==null||A(),A=null}),co&>.push(()=>{co==null||co.disconnect(),co=null}),gt.push(()=>{Fr==null||Fr(),Fr=null,Uo(),$t&&($t.remove(),$t=null),mt==null||mt.element.style.removeProperty("width"),mt==null||mt.element.style.removeProperty("maxWidth")}),We&>.push(()=>{Oe!==null&&(cancelAnimationFrame(Oe),Oe=null),Y==null||Y.destroy(),Y=null,be==null||be.destroy(),be=null,ne=null});let _=null,ue=()=>{_&&(_(),_=null),o.colorScheme==="auto"&&(_=El(()=>{Vn(r,o)}))};ue(),gt.push(()=>{_&&(_(),_=null)});let $=(Rf=o.features)==null?void 0:Rf.streamAnimation;if($!=null&&$.type&&$.type!=="none"){let c=ni($.type,$.plugins);c&&(Yp(c,r),gt.push(()=>Hx(r)))}let at=Kx(Pt),ut=null,U,nr=c=>{var S,W;if(!U)return;let g=c!=null?c:U.getMessages(),b=((W=(S=o.features)==null?void 0:S.suggestReplies)==null?void 0:W.enabled)!==!1?Yi(g):null;b?at.render(b,U,te,g,o.suggestionChipsConfig,{agentPushed:!0}):g.some(F=>F.role==="user")?at.render([],U,te,g):at.render(o.suggestionChips,U,te,g,o.suggestionChipsConfig)},mr=!1,Cr=Sx(),ko=new Map,sr=new Map,Ko=new Map,us=0,Eo=Rl(),Lo=0,Xo=null,Qo=!1,Qn=!1,gn=0,ro=null,an=null,Pa=!1,Yn=!1,Ra=null,bi=4,Ia=24,vi=80,Ha=new Map,Lt={active:!1,manuallyDeactivated:!1,lastUserMessageWasVoice:!1,lastUserMessageId:null},fs=(Hf=(If=o.voiceRecognition)==null?void 0:If.autoResume)!=null?Hf:!1,zo=c=>{a.emit("voice:state",{active:Lt.active,source:c,timestamp:Date.now()})},So=()=>{m(c=>({...c,voiceState:{active:Lt.active,timestamp:Date.now(),manuallyDeactivated:Lt.manuallyDeactivated}}))},Ci=()=>{var S,W;if(((S=o.voiceRecognition)==null?void 0:S.enabled)===!1)return;let c=gu(d.voiceState),g=!!c.active,b=Number((W=c.timestamp)!=null?W:0);Lt.manuallyDeactivated=!!c.manuallyDeactivated,g&&Date.now()-b<QC&&setTimeout(()=>{var F,q;Lt.active||(Lt.manuallyDeactivated=!1,((q=(F=o.voiceRecognition)==null?void 0:F.provider)==null?void 0:q.type)==="runtype"?U.toggleVoice().then(()=>{Lt.active=U.isVoiceActive(),zo("restore"),U.isVoiceActive()&&Ts()}):pr("restore"))},1e3)},wi=()=>U?fy(U.getMessages()).filter(c=>!c.__skipPersist):[];function Wa(c){if(!(i!=null&&i.save))return;let b={messages:c?fy(c):U?wi():[],metadata:d,artifacts:po.artifacts,selectedArtifactId:po.selectedId};try{let S=i.save(b);S instanceof Promise&&S.catch(W=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",W)})}catch(S){typeof console!="undefined"&&console.error("[AgentWidget] Failed to persist state:",S)}}let hn=null,ms=()=>De.querySelector("#persona-scroll-container")||he,Pn=()=>{hn!==null&&(cancelAnimationFrame(hn),hn=null),Qo=!1},gs=()=>{Xo!==null&&(cancelAnimationFrame(Xo),Xo=null),Qn=!1,Pn()},hs=()=>{gn>0?(Dr.textContent=String(gn),Dr.style.display="",tt.setAttribute("aria-label",`${zt()||"Jump to latest"} (${gn} new)`)):(Dr.textContent="",Dr.style.display="none",tt.setAttribute("aria-label",zt()||"Jump to latest"))},xs=()=>{gn!==0&&(gn=0,hs())},ys=()=>xt()==="follow"?!Eo.isFollowing():!Aa(he,Ia),To=()=>{if(!vr()||ge){tt.parentNode&&tt.remove(),tt.style.display="none";return}tt.parentNode!==K&&K.appendChild(tt),Sr();let g=Mn(he)>0&&ys();g||xs(),tt.style.display=g?"":"none"},Ba=()=>{Eo.pause()&&(gs(),To())},sn=()=>{Eo.resume(),xs(),To()},ln=(c=!1)=>{xt()==="follow"&&Eo.isFollowing()&&(!c&&!mr||(Xo!==null&&(cancelAnimationFrame(Xo),Xo=null),Qn=!0,Xo=requestAnimationFrame(()=>{Xo=null,Qn=!1,Eo.isFollowing()&&Ai(ms(),c?220:140)})))},bs=(c,g,b,S=()=>!0)=>{let W=c.scrollTop,F=g(),q=F-W;Pn();let G=performance.now();Qo=!0;let N=xe=>1-Math.pow(1-xe,3),Se=xe=>{if(!S()){Pn();return}let se=g();se!==F&&(F=se,q=F-W);let ke=xe-G,Ge=Math.min(ke/b,1),Te=N(Ge),ft=W+q*Te;c.scrollTop=ft,Lo=c.scrollTop,Ge<1?hn=requestAnimationFrame(Se):(c.scrollTop=F,Lo=c.scrollTop,hn=null,Qo=!1)};hn=requestAnimationFrame(Se)},Ai=(c,g=500)=>{let b=Mn(c)-c.scrollTop;if(Math.abs(b)<1){Lo=c.scrollTop;return}if(Math.abs(b)>=vi){Pn(),Qo=!0,c.scrollTop=Mn(c),Lo=c.scrollTop,Qo=!1;return}bs(c,()=>Mn(c),g,()=>Eo.isFollowing())},vs=()=>{let c=ms();Qo=!0,c.scrollTop=Mn(c),Lo=c.scrollTop,Qo=!1,To()},Cs=c=>{hr.style.height=`${Math.max(0,Math.round(c))}px`,ro&&(ro.spacerHeight=Math.max(0,c))},Jn=()=>{an!==null&&(cancelAnimationFrame(an),an=null),Pn(),ro=null,hr.style.height="0px"},Si=c=>{an!==null&&cancelAnimationFrame(an),an=requestAnimationFrame(()=>{var Se;an=null;let g=typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(c):c.replace(/"/g,'\\"'),b=he.querySelector(`[data-message-id="${g}"]`);if(!b)return;let S=0,W=b;for(;W&&W!==he;)S+=W.offsetTop,W=W.offsetParent;let F=(Se=ro==null?void 0:ro.spacerHeight)!=null?Se:0,q=he.scrollHeight-F,{targetScrollTop:G,spacerHeight:N}=Lx({anchorOffsetTop:S,topOffset:It(),viewportHeight:he.clientHeight,contentHeight:q});ro={initialSpacerHeight:N,contentHeightAtAnchor:q,spacerHeight:N},Cs(N),bs(he,()=>G,220)})},Ti=()=>{if(xt()==="follow"){if(!Eo.isFollowing()||Aa(he,1))return;ln(!mr);return}if(ro&&ro.initialSpacerHeight>0){let c=he.scrollHeight-ro.spacerHeight,g=Px({initialSpacerHeight:ro.initialSpacerHeight,contentHeightAtAnchor:ro.contentHeightAtAnchor,currentContentHeight:c});g!==ro.spacerHeight&&Cs(g)}To()},Mi=c=>{let g=xt();g==="follow"?(sn(),ln(!0)):g==="anchor-top"&&Si(c)},ki=c=>{let g=new Map;c.forEach(b=>{let S=Ha.get(b.id);g.set(b.id,{streaming:b.streaming,role:b.role}),!S&&b.role==="assistant"&&(a.emit("assistant:message",b),!Yn&&xt()!=="anchor-top"&&ys()&&(gn+=1,hs(),To())),b.role==="assistant"&&(S!=null&&S.streaming)&&b.streaming===!1&&a.emit("assistant:complete",b),b.variant==="approval"&&b.approval&&(S?b.approval.status!=="pending"&&a.emit("approval:resolved",{approval:b.approval,decision:b.approval.status}):a.emit("approval:requested",{approval:b.approval,message:b}))}),Ha.clear(),g.forEach((b,S)=>{Ha.set(S,b)})},Zn=(c,g,b)=>{var vt,He,Pe,Qe,ot,Ht;let S=document.createElement("div"),F=(()=>{var Ne;let D=n.find(Fe=>Fe.renderLoadingIndicator);if(D!=null&&D.renderLoadingIndicator)return D.renderLoadingIndicator;if((Ne=o.loadingIndicator)!=null&&Ne.render)return o.loadingIndicator.render})(),q=(D,Ne)=>Ne==null?!1:typeof Ne=="string"?(D.textContent=Ne,!0):(D.appendChild(Ne),!0),G=new Set,N=new Set,Se=n.some(D=>D.renderAskUserQuestion),xe=[],se=[],ke=o.enableComponentStreaming!==!1,Ge=n.some(D=>D.renderApproval)&&o.approval!==!1,Te=[];if(g.forEach(D=>{var st,Ut,kr,Vo,Ro,ta,ra,Fa,Ua,ur,oa,On,_n,yn,na,Yo;G.add(D.id);let Ne=Se&&wn(D),Fe=Ge&&D.variant==="approval"&&!!D.approval,we=!Ne&&D.role==="assistant"&&!D.variant&&ke&&td(D);if(!Fe&&Ko.has(D.id)){let pt=c.querySelector(`#wrapper-${D.id}`);pt==null||pt.removeAttribute("data-preserve-runtime"),Ko.delete(D.id)}if(!we&&sr.has(D.id)){let pt=c.querySelector(`#wrapper-${D.id}`);pt==null||pt.removeAttribute("data-preserve-runtime"),sr.delete(D.id)}let Qt=wn(D)?`:${(st=D.agentMetadata)!=null&&st.askUserQuestionAnswered?"a":"u"}:${(Ut=D.agentMetadata)!=null&&Ut.askUserQuestionAnswers?Object.keys(D.agentMetadata.askUserQuestionAnswers).length:0}`:"",Kt=Ax(D,us)+Qt,ir=Ne||Fe||we?null:Tx(Cr,D.id,Kt);if(ir){S.appendChild(ir.cloneNode(!0)),wn(D)&&((kr=D.toolCall)!=null&&kr.id)&&((Vo=D.agentMetadata)==null?void 0:Vo.awaitingLocalTool)===!0&&!((Ro=D.agentMetadata)!=null&&Ro.askUserQuestionAnswered)&&(N.add(D.toolCall.id),Qa(D,o,Re.composerOverlay));return}let Bt=null,ar=n.find(pt=>!!(D.variant==="reasoning"&&pt.renderReasoning||D.variant==="tool"&&pt.renderToolCall||!D.variant&&pt.renderMessage)),Po=(ta=o.layout)==null?void 0:ta.messages;if(wn(D)&&((ra=D.agentMetadata)==null?void 0:ra.askUserQuestionAnswered)===!0){ko.delete(D.id);let pt=c.querySelector(`#wrapper-${D.id}`);pt==null||pt.removeAttribute("data-preserve-runtime");return}if(js(D)&&((Ua=(Fa=o.features)==null?void 0:Fa.suggestReplies)==null?void 0:Ua.enabled)!==!1)return;if(wn(D)&&((oa=(ur=o.features)==null?void 0:ur.askUserQuestion)==null?void 0:oa.enabled)!==!1){let pt=n.find(Ir=>typeof Ir.renderAskUserQuestion=="function");if(pt&&Wt.current){let Ir=ko.get(D.id),Zt=Ir!==Kt,Yt=null;if(Zt){let{payload:_t,complete:oo}=An(D),ho=D.id,dn=()=>{var qr;return(qr=Wt.current)==null?void 0:qr.getMessages().find(xo=>xo.id===ho)};Yt=pt.renderAskUserQuestion({message:D,payload:_t,complete:oo,resolve:qr=>{var yo;let xo=dn();xo&&((yo=Wt.current)==null||yo.resolveAskUserQuestion(xo,qr))},dismiss:()=>{var xo,yo,aa;let qr=dn();(xo=qr==null?void 0:qr.agentMetadata)!=null&&xo.awaitingLocalTool&&((yo=Wt.current)==null||yo.markAskUserQuestionResolved(qr),(aa=Wt.current)==null||aa.resolveAskUserQuestion(qr,"(dismissed)"))},config:o})}let Et=Ir!=null;if(Zt&&Yt===null&&!Et){((On=D.agentMetadata)==null?void 0:On.awaitingLocalTool)===!0&&!((_n=D.agentMetadata)!=null&&_n.askUserQuestionAnswered)&&(N.add(D.toolCall.id),Qa(D,o,Re.composerOverlay));return}let fr=document.createElement("div");fr.className="persona-flex",fr.id=`wrapper-${D.id}`,fr.setAttribute("data-wrapper-id",D.id),fr.setAttribute("data-ask-plugin-stub","true"),fr.setAttribute("data-preserve-runtime","true"),S.appendChild(fr),xe.push({messageId:D.id,fingerprint:Kt,bubble:Yt});return}else{((yn=D.agentMetadata)==null?void 0:yn.awaitingLocalTool)===!0&&!((na=D.agentMetadata)!=null&&na.askUserQuestionAnswered)&&(N.add(D.toolCall.id),Qa(D,o,Re.composerOverlay));return}}else if(Fe){let pt=n.find(Et=>typeof Et.renderApproval=="function"),Zt=Ko.get(D.id)!==Kt,Yt=null;if(Zt&&(pt!=null&&pt.renderApproval)){let Et=D.id,fr=(_t,oo)=>{var dn,qr,xo;let ho=(dn=Wt.current)==null?void 0:dn.getMessages().find(yo=>yo.id===Et);ho!=null&&ho.approval&&(ho.approval.toolType==="webmcp"?(qr=Wt.current)==null||qr.resolveWebMcpApproval(ho.id,_t):(xo=Wt.current)==null||xo.resolveApproval(ho.approval,_t,oo))};Yt=pt.renderApproval({message:D,defaultRenderer:()=>Kl(D,o),config:o,approve:_t=>fr("approved",_t),deny:_t=>fr("denied",_t)})}if(Zt&&Yt===null){let Et=c.querySelector(`#wrapper-${D.id}`);Et==null||Et.removeAttribute("data-preserve-runtime"),Ko.delete(D.id),Bt=Kl(D,o)}else{let Et=document.createElement("div");Et.className="persona-flex",Et.id=`wrapper-${D.id}`,Et.setAttribute("data-wrapper-id",D.id),Et.setAttribute("data-approval-plugin-stub","true"),Et.setAttribute("data-preserve-runtime","true"),S.appendChild(Et),Te.push({messageId:D.id,fingerprint:Kt,bubble:Yt});return}}else if(ar)if(D.variant==="reasoning"&&D.reasoning&&ar.renderReasoning){if(!Xe)return;Bt=ar.renderReasoning({message:D,defaultRenderer:()=>iu(D,o),config:o})}else if(D.variant==="tool"&&D.toolCall&&ar.renderToolCall){if(!Ae)return;Bt=ar.renderToolCall({message:D,defaultRenderer:()=>lu(D,o),config:o})}else ar.renderMessage&&(Bt=ar.renderMessage({message:D,defaultRenderer:()=>{let pt=as(D,b,Po,o.messageActions,ae,{loadingIndicatorRenderer:F,widgetConfig:o});return D.role!=="user"&&uu(pt,D,o,U),pt},config:o}));if(!Bt&&we){let pt=rd(D);if(pt){let Ir=sr.get(D.id),Zt=Ir!==Kt,Yt=o.wrapComponentDirectiveInBubble!==!1,Et=null;if(Zt){let fr=ed(pt,{config:o,message:D,transform:b});if(fr)if(Yt){let _t=document.createElement("div");if(_t.className=["persona-message-bubble","persona-max-w-[85%]","persona-rounded-2xl","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-p-4"].join(" "),_t.id=`bubble-${D.id}`,_t.setAttribute("data-message-id",D.id),D.content&&D.content.trim()){let oo=document.createElement("div");oo.className="persona-mb-3 persona-text-sm persona-leading-relaxed",oo.innerHTML=b({text:D.content,message:D,streaming:!!D.streaming,raw:D.rawContent}),_t.appendChild(oo)}_t.appendChild(fr),Et=_t}else{let _t=document.createElement("div");if(_t.className="persona-flex persona-flex-col persona-w-full persona-max-w-full persona-gap-3 persona-items-stretch",_t.id=`bubble-${D.id}`,_t.setAttribute("data-message-id",D.id),_t.setAttribute("data-persona-component-directive","true"),D.content&&D.content.trim()){let oo=document.createElement("div");oo.className="persona-text-sm persona-leading-relaxed persona-text-persona-primary persona-w-full",oo.innerHTML=b({text:D.content,message:D,streaming:!!D.streaming,raw:D.rawContent}),_t.appendChild(oo)}_t.appendChild(fr),Et=_t}}if(Et||Ir!=null){let fr=document.createElement("div");fr.className="persona-flex",fr.id=`wrapper-${D.id}`,fr.setAttribute("data-wrapper-id",D.id),fr.setAttribute("data-component-directive-stub","true"),fr.setAttribute("data-preserve-runtime","true"),Yt||fr.classList.add("persona-w-full"),S.appendChild(fr),se.push({messageId:D.id,fingerprint:Kt,bubble:Et});return}}}if(!Bt)if(D.variant==="reasoning"&&D.reasoning){if(!Xe)return;Bt=iu(D,o)}else if(D.variant==="tool"&&D.toolCall){if(!Ae)return;Bt=lu(D,o)}else if(D.variant==="approval"&&D.approval){if(o.approval===!1)return;Bt=Kl(D,o)}else{let pt=(Yo=o.layout)==null?void 0:Yo.messages;pt!=null&&pt.renderUserMessage&&D.role==="user"?Bt=pt.renderUserMessage({message:D,config:o,streaming:!!D.streaming}):pt!=null&&pt.renderAssistantMessage&&D.role==="assistant"?Bt=pt.renderAssistantMessage({message:D,config:o,streaming:!!D.streaming}):Bt=as(D,b,pt,o.messageActions,ae,{loadingIndicatorRenderer:F,widgetConfig:o}),D.role!=="user"&&Bt&&uu(Bt,D,o,U)}let wr=document.createElement("div");wr.className="persona-flex",wr.id=`wrapper-${D.id}`,wr.setAttribute("data-wrapper-id",D.id),D.role==="user"&&wr.classList.add("persona-justify-end"),(Bt==null?void 0:Bt.getAttribute("data-persona-component-directive"))==="true"&&wr.classList.add("persona-w-full"),wr.appendChild(Bt),Mx(Cr,D.id,Kt,wr),S.appendChild(wr)}),Re.composerOverlay&&Re.composerOverlay.querySelectorAll("[data-persona-ask-sheet-for]").forEach(Ne=>{let Fe=Ne.getAttribute("data-persona-ask-sheet-for");Fe&&!N.has(Fe)&&zn(Re.composerOverlay,Fe)}),(He=(vt=o.features)==null?void 0:vt.toolCallDisplay)!=null&&He.grouped){let D=[],Ne=[];g.forEach(Fe=>{if(Fe.variant==="tool"&&Fe.toolCall&&Ae){Ne.push(Fe);return}Ne.length>1&&D.push(Ne),Ne=[]}),Ne.length>1&&D.push(Ne),D.forEach((Fe,we)=>{var st,Ut;let Qt=Fe.map(kr=>Array.from(S.children).find(Vo=>Vo instanceof HTMLElement&&Vo.getAttribute("data-wrapper-id")===kr.id)).filter(kr=>!!kr);if(Qt.length<2)return;let Kt=document.createElement("div");Kt.className="persona-flex",Kt.id=`wrapper-tool-group-${we}-${Fe[0].id}`,Kt.setAttribute("data-wrapper-id",`tool-group-${we}-${Fe[0].id}`);let ir=document.createElement("div");ir.className="persona-tool-group persona-flex persona-w-full persona-flex-col persona-gap-2",ir.setAttribute("data-persona-tool-group","true");let Bt=document.createElement("div");Bt.className="persona-tool-group-summary persona-text-xs persona-text-persona-muted";let ar=`Called ${Fe.length} tools`,Po=(Ut=(st=o.toolCall)==null?void 0:st.renderGroupedSummary)==null?void 0:Ut.call(st,{messages:Fe,toolCalls:Fe.map(kr=>kr.toolCall).filter(kr=>!!kr),defaultSummary:ar,config:o});q(Bt,Po)||(Bt.textContent=ar);let wr=document.createElement("div");wr.className="persona-tool-group-stack persona-flex persona-flex-col",ir.append(Bt,wr),Kt.appendChild(ir),Qt[0].before(Kt),Qt.forEach((kr,Vo)=>{let Ro=document.createElement("div");Ro.className="persona-tool-group-item persona-relative",Ro.setAttribute("data-persona-tool-group-item","true"),Vo<Qt.length-1&&Ro.setAttribute("data-persona-tool-group-connector","true"),Ro.appendChild(kr),wr.appendChild(Ro)})})}kx(Cr,G);let ft=g.some(D=>D.role==="assistant"&&D.streaming),Ze=g[g.length-1],bt=(Ze==null?void 0:Ze.role)==="assistant"&&!Ze.streaming&&Ze.variant!=="approval";if(mr&&g.some(D=>D.role==="user")&&!ft&&!bt){let D={config:o,streaming:!0,location:"standalone",defaultRenderer:Ma},Ne=n.find(we=>we.renderLoadingIndicator),Fe=null;if(Ne!=null&&Ne.renderLoadingIndicator&&(Fe=Ne.renderLoadingIndicator(D)),Fe===null&&((Pe=o.loadingIndicator)!=null&&Pe.render)&&(Fe=o.loadingIndicator.render(D)),Fe===null&&(Fe=Ma()),Fe){let we=document.createElement("div"),Qt=((Qe=o.loadingIndicator)==null?void 0:Qe.showBubble)!==!1;we.className=Qt?["persona-max-w-[85%]","persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm","persona-bg-persona-surface","persona-border","persona-text-persona-primary","persona-px-5","persona-py-3"].join(" "):["persona-max-w-[85%]","persona-text-sm","persona-leading-relaxed","persona-text-persona-primary"].join(" "),we.setAttribute("data-typing-indicator","true"),we.style.borderColor="var(--persona-message-assistant-border, var(--persona-border, #e5e7eb))",we.appendChild(Fe);let Kt=document.createElement("div");Kt.className="persona-flex",Kt.id="wrapper-typing-indicator",Kt.setAttribute("data-wrapper-id","typing-indicator"),Kt.appendChild(we),S.appendChild(Kt)}}if(!mr&&g.length>0){let D=g[g.length-1],Ne={config:o,lastMessage:D,messageCount:g.length},Fe=n.find(Qt=>Qt.renderIdleIndicator),we=null;if(Fe!=null&&Fe.renderIdleIndicator&&(we=Fe.renderIdleIndicator(Ne)),we===null&&((ot=o.loadingIndicator)!=null&&ot.renderIdle)&&(we=o.loadingIndicator.renderIdle(Ne)),we){let Qt=document.createElement("div"),Kt=((Ht=o.loadingIndicator)==null?void 0:Ht.showBubble)!==!1;Qt.className=Kt?["persona-max-w-[85%]","persona-rounded-2xl","persona-text-sm","persona-leading-relaxed","persona-shadow-sm","persona-bg-persona-surface","persona-border","persona-border-persona-message-border","persona-text-persona-primary","persona-px-5","persona-py-3"].join(" "):["persona-max-w-[85%]","persona-text-sm","persona-leading-relaxed","persona-text-persona-primary"].join(" "),Qt.setAttribute("data-idle-indicator","true"),Qt.appendChild(we);let ir=document.createElement("div");ir.className="persona-flex",ir.id="wrapper-idle-indicator",ir.setAttribute("data-wrapper-id","idle-indicator"),ir.appendChild(Qt),S.appendChild(ir)}}if(Ll(c,S),xe.length>0)for(let{messageId:D,fingerprint:Ne,bubble:Fe}of xe){let we=c.querySelector(`#wrapper-${D}`);we&&Fe!==null&&(we.replaceChildren(Fe),we.setAttribute("data-bubble-fp",Ne),ko.set(D,Ne))}if(ko.size>0)for(let D of ko.keys())G.has(D)||ko.delete(D);if(se.length>0)for(let{messageId:D,fingerprint:Ne,bubble:Fe}of se){let we=c.querySelector(`#wrapper-${D}`);we&&Fe!==null&&(we.replaceChildren(Fe),we.setAttribute("data-bubble-fp",Ne),sr.set(D,Ne))}if(sr.size>0)for(let D of sr.keys())G.has(D)||sr.delete(D);if(Te.length>0)for(let{messageId:D,fingerprint:Ne,bubble:Fe}of Te){let we=c.querySelector(`#wrapper-${D}`);we&&Fe!==null&&(we.replaceChildren(Fe),we.setAttribute("data-bubble-fp",Ne),Ko.set(D,Ne))}if(Ko.size>0)for(let D of Ko.keys())G.has(D)||Ko.delete(D)},Rn=null,Ei=()=>{var b;if(Rn)return;let c=S=>{let W=S.composedPath();W.includes(De)||nt&&W.includes(nt)||Gt(!1,"user")};Rn=c,((b=r.ownerDocument)!=null?b:document).addEventListener("pointerdown",c,!0)},ws=()=>{var g;if(!Rn)return;((g=r.ownerDocument)!=null?g:document).removeEventListener("pointerdown",Rn,!0),Rn=null};gt.push(()=>ws());let In=null,Li=()=>{var b;if(In)return;let c=S=>{S.key==="Escape"&&(S.isComposing||Gt(!1,"user"))};In=c,((b=r.ownerDocument)!=null?b:document).addEventListener("keydown",c,!0)},As=()=>{var g;if(!In)return;((g=r.ownerDocument)!=null?g:document).removeEventListener("keydown",In,!0),In=null};gt.push(()=>As());let Hn=!1,Ss=new Set,Pi=()=>{var g,b,S,W;let c=(S=(b=(g=o.launcher)==null?void 0:g.composerBar)==null?void 0:b.peek)==null?void 0:S.streamAnimation;return c||((W=o.features)==null?void 0:W.streamAnimation)},xn=()=>{var bt,vt,He,Pe;if(!H())return;let c=Re.peekBanner,g=Re.peekTextNode;if(!c||!g)return;if(P){c.classList.remove("persona-pill-peek--visible");return}let b=(bt=U==null?void 0:U.getMessages())!=null?bt:[],S;for(let Qe=b.length-1;Qe>=0;Qe--){let ot=b[Qe];if(ot.role==="assistant"&&ot.content){S=ot;break}}if(!S){c.classList.remove("persona-pill-peek--visible");return}let W=S.content,F=!!S.streaming,q=Pi(),G=Wl(q),N=G.type!=="none"?ni(G.type,q==null?void 0:q.plugins):null,Se=((vt=N==null?void 0:N.isAnimating)==null?void 0:vt.call(N,S))===!0,xe=N!==null&&(F||Se);xe&&N&&!Ss.has(N.name)&&(Yp(N,r),Ss.add(N.name));let se=xe&&(N!=null&&N.containerClass)?N.containerClass:null,ke=(He=g.dataset.personaPeekStreamClass)!=null?He:null;ke&&ke!==se&&(g.classList.remove(ke),delete g.dataset.personaPeekStreamClass),se&&ke!==se&&(g.classList.add(se),g.dataset.personaPeekStreamClass=se),xe?(g.style.setProperty("--persona-stream-step",`${G.speed}ms`),g.style.setProperty("--persona-stream-duration",`${G.duration}ms`)):(g.style.removeProperty("--persona-stream-step"),g.style.removeProperty("--persona-stream-duration"));let Ge=xe?Bl(W,G.buffer,N,S,F):W;if(xe&&G.placeholder==="skeleton"&&F&&(!Ge||!Ge.trim())){let Qe=document.createElement("div"),ot=si();ot.classList.add("persona-pill-peek__skeleton"),Qe.appendChild(ot),Ll(g,Qe)}else{let Qe=Math.max(0,Ge.length-100),ot=Ge.length>100?Ge.slice(-100):Ge,Ht=fa(ot);if(!xe||!N){let D=Ge.length>100?`\u2026${ot}`:ot;g.textContent!==D&&(g.textContent=D)}else{let D=Ht;(N.wrap==="char"||N.wrap==="word")&&(D=ai(Ht,N.wrap,`peek-${S.id}`,{skipTags:N.skipTags,startIndex:Qe}));let Ne=document.createElement("div");if(Ne.innerHTML=D,N.useCaret&&ot.length>0){let Fe=Dl(),we=Ne.querySelectorAll(".persona-stream-char, .persona-stream-word"),Qt=we[we.length-1];Qt!=null&&Qt.parentNode?Qt.parentNode.insertBefore(Fe,Qt.nextSibling):Ne.appendChild(Fe)}Ll(g,Ne),(Pe=N.onAfterRender)==null||Pe.call(N,{container:g,bubble:c,messageId:S.id,message:S,speed:G.speed,duration:G.duration})}}let Ze=mr||Hn;c.classList.toggle("persona-pill-peek--visible",Ze)};if(H()){let c=Re.peekBanner;if(c){let S=W=>{W.preventDefault(),W.stopPropagation(),Gt(!0,"user")};c.addEventListener("pointerdown",S),gt.push(()=>{c.removeEventListener("pointerdown",S)})}let g=()=>{Hn||(Hn=!0,xn())},b=()=>{Hn&&(Hn=!1,xn())};le.addEventListener("pointerenter",g),le.addEventListener("pointerleave",b),gt.push(()=>{le.removeEventListener("pointerenter",g),le.removeEventListener("pointerleave",b)}),nt&&(nt.addEventListener("pointerenter",g),nt.addEventListener("pointerleave",b),gt.push(()=>{nt.removeEventListener("pointerenter",g),nt.removeEventListener("pointerleave",b)}))}let Ri=c=>{var ke,Ge,Te,ft,Ze,bt,vt,He;let g=(Ge=(ke=o.launcher)==null?void 0:ke.composerBar)!=null?Ge:{},b=(Te=g.expandedSize)!=null?Te:"anchored",S=(ft=g.bottomOffset)!=null?ft:"16px",W=g.collapsedMaxWidth,F=(Ze=g.expandedMaxWidth)!=null?Ze:"880px",q=(bt=g.expandedTopOffset)!=null?bt:"5vh",G=(vt=g.modalMaxWidth)!=null?vt:"880px",N=(He=g.modalMaxHeight)!=null?He:"min(90vh, 800px)",Se="calc(100vw - 32px)",xe="var(--persona-pill-area-height, 80px)",se=De.style;if(se.left="",se.right="",se.top="",se.bottom="",se.transform="",se.width="",se.maxWidth="",se.height="",se.maxHeight="",nt){let Pe=nt.style;Pe.bottom=S,Pe.width=W!=null?W:""}if(c&&b!=="fullscreen"){if(b==="modal"){se.top="50%",se.left="50%",se.transform="translate(-50%, -50%)",se.bottom="auto",se.right="auto",se.width=G,se.maxWidth=Se,se.maxHeight=N,se.height=N;return}se.left="50%",se.transform="translateX(-50%)",se.bottom=`calc(${S} + ${xe})`,se.top=q,se.width=F,se.maxWidth=Se}},Wn=()=>{var N,Se,xe,se,ke,Ge,Te,ft;if(!I())return;if(H()){let bt=(xe=((Se=(N=o.launcher)==null?void 0:N.composerBar)!=null?Se:{}).expandedSize)!=null?xe:"anchored",vt=P?"expanded":"collapsed";De.dataset.state=vt,De.dataset.expandedSize=bt,nt&&(nt.dataset.state=vt,nt.dataset.expandedSize=bt),De.style.removeProperty("display"),De.classList.remove("persona-pointer-events-none","persona-opacity-0"),le.classList.remove("persona-scale-95","persona-opacity-0","persona-scale-100","persona-opacity-100"),Ri(P),K.style.display=P?"flex":"none",to(),P?(Ei(),Li()):(ws(),As()),xn();return}let c=Lr(o),g=(se=r.ownerDocument.defaultView)!=null?se:window,b=(Ge=(ke=o.launcher)==null?void 0:ke.mobileBreakpoint)!=null?Ge:640,S=(ft=(Te=o.launcher)==null?void 0:Te.mobileFullscreen)!=null?ft:!0,W=g.innerWidth<=b,F=S&&W&&M,q=Bo(o).reveal;P?(De.style.removeProperty("display"),De.style.display=c?"flex":"",De.classList.remove("persona-pointer-events-none","persona-opacity-0"),le.classList.remove("persona-scale-95","persona-opacity-0"),le.classList.add("persona-scale-100","persona-opacity-100"),xr?xr.element.style.display="none":yr&&(yr.style.display="none")):(c?c&&(q==="overlay"||q==="push")&&!F?(De.style.removeProperty("display"),De.style.display="flex",De.classList.remove("persona-pointer-events-none","persona-opacity-0"),le.classList.remove("persona-scale-100","persona-opacity-100","persona-scale-95","persona-opacity-0")):(De.style.setProperty("display","none","important"),De.classList.remove("persona-pointer-events-none","persona-opacity-0"),le.classList.remove("persona-scale-100","persona-opacity-100","persona-scale-95","persona-opacity-0")):(De.style.display="",De.classList.add("persona-pointer-events-none","persona-opacity-0"),le.classList.remove("persona-scale-100","persona-opacity-100"),le.classList.add("persona-scale-95","persona-opacity-0")),xr?xr.element.style.display=c?"none":"":yr&&(yr.style.display=c?"none":""))},Gt=(c,g="user")=>{var F,q;if(!I()||P===c)return;let b=P;P=c,Wn();let S=(()=>{var Te,ft,Ze,bt,vt,He,Pe,Qe,ot,Ht;let G=(ft=(Te=o.launcher)==null?void 0:Te.sidebarMode)!=null?ft:!1,N=(Ze=r.ownerDocument.defaultView)!=null?Ze:window,Se=(vt=(bt=o.launcher)==null?void 0:bt.mobileFullscreen)!=null?vt:!0,xe=(Pe=(He=o.launcher)==null?void 0:He.mobileBreakpoint)!=null?Pe:640,se=N.innerWidth<=xe,ke=Lr(o)&&Se&&se,Ge=H()&&((Ht=(ot=(Qe=o.launcher)==null?void 0:Qe.composerBar)==null?void 0:ot.expandedSize)!=null?Ht:"fullscreen")==="fullscreen";return G||Se&&se&&M||ke||Ge})();if(P&&S){if(!re){let G=r.getRootNode(),N=G instanceof ShadowRoot?G.host:r.closest(".persona-host");N&&(re=Jp(N,(q=(F=o.launcher)==null?void 0:F.zIndex)!=null?q:so))}A||(A=Zp(r.ownerDocument))}else P||(re==null||re(),re=null,A==null||A(),A=null);P&&(Ms(),xt()==="follow"?ln(!0):vs());let W={open:P,source:g,timestamp:Date.now()};P&&!b?a.emit("widget:opened",W):!P&&b&&a.emit("widget:closed",W),a.emit("widget:state",{open:P,launcherEnabled:M,voiceActive:Lt.active,streaming:U.isStreaming()})},Da=c=>{or(c?"stop":"send"),X&&(X.disabled=c),at.buttons.forEach(g=>{g.disabled=c}),ze.dataset.personaComposerStreaming=c?"true":"false",ze.querySelectorAll("[data-persona-composer-disable-when-streaming]").forEach(g=>{(g instanceof HTMLButtonElement||g instanceof HTMLInputElement||g instanceof HTMLTextAreaElement||g instanceof HTMLSelectElement)&&(g.disabled=c)})},Oa=()=>{Lt.active||te&&te.focus()};a.on("widget:opened",()=>{o.autoFocusInput&&setTimeout(()=>Oa(),200)});let ea=()=>{var b,S,W,F,q,G,N,Se,xe,se,ke;Yr.textContent=(S=(b=o.copy)==null?void 0:b.welcomeTitle)!=null?S:"Hello \u{1F44B}",zr.textContent=(F=(W=o.copy)==null?void 0:W.welcomeSubtitle)!=null?F:"Ask anything about your account or products.",te.placeholder=(G=(q=o.copy)==null?void 0:q.inputPlaceholder)!=null?G:"How can I help...";let c=he.querySelector("[data-persona-intro-card]");if(c){let Ge=((N=o.copy)==null?void 0:N.showWelcomeCard)!==!1;c.style.display=Ge?"":"none",Ge?(he.classList.remove("persona-gap-3"),he.classList.add("persona-gap-6")):(he.classList.remove("persona-gap-6"),he.classList.add("persona-gap-3"))}!((xe=(Se=o.sendButton)==null?void 0:Se.useIcon)!=null&&xe)&&!(U!=null&&U.isStreaming())&&(_e.textContent=(ke=(se=o.copy)==null?void 0:se.sendButtonLabel)!=null?ke:"Send"),te.style.fontFamily='var(--persona-input-font-family, var(--persona-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif))',te.style.fontWeight="var(--persona-input-font-weight, var(--persona-font-weight, 400))"};o.clientToken&&(o={...o,getStoredSessionId:()=>{let c=d.sessionId;return typeof c=="string"?c:null},setStoredSessionId:c=>{m(g=>({...g,sessionId:c}))}});let Ke=null,R=()=>{Ke==null&&(Ke=setInterval(()=>{let c=it.querySelectorAll("[data-tool-elapsed]");if(c.length===0){clearInterval(Ke),Ke=null;return}let g=Date.now();c.forEach(b=>{let S=Number(b.getAttribute("data-tool-elapsed"));S&&(b.textContent=Zi(g-S))})},100))};if(U=new Za(o,{onMessagesChanged(c){var S;Zn(it,c,ve),R(),nr(c),ln(!mr),ki(c);let g=[...c].reverse().find(W=>W.role==="user");c.length===0&&Jn(),!Pa||Yn?(Pa=!0,Ra=(S=g==null?void 0:g.id)!=null?S:null):g&&g.id!==Ra&&(Ra=g.id,Mi(g.id));let b=Lt.lastUserMessageId;g&&g.id!==b&&(Lt.lastUserMessageId=g.id,a.emit("user:message",g)),Lt.lastUserMessageWasVoice=!!(g!=null&&g.viaVoice),Wa(c),xn()},onStatusChanged(c){var S;let g=(S=o.statusIndicator)!=null?S:{};Ye(dr,(W=>{var F,q,G,N;return W==="idle"?(F=g.idleText)!=null?F:ao.idle:W==="connecting"?(q=g.connectingText)!=null?q:ao.connecting:W==="connected"?(G=g.connectedText)!=null?G:ao.connected:W==="error"?(N=g.errorText)!=null?N:ao.error:ao[W]})(c),g,c)},onStreamingChanged(c){mr=c,Da(c),U&&Zn(it,U.getMessages(),ve),c||ln(!0),xn()},onVoiceStatusChanged(c){var g,b;if(((b=(g=o.voiceRecognition)==null?void 0:g.provider)==null?void 0:b.type)==="runtype")switch(c){case"listening":break;case"processing":Bn(),rb();break;case"speaking":Bn(),ob();break;default:c==="idle"&&U.isBargeInActive()?(Bn(),Ts(),X==null||X.setAttribute("aria-label","End voice session")):(Lt.active=!1,Bn(),zo("system"),So());break}},onArtifactsState(c){po=c,eo(),Wa()}}),Wt.current=U,Pa=!0,((Bf=(Wf=o.voiceRecognition)==null?void 0:Wf.provider)==null?void 0:Bf.type)==="runtype")try{U.setupVoice()}catch(c){typeof console!="undefined"&&console.warn("[AgentWidget] Runtype voice setup failed:",c)}o.clientToken&&U.initClientSession().catch(c=>{o.debug&&console.warn("[AgentWidget] Pre-init client session failed:",c)}),(be||o.onSSEEvent)&&U.setSSEEventCallback((c,g)=>{var b;(b=o.onSSEEvent)==null||b.call(o,c,g),ye==null||ye.processEvent(c,g),be==null||be.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:c,timestamp:Date.now(),payload:JSON.stringify(g)})}),l&&l.then(c=>{var g,b,S;if(c){if(c.metadata&&(d=gu(c.metadata),T.syncFromMetadata()),(g=c.messages)!=null&&g.length){Yn=!0;try{U.hydrateMessages(c.messages)}finally{Yn=!1}}(b=c.artifacts)!=null&&b.length&&U.hydrateArtifacts(c.artifacts,(S=c.selectedArtifactId)!=null?S:null)}}).catch(c=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to hydrate stored state:",c)});let V=()=>{var g,b,S;!H()||P||!((S=(b=(g=o.launcher)==null?void 0:g.composerBar)==null?void 0:b.expandOnSubmit)==null||S)||Gt(!0,"auto")},B=c=>{var W;if(c.preventDefault(),U.isStreaming()){U.cancel(),ye==null||ye.reset(),Y==null||Y.update();return}let g=te.value.trim(),b=(W=je==null?void 0:je.hasAttachments())!=null?W:!1;if(!g&&!b)return;V();let S;b&&(S=[],S.push(...je.getContentParts()),g&&S.push(Qs(g))),te.value="",te.style.height="auto",Le(),U.sendMessage(g,{contentParts:S}),b&&je.clearAttachments()},oe=()=>{var c;return((c=o.features)==null?void 0:c.composerHistory)!==!1},pe={...Pl},J=!1,Le=()=>{pe={...Pl}},Ve=()=>U.getMessages().filter(c=>c.role==="user").map(c=>{var g;return(g=c.content)!=null?g:""}).filter(c=>c.length>0),yt=c=>{if(!te)return;J=!0,te.value=c,te.dispatchEvent(new Event("input",{bubbles:!0})),J=!1;let g=te.value.length;te.setSelectionRange(g,g)},dt=()=>{J||Le()},Vt=c=>{if(te){if(oe()&&(c.key==="ArrowUp"||c.key==="ArrowDown")&&!c.shiftKey&&!c.metaKey&&!c.ctrlKey&&!c.altKey&&!c.isComposing){let g=te.selectionStart===0&&te.selectionEnd===0,b=wx({direction:c.key==="ArrowUp"?"up":"down",history:Ve(),currentValue:te.value,atStart:g,state:pe});if(pe=b.state,b.handled){c.preventDefault(),b.value!==void 0&&yt(b.value);return}}if(c.key==="Enter"&&!c.shiftKey){if(U.isStreaming()){c.preventDefault();return}Le(),c.preventDefault(),_e.click()}}},Jt=c=>{c.key!=="Escape"||c.isComposing||U.isStreaming()&&c.composedPath().includes(K)&&(U.cancel(),ye==null||ye.reset(),Y==null||Y.update(),Le(),c.preventDefault(),c.stopImmediatePropagation())},Rr=async c=>{var b;if(((b=o.attachments)==null?void 0:b.enabled)!==!0||!je)return;let g=JC(c.clipboardData);g.length!==0&&(c.preventDefault(),await je.handleFiles(g))},ht=null,kt=!1,gr=null,et=null,jr=()=>typeof window=="undefined"?null:window.webkitSpeechRecognition||window.SpeechRecognition||null,pr=(c="user")=>{var F,q,G,N,Se,xe,se;if(kt||U.isStreaming())return;let g=jr();if(!g)return;ht=new g;let S=(q=((F=o.voiceRecognition)!=null?F:{}).pauseDuration)!=null?q:2e3;ht.continuous=!0,ht.interimResults=!0,ht.lang="en-US";let W=te.value;ht.onresult=ke=>{let Ge="",Te="";for(let Ze=0;Ze<ke.results.length;Ze++){let bt=ke.results[Ze],vt=bt[0].transcript;bt.isFinal?Ge+=vt+" ":Te=vt}let ft=W+Ge+Te;te.value=ft,gr&&clearTimeout(gr),(Ge||Te)&&(gr=window.setTimeout(()=>{let Ze=te.value.trim();Ze&&ht&&kt&&(Ur(),te.value="",te.style.height="auto",U.sendMessage(Ze,{viaVoice:!0}))},S))},ht.onerror=ke=>{ke.error!=="no-speech"&&Ur()},ht.onend=()=>{if(kt){let ke=te.value.trim();ke&&ke!==W.trim()&&(te.value="",te.style.height="auto",U.sendMessage(ke,{viaVoice:!0})),Ur()}};try{if(ht.start(),kt=!0,Lt.active=!0,c!=="system"&&(Lt.manuallyDeactivated=!1),zo(c),So(),X){let ke=(G=o.voiceRecognition)!=null?G:{};et={backgroundColor:X.style.backgroundColor,color:X.style.color,borderColor:X.style.borderColor,iconName:(N=ke.iconName)!=null?N:"mic",iconSize:parseFloat((se=(xe=ke.iconSize)!=null?xe:(Se=o.sendButton)==null?void 0:Se.size)!=null?se:"40")||24};let Ge=ke.recordingBackgroundColor,Te=ke.recordingIconColor,ft=ke.recordingBorderColor;if(X.classList.add("persona-voice-recording"),X.style.backgroundColor=Ge!=null?Ge:"var(--persona-voice-recording-bg, #ef4444)",X.style.color=Te!=null?Te:"var(--persona-voice-recording-indicator, #ffffff)",Te){let Ze=X.querySelector("svg");Ze&&Ze.setAttribute("stroke",Te)}ft&&(X.style.borderColor=ft),X.setAttribute("aria-label","Stop voice recognition")}}catch{Ur("system")}},Ur=(c="user")=>{if(kt){if(kt=!1,gr&&(clearTimeout(gr),gr=null),ht){try{ht.stop()}catch{}ht=null}if(Lt.active=!1,zo(c),So(),X){if(X.classList.remove("persona-voice-recording"),et){X.style.backgroundColor=et.backgroundColor,X.style.color=et.color,X.style.borderColor=et.borderColor;let g=X.querySelector("svg");g&&g.setAttribute("stroke",et.color||"currentColor"),et=null}X.setAttribute("aria-label","Start voice recognition")}}},tb=(c,g)=>{var bt,vt,He,Pe,Qe,ot,Ht,D;let b=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),S=((bt=c==null?void 0:c.provider)==null?void 0:bt.type)==="runtype";if(!(b||S))return null;let F=C("div","persona-send-button-wrapper"),q=C("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer");q.type="button",q.setAttribute("aria-label","Start voice recognition");let G=(vt=c==null?void 0:c.iconName)!=null?vt:"mic",N=(He=g==null?void 0:g.size)!=null?He:"40px",Se=(Pe=c==null?void 0:c.iconSize)!=null?Pe:N,xe=parseFloat(Se)||24,se=(Qe=c==null?void 0:c.backgroundColor)!=null?Qe:g==null?void 0:g.backgroundColor,ke=(ot=c==null?void 0:c.iconColor)!=null?ot:g==null?void 0:g.textColor;q.style.width=Se,q.style.height=Se,q.style.minWidth=Se,q.style.minHeight=Se,q.style.fontSize="18px",q.style.lineHeight="1",ke?q.style.color=ke:q.style.color="var(--persona-text, #111827)";let Te=Ee(G,xe,ke||"currentColor",1.5);Te?q.appendChild(Te):q.textContent="\u{1F3A4}",se?q.style.backgroundColor=se:q.style.backgroundColor="",c!=null&&c.borderWidth&&(q.style.borderWidth=c.borderWidth,q.style.borderStyle="solid"),c!=null&&c.borderColor&&(q.style.borderColor=c.borderColor),c!=null&&c.paddingX&&(q.style.paddingLeft=c.paddingX,q.style.paddingRight=c.paddingX),c!=null&&c.paddingY&&(q.style.paddingTop=c.paddingY,q.style.paddingBottom=c.paddingY),F.appendChild(q);let ft=(Ht=c==null?void 0:c.tooltipText)!=null?Ht:"Start voice recognition";if(((D=c==null?void 0:c.showTooltip)!=null?D:!1)&&ft){let Ne=C("div","persona-send-button-tooltip");Ne.textContent=ft,F.appendChild(Ne)}return{micButton:q,micButtonWrapper:F}},cd=()=>{var g,b,S,W,F;if(!X||et)return;let c=(g=o.voiceRecognition)!=null?g:{};et={backgroundColor:X.style.backgroundColor,color:X.style.color,borderColor:X.style.borderColor,iconName:(b=c.iconName)!=null?b:"mic",iconSize:parseFloat((F=(W=c.iconSize)!=null?W:(S=o.sendButton)==null?void 0:S.size)!=null?F:"40")||24}},pd=(c,g)=>{var F,q,G,N,Se;if(!X)return;let b=X.querySelector("svg");b&&b.remove();let S=(Se=et==null?void 0:et.iconSize)!=null?Se:parseFloat((N=(G=(F=o.voiceRecognition)==null?void 0:F.iconSize)!=null?G:(q=o.sendButton)==null?void 0:q.size)!=null?N:"40")||24,W=Ee(c,S,g,1.5);W&&X.appendChild(W)},Ii=()=>{X&&X.classList.remove("persona-voice-recording","persona-voice-processing","persona-voice-speaking")},Ts=()=>{var W;if(!X)return;cd();let c=(W=o.voiceRecognition)!=null?W:{},g=c.recordingBackgroundColor,b=c.recordingIconColor,S=c.recordingBorderColor;if(Ii(),X.classList.add("persona-voice-recording"),X.style.backgroundColor=g!=null?g:"var(--persona-voice-recording-bg, #ef4444)",X.style.color=b!=null?b:"var(--persona-voice-recording-indicator, #ffffff)",b){let F=X.querySelector("svg");F&&F.setAttribute("stroke",b)}S&&(X.style.borderColor=S),X.setAttribute("aria-label","Stop voice recognition")},rb=()=>{var G,N,Se,xe,se,ke,Ge,Te;if(!X)return;cd();let c=(G=o.voiceRecognition)!=null?G:{},g=U.getVoiceInterruptionMode(),b=(N=c.processingIconName)!=null?N:"loader",S=(xe=(Se=c.processingIconColor)!=null?Se:et==null?void 0:et.color)!=null?xe:"",W=(ke=(se=c.processingBackgroundColor)!=null?se:et==null?void 0:et.backgroundColor)!=null?ke:"",F=(Te=(Ge=c.processingBorderColor)!=null?Ge:et==null?void 0:et.borderColor)!=null?Te:"";Ii(),X.classList.add("persona-voice-processing"),X.style.backgroundColor=W,X.style.borderColor=F;let q=S||"currentColor";X.style.color=q,pd(b,q),X.setAttribute("aria-label","Processing voice input"),g==="none"&&(X.style.cursor="default")},ob=()=>{var Se,xe,se,ke,Ge,Te,ft,Ze,bt,vt,He,Pe;if(!X)return;cd();let c=(Se=o.voiceRecognition)!=null?Se:{},g=U.getVoiceInterruptionMode(),b=g==="cancel"?"square":g==="barge-in"?"mic":"volume-2",S=(xe=c.speakingIconName)!=null?xe:b,W=(Te=c.speakingIconColor)!=null?Te:g==="barge-in"?(ke=(se=c.recordingIconColor)!=null?se:et==null?void 0:et.color)!=null?ke:"":(Ge=et==null?void 0:et.color)!=null?Ge:"",F=(bt=c.speakingBackgroundColor)!=null?bt:g==="barge-in"?(ft=c.recordingBackgroundColor)!=null?ft:"var(--persona-voice-recording-bg, #ef4444)":(Ze=et==null?void 0:et.backgroundColor)!=null?Ze:"",q=(Pe=c.speakingBorderColor)!=null?Pe:g==="barge-in"?(vt=c.recordingBorderColor)!=null?vt:"":(He=et==null?void 0:et.borderColor)!=null?He:"";Ii(),X.classList.add("persona-voice-speaking"),X.style.backgroundColor=F,X.style.borderColor=q;let G=W||"currentColor";X.style.color=G,pd(S,G);let N=g==="cancel"?"Stop playback and re-record":g==="barge-in"?"Speak to interrupt":"Agent is speaking";X.setAttribute("aria-label",N),g==="none"&&(X.style.cursor="default"),g==="barge-in"&&X.classList.add("persona-voice-recording")},Bn=()=>{var c,g,b;X&&(Ii(),et&&(X.style.backgroundColor=(c=et.backgroundColor)!=null?c:"",X.style.color=(g=et.color)!=null?g:"",X.style.borderColor=(b=et.borderColor)!=null?b:"",pd(et.iconName,et.color||"currentColor"),et=null),X.style.cursor="",X.setAttribute("aria-label","Start voice recognition"))},Hi=()=>{var c,g;if(((g=(c=o.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"){let b=U.getVoiceStatus(),S=U.getVoiceInterruptionMode();if(S==="none"&&(b==="processing"||b==="speaking"))return;if(S==="cancel"&&(b==="processing"||b==="speaking")){U.stopVoicePlayback();return}if(U.isBargeInActive()){U.stopVoicePlayback(),U.deactivateBargeIn().then(()=>{Lt.active=!1,Lt.manuallyDeactivated=!0,So(),zo("user"),Bn()});return}U.toggleVoice().then(()=>{Lt.active=U.isVoiceActive(),Lt.manuallyDeactivated=!U.isVoiceActive(),So(),zo("user"),U.isVoiceActive()?Ts():Bn()});return}if(kt){let b=te.value.trim();Lt.manuallyDeactivated=!0,So(),Ur("user"),b&&(te.value="",te.style.height="auto",U.sendMessage(b))}else Lt.manuallyDeactivated=!1,So(),pr("user")};Tr=Hi,X&&(X.addEventListener("click",Hi),gt.push(()=>{var c,g;((g=(c=o.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?(U.isVoiceActive()&&U.toggleVoice(),Bn()):Ur("system"),X&&X.removeEventListener("click",Hi)}));let nb=a.on("assistant:complete",()=>{fs&&(Lt.active||Lt.manuallyDeactivated||fs==="assistant"&&!Lt.lastUserMessageWasVoice||setTimeout(()=>{var c,g;!Lt.active&&!Lt.manuallyDeactivated&&(((g=(c=o.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?U.toggleVoice().then(()=>{Lt.active=U.isVoiceActive(),zo("auto"),U.isVoiceActive()&&Ts()}):pr("auto"))},600))});gt.push(nb);let ab=a.on("action:resubmit",()=>{setTimeout(()=>{U&&!U.isStreaming()&&U.continueConversation()},100)});gt.push(ab);let _a=()=>{Gt(!P,"user")},xr=null,yr=null;if(M&&!H()){let c=n.find(g=>g.renderLauncher);if(c!=null&&c.renderLauncher){let g=c.renderLauncher({config:o,defaultRenderer:()=>di(o,_a).element,onToggle:_a});g&&(yr=g)}yr||(xr=di(o,_a))}xr?r.appendChild(xr.element):yr&&r.appendChild(yr),Wn(),nr(),ea(),Da(U.isStreaming()),xt()==="follow"?ln(!0):vs(),Ci(),L&&(!M||H()?setTimeout(()=>Oa(),0):P&&setTimeout(()=>Oa(),200));let Ms=()=>{var N,Se,xe,se,ke,Ge,Te,ft,Ze,bt,vt,He,Pe,Qe,ot,Ht,D,Ne,Fe,we,Qt,Kt;if(H()){Sr(),Wn();return}let c=Lr(o),g=(Se=(N=o.launcher)==null?void 0:N.sidebarMode)!=null?Se:!1,b=c||g||((se=(xe=o.launcher)==null?void 0:xe.fullHeight)!=null?se:!1),S=(ke=r.ownerDocument.defaultView)!=null?ke:window,W=(Te=(Ge=o.launcher)==null?void 0:Ge.mobileFullscreen)!=null?Te:!0,F=(Ze=(ft=o.launcher)==null?void 0:ft.mobileBreakpoint)!=null?Ze:640,q=S.innerWidth<=F,G=W&&q&&M;try{if(G){to(),Vn(r,o);return}if(E&&(E=!1,to(),Vn(r,o)),!M&&!c){le.style.height="",le.style.width="";return}if(!g&&!c){let ir=(vt=(bt=o==null?void 0:o.launcher)==null?void 0:bt.width)!=null?vt:o==null?void 0:o.launcherWidth,Bt=ir!=null?ir:Wo;le.style.width=Bt,le.style.maxWidth=Bt}if(qo(),!b){let ir=S.innerHeight,Bt=64,ar=(Pe=(He=o.launcher)==null?void 0:He.heightOffset)!=null?Pe:0,Po=Math.max(200,ir-Bt),wr=Math.min(640,Po),st=Math.max(200,wr-ar);le.style.height=`${st}px`}}finally{if(Sr(),Wn(),P&&M){let Bt=((Qe=r.ownerDocument.defaultView)!=null?Qe:window).innerWidth<=((Ht=(ot=o.launcher)==null?void 0:ot.mobileBreakpoint)!=null?Ht:640),ar=(Ne=(D=o.launcher)==null?void 0:D.sidebarMode)!=null?Ne:!1,Po=(we=(Fe=o.launcher)==null?void 0:Fe.mobileFullscreen)!=null?we:!0,wr=Lr(o)&&Po&&Bt,st=ar||Po&&Bt&&M||wr;if(st&&!A){let Ut=r.getRootNode(),kr=Ut instanceof ShadowRoot?Ut.host:r.closest(".persona-host");kr&&!re&&(re=Jp(kr,(Kt=(Qt=o.launcher)==null?void 0:Qt.zIndex)!=null?Kt:so)),A=Zp(r.ownerDocument)}else st||(re==null||re(),re=null,A==null||A(),A=null)}}};Ms();let Iu=(Df=r.ownerDocument.defaultView)!=null?Df:window;if(Iu.addEventListener("resize",Ms),gt.push(()=>Iu.removeEventListener("resize",Ms)),typeof ResizeObserver!="undefined"){let c=new ResizeObserver(()=>{Sr()});c.observe(ze),gt.push(()=>c.disconnect())}Lo=he.scrollTop;let Hu=Mn(he),sb=()=>{let c=he.getRootNode(),g=typeof c.getSelection=="function"?c.getSelection():null;return g!=null?g:he.ownerDocument.getSelection()},ud=()=>Ex(sb(),he),Wu=()=>{let c=he.scrollTop,g=Mn(he),b=g<Hu;if(Hu=g,xt()!=="follow"){Lo=c,To();return}let{action:S,nextLastScrollTop:W}=Il({following:Eo.isFollowing(),currentScrollTop:c,lastScrollTop:Lo,nearBottom:Aa(he,Ia),userScrollThreshold:bi,isAutoScrolling:Qo||Qn||b,pauseOnUpwardScroll:!0,pauseWhenAwayFromBottom:!1,resumeRequiresDownwardScroll:!0});if(Lo=W,S==="resume"){ud()||sn();return}S==="pause"&&Ba()};if(he.addEventListener("scroll",Wu,{passive:!0}),gt.push(()=>he.removeEventListener("scroll",Wu)),typeof ResizeObserver!="undefined"){let c=new ResizeObserver(()=>{Ti()});c.observe(it),c.observe(he),gt.push(()=>c.disconnect())}let Bu=()=>{xt()==="follow"&&Eo.isFollowing()&&ud()&&Ba()},Du=he.ownerDocument;Du.addEventListener("selectionchange",Bu),gt.push(()=>{Du.removeEventListener("selectionchange",Bu)});let Ou=c=>{if(xt()!=="follow")return;let g=Hl({following:Eo.isFollowing(),deltaY:c.deltaY,nearBottom:Aa(he,Ia),resumeWhenNearBottom:!0});g==="pause"?Ba():g==="resume"&&!ud()&&sn()};he.addEventListener("wheel",Ou,{passive:!0}),gt.push(()=>he.removeEventListener("wheel",Ou)),tt.addEventListener("click",()=>{Jn(),he.scrollTop=he.scrollHeight,Lo=he.scrollTop,sn(),ln(!0),To()}),gt.push(()=>tt.remove()),gt.push(()=>{gs(),Jn()});let _u=()=>{O&&(ut&&(O.removeEventListener("click",ut),ut=null),I()?(O.style.display="",ut=()=>{Gt(!1,"user")},O.addEventListener("click",ut)):O.style.display="none")};_u(),(()=>{let{clearChatButton:c}=Re;c&&c.addEventListener("click",()=>{U.clearMessages(),Cr.clear(),sn(),zn(Re.composerOverlay);try{localStorage.removeItem(cs),o.debug&&console.log(`[AgentWidget] Cleared default localStorage key: ${cs}`)}catch(b){console.error("[AgentWidget] Failed to clear default localStorage:",b)}if(o.clearChatHistoryStorageKey&&o.clearChatHistoryStorageKey!==cs)try{localStorage.removeItem(o.clearChatHistoryStorageKey),o.debug&&console.log(`[AgentWidget] Cleared custom localStorage key: ${o.clearChatHistoryStorageKey}`)}catch(b){console.error("[AgentWidget] Failed to clear custom localStorage:",b)}let g=new CustomEvent("persona:clear-chat",{detail:{timestamp:new Date().toISOString()}});if(window.dispatchEvent(g),i!=null&&i.clear)try{let b=i.clear();b instanceof Promise&&b.catch(S=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",S)})}catch(b){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",b)}d={},T.syncFromMetadata(),be==null||be.clear(),ye==null||ye.reset(),Y==null||Y.update()})})(),Rt&&Rt.addEventListener("submit",B),te==null||te.addEventListener("keydown",Vt),te==null||te.addEventListener("input",dt),te==null||te.addEventListener("paste",Rr);let Nu=(Of=r.ownerDocument)!=null?Of:document;Nu.addEventListener("keydown",Jt,!0);let Fu="persona-attachment-drop-active",ks=0,fd=()=>{ks=0,K.classList.remove(Fu)},Na=()=>{var c;return((c=o.attachments)==null?void 0:c.enabled)===!0&&je!==null},Uu=c=>{!ad(c.dataTransfer)||!Na()||(ks++,ks===1&&K.classList.add(Fu))},qu=c=>{!ad(c.dataTransfer)||!Na()||(ks--,ks<=0&&fd())},zu=c=>{!ad(c.dataTransfer)||!Na()||(c.preventDefault(),c.dataTransfer.dropEffect="copy")},$u=c=>{var b;if(!ad(c.dataTransfer)||!Na())return;c.preventDefault(),c.stopPropagation(),fd();let g=Array.from((b=c.dataTransfer.files)!=null?b:[]);g.length!==0&&je.handleFiles(g)},Dn=!0;K.addEventListener("dragenter",Uu,Dn),K.addEventListener("dragleave",qu,Dn),r.addEventListener("dragover",zu,Dn),r.addEventListener("drop",$u,Dn);let Wi=r.ownerDocument,Vu=c=>{Na()&&c.preventDefault()},ju=c=>{Na()&&c.preventDefault()};Wi.addEventListener("dragover",Vu),Wi.addEventListener("drop",ju),gt.push(()=>{Rt&&Rt.removeEventListener("submit",B),te==null||te.removeEventListener("keydown",Vt),te==null||te.removeEventListener("input",dt),te==null||te.removeEventListener("paste",Rr),Nu.removeEventListener("keydown",Jt,!0)}),gt.push(()=>{K.removeEventListener("dragenter",Uu,Dn),K.removeEventListener("dragleave",qu,Dn),r.removeEventListener("dragover",zu,Dn),r.removeEventListener("drop",$u,Dn),Wi.removeEventListener("dragover",Vu),Wi.removeEventListener("drop",ju),fd()}),gt.push(()=>{U.cancel()}),xr?gt.push(()=>{xr==null||xr.destroy()}):yr&>.push(()=>{yr==null||yr.remove()});let Mr={update(c){var oo,ho,dn,qr,xo,yo,aa,Es,$f,Vf,jf,Gf,Kf,Xf,Qf,Yf,Jf,Zf,em,tm,rm,om,nm,am,sm,im,lm,dm,cm,pm,um,fm,mm,gm,hm,xm,ym,bm,vm,Cm,wm,Am,Sm,Tm,Mm,km,Em,Lm,Pm,Rm,Im,Hm,Wm,Bm,Dm,Om,_m,Nm,Fm,Um,qm,zm,$m,Vm,jm,Gm,Km,Xm,Qm,Ym,Jm,Zm,eg,tg,rg,og,ng,ag,sg,ig,lg,dg,cg,pg,ug,fg,mg,gg,hg,xg,yg,bg,vg,Cg,wg,Ag,Sg,Tg,Mg,kg,Eg,Lg,Pg,Rg,Ig,Hg,Wg,Bg,Dg,Og,_g,Ng,Fg,Ug,qg;let g=o.toolCall,b=o.messageActions,S=(oo=o.layout)==null?void 0:oo.messages,W=o.colorScheme,F=o.loadingIndicator,q=o.iterationDisplay,G=(ho=o.features)==null?void 0:ho.showReasoning,N=(dn=o.features)==null?void 0:dn.showToolCalls,Se=(qr=o.features)==null?void 0:qr.toolCallDisplay,xe=(xo=o.features)==null?void 0:xo.reasoningDisplay;o={...o,...c},to(),Vn(r,o),Ql(r,o),Yl(r,o),eo(),o.colorScheme!==W&&ue();let se=mi.getForInstance(o.plugins);n.length=0,n.push(...se),M=(aa=(yo=o.launcher)==null?void 0:yo.enabled)!=null?aa:!0,k=($f=(Es=o.launcher)==null?void 0:Es.autoExpand)!=null?$f:!1,Xe=(jf=(Vf=o.features)==null?void 0:Vf.showReasoning)!=null?jf:!0,Ae=(Kf=(Gf=o.features)==null?void 0:Gf.showToolCalls)!=null?Kf:!0,Me=(Qf=(Xf=o.features)==null?void 0:Xf.scrollToBottom)!=null?Qf:{};let ke=xt();Ue=(Jf=(Yf=o.features)==null?void 0:Yf.scrollBehavior)!=null?Jf:{},ke!==xt()&&(Jn(),sn()),Oo(),To();let Ge=We;if(We=(em=(Zf=o.features)==null?void 0:Zf.showEventStreamToggle)!=null?em:!1,We&&!Ge){if(be||(ne=new ui(Z),be=new pi(me,ne),ye=ye!=null?ye:new fi,ne.open().then(()=>be==null?void 0:be.restore()).catch(()=>{}),U.setSSEEventCallback((ee,Ot)=>{var er;(er=o.onSSEEvent)==null||er.call(o,ee,Ot),ye==null||ye.processEvent(ee,Ot),be.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:ee,timestamp:Date.now(),payload:JSON.stringify(Ot)})})),!At&&qe){let ee=(rm=(tm=o.features)==null?void 0:tm.eventStream)==null?void 0:rm.classNames,Ot="persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1"+(ee!=null&&ee.toggleButton?" "+ee.toggleButton:"");At=C("button",Ot),At.style.width="28px",At.style.height="28px",At.style.color=Ao.actionIconColor,At.type="button",At.setAttribute("aria-label","Event Stream"),At.title="Event Stream";let er=Ee("activity","18px","currentColor",1.5);er&&At.appendChild(er);let Ct=Re.clearChatButtonWrapper,qt=Re.closeButtonWrapper,Hr=Ct||qt;Hr&&Hr.parentNode===qe?qe.insertBefore(At,Hr):qe.appendChild(At),At.addEventListener("click",()=>{ge?lo():_o()})}}else!We&&Ge&&(lo(),At&&(At.remove(),At=null),be==null||be.clear(),ne==null||ne.destroy(),be=null,ne=null,ye==null||ye.reset(),ye=null);if(((om=o.launcher)==null?void 0:om.enabled)===!1&&xr&&(xr.destroy(),xr=null),((nm=o.launcher)==null?void 0:nm.enabled)===!1&&yr&&(yr.remove(),yr=null),((am=o.launcher)==null?void 0:am.enabled)!==!1&&!xr&&!yr){let ee=n.find(Ot=>Ot.renderLauncher);if(ee!=null&&ee.renderLauncher){let Ot=ee.renderLauncher({config:o,defaultRenderer:()=>di(o,_a).element,onToggle:_a});Ot&&(yr=Ot,r.appendChild(yr))}yr||(xr=di(o,_a),r.appendChild(xr.element))}xr&&xr.update(o),Ie&&((sm=o.launcher)==null?void 0:sm.title)!==void 0&&(Ie.textContent=o.launcher.title),Je&&((im=o.launcher)==null?void 0:im.subtitle)!==void 0&&(Je.textContent=o.launcher.subtitle);let Te=(lm=o.layout)==null?void 0:lm.header;if((Te==null?void 0:Te.layout)!==v&&qe){let ee=Te?os(o,Te,{showClose:I(),onClose:()=>Gt(!1,"user")}):kn({config:o,showClose:I(),onClose:()=>Gt(!1,"user")});qe.replaceWith(ee.header),qe=ee.header,fe=ee.iconHolder,Ie=ee.headerTitle,Je=ee.headerSubtitle,O=ee.closeButton,v=Te==null?void 0:Te.layout}else if(Te&&(fe&&(fe.style.display=Te.showIcon===!1?"none":""),Ie&&(Ie.style.display=Te.showTitle===!1?"none":""),Je&&(Je.style.display=Te.showSubtitle===!1?"none":""),O&&(O.style.display=Te.showCloseButton===!1?"none":""),Re.clearChatButtonWrapper)){let ee=Te.showClearChat;if(ee!==void 0){Re.clearChatButtonWrapper.style.display=ee?"":"none";let{closeButtonWrapper:Ot}=Re;Ot&&!Ot.classList.contains("persona-absolute")&&(ee?Ot.classList.remove("persona-ml-auto"):Ot.classList.add("persona-ml-auto"))}}let Ze=((dm=o.layout)==null?void 0:dm.showHeader)!==!1;qe&&(qe.style.display=Ze?"":"none");let bt=((cm=o.layout)==null?void 0:cm.showFooter)!==!1;ze&&(ze.style.display=bt?"":"none"),Sr(),To(),M!==w?M?Gt(k,"auto"):(P=!0,Wn()):k!==x&&Gt(k,"auto"),x=k,w=M,Ms(),_u();let Pe=JSON.stringify(c.toolCall)!==JSON.stringify(g),Qe=JSON.stringify(o.messageActions)!==JSON.stringify(b),ot=JSON.stringify((pm=o.layout)==null?void 0:pm.messages)!==JSON.stringify(S),Ht=((um=o.loadingIndicator)==null?void 0:um.render)!==(F==null?void 0:F.render)||((fm=o.loadingIndicator)==null?void 0:fm.renderIdle)!==(F==null?void 0:F.renderIdle)||((mm=o.loadingIndicator)==null?void 0:mm.showBubble)!==(F==null?void 0:F.showBubble),D=o.iterationDisplay!==q,Ne=((hm=(gm=o.features)==null?void 0:gm.showReasoning)!=null?hm:!0)!==(G!=null?G:!0)||((ym=(xm=o.features)==null?void 0:xm.showToolCalls)!=null?ym:!0)!==(N!=null?N:!0)||JSON.stringify((bm=o.features)==null?void 0:bm.toolCallDisplay)!==JSON.stringify(Se)||JSON.stringify((vm=o.features)==null?void 0:vm.reasoningDisplay)!==JSON.stringify(xe);(Pe||Qe||ot||Ht||D||Ne)&&U&&(us++,Zn(it,U.getMessages(),ve));let we=(Cm=o.launcher)!=null?Cm:{},Qt=(wm=we.headerIconHidden)!=null?wm:!1,Kt=(Sm=(Am=o.layout)==null?void 0:Am.header)==null?void 0:Sm.showIcon,ir=Qt||Kt===!1,Bt=we.headerIconName,ar=(Tm=we.headerIconSize)!=null?Tm:"48px";if(fe){let ee=K.querySelector(".persona-border-b-persona-divider"),Ot=ee==null?void 0:ee.querySelector(".persona-flex-col");if(ir)fe.style.display="none",ee&&Ot&&!ee.contains(Ot)&&ee.insertBefore(Ot,ee.firstChild);else{if(fe.style.display="",fe.style.height=ar,fe.style.width=ar,ee&&Ot&&(ee.contains(fe)?fe.nextSibling!==Ot&&(fe.remove(),ee.insertBefore(fe,Ot)):ee.insertBefore(fe,Ot)),Bt){let Ct=parseFloat(ar)||24,qt=Ee(Bt,Ct*.6,"#ffffff",2);qt?fe.replaceChildren(qt):fe.textContent=(Mm=we.agentIconText)!=null?Mm:"\u{1F4AC}"}else if(we.iconUrl){let Ct=fe.querySelector("img");if(Ct)Ct.src=we.iconUrl,Ct.style.height=ar,Ct.style.width=ar;else{let qt=document.createElement("img");qt.src=we.iconUrl,qt.alt="",qt.className="persona-rounded-xl persona-object-cover",qt.style.height=ar,qt.style.width=ar,fe.replaceChildren(qt)}}else{let Ct=fe.querySelector("svg"),qt=fe.querySelector("img");(Ct||qt)&&fe.replaceChildren(),fe.textContent=(km=we.agentIconText)!=null?km:"\u{1F4AC}"}let er=fe.querySelector("img");er&&(er.style.height=ar,er.style.width=ar)}}let Po=(Lm=(Em=o.layout)==null?void 0:Em.header)==null?void 0:Lm.showTitle,wr=(Rm=(Pm=o.layout)==null?void 0:Pm.header)==null?void 0:Rm.showSubtitle;if(Ie&&(Ie.style.display=Po===!1?"none":""),Je&&(Je.style.display=wr===!1?"none":""),O){((Hm=(Im=o.layout)==null?void 0:Im.header)==null?void 0:Hm.showCloseButton)===!1?O.style.display="none":O.style.display="";let Ot=(Wm=we.closeButtonSize)!=null?Wm:"32px",er=(Bm=we.closeButtonPlacement)!=null?Bm:"inline";O.style.height=Ot,O.style.width=Ot;let{closeButtonWrapper:Ct}=Re,qt=er==="top-right",Hr=Ct==null?void 0:Ct.classList.contains("persona-absolute");if(Ct&&qt!==Hr)if(Ct.remove(),qt)Ct.className="persona-absolute persona-top-4 persona-right-4 persona-z-50",K.style.position="relative",K.appendChild(Ct);else{let St=(Om=(Dm=we.clearChat)==null?void 0:Dm.placement)!=null?Om:"inline",Wr=(Nm=(_m=we.clearChat)==null?void 0:_m.enabled)!=null?Nm:!0;Ct.className=Wr&&St==="inline"?"":"persona-ml-auto";let Mo=K.querySelector(".persona-border-b-persona-divider");Mo&&Mo.appendChild(Ct)}if(O.style.color=we.closeButtonColor||Ao.actionIconColor,we.closeButtonBackgroundColor?(O.style.backgroundColor=we.closeButtonBackgroundColor,O.classList.remove("hover:persona-bg-gray-100")):(O.style.backgroundColor="",O.classList.add("hover:persona-bg-gray-100")),we.closeButtonBorderWidth||we.closeButtonBorderColor){let St=we.closeButtonBorderWidth||"0px",Wr=we.closeButtonBorderColor||"transparent";O.style.border=`${St} solid ${Wr}`,O.classList.remove("persona-border-none")}else O.style.border="",O.classList.add("persona-border-none");we.closeButtonBorderRadius?(O.style.borderRadius=we.closeButtonBorderRadius,O.classList.remove("persona-rounded-full")):(O.style.borderRadius="",O.classList.add("persona-rounded-full")),we.closeButtonPaddingX?(O.style.paddingLeft=we.closeButtonPaddingX,O.style.paddingRight=we.closeButtonPaddingX):(O.style.paddingLeft="",O.style.paddingRight=""),we.closeButtonPaddingY?(O.style.paddingTop=we.closeButtonPaddingY,O.style.paddingBottom=we.closeButtonPaddingY):(O.style.paddingTop="",O.style.paddingBottom="");let no=(Fm=we.closeButtonIconName)!=null?Fm:"x",Jo=(Um=we.closeButtonIconText)!=null?Um:"\xD7";O.innerHTML="";let bo=Ee(no,"28px","currentColor",1);bo?O.appendChild(bo):O.textContent=Jo;let br=(qm=we.closeButtonTooltipText)!=null?qm:"Close chat",Io=(zm=we.closeButtonShowTooltip)!=null?zm:!0;if(O.setAttribute("aria-label",br),Ct&&(Ct._cleanupTooltip&&(Ct._cleanupTooltip(),delete Ct._cleanupTooltip),Io&&br)){let St=null,Wr=()=>{if(St||!O)return;let sa=O.ownerDocument,Ls=sa.body;if(!Ls)return;St=un(sa,"div","persona-clear-chat-tooltip"),St.textContent=br;let Ps=un(sa,"div");Ps.className="persona-clear-chat-tooltip-arrow",St.appendChild(Ps);let ia=O.getBoundingClientRect();St.style.position="fixed",St.style.zIndex=String(jn),St.style.left=`${ia.left+ia.width/2}px`,St.style.top=`${ia.top-8}px`,St.style.transform="translate(-50%, -100%)",Ls.appendChild(St)},Mo=()=>{St&&St.parentNode&&(St.parentNode.removeChild(St),St=null)};Ct.addEventListener("mouseenter",Wr),Ct.addEventListener("mouseleave",Mo),O.addEventListener("focus",Wr),O.addEventListener("blur",Mo),Ct._cleanupTooltip=()=>{Mo(),Ct&&(Ct.removeEventListener("mouseenter",Wr),Ct.removeEventListener("mouseleave",Mo)),O&&(O.removeEventListener("focus",Wr),O.removeEventListener("blur",Mo))}}}let{clearChatButton:st,clearChatButtonWrapper:Ut}=Re;if(st){let ee=($m=we.clearChat)!=null?$m:{},Ot=(Vm=ee.enabled)!=null?Vm:!0,er=(Gm=(jm=o.layout)==null?void 0:jm.header)==null?void 0:Gm.showClearChat,Ct=er!==void 0?er:Ot,qt=(Km=ee.placement)!=null?Km:"inline";if(Ut){Ut.style.display=Ct?"":"none";let{closeButtonWrapper:Hr}=Re;!H()&&Hr&&!Hr.classList.contains("persona-absolute")&&(Ct?Hr.classList.remove("persona-ml-auto"):Hr.classList.add("persona-ml-auto"));let no=qt==="top-right",Jo=Ut.classList.contains("persona-absolute");if(!H()&&no!==Jo&&Ct){if(Ut.remove(),no)Ut.className="persona-absolute persona-top-4 persona-z-50",Ut.style.right="48px",K.style.position="relative",K.appendChild(Ut);else{Ut.className="persona-relative persona-ml-auto persona-clear-chat-button-wrapper",Ut.style.right="";let br=K.querySelector(".persona-border-b-persona-divider"),Io=Re.closeButtonWrapper;br&&Io&&Io.parentElement===br?br.insertBefore(Ut,Io):br&&br.appendChild(Ut)}let bo=Re.closeButtonWrapper;bo&&!bo.classList.contains("persona-absolute")&&(no?bo.classList.add("persona-ml-auto"):bo.classList.remove("persona-ml-auto"))}}if(Ct){if(!H()){let St=(Xm=ee.size)!=null?Xm:"32px";st.style.height=St,st.style.width=St}let Hr=(Qm=ee.iconName)!=null?Qm:"refresh-cw",no=(Ym=ee.iconColor)!=null?Ym:"";st.style.color=no||Ao.actionIconColor,st.innerHTML="";let Jo=H()?"14px":"20px",bo=Ee(Hr,Jo,"currentColor",2);if(bo&&st.appendChild(bo),ee.backgroundColor?(st.style.backgroundColor=ee.backgroundColor,st.classList.remove("hover:persona-bg-gray-100")):(st.style.backgroundColor="",st.classList.add("hover:persona-bg-gray-100")),ee.borderWidth||ee.borderColor){let St=ee.borderWidth||"0px",Wr=ee.borderColor||"transparent";st.style.border=`${St} solid ${Wr}`,st.classList.remove("persona-border-none")}else st.style.border="",st.classList.add("persona-border-none");ee.borderRadius?(st.style.borderRadius=ee.borderRadius,st.classList.remove("persona-rounded-full")):(st.style.borderRadius="",st.classList.add("persona-rounded-full")),ee.paddingX?(st.style.paddingLeft=ee.paddingX,st.style.paddingRight=ee.paddingX):(st.style.paddingLeft="",st.style.paddingRight=""),ee.paddingY?(st.style.paddingTop=ee.paddingY,st.style.paddingBottom=ee.paddingY):(st.style.paddingTop="",st.style.paddingBottom="");let br=(Jm=ee.tooltipText)!=null?Jm:"Clear chat",Io=(Zm=ee.showTooltip)!=null?Zm:!0;if(st.setAttribute("aria-label",br),Ut&&(Ut._cleanupTooltip&&(Ut._cleanupTooltip(),delete Ut._cleanupTooltip),Io&&br)){let St=null,Wr=()=>{if(St||!st)return;let sa=st.ownerDocument,Ls=sa.body;if(!Ls)return;St=un(sa,"div","persona-clear-chat-tooltip"),St.textContent=br;let Ps=un(sa,"div");Ps.className="persona-clear-chat-tooltip-arrow",St.appendChild(Ps);let ia=st.getBoundingClientRect();St.style.position="fixed",St.style.zIndex=String(jn),St.style.left=`${ia.left+ia.width/2}px`,St.style.top=`${ia.top-8}px`,St.style.transform="translate(-50%, -100%)",Ls.appendChild(St)},Mo=()=>{St&&St.parentNode&&(St.parentNode.removeChild(St),St=null)};Ut.addEventListener("mouseenter",Wr),Ut.addEventListener("mouseleave",Mo),st.addEventListener("focus",Wr),st.addEventListener("blur",Mo),Ut._cleanupTooltip=()=>{Mo(),Ut&&(Ut.removeEventListener("mouseenter",Wr),Ut.removeEventListener("mouseleave",Mo)),st&&(st.removeEventListener("focus",Wr),st.removeEventListener("blur",Mo))}}}}let kr=o.actionParsers&&o.actionParsers.length?o.actionParsers:[gi],Vo=o.actionHandlers&&o.actionHandlers.length?o.actionHandlers:[Ea.message,Ea.messageAndClick];T=hi({parsers:kr,handlers:Vo,getSessionMetadata:p,updateSessionMetadata:m,emit:a.emit,documentRef:typeof document!="undefined"?document:null}),ve=my(o,T,ie),U.updateConfig(o),Zn(it,U.getMessages(),ve),nr(),ea(),Da(U.isStreaming());let Ro=((eg=o.voiceRecognition)==null?void 0:eg.enabled)===!0,ta=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),ra=((rg=(tg=o.voiceRecognition)==null?void 0:tg.provider)==null?void 0:rg.type)==="runtype";if(Ro&&(ta||ra))if(!X||!wt){let ee=tb(o.voiceRecognition,o.sendButton);ee&&(X=ee.micButton,wt=ee.micButtonWrapper,Dt.insertBefore(wt,Ar),X.addEventListener("click",Hi),X.disabled=U.isStreaming())}else{let ee=(og=o.voiceRecognition)!=null?og:{},Ot=(ng=o.sendButton)!=null?ng:{},er=(ag=ee.iconName)!=null?ag:"mic",Ct=(sg=Ot.size)!=null?sg:"40px",qt=(ig=ee.iconSize)!=null?ig:Ct,Hr=parseFloat(qt)||24;X.style.width=qt,X.style.height=qt,X.style.minWidth=qt,X.style.minHeight=qt;let no=(dg=(lg=ee.iconColor)!=null?lg:Ot.textColor)!=null?dg:"currentColor";X.innerHTML="";let Jo=Ee(er,Hr,no,2);Jo?X.appendChild(Jo):X.textContent="\u{1F3A4}";let bo=(cg=ee.backgroundColor)!=null?cg:Ot.backgroundColor;bo?X.style.backgroundColor=bo:X.style.backgroundColor="",no?X.style.color=no:X.style.color="var(--persona-text, #111827)",ee.borderWidth?(X.style.borderWidth=ee.borderWidth,X.style.borderStyle="solid"):(X.style.borderWidth="",X.style.borderStyle=""),ee.borderColor?X.style.borderColor=ee.borderColor:X.style.borderColor="",ee.paddingX?(X.style.paddingLeft=ee.paddingX,X.style.paddingRight=ee.paddingX):(X.style.paddingLeft="",X.style.paddingRight=""),ee.paddingY?(X.style.paddingTop=ee.paddingY,X.style.paddingBottom=ee.paddingY):(X.style.paddingTop="",X.style.paddingBottom="");let br=wt==null?void 0:wt.querySelector(".persona-send-button-tooltip"),Io=(pg=ee.tooltipText)!=null?pg:"Start voice recognition";if(((ug=ee.showTooltip)!=null?ug:!1)&&Io)if(br)br.textContent=Io,br.style.display="";else{let Wr=document.createElement("div");Wr.className="persona-send-button-tooltip",Wr.textContent=Io,wt==null||wt.insertBefore(Wr,X)}else br&&(br.style.display="none");wt.style.display="",X.disabled=U.isStreaming()}else X&&wt&&(wt.style.display="none",((mg=(fg=o.voiceRecognition)==null?void 0:fg.provider)==null?void 0:mg.type)==="runtype"?U.isVoiceActive()&&U.toggleVoice():kt&&Ur());if(((gg=o.attachments)==null?void 0:gg.enabled)===!0)if(!Ce||!ct){let ee=(hg=o.attachments)!=null?hg:{},er=(yg=((xg=o.sendButton)!=null?xg:{}).size)!=null?yg:"40px";rt||(rt=C("div","persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2"),rt.style.display="none",Rt.insertBefore(rt,te)),de||(de=document.createElement("input"),de.type="file",de.accept=((bg=ee.allowedTypes)!=null?bg:Tn).join(","),de.multiple=((vg=ee.maxFiles)!=null?vg:4)>1,de.style.display="none",de.setAttribute("aria-label","Attach files"),Rt.insertBefore(de,te)),Ce=C("div","persona-send-button-wrapper"),ct=C("button","persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button"),ct.type="button",ct.setAttribute("aria-label",(Cg=ee.buttonTooltipText)!=null?Cg:"Attach file");let Ct=(wg=ee.buttonIconName)!=null?wg:"paperclip",qt=er,Hr=parseFloat(qt)||40,no=Math.round(Hr*.6);ct.style.width=qt,ct.style.height=qt,ct.style.minWidth=qt,ct.style.minHeight=qt,ct.style.fontSize="18px",ct.style.lineHeight="1",ct.style.backgroundColor="transparent",ct.style.color="var(--persona-primary, #111827)",ct.style.border="none",ct.style.borderRadius="6px",ct.style.transition="background-color 0.15s ease",ct.addEventListener("mouseenter",()=>{ct.style.backgroundColor="var(--persona-palette-colors-black-alpha-50, rgba(0, 0, 0, 0.05))"}),ct.addEventListener("mouseleave",()=>{ct.style.backgroundColor="transparent"});let Jo=Ee(Ct,no,"currentColor",1.5);Jo?ct.appendChild(Jo):ct.textContent="\u{1F4CE}",ct.addEventListener("click",Io=>{Io.preventDefault(),de==null||de.click()}),Ce.appendChild(ct);let bo=(Ag=ee.buttonTooltipText)!=null?Ag:"Attach file",br=C("div","persona-send-button-tooltip");br.textContent=bo,Ce.appendChild(br),Mt.append(Ce),!je&&de&&rt&&(je=wa.fromConfig(ee),je.setPreviewsContainer(rt),de.addEventListener("change",async()=>{je&&(de!=null&&de.files)&&(await je.handleFileSelect(de.files),de.value="")})),K.querySelector(".persona-attachment-drop-overlay")||K.appendChild(gy(ee.dropOverlay))}else{Ce.style.display="";let ee=(Sg=o.attachments)!=null?Sg:{};de&&(de.accept=((Tg=ee.allowedTypes)!=null?Tg:Tn).join(","),de.multiple=((Mg=ee.maxFiles)!=null?Mg:4)>1),je&&je.updateConfig({allowedTypes:ee.allowedTypes,maxFileSize:ee.maxFileSize,maxFiles:ee.maxFiles})}else Ce&&(Ce.style.display="none"),je&&je.clearAttachments(),(kg=K.querySelector(".persona-attachment-drop-overlay"))==null||kg.remove();let ur=(Eg=o.sendButton)!=null?Eg:{},oa=(Lg=ur.useIcon)!=null?Lg:!1,On=(Pg=ur.iconText)!=null?Pg:"\u2191",_n=ur.iconName,yn=(Rg=ur.tooltipText)!=null?Rg:"Send message",na=(Ig=ur.showTooltip)!=null?Ig:!1,Yo=(Hg=ur.size)!=null?Hg:"40px",pt=ur.backgroundColor,Ir=ur.textColor;if(oa){if(_e.style.width=Yo,_e.style.height=Yo,_e.style.minWidth=Yo,_e.style.minHeight=Yo,_e.style.fontSize="18px",_e.style.lineHeight="1",_e.innerHTML="",Ir?_e.style.color=Ir:_e.style.color="var(--persona-button-primary-fg, #ffffff)",_n){let ee=parseFloat(Yo)||24,Ot=(Ir==null?void 0:Ir.trim())||"currentColor",er=Ee(_n,ee,Ot,2);er?_e.appendChild(er):_e.textContent=On}else _e.textContent=On;_e.className="persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer",pt?(_e.style.backgroundColor=pt,_e.classList.remove("persona-bg-persona-primary")):(_e.style.backgroundColor="",_e.classList.add("persona-bg-persona-primary"))}else _e.textContent=(Bg=(Wg=o.copy)==null?void 0:Wg.sendButtonLabel)!=null?Bg:"Send",_e.style.width="",_e.style.height="",_e.style.minWidth="",_e.style.minHeight="",_e.style.fontSize="",_e.style.lineHeight="",_e.className="persona-rounded-button persona-bg-persona-accent persona-px-4 persona-py-2 persona-text-sm persona-font-semibold persona-text-white disabled:persona-opacity-50 persona-cursor-pointer",pt?(_e.style.backgroundColor=pt,_e.classList.remove("persona-bg-persona-accent")):_e.classList.add("persona-bg-persona-accent"),Ir?_e.style.color=Ir:_e.classList.add("persona-text-white");ur.borderWidth?(_e.style.borderWidth=ur.borderWidth,_e.style.borderStyle="solid"):(_e.style.borderWidth="",_e.style.borderStyle=""),ur.borderColor?_e.style.borderColor=ur.borderColor:_e.style.borderColor="",ur.paddingX?(_e.style.paddingLeft=ur.paddingX,_e.style.paddingRight=ur.paddingX):(_e.style.paddingLeft="",_e.style.paddingRight=""),ur.paddingY?(_e.style.paddingTop=ur.paddingY,_e.style.paddingBottom=ur.paddingY):(_e.style.paddingTop="",_e.style.paddingBottom="");let Zt=Ar==null?void 0:Ar.querySelector(".persona-send-button-tooltip");if(na&&yn)if(Zt)Zt.textContent=yn,Zt.style.display="";else{let ee=document.createElement("div");ee.className="persona-send-button-tooltip",ee.textContent=yn,Ar==null||Ar.insertBefore(ee,_e)}else Zt&&(Zt.style.display="none");let Yt=(Fg=(Dg=o.layout)==null?void 0:Dg.contentMaxWidth)!=null?Fg:H()?(Ng=(_g=(Og=o.launcher)==null?void 0:Og.composerBar)==null?void 0:_g.contentMaxWidth)!=null?Ng:"720px":void 0;Yt?(it.style.maxWidth=Yt,it.style.marginLeft="auto",it.style.marginRight="auto",it.style.width="100%",Rt&&(Rt.style.maxWidth=Yt,Rt.style.marginLeft="auto",Rt.style.marginRight="auto"),Pt&&(Pt.style.maxWidth=Yt,Pt.style.marginLeft="auto",Pt.style.marginRight="auto")):(it.style.maxWidth="",it.style.marginLeft="",it.style.marginRight="",it.style.width="",Rt&&(Rt.style.maxWidth="",Rt.style.marginLeft="",Rt.style.marginRight=""),Pt&&(Pt.style.maxWidth="",Pt.style.marginLeft="",Pt.style.marginRight=""));let Et=(Ug=o.statusIndicator)!=null?Ug:{},fr=(qg=Et.visible)!=null?qg:!0;if(dr.style.display=fr?"":"none",U){let ee=U.getStatus();Ye(dr,(er=>{var Ct,qt,Hr,no;return er==="idle"?(Ct=Et.idleText)!=null?Ct:ao.idle:er==="connecting"?(qt=Et.connectingText)!=null?qt:ao.connecting:er==="connected"?(Hr=Et.connectedText)!=null?Hr:ao.connected:er==="error"?(no=Et.errorText)!=null?no:ao.error:ao[er]})(ee),Et,ee)}dr.classList.remove("persona-text-left","persona-text-center","persona-text-right");let _t=Et.align==="left"?"persona-text-left":Et.align==="center"?"persona-text-center":"persona-text-right";dr.classList.add(_t)},open(){I()&&Gt(!0,"api")},close(){I()&&Gt(!1,"api")},toggle(){I()&&Gt(!P,"api")},clearChat(){Or=!1,U.clearMessages(),Cr.clear(),sn();try{localStorage.removeItem(cs),o.debug&&console.log(`[AgentWidget] Cleared default localStorage key: ${cs}`)}catch(g){console.error("[AgentWidget] Failed to clear default localStorage:",g)}if(o.clearChatHistoryStorageKey&&o.clearChatHistoryStorageKey!==cs)try{localStorage.removeItem(o.clearChatHistoryStorageKey),o.debug&&console.log(`[AgentWidget] Cleared custom localStorage key: ${o.clearChatHistoryStorageKey}`)}catch(g){console.error("[AgentWidget] Failed to clear custom localStorage:",g)}let c=new CustomEvent("persona:clear-chat",{detail:{timestamp:new Date().toISOString()}});if(window.dispatchEvent(c),i!=null&&i.clear)try{let g=i.clear();g instanceof Promise&&g.catch(b=>{typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",b)})}catch(g){typeof console!="undefined"&&console.error("[AgentWidget] Failed to clear storage adapter:",g)}d={},T.syncFromMetadata(),be==null||be.clear(),ye==null||ye.reset(),Y==null||Y.update()},setMessage(c){return!te||U.isStreaming()?!1:(!P&&I()&&Gt(!0,"system"),te.value=c,te.dispatchEvent(new Event("input",{bubbles:!0})),!0)},submitMessage(c){if(U.isStreaming())return!1;let g=(c==null?void 0:c.trim())||te.value.trim();return g?(!P&&I()&&Gt(!0,"system"),te.value="",te.style.height="auto",U.sendMessage(g),!0):!1},startVoiceRecognition(){var g,b;return U.isStreaming()?!1:((b=(g=o.voiceRecognition)==null?void 0:g.provider)==null?void 0:b.type)==="runtype"?(U.isVoiceActive()||(!P&&I()&&Gt(!0,"system"),Lt.manuallyDeactivated=!1,So(),U.toggleVoice().then(()=>{Lt.active=U.isVoiceActive(),zo("user"),U.isVoiceActive()&&Ts()})),!0):kt?!0:jr()?(!P&&I()&&Gt(!0,"system"),Lt.manuallyDeactivated=!1,So(),pr("user"),!0):!1},stopVoiceRecognition(){var c,g;return((g=(c=o.voiceRecognition)==null?void 0:c.provider)==null?void 0:g.type)==="runtype"?U.isVoiceActive()?(U.toggleVoice().then(()=>{Lt.active=!1,Lt.manuallyDeactivated=!0,So(),zo("user"),Bn()}),!0):!1:kt?(Lt.manuallyDeactivated=!0,So(),Ur("user"),!0):!1},injectMessage(c){return!P&&I()&&Gt(!0,"system"),U.injectMessage(c)},injectAssistantMessage(c){!P&&I()&&Gt(!0,"system");let g=U.injectAssistantMessage(c);return z&&(z=!1,j&&(clearTimeout(j),j=null),setTimeout(()=>{U&&!U.isStreaming()&&U.continueConversation()},100)),g},injectUserMessage(c){return!P&&I()&&Gt(!0,"system"),U.injectUserMessage(c)},injectSystemMessage(c){return!P&&I()&&Gt(!0,"system"),U.injectSystemMessage(c)},injectMessageBatch(c){return!P&&I()&&Gt(!0,"system"),U.injectMessageBatch(c)},injectComponentDirective(c){return!P&&I()&&Gt(!0,"system"),U.injectComponentDirective(c)},injectTestMessage(c){!P&&I()&&Gt(!0,"system"),U.injectTestEvent(c)},async connectStream(c,g){return U.connectStream(c,g)},__pushEventStreamEvent(c){be&&(ye==null||ye.processEvent(c.type,c.payload),be.push({id:`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,type:c.type,timestamp:Date.now(),payload:JSON.stringify(c.payload)}))},showEventStream(){!We||!be||_o()},hideEventStream(){ge&&lo()},isEventStreamVisible(){return ge},showArtifacts(){Go(o)&&(Or=!1,eo(),mt==null||mt.setMobileOpen(!0))},hideArtifacts(){Go(o)&&(Or=!0,eo())},upsertArtifact(c){return Go(o)?(Or=!1,U.upsertArtifact(c)):null},selectArtifact(c){Go(o)&&U.selectArtifact(c)},clearArtifacts(){Go(o)&&U.clearArtifacts()},getArtifacts(){var c;return(c=U==null?void 0:U.getArtifacts())!=null?c:[]},getSelectedArtifactId(){var c;return(c=U==null?void 0:U.getSelectedArtifactId())!=null?c:null},focusInput(){return M&&!P&&!H()||!te?!1:(te.focus(),!0)},async resolveApproval(c,g,b){let W=U.getMessages().find(F=>{var q;return F.variant==="approval"&&((q=F.approval)==null?void 0:q.id)===c});if(!(W!=null&&W.approval))throw new Error(`Approval not found: ${c}`);if(W.approval.toolType==="webmcp"){U.resolveWebMcpApproval(W.id,g);return}return U.resolveApproval(W.approval,g,b)},getMessages(){return U.getMessages()},getStatus(){return U.getStatus()},getPersistentMetadata(){return{...d}},updatePersistentMetadata(c){m(c)},on(c,g){return a.on(c,g)},off(c,g){a.off(c,g)},isOpen(){return I()&&P},isVoiceActive(){return Lt.active},getState(){return{open:I()&&P,launcherEnabled:M,voiceActive:Lt.active,streaming:U.isStreaming()}},showCSATFeedback(c){!P&&I()&&Gt(!0,"system");let g=it.querySelector(".persona-feedback-container");g&&g.remove();let b=od({onSubmit:async(S,W)=>{var F;U.isClientTokenMode()&&await U.submitCSATFeedback(S,W),(F=c==null?void 0:c.onSubmit)==null||F.call(c,S,W)},onDismiss:c==null?void 0:c.onDismiss,...c});it.appendChild(b),b.scrollIntoView({behavior:"smooth",block:"end"})},showNPSFeedback(c){!P&&I()&&Gt(!0,"system");let g=it.querySelector(".persona-feedback-container");g&&g.remove();let b=nd({onSubmit:async(S,W)=>{var F;U.isClientTokenMode()&&await U.submitNPSFeedback(S,W),(F=c==null?void 0:c.onSubmit)==null||F.call(c,S,W)},onDismiss:c==null?void 0:c.onDismiss,...c});it.appendChild(b),b.scrollIntoView({behavior:"smooth",block:"end"})},async submitCSATFeedback(c,g){return U.submitCSATFeedback(c,g)},async submitNPSFeedback(c,g){return U.submitNPSFeedback(c,g)},destroy(){Ke!=null&&(clearInterval(Ke),Ke=null),gt.forEach(c=>c()),De.remove(),nt==null||nt.remove(),xr==null||xr.destroy(),yr==null||yr.remove(),ut&&O.removeEventListener("click",ut)}};if((((_f=t==null?void 0:t.debugTools)!=null?_f:!1)||!!o.debug)&&typeof window!="undefined"){let c=window.AgentWidgetBrowser,g={controller:Mr,getMessages:Mr.getMessages,getStatus:Mr.getStatus,getMetadata:Mr.getPersistentMetadata,updateMetadata:Mr.updatePersistentMetadata,clearHistory:()=>Mr.clearChat(),setVoiceActive:b=>b?Mr.startVoiceRecognition():Mr.stopVoiceRecognition()};window.AgentWidgetBrowser=g,gt.push(()=>{window.AgentWidgetBrowser===g&&(window.AgentWidgetBrowser=c)})}if(typeof window!="undefined"){let c=r.getAttribute("data-persona-instance")||r.id||"persona-"+Math.random().toString(36).slice(2,8),g=G=>{let N=G.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Mr.focusInput()};if(window.addEventListener("persona:focusInput",g),gt.push(()=>{window.removeEventListener("persona:focusInput",g)}),We){let G=Se=>{let xe=Se.detail;(!(xe!=null&&xe.instanceId)||xe.instanceId===c)&&Mr.showEventStream()},N=Se=>{let xe=Se.detail;(!(xe!=null&&xe.instanceId)||xe.instanceId===c)&&Mr.hideEventStream()};window.addEventListener("persona:showEventStream",G),window.addEventListener("persona:hideEventStream",N),gt.push(()=>{window.removeEventListener("persona:showEventStream",G),window.removeEventListener("persona:hideEventStream",N)})}let b=G=>{let N=G.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Mr.showArtifacts()},S=G=>{let N=G.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Mr.hideArtifacts()},W=G=>{let N=G.detail;N!=null&&N.instanceId&&N.instanceId!==c||N!=null&&N.artifact&&Mr.upsertArtifact(N.artifact)},F=G=>{let N=G.detail;N!=null&&N.instanceId&&N.instanceId!==c||typeof(N==null?void 0:N.id)=="string"&&Mr.selectArtifact(N.id)},q=G=>{let N=G.detail;(!(N!=null&&N.instanceId)||N.instanceId===c)&&Mr.clearArtifacts()};window.addEventListener("persona:showArtifacts",b),window.addEventListener("persona:hideArtifacts",S),window.addEventListener("persona:upsertArtifact",W),window.addEventListener("persona:selectArtifact",F),window.addEventListener("persona:clearArtifacts",q),gt.push(()=>{window.removeEventListener("persona:showArtifacts",b),window.removeEventListener("persona:hideArtifacts",S),window.removeEventListener("persona:upsertArtifact",W),window.removeEventListener("persona:selectArtifact",F),window.removeEventListener("persona:clearArtifacts",q)})}let $o=ZC(o.persistState);if($o&&I()){let c=ew($o.storage),g=`${$o.keyPrefix}widget-open`,b=`${$o.keyPrefix}widget-voice`,S=`${$o.keyPrefix}widget-voice-mode`;if(c){let W=((Nf=$o.persist)==null?void 0:Nf.openState)&&c.getItem(g)==="true",F=((Ff=$o.persist)==null?void 0:Ff.voiceState)&&c.getItem(b)==="true",q=((Uf=$o.persist)==null?void 0:Uf.voiceState)&&c.getItem(S)==="true";if(W&&setTimeout(()=>{Mr.open(),setTimeout(()=>{var G;if(F||q)Mr.startVoiceRecognition();else if((G=$o.persist)!=null&&G.focusInput){let N=r.querySelector("textarea");N&&N.focus()}},100)},0),(qf=$o.persist)!=null&&qf.openState&&(a.on("widget:opened",()=>{c.setItem(g,"true")}),a.on("widget:closed",()=>{c.setItem(g,"false")})),(zf=$o.persist)!=null&&zf.voiceState&&(a.on("voice:state",G=>{c.setItem(b,G.active?"true":"false")}),a.on("user:message",G=>{c.setItem(S,G.viaVoice?"true":"false")})),$o.clearOnChatClear){let G=()=>{c.removeItem(g),c.removeItem(b),c.removeItem(S)},N=()=>G();window.addEventListener("persona:clear-chat",N),gt.push(()=>{window.removeEventListener("persona:clear-chat",N)})}}}return u&&I()&&setTimeout(()=>{Mr.open()},0),xn(),Mr};var tw=(r,e)=>{let t=r.trim(),o=/^(\d+(?:\.\d+)?)px$/i.exec(t);if(o)return Math.max(0,parseFloat(o[1]));let n=/^(\d+(?:\.\d+)?)%$/i.exec(t);return n?Math.max(0,e*parseFloat(n[1])/100):420},rw=(r,e)=>{if(e===!1){r.style.maxHeight="";return}r.style.maxHeight="100vh",r.style.maxHeight=e},ow=(r,e)=>{e===!1?(r.style.position="relative",r.style.top=""):(r.style.position="sticky",r.style.top="0")},nw=(r,e)=>{let t=r.parentElement;if(!t)return;let o=r.ownerDocument.createElement("div");o.style.cssText="width:0;height:1px;margin:0;padding:0;border:0;visibility:hidden;",t.appendChild(o);let n=o.offsetHeight>0;o.style.height="100%";let a=o.offsetHeight>0;o.remove(),!(!n||a)&&console.warn("[AgentWidget] Docked mode: no ancestor of the dock target provides a definite height, so the dock panel cannot size to your layout."+(e.maxHeight===!1?" The viewport guard is disabled (dock.maxHeight: false), so the panel will grow with the conversation and overflow the viewport.":` Falling back to clamping the panel to ${e.maxHeight} (configurable via launcher.dock.maxHeight).`)+" To size the panel from your layout instead, give the height chain a definite height (e.g. `html, body { height: 100% }`) down to the dock target's parent.")},hy=(r,e)=>{var o,n;let t=(n=(o=e==null?void 0:e.launcher)==null?void 0:o.enabled)!=null?n:!0;r.className="persona-host",r.style.height=t?"":"100%",r.style.display=t?"":"flex",r.style.flexDirection=t?"":"column",r.style.flex=t?"":"1 1 auto",r.style.minHeight=t?"":"0"},bu=r=>{r.style.position="",r.style.top="",r.style.bottom="",r.style.left="",r.style.right="",r.style.zIndex="",r.style.transform="",r.style.pointerEvents=""},xy=r=>{r.style.inset="",r.style.width="",r.style.height="",r.style.maxWidth="",r.style.maxHeight="",r.style.minWidth="",bu(r)},hu=r=>{r.style.transition=""},xu=r=>{r.style.display="",r.style.flexDirection="",r.style.flex="",r.style.minHeight="",r.style.minWidth="",r.style.width="",r.style.height="",r.style.alignItems="",r.style.transition="",r.style.transform="",r.style.marginLeft=""},yu=r=>{r.style.width="",r.style.maxWidth="",r.style.minWidth="",r.style.flex="1 1 auto"},id=(r,e)=>{r.style.width="",r.style.minWidth="",r.style.maxWidth="",r.style.boxSizing="",e.style.alignItems=""},aw=(r,e,t,o,n)=>{n?t.parentElement!==e&&(r.replaceChildren(),e.replaceChildren(t,o),r.appendChild(e)):t.parentElement===e&&(e.replaceChildren(),r.appendChild(t),r.appendChild(o))},sw=(r,e,t,o,n,a)=>{let s=a?e:r;n==="left"?s.firstElementChild!==o&&s.replaceChildren(o,t):s.lastElementChild!==o&&s.replaceChildren(t,o)},yy=(r,e,t,o,n,a,s)=>{var y,h,T,M,k,L;let i=Bo(a),d=i.reveal==="push";aw(r,e,t,o,d),sw(r,e,t,o,i.side,d),r.dataset.personaHostLayout="docked",r.dataset.personaDockSide=i.side,r.dataset.personaDockOpen=s?"true":"false",r.style.width="100%",r.style.maxWidth="100%",r.style.minWidth="0",r.style.height="100%",r.style.minHeight="0",r.style.position="relative",t.style.display="flex",t.style.flexDirection="column",t.style.minHeight="0",t.style.position="relative",n.className="persona-host",n.style.height="100%",n.style.minHeight="0",n.style.display="flex",n.style.flexDirection="column",n.style.flex="1 1 auto";let l=r.ownerDocument.defaultView,u=(h=(y=a==null?void 0:a.launcher)==null?void 0:y.mobileFullscreen)!=null?h:!0,f=(M=(T=a==null?void 0:a.launcher)==null?void 0:T.mobileBreakpoint)!=null?M:640,p=l!=null?l.innerWidth<=f:!1;if(u&&p&&s){r.dataset.personaDockMobileFullscreen="true",r.removeAttribute("data-persona-dock-reveal"),xu(e),hu(o),xy(o),yu(t),id(n,o),r.style.display="flex",r.style.flexDirection="column",r.style.alignItems="stretch",r.style.overflow="hidden",t.style.flex="1 1 auto",t.style.width="100%",t.style.minWidth="0",o.style.display="flex",o.style.flexDirection="column",o.style.position="fixed",o.style.inset="0",o.style.width="100%",o.style.height="100%",o.style.maxWidth="100%",o.style.minWidth="0",o.style.minHeight="0",o.style.overflow="hidden",o.style.zIndex=String((L=(k=a==null?void 0:a.launcher)==null?void 0:k.zIndex)!=null?L:so),o.style.transform="none",o.style.transition="none",o.style.pointerEvents="auto",o.style.flex="none",d&&(e.style.display="flex",e.style.flexDirection="column",e.style.width="100%",e.style.height="100%",e.style.minHeight="0",e.style.minWidth="0",e.style.flex="1 1 auto",e.style.alignItems="stretch",e.style.transform="none",e.style.marginLeft="0",e.style.transition="none",t.style.flex="1 1 auto",t.style.width="100%",t.style.maxWidth="100%",t.style.minWidth="0");return}if(r.removeAttribute("data-persona-dock-mobile-fullscreen"),xy(o),rw(o,i.maxHeight),i.reveal==="overlay"){r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="hidden",r.dataset.personaDockReveal="overlay",xu(e),hu(o),yu(t),id(n,o);let x=i.animate?"transform 180ms ease":"none",w=i.side==="right"?"translateX(100%)":"translateX(-100%)",v=s?"translateX(0)":w;o.style.display="flex",o.style.flexDirection="column",o.style.flex="none",o.style.position="absolute",o.style.top="0",o.style.bottom="0",o.style.width=i.width,o.style.maxWidth=i.width,o.style.minWidth=i.width,o.style.minHeight="0",o.style.overflow="hidden",o.style.transition=x,o.style.transform=v,o.style.pointerEvents=s?"auto":"none",o.style.zIndex="2",i.side==="right"?(o.style.right="0",o.style.left=""):(o.style.left="0",o.style.right="")}else if(i.reveal==="push"){r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="hidden",r.dataset.personaDockReveal="push",hu(o),bu(o),id(n,o);let x=tw(i.width,r.clientWidth),w=Math.max(0,r.clientWidth),v=i.animate?"margin-left 180ms ease":"none",E=i.side==="right"?s?-x:0:s?0:-x;e.style.display="flex",e.style.flexDirection="row",e.style.flex="0 0 auto",e.style.minHeight="0",e.style.minWidth="0",e.style.alignItems="stretch",e.style.height="100%",e.style.width=`${w+x}px`,e.style.transition=v,e.style.marginLeft=`${E}px`,e.style.transform="",t.style.flex="0 0 auto",t.style.flexGrow="0",t.style.flexShrink="0",t.style.width=`${w}px`,t.style.maxWidth=`${w}px`,t.style.minWidth=`${w}px`,o.style.display="flex",o.style.flexDirection="column",o.style.flex="0 0 auto",o.style.flexShrink="0",o.style.width=i.width,o.style.minWidth=i.width,o.style.maxWidth=i.width,o.style.position="relative",o.style.top="",o.style.overflow="hidden",o.style.transition="none",o.style.pointerEvents=s?"auto":"none"}else{r.style.display="flex",r.style.flexDirection="row",r.style.alignItems="stretch",r.style.overflow="",xu(e),bu(o),yu(t),id(n,o);let x=i.reveal==="emerge";x?r.dataset.personaDockReveal="emerge":r.removeAttribute("data-persona-dock-reveal");let w=s?i.width:"0px",v=i.animate?"width 180ms ease, min-width 180ms ease, max-width 180ms ease, flex-basis 180ms ease":"none",E=!s;o.style.display="flex",o.style.flexDirection="column",o.style.flex=`0 0 ${w}`,o.style.width=w,o.style.maxWidth=w,o.style.minWidth=w,o.style.minHeight="0",ow(o,i.maxHeight),o.style.overflow=x||E?"hidden":"visible",o.style.transition=v,x&&(o.style.alignItems=i.side==="right"?"flex-start":"flex-end",n.style.width=i.width,n.style.minWidth=i.width,n.style.maxWidth=i.width,n.style.boxSizing="border-box")}},iw=(r,e)=>{let t=r.ownerDocument.createElement("div");return hy(t,e),r.appendChild(t),{mode:"direct",host:t,shell:null,syncWidgetState:()=>{},updateConfig(o){hy(t,o)},destroy(){t.remove()}}},lw=(r,e)=>{var L,x,w,v;let{ownerDocument:t}=r,o=r.parentElement;if(!o)throw new Error("Docked widget target must be attached to the DOM");let n=r.tagName.toUpperCase();if(n==="BODY"||n==="HTML")throw new Error('Docked widget target must be a concrete container element, not "body" or "html"');let a=r.nextSibling,s=t.createElement("div"),i=t.createElement("div"),d=t.createElement("div"),l=t.createElement("aside"),u=t.createElement("div"),f=(x=(L=e==null?void 0:e.launcher)==null?void 0:L.enabled)==null||x?(v=(w=e==null?void 0:e.launcher)==null?void 0:w.autoExpand)!=null?v:!1:!0;i.dataset.personaDockRole="push-track",d.dataset.personaDockRole="content",l.dataset.personaDockRole="panel",u.dataset.personaDockRole="host",l.appendChild(u),o.insertBefore(s,r),d.appendChild(r);let p=null,m=()=>{p==null||p.disconnect(),p=null},y=()=>{m(),Bo(e).reveal==="push"&&typeof ResizeObserver!="undefined"&&(p=new ResizeObserver(()=>{yy(s,i,d,l,u,e,f)}),p.observe(s))},h=!1,T=()=>{yy(s,i,d,l,u,e,f),y(),f&&!h&&s.dataset.personaDockMobileFullscreen!=="true"&&(h=!0,nw(s,Bo(e)))},M=s.ownerDocument.defaultView,k=()=>{T()};return M==null||M.addEventListener("resize",k),Bo(e).reveal==="push"?(i.appendChild(d),i.appendChild(l),s.appendChild(i)):(s.appendChild(d),s.appendChild(l)),T(),{mode:"docked",host:u,shell:s,syncWidgetState(E){let H=E.launcherEnabled?E.open:!0;f!==H&&(f=H,T())},updateConfig(E){var H,I;e=E,((I=(H=e==null?void 0:e.launcher)==null?void 0:H.enabled)!=null?I:!0)===!1&&(f=!0),T()},destroy(){M==null||M.removeEventListener("resize",k),m(),o.isConnected&&(a&&a.parentNode===o?o.insertBefore(r,a):o.appendChild(r)),s.remove()}}},xi=(r,e)=>Lr(e)?lw(r,e):iw(r,e);var vu={},by=!1,dw=r=>{if(typeof window=="undefined"||typeof document=="undefined")throw new Error("Chat widget can only be mounted in a browser environment");if(typeof r=="string"){let e=document.querySelector(r);if(!e)throw new Error(`Chat widget target "${r}" was not found`);return e}return r},cw=()=>{try{if(typeof vu!="undefined"&&vu.url)return new URL("../widget.css",vu.url).href}catch{}return null},vy=(r,e)=>{let t=cw(),o=()=>{if(!(r instanceof ShadowRoot)||r.querySelector("link[data-persona]"))return;let n=e.head.querySelector("link[data-persona]");if(!n)return;let a=n.cloneNode(!0);r.insertBefore(a,r.firstChild)};if(r instanceof ShadowRoot)if(t){let n=e.createElement("link");n.rel="stylesheet",n.href=t,n.setAttribute("data-persona","true"),r.insertBefore(n,r.firstChild)}else o();else if(!e.head.querySelector("link[data-persona]")&&t){let a=e.createElement("link");a.rel="stylesheet",a.href=t,a.setAttribute("data-persona","true"),e.head.appendChild(a)}},Cy=r=>{let e=dw(r.target),t=r.useShadowDom===!0,o=e.ownerDocument,n=r.config,a=xi(e,n),s,i=[],d=(T,M)=>{var w,v;let L=!((v=(w=M==null?void 0:M.launcher)==null?void 0:w.enabled)!=null?v:!0)||Lr(M),x=o.createElement("div");if(x.setAttribute("data-persona-root","true"),L&&(x.style.height="100%",x.style.display="flex",x.style.flexDirection="column",x.style.flex="1",x.style.minHeight="0"),t){let E=T.attachShadow({mode:"open"});E.appendChild(x),vy(E,o)}else T.appendChild(x),vy(T,o);return e.id&&x.setAttribute("data-persona-instance",e.id),x},l=()=>{a.syncWidgetState(s.getState())},u=()=>{i.forEach(T=>T()),i=[s.on("widget:opened",l),s.on("widget:closed",l)],l()},f=()=>{let T=d(a.host,n);s=sd(T,n,{debugTools:r.debugTools}),u()},p=()=>{i.forEach(T=>T()),i=[],s.destroy()};f(),r.onChatReady?r.onChatReady():r.onReady&&(by||(by=!0,console.warn("[Persona] `onReady` is deprecated \u2014 use `onChatReady`. `onReady` still works but is removed in the next major.")),r.onReady());let m=T=>{p(),a.destroy(),a=xi(e,T),n=T,f()},y={update(T){var v,E,H,I,P,z;let M={...n,...T,launcher:{...(v=n==null?void 0:n.launcher)!=null?v:{},...(E=T==null?void 0:T.launcher)!=null?E:{},dock:{...(I=(H=n==null?void 0:n.launcher)==null?void 0:H.dock)!=null?I:{},...(z=(P=T==null?void 0:T.launcher)==null?void 0:P.dock)!=null?z:{}}}},k=Lr(n),L=Lr(M),x=Kn(n),w=Kn(M);if(k!==L||x!==w){m(M);return}n=M,a.updateConfig(n),s.update(T),l()},destroy(){p(),a.destroy(),r.windowKey&&typeof window!="undefined"&&delete window[r.windowKey]}},h=new Proxy(y,{get(T,M,k){if(M==="host")return a.host;if(M in T)return Reflect.get(T,M,k);let L=s[M];return typeof L=="function"?L.bind(s):L}});return r.windowKey&&typeof window!="undefined"&&(window[r.windowKey]=h),h};var My=new Set(["script","style","noscript","svg","path","meta","link","br","hr"]),pw=new Set(["button","a","input","select","textarea","details","summary"]),uw=new Set(["button","link","menuitem","tab","option","switch","checkbox","radio","combobox","listbox","slider","spinbutton","textbox"]),Cu=/\b(product|card|item|listing|result)\b/i,Au=/\$[\d,]+(?:\.\d{2})?|€[\d,]+(?:\.\d{2})?|£[\d,]+(?:\.\d{2})?|USD\s*[\d,]+(?:\.\d{2})?/i,fw=3e3,mw=100;function ky(r){let e=typeof r.className=="string"?r.className:"";if(Cu.test(e)||r.id&&Cu.test(r.id))return!0;for(let t=0;t<r.attributes.length;t++){let o=r.attributes[t];if(o.name.startsWith("data-")&&Cu.test(o.value))return!0}return!1}function Ey(r){var e;return Au.test(((e=r.textContent)!=null?e:"").trim())}function Ly(r){var t;let e=r.querySelectorAll("a[href]");for(let o=0;o<e.length;o++){let n=(t=e[o].getAttribute("href"))!=null?t:"";if(n&&n!=="#"&&!n.toLowerCase().startsWith("javascript:"))return!0}return!1}function gw(r){return!!r.querySelector('button, [role="button"], input[type="submit"], input[type="button"]')}function wy(r){let e=r.match(Au);return e?e[0]:null}function Ay(r){var o,n,a;let e=(o=r.querySelector(".product-title a, h1 a, h2 a, h3 a, h4 a, .title a, a[href]"))!=null?o:r.querySelector("a[href]");if(e&&((n=e.textContent)!=null&&n.trim())){let s=e.getAttribute("href");return{title:e.textContent.trim(),href:s&&s!=="#"?s:null}}let t=r.querySelector("h1, h2, h3, h4, h5, h6");return(a=t==null?void 0:t.textContent)!=null&&a.trim()?{title:t.textContent.trim(),href:null}:{title:"",href:null}}function hw(r){let e=[],t=o=>{let n=o.trim();n&&!e.includes(n)&&e.push(n)};return r.querySelectorAll("button").forEach(o=>{var n;return t((n=o.textContent)!=null?n:"")}),r.querySelectorAll('[role="button"]').forEach(o=>{var n;return t((n=o.textContent)!=null?n:"")}),r.querySelectorAll('input[type="submit"], input[type="button"]').forEach(o=>{var n;t((n=o.value)!=null?n:"")}),e.slice(0,6)}var xw="commerce-card",yw="result-card";function Sy(r){return!ky(r)||!Ey(r)||!Ly(r)&&!gw(r)?0:5200}function Ty(r){var o;return!ky(r)||Ey(r)||!Ly(r)||((o=r.textContent)!=null?o:"").trim().length<20||!(!!r.querySelector("h1, h2, h3, h4, h5, h6, .title")||!!r.querySelector(".snippet, .description, p"))?0:2800}var Su=[{id:xw,scoreElement(r){return Sy(r)},shouldSuppressDescendant(r,e,t){if(e===r||!r.contains(e))return!1;if(t.interactivity==="static"){let o=t.text.trim();return!!(o.length===0||Au.test(o)&&o.length<32)}return!0},formatSummary(r,e){var d,l,u;if(Sy(r)===0)return null;let{title:t,href:o}=Ay(r),n=(u=(l=wy(((d=r.textContent)!=null?d:"").trim()))!=null?l:wy(e.text))!=null?u:"",a=hw(r);return[o&&t?`[${t}](${o})${n?` \u2014 ${n}`:""}`:t?`${t}${n?` \u2014 ${n}`:""}`:n||e.text.trim().slice(0,120),`selector: ${e.selector}`,a.length?`actions: ${a.join(", ")}`:""].filter(Boolean).join(`
|
|
156
|
+
`)}},{id:yw,scoreElement(r){return Ty(r)},formatSummary(r,e){if(Ty(r)===0)return null;let{title:t,href:o}=Ay(r);return[o&&t?`[${t}](${o})`:t||e.text.trim().slice(0,120),`selector: ${e.selector}`].filter(Boolean).join(`
|
|
157
|
+
`)}}];function bw(){typeof console!="undefined"&&typeof console.warn=="function"&&console.warn('[persona] collectEnrichedPageContext: options.mode is "simple" but `rules` were provided; rules are ignored.')}function vw(r){var u,f,p,m,y,h,T,M,k,L,x,w,v;let e=(u=r.options)!=null?u:{},t=(p=(f=e.maxElements)!=null?f:r.maxElements)!=null?p:80,o=(y=(m=e.excludeSelector)!=null?m:r.excludeSelector)!=null?y:".persona-host",n=(T=(h=e.maxTextLength)!=null?h:r.maxTextLength)!=null?T:200,a=(k=(M=e.visibleOnly)!=null?M:r.visibleOnly)!=null?k:!0,s=(L=e.root)!=null?L:r.root,i=(x=e.mode)!=null?x:"structured",d=(w=e.maxCandidates)!=null?w:Math.max(500,t*10),l=(v=r.rules)!=null?v:Su;return i==="simple"&&r.rules&&r.rules.length>0?(bw(),l=[]):i==="simple"&&(l=[]),{mode:i,maxElements:t,maxCandidates:d,excludeSelector:o,maxTextLength:n,visibleOnly:a,root:s,rules:l}}function wu(r){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(r):r.replace(/([^\w-])/g,"\\$1")}var Cw=["data-testid","data-product","data-action","data-id","data-name","data-type"];function ww(r){let e=r.tagName.toLowerCase(),t=r.getAttribute("role");return e==="a"&&r.hasAttribute("href")?"navigable":e==="input"||e==="select"||e==="textarea"||t==="textbox"||t==="combobox"||t==="listbox"||t==="spinbutton"?"input":e==="button"||t==="button"||pw.has(e)||t&&uw.has(t)||r.hasAttribute("tabindex")||r.hasAttribute("onclick")||r.getAttribute("contenteditable")==="true"?"clickable":"static"}function Py(r){if(r.hidden)return!1;try{let e=getComputedStyle(r);if(e.display==="none"||e.visibility==="hidden")return!1}catch{}return!(r.style.display==="none"||r.style.visibility==="hidden")}function Aw(r){let e={},t=r.id;t&&(e.id=t);let o=r.getAttribute("href");o&&(e.href=o);let n=r.getAttribute("aria-label");n&&(e["aria-label"]=n);let a=r.getAttribute("type");a&&(e.type=a);let s=r.getAttribute("value");s&&(e.value=s);let i=r.getAttribute("name");i&&(e.name=i);let d=r.getAttribute("role");d&&(e.role=d);for(let l=0;l<r.attributes.length;l++){let u=r.attributes[l];u.name.startsWith("data-")&&(e[u.name]=u.value)}return e}function Tu(r){let e=r.tagName.toLowerCase();if(r.id){let n=`#${wu(r.id)}`;try{if(r.ownerDocument.querySelectorAll(n).length===1)return n}catch{}}for(let n of Cw){let a=r.getAttribute(n);if(a){let s=`${e}[${n}="${wu(a)}"]`;try{if(r.ownerDocument.querySelectorAll(s).length===1)return s}catch{}}}let t=Array.from(r.classList).filter(n=>n&&!n.startsWith("persona-")).slice(0,3);if(t.length>0){let n=`${e}.${t.map(s=>wu(s)).join(".")}`;try{if(r.ownerDocument.querySelectorAll(n).length===1)return n}catch{}let a=r.parentElement;if(a){let i=Array.from(a.querySelectorAll(`:scope > ${e}`)).indexOf(r);if(i>=0){let d=`${n}:nth-of-type(${i+1})`;try{if(r.ownerDocument.querySelectorAll(d).length===1)return d}catch{}}}}let o=r.parentElement;if(o){let a=Array.from(o.querySelectorAll(`:scope > ${e}`)).indexOf(r);if(a>=0)return`${e}:nth-of-type(${a+1})`}return e}function Sw(r){return r==="static"?mw:fw}function Ry(r,e){var n;let t=r.tagName.toLowerCase(),o=((n=r.textContent)!=null?n:"").trim().substring(0,e);return{selector:Tu(r),tagName:t,text:o,role:r.getAttribute("role"),interactivity:ww(r),attributes:Aw(r)}}function Tw(r,e,t,o){let n=Sw(e.interactivity),a=null;for(let s of t){let i=s.scoreElement(r,e,o);i>0&&(n+=i,s.formatSummary&&!a&&(a=s))}return{score:n,formattingRule:a}}function Mw(r,e){var t;for(let o of r)if(e.el!==o.el&&(t=o.formattingRule)!=null&&t.shouldSuppressDescendant&&o.el.contains(e.el)&&o.formattingRule.shouldSuppressDescendant(o.el,e.el,e.enriched))return!0;return!1}function kw(r,e){let t={doc:e.ownerDocument,maxTextLength:r.maxTextLength},o=new Set,n=[],a=0,s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null),i=s.currentNode;for(;i&&n.length<r.maxCandidates;){if(i.nodeType===Node.ELEMENT_NODE){let l=i,u=l.tagName.toLowerCase();if(My.has(u)){i=s.nextNode();continue}if(r.excludeSelector)try{if(l.closest(r.excludeSelector)){i=s.nextNode();continue}}catch{}if(r.visibleOnly&&!Py(l)){i=s.nextNode();continue}let f=Ry(l,r.maxTextLength),p=f.text.length>0,m=Object.keys(f.attributes).length>0&&!Object.keys(f.attributes).every(T=>T==="role");if(!p&&!m){i=s.nextNode();continue}if(o.has(f.selector)){i=s.nextNode();continue}o.add(f.selector);let{score:y,formattingRule:h}=Tw(l,f,r.rules,t);n.push({el:l,domIndex:a,enriched:f,score:y,formattingRule:h}),a+=1}i=s.nextNode()}n.sort((l,u)=>{let f=l.enriched.interactivity==="static"?1:0,p=u.enriched.interactivity==="static"?1:0;return f!==p?f-p:u.score!==l.score?u.score-l.score:l.domIndex-u.domIndex});let d=[];for(let l of n){if(d.length>=r.maxElements)break;Mw(d,l)||d.push(l)}return d.sort((l,u)=>{let f=l.enriched.interactivity==="static"?1:0,p=u.enriched.interactivity==="static"?1:0;return f!==p?f-p:f===1&&u.score!==l.score?u.score-l.score:l.domIndex-u.domIndex}),d.map(l=>{var p;let u;if((p=l.formattingRule)!=null&&p.formatSummary){let m=l.formattingRule.formatSummary(l.el,l.enriched,t);m&&(u=m)}let f={...l.enriched};return u&&(f.formattedSummary=u),f})}function Ew(r,e){let t=[],o=new Set,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null),a=n.currentNode;for(;a&&t.length<r.maxElements;){if(a.nodeType===Node.ELEMENT_NODE){let d=a,l=d.tagName.toLowerCase();if(My.has(l)){a=n.nextNode();continue}if(r.excludeSelector)try{if(d.closest(r.excludeSelector)){a=n.nextNode();continue}}catch{}if(r.visibleOnly&&!Py(d)){a=n.nextNode();continue}let u=Ry(d,r.maxTextLength),f=u.text.length>0,p=Object.keys(u.attributes).length>0&&!Object.keys(u.attributes).every(m=>m==="role");if(!f&&!p){a=n.nextNode();continue}o.has(u.selector)||(o.add(u.selector),t.push(u))}a=n.nextNode()}let s=[],i=[];for(let d of t)d.interactivity!=="static"?s.push(d):i.push(d);return[...s,...i].slice(0,r.maxElements)}function Iy(r={}){var o;let e=vw(r),t=(o=e.root)!=null?o:document.body;return t?e.mode==="simple"?Ew(e,t):kw(e,t):[]}var ld=100;function Hy(r,e={}){var a;if(r.length===0)return"No page elements found.";let t=(a=e.mode)!=null?a:"structured",o=[];if(t==="structured"){let s=r.map(i=>i.formattedSummary).filter(i=>!!i&&i.length>0);s.length>0&&o.push(`Structured summaries:
|
|
157
158
|
${s.map(i=>`- ${i.split(`
|
|
158
159
|
`).join(`
|
|
159
160
|
`)}`).join(`
|
|
160
|
-
`)}`)}let
|
|
161
|
+
`)}`)}let n={clickable:[],navigable:[],input:[],static:[]};for(let s of r)t==="structured"&&s.formattedSummary||n[s.interactivity].push(s);if(n.clickable.length>0){let s=n.clickable.map(i=>`- ${i.selector}: "${i.text.substring(0,ld)}" (clickable)`);o.push(`Interactive elements:
|
|
161
162
|
${s.join(`
|
|
162
|
-
`)}`)}if(
|
|
163
|
+
`)}`)}if(n.navigable.length>0){let s=n.navigable.map(i=>`- ${i.selector}${i.attributes.href?`[href="${i.attributes.href}"]`:""}: "${i.text.substring(0,ld)}" (navigable)`);o.push(`Navigation links:
|
|
163
164
|
${s.join(`
|
|
164
|
-
`)}`)}if(
|
|
165
|
+
`)}`)}if(n.input.length>0){let s=n.input.map(i=>`- ${i.selector}${i.attributes.type?`[type="${i.attributes.type}"]`:""}: "${i.text.substring(0,ld)}" (input)`);o.push(`Form inputs:
|
|
165
166
|
${s.join(`
|
|
166
|
-
`)}`)}if(
|
|
167
|
+
`)}`)}if(n.static.length>0){let s=n.static.map(i=>`- ${i.selector}: "${i.text.substring(0,ld)}"`);o.push(`Content:
|
|
167
168
|
${s.join(`
|
|
168
|
-
`)}`)}return
|
|
169
|
+
`)}`)}return o.join(`
|
|
169
170
|
|
|
170
|
-
`)}var
|
|
171
|
+
`)}var Wy="3.34.0";var By=Wy;function Dy(){return{name:"@persona/accessibility",version:"1.0.0",transform(r){return{...r,semantic:{...r.semantic,colors:{...r.semantic.colors,interactive:{...r.semantic.colors.interactive,focus:"palette.colors.primary.700",disabled:"palette.colors.gray.300"}}}}},cssVariables:{"--persona-accessibility-focus-ring":"0 0 0 2px var(--persona-semantic-colors-surface, #fff), 0 0 0 4px var(--persona-semantic-colors-interactive-focus, #0f0f0f)"}}}function Oy(){return{name:"@persona/animations",version:"1.0.0",transform(r){return{...r,palette:{...r.palette,transitions:{fast:"150ms",normal:"200ms",slow:"300ms",bounce:"500ms cubic-bezier(0.68, -0.55, 0.265, 1.55)"},easings:{easeIn:"cubic-bezier(0.4, 0, 1, 1)",easeOut:"cubic-bezier(0, 0, 0.2, 1)",easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)"}}}},cssVariables:{"--persona-transition-fast":"150ms ease","--persona-transition-normal":"200ms ease","--persona-transition-slow":"300ms ease"}}}function _y(r){return{name:"@persona/brand",version:"1.0.0",transform(e){var o;let t={...e.palette};return(o=r.colors)!=null&&o.primary&&(t.colors={...t.colors,primary:{50:fn(r.colors.primary,.95),100:fn(r.colors.primary,.9),200:fn(r.colors.primary,.8),300:fn(r.colors.primary,.7),400:fn(r.colors.primary,.6),500:r.colors.primary,600:fn(r.colors.primary,.8),700:fn(r.colors.primary,.7),800:fn(r.colors.primary,.6),900:fn(r.colors.primary,.5),950:fn(r.colors.primary,.45)}}),{...e,palette:t}}}}function Ny(){return{name:"@persona/reduced-motion",version:"1.0.0",transform(r){return{...r,palette:{...r.palette,transitions:{fast:"0ms",normal:"0ms",slow:"0ms",bounce:"0ms"}}}},afterResolve(r){return{...r,"--persona-transition-fast":"0ms","--persona-transition-normal":"0ms","--persona-transition-slow":"0ms"}}}}function Fy(){return{name:"@persona/high-contrast",version:"1.0.0",transform(r){return{...r,semantic:{...r.semantic,colors:{...r.semantic.colors,text:"palette.colors.gray.950",textMuted:"palette.colors.gray.700",border:"palette.colors.gray.900",divider:"palette.colors.gray.900"}}}}}}function fn(r,e){let t=parseInt(r.slice(1,3),16),o=parseInt(r.slice(3,5),16),n=parseInt(r.slice(5,7),16),a=Math.round(t+(255-t)*(1-e)),s=Math.round(o+(255-o)*(1-e)),i=Math.round(n+(255-n)*(1-e));return`#${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}function Uy(r){return{name:r.name,version:r.version,transform:r.transform||(e=>e),cssVariables:r.cssVariables,afterResolve:r.afterResolve}}var Pw={palette:{colors:{primary:{500:"#111827"},accent:{600:"#1d4ed8"},gray:{50:"#ffffff",100:"#f8fafc",200:"#f1f5f9",500:"#6b7280",900:"#000000"}},radius:{sm:"0.75rem",md:"1rem",lg:"1.5rem",launcher:"9999px",button:"9999px"}},semantic:{colors:{primary:"palette.colors.primary.500",textInverse:"palette.colors.gray.50"}}},qy={components:{panel:{borderRadius:"0",shadow:"none"}}},Mu={id:"shop",label:"Shopping Assistant",config:{theme:Pw,launcher:{title:"Shopping Assistant",subtitle:"Here to help you find what you need",agentIconText:"\u{1F6CD}\uFE0F",position:"bottom-right",width:Wo},copy:{welcomeTitle:"Welcome to our shop!",welcomeSubtitle:"I can help you find products and answer questions",inputPlaceholder:"Ask me anything...",sendButtonLabel:"Send"},suggestionChips:["What can you help me with?","Tell me about your features","How does this work?"]}},ku={id:"minimal",label:"Minimal",config:{launcher:{enabled:!1,fullHeight:!0},layout:{header:{layout:"minimal",showCloseButton:!1},messages:{layout:"minimal"}},theme:qy}},Eu={id:"fullscreen",label:"Fullscreen Assistant",config:{launcher:{enabled:!1,fullHeight:!0},layout:{header:{layout:"minimal",showCloseButton:!1},contentMaxWidth:"72ch"},theme:qy}},Lu={shop:Mu,minimal:ku,fullscreen:Eu};function zy(r){return Lu[r]}var Rw=`
|
|
171
172
|
@keyframes persona-stream-wipe {
|
|
172
173
|
from { -webkit-mask-position: 100% 0; mask-position: 100% 0; }
|
|
173
174
|
to { -webkit-mask-position: 0% 0; mask-position: 0% 0; }
|
|
@@ -203,7 +204,7 @@ ${s.join(`
|
|
|
203
204
|
mask-image: none !important;
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
|
-
`.trim(),
|
|
207
|
+
`.trim(),Iw={name:"wipe",containerClass:"persona-stream-wipe",wrap:"word",styles:Rw};Sa(Iw);var Hw=`
|
|
207
208
|
[data-persona-root] .persona-stream-glyph-cycle .persona-stream-char {
|
|
208
209
|
animation: persona-stream-glyph-cycle-fade
|
|
209
210
|
calc(var(--persona-stream-step, 120ms) * 1.5) ease-out both;
|
|
@@ -221,128 +222,128 @@ ${s.join(`
|
|
|
221
222
|
opacity: 1 !important;
|
|
222
223
|
}
|
|
223
224
|
}
|
|
224
|
-
`.trim(),
|
|
225
|
+
`.trim(),yi="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#$%&@",Ww=10,Bw=120,Pu=120,Dw=.4,Ow=50,_w=r=>{var o;if(!r)return Pu;let t=((o=r.style.getPropertyValue("--persona-stream-step"))==null?void 0:o.trim()).match(/([\d.]+)\s*ms/);return t?parseFloat(t[1]):Pu},Yy=r=>{let e=r.closest(".persona-stream-glyph-cycle"),t=_w(e);return Bw*t/Pu},Ru=r=>{let e=yi[Math.floor(Math.random()*yi.length)];return r&&e===r&&(e=yi[(yi.indexOf(e)+1)%yi.length]),e},Nw=r=>{let e=r.closest(".persona-stream-glyph-cycle");if(!e)return;let t=e.querySelectorAll(".persona-stream-char[data-glyph-cycle-final]"),o=!1;for(let n of Array.from(t)){if(n===r){o=!0;continue}o&&Math.random()<Dw&&(n.textContent=Ru())}},$y=new WeakMap,Vy=25,jy=.5,Fw=6,Gy=.25,Ky=new WeakMap,Xy=new WeakMap,Uw=(r,e)=>{var n;if(!r)return Vy*jy;let t=Ky.get(r);Ky.set(r,e);let o=(n=Xy.get(r))!=null?n:Vy;if(t!==void 0){let a=e-t;a>1&&(o=o*(1-Gy)+a*Gy,Xy.set(r,o))}return Math.max(Fw,o*jy)},ps=new Map,qw=r=>{var t;let e=r.closest("[data-message-id]");return(t=e==null?void 0:e.dataset.messageId)!=null?t:null},zw=r=>{var e;r&&ps.set(r,((e=ps.get(r))!=null?e:0)+1)},$w=r=>{var t;if(!r)return;let e=(t=ps.get(r))!=null?t:0;e<=1?ps.delete(r):ps.set(r,e-1)},Jy=r=>{var l;if(r.dataset.glyphCycleScheduled==="true")return;let e=(l=r.textContent)!=null?l:"";if(!e||/\s/.test(e))return;r.dataset.glyphCycleScheduled="true",r.dataset.glyphCycleFinal=e,r.setAttribute("data-preserve-runtime","stream-glyph-cycle"),r.textContent=Ru();let t=qw(r);t&&(r.dataset.glyphCycleMessageId=t),zw(t);let o=r.closest(".persona-stream-glyph-cycle"),n=Date.now(),a=Uw(o,n),s=Yy(r),i=Ww*s,d=n+i;if(o){let u=$y.get(o);u!==void 0&&(d=Math.max(d,u)),$y.set(o,d+a)}Vw(r,e,d)},Vw=(r,e,t)=>{var s;if(r.dataset.glyphCycleStarted==="true")return;r.dataset.glyphCycleStarted="true";let o=Yy(r),n=(s=r.textContent)!=null?s:void 0,a=()=>{var d;if(!r.isConnected)return;if(Date.now()>=t){r.textContent=e,r.removeAttribute("data-preserve-runtime"),delete r.dataset.glyphCycleStarted,delete r.dataset.glyphCycleFinal,$w((d=r.dataset.glyphCycleMessageId)!=null?d:null),delete r.dataset.glyphCycleMessageId;return}let i=Ru(n);r.textContent=i,n=i,Nw(r),setTimeout(a,o)};setTimeout(a,o)},Qy=r=>{var t;let e=(t=r.querySelectorAll)==null?void 0:t.call(r,".persona-stream-glyph-cycle .persona-stream-char:not([data-glyph-cycle-scheduled])");if(e)for(let o of Array.from(e))Jy(o)},jw=r=>r.nodeType===1,Gw={name:"glyph-cycle",containerClass:"persona-stream-glyph-cycle",wrap:"char",skipTags:["a","script","style"],styles:Hw,bufferContent(r){if(r.length<Ow)return"";let e=0,t=-1,o=0;for(;o<r.length;){if(r[o]==="*"&&r[o+1]==="*"){e+=1,o+=2;continue}/\s/.test(r[o])&&e%2===0&&(t=o),o+=1}return t<0?"":r.slice(0,t)},isAnimating(r){var e;return((e=ps.get(r.id))!=null?e:0)>0},onAttach(r){Qy(r);let e=new MutationObserver(t=>{for(let o of t)for(let n of Array.from(o.addedNodes))jw(n)&&(n.classList.contains("persona-stream-char")&&n.closest(".persona-stream-glyph-cycle")?Jy(n):Qy(n))});return e.observe(r,{childList:!0,subtree:!0}),()=>e.disconnect()}};Sa(Gw);var Zy,eb,La=typeof document!="undefined"&&(eb=(Zy=document.currentScript)==null?void 0:Zy.src)!=null?eb:null;Wh(()=>{let r=La==null?void 0:La.replace(/index\.global\.js($|\?)/,"webmcp-polyfill.js$1");return!r||r===La?Promise.reject(new Error(`Could not derive the webmcp-polyfill.js URL from the widget script URL (${La!=null?La:"unavailable"}). Self-hosted deployments that rename index.global.js should install @mcp-b/webmcp-polyfill on the page themselves before enabling config.webmcp.`)):import(r)});return gb(Kw);})();
|
|
225
226
|
/*! Bundled license information:
|
|
226
227
|
|
|
227
228
|
dompurify/dist/purify.es.mjs:
|
|
228
|
-
(*! @license DOMPurify 3.
|
|
229
|
+
(*! @license DOMPurify 3.4.10 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.10/LICENSE *)
|
|
229
230
|
|
|
230
|
-
lucide/dist/esm/icons/activity.
|
|
231
|
-
lucide/dist/esm/icons/arrow-down.
|
|
232
|
-
lucide/dist/esm/icons/arrow-left.
|
|
233
|
-
lucide/dist/esm/icons/arrow-right.
|
|
234
|
-
lucide/dist/esm/icons/arrow-up-right.
|
|
235
|
-
lucide/dist/esm/icons/arrow-up.
|
|
236
|
-
lucide/dist/esm/icons/at-sign.
|
|
237
|
-
lucide/dist/esm/icons/ban.
|
|
238
|
-
lucide/dist/esm/icons/bell.
|
|
239
|
-
lucide/dist/esm/icons/bookmark.
|
|
240
|
-
lucide/dist/esm/icons/bot.
|
|
241
|
-
lucide/dist/esm/icons/building.
|
|
242
|
-
lucide/dist/esm/icons/calendar-days.
|
|
243
|
-
lucide/dist/esm/icons/calendar.
|
|
244
|
-
lucide/dist/esm/icons/camera.
|
|
245
|
-
lucide/dist/esm/icons/check.
|
|
246
|
-
lucide/dist/esm/icons/chevron-down.
|
|
247
|
-
lucide/dist/esm/icons/chevron-left.
|
|
248
|
-
lucide/dist/esm/icons/chevron-right.
|
|
249
|
-
lucide/dist/esm/icons/chevron-up.
|
|
250
|
-
lucide/dist/esm/icons/circle-check.
|
|
251
|
-
lucide/dist/esm/icons/circle-x.
|
|
252
|
-
lucide/dist/esm/icons/clipboard-copy.
|
|
253
|
-
lucide/dist/esm/icons/clipboard.
|
|
254
|
-
lucide/dist/esm/icons/clock.
|
|
255
|
-
lucide/dist/esm/icons/copy.
|
|
256
|
-
lucide/dist/esm/icons/credit-card.
|
|
257
|
-
lucide/dist/esm/icons/dollar-sign.
|
|
258
|
-
lucide/dist/esm/icons/download.
|
|
259
|
-
lucide/dist/esm/icons/ellipsis-vertical.
|
|
260
|
-
lucide/dist/esm/icons/ellipsis.
|
|
261
|
-
lucide/dist/esm/icons/
|
|
262
|
-
lucide/dist/esm/icons/
|
|
263
|
-
lucide/dist/esm/icons/eye.
|
|
264
|
-
lucide/dist/esm/icons/file-code.
|
|
265
|
-
lucide/dist/esm/icons/file-spreadsheet.
|
|
266
|
-
lucide/dist/esm/icons/file-text.
|
|
267
|
-
lucide/dist/esm/icons/file.
|
|
268
|
-
lucide/dist/esm/icons/files.
|
|
269
|
-
lucide/dist/esm/icons/film.
|
|
270
|
-
lucide/dist/esm/icons/flag.
|
|
271
|
-
lucide/dist/esm/icons/folder-open.
|
|
272
|
-
lucide/dist/esm/icons/folder.
|
|
273
|
-
lucide/dist/esm/icons/funnel.
|
|
274
|
-
lucide/dist/esm/icons/gift.
|
|
275
|
-
lucide/dist/esm/icons/globe.
|
|
276
|
-
lucide/dist/esm/icons/hash.
|
|
277
|
-
lucide/dist/esm/icons/headphones.
|
|
278
|
-
lucide/dist/esm/icons/heart.
|
|
279
|
-
lucide/dist/esm/icons/history.
|
|
280
|
-
lucide/dist/esm/icons/house.
|
|
281
|
-
lucide/dist/esm/icons/image-plus.
|
|
282
|
-
lucide/dist/esm/icons/image.
|
|
283
|
-
lucide/dist/esm/icons/info.
|
|
284
|
-
lucide/dist/esm/icons/key.
|
|
285
|
-
lucide/dist/esm/icons/link.
|
|
286
|
-
lucide/dist/esm/icons/loader-circle.
|
|
287
|
-
lucide/dist/esm/icons/loader.
|
|
288
|
-
lucide/dist/esm/icons/lock.
|
|
289
|
-
lucide/dist/esm/icons/mail.
|
|
290
|
-
lucide/dist/esm/icons/map-pin.
|
|
291
|
-
lucide/dist/esm/icons/maximize.
|
|
292
|
-
lucide/dist/esm/icons/menu.
|
|
293
|
-
lucide/dist/esm/icons/message-circle.
|
|
294
|
-
lucide/dist/esm/icons/message-square.
|
|
295
|
-
lucide/dist/esm/icons/mic.
|
|
296
|
-
lucide/dist/esm/icons/minimize.
|
|
297
|
-
lucide/dist/esm/icons/minus.
|
|
298
|
-
lucide/dist/esm/icons/monitor.
|
|
299
|
-
lucide/dist/esm/icons/moon.
|
|
300
|
-
lucide/dist/esm/icons/package.
|
|
301
|
-
lucide/dist/esm/icons/paperclip.
|
|
302
|
-
lucide/dist/esm/icons/pause.
|
|
303
|
-
lucide/dist/esm/icons/pencil.
|
|
304
|
-
lucide/dist/esm/icons/percent.
|
|
305
|
-
lucide/dist/esm/icons/phone.
|
|
306
|
-
lucide/dist/esm/icons/play.
|
|
307
|
-
lucide/dist/esm/icons/plus.
|
|
308
|
-
lucide/dist/esm/icons/receipt.
|
|
309
|
-
lucide/dist/esm/icons/refresh-cw.
|
|
310
|
-
lucide/dist/esm/icons/rotate-cw.
|
|
311
|
-
lucide/dist/esm/icons/save.
|
|
312
|
-
lucide/dist/esm/icons/search.
|
|
313
|
-
lucide/dist/esm/icons/send.
|
|
314
|
-
lucide/dist/esm/icons/settings.
|
|
315
|
-
lucide/dist/esm/icons/share.
|
|
316
|
-
lucide/dist/esm/icons/shield-alert.
|
|
317
|
-
lucide/dist/esm/icons/shield-check.
|
|
318
|
-
lucide/dist/esm/icons/shield-x.
|
|
319
|
-
lucide/dist/esm/icons/shield.
|
|
320
|
-
lucide/dist/esm/icons/shopping-bag.
|
|
321
|
-
lucide/dist/esm/icons/shopping-cart.
|
|
322
|
-
lucide/dist/esm/icons/smartphone.
|
|
323
|
-
lucide/dist/esm/icons/sparkles.
|
|
324
|
-
lucide/dist/esm/icons/square.
|
|
325
|
-
lucide/dist/esm/icons/star.
|
|
326
|
-
lucide/dist/esm/icons/store.
|
|
327
|
-
lucide/dist/esm/icons/sun.
|
|
328
|
-
lucide/dist/esm/icons/tag.
|
|
329
|
-
lucide/dist/esm/icons/thumbs-down.
|
|
330
|
-
lucide/dist/esm/icons/thumbs-up.
|
|
331
|
-
lucide/dist/esm/icons/timer.
|
|
332
|
-
lucide/dist/esm/icons/trash-2.
|
|
333
|
-
lucide/dist/esm/icons/trash.
|
|
334
|
-
lucide/dist/esm/icons/triangle-alert.
|
|
335
|
-
lucide/dist/esm/icons/truck.
|
|
336
|
-
lucide/dist/esm/icons/upload.
|
|
337
|
-
lucide/dist/esm/icons/user.
|
|
338
|
-
lucide/dist/esm/icons/volume-2.
|
|
339
|
-
lucide/dist/esm/icons/volume-x.
|
|
340
|
-
lucide/dist/esm/icons/wallet.
|
|
341
|
-
lucide/dist/esm/icons/x.
|
|
342
|
-
lucide/dist/esm/icons/zap.
|
|
343
|
-
lucide/dist/esm/lucide.
|
|
231
|
+
lucide/dist/esm/icons/activity.mjs:
|
|
232
|
+
lucide/dist/esm/icons/arrow-down.mjs:
|
|
233
|
+
lucide/dist/esm/icons/arrow-left.mjs:
|
|
234
|
+
lucide/dist/esm/icons/arrow-right.mjs:
|
|
235
|
+
lucide/dist/esm/icons/arrow-up-right.mjs:
|
|
236
|
+
lucide/dist/esm/icons/arrow-up.mjs:
|
|
237
|
+
lucide/dist/esm/icons/at-sign.mjs:
|
|
238
|
+
lucide/dist/esm/icons/ban.mjs:
|
|
239
|
+
lucide/dist/esm/icons/bell.mjs:
|
|
240
|
+
lucide/dist/esm/icons/bookmark.mjs:
|
|
241
|
+
lucide/dist/esm/icons/bot.mjs:
|
|
242
|
+
lucide/dist/esm/icons/building.mjs:
|
|
243
|
+
lucide/dist/esm/icons/calendar-days.mjs:
|
|
244
|
+
lucide/dist/esm/icons/calendar.mjs:
|
|
245
|
+
lucide/dist/esm/icons/camera.mjs:
|
|
246
|
+
lucide/dist/esm/icons/check.mjs:
|
|
247
|
+
lucide/dist/esm/icons/chevron-down.mjs:
|
|
248
|
+
lucide/dist/esm/icons/chevron-left.mjs:
|
|
249
|
+
lucide/dist/esm/icons/chevron-right.mjs:
|
|
250
|
+
lucide/dist/esm/icons/chevron-up.mjs:
|
|
251
|
+
lucide/dist/esm/icons/circle-check.mjs:
|
|
252
|
+
lucide/dist/esm/icons/circle-x.mjs:
|
|
253
|
+
lucide/dist/esm/icons/clipboard-copy.mjs:
|
|
254
|
+
lucide/dist/esm/icons/clipboard.mjs:
|
|
255
|
+
lucide/dist/esm/icons/clock.mjs:
|
|
256
|
+
lucide/dist/esm/icons/copy.mjs:
|
|
257
|
+
lucide/dist/esm/icons/credit-card.mjs:
|
|
258
|
+
lucide/dist/esm/icons/dollar-sign.mjs:
|
|
259
|
+
lucide/dist/esm/icons/download.mjs:
|
|
260
|
+
lucide/dist/esm/icons/ellipsis-vertical.mjs:
|
|
261
|
+
lucide/dist/esm/icons/ellipsis.mjs:
|
|
262
|
+
lucide/dist/esm/icons/eye-off.mjs:
|
|
263
|
+
lucide/dist/esm/icons/external-link.mjs:
|
|
264
|
+
lucide/dist/esm/icons/eye.mjs:
|
|
265
|
+
lucide/dist/esm/icons/file-code.mjs:
|
|
266
|
+
lucide/dist/esm/icons/file-spreadsheet.mjs:
|
|
267
|
+
lucide/dist/esm/icons/file-text.mjs:
|
|
268
|
+
lucide/dist/esm/icons/file.mjs:
|
|
269
|
+
lucide/dist/esm/icons/files.mjs:
|
|
270
|
+
lucide/dist/esm/icons/film.mjs:
|
|
271
|
+
lucide/dist/esm/icons/flag.mjs:
|
|
272
|
+
lucide/dist/esm/icons/folder-open.mjs:
|
|
273
|
+
lucide/dist/esm/icons/folder.mjs:
|
|
274
|
+
lucide/dist/esm/icons/funnel.mjs:
|
|
275
|
+
lucide/dist/esm/icons/gift.mjs:
|
|
276
|
+
lucide/dist/esm/icons/globe.mjs:
|
|
277
|
+
lucide/dist/esm/icons/hash.mjs:
|
|
278
|
+
lucide/dist/esm/icons/headphones.mjs:
|
|
279
|
+
lucide/dist/esm/icons/heart.mjs:
|
|
280
|
+
lucide/dist/esm/icons/history.mjs:
|
|
281
|
+
lucide/dist/esm/icons/house.mjs:
|
|
282
|
+
lucide/dist/esm/icons/image-plus.mjs:
|
|
283
|
+
lucide/dist/esm/icons/image.mjs:
|
|
284
|
+
lucide/dist/esm/icons/info.mjs:
|
|
285
|
+
lucide/dist/esm/icons/key.mjs:
|
|
286
|
+
lucide/dist/esm/icons/link.mjs:
|
|
287
|
+
lucide/dist/esm/icons/loader-circle.mjs:
|
|
288
|
+
lucide/dist/esm/icons/loader.mjs:
|
|
289
|
+
lucide/dist/esm/icons/lock.mjs:
|
|
290
|
+
lucide/dist/esm/icons/mail.mjs:
|
|
291
|
+
lucide/dist/esm/icons/map-pin.mjs:
|
|
292
|
+
lucide/dist/esm/icons/maximize.mjs:
|
|
293
|
+
lucide/dist/esm/icons/menu.mjs:
|
|
294
|
+
lucide/dist/esm/icons/message-circle.mjs:
|
|
295
|
+
lucide/dist/esm/icons/message-square.mjs:
|
|
296
|
+
lucide/dist/esm/icons/mic.mjs:
|
|
297
|
+
lucide/dist/esm/icons/minimize.mjs:
|
|
298
|
+
lucide/dist/esm/icons/minus.mjs:
|
|
299
|
+
lucide/dist/esm/icons/monitor.mjs:
|
|
300
|
+
lucide/dist/esm/icons/moon.mjs:
|
|
301
|
+
lucide/dist/esm/icons/package.mjs:
|
|
302
|
+
lucide/dist/esm/icons/paperclip.mjs:
|
|
303
|
+
lucide/dist/esm/icons/pause.mjs:
|
|
304
|
+
lucide/dist/esm/icons/pencil.mjs:
|
|
305
|
+
lucide/dist/esm/icons/percent.mjs:
|
|
306
|
+
lucide/dist/esm/icons/phone.mjs:
|
|
307
|
+
lucide/dist/esm/icons/play.mjs:
|
|
308
|
+
lucide/dist/esm/icons/plus.mjs:
|
|
309
|
+
lucide/dist/esm/icons/receipt.mjs:
|
|
310
|
+
lucide/dist/esm/icons/refresh-cw.mjs:
|
|
311
|
+
lucide/dist/esm/icons/rotate-cw.mjs:
|
|
312
|
+
lucide/dist/esm/icons/save.mjs:
|
|
313
|
+
lucide/dist/esm/icons/search.mjs:
|
|
314
|
+
lucide/dist/esm/icons/send.mjs:
|
|
315
|
+
lucide/dist/esm/icons/settings.mjs:
|
|
316
|
+
lucide/dist/esm/icons/share.mjs:
|
|
317
|
+
lucide/dist/esm/icons/shield-alert.mjs:
|
|
318
|
+
lucide/dist/esm/icons/shield-check.mjs:
|
|
319
|
+
lucide/dist/esm/icons/shield-x.mjs:
|
|
320
|
+
lucide/dist/esm/icons/shield.mjs:
|
|
321
|
+
lucide/dist/esm/icons/shopping-bag.mjs:
|
|
322
|
+
lucide/dist/esm/icons/shopping-cart.mjs:
|
|
323
|
+
lucide/dist/esm/icons/smartphone.mjs:
|
|
324
|
+
lucide/dist/esm/icons/sparkles.mjs:
|
|
325
|
+
lucide/dist/esm/icons/square.mjs:
|
|
326
|
+
lucide/dist/esm/icons/star.mjs:
|
|
327
|
+
lucide/dist/esm/icons/store.mjs:
|
|
328
|
+
lucide/dist/esm/icons/sun.mjs:
|
|
329
|
+
lucide/dist/esm/icons/tag.mjs:
|
|
330
|
+
lucide/dist/esm/icons/thumbs-down.mjs:
|
|
331
|
+
lucide/dist/esm/icons/thumbs-up.mjs:
|
|
332
|
+
lucide/dist/esm/icons/timer.mjs:
|
|
333
|
+
lucide/dist/esm/icons/trash-2.mjs:
|
|
334
|
+
lucide/dist/esm/icons/trash.mjs:
|
|
335
|
+
lucide/dist/esm/icons/triangle-alert.mjs:
|
|
336
|
+
lucide/dist/esm/icons/truck.mjs:
|
|
337
|
+
lucide/dist/esm/icons/upload.mjs:
|
|
338
|
+
lucide/dist/esm/icons/user.mjs:
|
|
339
|
+
lucide/dist/esm/icons/volume-2.mjs:
|
|
340
|
+
lucide/dist/esm/icons/volume-x.mjs:
|
|
341
|
+
lucide/dist/esm/icons/wallet.mjs:
|
|
342
|
+
lucide/dist/esm/icons/x.mjs:
|
|
343
|
+
lucide/dist/esm/icons/zap.mjs:
|
|
344
|
+
lucide/dist/esm/lucide.mjs:
|
|
344
345
|
(**
|
|
345
|
-
* @license lucide
|
|
346
|
+
* @license lucide v1.18.0 - ISC
|
|
346
347
|
*
|
|
347
348
|
* This source code is licensed under the ISC license.
|
|
348
349
|
* See the LICENSE file in the root directory of this source tree.
|