react-instantsearch 7.47.0 → 7.49.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.
@@ -1,4 +1,4 @@
1
- /*! React InstantSearch 7.47.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! React InstantSearch 7.49.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
@@ -24,7 +24,7 @@
24
24
 
25
25
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
26
26
 
27
- var version$2 = '7.47.0';
27
+ var version$2 = '7.49.0';
28
28
 
29
29
  function _define_property(obj, key, value) {
30
30
  if (key in obj) {
@@ -9392,7 +9392,7 @@
9392
9392
  });
9393
9393
  }
9394
9394
 
9395
- var version = '4.114.0';
9395
+ var version = '4.116.0';
9396
9396
 
9397
9397
  var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA';
9398
9398
  function getCookie(name) {
@@ -14381,7 +14381,7 @@
14381
14381
  };
14382
14382
  };
14383
14383
 
14384
- function n(){return n=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t]);}return e},n.apply(this,arguments)}const o=["allowFullScreen","allowTransparency","autoComplete","autoFocus","autoPlay","cellPadding","cellSpacing","charSet","classId","colSpan","contentEditable","contextMenu","crossOrigin","encType","formAction","formEncType","formMethod","formNoValidate","formTarget","frameBorder","hrefLang","inputMode","keyParams","keyType","marginHeight","marginWidth","maxLength","mediaGroup","minLength","noValidate","radioGroup","readOnly","rowSpan","spellCheck","srcDoc","srcLang","srcSet","tabIndex","useMap"].reduce((e,n)=>(e[n.toLowerCase()]=n,e),{class:"className",for:"htmlFor"}),a={amp:"&",apos:"'",gt:">",lt:"<",nbsp:" ",quot:"“"},c=["style","script","pre"],i=["src","href","data","formAction","srcDoc","action"],u=/([-A-Z0-9_:]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:\{((?:\\.|{[^}]*?}|[^}])*)\})))?/gi,l=/\n{2,}$/,s=/^(\s*>[\s\S]*?)(?=\n\n|$)/,f=/^ *> ?/gm,_=/^(?:\[!([^\]]*)\]\n)?([\s\S]*)/,d=/^ {2,}\n/,p=/^(?:([-*_])( *\1){2,}) *(?:\n *)+\n/,y=/^(?: {1,3})?(`{3,}|~{3,}) *(\S+)? *([^\n]*?)?\n([\s\S]*?)(?:\1\n?|$)/,h=/^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/,g=/^(`+)((?:\\`|(?!\1)`|[^`])+)\1/,m=/^(?:\n *)*\n/,k=/\r\n?/g,x=/^\[\^([^\]]+)](:(.*)((\n+ {4,}.*)|(\n(?!\[\^).+))*)/,q=/^\[\^([^\]]+)]/,v=/\f/g,b=/^---[ \t]*\n(.|\n)*\n---[ \t]*\n/,$=/^\s*?\[(x|\s)\]/,S=/^ *(#{1,6}) *([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,z=/^ *(#{1,6}) +([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,E=/^([^\n]+)\n *(=|-)\2{2,} *\n/,A=/^ *(?!<[a-z][^ >/]* ?\/>)<([a-z][^ >/]*) ?((?:[^>]*[^/])?)>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1\b)[\s\S])*?)<\/\1>(?!<\/\1>)\n*/i,R=/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/gi,B=/^<!--[\s\S]*?(?:-->)/,L=/^(data|aria|x)-[a-z_][a-z\d_.-]*$/,O=/^ *<([a-z][a-z0-9:]*)(?:\s+((?:<.*?>|[^>])*))?\/?>(?!<\/\1>)(\s*\n)?/i,j=/^\{.*\}$/,C=/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,I=/^<([^ >]+[:@\/][^ >]+)>/,T=/-([a-z])?/gi,M=/^(\|.*)\n(?: *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*))?\n?/,w=/^[^\n]+(?: \n|\n{2,})/,D=/^\[([^\]]*)\]:\s+<?([^\s>]+)>?\s*("([^"]*)")?/,F=/^!\[([^\]]*)\] ?\[([^\]]*)\]/,P=/^\[([^\]]*)\] ?\[([^\]]*)\]/,Z=/(\n|^[-*]\s|^#|^ {2,}|^-{2,}|^>\s)/,N=/\t/g,G=/(^ *\||\| *$)/g,U=/^ *:-+: *$/,V=/^ *:-+ *$/,H=/^ *-+: *$/,Q=e=>`(?=[\\s\\S]+?\\1${e?"\\1":""})`,W="((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|\\\\\\1|[\\s\\S])+?)",J=RegExp(`^([*_])\\1${Q(1)}${W}\\1\\1(?!\\1)`),K=RegExp(`^([*_])${Q(0)}${W}\\1(?!\\1)`),X=RegExp(`^(==)${Q(0)}${W}\\1`),Y=RegExp(`^(~~)${Q(0)}${W}\\1`),ee=/^(:[a-zA-Z0-9-_]+:)/,ne=/^\\([^0-9A-Za-z\s])/,re=/\\([^0-9A-Za-z\s])/g,te=/^[\s\S](?:(?! \n|[0-9]\.|http)[^=*_~\-\n:<`\\\[!])*/,oe=/^\n+/,ae=/^([ \t]*)/,ce=/(?:^|\n)( *)$/,ie="(?:\\d+\\.)",ue="(?:[*+-])";function le(e){return "( *)("+(1===e?ie:ue)+") +"}const se=le(1),fe=le(2);function _e(e){return RegExp("^"+(1===e?se:fe))}const de=_e(1),pe=_e(2);function ye(e){return RegExp("^"+(1===e?se:fe)+"[^\\n]*(?:\\n(?!\\1"+(1===e?ie:ue)+" )[^\\n]*)*(\\n|$)","gm")}const he=ye(1),ge=ye(2);function me(e){const n=1===e?ie:ue;return RegExp("^( *)("+n+") [\\s\\S]+?(?:\\n{2,}(?! )(?!\\1"+n+" (?!"+n+" ))\\n*|\\s*\\n*$)")}const ke=me(1),xe=me(2);function qe(e,n){const r=1===n,t=r?ke:xe,o=r?he:ge,a=r?de:pe;return {t:e=>a.test(e),o:je(function(e,n){const r=ce.exec(n.prevCapture);return r&&(n.list||!n.inline&&!n.simple)?t.exec(e=r[1]+e):null}),i:1,u(e,n,t){const c=r?+e[2]:void 0,i=e[0].replace(l,"\n").match(o);let u=!1;return {items:i.map(function(e,r){const o=a.exec(e)[0].length,c=RegExp("^ {1,"+o+"}","gm"),l=e.replace(c,"").replace(a,""),s=r===i.length-1,f=-1!==l.indexOf("\n\n")||s&&u;u=f;const _=t.inline,d=t.list;let p;t.list=!0,f?(t.inline=!1,p=Se(l)+"\n\n"):(t.inline=!0,p=Se(l));const y=n(p,t);return t.inline=_,t.list=d,y}),ordered:r,start:c}},l:(n,r,t)=>e(n.ordered?"ol":"ul",{key:t.key,start:"20"===n.type?n.start:void 0},n.items.map(function(n,o){return e("li",{key:o},r(n,t))}))}}const ve=RegExp("^\\[((?:\\[[^\\[\\]]*(?:\\[[^\\[\\]]*\\][^\\[\\]]*)*\\]|[^\\[\\]])*)\\]\\(\\s*<?((?:\\([^)]*\\)|[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*\\)"),be=/^!\[(.*?)\]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/;function $e(e){return "string"==typeof e}function Se(e){let n=e.length;for(;n>0&&e[n-1]<=" ";)n--;return e.slice(0,n)}function ze(e,n){return e.startsWith(n)}function Ee(e,n,r){if(Array.isArray(r)){for(let n=0;n<r.length;n++)if(ze(e,r[n]))return !0;return !1}return r(e,n)}function Ae(e){return e.replace(/[ÀÁÂÃÄÅàáâãä忯]/g,"a").replace(/[çÇ]/g,"c").replace(/[ðÐ]/g,"d").replace(/[ÈÉÊËéèêë]/g,"e").replace(/[ÏïÎîÍíÌì]/g,"i").replace(/[Ññ]/g,"n").replace(/[øØœŒÕõÔôÓóÒò]/g,"o").replace(/[ÜüÛûÚúÙù]/g,"u").replace(/[ŸÿÝý]/g,"y").replace(/[^a-z0-9- ]/gi,"").replace(/ /gi,"-").toLowerCase()}function Re(e){return H.test(e)?"right":U.test(e)?"center":V.test(e)?"left":null}function Be(e,n,r,t){const o=r.inTable;r.inTable=!0;let a=[[]],c="";function i(){if(!c)return;const e=a[a.length-1];e.push.apply(e,n(c,r)),c="";}return e.trim().split(/(`[^`]*`|\\\||\|)/).filter(Boolean).forEach((e,n,r)=>{"|"===e.trim()&&(i(),t)?0!==n&&n!==r.length-1&&a.push([]):c+=e;}),i(),r.inTable=o,a}function Le(e,n,r){r.inline=!0;const t=e[2]?e[2].replace(G,"").split("|").map(Re):[],o=e[3]?function(e,n,r){return e.trim().split("\n").map(function(e){return Be(e,n,r,!0)})}(e[3],n,r):[],a=Be(e[1],n,r,!!o.length);return r.inline=!1,o.length?{align:t,cells:o,header:a,type:"25"}:{children:a,type:"21"}}function Oe(e,n){return null==e.align[n]?{}:{textAlign:e.align[n]}}function je(e){return e.inline=1,e}function Ce(e){return je(function(n,r){return r.inline?e.exec(n):null})}function Ie(e){return je(function(n,r){return r.inline||r.simple?e.exec(n):null})}function Te(e){return function(n,r){return r.inline||r.simple?null:e.exec(n)}}function Me(e){return je(function(n){return e.exec(n)})}const we=/(javascript|vbscript|data(?!:image)):/i;function De(e){try{const n=decodeURIComponent(e).replace(/[^A-Za-z0-9/:]/g,"");if(we.test(n))return null}catch(e){return null}return e}function Fe(e){return e?e.replace(re,"$1"):e}function Pe(e,n,r){const t=r.inline||!1,o=r.simple||!1;r.inline=!0,r.simple=!0;const a=e(n,r);return r.inline=t,r.simple=o,a}function Ze(e,n,r){const t=r.inline||!1,o=r.simple||!1;r.inline=!1,r.simple=!0;const a=e(n,r);return r.inline=t,r.simple=o,a}function Ne(e,n,r){const t=r.inline||!1;r.inline=!1;const o=e(n,r);return r.inline=t,o}const Ge=(e,n,r)=>({children:Pe(n,e[2],r)});function Ue(){return {}}function Ve(){return null}function He(...e){return e.filter(Boolean).join(" ")}function Qe(e,n,r){let t=e;const o=n.split(".");for(;o.length&&(t=t[o[0]],void 0!==t);)o.shift();return t||r}function We(r="",t={}){t.overrides=t.overrides||{},t.namedCodesToUnicode=t.namedCodesToUnicode?n({},a,t.namedCodesToUnicode):a;const l=t.slugify||Ae,G=t.sanitizer||De,U=t.createElement||React__namespace.createElement,V=[s,y,h,t.enforceAtxHeadings?z:S,E,M,ke,xe],H=[...V,w,A,B,O];function Q(e,n){for(let r=0;r<e.length;r++)if(e[r].test(n))return !0;return !1}function W(e,r,...o){const a=Qe(t.overrides,e+".props",{});return U(function(e,n){const r=Qe(n,e);return r?"function"==typeof r||"object"==typeof r&&"render"in r?r:Qe(n,e+".component",e):e}(e,t.overrides),n({},r,a,{className:He(null==r?void 0:r.className,a.className)||void 0}),...o)}function re(e){e=e.replace(b,"");let n=!1;t.forceInline?n=!0:t.forceBlock||(n=!1===Z.test(e));const r=fe(se(n?e:Se(e).replace(oe,"")+"\n\n",{inline:n}));for(;$e(r[r.length-1])&&!r[r.length-1].trim();)r.pop();if(null===t.wrapper)return r;const o=t.wrapper||(n?"span":"div");let a;if(r.length>1||t.forceWrapper)a=r;else {if(1===r.length)return a=r[0],"string"==typeof a?W("span",{key:"outer"},a):a;a=null;}return U(o,{key:"outer"},a)}function ce(e,n){if(!n||!n.trim())return null;const r=n.match(u);return r?r.reduce(function(n,r){const t=r.indexOf("=");if(-1!==t){const a=function(e){return -1!==e.indexOf("-")&&null===e.match(L)&&(e=e.replace(T,function(e,n){return n.toUpperCase()})),e}(r.slice(0,t)).trim(),c=function(e){const n=e[0];return ('"'===n||"'"===n)&&e.length>=2&&e[e.length-1]===n?e.slice(1,-1):e}(r.slice(t+1).trim()),u=o[a]||a;if("ref"===u)return n;const l=n[u]=function(e,n,r,t){return "style"===n?function(e){const n=[];let r="",t=!1,o=!1,a="";if(!e)return n;for(let c=0;c<e.length;c++){const i=e[c];if('"'!==i&&"'"!==i||t||(o?i===a&&(o=!1,a=""):(o=!0,a=i)),"("===i&&r.endsWith("url")?t=!0:")"===i&&t&&(t=!1),";"!==i||o||t)r+=i;else {const e=r.trim();if(e){const r=e.indexOf(":");if(r>0){const t=e.slice(0,r).trim(),o=e.slice(r+1).trim();n.push([t,o]);}}r="";}}const c=r.trim();if(c){const e=c.indexOf(":");if(e>0){const r=c.slice(0,e).trim(),t=c.slice(e+1).trim();n.push([r,t]);}}return n}(r).reduce(function(n,[r,o]){return n[r.replace(/(-[a-z])/g,e=>e[1].toUpperCase())]=t(o,e,r),n},{}):-1!==i.indexOf(n)?t(Fe(r),e,n):(r.match(j)&&(r=Fe(r.slice(1,r.length-1))),"true"===r||"false"!==r&&r)}(e,a,c,G);"string"==typeof l&&(A.test(l)||O.test(l))&&(n[u]=re(l.trim()));}else "style"!==r&&(n[o[r]||r]=!0);return n},{}):null}const ie=[],ue={},le={0:{t:[">"],o:Te(s),i:1,u(e,n,r){const[,t,o]=e[0].replace(f,"").match(_);return {alert:t,children:n(o,r)}},l(e,n,r){const t={key:r.key};return e.alert&&(t.className="markdown-alert-"+l(e.alert.toLowerCase(),Ae),e.children.unshift({attrs:{},children:[{type:"27",text:e.alert}],noInnerParse:!0,type:"11",tag:"header"})),W("blockquote",t,n(e.children,r))}},1:{t:[" "],o:Me(d),i:1,u:Ue,l:(e,n,r)=>W("br",{key:r.key})},2:{t:["--","__","**","- ","* ","_ "],o:Te(p),i:1,u:Ue,l:(e,n,r)=>W("hr",{key:r.key})},3:{t:[" "],o:Te(h),i:0,u:e=>({lang:void 0,text:Fe(Se(e[0].replace(/^ {4}/gm,"")))}),l:(e,r,t)=>W("pre",{key:t.key},W("code",n({},e.attrs,{className:e.lang?"lang-"+e.lang:""}),e.text))},4:{t:["```","~~~"],o:Te(y),i:0,u:e=>({attrs:ce("code",e[3]||""),lang:e[2]||void 0,text:e[4],type:"3"})},5:{t:["`"],o:Ie(g),i:3,u:e=>({text:Fe(e[2])}),l:(e,n,r)=>W("code",{key:r.key},e.text)},6:{t:["[^"],o:Te(x),i:0,u:e=>(ie.push({footnote:e[2],identifier:e[1]}),{}),l:Ve},7:{t:["[^"],o:Ce(q),i:1,u:e=>({target:"#"+l(e[1],Ae),text:e[1]}),l:(e,n,r)=>W("a",{key:r.key,href:G(e.target,"a","href")},W("sup",{key:r.key},e.text))},8:{t:["[ ]","[x]"],o:Ce($),i:1,u:e=>({completed:"x"===e[1].toLowerCase()}),l:(e,n,r)=>W("input",{checked:e.completed,key:r.key,readOnly:!0,type:"checkbox"})},9:{t:["#"],o:Te(t.enforceAtxHeadings?z:S),i:1,u:(e,n,r)=>({children:Pe(n,e[2],r),id:l(e[2],Ae),level:e[1].length}),l:(e,n,r)=>W("h"+e.level,{id:e.id,key:r.key},n(e.children,r))},10:{t:e=>{const n=e.indexOf("\n");return n>0&&n<e.length-1&&("="===e[n+1]||"-"===e[n+1])},o:Te(E),i:0,u:(e,n,r)=>({children:Pe(n,e[1],r),level:"="===e[2]?1:2,type:"9"})},11:{t:["<"],o:Me(A),i:1,u(e,n,r){const[,t]=e[3].match(ae),o=RegExp("^"+t,"gm"),a=e[3].replace(o,""),i=Q(H,a)?Ne:Pe,u=e[1].toLowerCase(),l=-1!==c.indexOf(u),s=(l?u:e[1]).trim(),f={attrs:ce(s,e[2]),noInnerParse:l,tag:s};if(r.inAnchor=r.inAnchor||"a"===u,l)f.text=e[3];else {const e=r.inHTML;r.inHTML=!0,f.children=i(n,a,r),r.inHTML=e;}return r.inAnchor=!1,f},l:(e,r,t)=>W(e.tag,n({key:t.key},e.attrs),e.text||(e.children?r(e.children,t):""))},13:{t:["<"],o:Me(O),i:1,u(e){const n=e[1].trim();return {attrs:ce(n,e[2]||""),tag:n}},l:(e,r,t)=>W(e.tag,n({},e.attrs,{key:t.key}))},12:{t:["\x3c!--"],o:Me(B),i:1,u:()=>({}),l:Ve},14:{t:["!["],o:Ie(be),i:1,u:e=>({alt:Fe(e[1]),target:Fe(e[2]),title:Fe(e[3])}),l:(e,n,r)=>W("img",{key:r.key,alt:e.alt||void 0,title:e.title||void 0,src:G(e.target,"img","src")})},15:{t:["["],o:Ce(ve),i:3,u:(e,n,r)=>({children:Ze(n,e[1],r),target:Fe(e[2]),title:Fe(e[3])}),l:(e,n,r)=>W("a",{key:r.key,href:G(e.target,"a","href"),title:e.title},n(e.children,r))},16:{t:["<"],o:Ce(I),i:0,u(e){let n=e[1],r=!1;return -1!==n.indexOf("@")&&-1===n.indexOf("//")&&(r=!0,n=n.replace("mailto:","")),{children:[{text:n,type:"27"}],target:r?"mailto:"+n:n,type:"15"}}},17:{t:(e,n)=>!n.inAnchor&&!t.disableAutoLink&&(ze(e,"http://")||ze(e,"https://")),o:Ce(C),i:0,u:e=>({children:[{text:e[1],type:"27"}],target:e[1],title:void 0,type:"15"})},20:qe(W,1),33:qe(W,2),19:{t:["\n"],o:Te(m),i:3,u:Ue,l:()=>"\n"},21:{o:je(function(e,n){if(n.inline||n.simple||n.inHTML&&-1===e.indexOf("\n\n")&&-1===n.prevCapture.indexOf("\n\n"))return null;let r="",t=0;for(;;){const n=e.indexOf("\n",t),o=e.slice(t,-1===n?void 0:n+1);if(Q(V,o))break;if(r+=o,-1===n||!o.trim())break;t=n+1;}const o=Se(r);return ""===o?null:[r,,o]}),i:3,u:Ge,l:(e,n,r)=>W("p",{key:r.key},n(e.children,r))},22:{t:["["],o:Ce(D),i:0,u:e=>(ue[e[1]]={target:e[2],title:e[4]},{}),l:Ve},23:{t:["!["],o:Ie(F),i:0,u:e=>({alt:e[1]?Fe(e[1]):void 0,ref:e[2]}),l:(e,n,r)=>ue[e.ref]?W("img",{key:r.key,alt:e.alt,src:G(ue[e.ref].target,"img","src"),title:ue[e.ref].title}):null},24:{t:e=>"["===e[0]&&-1===e.indexOf("]("),o:Ce(P),i:0,u:(e,n,r)=>({children:n(e[1],r),fallbackChildren:e[0],ref:e[2]}),l:(e,n,r)=>ue[e.ref]?W("a",{key:r.key,href:G(ue[e.ref].target,"a","href"),title:ue[e.ref].title},n(e.children,r)):W("span",{key:r.key},e.fallbackChildren)},25:{t:["|"],o:Te(M),i:1,u:Le,l(e,n,r){const t=e;return W("table",{key:r.key},W("thead",null,W("tr",null,t.header.map(function(e,o){return W("th",{key:o,style:Oe(t,o)},n(e,r))}))),W("tbody",null,t.cells.map(function(e,o){return W("tr",{key:o},e.map(function(e,o){return W("td",{key:o,style:Oe(t,o)},n(e,r))}))})))}},27:{o:je(function(e,n){let r;return ze(e,":")&&(r=ee.exec(e)),r||te.exec(e)}),i:4,u(e){const n=e[0];return {text:-1===n.indexOf("&")?n:n.replace(R,(e,n)=>t.namedCodesToUnicode[n]||e)}},l:e=>e.text},28:{t:["**","__"],o:Ie(J),i:2,u:(e,n,r)=>({children:n(e[2],r)}),l:(e,n,r)=>W("strong",{key:r.key},n(e.children,r))},29:{t:e=>{const n=e[0];return ("*"===n||"_"===n)&&e[1]!==n},o:Ie(K),i:3,u:(e,n,r)=>({children:n(e[2],r)}),l:(e,n,r)=>W("em",{key:r.key},n(e.children,r))},30:{t:["\\"],o:Ie(ne),i:1,u:e=>({text:e[1],type:"27"})},31:{t:["=="],o:Ie(X),i:3,u:Ge,l:(e,n,r)=>W("mark",{key:r.key},n(e.children,r))},32:{t:["~~"],o:Ie(Y),i:3,u:Ge,l:(e,n,r)=>W("del",{key:r.key},n(e.children,r))}};!0===t.disableParsingRawHTML&&(delete le[11],delete le[13]);const se=function(e){var n=Object.keys(e);function r(t,o){var a=[];if(o.prevCapture=o.prevCapture||"",t.trim())for(;t;)for(var c=0;c<n.length;){var i=n[c],u=e[i];if(!u.t||Ee(t,o,u.t)){var l=u.o(t,o);if(l&&l[0]){t=t.substring(l[0].length);var s=u.u(l,r,o);o.prevCapture+=l[0],s.type||(s.type=i),a.push(s);break}c++;}else c++;}return o.prevCapture="",a}return n.sort(function(n,r){return e[n].i-e[r].i||(n<r?-1:1)}),function(e,n){return r(function(e){return e.replace(k,"\n").replace(v,"").replace(N," ")}(e),n)}}(le),fe=function(e,n){return function r(t,o={}){if(Array.isArray(t)){const e=o.key,n=[];let a=!1;for(let e=0;e<t.length;e++){o.key=e;const c=r(t[e],o),i=$e(c);i&&a?n[n.length-1]+=c:null!==c&&n.push(c),a=i;}return o.key=e,n}return function(r,t,o){const a=e[r.type].l;return n?n(()=>a(r,t,o),r,t,o):a(r,t,o)}(t,r,o)}}(le,t.renderRule),_e=re(r);return ie.length?W("div",null,_e,W("footer",{key:"footer"},ie.map(function(e){return W("div",{id:l(e.identifier,Ae),key:e.identifier},e.identifier,fe(se(e.footnote,{inline:!0})))}))):_e}
14384
+ function n(){return n=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t]);}return e},n.apply(this,arguments)}const t={blockQuote:"0",breakLine:"1",breakThematic:"2",codeBlock:"3",codeFenced:"4",codeInline:"5",footnote:"6",footnoteReference:"7",gfmTask:"8",heading:"9",headingSetext:"10",htmlBlock:"11",htmlComment:"12",htmlSelfClosing:"13",image:"14",link:"15",linkAngleBraceStyleDetector:"16",linkBareUrlDetector:"17",linkMailtoDetector:"18",newlineCoalescer:"19",orderedList:"20",paragraph:"21",ref:"22",refImage:"23",refLink:"24",table:"25",tableSeparator:"26",text:"27",textBolded:"28",textEmphasized:"29",textEscaped:"30",textMarked:"31",textStrikethroughed:"32",unorderedList:"33"},o=["allowFullScreen","allowTransparency","autoComplete","autoFocus","autoPlay","cellPadding","cellSpacing","charSet","classId","colSpan","contentEditable","contextMenu","crossOrigin","encType","formAction","formEncType","formMethod","formNoValidate","formTarget","frameBorder","hrefLang","inputMode","keyParams","keyType","marginHeight","marginWidth","maxLength","mediaGroup","minLength","noValidate","radioGroup","readOnly","rowSpan","spellCheck","srcDoc","srcLang","srcSet","tabIndex","useMap"].reduce((e,n)=>(e[n.toLowerCase()]=n,e),{class:"className",for:"htmlFor"}),a={amp:"&",apos:"'",gt:">",lt:"<",nbsp:" ",quot:"“"},c=["style","script","pre"],i=["src","href","data","formAction","srcDoc","action"],u=/([-A-Z0-9_:]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:\{((?:\\.|{[^}]*?}|[^}])*)\})))?/gi,l=/\n{2,}$/,s=/^(\s*>[\s\S]*?)(?=\n\n|$)/,f=/^ *> ?/gm,_=/^(?:\[!([^\]]*)\]\n)?([\s\S]*)/,d=/^ {2,}\n/,p=/^(?:([-*_])( *\1){2,}) *(?:\n *)+\n/,y=/^(?: {1,3})?(`{3,}|~{3,}) *(\S+)? *([^\n]*?)?\n([\s\S]*?)(?:\1\n?|$)/,h=/^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/,g=/^(`+)((?:\\`|(?!\1)`|[^`])+)\1/,m=/^(?:\n *)*\n/,k=/\r\n?/g,x=/^\[\^([^\]]+)](:(.*)((\n+ {4,}.*)|(\n(?!\[\^).+))*)/,q=/^\[\^([^\]]+)]/,v=/\f/g,b=/^---[ \t]*\n(.|\n)*\n---[ \t]*\n/,$=/^\s*?\[(x|\s)\]/,S=/^ *(#{1,6}) *([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,z=/^ *(#{1,6}) +([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,E=/^([^\n]+)\n *(=|-)\2{2,} *\n/,A=/^ *(?!<[a-z][^ >/]* ?\/>)<([a-z][^ >/]*) ?((?:[^>]*[^/])?)>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1\b)[\s\S])*?)<\/\1>(?!<\/\1>)\n*/i,R=/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/gi,B=/^<!--[\s\S]*?(?:-->)/,L=/^(data|aria|x)-[a-z_][a-z\d_.-]*$/,O=/^ *<([a-z][a-z0-9:]*)(?:\s+((?:<.*?>|[^>])*))?\/?>(?!<\/\1>)(\s*\n)?/i,j=/^\{.*\}$/,C=/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,I=/^<([^ >]+[:@\/][^ >]+)>/,T=/-([a-z])?/gi,M=/^(\|.*)\n(?: *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*))?\n?/,w=/^[^\n]+(?: \n|\n{2,})/,D=/^\[([^\]]*)\]:\s+<?([^\s>]+)>?\s*("([^"]*)")?/,F=/^!\[([^\]]*)\] ?\[([^\]]*)\]/,P=/^\[([^\]]*)\] ?\[([^\]]*)\]/,Z=/(\n|^[-*]\s|^#|^ {2,}|^-{2,}|^>\s)/,N=/\t/g,G=/(^ *\||\| *$)/g,U=/^ *:-+: *$/,V=/^ *:-+ *$/,H=/^ *-+: *$/,Q=e=>`(?=[\\s\\S]+?\\1${e?"\\1":""})`,W="((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|\\\\\\1|[\\s\\S])+?)",J=RegExp(`^([*_])\\1${Q(1)}${W}\\1\\1(?!\\1)`),K=RegExp(`^([*_])${Q(0)}${W}\\1(?!\\1)`),X=RegExp(`^(==)${Q(0)}${W}\\1`),Y=RegExp(`^(~~)${Q(0)}${W}\\1`),ee=/^(:[a-zA-Z0-9-_]+:)/,ne=/^\\([^0-9A-Za-z\s])/,re=/\\([^0-9A-Za-z\s])/g,te=/^[\s\S](?:(?! \n|[0-9]\.|http)[^=*_~\-\n:<`\\\[!])*/,oe=/^\n+/,ae=/^([ \t]*)/,ce=/(?:^|\n)( *)$/,ie="(?:\\d+\\.)",ue="(?:[*+-])";function le(e){return "( *)("+(1===e?ie:ue)+") +"}const se=le(1),fe=le(2);function _e(e){return RegExp("^"+(1===e?se:fe))}const de=_e(1),pe=_e(2);function ye(e){return RegExp("^"+(1===e?se:fe)+"[^\\n]*(?:\\n(?!\\1"+(1===e?ie:ue)+" )[^\\n]*)*(\\n|$)","gm")}const he=ye(1),ge=ye(2);function me(e){const n=1===e?ie:ue;return RegExp("^( *)("+n+") [\\s\\S]+?(?:\\n{2,}(?! )(?!\\1"+n+" (?!"+n+" ))\\n*|\\s*\\n*$)")}const ke=me(1),xe=me(2);function qe(e,n){const r=1===n,t=r?ke:xe,o=r?he:ge,a=r?de:pe;return {t:e=>a.test(e),o:je(function(e,n){const r=ce.exec(n.prevCapture);return r&&(n.list||!n.inline&&!n.simple)?t.exec(e=r[1]+e):null}),i:1,u(e,n,t){const c=r?+e[2]:void 0,i=e[0].replace(l,"\n").match(o);let u=!1;return {items:i.map(function(e,r){const o=a.exec(e)[0].length,c=RegExp("^ {1,"+o+"}","gm"),l=e.replace(c,"").replace(a,""),s=r===i.length-1,f=-1!==l.indexOf("\n\n")||s&&u;u=f;const _=t.inline,d=t.list;let p;t.list=!0,f?(t.inline=!1,p=Se(l)+"\n\n"):(t.inline=!0,p=Se(l));const y=n(p,t);return t.inline=_,t.list=d,y}),ordered:r,start:c}},l:(n,r,t)=>e(n.ordered?"ol":"ul",{key:t.key,start:"20"===n.type?n.start:void 0},n.items.map(function(n,o){return e("li",{key:o},r(n,t))}))}}const ve=RegExp("^\\[((?:\\[[^\\[\\]]*(?:\\[[^\\[\\]]*\\][^\\[\\]]*)*\\]|[^\\[\\]])*)\\]\\(\\s*<?((?:\\([^)]*\\)|[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*\\)"),be=/^!\[(.*?)\]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/;function $e(e){return "string"==typeof e}function Se(e){let n=e.length;for(;n>0&&e[n-1]<=" ";)n--;return e.slice(0,n)}function ze(e,n){return e.startsWith(n)}function Ee(e,n,r){if(Array.isArray(r)){for(let n=0;n<r.length;n++)if(ze(e,r[n]))return !0;return !1}return r(e,n)}function Ae(e){return e.replace(/[ÀÁÂÃÄÅàáâãä忯]/g,"a").replace(/[çÇ]/g,"c").replace(/[ðÐ]/g,"d").replace(/[ÈÉÊËéèêë]/g,"e").replace(/[ÏïÎîÍíÌì]/g,"i").replace(/[Ññ]/g,"n").replace(/[øØœŒÕõÔôÓóÒò]/g,"o").replace(/[ÜüÛûÚúÙù]/g,"u").replace(/[ŸÿÝý]/g,"y").replace(/[^a-z0-9- ]/gi,"").replace(/ /gi,"-").toLowerCase()}function Re(e){return H.test(e)?"right":U.test(e)?"center":V.test(e)?"left":null}function Be(e,n,r,t){const o=r.inTable;r.inTable=!0;let a=[[]],c="";function i(){if(!c)return;const e=a[a.length-1];e.push.apply(e,n(c,r)),c="";}return e.trim().split(/(`[^`]*`|\\\||\|)/).filter(Boolean).forEach((e,n,r)=>{"|"===e.trim()&&(i(),t)?0!==n&&n!==r.length-1&&a.push([]):c+=e;}),i(),r.inTable=o,a}function Le(e,n,r){r.inline=!0;const t=e[2]?e[2].replace(G,"").split("|").map(Re):[],o=e[3]?function(e,n,r){return e.trim().split("\n").map(function(e){return Be(e,n,r,!0)})}(e[3],n,r):[],a=Be(e[1],n,r,!!o.length);return r.inline=!1,o.length?{align:t,cells:o,header:a,type:"25"}:{children:a,type:"21"}}function Oe(e,n){return null==e.align[n]?{}:{textAlign:e.align[n]}}function je(e){return e.inline=1,e}function Ce(e){return je(function(n,r){return r.inline?e.exec(n):null})}function Ie(e){return je(function(n,r){return r.inline||r.simple?e.exec(n):null})}function Te(e){return function(n,r){return r.inline||r.simple?null:e.exec(n)}}function Me(e){return je(function(n){return e.exec(n)})}const we=/(javascript|vbscript|data(?!:image)):/i;function De(e){try{const n=decodeURIComponent(e).replace(/[^A-Za-z0-9/:]/g,"");if(we.test(n))return null}catch(e){return null}return e}function Fe(e){return e?e.replace(re,"$1"):e}function Pe(e,n,r){const t=r.inline||!1,o=r.simple||!1;r.inline=!0,r.simple=!0;const a=e(n,r);return r.inline=t,r.simple=o,a}function Ze(e,n,r){const t=r.inline||!1,o=r.simple||!1;r.inline=!1,r.simple=!0;const a=e(n,r);return r.inline=t,r.simple=o,a}function Ne(e,n,r){const t=r.inline||!1;r.inline=!1;const o=e(n,r);return r.inline=t,o}const Ge=(e,n,r)=>({children:Pe(n,e[2],r)});function Ue(){return {}}function Ve(){return null}function He(...e){return e.filter(Boolean).join(" ")}function Qe(e,n,r){let t=e;const o=n.split(".");for(;o.length&&(t=t[o[0]],void 0!==t);)o.shift();return t||r}function We(r="",t={}){t.overrides=t.overrides||{},t.namedCodesToUnicode=t.namedCodesToUnicode?n({},a,t.namedCodesToUnicode):a;const l=t.slugify||Ae,G=t.sanitizer||De,U=t.createElement||React__namespace.createElement,V=[s,y,h,t.enforceAtxHeadings?z:S,E,M,ke,xe],H=[...V,w,A,B,O];function Q(e,n){for(let r=0;r<e.length;r++)if(e[r].test(n))return !0;return !1}function W(e,r,...o){const a=Qe(t.overrides,e+".props",{});return U(function(e,n){const r=Qe(n,e);return r?"function"==typeof r||"object"==typeof r&&"render"in r?r:Qe(n,e+".component",e):e}(e,t.overrides),n({},r,a,{className:He(null==r?void 0:r.className,a.className)||void 0}),...o)}function re(e){e=e.replace(b,"");let n=!1;t.forceInline?n=!0:t.forceBlock||(n=!1===Z.test(e));const r=fe(se(n?e:Se(e).replace(oe,"")+"\n\n",{inline:n}));for(;$e(r[r.length-1])&&!r[r.length-1].trim();)r.pop();if(null===t.wrapper)return r;const o=t.wrapper||(n?"span":"div");let a;if(r.length>1||t.forceWrapper)a=r;else {if(1===r.length)return a=r[0],"string"==typeof a?W("span",{key:"outer"},a):a;a=null;}return U(o,{key:"outer"},a)}function ce(e,n){if(!n||!n.trim())return null;const r=n.match(u);return r?r.reduce(function(n,r){const t=r.indexOf("=");if(-1!==t){const a=function(e){return -1!==e.indexOf("-")&&null===e.match(L)&&(e=e.replace(T,function(e,n){return n.toUpperCase()})),e}(r.slice(0,t)).trim(),c=function(e){const n=e[0];return ('"'===n||"'"===n)&&e.length>=2&&e[e.length-1]===n?e.slice(1,-1):e}(r.slice(t+1).trim()),u=o[a]||a;if("ref"===u)return n;const l=n[u]=function(e,n,r,t){return "style"===n?function(e){const n=[];let r="",t=!1,o=!1,a="";if(!e)return n;for(let c=0;c<e.length;c++){const i=e[c];if('"'!==i&&"'"!==i||t||(o?i===a&&(o=!1,a=""):(o=!0,a=i)),"("===i&&r.endsWith("url")?t=!0:")"===i&&t&&(t=!1),";"!==i||o||t)r+=i;else {const e=r.trim();if(e){const r=e.indexOf(":");if(r>0){const t=e.slice(0,r).trim(),o=e.slice(r+1).trim();n.push([t,o]);}}r="";}}const c=r.trim();if(c){const e=c.indexOf(":");if(e>0){const r=c.slice(0,e).trim(),t=c.slice(e+1).trim();n.push([r,t]);}}return n}(r).reduce(function(n,[r,o]){return n[r.replace(/(-[a-z])/g,e=>e[1].toUpperCase())]=t(o,e,r),n},{}):-1!==i.indexOf(n)?t(Fe(r),e,n):(r.match(j)&&(r=Fe(r.slice(1,r.length-1))),"true"===r||"false"!==r&&r)}(e,a,c,G);"string"==typeof l&&(A.test(l)||O.test(l))&&(n[u]=re(l.trim()));}else "style"!==r&&(n[o[r]||r]=!0);return n},{}):null}const ie=[],ue={},le={0:{t:[">"],o:Te(s),i:1,u(e,n,r){const[,t,o]=e[0].replace(f,"").match(_);return {alert:t,children:n(o,r)}},l(e,n,r){const t={key:r.key};return e.alert&&(t.className="markdown-alert-"+l(e.alert.toLowerCase(),Ae),e.children.unshift({attrs:{},children:[{type:"27",text:e.alert}],noInnerParse:!0,type:"11",tag:"header"})),W("blockquote",t,n(e.children,r))}},1:{t:[" "],o:Me(d),i:1,u:Ue,l:(e,n,r)=>W("br",{key:r.key})},2:{t:["--","__","**","- ","* ","_ "],o:Te(p),i:1,u:Ue,l:(e,n,r)=>W("hr",{key:r.key})},3:{t:[" "],o:Te(h),i:0,u:e=>({lang:void 0,text:Fe(Se(e[0].replace(/^ {4}/gm,"")))}),l:(e,r,t)=>W("pre",{key:t.key},W("code",n({},e.attrs,{className:e.lang?"lang-"+e.lang:""}),e.text))},4:{t:["```","~~~"],o:Te(y),i:0,u:e=>({attrs:ce("code",e[3]||""),lang:e[2]||void 0,text:e[4],type:"3"})},5:{t:["`"],o:Ie(g),i:3,u:e=>({text:Fe(e[2])}),l:(e,n,r)=>W("code",{key:r.key},e.text)},6:{t:["[^"],o:Te(x),i:0,u:e=>(ie.push({footnote:e[2],identifier:e[1]}),{}),l:Ve},7:{t:["[^"],o:Ce(q),i:1,u:e=>({target:"#"+l(e[1],Ae),text:e[1]}),l:(e,n,r)=>W("a",{key:r.key,href:G(e.target,"a","href")},W("sup",{key:r.key},e.text))},8:{t:["[ ]","[x]"],o:Ce($),i:1,u:e=>({completed:"x"===e[1].toLowerCase()}),l:(e,n,r)=>W("input",{checked:e.completed,key:r.key,readOnly:!0,type:"checkbox"})},9:{t:["#"],o:Te(t.enforceAtxHeadings?z:S),i:1,u:(e,n,r)=>({children:Pe(n,e[2],r),id:l(e[2],Ae),level:e[1].length}),l:(e,n,r)=>W("h"+e.level,{id:e.id,key:r.key},n(e.children,r))},10:{t:e=>{const n=e.indexOf("\n");return n>0&&n<e.length-1&&("="===e[n+1]||"-"===e[n+1])},o:Te(E),i:0,u:(e,n,r)=>({children:Pe(n,e[1],r),level:"="===e[2]?1:2,type:"9"})},11:{t:["<"],o:Me(A),i:1,u(e,n,r){const[,t]=e[3].match(ae),o=RegExp("^"+t,"gm"),a=e[3].replace(o,""),i=Q(H,a)?Ne:Pe,u=e[1].toLowerCase(),l=-1!==c.indexOf(u),s=(l?u:e[1]).trim(),f={attrs:ce(s,e[2]),noInnerParse:l,tag:s};if(r.inAnchor=r.inAnchor||"a"===u,l)f.text=e[3];else {const e=r.inHTML;r.inHTML=!0,f.children=i(n,a,r),r.inHTML=e;}return r.inAnchor=!1,f},l:(e,r,t)=>W(e.tag,n({key:t.key},e.attrs),e.text||(e.children?r(e.children,t):""))},13:{t:["<"],o:Me(O),i:1,u(e){const n=e[1].trim();return {attrs:ce(n,e[2]||""),tag:n}},l:(e,r,t)=>W(e.tag,n({},e.attrs,{key:t.key}))},12:{t:["\x3c!--"],o:Me(B),i:1,u:()=>({}),l:Ve},14:{t:["!["],o:Ie(be),i:1,u:e=>({alt:Fe(e[1]),target:Fe(e[2]),title:Fe(e[3])}),l:(e,n,r)=>W("img",{key:r.key,alt:e.alt||void 0,title:e.title||void 0,src:G(e.target,"img","src")})},15:{t:["["],o:Ce(ve),i:3,u:(e,n,r)=>({children:Ze(n,e[1],r),target:Fe(e[2]),title:Fe(e[3])}),l:(e,n,r)=>W("a",{key:r.key,href:G(e.target,"a","href"),title:e.title},n(e.children,r))},16:{t:["<"],o:Ce(I),i:0,u(e){let n=e[1],r=!1;return -1!==n.indexOf("@")&&-1===n.indexOf("//")&&(r=!0,n=n.replace("mailto:","")),{children:[{text:n,type:"27"}],target:r?"mailto:"+n:n,type:"15"}}},17:{t:(e,n)=>!n.inAnchor&&!t.disableAutoLink&&(ze(e,"http://")||ze(e,"https://")),o:Ce(C),i:0,u:e=>({children:[{text:e[1],type:"27"}],target:e[1],title:void 0,type:"15"})},20:qe(W,1),33:qe(W,2),19:{t:["\n"],o:Te(m),i:3,u:Ue,l:()=>"\n"},21:{o:je(function(e,n){if(n.inline||n.simple||n.inHTML&&-1===e.indexOf("\n\n")&&-1===n.prevCapture.indexOf("\n\n"))return null;let r="",t=0;for(;;){const n=e.indexOf("\n",t),o=e.slice(t,-1===n?void 0:n+1);if(Q(V,o))break;if(r+=o,-1===n||!o.trim())break;t=n+1;}const o=Se(r);return ""===o?null:[r,,o]}),i:3,u:Ge,l:(e,n,r)=>W("p",{key:r.key},n(e.children,r))},22:{t:["["],o:Ce(D),i:0,u:e=>(ue[e[1]]={target:e[2],title:e[4]},{}),l:Ve},23:{t:["!["],o:Ie(F),i:0,u:e=>({alt:e[1]?Fe(e[1]):void 0,ref:e[2]}),l:(e,n,r)=>ue[e.ref]?W("img",{key:r.key,alt:e.alt,src:G(ue[e.ref].target,"img","src"),title:ue[e.ref].title}):null},24:{t:e=>"["===e[0]&&-1===e.indexOf("]("),o:Ce(P),i:0,u:(e,n,r)=>({children:n(e[1],r),fallbackChildren:e[0],ref:e[2]}),l:(e,n,r)=>ue[e.ref]?W("a",{key:r.key,href:G(ue[e.ref].target,"a","href"),title:ue[e.ref].title},n(e.children,r)):W("span",{key:r.key},e.fallbackChildren)},25:{t:["|"],o:Te(M),i:1,u:Le,l(e,n,r){const t=e;return W("table",{key:r.key},W("thead",null,W("tr",null,t.header.map(function(e,o){return W("th",{key:o,style:Oe(t,o)},n(e,r))}))),W("tbody",null,t.cells.map(function(e,o){return W("tr",{key:o},e.map(function(e,o){return W("td",{key:o,style:Oe(t,o)},n(e,r))}))})))}},27:{o:je(function(e,n){let r;return ze(e,":")&&(r=ee.exec(e)),r||te.exec(e)}),i:4,u(e){const n=e[0];return {text:-1===n.indexOf("&")?n:n.replace(R,(e,n)=>t.namedCodesToUnicode[n]||e)}},l:e=>e.text},28:{t:["**","__"],o:Ie(J),i:2,u:(e,n,r)=>({children:n(e[2],r)}),l:(e,n,r)=>W("strong",{key:r.key},n(e.children,r))},29:{t:e=>{const n=e[0];return ("*"===n||"_"===n)&&e[1]!==n},o:Ie(K),i:3,u:(e,n,r)=>({children:n(e[2],r)}),l:(e,n,r)=>W("em",{key:r.key},n(e.children,r))},30:{t:["\\"],o:Ie(ne),i:1,u:e=>({text:e[1],type:"27"})},31:{t:["=="],o:Ie(X),i:3,u:Ge,l:(e,n,r)=>W("mark",{key:r.key},n(e.children,r))},32:{t:["~~"],o:Ie(Y),i:3,u:Ge,l:(e,n,r)=>W("del",{key:r.key},n(e.children,r))}};!0===t.disableParsingRawHTML&&(delete le[11],delete le[13]);const se=function(e){var n=Object.keys(e);function r(t,o){var a=[];if(o.prevCapture=o.prevCapture||"",t.trim())for(;t;)for(var c=0;c<n.length;){var i=n[c],u=e[i];if(!u.t||Ee(t,o,u.t)){var l=u.o(t,o);if(l&&l[0]){t=t.substring(l[0].length);var s=u.u(l,r,o);o.prevCapture+=l[0],s.type||(s.type=i),a.push(s);break}c++;}else c++;}return o.prevCapture="",a}return n.sort(function(n,r){return e[n].i-e[r].i||(n<r?-1:1)}),function(e,n){return r(function(e){return e.replace(k,"\n").replace(v,"").replace(N," ")}(e),n)}}(le),fe=function(e,n){return function r(t,o={}){if(Array.isArray(t)){const e=o.key,n=[];let a=!1;for(let e=0;e<t.length;e++){o.key=e;const c=r(t[e],o),i=$e(c);i&&a?n[n.length-1]+=c:null!==c&&n.push(c),a=i;}return o.key=e,n}return function(r,t,o){const a=e[r.type].l;return n?n(()=>a(r,t,o),r,t,o):a(r,t,o)}(t,r,o)}}(le,t.renderRule),_e=re(r);return ie.length?W("div",null,_e,W("footer",{key:"footer"},ie.map(function(e){return W("div",{id:l(e.identifier,Ae),key:e.identifier},e.identifier,fe(se(e.footnote,{inline:!0})))}))):_e}
14385
14385
 
14386
14386
  var createRecords = function createRecords() {
14387
14387
  return Object.create(null);
@@ -14440,18 +14440,39 @@
14440
14440
  function createChatMessageReasoningComponent(param) {
14441
14441
  var createElement = param.createElement;
14442
14442
  return function ChatMessageReasoning(userProps) {
14443
- var part = userProps.part, isStreaming = userProps.isStreaming, _userProps_parseMarkdown = userProps.parseMarkdown, parseMarkdown = _userProps_parseMarkdown === void 0 ? true : _userProps_parseMarkdown, translations = userProps.translations, classNames = userProps.classNames;
14444
- var body = parseMarkdown ? We(part.text, {
14445
- createElement: createElement,
14446
- disableParsingRawHTML: true
14447
- }) : // newlines markdown would collapse.
14448
- /*#__PURE__*/ createElement("p", {
14449
- className: "ais-ChatMessage-text"
14450
- }, part.text);
14443
+ var parts = userProps.parts, hidden = userProps.hidden, _userProps_parseMarkdown = userProps.parseMarkdown, parseMarkdown = _userProps_parseMarkdown === void 0 ? true : _userProps_parseMarkdown, translations = userProps.translations, classNames = userProps.classNames;
14444
+ var activePart = parts.find(function(param) {
14445
+ var isStreaming = param.isStreaming;
14446
+ return isStreaming;
14447
+ });
14448
+ var isStreaming = Boolean(activePart);
14449
+ var hasActiveHint = Boolean(activePart === null || activePart === void 0 ? void 0 : activePart.part.text.trim());
14450
+ var renderPart = function renderPart(param) {
14451
+ var part = param.part;
14452
+ return parseMarkdown ? We(part.text, {
14453
+ createElement: createElement,
14454
+ disableParsingRawHTML: true
14455
+ }) : /*#__PURE__*/ createElement("p", {
14456
+ className: "ais-ChatMessage-text"
14457
+ }, part.text);
14458
+ };
14459
+ var renderHint = function renderHint(part) {
14460
+ return parseMarkdown ? We(part.text, {
14461
+ createElement: createElement,
14462
+ forceInline: true,
14463
+ renderRule: function renderRule(next, node) {
14464
+ if (node.type === t.htmlBlock || node.type === t.htmlComment || node.type === t.htmlSelfClosing) {
14465
+ return null;
14466
+ }
14467
+ return next();
14468
+ }
14469
+ }) : part.text;
14470
+ };
14451
14471
  return /*#__PURE__*/ createElement("details", {
14452
14472
  className: cx(classNames.reasoning),
14453
14473
  "aria-label": translations.reasoningLabel,
14454
- "aria-busy": isStreaming
14474
+ "aria-busy": isStreaming,
14475
+ hidden: hidden
14455
14476
  }, /*#__PURE__*/ createElement("summary", {
14456
14477
  className: cx(classNames.reasoningHeader)
14457
14478
  }, /*#__PURE__*/ createElement("span", {
@@ -14461,17 +14482,29 @@
14461
14482
  createElement: createElement
14462
14483
  })), /*#__PURE__*/ createElement("span", {
14463
14484
  className: cx(classNames.reasoningLabel)
14464
- }, translations.reasoningLabel), /*#__PURE__*/ createElement("span", {
14485
+ }, translations.reasoningLabel), activePart && hasActiveHint && /*#__PURE__*/ createElement("span", {
14486
+ className: "ais-ChatMessageReasoning-status",
14487
+ "aria-hidden": "true"
14488
+ }, /*#__PURE__*/ createElement("span", {
14489
+ className: "ais-ChatMessageReasoning-separator"
14490
+ }, "\xb7"), /*#__PURE__*/ createElement("span", {
14491
+ className: "ais-ChatMessageReasoning-hint"
14492
+ }, renderHint(activePart.part))), /*#__PURE__*/ createElement("span", {
14465
14493
  className: cx(classNames.reasoningChevron),
14466
14494
  "aria-hidden": "true"
14467
14495
  }, /*#__PURE__*/ createElement(ChevronDownIcon, {
14468
14496
  createElement: createElement
14469
14497
  }))), /*#__PURE__*/ createElement("div", {
14470
- className: cx(classNames.reasoningBody),
14471
- tabIndex: 0
14472
- }, /*#__PURE__*/ createElement("div", {
14498
+ className: cx(classNames.reasoningBody)
14499
+ }, /*#__PURE__*/ createElement("ol", {
14473
14500
  className: cx(classNames.reasoningText)
14474
- }, body)));
14501
+ }, parts.map(function(reasoningPart) {
14502
+ return /*#__PURE__*/ createElement("li", {
14503
+ key: reasoningPart.partIndex,
14504
+ className: "ais-ChatMessageReasoning-item",
14505
+ "aria-current": reasoningPart.isStreaming ? 'step' : undefined
14506
+ }, renderPart(reasoningPart));
14507
+ }))));
14475
14508
  };
14476
14509
  }
14477
14510
 
@@ -14504,8 +14537,8 @@
14504
14537
  createElement: createElement
14505
14538
  });
14506
14539
  return function ChatMessage(userProps) {
14507
- var _messages_;
14508
- var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, message = userProps.message, _userProps_side = userProps.side, side = _userProps_side === void 0 ? 'left' : _userProps_side, _userProps_variant = userProps.variant, variant = _userProps_variant === void 0 ? 'subtle' : _userProps_variant, _userProps_actions = userProps.actions, actions = _userProps_actions === void 0 ? [] : _userProps_actions, _userProps_autoHideActions = userProps.autoHideActions, autoHideActions = _userProps_autoHideActions === void 0 ? false : _userProps_autoHideActions, LeadingComponent = userProps.leadingComponent, ActionsComponent = userProps.actionsComponent, FooterComponent = userProps.footerComponent, TextComponent = userProps.textComponent, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, userTranslations = userProps.translations, suggestionsElement = userProps.suggestionsElement, loaderElement = userProps.loaderElement, _userProps_showReasoning = userProps.showReasoning, showReasoning = _userProps_showReasoning === void 0 ? false : _userProps_showReasoning, _userProps_parseMarkdown = userProps.parseMarkdown, parseMarkdown = _userProps_parseMarkdown === void 0 ? true : _userProps_parseMarkdown, ownMessages = userProps.messages, /* eslint-disable typescript/no-deprecated -- reading the
14540
+ var _messages_, _reasoningParts_;
14541
+ var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, message = userProps.message, _userProps_side = userProps.side, side = _userProps_side === void 0 ? 'left' : _userProps_side, _userProps_variant = userProps.variant, variant = _userProps_variant === void 0 ? 'subtle' : _userProps_variant, _userProps_actions = userProps.actions, actions = _userProps_actions === void 0 ? [] : _userProps_actions, _userProps_autoHideActions = userProps.autoHideActions, autoHideActions = _userProps_autoHideActions === void 0 ? false : _userProps_autoHideActions, LeadingComponent = userProps.leadingComponent, ActionsComponent = userProps.actionsComponent, FooterComponent = userProps.footerComponent, TextComponent = userProps.textComponent, ReasoningComponent = userProps.reasoningComponent, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, userTranslations = userProps.translations, suggestionsElement = userProps.suggestionsElement, loaderElement = userProps.loaderElement, _userProps_showReasoning = userProps.showReasoning, showReasoning = _userProps_showReasoning === void 0 ? true : _userProps_showReasoning, _userProps_parseMarkdown = userProps.parseMarkdown, parseMarkdown = _userProps_parseMarkdown === void 0 ? true : _userProps_parseMarkdown, ownMessages = userProps.messages, /* eslint-disable typescript/no-deprecated -- reading the
14509
14542
  deprecated aliases is the point: they are resolved into `context`
14510
14543
  below so callers on the previous API keep working. */ ownStatus = userProps.status, ownTools = userProps.tools, ownOnClose = userProps.onClose, /* eslint-enable typescript/no-deprecated */ sharedContext = userProps.context, props = _object_without_properties(userProps, [
14511
14544
  "classNames",
@@ -14518,6 +14551,7 @@
14518
14551
  "actionsComponent",
14519
14552
  "footerComponent",
14520
14553
  "textComponent",
14554
+ "reasoningComponent",
14521
14555
  "indexUiState",
14522
14556
  "setIndexUiState",
14523
14557
  "translations",
@@ -14546,6 +14580,7 @@
14546
14580
  var translations = _object_spread({
14547
14581
  messageLabel: 'Message',
14548
14582
  actionsLabel: 'Message actions',
14583
+ toolErrorRetryText: 'Retry',
14549
14584
  reasoningLabel: 'Reasoning'
14550
14585
  }, userTranslations);
14551
14586
  // A message rendered without a connector-attached store falls back to
@@ -14557,7 +14592,35 @@
14557
14592
  };
14558
14593
  var hasLeading = Boolean(LeadingComponent);
14559
14594
  var isCurrentMessage = messages === undefined || ((_messages_ = messages[messages.length - 1]) === null || _messages_ === void 0 ? void 0 : _messages_.id) === message.id;
14560
- var showActions = Boolean(actions.length > 0 || ActionsComponent) && status === 'ready';
14595
+ var reasoningParts = showReasoning ? message.parts.reduce(function(receivedParts, part, partIndex) {
14596
+ if (part.type !== 'reasoning') {
14597
+ return receivedParts;
14598
+ }
14599
+ var isStreaming = status === 'streaming' && isCurrentMessage && isReasoningPartActive(message.parts, partIndex);
14600
+ if (!isStreaming && part.text.trim().length === 0) {
14601
+ return receivedParts;
14602
+ }
14603
+ receivedParts.push({
14604
+ part: part,
14605
+ partIndex: partIndex,
14606
+ isStreaming: isStreaming
14607
+ });
14608
+ return receivedParts;
14609
+ }, []) : [];
14610
+ var firstReasoningPartIndex = (_reasoningParts_ = reasoningParts[0]) === null || _reasoningParts_ === void 0 ? void 0 : _reasoningParts_.partIndex;
14611
+ // Keep the built-in native disclosure mounted through a temporary
14612
+ // eligibility gap so its reader-owned state survives resumed reasoning.
14613
+ var reasoningPartIndex = firstReasoningPartIndex !== null && firstReasoningPartIndex !== void 0 ? firstReasoningPartIndex : showReasoning && !ReasoningComponent && status === 'streaming' && isCurrentMessage ? message.parts.findIndex(function(part) {
14614
+ return part.type === 'reasoning';
14615
+ }) : -1;
14616
+ var isReasoningStreaming = reasoningParts.some(function(part) {
14617
+ return part.isStreaming;
14618
+ });
14619
+ // `status` is the chat's, not the row's: gating every row on it took the
14620
+ // actions off completed answers the moment a follow-up turn started,
14621
+ // reflowing rows the turn hasn't touched. Only the row the turn is
14622
+ // producing waits for the status to settle.
14623
+ var showActions = Boolean(actions.length > 0 || ActionsComponent) && (status === 'ready' || !isCurrentMessage);
14561
14624
  var cssClasses = {
14562
14625
  root: cx('ais-ChatMessage', "ais-ChatMessage--".concat(side), "ais-ChatMessage--".concat(variant), autoHideActions && 'ais-ChatMessage--auto-hide-actions', classNames.root),
14563
14626
  container: cx('ais-ChatMessage-container', classNames.container),
@@ -14579,30 +14642,44 @@
14579
14642
  return null;
14580
14643
  }
14581
14644
  if (part.type === 'reasoning') {
14582
- if (!showReasoning) {
14583
- return null;
14645
+ // A custom component renders each step where it arrived, so the rendered
14646
+ // order matches the stream. The built-in disclosure below aggregates the
14647
+ // whole message into a single row, which is why only it is placed by
14648
+ // index.
14649
+ if (ReasoningComponent) {
14650
+ var receivedPart = reasoningParts.find(function(candidate) {
14651
+ return candidate.partIndex === index;
14652
+ });
14653
+ if (!receivedPart) {
14654
+ return null;
14655
+ }
14656
+ return /*#__PURE__*/ createElement(Fragment, {
14657
+ key: "".concat(message.id, "-reasoning-").concat(index)
14658
+ }, /*#__PURE__*/ createElement(ReasoningComponent, {
14659
+ part: receivedPart.part,
14660
+ partIndex: index,
14661
+ isStreaming: receivedPart.isStreaming,
14662
+ message: message,
14663
+ context: context
14664
+ }));
14584
14665
  }
14585
- var isReasoningStreaming = status === 'streaming' && isCurrentMessage && isReasoningPartActive(message.parts, index);
14586
- if (!isReasoningStreaming && part.text.trim().length === 0) {
14666
+ if (index !== reasoningPartIndex) {
14587
14667
  return null;
14588
14668
  }
14589
14669
  return /*#__PURE__*/ createElement(ChatMessageReasoning, {
14590
- key: "".concat(message.id, "-").concat(index),
14591
- part: part,
14592
- isStreaming: isReasoningStreaming,
14670
+ key: "".concat(message.id, "-reasoning"),
14671
+ parts: reasoningParts,
14672
+ hidden: reasoningParts.length === 0,
14593
14673
  parseMarkdown: parseMarkdown,
14594
14674
  translations: translations,
14595
14675
  classNames: _object_spread_props(_object_spread({}, cssClasses), {
14596
- reasoningLabel: cx('ais-ChatMessageReasoning-label', isReasoningStreaming && 'ais-ChatMessageReasoning-label--streaming', classNames.reasoningLabel)
14676
+ reasoningIcon: cx(cssClasses.reasoningIcon, isReasoningStreaming && 'ais-ChatMessageReasoning-icon--streaming'),
14677
+ reasoningLabel: cx(cssClasses.reasoningLabel, isReasoningStreaming && 'ais-ChatMessageReasoning-label--streaming')
14597
14678
  })
14598
14679
  });
14599
14680
  }
14600
14681
  if (part.type === 'text') {
14601
- // Back-compat shim for sessions started before the move from a
14602
- // `<context>{...}</context>` text part to `metadata.turnContext`.
14603
- // Safe to remove once existing sessionStorage transcripts have
14604
- // rolled over (~2 weeks after release).
14605
- if (part.text.startsWith('<context>') && part.text.endsWith('</context>')) {
14682
+ if (isPartTextEmpty(part)) {
14606
14683
  return null;
14607
14684
  }
14608
14685
  if (TextComponent) {
@@ -14664,7 +14741,30 @@
14664
14741
  return null;
14665
14742
  }
14666
14743
  if (!ToolLayoutComponent) {
14667
- return null;
14744
+ if (toolMessage.state !== 'output-error') {
14745
+ return null;
14746
+ }
14747
+ var messageIndex = messages.findIndex(function(candidate) {
14748
+ return candidate.id === message.id;
14749
+ });
14750
+ var canRetry = tool.retryOnError === true && Boolean(tool.onToolCall) && status === 'ready' && messageIndex >= 0 && !messages.slice(messageIndex + 1).some(function(candidate) {
14751
+ return candidate.role === 'user';
14752
+ });
14753
+ return /*#__PURE__*/ createElement("div", {
14754
+ key: "".concat(message.id, "-").concat(index),
14755
+ className: "ais-ChatMessage-tool ais-ChatMessage-toolError"
14756
+ }, /*#__PURE__*/ createElement("span", {
14757
+ className: "ais-ChatMessage-toolError-message"
14758
+ }, toolMessage.errorText || 'Tool call failed.'), canRetry && /*#__PURE__*/ createElement(Button, {
14759
+ variant: "primary",
14760
+ size: "sm",
14761
+ className: "ais-ChatMessage-toolError-action",
14762
+ onClick: function onClick() {
14763
+ return context.onReload(message.id);
14764
+ }
14765
+ }, /*#__PURE__*/ createElement(ReloadIcon, {
14766
+ createElement: createElement
14767
+ }), translations.toolErrorRetryText));
14668
14768
  }
14669
14769
  var toolSendEvent = tool.sendEvent || function() {};
14670
14770
  var agentId = (_tool_insightsEventContext = tool.insightsEventContext) === null || _tool_insightsEventContext === void 0 ? void 0 : _tool_insightsEventContext.agentId;
@@ -14700,6 +14800,13 @@
14700
14800
  }
14701
14801
  return null;
14702
14802
  }
14803
+ var renderedParts = message.parts.map(renderMessagePart);
14804
+ var hasRenderedParts = renderedParts.some(function(part) {
14805
+ return part != null;
14806
+ });
14807
+ if (!hasRenderedParts && !loaderElement && !(ActionsComponent && showActions) && !FooterComponent) {
14808
+ return suggestionsElement !== null && suggestionsElement !== void 0 ? suggestionsElement : null;
14809
+ }
14703
14810
  return /*#__PURE__*/ createElement("article", _object_spread_props(_object_spread({}, props), {
14704
14811
  className: cx(cssClasses.root, props.className),
14705
14812
  "aria-label": translations.messageLabel
@@ -14711,7 +14818,7 @@
14711
14818
  className: cx(cssClasses.content)
14712
14819
  }, /*#__PURE__*/ createElement("div", {
14713
14820
  className: cx(cssClasses.message)
14714
- }, message.parts.map(renderMessagePart), loaderElement), suggestionsElement, showActions && /*#__PURE__*/ createElement("div", {
14821
+ }, renderedParts, loaderElement), suggestionsElement, showActions && /*#__PURE__*/ createElement("div", {
14715
14822
  className: cx(cssClasses.actions),
14716
14823
  "aria-label": translations.actionsLabel
14717
14824
  }, ActionsComponent ? /*#__PURE__*/ createElement(ActionsComponent, {
@@ -15121,9 +15228,10 @@
15121
15228
  // Read the row's own side, mirroring `DefaultMessage`, so one role's change
15122
15229
  // neither invalidates the other's completed rows nor goes unnoticed here.
15123
15230
  var messageProps = props.message.role === 'user' ? props.userMessageProps : props.assistantMessageProps;
15124
- var showReasoning = messageProps === null || messageProps === void 0 ? void 0 : messageProps.showReasoning;
15231
+ var showReasoning = (messageProps === null || messageProps === void 0 ? void 0 : messageProps.showReasoning) !== false;
15125
15232
  var parseMarkdown = messageProps === null || messageProps === void 0 ? void 0 : messageProps.parseMarkdown;
15126
15233
  var textComponent = messageProps === null || messageProps === void 0 ? void 0 : messageProps.textComponent;
15234
+ var reasoningComponent = messageProps === null || messageProps === void 0 ? void 0 : messageProps.reasoningComponent;
15127
15235
  // A completed row is memoized against its own message, but `shouldRender`
15128
15236
  // reads the whole `context`: a predicate can hide an older tool result once a
15129
15237
  // newer message arrives. Track the verdicts themselves rather than
@@ -15133,6 +15241,17 @@
15133
15241
  // Custom text components receive the conversation, so their completed rows
15134
15242
  // must update with it. Keep the default renderer's streaming optimization.
15135
15243
  var textComponentMessages = textComponent ? props.context.messages : undefined;
15244
+ // A custom reasoning component receives the full context, but completed
15245
+ // rows only need to update for its semantic state, so the memo tracks those
15246
+ // fields rather than `props.context`. The context's callback identities and
15247
+ // its scroll-only changes stay out. `reasoningComponent` is tracked, so
15248
+ // replacing the component still takes effect.
15249
+ var reasoningComponentMessages = reasoningComponent ? props.context.messages : undefined;
15250
+ var reasoningComponentStatus = reasoningComponent ? props.context.status : undefined;
15251
+ var reasoningComponentError = reasoningComponent ? props.context.error : undefined;
15252
+ var reasoningComponentIsClearing = reasoningComponent ? props.context.isClearing : undefined;
15253
+ var reasoningComponentActivePart = reasoningComponent ? props.context.activePart : undefined;
15254
+ var reasoningComponentTools = reasoningComponent ? props.context.tools : undefined;
15136
15255
  // Object-level fallback, matching the render: the spread replaces
15137
15256
  // `translations` wholesale, and it copies a key holding `undefined` too. Both
15138
15257
  // are why this resolves by own-key presence rather than key by key.
@@ -15168,6 +15287,13 @@
15168
15287
  parseMarkdown,
15169
15288
  textComponent,
15170
15289
  textComponentMessages,
15290
+ reasoningComponent,
15291
+ reasoningComponentMessages,
15292
+ reasoningComponentStatus,
15293
+ reasoningComponentError,
15294
+ reasoningComponentIsClearing,
15295
+ reasoningComponentActivePart,
15296
+ reasoningComponentTools,
15171
15297
  reasoningLabel,
15172
15298
  reasoningClassName,
15173
15299
  reasoningHeaderClassName,
@@ -15251,7 +15377,7 @@
15251
15377
  scrollToBottomHidden: cx('ais-ChatMessages-scrollToBottom--hidden', classNames.scrollToBottomHidden)
15252
15378
  };
15253
15379
  var lastMessage = messages[messages.length - 1];
15254
- var showReasoning = assistantMessageProps === null || assistantMessageProps === void 0 ? void 0 : assistantMessageProps.showReasoning;
15380
+ var showReasoning = (assistantMessageProps === null || assistantMessageProps === void 0 ? void 0 : assistantMessageProps.showReasoning) !== false;
15255
15381
  var lastPart = lastMessage === null || lastMessage === void 0 ? void 0 : (_lastMessage_parts = lastMessage.parts) === null || _lastMessage_parts === void 0 ? void 0 : _lastMessage_parts[lastMessage.parts.length - 1];
15256
15382
  // `activePart` means "the part currently being processed". It must clear
15257
15383
  // when nothing is in progress: once the response settles (`ready`/`error`),
@@ -15261,7 +15387,7 @@
15261
15387
  var isProcessing = status === 'submitted' || status === 'streaming';
15262
15388
  var activePart = isProcessing && (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.role) === 'assistant' ? lastPart : undefined;
15263
15389
  // The scan slices the remaining parts per candidate, and only the loader reads
15264
- // it, so skip it entirely while the opt-in is off.
15390
+ // it, so skip it entirely once `showReasoning` is off.
15265
15391
  // The loader reports on the assistant's turn, so it only ever belongs to an
15266
15392
  // assistant message. While `submitted` the last message is still the user's
15267
15393
  // own, and the loader belongs to no message at all.
@@ -15432,9 +15558,13 @@
15432
15558
  if (status !== 'submitted' && status !== 'streaming') return false;
15433
15559
  if (status === 'submitted') return true;
15434
15560
  var lastMessage = messages[messages.length - 1];
15561
+ // `processStream` sets `streaming` before the `start` chunk pushes the
15562
+ // assistant. Until then the last message is still the user's, and its text
15563
+ // must not be read as the answer or the loader hides and comes back.
15564
+ if ((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.role) !== 'assistant') return true;
15435
15565
  // Parts that render nothing must not answer for the turn's progress, or the
15436
15566
  // loader flips on a part that changed nothing on screen.
15437
- var lastPart = findLastProgressPart(lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parts);
15567
+ var lastPart = findLastProgressPart(lastMessage.parts);
15438
15568
  if (!lastPart) return true;
15439
15569
  // An active disclosure carries its own progress affordance, so the loader would
15440
15570
  // double it. Settled reasoning still shows it: the answer has not started.
@@ -17246,6 +17376,7 @@
17246
17376
  }
17247
17377
  var scrollTop1 = state.scrollTop, ignoreScrollToTop = state.ignoreScrollToTop;
17248
17378
  var _state_lastScrollTop = state.lastScrollTop, lastScrollTop = _state_lastScrollTop === void 0 ? scrollTop1 : _state_lastScrollTop;
17379
+ var isNearBottom = state.isNearBottom;
17249
17380
  state.lastScrollTop = scrollTop1;
17250
17381
  state.ignoreScrollToTop = undefined;
17251
17382
  if (ignoreScrollToTop && ignoreScrollToTop > scrollTop1) {
@@ -17255,7 +17386,7 @@
17255
17386
  * is correct, set the lastScrollTop to the ignored event.
17256
17387
  */ lastScrollTop = ignoreScrollToTop;
17257
17388
  }
17258
- setIsNearBottom(state.isNearBottom);
17389
+ setIsNearBottom(isNearBottom);
17259
17390
  /**
17260
17391
  * Scroll events may come before a ResizeObserver event,
17261
17392
  * so in order to ignore resize events correctly we use a
@@ -17287,7 +17418,7 @@
17287
17418
  if (isScrollingDown) {
17288
17419
  setEscapedFromLock(false);
17289
17420
  }
17290
- if (!state.escapedFromLock && state.isNearBottom) {
17421
+ if (!state.escapedFromLock && isNearBottom) {
17291
17422
  setIsAtBottom(true);
17292
17423
  }
17293
17424
  }, 1);
@@ -17823,6 +17954,26 @@
17823
17954
  var _computedKey$1;
17824
17955
  var defaultGuardrailFallbackResponse = 'Sorry, we are not able to generate a response at the moment.';
17825
17956
  var TOOL_CALL_CANCELLED_ERROR_TEXT = 'The tool call was cancelled: the conversation moved on before a result was provided.';
17957
+ var RESTORED_TOOL_CALL_ERROR_TEXT = 'The page was reloaded before a tool result was received. The operation may have completed.';
17958
+ var RESTORED_TOOL_INPUT_ERROR_TEXT = 'The page was reloaded before the tool input was complete. The operation was not started.';
17959
+ function getTerminalToolState(options) {
17960
+ if (options.state === 'output-error') {
17961
+ return {
17962
+ state: 'output-error',
17963
+ errorText: options.errorText || 'Tool call failed.'
17964
+ };
17965
+ }
17966
+ if (options.state === undefined && 'errorText' in options && typeof options.errorText === 'string') {
17967
+ return {
17968
+ state: 'output-error',
17969
+ errorText: options.errorText || 'Tool call failed.'
17970
+ };
17971
+ }
17972
+ return {
17973
+ state: 'output-available',
17974
+ output: options.output
17975
+ };
17976
+ }
17826
17977
  function getToolName(part) {
17827
17978
  if (part.type === 'dynamic-tool') {
17828
17979
  var _part_toolName;
@@ -17860,7 +18011,7 @@
17860
18011
  */ var AbstractChat = /*#__PURE__*/ function() {
17861
18012
  function AbstractChat(param) {
17862
18013
  var _this = this;
17863
- var _param_generateId = param.generateId, generateId$1 = _param_generateId === void 0 ? generateId : _param_generateId, _param_id = param.id, id = _param_id === void 0 ? generateId$1() : _param_id, transport = param.transport, state = param.state, onError = param.onError, onToolCall = param.onToolCall, onFinish = param.onFinish, onData = param.onData, sendAutomaticallyWhen = param.sendAutomaticallyWhen, shouldRepairToolInput = param.shouldRepairToolInput, resolveCancelledToolOutput = param.resolveCancelledToolOutput;
18014
+ var _param_generateId = param.generateId, generateId$1 = _param_generateId === void 0 ? generateId : _param_generateId, _param_id = param.id, id = _param_id === void 0 ? generateId$1() : _param_id, transport = param.transport, state = param.state, onError = param.onError, onToolCall = param.onToolCall, onFinish = param.onFinish, onData = param.onData, sendAutomaticallyWhen = param.sendAutomaticallyWhen, shouldRepairToolInput = param.shouldRepairToolInput, shouldRepairRestoredPendingToolPart = param.shouldRepairRestoredPendingToolPart, resolveCancelledToolOutput = param.resolveCancelledToolOutput;
17864
18015
  var _this1 = this;
17865
18016
  _class_call_check(this, AbstractChat);
17866
18017
  _define_property(this, "conversationId", void 0);
@@ -17873,11 +18024,13 @@
17873
18024
  _define_property(this, "onData", void 0);
17874
18025
  _define_property(this, "sendAutomaticallyWhen", void 0);
17875
18026
  _define_property(this, "shouldRepairToolInput", void 0);
18027
+ _define_property(this, "shouldRepairRestoredPendingToolPart", void 0);
17876
18028
  _define_property(this, "resolveCancelledToolOutput", void 0);
17877
18029
  _define_property(this, "activeResponse", null);
17878
18030
  _define_property(this, "latestResponse", null);
17879
18031
  _define_property(this, "responsesByToolCallId", new Map());
17880
18032
  _define_property(this, "responseByMessage", new WeakMap());
18033
+ _define_property(this, "restoredToolCalls", void 0);
17881
18034
  // Once tool ownership is discarded, an identifier-only result cannot prove
17882
18035
  // which response generation submitted it. Scoped submissions remain safe.
17883
18036
  _define_property(this, "acceptsIdentifierOnlyToolResults", true);
@@ -18045,7 +18198,7 @@
18045
18198
  warnInvalidGlobalToolResult(options.toolCallId);
18046
18199
  return Promise.resolve();
18047
18200
  }
18048
- if (!_this.commit(options.toolCallId, options.output, message.id, undefined, message)) {
18201
+ if (!_this.commit(options.toolCallId, getTerminalToolState(options), message.id, undefined, message)) {
18049
18202
  return Promise.resolve();
18050
18203
  }
18051
18204
  return _this.continueResponse();
@@ -18092,6 +18245,7 @@
18092
18245
  this.onData = onData;
18093
18246
  this.sendAutomaticallyWhen = sendAutomaticallyWhen;
18094
18247
  this.shouldRepairToolInput = shouldRepairToolInput;
18248
+ this.shouldRepairRestoredPendingToolPart = shouldRepairRestoredPendingToolPart;
18095
18249
  this.resolveCancelledToolOutput = resolveCancelledToolOutput;
18096
18250
  }
18097
18251
  _create_class(AbstractChat, [
@@ -18264,7 +18418,7 @@
18264
18418
  },
18265
18419
  {
18266
18420
  key: "commit",
18267
- value: function commit(toolCallId, output, messageId, response, expectedMessage) {
18421
+ value: function commit(toolCallId, terminalState, messageId, response, expectedMessage) {
18268
18422
  var isTargetPart = function isTargetPart(part) {
18269
18423
  return 'toolCallId' in part && part.toolCallId === toolCallId;
18270
18424
  };
@@ -18279,10 +18433,7 @@
18279
18433
  return false;
18280
18434
  }
18281
18435
  var updatedParts = _to_consumable_array(message.parts);
18282
- updatedParts[partIndex] = withTerminalToolState(part, {
18283
- state: 'output-available',
18284
- output: output
18285
- });
18436
+ updatedParts[partIndex] = withTerminalToolState(part, terminalState);
18286
18437
  var updatedMessage = _object_spread_props(_object_spread({}, message), {
18287
18438
  parts: updatedParts
18288
18439
  });
@@ -18290,6 +18441,60 @@
18290
18441
  return true;
18291
18442
  }
18292
18443
  },
18444
+ {
18445
+ key: "captureRestoredToolCalls",
18446
+ value: function captureRestoredToolCalls() {
18447
+ var restoredToolCalls = new Map();
18448
+ this.messages.forEach(function(message) {
18449
+ message.parts.forEach(function(part) {
18450
+ var _restoredToolCalls_get;
18451
+ if (!isPendingToolPart(part)) return;
18452
+ var toolCallIds = (_restoredToolCalls_get = restoredToolCalls.get(message.id)) !== null && _restoredToolCalls_get !== void 0 ? _restoredToolCalls_get : new Set();
18453
+ toolCallIds.add(part.toolCallId);
18454
+ restoredToolCalls.set(message.id, toolCallIds);
18455
+ });
18456
+ });
18457
+ this.restoredToolCalls = restoredToolCalls;
18458
+ }
18459
+ },
18460
+ {
18461
+ key: "clearRestoredToolCalls",
18462
+ value: function clearRestoredToolCalls() {
18463
+ this.restoredToolCalls = undefined;
18464
+ }
18465
+ },
18466
+ {
18467
+ key: "repairRestoredPendingToolParts",
18468
+ value: function repairRestoredPendingToolParts() {
18469
+ var _this = this;
18470
+ var shouldRepairRestoredPendingToolPart = this.shouldRepairRestoredPendingToolPart;
18471
+ if (!shouldRepairRestoredPendingToolPart) return;
18472
+ this.messages.forEach(function(message, messageIndex) {
18473
+ message.parts.forEach(function(part) {
18474
+ var _this_restoredToolCalls_get;
18475
+ if (!isPendingToolPart(part)) return;
18476
+ if (_this.restoredToolCalls && !((_this_restoredToolCalls_get = _this.restoredToolCalls.get(message.id)) === null || _this_restoredToolCalls_get === void 0 ? void 0 : _this_restoredToolCalls_get.has(part.toolCallId))) {
18477
+ return;
18478
+ }
18479
+ var shouldRepair = false;
18480
+ try {
18481
+ shouldRepair = shouldRepairRestoredPendingToolPart({
18482
+ toolName: getToolName(part),
18483
+ toolCallId: part.toolCallId,
18484
+ input: 'input' in part ? part.input : undefined
18485
+ });
18486
+ } catch (unused) {
18487
+ return;
18488
+ }
18489
+ if (!shouldRepair) return;
18490
+ _this.commit(part.toolCallId, {
18491
+ state: 'output-error',
18492
+ errorText: part.state === 'input-streaming' ? RESTORED_TOOL_INPUT_ERROR_TEXT : RESTORED_TOOL_CALL_ERROR_TEXT
18493
+ }, message.id, undefined, _this.messages[messageIndex]);
18494
+ });
18495
+ });
18496
+ }
18497
+ },
18293
18498
  {
18294
18499
  key: "getOutboundMessages",
18295
18500
  value: /**
@@ -18424,18 +18629,18 @@
18424
18629
  },
18425
18630
  {
18426
18631
  key: "submitToolResult",
18427
- value: function submitToolResult(response, param) {
18632
+ value: function submitToolResult(response, options) {
18428
18633
  var _this = this;
18429
- var toolCallId = param.toolCallId, output = param.output, messageId = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : response === null || response === void 0 ? void 0 : response.messageId, expectedMessage = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : messageId ? this.messages.find(function(message) {
18634
+ var messageId = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : response === null || response === void 0 ? void 0 : response.messageId, expectedMessage = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : messageId ? this.messages.find(function(message) {
18430
18635
  return message.id === messageId;
18431
18636
  }) : undefined;
18432
18637
  if (response === null || response === void 0 ? void 0 : response.isRetired) return Promise.resolve();
18433
18638
  var commitResult = function commitResult() {
18434
- if (!_this.commit(toolCallId, output, messageId, response, expectedMessage)) {
18639
+ if (!_this.commit(options.toolCallId, getTerminalToolState(options), messageId, response, expectedMessage)) {
18435
18640
  return Promise.resolve();
18436
18641
  }
18437
- if (response === null || response === void 0 ? void 0 : response.requiredToolCallIds.has(toolCallId)) {
18438
- response.resolvedToolCallIds.add(toolCallId);
18642
+ if (response === null || response === void 0 ? void 0 : response.requiredToolCallIds.has(options.toolCallId)) {
18643
+ response.resolvedToolCallIds.add(options.toolCallId);
18439
18644
  }
18440
18645
  return _this.continueResponse(response);
18441
18646
  };
@@ -18819,13 +19024,16 @@
18819
19024
  _this.responsesByToolCallId.set(chunk.toolCallId, owners);
18820
19025
  response.pendingToolCallbacks++;
18821
19026
  try {
19027
+ var _this_restoredToolCalls_get, _this_restoredToolCalls;
19028
+ (_this_restoredToolCalls = _this.restoredToolCalls) === null || _this_restoredToolCalls === void 0 ? void 0 : (_this_restoredToolCalls_get = _this_restoredToolCalls.get(currentMessage.id)) === null || _this_restoredToolCalls_get === void 0 ? void 0 : _this_restoredToolCalls_get.delete(chunk.toolCallId);
18822
19029
  var result = _this.onToolCall({
18823
19030
  toolCall: {
18824
19031
  toolName: chunk.toolName,
18825
19032
  toolCallId: chunk.toolCallId,
18826
19033
  input: chunk.input,
18827
19034
  dynamic: 'dynamic' in chunk ? chunk.dynamic : undefined
18828
- }
19035
+ },
19036
+ signal: response.abortController.signal
18829
19037
  }, function(options) {
18830
19038
  return response.isRetired ? Promise.resolve() : _this.submitToolResult(response, options);
18831
19039
  });
@@ -19145,7 +19353,7 @@
19145
19353
  return AbstractChat;
19146
19354
  }();
19147
19355
 
19148
- var _computedKey, _computedKey1, _computedKey2, _computedKey3, _computedKey4, _computedKey5;
19356
+ var _computedKey, _computedKey1, _computedKey2, _computedKey3, _computedKey4, _computedKey5, _computedKey6, _computedKey7;
19149
19357
  var CACHE_KEY = 'instantsearch-chat-initial-messages';
19150
19358
  // Message history is a browser concern, and a server render constructs a Chat
19151
19359
  // too. Reading storage there throws during rendering; the write below only
@@ -19167,8 +19375,8 @@
19167
19375
  }
19168
19376
  });
19169
19377
  }
19170
- _computedKey = '~registerMessagesCallback', _computedKey1 = '~registerStatusCallback', _computedKey2 = '~registerErrorCallback';
19171
- var _computedKey6 = _computedKey, _computedKey7 = _computedKey1, _computedKey8 = _computedKey2;
19378
+ _computedKey = '~persistMessages', _computedKey1 = '~registerMessagesCallback', _computedKey2 = '~registerStatusCallback', _computedKey3 = '~registerErrorCallback';
19379
+ var _computedKey8 = _computedKey, _computedKey9 = _computedKey1, _computedKey10 = _computedKey2, _computedKey11 = _computedKey3;
19172
19380
  var ChatState = /*#__PURE__*/ function() {
19173
19381
  function ChatState() {
19174
19382
  var _this = this;
@@ -19180,6 +19388,7 @@
19180
19388
  _define_property(this, "_messagesCallbacks", new Set());
19181
19389
  _define_property(this, "_statusCallbacks", new Set());
19182
19390
  _define_property(this, "_errorCallbacks", new Set());
19391
+ _define_property(this, "persistenceKey", void 0);
19183
19392
  _define_property(this, "pushMessage", function(message) {
19184
19393
  _this._messages = _this._messages.concat(message);
19185
19394
  _this._callMessagesCallbacks();
@@ -19198,20 +19407,31 @@
19198
19407
  _define_property(this, "snapshot", function(thing) {
19199
19408
  return JSON.parse(JSON.stringify(thing));
19200
19409
  });
19201
- _define_property(this, _computedKey6, function(onChange) {
19410
+ _define_property(this, _computedKey8, function() {
19411
+ var persistenceKey = _this.persistenceKey;
19412
+ if (!persistenceKey) return;
19413
+ safelyRunOnBrowser(function() {
19414
+ try {
19415
+ sessionStorage.setItem(persistenceKey, JSON.stringify(_this.messages));
19416
+ } catch (e) {
19417
+ // Do nothing if sessionStorage is not available or full
19418
+ }
19419
+ });
19420
+ });
19421
+ _define_property(this, _computedKey9, function(onChange) {
19202
19422
  var callback = onChange;
19203
19423
  _this._messagesCallbacks.add(callback);
19204
19424
  return function() {
19205
19425
  _this._messagesCallbacks.delete(callback);
19206
19426
  };
19207
19427
  });
19208
- _define_property(this, _computedKey7, function(onChange) {
19428
+ _define_property(this, _computedKey10, function(onChange) {
19209
19429
  _this._statusCallbacks.add(onChange);
19210
19430
  return function() {
19211
19431
  _this._statusCallbacks.delete(onChange);
19212
19432
  };
19213
19433
  });
19214
- _define_property(this, _computedKey8, function(onChange) {
19434
+ _define_property(this, _computedKey11, function(onChange) {
19215
19435
  _this._errorCallbacks.add(onChange);
19216
19436
  return function() {
19217
19437
  _this._errorCallbacks.delete(onChange);
@@ -19242,19 +19462,14 @@
19242
19462
  if (!persistence) {
19243
19463
  return;
19244
19464
  }
19245
- var saveMessagesInLocalStorage = function saveMessagesInLocalStorage() {
19465
+ this.persistenceKey = CACHE_KEY + (id ? "-".concat(id) : '');
19466
+ var saveMessagesInSessionStorage = function saveMessagesInSessionStorage() {
19246
19467
  if (_this.status === 'ready') {
19247
- safelyRunOnBrowser(function() {
19248
- try {
19249
- sessionStorage.setItem(CACHE_KEY + (id ? "-".concat(id) : ''), JSON.stringify(_this.messages));
19250
- } catch (e) {
19251
- // Do nothing if sessionStorage is not available or full
19252
- }
19253
- });
19468
+ _this['~persistMessages']();
19254
19469
  }
19255
19470
  };
19256
- this['~registerMessagesCallback'](saveMessagesInLocalStorage);
19257
- this['~registerStatusCallback'](saveMessagesInLocalStorage);
19471
+ this['~registerMessagesCallback'](saveMessagesInSessionStorage);
19472
+ this['~registerStatusCallback'](saveMessagesInSessionStorage);
19258
19473
  }
19259
19474
  _create_class(ChatState, [
19260
19475
  {
@@ -19290,8 +19505,8 @@
19290
19505
  ]);
19291
19506
  return ChatState;
19292
19507
  }();
19293
- _computedKey3 = '~registerMessagesCallback', _computedKey4 = '~registerStatusCallback', _computedKey5 = '~registerErrorCallback';
19294
- var _computedKey9 = _computedKey3, _computedKey10 = _computedKey4, _computedKey11 = _computedKey5;
19508
+ _computedKey4 = '~repairRestoredPendingToolParts', _computedKey5 = '~registerMessagesCallback', _computedKey6 = '~registerStatusCallback', _computedKey7 = '~registerErrorCallback';
19509
+ var _computedKey12 = _computedKey4, _computedKey13 = _computedKey5, _computedKey14 = _computedKey6, _computedKey15 = _computedKey7;
19295
19510
  var Chat$1 = /*#__PURE__*/ function(AbstractChat) {
19296
19511
  _inherits(Chat, AbstractChat);
19297
19512
  function Chat(_0) {
@@ -19307,14 +19522,25 @@
19307
19522
  _object_spread_props(_object_spread({}, init), {
19308
19523
  state: state
19309
19524
  })
19310
- ]), _define_property(_this, "_state", void 0), _define_property(_this, _computedKey9, function(onChange) {
19525
+ ]), _define_property(_this, "_state", void 0), _define_property(_this, "hasRestoredMessages", false), _define_property(_this, _computedKey12, function() {
19526
+ if (!_this.hasRestoredMessages) return;
19527
+ _this.hasRestoredMessages = false;
19528
+ _this.repairRestoredPendingToolParts();
19529
+ _this.clearRestoredToolCalls();
19530
+ _this._state['~persistMessages']();
19531
+ }), _define_property(_this, _computedKey13, function(onChange) {
19311
19532
  return _this._state['~registerMessagesCallback'](onChange);
19312
- }), _define_property(_this, _computedKey10, function(onChange) {
19533
+ }), _define_property(_this, _computedKey14, function(onChange) {
19313
19534
  return _this._state['~registerStatusCallback'](onChange);
19314
- }), _define_property(_this, _computedKey11, function(onChange) {
19535
+ }), _define_property(_this, _computedKey15, function(onChange) {
19315
19536
  return _this._state['~registerErrorCallback'](onChange);
19316
19537
  });
19317
19538
  _this._state = state;
19539
+ if (messages === undefined && persistence) {
19540
+ _this.hasRestoredMessages = true;
19541
+ _this.captureRestoredToolCalls();
19542
+ _this.repairRestoredPendingToolParts();
19543
+ }
19318
19544
  return _this;
19319
19545
  }
19320
19546
  return Chat;
@@ -19577,6 +19803,9 @@
19577
19803
  name: 'chat',
19578
19804
  connector: true
19579
19805
  });
19806
+ var DEFAULT_TOOL_TIMEOUT = 20000;
19807
+ var TOOL_TIMEOUT_ERROR_TEXT = 'The tool call timed out before a result was received. The operation may have completed.';
19808
+ var TOOL_ABORTED_ERROR_TEXT = 'The tool call was cancelled before a result was received.';
19580
19809
  var OPEN_STATE_CACHE_KEY = 'instantsearch-chat-open-state';
19581
19810
  function normalizePersistence(persistence, hasCustomChat) {
19582
19811
  if (hasCustomChat) {
@@ -19924,7 +20153,8 @@
19924
20153
  if (!transport) {
19925
20154
  throw new Error(withUsage$q('You need to provide either an `agentId` or a `transport`.'));
19926
20155
  }
19927
- return new Chat$1(_object_spread_props(_object_spread({}, options), {
20156
+ var canRepairRestoredPendingToolParts = !resume;
20157
+ var chat = new Chat$1(_object_spread_props(_object_spread({}, options), {
19928
20158
  persistence: normalizedPersistence.messages,
19929
20159
  sendAutomaticallyWhen: sendAutomaticallyWhen,
19930
20160
  transport: transport,
@@ -19933,6 +20163,11 @@
19933
20163
  if (!tool) return true;
19934
20164
  return Boolean(tool.streamInput);
19935
20165
  },
20166
+ shouldRepairRestoredPendingToolPart: function shouldRepairRestoredPendingToolPart(param) {
20167
+ var toolName = param.toolName;
20168
+ var tool = findTool(toolName, tools);
20169
+ return Boolean(canRepairRestoredPendingToolParts && (tool === null || tool === void 0 ? void 0 : tool.onToolCall) && tool.timeout !== false);
20170
+ },
19936
20171
  resolveCancelledToolOutput: function resolveCancelledToolOutput(param) {
19937
20172
  var toolName = param.toolName, toolCallId = param.toolCallId, input = param.input;
19938
20173
  var _findTool;
@@ -19952,7 +20187,7 @@
19952
20187
  }
19953
20188
  },
19954
20189
  onToolCall: function onToolCall(param, submitToolResult) {
19955
- var toolCall = param.toolCall;
20190
+ var toolCall = param.toolCall, signal = param.signal;
19956
20191
  var tool = findTool(toolCall.toolName, tools);
19957
20192
  if (!tool) {
19958
20193
  return submitToolResult({
@@ -19962,21 +20197,103 @@
19962
20197
  });
19963
20198
  }
19964
20199
  if (tool.onToolCall) {
19965
- var addToolResult = function addToolResult(param) {
19966
- var output = param.output;
19967
- return submitToolResult({
19968
- output: output,
20200
+ var toolAbortController = new AbortController();
20201
+ var timeoutId;
20202
+ var settled = false;
20203
+ var resolveExecution;
20204
+ var rejectExecution;
20205
+ var execution = new Promise(function(resolve, reject) {
20206
+ resolveExecution = resolve;
20207
+ rejectExecution = reject;
20208
+ });
20209
+ var cleanup = function cleanup() {
20210
+ if (timeoutId !== undefined) {
20211
+ clearTimeout(timeoutId);
20212
+ }
20213
+ signal.removeEventListener('abort', abortToolCall);
20214
+ };
20215
+ var addToolResult = function addToolResult(options) {
20216
+ if (settled) return Promise.resolve();
20217
+ settled = true;
20218
+ cleanup();
20219
+ var submission = submitToolResult(_object_spread_props(_object_spread({}, options), {
19969
20220
  tool: toolCall.toolName,
19970
20221
  toolCallId: toolCall.toolCallId
20222
+ }));
20223
+ submission.then(resolveExecution, rejectExecution);
20224
+ return submission;
20225
+ };
20226
+ var addToolError = function addToolError(error) {
20227
+ var errorText = _instanceof(error, Error) ? error.message : String(error !== null && error !== void 0 ? error : '');
20228
+ return addToolResult({
20229
+ state: 'output-error',
20230
+ errorText: errorText || 'Tool call failed.'
19971
20231
  });
19972
20232
  };
19973
- return tool.onToolCall(_object_spread_props(_object_spread({}, toolCall), {
19974
- addToolResult: addToolResult
19975
- }));
20233
+ function abortToolCall() {
20234
+ var submission = addToolResult({
20235
+ state: 'output-error',
20236
+ errorText: TOOL_ABORTED_ERROR_TEXT
20237
+ });
20238
+ toolAbortController.abort();
20239
+ void submission.catch(function() {
20240
+ return undefined;
20241
+ });
20242
+ }
20243
+ if (signal.aborted) {
20244
+ abortToolCall();
20245
+ return execution;
20246
+ }
20247
+ signal.addEventListener('abort', abortToolCall, {
20248
+ once: true
20249
+ });
20250
+ if (tool.timeout !== false) {
20251
+ var _tool_timeout;
20252
+ timeoutId = setTimeout(function() {
20253
+ var submission = addToolResult({
20254
+ state: 'output-error',
20255
+ errorText: TOOL_TIMEOUT_ERROR_TEXT
20256
+ });
20257
+ toolAbortController.abort();
20258
+ void submission.catch(function() {
20259
+ return undefined;
20260
+ });
20261
+ }, (_tool_timeout = tool.timeout) !== null && _tool_timeout !== void 0 ? _tool_timeout : DEFAULT_TOOL_TIMEOUT);
20262
+ }
20263
+ var toolExecution;
20264
+ try {
20265
+ toolExecution = tool.onToolCall(_object_spread_props(_object_spread({}, toolCall), {
20266
+ addToolResult: addToolResult,
20267
+ signal: toolAbortController.signal
20268
+ }));
20269
+ } catch (error) {
20270
+ return addToolError(error);
20271
+ }
20272
+ var returnedExecution = Promise.resolve(toolExecution).catch(addToolError);
20273
+ if (tool.timeout === false) {
20274
+ return Promise.race([
20275
+ returnedExecution.then(cleanup),
20276
+ execution
20277
+ ]);
20278
+ }
20279
+ void returnedExecution.catch(function() {
20280
+ return undefined;
20281
+ });
20282
+ return execution;
19976
20283
  }
19977
20284
  return Promise.resolve();
19978
20285
  }
19979
20286
  }));
20287
+ if (resume) {
20288
+ var resumeStream = chat.resumeStream;
20289
+ chat.resumeStream = function(requestOptions) {
20290
+ return resumeStream(requestOptions).finally(function() {
20291
+ canRepairRestoredPendingToolParts = true;
20292
+ chat['~repairRestoredPendingToolParts']();
20293
+ });
20294
+ };
20295
+ }
20296
+ return chat;
19980
20297
  };
19981
20298
  return {
19982
20299
  $$type: 'ais.chat',
@@ -20777,8 +21094,35 @@
20777
21094
  return typeof s === 'string';
20778
21095
  });
20779
21096
  }
20780
- function buildSuggestionMessage(suggestion) {
20781
- return "The user clicked this on-page suggestion. Use the current page context first, then search only if needed.\n\nSuggestion: ".concat(suggestion);
21097
+ // Key order is not significant to the request, so a plain `JSON.stringify` would
21098
+ // report two identical payloads as different.
21099
+ function stableKey(value) {
21100
+ if (value === null || (typeof value === "undefined" ? "undefined" : _type_of(value)) !== 'object') {
21101
+ var _JSON_stringify;
21102
+ return (_JSON_stringify = JSON.stringify(value)) !== null && _JSON_stringify !== void 0 ? _JSON_stringify : 'null';
21103
+ }
21104
+ if (Array.isArray(value)) {
21105
+ return "[".concat(value.map(stableKey).join(','), "]");
21106
+ }
21107
+ var record = value;
21108
+ return "{".concat(Object.keys(record).sort().map(function(key) {
21109
+ return "".concat(JSON.stringify(key), ":").concat(stableKey(record[key]));
21110
+ }).join(','), "}");
21111
+ }
21112
+ /**
21113
+ * Comparable identity of a task payload, or `null` when it cannot be compared.
21114
+ */ function taskPayloadKey(payload) {
21115
+ try {
21116
+ // Round-trip first so the comparison sees what the request will actually
21117
+ // carry: `JSON.stringify` applies `toJSON` (a `Date` becomes its ISO string)
21118
+ // and drops the values the wire drops. Walking the raw object instead would
21119
+ // read a `Date` as a key-less object and call two different instants equal.
21120
+ return stableKey(JSON.parse(JSON.stringify(payload)));
21121
+ } catch (unused) {
21122
+ // Circular or otherwise unserializable. Never claim a match on a payload we
21123
+ // could not read; let the request go out and fail where it does today.
21124
+ return null;
21125
+ }
20782
21126
  }
20783
21127
  function stripInternalHitMetadata(hit) {
20784
21128
  var clean = {};
@@ -20844,16 +21188,27 @@
20844
21188
  var error;
20845
21189
  var debounceTimer;
20846
21190
  var lastStateSignature = null;
21191
+ // The payload of the last request that was actually sent. The automatic
21192
+ // trigger keys on the search state, which is only a proxy for the payload,
21193
+ // so this is what decides whether a request would ask anything new.
21194
+ var lastSubmittedPayload = null;
20847
21195
  var latestRenderOptions = null;
20848
21196
  // Set in `dispose()`. A debounced or in-flight `fetch()` can resolve after
20849
21197
  // the widget is unmounted; this guard stops those late callbacks from
20850
21198
  // calling `renderFn` into a torn-down container.
20851
21199
  var disposed = false;
21200
+ // Whether the "is a chat widget mounted on this index?" question has been
21201
+ // settled — see `validateChat`.
21202
+ var hasValidatedChat = false;
20852
21203
  // True between a state-signature change and the debounced refetch that
20853
21204
  // follows it. While pending, the search state has already moved on, so a
20854
21205
  // still-in-flight request from the previous state must not paint its
20855
21206
  // suggestions, its inner render is ignored until the new `submit` starts.
20856
21207
  var refetchPending = false;
21208
+ // True when `refetchPending` made an inner render be dropped. The fetch
21209
+ // that dropped it was expected to render in its place; if that fetch turns
21210
+ // out to send nothing, it has to reconcile the dropped state instead.
21211
+ var droppedInnerRender = false;
20857
21212
  var getStateSignature = function getStateSignature(results) {
20858
21213
  var _buildFilters;
20859
21214
  if (results.queryID) {
@@ -20877,21 +21232,26 @@
20877
21232
  };
20878
21233
  var sendToChat = function sendToChat(renderOptions) {
20879
21234
  return function(prompt) {
20880
- var _ref, _ref1;
21235
+ var _ref, _getLatestResults;
20881
21236
  var chatRenderState = getChatRenderState(renderOptions);
20882
21237
  if (!chatRenderState || !chatRenderState.sendMessage) {
20883
21238
  return false;
20884
21239
  }
20885
- var results = (_ref = (_ref1 = latestRenderOptions === null || latestRenderOptions === void 0 ? void 0 : latestRenderOptions.results) !== null && _ref1 !== void 0 ? _ref1 : 'results' in renderOptions ? renderOptions.results : null) !== null && _ref !== void 0 ? _ref : null;
21240
+ var results = (_ref = (_getLatestResults = getLatestResults()) !== null && _getLatestResults !== void 0 ? _getLatestResults : 'results' in renderOptions ? renderOptions.results : null) !== null && _ref !== void 0 ? _ref : null;
20886
21241
  return openChat(chatRenderState, {
20887
- message: buildSuggestionMessage(prompt),
21242
+ message: prompt,
20888
21243
  referer: 'prompt-suggestions-widget',
20889
21244
  turnContext: buildTurnContext(results)
20890
21245
  });
20891
21246
  };
20892
21247
  };
20893
- var resolvePageContext = function resolvePageContext(results) {
20894
- var resolvedContext = typeof context === 'function' ? context() : context;
21248
+ // `context` may be a function, so the option alone says nothing about what
21249
+ // a given fetch actually has to send. Resolve it once per fetch and let
21250
+ // callers read the value rather than the option.
21251
+ var resolveContext = function resolveContext() {
21252
+ return typeof context === 'function' ? context() : context;
21253
+ };
21254
+ var buildPageContext = function buildPageContext(resolvedContext, results) {
20895
21255
  // Explicit context replaces auto-extraction; otherwise derive it from
20896
21256
  // the current search state. The task's server-owned instructions decide
20897
21257
  // how to interpret the shape — the client doesn't label it.
@@ -20910,15 +21270,11 @@
20910
21270
  hitsSample: transformHits(results.hits)
20911
21271
  });
20912
21272
  };
20913
- var buildInput = function buildInput(results) {
20914
- var _resolvePageContext;
20915
- return (_resolvePageContext = resolvePageContext(results)) !== null && _resolvePageContext !== void 0 ? _resolvePageContext : {};
20916
- };
20917
21273
  // The same page context, flattened for the chat handoff: `turnContext` is
20918
21274
  // a flat `Record<string, string>` per the Agent Studio contract, so
20919
21275
  // non-string values (e.g. `hitsSample`) are serialized.
20920
21276
  var buildTurnContext = function buildTurnContext(results) {
20921
- var pageContext = resolvePageContext(results);
21277
+ var pageContext = buildPageContext(resolveContext(), results);
20922
21278
  if (!pageContext) {
20923
21279
  return undefined;
20924
21280
  }
@@ -20934,33 +21290,98 @@
20934
21290
  });
20935
21291
  return entries.length > 0 ? Object.fromEntries(entries) : undefined;
20936
21292
  };
21293
+ // `latestRenderOptions` may be the `init()` options, which carry no
21294
+ // `results` key at all, so the read has to be narrowed rather than
21295
+ // optional-chained.
21296
+ var getLatestResults = function getLatestResults() {
21297
+ var _latestRenderOptions_results;
21298
+ if (!latestRenderOptions || !('results' in latestRenderOptions)) {
21299
+ return null;
21300
+ }
21301
+ return (_latestRenderOptions_results = latestRenderOptions.results) !== null && _latestRenderOptions_results !== void 0 ? _latestRenderOptions_results : null;
21302
+ };
20937
21303
  var renderOutward = function renderOutward(renderOptions) {
20938
21304
  if (disposed) return;
20939
21305
  renderFn(_object_spread_props(_object_spread({}, getWidgetRenderState(renderOptions)), {
20940
21306
  instantSearchInstance: renderOptions.instantSearchInstance
20941
21307
  }), false);
20942
21308
  };
21309
+ // Copies an inner render's state into this widget's and re-renders on the
21310
+ // client.
21311
+ var adoptInnerState = function adoptInnerState(renderState) {
21312
+ error = renderState.error;
21313
+ if (renderState.error) {
21314
+ // A failed task (including a mid-stream `error` event) must not leave
21315
+ // any streamed partial visible.
21316
+ suggestions = [];
21317
+ } else if (renderState.isLoading || renderState.output !== undefined) {
21318
+ // Only adopt the inner output once a request is loading or has
21319
+ // produced one, so the initial no-op render doesn't clobber pills.
21320
+ suggestions = parseSuggestions(renderState.output);
21321
+ }
21322
+ isLoading = renderState.isLoading;
21323
+ if (!latestRenderOptions) return;
21324
+ renderOutward(latestRenderOptions);
21325
+ };
20943
21326
  var fetchAndRender = function fetchAndRender(results, renderOptions) {
21327
+ var _ref = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, _ref_force = _ref.force, force = _ref_force === void 0 ? false : _ref_force;
21328
+ var _buildPageContext;
20944
21329
  var _results_hits;
20945
21330
  if (disposed || !tasksState) return;
21331
+ var hadDroppedInnerRender = droppedInnerRender;
20946
21332
  refetchPending = false;
20947
- var hasContext = context !== undefined;
20948
- if (!hasContext && !(results === null || results === void 0 ? void 0 : (_results_hits = results.hits) === null || _results_hits === void 0 ? void 0 : _results_hits.length)) {
21333
+ droppedInnerRender = false;
21334
+ var resolvedContext = resolveContext();
21335
+ var input = (_buildPageContext = buildPageContext(resolvedContext, results)) !== null && _buildPageContext !== void 0 ? _buildPageContext : {};
21336
+ // Two ways there is nothing worth sending: no context for this fetch and
21337
+ // no hits to derive one from, or a context that resolved to something
21338
+ // empty. The first reads the resolved value rather than the option, so
21339
+ // `context: () => undefined` is gated exactly like an omitted `context`.
21340
+ // Sending an empty input spends a model call on no information.
21341
+ if (resolvedContext === undefined && !(results === null || results === void 0 ? void 0 : (_results_hits = results.hits) === null || _results_hits === void 0 ? void 0 : _results_hits.length) || Object.keys(input).length === 0) {
20949
21342
  tasksState.invalidate();
20950
21343
  suggestions = [];
20951
21344
  isLoading = false;
21345
+ // The output is gone, so the same payload must be allowed to rebuild it.
21346
+ lastSubmittedPayload = null;
20952
21347
  renderOutward(renderOptions);
20953
21348
  return;
20954
21349
  }
20955
- tasksState.submit(buildInput(results));
21350
+ var payload = taskPayloadKey(input);
21351
+ // A moved search state does not always mean a different question: with an
21352
+ // explicit `context` the payload ignores the results entirely, so a new
21353
+ // `queryID` or a new hit order produces a byte-identical request. Sending
21354
+ // it again spends a model call on an answer already on screen. Leave the
21355
+ // current suggestions alone and send nothing. `force` is the explicit
21356
+ // path (`refresh()`), which must always reach the network.
21357
+ if (!force && payload !== null && payload === lastSubmittedPayload) {
21358
+ // Nothing goes out, so nothing will render — but the state change that
21359
+ // scheduled this fetch also made `handleInnerRender` drop the render
21360
+ // that was carrying the previous request's result. Reconcile it here or
21361
+ // the widget keeps that request's `isLoading: true` with no
21362
+ // suggestions, and nothing later clears it: `refresh()` is blocked by
21363
+ // its own `isLoading` guard and an unchanged payload keeps skipping.
21364
+ if (hadDroppedInnerRender) {
21365
+ adoptInnerState(tasksState);
21366
+ }
21367
+ return;
21368
+ }
21369
+ lastSubmittedPayload = payload;
21370
+ tasksState.submit(input);
20956
21371
  };
20957
21372
  var refresh = function refresh() {
20958
21373
  if (isLoading) return;
20959
- var results = latestRenderOptions === null || latestRenderOptions === void 0 ? void 0 : latestRenderOptions.results;
20960
- if (!results || !latestRenderOptions) return;
21374
+ if (!latestRenderOptions) return;
21375
+ var results = getLatestResults();
20961
21376
  clearTimeout(debounceTimer);
20962
- lastStateSignature = getStateSignature(results);
20963
- fetchAndRender(results, latestRenderOptions);
21377
+ // Only meaningful with results: without them there is no signature for a
21378
+ // later automatic fetch to compare against.
21379
+ if (results) {
21380
+ lastStateSignature = getStateSignature(results);
21381
+ }
21382
+ fetchAndRender(results, latestRenderOptions, {
21383
+ force: true
21384
+ });
20964
21385
  };
20965
21386
  var getWidgetRenderState = function getWidgetRenderState(renderOptions) {
20966
21387
  var results = 'results' in renderOptions ? renderOptions.results : undefined;
@@ -20971,12 +21392,17 @@
20971
21392
  var chatRenderState = getChatRenderState(renderOptions);
20972
21393
  var isChatBusy$1 = chatRenderState ? !chatRenderState.sendMessage || isChatBusy(chatRenderState) : false;
20973
21394
  var send = sendToChat(renderOptions);
21395
+ // `sendToChat` is withheld only once the mount window has closed: a chat
21396
+ // widget further down a React tree is added after this widget's `init`,
21397
+ // so until `validateChat` runs its absence is not yet conclusive and
21398
+ // withholding the handler would make a valid setup look broken.
21399
+ var canSendToChat = Boolean(chatRenderState === null || chatRenderState === void 0 ? void 0 : chatRenderState.sendMessage) || !hasValidatedChat;
20974
21400
  return {
20975
21401
  suggestions: transformed,
20976
21402
  isLoading: isLoading,
20977
21403
  error: error,
20978
- onSuggestionClick: send,
20979
- sendToChat: send,
21404
+ onSuggestionClick: canSendToChat ? send : noop,
21405
+ sendToChat: canSendToChat ? send : undefined,
20980
21406
  refresh: refresh,
20981
21407
  isChatBusy: isChatBusy$1,
20982
21408
  widgetParams: widgetParams
@@ -20986,21 +21412,37 @@
20986
21412
  // resolve/error) into this widget's state and re-renders on the client.
20987
21413
  var handleInnerRender = function handleInnerRender(renderState) {
20988
21414
  tasksState = renderState;
20989
- if (refetchPending) return;
20990
- error = renderState.error;
20991
21415
  if (renderState.error) {
20992
- // A failed task (including a mid-stream `error` event) must not leave
20993
- // any streamed partial visible.
20994
- suggestions = [];
20995
- } else if (renderState.isLoading || renderState.output !== undefined) {
20996
- // Only adopt the inner output once a request is loading or has
20997
- // produced one, so the initial no-op render doesn't clobber pills.
20998
- suggestions = parseSuggestions(renderState.output);
21416
+ // Keep a failed payload retryable: without this the next automatic
21417
+ // attempt with the same payload would be skipped as a duplicate and
21418
+ // the error would have no way to clear. Set before the `refetchPending`
21419
+ // return so a failure that lands mid-refetch is not swallowed.
21420
+ lastSubmittedPayload = null;
21421
+ }
21422
+ if (refetchPending) {
21423
+ droppedInnerRender = true;
21424
+ return;
20999
21425
  }
21000
- isLoading = renderState.isLoading;
21001
- if (!latestRenderOptions) return;
21002
- renderOutward(latestRenderOptions);
21426
+ adoptInnerState(renderState);
21003
21427
  };
21428
+ // Deferred because a chat widget can be registered after this one: React
21429
+ // adds widgets in mount order, so a `chat` further down the tree only
21430
+ // lands after this widget's `init` has run. Until this closes the window,
21431
+ // `sendToChat` is handed out optimistically.
21432
+ var validateChat = defer(function(renderOptions) {
21433
+ var _getChatRenderState;
21434
+ if (hasValidatedChat) return;
21435
+ hasValidatedChat = true;
21436
+ if ((_getChatRenderState = getChatRenderState(renderOptions)) === null || _getChatRenderState === void 0 ? void 0 : _getChatRenderState.sendMessage) return;
21437
+ // A render may already have gone out with the optimistic `sendToChat`;
21438
+ // re-render so the widget layer sees the settled answer. The `init()`
21439
+ // options don't count: nothing has painted yet, so the next render
21440
+ // carries it — and a mount that never renders results shows no pills
21441
+ // to mislead anyone.
21442
+ if (latestRenderOptions && 'results' in latestRenderOptions) {
21443
+ renderOutward(latestRenderOptions);
21444
+ }
21445
+ });
21004
21446
  var tasksParams;
21005
21447
  if (agentId) {
21006
21448
  tasksParams = {
@@ -21023,12 +21465,37 @@
21023
21465
  var tasksWidget = connectTasks(handleInnerRender, noop)(tasksParams);
21024
21466
  return {
21025
21467
  $$type: 'ais.promptSuggestions',
21468
+ // Clicking a suggestion opens the chat, so this widget counts as an
21469
+ // entry point for `connectChat`'s trigger validation.
21470
+ opensChat: true,
21026
21471
  init: function init(initOptions) {
21027
21472
  var instantSearchInstance = initOptions.instantSearchInstance;
21028
21473
  tasksWidget.init(initOptions);
21474
+ // Set after the inner init so its initial no-op render is still
21475
+ // ignored, and before the first outward render so `refresh()` has a
21476
+ // render target even on a mount where `render()` never sees results.
21477
+ latestRenderOptions = initOptions;
21478
+ validateChat(initOptions);
21029
21479
  renderFn(_object_spread_props(_object_spread({}, getWidgetRenderState(initOptions)), {
21030
21480
  instantSearchInstance: instantSearchInstance
21031
21481
  }), true);
21482
+ // With an explicit `context` the payload never reads the results, so
21483
+ // waiting for a search is waiting on something the request does not
21484
+ // use — and a page that triggers no search (a `searchFunction` query
21485
+ // gate, or a mount made only for the widgets) would wait forever.
21486
+ // Fetch here instead, after the first render so the `isFirstRender`
21487
+ // one still arrives first.
21488
+ //
21489
+ // There are no results yet by definition, so "is there anything to
21490
+ // send" reduces to "did the context resolve to something". Checking it
21491
+ // here rather than letting `fetchAndRender` reject the call keeps init
21492
+ // out of the "nothing to send" branch, whose `invalidate()` would add
21493
+ // two outward renders to every mount that has no context — leaving the
21494
+ // auto-extracted path, the one that does need results, untouched.
21495
+ var initialContext = resolveContext();
21496
+ if (initialContext && Object.keys(initialContext).length > 0) {
21497
+ fetchAndRender(null, initOptions);
21498
+ }
21032
21499
  },
21033
21500
  render: function render(renderOptions) {
21034
21501
  var results = renderOptions.results, instantSearchInstance = renderOptions.instantSearchInstance;
@@ -21046,8 +21513,9 @@
21046
21513
  error = undefined;
21047
21514
  clearTimeout(debounceTimer);
21048
21515
  debounceTimer = setTimeout(function() {
21049
- if (latestRenderOptions === null || latestRenderOptions === void 0 ? void 0 : latestRenderOptions.results) {
21050
- fetchAndRender(latestRenderOptions.results, latestRenderOptions);
21516
+ var latestResults = getLatestResults();
21517
+ if (latestResults && latestRenderOptions) {
21518
+ fetchAndRender(latestResults, latestRenderOptions);
21051
21519
  }
21052
21520
  }, DEBOUNCE_MS);
21053
21521
  }
@@ -21058,6 +21526,7 @@
21058
21526
  dispose: function dispose(disposeOptions) {
21059
21527
  disposed = true;
21060
21528
  clearTimeout(debounceTimer);
21529
+ validateChat.cancel();
21061
21530
  tasksWidget.dispose(disposeOptions);
21062
21531
  unmountFn();
21063
21532
  },
@@ -26743,7 +27212,7 @@
26743
27212
  var _ref = [
26744
27213
  _0,
26745
27214
  _1
26746
- ], _ref1 = _to_array(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent, loaderComponent = _ref2.loaderComponent, loaderPosition = _ref2.loaderPosition, shouldShowLoader = _ref2.shouldShowLoader, loaderShowDelay = _ref2.loaderShowDelay, loaderMinDuration = _ref2.loaderMinDuration, messagesErrorComponent = _ref2.messagesErrorComponent, promptComponent = _ref2.promptComponent, promptHeaderComponent = _ref2.promptHeaderComponent, promptFooterComponent = _ref2.promptFooterComponent, assistantMessageLeadingComponent = _ref2.assistantMessageLeadingComponent, assistantMessageFooterComponent = _ref2.assistantMessageFooterComponent, userMessageLeadingComponent = _ref2.userMessageLeadingComponent, userMessageFooterComponent = _ref2.userMessageFooterComponent, emptyComponent = _ref2.emptyComponent, actionsComponent = _ref2.actionsComponent, suggestionsComponent = _ref2.suggestionsComponent, classNames = _ref2.classNames, _ref_translations = _ref2.translations, translations = _ref_translations === void 0 ? {} : _ref_translations, title = _ref2.title, getSearchPageURL = _ref2.getSearchPageURL, _ref_disableTriggerValidation = _ref2.disableTriggerValidation, disableTriggerValidation = _ref_disableTriggerValidation === void 0 ? false : _ref_disableTriggerValidation, showReasoning = _ref2.showReasoning, props = _object_without_properties(_ref2, [
27215
+ ], _ref1 = _to_array(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent, loaderComponent = _ref2.loaderComponent, loaderPosition = _ref2.loaderPosition, shouldShowLoader = _ref2.shouldShowLoader, loaderShowDelay = _ref2.loaderShowDelay, loaderMinDuration = _ref2.loaderMinDuration, messagesErrorComponent = _ref2.messagesErrorComponent, promptComponent = _ref2.promptComponent, promptHeaderComponent = _ref2.promptHeaderComponent, promptFooterComponent = _ref2.promptFooterComponent, assistantMessageLeadingComponent = _ref2.assistantMessageLeadingComponent, assistantMessageFooterComponent = _ref2.assistantMessageFooterComponent, userMessageLeadingComponent = _ref2.userMessageLeadingComponent, userMessageFooterComponent = _ref2.userMessageFooterComponent, emptyComponent = _ref2.emptyComponent, actionsComponent = _ref2.actionsComponent, suggestionsComponent = _ref2.suggestionsComponent, classNames = _ref2.classNames, _ref_translations = _ref2.translations, translations = _ref_translations === void 0 ? {} : _ref_translations, title = _ref2.title, getSearchPageURL = _ref2.getSearchPageURL, _ref_disableTriggerValidation = _ref2.disableTriggerValidation, disableTriggerValidation = _ref_disableTriggerValidation === void 0 ? false : _ref_disableTriggerValidation, showReasoning = _ref2.showReasoning, reasoningComponent = _ref2.reasoningComponent, props = _object_without_properties(_ref2, [
26747
27216
  "tools",
26748
27217
  "headerProps",
26749
27218
  "messagesProps",
@@ -26776,7 +27245,8 @@
26776
27245
  "title",
26777
27246
  "getSearchPageURL",
26778
27247
  "disableTriggerValidation",
26779
- "showReasoning"
27248
+ "showReasoning",
27249
+ "reasoningComponent"
26780
27250
  ]), _rest1 = _sliced_to_array(_rest, 1), ref = _rest1[0];
26781
27251
  var _ref3;
26782
27252
  var promptTranslations = translations.prompt, headerTranslations = translations.header, messageTranslations = translations.message, messagesTranslations = translations.messages;
@@ -26807,11 +27277,21 @@
26807
27277
  disableTriggerValidation: effectiveDisableTriggerValidation
26808
27278
  }));
26809
27279
  var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, suggestionsStatus = chatState.suggestionsStatus, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState, consumeInputFocus = chatState['~consumeInputFocus'], isOpenStatePersistenceEnabled = chatState['~isOpenStatePersistenceEnabled'];
27280
+ var sendMessageAndScrollToBottom = React.useCallback(function() {
27281
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
27282
+ args[_key] = arguments[_key];
27283
+ }
27284
+ scrollToBottom();
27285
+ return sendMessage.apply(void 0, _to_consumable_array(args));
27286
+ }, [
27287
+ scrollToBottom,
27288
+ sendMessage
27289
+ ]);
26810
27290
  React.useImperativeHandle(ref, function() {
26811
27291
  return {
26812
27292
  setOpen: setOpen,
26813
- sendMessage: function sendMessage1(params) {
26814
- return sendMessage(params);
27293
+ sendMessage: function sendMessage(params) {
27294
+ return sendMessageAndScrollToBottom(params);
26815
27295
  },
26816
27296
  setInput: setInput
26817
27297
  };
@@ -26863,7 +27343,7 @@
26863
27343
  title: title,
26864
27344
  open: open,
26865
27345
  maximized: maximized,
26866
- sendMessage: sendMessage,
27346
+ sendMessage: sendMessageAndScrollToBottom,
26867
27347
  regenerate: regenerate,
26868
27348
  stop: stop,
26869
27349
  error: error,
@@ -26898,7 +27378,7 @@
26898
27378
  onClose: function onClose() {
26899
27379
  return setOpen(false);
26900
27380
  },
26901
- sendMessage: sendMessage,
27381
+ sendMessage: sendMessageAndScrollToBottom,
26902
27382
  setInput: setInput,
26903
27383
  onFeedback: onFeedback,
26904
27384
  feedbackState: feedbackState,
@@ -26924,7 +27404,8 @@
26924
27404
  assistantMessageProps: _object_spread({
26925
27405
  leadingComponent: assistantMessageLeadingComponent,
26926
27406
  footerComponent: assistantMessageFooterComponent,
26927
- showReasoning: showReasoning
27407
+ showReasoning: showReasoning,
27408
+ reasoningComponent: reasoningComponent
26928
27409
  }, callerAssistantMessageProps),
26929
27410
  userMessageProps: _object_spread({
26930
27411
  leadingComponent: userMessageLeadingComponent,
@@ -26941,7 +27422,7 @@
26941
27422
  setInput(event.currentTarget.value);
26942
27423
  },
26943
27424
  onSubmit: function onSubmit() {
26944
- sendMessage({
27425
+ sendMessageAndScrollToBottom({
26945
27426
  text: input
26946
27427
  });
26947
27428
  setInput('');
@@ -26958,7 +27439,7 @@
26958
27439
  suggestions: suggestions,
26959
27440
  isLoading: suggestionsStatus === 'loading',
26960
27441
  onSuggestionClick: function onSuggestionClick(suggestion) {
26961
- sendMessage({
27442
+ sendMessageAndScrollToBottom({
26962
27443
  text: suggestion
26963
27444
  });
26964
27445
  }
@@ -27004,9 +27485,16 @@
27004
27485
  }), {
27005
27486
  $$widgetType: 'ais.promptSuggestions'
27006
27487
  }), suggestions = _usePromptSuggestions.suggestions, isLoading = _usePromptSuggestions.isLoading, error = _usePromptSuggestions.error, onSuggestionClick = _usePromptSuggestions.onSuggestionClick, isChatBusy = _usePromptSuggestions.isChatBusy, sendToChat = _usePromptSuggestions.sendToChat;
27488
+ if (!sendToChat && !onSuggestionClickOverride) {
27489
+ throw new Error('No <Chat> widget is mounted on this index, so there is nothing to send a clicked suggestion to. Mount a <Chat> on the same index, or pass `onSuggestionClick` to handle the click yourself.');
27490
+ }
27007
27491
  var handleClick = onSuggestionClickOverride ? function(prompt) {
27008
27492
  return onSuggestionClickOverride(prompt, {
27009
- sendToChat: sendToChat
27493
+ // `sendToChat` is only absent when the override above owns the click,
27494
+ // in which case falling through to the chat is a no-op.
27495
+ sendToChat: sendToChat !== null && sendToChat !== void 0 ? sendToChat : function() {
27496
+ return false;
27497
+ }
27010
27498
  });
27011
27499
  } : onSuggestionClick;
27012
27500
  if (LayoutComponent) {