@arbor-education/ask-arbor-chat-panel 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +18 -38
- package/dist/index.d.ts +11 -1
- package/dist/index.js +2009 -1696
- package/dist/style.css +1 -1
- package/dist-iife/ask-arbor-slideover.js +217 -237
- package/dist-iife/ask-arbor-widget.js +217 -237
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,93 +1,73 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Sr=Object.defineProperty;var Ar=(e,t,r)=>t in e?Sr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Cn=(e,t,r)=>Ar(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),se=require("@arbor-education/design-system.components"),l=require("react"),er=require("react-dom");function wr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var tr={exports:{}};/*!
|
|
2
2
|
Copyright (c) 2018 Jed Watson.
|
|
3
3
|
Licensed under the MIT License (MIT), see
|
|
4
4
|
http://jedwatson.github.io/classnames
|
|
5
|
-
*/(function(e){(function(){var t={}.hasOwnProperty;function r(){for(var i="",d=0;d<arguments.length;d++){var h=arguments[d];h&&(i=u(i,a(h)))}return i}function a(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return r.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var d="";for(var h in i)t.call(i,h)&&i[h]&&(d=u(d,h));return d}function u(i,d){return d?i?i+" "+d:i+d:i}e.exports?(r.default=r,e.exports=r):window.classNames=r})()})(Vn);var yr=Vn.exports;const pe=br(yr);function Tr(e,t,r,a){var u=this,i=l.useRef(null),d=l.useRef(0),h=l.useRef(0),_=l.useRef(null),p=l.useRef([]),E=l.useRef(),S=l.useRef(),g=l.useRef(e),A=l.useRef(!0),x=l.useRef(),L=l.useRef();g.current=e;var N=typeof window<"u",w=!t&&t!==0&&N;if(typeof e!="function")throw new TypeError("Expected a function");t=+t||0;var j=!!(r=r||{}).leading,ue=!("trailing"in r)||!!r.trailing,U=!!r.flushOnExit&&ue,$="maxWait"in r,M="debounceOnServer"in r&&!!r.debounceOnServer,Y=$?Math.max(+r.maxWait||0,t):null,de=l.useMemo(function(){var V=function(O){var z=p.current,fe=E.current;return p.current=E.current=null,d.current=O,h.current=h.current||O,S.current=g.current.apply(fe,z)},F=function(O,z){w&&cancelAnimationFrame(_.current),_.current=w?requestAnimationFrame(O):setTimeout(O,z)},ce=function(O){if(!A.current)return!1;var z=O-i.current;return!i.current||z>=t||z<0||$&&O-d.current>=Y},y=function(O){return _.current=null,ue&&p.current?V(O):(p.current=E.current=null,S.current)},v=function O(){var z=Date.now();if(j&&h.current===d.current&&H(),ce(z))return y(z);if(A.current){var fe=t-(z-i.current),Ce=$?Math.min(fe,Y-(z-d.current)):fe;F(O,Ce)}},H=function(){},ee=function(){if(N||M){var O,z=Date.now(),fe=ce(z);if(p.current=[].slice.call(arguments),E.current=u,i.current=z,U&&!x.current&&(x.current=function(){var Ce;((Ce=globalThis.document)==null?void 0:Ce.visibilityState)==="hidden"&&L.current.flush()},(O=globalThis.document)==null||O.addEventListener==null||O.addEventListener("visibilitychange",x.current)),fe){if(!_.current&&A.current)return d.current=i.current,F(v,t),j?V(i.current):S.current;if($)return F(v,t),V(i.current)}return _.current||F(v,t),S.current}};return ee.cancel=function(){var O=_.current;O&&(w?cancelAnimationFrame(_.current):clearTimeout(_.current)),d.current=0,p.current=i.current=E.current=_.current=null},ee.isPending=function(){return!!_.current},ee.flush=function(){return _.current?y(Date.now()):S.current},ee},[j,$,t,Y,ue,U,w,N,M,a]);return L.current=de,l.useEffect(function(){return A.current=!0,function(){var V;U&&L.current.flush(),x.current&&((V=globalThis.document)==null||V.removeEventListener==null||V.removeEventListener("visibilitychange",x.current),x.current=null),A.current=!1}},[U]),de}const Er=()=>s.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[s.jsx("path",{d:"M9.76794 5.1605L10.9845 5.50809C11.1003 5.54083 11.1784 5.64662 11.1784 5.765C11.1784 5.88338 11.1003 5.98917 10.9845 6.02191L9.76794 6.3695L9.42036 7.58606C9.38761 7.70192 9.28183 7.78 9.16344 7.78C9.04506 7.78 8.93928 7.70192 8.90653 7.58606L8.55894 6.3695L7.34239 6.02191C7.22653 5.98917 7.14844 5.88338 7.14844 5.765C7.14844 5.64662 7.22653 5.54083 7.34239 5.50809L8.55894 5.1605L8.90653 3.94394C8.93928 3.82808 9.04506 3.75 9.16344 3.75C9.28183 3.75 9.38761 3.82808 9.42036 3.94394L9.76794 5.1605Z",fill:"#F7941D"}),s.jsx("path",{d:"M6.67581 3.31451L7.42144 3.52755C7.49245 3.54762 7.54031 3.61246 7.54031 3.68501C7.54031 3.75757 7.49245 3.82241 7.42144 3.84247L6.67581 4.05551L6.46277 4.80114C6.4427 4.87216 6.37786 4.92001 6.30531 4.92001C6.23275 4.92001 6.16791 4.87216 6.14784 4.80114L5.93481 4.05551L5.18918 3.84247C5.11816 3.82241 5.07031 3.75757 5.07031 3.68501C5.07031 3.61246 5.11816 3.54762 5.18918 3.52755L5.93481 3.31451L6.14784 2.56888C6.16791 2.49787 6.23275 2.45001 6.30531 2.45001C6.37786 2.45001 6.4427 2.49787 6.46277 2.56888L6.67581 3.31451Z",fill:"#CFDD27"}),s.jsx("path",{d:"M6.49287 7.78652L8.18036 8.26865C8.34107 8.31407 8.44938 8.46081 8.44938 8.62502C8.44938 8.78922 8.34107 8.93596 8.18036 8.98138L6.49287 9.46352L6.01074 11.151C5.96532 11.3117 5.81857 11.42 5.65437 11.42C5.49016 11.42 5.34342 11.3117 5.298 11.151L4.81587 9.46352L3.1284 8.98138C2.96768 8.93596 2.85938 8.78922 2.85938 8.62502C2.85938 8.46081 2.96768 8.31407 3.1284 8.26865L4.81587 7.78652L5.298 6.09904C5.34342 5.93832 5.49016 5.83002 5.65437 5.83002C5.81857 5.83002 5.96532 5.93832 6.01074 6.09904L6.49287 7.78652Z",fill:"#7BB93C"})]}),Ar="Enter",Sr=" ",xn=({category:e,isExpanded:t,onHeaderClick:r})=>{const a=`ask-arbor-prompt-library__body-${e.id}`,u=i=>{(i.key===Ar||i.key===Sr)&&(i.preventDefault(),r(e.id))};return s.jsx("div",{className:pe("ask-arbor-prompt-library__category",`ask-arbor-prompt-library__category--${e.theme}`,{"ask-arbor-prompt-library__category--expanded":t}),children:s.jsxs("div",{className:"ask-arbor-prompt-library__header",onClick:()=>r(e.id),onKeyDown:u,role:"button",tabIndex:0,"aria-expanded":t,"aria-controls":a,"aria-label":`${e.title}, ${t?"collapse":"expand"} to ${t?"hide":"show"} prompts`,children:[s.jsx("div",{className:"ask-arbor-prompt-library__icon-circle",children:s.jsx(be.Icon,{name:e.icon,size:12,screenReaderText:e.title})}),s.jsx("div",{className:"ask-arbor-prompt-library__header-text",children:s.jsx("h4",{className:"ask-arbor-prompt-library__title",children:e.title})}),s.jsx(be.Icon,{name:t?"chevron-up":"chevron-down",size:16,screenReaderText:t?"Collapse section":"Expand section",className:"ask-arbor-prompt-library__chevron"}),s.jsx("p",{className:"ask-arbor-prompt-library__description",children:e.description})]})})},wr=({onSelectPrompt:e,onPromptHover:t,categories:r})=>{const[a,u]=l.useState(null),i=g=>{u(A=>A===g?null:g)},d=(g,A)=>{g.stopPropagation(),e(A)},h=a!=null?r.findIndex(g=>g.id===a):-1,_=h>=0?r[h]:null,p=g=>s.jsx("div",{className:"ask-arbor-prompt-library__grid-item ask-arbor-prompt-library__grid-item--full-width",children:s.jsxs("div",{className:"ask-arbor-prompt-library__expanded-block",children:[s.jsx(xn,{category:g,isExpanded:!0,onHeaderClick:i}),s.jsx("div",{id:`ask-arbor-prompt-library__body-${g.id}`,className:"ask-arbor-prompt-library__drawer",role:"region","aria-label":`${g.title} prompts`,children:g.promptGroups.map(A=>s.jsxs("div",{className:"ask-arbor-prompt-library__prompt-group",children:[s.jsx(be.Tag,{color:g.theme,children:A.tag}),s.jsx("div",{className:"ask-arbor-prompt-library__prompts",children:A.prompts.map((x,L)=>s.jsxs("button",{type:"button",className:"ask-arbor-prompt-library__prompt-row",onClick:N=>d(N,x),onMouseEnter:()=>t==null?void 0:t(x),onMouseLeave:()=>t==null?void 0:t(null),children:[s.jsx("span",{className:"ask-arbor-prompt-library__prompt-text",children:x}),s.jsx(be.Icon,{name:"chevron-right",size:12,screenReaderText:"Submit prompt"})]},`${A.tag}-${L}`))})]},A.tag))})]})},g.id),E=g=>s.jsx("div",{className:"ask-arbor-prompt-library__grid-item",children:s.jsx(xn,{category:g,isExpanded:!1,onHeaderClick:i})},g.id),S=h>=0?[...r.slice(0,h).map(E),p(_),...r.slice(h+1).map(E)]:r.map(E);return s.jsx("div",{className:"ask-arbor-prompt-library","data-testid":"ask-arbor-prompt-library",children:s.jsx("div",{className:"ask-arbor-prompt-library__grid",children:S})})};/**
|
|
5
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function r(){for(var i="",d=0;d<arguments.length;d++){var _=arguments[d];_&&(i=c(i,o(_)))}return i}function o(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return r.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var d="";for(var _ in i)t.call(i,_)&&i[_]&&(d=c(d,_));return d}function c(i,d){return d?i?i+" "+d:i+d:i}e.exports?(r.default=r,e.exports=r):window.classNames=r})()})(tr);var xr=tr.exports;const ye=wr(xr);function Nr(e,t,r,o){var c=this,i=l.useRef(null),d=l.useRef(0),_=l.useRef(0),m=l.useRef(null),g=l.useRef([]),h=l.useRef(),w=l.useRef(),T=l.useRef(e),S=l.useRef(!0),k=l.useRef(),M=l.useRef();T.current=e;var N=typeof window<"u",A=!t&&t!==0&&N;if(typeof e!="function")throw new TypeError("Expected a function");t=+t||0;var U=!!(r=r||{}).leading,de=!("trailing"in r)||!!r.trailing,$=!!r.flushOnExit&&de,G="maxWait"in r,z="debounceOnServer"in r&&!!r.debounceOnServer,X=G?Math.max(+r.maxWait||0,t):null,fe=l.useMemo(function(){var oe=function(L){var C=g.current,ae=h.current;return g.current=h.current=null,d.current=L,_.current=_.current||L,w.current=T.current.apply(ae,C)},B=function(L,C){A&&cancelAnimationFrame(m.current),m.current=A?requestAnimationFrame(L):setTimeout(L,C)},Ae=function(L){if(!S.current)return!1;var C=L-i.current;return!i.current||C>=t||C<0||G&&L-d.current>=X},y=function(L){return m.current=null,de&&g.current?oe(L):(g.current=h.current=null,w.current)},O=function L(){var C=Date.now();if(U&&_.current===d.current&&K(),Ae(C))return y(C);if(S.current){var ae=t-(C-i.current),Te=G?Math.min(ae,X-(C-d.current)):ae;B(L,Te)}},K=function(){},te=function(){if(N||z){var L,C=Date.now(),ae=Ae(C);if(g.current=[].slice.call(arguments),h.current=c,i.current=C,$&&!k.current&&(k.current=function(){var Te;((Te=globalThis.document)==null?void 0:Te.visibilityState)==="hidden"&&M.current.flush()},(L=globalThis.document)==null||L.addEventListener==null||L.addEventListener("visibilitychange",k.current)),ae){if(!m.current&&S.current)return d.current=i.current,B(O,t),U?oe(i.current):w.current;if(G)return B(O,t),oe(i.current)}return m.current||B(O,t),w.current}};return te.cancel=function(){var L=m.current;L&&(A?cancelAnimationFrame(m.current):clearTimeout(m.current)),d.current=0,g.current=i.current=h.current=m.current=null},te.isPending=function(){return!!m.current},te.flush=function(){return m.current?y(Date.now()):w.current},te},[U,G,t,X,de,$,A,N,z,o]);return M.current=fe,l.useEffect(function(){return S.current=!0,function(){var oe;$&&M.current.flush(),k.current&&((oe=globalThis.document)==null||oe.removeEventListener==null||oe.removeEventListener("visibilitychange",k.current),k.current=null),S.current=!1}},[$]),fe}const Rr=()=>s.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[s.jsx("path",{d:"M9.76794 5.1605L10.9845 5.50809C11.1003 5.54083 11.1784 5.64662 11.1784 5.765C11.1784 5.88338 11.1003 5.98917 10.9845 6.02191L9.76794 6.3695L9.42036 7.58606C9.38761 7.70192 9.28183 7.78 9.16344 7.78C9.04506 7.78 8.93928 7.70192 8.90653 7.58606L8.55894 6.3695L7.34239 6.02191C7.22653 5.98917 7.14844 5.88338 7.14844 5.765C7.14844 5.64662 7.22653 5.54083 7.34239 5.50809L8.55894 5.1605L8.90653 3.94394C8.93928 3.82808 9.04506 3.75 9.16344 3.75C9.28183 3.75 9.38761 3.82808 9.42036 3.94394L9.76794 5.1605Z",fill:"#F7941D"}),s.jsx("path",{d:"M6.67581 3.31451L7.42144 3.52755C7.49245 3.54762 7.54031 3.61246 7.54031 3.68501C7.54031 3.75757 7.49245 3.82241 7.42144 3.84247L6.67581 4.05551L6.46277 4.80114C6.4427 4.87216 6.37786 4.92001 6.30531 4.92001C6.23275 4.92001 6.16791 4.87216 6.14784 4.80114L5.93481 4.05551L5.18918 3.84247C5.11816 3.82241 5.07031 3.75757 5.07031 3.68501C5.07031 3.61246 5.11816 3.54762 5.18918 3.52755L5.93481 3.31451L6.14784 2.56888C6.16791 2.49787 6.23275 2.45001 6.30531 2.45001C6.37786 2.45001 6.4427 2.49787 6.46277 2.56888L6.67581 3.31451Z",fill:"#CFDD27"}),s.jsx("path",{d:"M6.49287 7.78652L8.18036 8.26865C8.34107 8.31407 8.44938 8.46081 8.44938 8.62502C8.44938 8.78922 8.34107 8.93596 8.18036 8.98138L6.49287 9.46352L6.01074 11.151C5.96532 11.3117 5.81857 11.42 5.65437 11.42C5.49016 11.42 5.34342 11.3117 5.298 11.151L4.81587 9.46352L3.1284 8.98138C2.96768 8.93596 2.85938 8.78922 2.85938 8.62502C2.85938 8.46081 2.96768 8.31407 3.1284 8.26865L4.81587 7.78652L5.298 6.09904C5.34342 5.93832 5.49016 5.83002 5.65437 5.83002C5.81857 5.83002 5.96532 5.93832 6.01074 6.09904L6.49287 7.78652Z",fill:"#7BB93C"})]}),kr="Enter",Ir=" ",vn=({category:e,isExpanded:t,onHeaderClick:r})=>{const o=`ask-arbor-prompt-library__body-${e.id}`,c=i=>{(i.key===kr||i.key===Ir)&&(i.preventDefault(),r(e.id))};return s.jsx("div",{className:ye("ask-arbor-prompt-library__category",`ask-arbor-prompt-library__category--${e.theme}`,{"ask-arbor-prompt-library__category--expanded":t}),children:s.jsxs("div",{className:"ask-arbor-prompt-library__header",onClick:()=>r(e.id),onKeyDown:c,role:"button",tabIndex:0,"aria-expanded":t,"aria-controls":o,"aria-label":`${e.title}, ${t?"collapse":"expand"} to ${t?"hide":"show"} prompts`,children:[s.jsx("div",{className:"ask-arbor-prompt-library__icon-circle",children:s.jsx(se.Icon,{name:e.icon,size:12,screenReaderText:e.title})}),s.jsx("div",{className:"ask-arbor-prompt-library__header-text",children:s.jsx("h4",{className:"ask-arbor-prompt-library__title",children:e.title})}),s.jsx(se.Icon,{name:t?"chevron-up":"chevron-down",size:16,screenReaderText:t?"Collapse section":"Expand section",className:"ask-arbor-prompt-library__chevron"}),s.jsx("p",{className:"ask-arbor-prompt-library__description",children:e.description})]})})},Cr=({onSelectPrompt:e,onPromptHover:t,categories:r})=>{const[o,c]=l.useState(null),i=T=>{c(S=>S===T?null:T)},d=(T,S)=>{T.stopPropagation(),e(S)},_=o!=null?r.findIndex(T=>T.id===o):-1,m=_>=0?r[_]:null,g=T=>s.jsx("div",{className:"ask-arbor-prompt-library__grid-item ask-arbor-prompt-library__grid-item--full-width",children:s.jsxs("div",{className:"ask-arbor-prompt-library__expanded-block",children:[s.jsx(vn,{category:T,isExpanded:!0,onHeaderClick:i}),s.jsx("div",{id:`ask-arbor-prompt-library__body-${T.id}`,className:"ask-arbor-prompt-library__drawer",role:"region","aria-label":`${T.title} prompts`,children:T.promptGroups.map(S=>s.jsxs("div",{className:"ask-arbor-prompt-library__prompt-group",children:[s.jsx(se.Tag,{color:T.theme,children:S.tag}),s.jsx("div",{className:"ask-arbor-prompt-library__prompts",children:S.prompts.map((k,M)=>s.jsxs("button",{type:"button",className:"ask-arbor-prompt-library__prompt-row",onClick:N=>d(N,k),onMouseEnter:()=>t==null?void 0:t(k),onMouseLeave:()=>t==null?void 0:t(null),children:[s.jsx("span",{className:"ask-arbor-prompt-library__prompt-text",children:k}),s.jsx(se.Icon,{name:"chevron-right",size:12,screenReaderText:"Submit prompt"})]},`${S.tag}-${M}`))})]},S.tag))})]})},T.id),h=T=>s.jsx("div",{className:"ask-arbor-prompt-library__grid-item",children:s.jsx(vn,{category:T,isExpanded:!1,onHeaderClick:i})},T.id),w=_>=0?[...r.slice(0,_).map(h),g(m),...r.slice(_+1).map(h)]:r.map(h);return s.jsx("div",{className:"ask-arbor-prompt-library","data-testid":"ask-arbor-prompt-library",children:s.jsx("div",{className:"ask-arbor-prompt-library__grid",children:w})})};function vr(e,t){if(t){t(e);return}/^https?:\/\//.test(e)?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e}const nr=({isOpen:e,onClose:t,anchorRef:r,items:o,onNavigate:c,className:i})=>{const d=l.useRef(null);return l.useEffect(()=>{if(!e)return;const _=g=>{d.current&&!d.current.contains(g.target)&&r.current&&!r.current.contains(g.target)&&t()},m=g=>{g.key==="Escape"&&t()};return document.addEventListener("mousedown",_),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",m)}},[e,t,r]),e?s.jsx("div",{ref:d,className:ye("ask-arbor-settings",i),role:"menu","aria-label":"Settings menu",children:o.map((_,m)=>s.jsxs("a",{href:_.url,className:"ask-arbor-settings__item",role:"menuitem",onClick:g=>{g.preventDefault(),t(),vr(_.url,c)},children:[_.icon,s.jsx("span",{className:"ask-arbor-settings__label",children:_.label})]},`${_.label}-${m}`))}):null};nr.displayName="AskArborSettings";const Or=4e3,jt=20*1024*1024,Lr={".pdf":["application/pdf"],".doc":["application/msword"],".docx":["application/vnd.openxmlformats-officedocument.wordprocessingml.document"]};function Dr(e){if(e)return Array.isArray(e)?e.join(","):e}const Mr=new Set(["","application/octet-stream"]);function jr(e){return e?e.split(",").some(t=>t.trim().startsWith(".")):!1}function Pr(e){return Mr.has(e.toLowerCase())}function Ur(e,t){if(!t)return"allowed";if(e.name)return mn(e,t)?"allowed":"rejected";const r=(e.type||"").toLowerCase();return Pr(r)?"unknown":mn(e,t)?"allowed":jr(t)?"unknown":"rejected"}function mn(e,t){if(!t)return!0;const r=e.name.toLowerCase(),o=(e.type||"").toLowerCase();return t.split(",").map(c=>c.trim().toLowerCase()).filter(Boolean).some(c=>{if(c.startsWith(".")){if(r.endsWith(c))return!0;const i=Lr[c];return!!(i&&o&&i.some(d=>d===o))}return c.endsWith("/*")?o.startsWith(c.slice(0,-1)):o===c})}function Fr(e,t){if(!t)return{allowed:e,rejected:[]};const r=[],o=[];for(const c of e)mn(c,t)?r.push(c):o.push(c);return{allowed:r,rejected:o}}function zr(e,t=jt){const r=[],o=[];for(const c of e)c.size<=t?r.push(c):o.push(c);return{allowed:r,oversized:o}}function rr(e){if(!e)return;const t=e.split(",").map(r=>r.trim()).filter(Boolean);return t.length>0?t.join(", "):void 0}function Hr(e,t){const r=rr(t);return e.length===1?r?`${e[0].name} is not allowed. Accepted types: ${r}`:`${e[0].name} is not allowed.`:r?`${e.length} files are not allowed. Accepted types: ${r}`:`${e.length} files are not allowed.`}function Gr(e){return e.length===1?`${e[0].name} is too large. Maximum file size: ${jt/(1024*1024)} MB`:`${e.length} files are too large. Maximum file size: ${jt/(1024*1024)} MB`}function sr(e){var r,o;if(!e)return[];if((r=e.files)!=null&&r.length)return Array.from(e.files);const t=[];for(const c of e.items??[]){if(c.kind!=="file")continue;const i=((o=c.getAsFile)==null?void 0:o.call(c))??null;i&&t.push(i)}return t}function Br(e){var o;if(!e)return[];const t=sr(e);if(t.length>0)return t;const r=[];for(const c of e.items??[]){if(c.kind!=="file")continue;const i=((o=c.getAsFile)==null?void 0:o.call(c))??null;if(i){r.push(i);continue}c.type&&r.push(new File([],"",{type:c.type}))}return r}function Wr(e,t,r=jt){const o=Br(e.dataTransfer);if(o.length===0)return"unknown";let c=!1,i=!1,d=!1,_=!1;for(const m of o){const g=Ur(m,t);if(g==="rejected"){d=!0;continue}if(g==="unknown"){i=!0;continue}if(m.size>r){_=!0;continue}c=!0}return d?"rejected":_&&!c&&!i?"size-rejected":c?"allowed":"unknown"}function $r(e,t){const r=[...e];for(const o of t)r.some(i=>i.name===o.name&&i.size===o.size&&i.lastModified===o.lastModified)||r.push(o);return r}function Yr(e){const t=Math.floor(e/60),r=e%60;return`${t}:${r.toString().padStart(2,"0")}`}const Ct=se.Button,or=l.forwardRef(({value:e,onChange:t,onKeyDown:r,placeholder:o="Explain what you need in your own words...",onSubmit:c,onSettingsClick:i,onMicClick:d,onStopClick:_,menuContent:m,onNavigate:g,isProcessing:h=!1,speechEngaged:w=!1,showMicButton:T=!0,ariaLabel:S="Chat panel input",disclaimerText:k="Ask Arbor can occasionally be wrong. Please check any important information.",showDisclaimer:M=!1,enableUpload:N=!1,acceptedFileTypes:A,onFileChange:U,uploadedFiles:de},$)=>{const G=Dr(A),z=de!==void 0,X=l.useRef(null),fe=l.useRef(null),oe=l.useRef(null),B=l.useRef(null),[Ae,y]=l.useState(0),[O,K]=l.useState(!1),[te,L]=l.useState([]),C=z?de??[]:te,[ae,Te]=l.useState(!1),[we,H]=l.useState(null),[Ve,Ne]=l.useState(null),Le=rr(G),Ce=l.useCallback(()=>{Ne(null),B.current&&(clearTimeout(B.current),B.current=null)},[]),Ge=l.useCallback(b=>{Ne(b),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{Ne(null),B.current=null},Or)},[]),q=l.useCallback(b=>{if(z){const v=b(de??[]);U==null||U(v);return}L(v=>{const V=b(v);return U==null||U(V),V})},[z,U,de]),Be=l.useCallback(b=>{if(b.length===0)return;const{allowed:v,rejected:V}=Fr(b,G);if(V.length>0){Ge(Hr(V,G));return}const{allowed:me,oversized:ie}=zr(v);if(ie.length>0){Ge(Gr(ie));return}me.length!==0&&q(Pe=>$r(Pe,me))},[G,Ge,q]),Z=l.useCallback(b=>{q(v=>v.filter((V,me)=>me!==b))},[q]),Xe=()=>{var b;(b=oe.current)==null||b.click()},W=b=>{const v=b.target.files?Array.from(b.target.files):[];Be(v),b.target.value=""},De=l.useCallback(b=>{const v=Wr(b,G);return H(v==="rejected"?"type":v==="size-rejected"?"size":null),v},[G]),j=l.useCallback(()=>{Te(!1),H(null)},[]),Me=b=>{b.preventDefault(),b.stopPropagation(),Te(!0);const v=De(b);b.dataTransfer.dropEffect=v==="rejected"||v==="size-rejected"?"none":"copy"},F=b=>{b.stopPropagation();const{clientX:v,clientY:V,currentTarget:me}=b,ie=b.relatedTarget;if(Number.isFinite(v)&&Number.isFinite(V)){const Ee=me.getBoundingClientRect();if(!(v<=Ee.left||v>=Ee.right||V<=Ee.top||V>=Ee.bottom))return}else if(ie&&me.contains(ie))return;j()},xe=b=>{b.preventDefault(),b.stopPropagation();const v=De(b);b.dataTransfer.dropEffect=v==="rejected"||v==="size-rejected"?"none":"copy"},Ze=b=>{b.preventDefault(),b.stopPropagation(),j();const v=sr(b.dataTransfer);Be(v)};l.useEffect(()=>{if(!w){y(0);return}y(0);const b=setInterval(()=>{y(v=>v+1)},1e3);return()=>clearInterval(b)},[w]),l.useEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]),l.useEffect(()=>{if(N)return window.addEventListener("dragend",j),()=>window.removeEventListener("dragend",j)},[N,j]),l.useImperativeHandle($,()=>X.current);const Re=!h&&!w&&(e.trim().length>0||N&&C.length>0),We=w,je=l.useMemo(()=>(m??[]).map(b=>({label:b.label,icon:s.jsx(se.Icon,{name:b.icon,size:12}),url:b.url})),[m]);return s.jsxs("div",{className:"ask-arbor-input",children:[N&&s.jsx("input",{ref:oe,type:"file",multiple:!0,accept:G,className:"ask-arbor-input__file-input",onChange:W,tabIndex:-1,"aria-hidden":!0}),s.jsxs("div",{className:"ask-arbor-input__content",children:[s.jsxs("div",{className:ye("ask-arbor-input__frame",{"ask-arbor-input__frame--dragging":ae,"ask-arbor-input__frame--dragging-rejected":ae&&we!==null}),onDragEnter:N?Me:void 0,onDragLeave:N?F:void 0,onDragOver:N?xe:void 0,onDrop:N?Ze:void 0,children:[N&&C.length>0&&s.jsx("div",{className:ye("ask-arbor-input__file-cards",{"ask-arbor-input__file-cards--hidden":ae||!!Ve}),children:C.map((b,v)=>s.jsxs("div",{className:"ask-arbor-input__file-card",children:[s.jsx(se.Icon,{name:"paperclip",size:12}),s.jsx("span",{className:"ask-arbor-input__file-card-name",title:b.name,children:b.name}),s.jsx("button",{type:"button",className:"ask-arbor-input__file-card-dismiss","aria-label":`Remove ${b.name}`,onClick:()=>Z(v),children:s.jsx(se.Icon,{name:"x",size:12})})]},`${b.name}-${b.size}-${b.lastModified}-${v}`))}),s.jsxs("div",{className:"ask-arbor-input__input-zone",children:[s.jsx("div",{className:"ask-arbor-input__input-row",children:s.jsx("textarea",{ref:X,className:"ask-arbor-input__textarea",value:e,onChange:b=>t(b.target.value),onKeyDown:r,placeholder:w?"":o,"aria-label":S,disabled:h||w,rows:1,tabIndex:w?-1:void 0,readOnly:w})}),s.jsx("div",{className:"ask-arbor-input__bottom-actions",children:s.jsxs("div",{className:"ask-arbor-input__actions-right",children:[w&&s.jsx("span",{className:"ask-arbor-input__timer",children:Yr(Ae)}),je.length>0&&s.jsxs("div",{className:"ask-arbor-input__settings-wrap",children:[s.jsx(Ct,{ref:fe,type:"button",variant:"secondary",size:"S",borderless:!0,iconLeftName:"settings",iconLeftScreenReaderText:"Settings",className:ye("ask-arbor-input__settings-btn",{"ask-arbor-input__settings-btn--open":O}),onClick:()=>{K(b=>!b),i==null||i()},"aria-expanded":O,"aria-haspopup":"menu"}),s.jsx(nr,{isOpen:O,onClose:()=>K(!1),anchorRef:fe,items:je,onNavigate:g})]}),T&&d&&!We&&s.jsx(Ct,{type:"button",variant:"secondary",size:"S",borderless:!0,iconLeftName:"mic",iconLeftScreenReaderText:"speak with agent",onClick:d,disabled:w||h}),N&&s.jsx(Ct,{type:"button",variant:"secondary",size:"S",borderless:!0,iconLeftName:"paperclip",iconLeftScreenReaderText:"Upload files",onClick:Xe,disabled:h||w}),We&&_?s.jsx(Ct,{type:"button",variant:"primary-destructive",size:"S",onClick:_,"aria-label":"Stop",children:"Stop"}):s.jsx(Ct,{type:"button",variant:"primary",size:"S",iconLeftName:"arrow-right",iconLeftScreenReaderText:"submit message",onClick:c,disabled:!Re})]})})]}),N&&ae&&s.jsxs("div",{className:ye("ask-arbor-input__drop-overlay",{"ask-arbor-input__drop-overlay--rejected":we!==null}),"aria-hidden":!0,children:[s.jsx(se.Icon,{name:we?"triangle-alert":"paperclip",size:16}),s.jsx("span",{className:"ask-arbor-input__drop-overlay-text",children:we==="type"?"File type not allowed":we==="size"?"File too large":"Drop files here"}),we==="type"&&Le&&s.jsxs("span",{className:"ask-arbor-input__drop-overlay-hint",children:["Accepted types:"," ",Le]}),we==="size"&&s.jsxs("span",{className:"ask-arbor-input__drop-overlay-hint",children:["Maximum size:"," ",jt/(1024*1024)," ","MB"]})]}),N&&Ve&&!ae&&s.jsxs("div",{className:"ask-arbor-input__upload-rejection",role:"alert",onClick:Ce,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),Ce())},tabIndex:0,children:[s.jsx(se.Icon,{name:"triangle-alert",size:12}),s.jsx("span",{className:"ask-arbor-input__upload-rejection-text",children:Ve}),s.jsx("button",{type:"button",className:"ask-arbor-input__upload-rejection-dismiss","aria-label":"Dismiss upload warning",onClick:b=>{b.stopPropagation(),Ce()},children:s.jsx(se.Icon,{name:"x",size:12})})]})]}),M&&s.jsx("p",{className:"ask-arbor-input__disclaimer",children:k})]})]})});or.displayName="AskArborInput";/**
|
|
6
6
|
* @license lucide-react v1.21.0 - ISC
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the ISC license.
|
|
9
9
|
* See the LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/const
|
|
10
|
+
*/const ar=(...e)=>e.filter((t,r,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===r).join(" ").trim();/**
|
|
11
11
|
* @license lucide-react v1.21.0 - ISC
|
|
12
12
|
*
|
|
13
13
|
* This source code is licensed under the ISC license.
|
|
14
14
|
* See the LICENSE file in the root directory of this source tree.
|
|
15
|
-
*/const
|
|
15
|
+
*/const Kr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
16
16
|
* @license lucide-react v1.21.0 - ISC
|
|
17
17
|
*
|
|
18
18
|
* This source code is licensed under the ISC license.
|
|
19
19
|
* See the LICENSE file in the root directory of this source tree.
|
|
20
|
-
*/const
|
|
20
|
+
*/const qr=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,o)=>o?o.toUpperCase():r.toLowerCase());/**
|
|
21
21
|
* @license lucide-react v1.21.0 - ISC
|
|
22
22
|
*
|
|
23
23
|
* This source code is licensed under the ISC license.
|
|
24
24
|
* See the LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/const
|
|
25
|
+
*/const On=e=>{const t=qr(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
|
|
26
26
|
* @license lucide-react v1.21.0 - ISC
|
|
27
27
|
*
|
|
28
28
|
* This source code is licensed under the ISC license.
|
|
29
29
|
* See the LICENSE file in the root directory of this source tree.
|
|
30
|
-
*/var
|
|
30
|
+
*/var sn={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
31
31
|
* @license lucide-react v1.21.0 - ISC
|
|
32
32
|
*
|
|
33
33
|
* This source code is licensed under the ISC license.
|
|
34
34
|
* See the LICENSE file in the root directory of this source tree.
|
|
35
|
-
*/const
|
|
35
|
+
*/const Vr=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},Xr=l.createContext({}),Zr=()=>l.useContext(Xr),Jr=l.forwardRef(({color:e,size:t,strokeWidth:r,absoluteStrokeWidth:o,className:c="",children:i,iconNode:d,..._},m)=>{const{size:g=24,strokeWidth:h=2,absoluteStrokeWidth:w=!1,color:T="currentColor",className:S=""}=Zr()??{},k=o??w?Number(r??h)*24/Number(t??g):r??h;return l.createElement("svg",{ref:m,...sn,width:t??g??sn.width,height:t??g??sn.height,stroke:e??T,strokeWidth:k,className:ar("lucide",S,c),...!i&&!Vr(_)&&{"aria-hidden":"true"},..._},[...d.map(([M,N])=>l.createElement(M,N)),...Array.isArray(i)?i:[i]])});/**
|
|
36
36
|
* @license lucide-react v1.21.0 - ISC
|
|
37
37
|
*
|
|
38
38
|
* This source code is licensed under the ISC license.
|
|
39
39
|
* See the LICENSE file in the root directory of this source tree.
|
|
40
|
-
*/const
|
|
40
|
+
*/const Tt=(e,t)=>{const r=l.forwardRef(({className:o,...c},i)=>l.createElement(Jr,{ref:i,iconNode:t,className:ar(`lucide-${Kr(On(e))}`,`lucide-${e}`,o),...c}));return r.displayName=On(e),r};/**
|
|
41
41
|
* @license lucide-react v1.21.0 - ISC
|
|
42
42
|
*
|
|
43
43
|
* This source code is licensed under the ISC license.
|
|
44
44
|
* See the LICENSE file in the root directory of this source tree.
|
|
45
|
-
*/const
|
|
45
|
+
*/const Qr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],es=Tt("circle-alert",Qr);/**
|
|
46
46
|
* @license lucide-react v1.21.0 - ISC
|
|
47
47
|
*
|
|
48
48
|
* This source code is licensed under the ISC license.
|
|
49
49
|
* See the LICENSE file in the root directory of this source tree.
|
|
50
|
-
*/const
|
|
50
|
+
*/const ts=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],ns=Tt("frown",ts);/**
|
|
51
51
|
* @license lucide-react v1.21.0 - ISC
|
|
52
52
|
*
|
|
53
53
|
* This source code is licensed under the ISC license.
|
|
54
54
|
* See the LICENSE file in the root directory of this source tree.
|
|
55
|
-
*/const
|
|
55
|
+
*/const rs=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ss=Tt("info",rs);/**
|
|
56
56
|
* @license lucide-react v1.21.0 - ISC
|
|
57
57
|
*
|
|
58
58
|
* This source code is licensed under the ISC license.
|
|
59
59
|
* See the LICENSE file in the root directory of this source tree.
|
|
60
|
-
*/const
|
|
60
|
+
*/const os=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],as=Tt("smile",os);/**
|
|
61
61
|
* @license lucide-react v1.21.0 - ISC
|
|
62
62
|
*
|
|
63
63
|
* This source code is licensed under the ISC license.
|
|
64
64
|
* See the LICENSE file in the root directory of this source tree.
|
|
65
|
-
*/const
|
|
65
|
+
*/const is=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],cs=Tt("triangle-alert",is);/**
|
|
66
66
|
* @license lucide-react v1.21.0 - ISC
|
|
67
67
|
*
|
|
68
68
|
* This source code is licensed under the ISC license.
|
|
69
69
|
* See the LICENSE file in the root directory of this source tree.
|
|
70
|
-
*/const zr=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],Gr=ke("mic",zr);/**
|
|
71
|
-
* @license lucide-react v1.21.0 - ISC
|
|
72
|
-
*
|
|
73
|
-
* This source code is licensed under the ISC license.
|
|
74
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
75
|
-
*/const Br=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Wr=ke("settings",Br);/**
|
|
76
|
-
* @license lucide-react v1.21.0 - ISC
|
|
77
|
-
*
|
|
78
|
-
* This source code is licensed under the ISC license.
|
|
79
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
80
|
-
*/const $r=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],Yr=ke("smile",$r);/**
|
|
81
|
-
* @license lucide-react v1.21.0 - ISC
|
|
82
|
-
*
|
|
83
|
-
* This source code is licensed under the ISC license.
|
|
84
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
85
|
-
*/const Kr=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],qr=ke("triangle-alert",Kr);/**
|
|
86
|
-
* @license lucide-react v1.21.0 - ISC
|
|
87
|
-
*
|
|
88
|
-
* This source code is licensed under the ISC license.
|
|
89
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
90
|
-
*/const Vr=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Xr=ke("x",Vr);function Zr(e,t){if(t){t(e);return}/^https?:\/\//.test(e)?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e}const Zn=({isOpen:e,onClose:t,anchorRef:r,items:a,onNavigate:u,className:i})=>{const d=l.useRef(null);return l.useEffect(()=>{if(!e)return;const h=p=>{d.current&&!d.current.contains(p.target)&&r.current&&!r.current.contains(p.target)&&t()},_=p=>{p.key==="Escape"&&t()};return document.addEventListener("mousedown",h),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",_)}},[e,t,r]),e?s.jsx("div",{ref:d,className:pe("ask-arbor-settings",i),role:"menu","aria-label":"Settings menu",children:a.map((h,_)=>s.jsxs("a",{href:h.url,className:"ask-arbor-settings__item",role:"menuitem",onClick:p=>{p.preventDefault(),t(),Zr(h.url,u)},children:[h.icon,s.jsx("span",{className:"ask-arbor-settings__label",children:h.label})]},`${h.label}-${_}`))}):null};Zn.displayName="AskArborSettings";function Jr(e){const t=Math.floor(e/60),r=e%60;return`${t}:${r.toString().padStart(2,"0")}`}const Jn=l.forwardRef(({value:e,onChange:t,onKeyDown:r,placeholder:a="Explain what you need in your own words...",onSubmit:u,onSettingsClick:i,onMicClick:d,onStopClick:h,menuContent:_,onNavigate:p,isProcessing:E=!1,speechEngaged:S=!1,showMicButton:g=!0,ariaLabel:A="Chat panel input",disclaimerText:x="Ask Arbor can occasionally be wrong. Please check any important information.",showDisclaimer:L=!1},N)=>{const w=l.useRef(null),j=l.useRef(null),[ue,U]=l.useState(0),[$,M]=l.useState(!1);l.useEffect(()=>{if(!S){U(0);return}U(0);const F=setInterval(()=>{U(ce=>ce+1)},1e3);return()=>clearInterval(F)},[S]),l.useImperativeHandle(N,()=>w.current);const Y=!E&&!S&&e.trim().length>0,de=S,V=l.useMemo(()=>(_??[]).map(F=>({label:F.label,icon:s.jsx(be.Icon,{name:F.icon,size:12}),url:F.url})),[_]);return s.jsxs("div",{className:"ask-arbor-input",children:[s.jsxs("div",{className:"ask-arbor-input__frame",children:[s.jsx("div",{className:"ask-arbor-input__input-row",children:s.jsx("textarea",{ref:w,className:"ask-arbor-input__textarea",value:e,onChange:F=>t(F.target.value),onKeyDown:r,placeholder:S?"":a,"aria-label":A,disabled:E||S,rows:1,tabIndex:S?-1:void 0,readOnly:S})}),s.jsx("div",{className:"ask-arbor-input__bottom-actions",children:s.jsxs("div",{className:"ask-arbor-input__actions-right",children:[S&&s.jsx("span",{className:"ask-arbor-input__timer",children:Jr(ue)}),V.length>0&&s.jsxs("div",{className:"ask-arbor-input__settings-wrap",children:[s.jsx("button",{ref:j,type:"button",className:pe("ask-arbor-input__btn","ask-arbor-input__btn--settings",{"ask-arbor-input__btn--settings-open":$}),onClick:()=>{M(F=>!F),i==null||i()},"aria-label":"Settings","aria-expanded":$,"aria-haspopup":"menu",children:s.jsx(Wr,{size:12,stroke:"#000000"})}),s.jsx(Zn,{isOpen:$,onClose:()=>M(!1),anchorRef:j,items:V,onNavigate:p})]}),g&&d&&!de&&s.jsx("button",{type:"button",className:pe("ask-arbor-input__btn","ask-arbor-input__btn--mic"),onClick:d,"aria-label":"speak with agent",disabled:S||E,children:s.jsx(Gr,{size:12,stroke:"#3C3735"})}),de&&h?s.jsxs("button",{type:"button",className:"ask-arbor-input__btn ask-arbor-input__btn--stop",onClick:h,"aria-label":"Stop",children:[s.jsx(Hr,{size:12,stroke:"#FFFFFF"}),"Stop"]}):s.jsx("button",{type:"button",className:"ask-arbor-input__btn ask-arbor-input__btn--submit",onClick:u,disabled:!Y,"aria-label":"submit message",children:s.jsx(Or,{size:12,stroke:"#FFFFFF",strokeWidth:2.5})})]})})]}),L&&s.jsx("p",{className:"ask-arbor-input__disclaimer",children:x})]})});Jn.displayName="AskArborInput";const mt="AGENT",Ze="USER",Bt="INFO",Ct="WARNING",Ae="ERROR",Qt="up",kn="down",Cn=10,Qr=({message:e,onRate:t,upRatingPopupUrl:r,downRatingPopupUrl:a,onRatingPopupOpen:u})=>{const[i,d]=l.useState(null),h=p=>{const E=p===Qt?r:a;E!=null&&E.trim()&&(u?u(E.trim()):window.open(E.trim(),"_blank","noopener,noreferrer"))},_=p=>{d(p),t(p),h(p)};return s.jsxs("div",{className:"chat-message__feedback",children:[s.jsx("span",{className:"chat-message__feedback-question",children:"How did Ask Arbor do?"}),s.jsxs("div",{className:"chat-message__feedback-buttons",children:[s.jsxs("button",{type:"button","aria-label":"Rate message as good response",title:"Good response",className:pe("chat-message__feedback-button","chat-message__feedback-button--up",{"chat-message__feedback-button--selected":i===Qt}),onClick:()=>_(Qt),children:[s.jsx(Yr,{size:Cn,strokeWidth:1.5,className:"chat-message__feedback-button-icon","aria-hidden":!0}),s.jsx("span",{className:"chat-message__feedback-button-text",children:"Nailed it"})]}),s.jsxs("button",{type:"button","aria-label":"Rate message as bad response",title:"Bad response",className:pe("chat-message__feedback-button","chat-message__feedback-button--down",{"chat-message__feedback-button--selected":i===kn}),onClick:()=>_(kn),children:[s.jsx(Pr,{size:Cn,strokeWidth:1.5,className:"chat-message__feedback-button-icon","aria-hidden":!0}),s.jsx("span",{className:"chat-message__feedback-button-text",children:"Missed the mark"})]})]})]})},es=be.Button,Qn=({prompt:e,onClick:t})=>s.jsx(es,{type:"button",variant:"secondary",size:"S",onClick:()=>t(e),children:e}),ts=({id:e,text:t,type:r,onRate:a,ratingPopupUrls:u={},chatId:i,showRating:d=!1,followUpPrompts:h,onFollowUpPromptClick:_,processCanvasReferences:p,isFallbackMessage:E,onRatingPopupOpen:S,children:g})=>{const A=r===mt,x=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:pe("chat-message",{"chat-message--user":r===Ze,"chat-message--agent":r===mt,"chat-message--info":r===Bt,"chat-message--error":r===Ae,"chat-message--warning":r===Ct}),children:[r===Bt&&s.jsx(Ur,{className:"chat-message__icon","aria-label":"Information",size:20}),r===Ct&&s.jsx(qr,{className:"chat-message__icon","aria-label":"Warning",size:20}),r===Ae&&s.jsx(Dr,{className:"chat-message__icon","aria-label":"Error",size:20}),g??s.jsx("span",{dangerouslySetInnerHTML:{__html:p(t)}})]}),A&&s.jsxs("div",{className:"chat-message__footer-actions",children:[s.jsx("div",{className:"chat-message__footer-icons",children:d&&a&&i&&s.jsx(Qr,{upRatingPopupUrl:u.up,downRatingPopupUrl:u.down,message:{id:e,type:r,text:t},onRate:L=>a(L,e),onRatingPopupOpen:S})}),s.jsx("div",{className:"chat-message__follow-up-prompts",children:h&&h.length>0&&!E&&s.jsx("ul",{className:"chat-message__follow-up-prompts-list",children:h.map((L,N)=>s.jsx("li",{children:s.jsx(Qn,{prompt:L,onClick:w=>_==null?void 0:_(w)})},`follow-up-prompt-${N}`))})})]})]});return s.jsx("li",{className:pe("chat-message-container",{"chat-message-container--user":r===Ze,"chat-message-container--agent":A}),children:A?s.jsx("div",{className:"chat-message-container__content",children:x}):x})},ns="Not authorised. Your session could have expired or is invalid. Please refresh the page and try again.",rs="You do not have permission to use this feature. Please contact your administrator if you need access.",ss="The chat service could not be found. Please check your configuration and try again.",os="It looks like this request took too long to complete. Please try again.",as="Whoops! Too many requests. Please wait a moment and try again.",is="The chat service is temporarily unavailable. Please try again later.",cs="Unable to reach the chat service. Please check your connection and try again.",er="Something went wrong. Please try again later.",ls="Something went wrong while trying to get a new agent message. Please try again later.",In="keyboard-shortcut-menu-portal";function us(){let e=document.getElementById(In);return e||(e=document.createElement("div"),e.id=In,e.style.cssText="position:fixed;left:0;top:0;z-index:19950;pointer-events:none;",document.body.appendChild(e)),e}const Wt=200;function ds(e){const t=window.innerHeight,r=e.top+e.height>t-Wt,a=e.top<Wt;return r?"above":a?"below":"above"}function fs(e){const t=ds(e),r=8;return t==="below"?{left:e.left,width:e.width,top:e.bottom+r,placement:"below"}:{left:e.left,width:e.width,bottom:window.innerHeight-e.top+r,placement:"above"}}function vn(e,t){if(t){t(e);return}/^https?:\/\//.test(e)?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e}const ps=({anchorRef:e,...t})=>{const[r,a]=l.useState(null);if(l.useLayoutEffect(()=>{const i=()=>{const p=e.current;if(!p)return;const E=p.getBoundingClientRect();a(fs(E))};i();const d=requestAnimationFrame(()=>i()),h=()=>i(),_=()=>i();return document.addEventListener("scroll",h,!0),window.addEventListener("resize",_),()=>{cancelAnimationFrame(d),document.removeEventListener("scroll",h,!0),window.removeEventListener("resize",_)}},[e]),!r)return null;const u={position:"fixed",left:r.left,width:r.width,pointerEvents:"auto"};return r.placement==="below"?u.top=r.top:u.bottom=r.bottom,qn.createPortal(s.jsx(tr,{...t,portalStyle:u}),us())},tr=e=>{const{menuItems:t=[],onSelectItem:r,onClose:a,hideReferenceFromList:u=!1,anchorRef:i,portalStyle:d,onNavigate:h}=e,[_,p]=l.useState(0),[E,S]=l.useState(""),[g,A]=l.useState(t),x=l.useRef(null),L=l.useRef(null),N=l.useRef(null),[w,j]=l.useState(!1),[ue,U]=l.useState(!1),$=d?d.top!=null:w,M=d?!0:ue;l.useEffect(()=>{p(0),S("")},[]),l.useEffect(()=>{d&&setTimeout(()=>{var y;return(y=N.current)==null?void 0:y.focus()},0)},[d]),l.useEffect(()=>{if(d||i||!x.current)return;const y=x.current.getBoundingClientRect(),v=window.innerHeight,H=y.top,ee=H+y.height>v-Wt,O=H<Wt;j(ee?!1:!!O),U(!0),setTimeout(()=>{var z;return(z=N.current)==null?void 0:z.focus()},0)},[i]),l.useEffect(()=>{if(L.current){const y=L.current.querySelector(".keyboard-shortcut-menu__items"),v=y==null?void 0:y.querySelector(".keyboard-shortcut-menu__item--selected");v&&v.scrollIntoView({behavior:"smooth",block:"nearest"})}},[_]),l.useEffect(()=>{A(E?t.filter(y=>y.reference.toLowerCase().includes(E.toLowerCase())||y.description.toLowerCase().includes(E.toLowerCase())):t)},[E,t]);const Y=y=>{var v;r&&g[y]&&!g[y].link&&r(g[y]),a&&!((v=g[y])!=null&&v.link)&&a()};l.useEffect(()=>{const y=H=>{H.key==="Escape"&&a&&(H.preventDefault(),a())},v=H=>{x.current&&!x.current.contains(H.target)&&a&&a()};return document.addEventListener("keydown",y),document.addEventListener("mousedown",v),()=>{document.removeEventListener("keydown",y),document.removeEventListener("mousedown",v)}},[a]);const de=y=>{switch(y.key){case"ArrowDown":y.preventDefault(),p(v=>v<g.length-1?v+1:v);break;case"ArrowUp":y.preventDefault(),p(v=>v>0?v-1:0);break;case"Enter":y.preventDefault(),g[_]&&(g[_].link?vn(g[_].link.replace(/\/\?/g,""),h):Y(_));break;case"Escape":y.preventDefault(),a&&a();break}},V=y=>{S(y),p(0)},F=(y,v)=>{const H=v===_,ee=y.icon?s.jsxs(s.Fragment,{children:[s.jsx(be.Icon,{name:y.icon,size:12}),s.jsx("span",{className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-main",children:y.description})]}):s.jsx(s.Fragment,{children:u?s.jsx("span",{"data-testid":"keyboard-shortcut-menu-item",className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-main",children:y.description}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"keyboard-shortcut-menu__item-reference keyboard-shortcut-menu__item-main",children:y.reference}),s.jsx("span",{className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-secondary",children:y.description})]})});if(y.link){const O=y.link.replace(/\/\?/g,"");return s.jsx("li",{role:"menuitem",children:s.jsx("a",{href:O,className:pe("keyboard-shortcut-menu__item-main keyboard-shortcut-menu__item",{"keyboard-shortcut-menu__item--selected":H,"keyboard-shortcut-menu__item--with-icon":!!y.icon}),onClick:z=>{z.preventDefault(),vn(O,h),a==null||a()},children:ee})},y.reference)}return s.jsx("li",{role:"menuitem",className:pe("keyboard-shortcut-menu__item",{"keyboard-shortcut-menu__item--selected":H,"keyboard-shortcut-menu__item--with-icon":!!y.icon}),onClick:()=>{r&&r(y),a&&a()},"aria-selected":H,children:ee},y.reference)},ce=s.jsx("div",{className:pe("keyboard-shortcut-menu",{"keyboard-shortcut-menu-below":$,"keyboard-shortcut-menu-hidden":!M}),onKeyDown:de,tabIndex:0,"aria-label":"Keyboard shortcut menu","data-testid":"keyboard-shortcut-menu",ref:x,children:s.jsxs("div",{className:"keyboard-shortcut-menu__content",ref:L,children:[s.jsxs("div",{className:"keyboard-shortcut-menu__header",children:[s.jsx("div",{className:"keyboard-shortcut-menu__search",children:s.jsx("input",{type:"text",value:E,onChange:y=>V(y.target.value),placeholder:"Search...",autoFocus:!0,ref:N})}),a&&s.jsx("button",{type:"button",className:"keyboard-shortcut-menu__close",onClick:a,"aria-label":"Close menu",children:s.jsx(Xr,{size:12,className:"keyboard-shortcut-menu__close-icon"})})]}),s.jsx("ul",{className:"keyboard-shortcut-menu__items",role:"menu","aria-label":"Menu options",children:g.length===0?s.jsx("li",{className:"keyboard-shortcut-menu__no-results",role:"menuitem",children:"No results found"}):g.map((y,v)=>F(y,v))})]})});return i&&!d?s.jsx(ps,{anchorRef:i,menuItems:t,onSelectItem:r,onClose:a,hideReferenceFromList:e.hideReferenceFromList,title:e.title,onNavigate:h}):d?s.jsx("div",{style:d,children:ce}):ce},On=({className:e})=>s.jsx("div",{className:pe("loading-spinner",e),"aria-label":"Loading",role:"img",children:s.jsxs("div",{className:"loading-spinner__inner",role:"presentation",children:[s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-left",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-top",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-right",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-bottom",role:"presentation"})]})}),ms=4e3,hs=500,_s=8e3,en=["I'm working on it…","Generating insights…","Piecing things together…","Processing your request…","Refining the details…","Just a moment…","Organising the information…","Bringing it all together…","Gathering facts…","Crafting a response…","Thinking things through…","Preparing results…","Double-checking my output…","Reviewing the options…","Gathering data…","Looking at data…","Digging deeper…","Reaching a conclusion…","Checking the data…","Thinking…","Putting ideas together…","Cross-checking information…","Filling in the gaps…","Finding the answers…","Organising my thoughts…","On it…","Working on my response…","Building your response…","Exploring the possibilities…","Completing the task…","Shaping the outcome…","Fine-tuning the details…","Crunching the data…","Looking up insights…","Composing an answer…","Pulling it all together…","Preparing a solution…","Making connections…","Polishing the results…","Steady progress…","Testing assumptions…","Checking possibilities…","Sifting through some ideas…","Organising concepts…","Analysing your query…","Analysing results…","Working through the details…"],gs=({loadingPhrase:e,showSpinnerAsIcon:t=!0,showNotifyLaterButton:r=!1,onNotifyLater:a,onNotificationRegisteredGotIt:u})=>{const i=()=>Math.floor(Math.random()*en.length),d=l.useRef(null),[h,_]=l.useState(e||en[i()]),[p,E]=l.useState("fade-in"),[S,g]=l.useState(!1),[A,x]=l.useState(!1);l.useEffect(()=>{r||x(!1)},[r]),l.useEffect(()=>{if(!r||!a)return;const w=setTimeout(()=>{g(!0)},_s);return()=>{clearTimeout(w)}},[r,a]);const L=async()=>{if(!a)return;await a()&&x(!0)},N=()=>{x(!1),u==null||u()};return l.useEffect(()=>{let w=null;return e?(_(e),E("fade-in")):w=setInterval(()=>{E("fade-out"),setTimeout(()=>{let j;do j=i();while(j===d.current);d.current=j,_(en[j]),E("fade-in")},hs)},ms),()=>{w&&clearInterval(w)}},[e]),s.jsxs("li",{"aria-label":"Loading response",className:"chat-panel__loading-container","data-testid":"loading-widget",children:[s.jsxs("div",{className:"chat-panel__loading-content",children:[t?s.jsx(On,{className:"chat-panel__loading-spinner"}):s.jsx("span",{className:"chat-panel__loading-spinner-container",children:s.jsx(On,{className:"chat-panel__loading-spinner"})}),s.jsx("span",{className:`chat-panel__loading-phrase ${p}`,children:h})]}),r&&a&&S&&s.jsx("div",{className:"chat-panel__notify-later",children:A?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"We'll notify you in the notifications panel on the left of your MIS."}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:N,"aria-label":"Got it",children:"Got it"})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"This one's taking a bit longer than usual"}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:L,"aria-label":"Let me know when it's done",children:"Let me know when it's done"})]})})]})};function bs(e){l.useEffect(e,[])}function ys(){const e=l.useRef(!1);return l.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Ts(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2)+Date.now().toString(36)}function Es(e,t=0){if(typeof e=="number"&&e>0)return e;if(typeof e=="string"){const r=parseInt(e,10);if(!isNaN(r)&&r>0)return r}return t}const As=/\*\*(.+?)\*\*/g;function Ss(e){return e.replace(As,"<strong>$1</strong>")}/*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */function Ln(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,a=Array(t);r<t;r++)a[r]=e[r];return a}function ws(e){if(Array.isArray(e))return e}function Ns(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var a,u,i,d,h=[],_=!0,p=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(_=(a=i.call(r)).done)&&(h.push(a.value),h.length!==t);_=!0);}catch(E){p=!0,u=E}finally{try{if(!_&&r.return!=null&&(d=r.return(),Object(d)!==d))return}finally{if(p)throw u}}return h}}function xs(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
91
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rs(e,t){return ws(e)||Ns(e,t)||ks(e,t)||xs()}function ks(e,t){if(e){if(typeof e=="string")return Ln(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ln(e,t):void 0}}const nr=Object.entries,Dn=Object.setPrototypeOf,Cs=Object.isFrozen,Is=Object.getPrototypeOf,vs=Object.getOwnPropertyDescriptor;let re=Object.freeze,se=Object.seal,pt=Object.create,rr=typeof Reflect<"u"&&Reflect,cn=rr.apply,ln=rr.construct;re||(re=function(t){return t});se||(se=function(t){return t});cn||(cn=function(t,r){for(var a=arguments.length,u=new Array(a>2?a-2:0),i=2;i<a;i++)u[i-2]=arguments[i];return t.apply(r,u)});ln||(ln=function(t){for(var r=arguments.length,a=new Array(r>1?r-1:0),u=1;u<r;u++)a[u-1]=arguments[u];return new t(...a)});const wt=q(Array.prototype.forEach),Os=q(Array.prototype.lastIndexOf),Mn=q(Array.prototype.pop),ft=q(Array.prototype.push),Ls=q(Array.prototype.splice),Fe=Array.isArray,kt=q(String.prototype.toLowerCase),tn=q(String.prototype.toString),Pn=q(String.prototype.match),Nt=q(String.prototype.replace),jn=q(String.prototype.indexOf),Ds=q(String.prototype.trim),Ms=q(Number.prototype.toString),Ps=q(Boolean.prototype.toString),Un=typeof BigInt>"u"?null:q(BigInt.prototype.toString),Fn=typeof Symbol>"u"?null:q(Symbol.prototype.toString),Q=q(Object.prototype.hasOwnProperty),xt=q(Object.prototype.toString),ne=q(RegExp.prototype.test),Xe=js(TypeError);function q(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,a=new Array(r>1?r-1:0),u=1;u<r;u++)a[u-1]=arguments[u];return cn(e,t,a)}}function js(e){return function(){for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];return ln(e,r)}}function C(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kt;if(Dn&&Dn(e,null),!Fe(t))return e;let a=t.length;for(;a--;){let u=t[a];if(typeof u=="string"){const i=r(u);i!==u&&(Cs(t)||(t[a]=i),u=i)}e[u]=!0}return e}function Us(e){for(let t=0;t<e.length;t++)Q(e,t)||(e[t]=null);return e}function ie(e){const t=pt(null);for(const a of nr(e)){var r=Rs(a,2);const u=r[0],i=r[1];Q(e,u)&&(Fe(i)?t[u]=Us(i):i&&typeof i=="object"&&i.constructor===Object?t[u]=ie(i):t[u]=i)}return t}function Fs(e){switch(typeof e){case"string":return e;case"number":return Ms(e);case"boolean":return Ps(e);case"bigint":return Un?Un(e):"0";case"symbol":return Fn?Fn(e):"Symbol()";case"undefined":return xt(e);case"function":case"object":{if(e===null)return xt(e);const t=e,r=Re(t,"toString");if(typeof r=="function"){const a=r(t);return typeof a=="string"?a:xt(a)}return xt(e)}default:return xt(e)}}function Re(e,t){for(;e!==null;){const a=vs(e,t);if(a){if(a.get)return q(a.get);if(typeof a.value=="function")return q(a.value)}e=Is(e)}function r(){return null}return r}function Hs(e){try{return ne(e,""),!0}catch{return!1}}const Hn=re(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),nn=re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),rn=re(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),zs=re(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),sn=re(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Gs=re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),zn=re(["#text"]),Gn=re(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),on=re(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Bn=re(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),zt=re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Bs=se(/{{[\w\W]*|^[\w\W]*}}/g),Ws=se(/<%[\w\W]*|^[\w\W]*%>/g),$s=se(/\${[\w\W]*/g),Ys=se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ks=se(/^aria-[\-\w]+$/),Wn=se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),qs=se(/^(?:\w+script|data):/i),Vs=se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xs=se(/^html$/i),Zs=se(/^[a-z][.\w]*(-[.\w]+)+$/i),$n=se(/<[/\w!]/g),Js=se(/<[/\w]/g),Qs=se(/<\/no(script|embed|frames)/i),eo=se(/\/>/i),xe={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},to=function(){return typeof window>"u"?null:window},no=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let a=null;const u="data-tt-policy-suffix";r&&r.hasAttribute(u)&&(a=r.getAttribute(u));const i="dompurify"+(a?"#"+a:"");try{return t.createPolicy(i,{createHTML(d){return d},createScriptURL(d){return d}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Yn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ue=function(t,r,a,u){return Q(t,r)&&Fe(t[r])?C(u.base?ie(u.base):{},t[r],u.transform):a};function sr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:to();const t=m=>sr(m);if(t.version="3.4.11",t.removed=[],!e||!e.document||e.document.nodeType!==xe.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const a=r,u=a.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,d=e.Node,h=e.Element,_=e.NodeFilter,p=e.NamedNodeMap;p===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const E=e.DOMParser,S=e.trustedTypes,g=h.prototype,A=Re(g,"cloneNode"),x=Re(g,"remove"),L=Re(g,"nextSibling"),N=Re(g,"childNodes"),w=Re(g,"parentNode"),j=Re(g,"shadowRoot"),ue=Re(g,"attributes"),U=d&&d.prototype?Re(d.prototype,"nodeType"):null,$=d&&d.prototype?Re(d.prototype,"nodeName"):null;if(typeof i=="function"){const m=r.createElement("template");m.content&&m.content.ownerDocument&&(r=m.content.ownerDocument)}let M,Y="",de,V=!1,F=0;const ce=function(){if(F>0)throw Xe('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},y=function(n){ce(),F++;try{return M.createHTML(n)}finally{F--}},v=function(n){ce(),F++;try{return M.createScriptURL(n)}finally{F--}},H=function(){return V||(de=no(S,u),V=!0),de},ee=r,O=ee.implementation,z=ee.createNodeIterator,fe=ee.createDocumentFragment,Ce=ee.getElementsByTagName,Oe=a.importNode;let P=Yn();t.isSupported=typeof nr=="function"&&typeof w=="function"&&O&&O.createHTMLDocument!==void 0;const te=Bs,ht=Ws,X=$s,_t=Ys,$t=Ks,Je=qs,Qe=Vs,He=Zs;let Le=Wn,D=null;const et=C({},[...Hn,...nn,...rn,...sn,...zn]);let B=null;const tt=C({},[...Gn,...on,...Bn,...zt]);let G=Object.seal(pt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Se=null,gt=null;const ye=Object.seal(pt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let It=!0,ze=!0,nt=!1,De=!0,Te=!1,Ge=!0,we=!1,rt=!1,Be=null,Me=null,st=!1,Ie=!1,We=!1,ot=!1,bt=!0,$e=!1;const at="user-content-";let yt=!0,it=!1,Pe={},me=null;const Ye=C({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let vt=null;const Ke=C({},["audio","video","img","source","image","track"]);let Tt=null;const Ot=C({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ne="http://www.w3.org/1998/Math/MathML",ct="http://www.w3.org/2000/svg",Z="http://www.w3.org/1999/xhtml";let he=Z,lt=!1,ut=null;const Yt=C({},[Ne,ct,Z],tn),Lt=re(["mi","mo","mn","ms","mtext"]);let Et=C({},Lt);const Dt=re(["annotation-xml"]);let At=C({},Dt);const Kt=C({},["title","style","font","a","script"]);let qe=null;const qt=["application/xhtml+xml","text/html"],Mt="text/html";let W=null,c=null;const T=r.createElement("form"),k=function(n){return n instanceof RegExp||n instanceof Function},oe=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(c&&c===n)return;(!n||typeof n!="object")&&(n={}),n=ie(n),qe=qt.indexOf(n.PARSER_MEDIA_TYPE)===-1?Mt:n.PARSER_MEDIA_TYPE,W=qe==="application/xhtml+xml"?tn:kt,D=Ue(n,"ALLOWED_TAGS",et,{transform:W}),B=Ue(n,"ALLOWED_ATTR",tt,{transform:W}),ut=Ue(n,"ALLOWED_NAMESPACES",Yt,{transform:tn}),Tt=Ue(n,"ADD_URI_SAFE_ATTR",Ot,{transform:W,base:Ot}),vt=Ue(n,"ADD_DATA_URI_TAGS",Ke,{transform:W,base:Ke}),me=Ue(n,"FORBID_CONTENTS",Ye,{transform:W}),Se=Ue(n,"FORBID_TAGS",ie({}),{transform:W}),gt=Ue(n,"FORBID_ATTR",ie({}),{transform:W}),Pe=Q(n,"USE_PROFILES")?n.USE_PROFILES&&typeof n.USE_PROFILES=="object"?ie(n.USE_PROFILES):n.USE_PROFILES:!1,It=n.ALLOW_ARIA_ATTR!==!1,ze=n.ALLOW_DATA_ATTR!==!1,nt=n.ALLOW_UNKNOWN_PROTOCOLS||!1,De=n.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Te=n.SAFE_FOR_TEMPLATES||!1,Ge=n.SAFE_FOR_XML!==!1,we=n.WHOLE_DOCUMENT||!1,Ie=n.RETURN_DOM||!1,We=n.RETURN_DOM_FRAGMENT||!1,ot=n.RETURN_TRUSTED_TYPE||!1,st=n.FORCE_BODY||!1,bt=n.SANITIZE_DOM!==!1,$e=n.SANITIZE_NAMED_PROPS||!1,yt=n.KEEP_CONTENT!==!1,it=n.IN_PLACE||!1,Le=Hs(n.ALLOWED_URI_REGEXP)?n.ALLOWED_URI_REGEXP:Wn,he=typeof n.NAMESPACE=="string"?n.NAMESPACE:Z,Et=Q(n,"MATHML_TEXT_INTEGRATION_POINTS")&&n.MATHML_TEXT_INTEGRATION_POINTS&&typeof n.MATHML_TEXT_INTEGRATION_POINTS=="object"?ie(n.MATHML_TEXT_INTEGRATION_POINTS):C({},Lt),At=Q(n,"HTML_INTEGRATION_POINTS")&&n.HTML_INTEGRATION_POINTS&&typeof n.HTML_INTEGRATION_POINTS=="object"?ie(n.HTML_INTEGRATION_POINTS):C({},Dt);const o=Q(n,"CUSTOM_ELEMENT_HANDLING")&&n.CUSTOM_ELEMENT_HANDLING&&typeof n.CUSTOM_ELEMENT_HANDLING=="object"?ie(n.CUSTOM_ELEMENT_HANDLING):pt(null);if(G=pt(null),Q(o,"tagNameCheck")&&k(o.tagNameCheck)&&(G.tagNameCheck=o.tagNameCheck),Q(o,"attributeNameCheck")&&k(o.attributeNameCheck)&&(G.attributeNameCheck=o.attributeNameCheck),Q(o,"allowCustomizedBuiltInElements")&&typeof o.allowCustomizedBuiltInElements=="boolean"&&(G.allowCustomizedBuiltInElements=o.allowCustomizedBuiltInElements),se(G),Te&&(ze=!1),We&&(Ie=!0),Pe&&(D=C({},zn),B=pt(null),Pe.html===!0&&(C(D,Hn),C(B,Gn)),Pe.svg===!0&&(C(D,nn),C(B,on),C(B,zt)),Pe.svgFilters===!0&&(C(D,rn),C(B,on),C(B,zt)),Pe.mathMl===!0&&(C(D,sn),C(B,Bn),C(B,zt))),ye.tagCheck=null,ye.attributeCheck=null,Q(n,"ADD_TAGS")&&(typeof n.ADD_TAGS=="function"?ye.tagCheck=n.ADD_TAGS:Fe(n.ADD_TAGS)&&(D===et&&(D=ie(D)),C(D,n.ADD_TAGS,W))),Q(n,"ADD_ATTR")&&(typeof n.ADD_ATTR=="function"?ye.attributeCheck=n.ADD_ATTR:Fe(n.ADD_ATTR)&&(B===tt&&(B=ie(B)),C(B,n.ADD_ATTR,W))),Q(n,"ADD_URI_SAFE_ATTR")&&Fe(n.ADD_URI_SAFE_ATTR)&&C(Tt,n.ADD_URI_SAFE_ATTR,W),Q(n,"FORBID_CONTENTS")&&Fe(n.FORBID_CONTENTS)&&(me===Ye&&(me=ie(me)),C(me,n.FORBID_CONTENTS,W)),Q(n,"ADD_FORBID_CONTENTS")&&Fe(n.ADD_FORBID_CONTENTS)&&(me===Ye&&(me=ie(me)),C(me,n.ADD_FORBID_CONTENTS,W)),yt&&(D["#text"]=!0),we&&C(D,["html","head","body"]),D.table&&(C(D,["tbody"]),delete Se.tbody),n.TRUSTED_TYPES_POLICY){if(typeof n.TRUSTED_TYPES_POLICY.createHTML!="function")throw Xe('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof n.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Xe('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const f=M;M=n.TRUSTED_TYPES_POLICY;try{Y=y("")}catch(b){throw M=f,b}}else n.TRUSTED_TYPES_POLICY===null?(M=void 0,Y=""):(M===void 0&&(M=H()),M&&typeof Y=="string"&&(Y=y("")));re&&re(n),c=n},_e=C({},[...nn,...rn,...zs]),le=C({},[...sn,...Gs]),Pt=function(n,o,f){return o.namespaceURI===Z?n==="svg":o.namespaceURI===Ne?n==="svg"&&(f==="annotation-xml"||Et[f]):!!_e[n]},_n=function(n,o,f){return o.namespaceURI===Z?n==="math":o.namespaceURI===ct?n==="math"&&At[f]:!!le[n]},gn=function(n,o,f){return o.namespaceURI===ct&&!At[f]||o.namespaceURI===Ne&&!Et[f]?!1:!le[n]&&(Kt[n]||!_e[n])},jt=function(n){let o=w(n);(!o||!o.tagName)&&(o={namespaceURI:he,tagName:"template"});const f=kt(n.tagName),b=kt(o.tagName);return ut[n.namespaceURI]?n.namespaceURI===ct?Pt(f,o,b):n.namespaceURI===Ne?_n(f,o,b):n.namespaceURI===Z?gn(f,o,b):!!(qe==="application/xhtml+xml"&&ut[n.namespaceURI]):!1},je=function(n){ft(t.removed,{element:n});try{w(n).removeChild(n)}catch{if(x(n),!w(n))throw Xe("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},bn=function(n){const o=N(n);if(o){const b=[];wt(o,R=>{ft(b,R)}),wt(b,R=>{try{x(R)}catch{}})}const f=ue(n);if(f)for(let b=f.length-1;b>=0;--b){const R=f[b],I=R&&R.name;if(typeof I=="string")try{n.removeAttribute(I)}catch{}}},Ve=function(n,o){try{ft(t.removed,{attribute:o.getAttributeNode(n),from:o})}catch{ft(t.removed,{attribute:null,from:o})}if(o.removeAttribute(n),n==="is")if(Ie||We)try{je(o)}catch{}else try{o.setAttribute(n,"")}catch{}},lr=function(n){const o=ue(n);if(o)for(let f=o.length-1;f>=0;--f){const b=o[f],R=b&&b.name;if(!(typeof R!="string"||B[W(R)]))try{n.removeAttribute(R)}catch{}}},ur=function(n){const o=[n];for(;o.length>0;){const f=o.pop();(U?U(f):f.nodeType)===xe.element&&lr(f);const R=N(f);if(R)for(let I=R.length-1;I>=0;--I)o.push(R[I])}},yn=function(n){let o=null,f=null;if(st)n="<remove></remove>"+n;else{const I=Pn(n,/^[\r\n\t ]+/);f=I&&I[0]}qe==="application/xhtml+xml"&&he===Z&&(n='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+n+"</body></html>");const b=M?y(n):n;if(he===Z)try{o=new E().parseFromString(b,qe)}catch{}if(!o||!o.documentElement){o=O.createDocument(he,"template",null);try{o.documentElement.innerHTML=lt?Y:b}catch{}}const R=o.body||o.documentElement;return n&&f&&R.insertBefore(r.createTextNode(f),R.childNodes[0]||null),he===Z?Ce.call(o,we?"html":"body")[0]:we?o.documentElement:R},Tn=function(n){return z.call(n.ownerDocument||n,n,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},Ut=function(n){return n=Nt(n,te," "),n=Nt(n,ht," "),n=Nt(n,X," "),n},Vt=function(n){var o;n.normalize();const f=z.call(n.ownerDocument||n,n,_.SHOW_TEXT|_.SHOW_COMMENT|_.SHOW_CDATA_SECTION|_.SHOW_PROCESSING_INSTRUCTION,null);let b=f.nextNode();for(;b;)b.data=Ut(b.data),b=f.nextNode();const R=(o=n.querySelectorAll)===null||o===void 0?void 0:o.call(n,"template");R&&wt(R,I=>{dt(I.content)&&Vt(I.content)})},Ft=function(n){const o=$?$(n):null;return typeof o!="string"||W(o)!=="form"?!1:typeof n.nodeName!="string"||typeof n.textContent!="string"||typeof n.removeChild!="function"||n.attributes!==ue(n)||typeof n.removeAttribute!="function"||typeof n.setAttribute!="function"||typeof n.namespaceURI!="string"||typeof n.insertBefore!="function"||typeof n.hasChildNodes!="function"||n.nodeType!==U(n)||n.childNodes!==N(n)},dt=function(n){if(!U||typeof n!="object"||n===null)return!1;try{return U(n)===xe.documentFragment}catch{return!1}},St=function(n){if(!U||typeof n!="object"||n===null)return!1;try{return typeof U(n)=="number"}catch{return!1}};function ve(m,n,o){m.length!==0&&wt(m,f=>{f.call(t,n,o,c)})}const dr=function(n,o){return!!(Ge&&n.hasChildNodes()&&!St(n.firstElementChild)&&ne($n,n.textContent)&&ne($n,n.innerHTML)||Ge&&n.namespaceURI===Z&&o==="style"&&St(n.firstElementChild)||n.nodeType===xe.processingInstruction||Ge&&n.nodeType===xe.comment&&ne(Js,n.data))},fr=function(n,o){if(!Se[o]&&Sn(o)&&(G.tagNameCheck instanceof RegExp&&ne(G.tagNameCheck,o)||G.tagNameCheck instanceof Function&&G.tagNameCheck(o)))return!1;if(yt&&!me[o]){const f=w(n),b=N(n);if(b&&f){const R=b.length;for(let I=R-1;I>=0;--I){const J=it?b[I]:A(b[I],!0);f.insertBefore(J,L(n))}}}return je(n),!0},En=function(n){if(ve(P.beforeSanitizeElements,n,null),Ft(n))return je(n),!0;const o=W($?$(n):n.nodeName);if(ve(P.uponSanitizeElement,n,{tagName:o,allowedTags:D}),dr(n,o))return je(n),!0;if(Se[o]||!(ye.tagCheck instanceof Function&&ye.tagCheck(o))&&!D[o])return fr(n,o);if((U?U(n):n.nodeType)===xe.element&&!jt(n)||(o==="noscript"||o==="noembed"||o==="noframes")&&ne(Qs,n.innerHTML))return je(n),!0;if(Te&&n.nodeType===xe.text){const b=Ut(n.textContent);n.textContent!==b&&(ft(t.removed,{element:n.cloneNode()}),n.textContent=b)}return ve(P.afterSanitizeElements,n,null),!1},An=function(n,o,f){if(gt[o]||bt&&(o==="id"||o==="name")&&(f in r||f in T))return!1;const b=B[o]||ye.attributeCheck instanceof Function&&ye.attributeCheck(o,n);if(!(ze&&ne(_t,o))){if(!(It&&ne($t,o))){if(b){if(!Tt[o]){if(!ne(Le,Nt(f,Qe,""))){if(!((o==="src"||o==="xlink:href"||o==="href")&&n!=="script"&&jn(f,"data:")===0&&vt[n])){if(!(nt&&!ne(Je,Nt(f,Qe,"")))){if(f)return!1}}}}}else if(!(Sn(n)&&(G.tagNameCheck instanceof RegExp&&ne(G.tagNameCheck,n)||G.tagNameCheck instanceof Function&&G.tagNameCheck(n))&&(G.attributeNameCheck instanceof RegExp&&ne(G.attributeNameCheck,o)||G.attributeNameCheck instanceof Function&&G.attributeNameCheck(o,n))||o==="is"&&G.allowCustomizedBuiltInElements&&(G.tagNameCheck instanceof RegExp&&ne(G.tagNameCheck,f)||G.tagNameCheck instanceof Function&&G.tagNameCheck(f))))return!1}}return!0},pr=C({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Sn=function(n){return!pr[kt(n)]&&ne(He,n)},mr=function(n,o,f,b){if(M&&typeof S=="object"&&typeof S.getAttributeType=="function"&&!f)switch(S.getAttributeType(n,o)){case"TrustedHTML":return y(b);case"TrustedScriptURL":return v(b)}return b},hr=function(n,o,f,b){try{f?n.setAttributeNS(f,o,b):n.setAttribute(o,b),Ft(n)?je(n):Mn(t.removed)}catch{Ve(o,n)}},wn=function(n){ve(P.beforeSanitizeAttributes,n,null);const o=n.attributes;if(!o||Ft(n))return;const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0};let b=o.length;const R=W(n.nodeName);for(;b--;){const I=o[b],J=I.name,K=I.namespaceURI,ge=I.value,Ee=W(J),Zt=ge;let ae=J==="value"?Zt:Ds(Zt);if(f.attrName=Ee,f.attrValue=ae,f.keepAttr=!0,f.forceKeepAttr=void 0,ve(P.uponSanitizeAttribute,n,f),ae=f.attrValue,$e&&(Ee==="id"||Ee==="name")&&jn(ae,at)!==0&&(Ve(J,n),ae=at+ae),Ge&&ne(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ae)){Ve(J,n);continue}if(Ee==="attributename"&&Pn(ae,"href")){Ve(J,n);continue}if(!f.forceKeepAttr){if(!f.keepAttr){Ve(J,n);continue}if(!De&&ne(eo,ae)){Ve(J,n);continue}if(Te&&(ae=Ut(ae)),!An(R,Ee,ae)){Ve(J,n);continue}ae=mr(R,Ee,K,ae),ae!==Zt&&hr(n,J,K,ae)}}ve(P.afterSanitizeAttributes,n,null)},Ht=function(n){let o=null;const f=Tn(n);for(ve(P.beforeSanitizeShadowDOM,n,null);o=f.nextNode();)if(ve(P.uponSanitizeShadowNode,o,null),En(o),wn(o),dt(o.content)&&Ht(o.content),(U?U(o):o.nodeType)===xe.element){const R=j(o);dt(R)&&(Xt(R),Ht(R))}ve(P.afterSanitizeShadowDOM,n,null)},Xt=function(n){const o=[{node:n,shadow:null}];for(;o.length>0;){const f=o.pop();if(f.shadow){Ht(f.shadow);continue}const b=f.node,I=(U?U(b):b.nodeType)===xe.element,J=N(b);if(J)for(let K=J.length-1;K>=0;--K)o.push({node:J[K],shadow:null});if(I){const K=$?$(b):null;if(typeof K=="string"&&W(K)==="template"){const ge=b.content;dt(ge)&&o.push({node:ge,shadow:null})}}if(I){const K=j(b);dt(K)&&o.push({node:null,shadow:K},{node:K,shadow:null})}}};return t.sanitize=function(m){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=null,f=null,b=null,R=null;if(lt=!m,lt&&(m="<!-->"),typeof m!="string"&&!St(m)&&(m=Fs(m),typeof m!="string"))throw Xe("dirty is not a string, aborting");if(!t.isSupported)return m;rt?(D=Be,B=Me):oe(n),(P.uponSanitizeElement.length>0||P.uponSanitizeAttribute.length>0)&&(D=ie(D)),P.uponSanitizeAttribute.length>0&&(B=ie(B)),t.removed=[];const I=it&&typeof m!="string"&&St(m);if(I){const ge=$?$(m):m.nodeName;if(typeof ge=="string"){const Ee=W(ge);if(!D[Ee]||Se[Ee])throw Xe("root node is forbidden and cannot be sanitized in-place")}if(Ft(m))throw Xe("root node is clobbered and cannot be sanitized in-place");try{Xt(m)}catch(Ee){throw bn(m),Ee}}else if(St(m))o=yn("<!---->"),f=o.ownerDocument.importNode(m,!0),f.nodeType===xe.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?o=f:o.appendChild(f),Xt(f);else{if(!Ie&&!Te&&!we&&m.indexOf("<")===-1)return M&&ot?y(m):m;if(o=yn(m),!o)return Ie?null:ot?Y:""}o&&st&&je(o.firstChild);const J=Tn(I?m:o);try{for(;b=J.nextNode();)En(b),wn(b),dt(b.content)&&Ht(b.content)}catch(ge){throw I&&bn(m),ge}if(I)return wt(t.removed,ge=>{ge.element&&ur(ge.element)}),Te&&Vt(m),m;if(Ie){if(Te&&Vt(o),We)for(R=fe.call(o.ownerDocument);o.firstChild;)R.appendChild(o.firstChild);else R=o;return(B.shadowroot||B.shadowrootmode)&&(R=Oe.call(a,R,!0)),R}let K=we?o.outerHTML:o.innerHTML;return we&&D["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&ne(Xs,o.ownerDocument.doctype.name)&&(K="<!DOCTYPE "+o.ownerDocument.doctype.name+`>
|
|
92
|
-
`+K),Te&&(K=Ut(K)),M&&ot?y(K):K},t.setConfig=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};oe(m),rt=!0,Be=D,Me=B},t.clearConfig=function(){c=null,rt=!1,Be=null,Me=null,M=de,Y=""},t.isValidAttribute=function(m,n,o){c||oe({});const f=W(m),b=W(n);return An(f,b,o)},t.addHook=function(m,n){typeof n=="function"&&Q(P,m)&&ft(P[m],n)},t.removeHook=function(m,n){if(Q(P,m)){if(n!==void 0){const o=Os(P[m],n);return o===-1?void 0:Ls(P[m],o,1)[0]}return Mn(P[m])}},t.removeHooks=function(m){Q(P,m)&&(P[m]=[])},t.removeAllHooks=function(){P=Yn()},t}var Gt=sr();const ro=["a","b","br","div","em","i","li","ol","p","s","span","strong","u","ul"];function so(e){e.hasAttribute("href")&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"))}function oo(e){Gt.addHook("afterSanitizeAttributes",so);const t=Gt.sanitize(e,{ALLOWED_TAGS:[...ro]});return Gt.removeHook("afterSanitizeAttributes"),t}function ao(e){return Gt.sanitize(e,{ALLOWED_TAGS:[]})}class pn extends Error{constructor(t,r){super(`HTTP ${t}: ${r}`),this.name="HttpError",this.status=t,this.statusText=r}}async function or(e,t,r,a={}){const{authorizationToken:u,headers:i,...d}=a,h=await fetch(t,{method:e,headers:{"Content-Type":"application/json",...u&&{Authorization:`Bearer ${u}`},...i},body:r!==void 0?JSON.stringify(r):void 0,...d});if(!h.ok)throw new pn(h.status,h.statusText);return h.json()}const ar=(e,t,r,a)=>or("GET",e,void 0,{signal:r,authorizationToken:a}),mn=(e,t,r={})=>or("POST",e,t,r);function un(e){if(e==="")return"";try{const t=JSON.parse(e);return typeof t=="string"?t:String(t??"")}catch{return e}}function io(e){return e.includes("/chat/agent-completions")}function ir(e){return/\/conversations(?:\/|$)/.test(e.replace(/\?.*$/,""))}const Rt={model:"gpt-4o-mini",agentName:"Group_Ask_Arbor_Agent",systemPrompt:"You are a helpful AI assistant for Arbor Education group MIS users.",modelKwargs:{temperature:1,top_p:1},mcps:[{server:"statsapi",tools:["*"]},{server:"arbormis",tools:["create_pdf","academic_date_range_finder"]}]},dn="user",co="assistant",lo="system";function uo({chatId:e,userMessage:t,chatHistory:r=[],config:a={}}){const u=a.model??Rt.model,i=a.agentName??Rt.agentName,d=a.systemPrompt??Rt.systemPrompt,h=a.modelKwargs??Rt.modelKwargs,_=a.mcps??[...Rt.mcps],p=!e&&r.length===0,S={messages:p?[{role:lo,content:d},{role:dn,content:t}]:[{role:dn,content:t}],model:u,model_kwargs:h,mcps:_,meta:{feature_id:i,source:"ask-arbor-standalone"},moderation_enabled:!0};return e&&(S.chat_id=e),p&&(S.auto_title=!1),S}function fo(e){const t=e.trim();if(!t.startsWith("data:"))return null;const r=t.slice(5).trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}async function po(e){var p,E,S;if((e.headers.get("content-type")??"").includes("application/json")){const A=(p=(await e.json()).items)==null?void 0:p[0];return A?{text:A.text??A.content??"",chatId:A.chatId,messageId:A.id}:null}const r=(E=e.body)==null?void 0:E.getReader();if(!r)return null;const a=new TextDecoder;let u="",i="",d,h=`agent-${Date.now()}`,_=!1;for(;;){const{done:g,value:A}=await r.read();if(g)break;u+=a.decode(A,{stream:!0});const x=u.split(`
|
|
93
|
-
`);u=x.pop()??"";for(const L of x){const N=L.trim();if(N==="event: error"){_=!0;continue}const w=fo(N);if(!w)continue;if(w.error||_)throw new Error(w.message_text??(typeof w.message=="string"?w.message:"Agent completion stream failed"));_=!1,w.chat_id&&(d=w.chat_id),w.event_id&&(h=w.event_id),w.client_message_id&&(h=w.client_message_id);const j=(S=w.message)==null?void 0:S.content;j&&(i=w.is_final?j:i+j)}}return i?{text:i,chatId:d,messageId:h}:null}async function mo({chatUrl:e,chatId:t,userMessage:r,chatHistory:a,authorizationToken:u,config:i}){const d=uo({chatId:t,userMessage:r,chatHistory:a,config:i}),h=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...u&&{Authorization:`Bearer ${u}`},"X-Trace-Id":crypto.randomUUID()},body:JSON.stringify(d)});if(!h.ok)throw new pn(h.status,h.statusText);return po(h)}function ho(e){switch(e){case 401:return{text:ns,type:Ae};case 403:return{text:rs,type:Ae};case 404:return{text:ss,type:Ae};case 408:case 504:return{text:os,type:Ct};case 429:return{text:as,type:Ct};default:return e>=500?{text:is,type:Ae}:{text:er,type:Ae}}}function _o(e){return e instanceof pn?ho(e.status):e instanceof TypeError?{text:cs,type:Ae}:{text:er,type:Ae}}const go=55e3,fn="fallback",bo=async({chatId:e=void 0,chatUrl:t,userMessage:r,userInputDeviceLastUsed:a,chatHistory:u,canvasHistory:i,authorizationToken:d,agentCompletionsConfig:h})=>{let _;try{if(io(t)){const N=await mo({chatUrl:t,chatId:e,userMessage:r,chatHistory:u,authorizationToken:d,config:h});return N?{text:N.text,id:N.messageId,...N.chatId!=null&&{chatId:N.chatId},type:mt}:null}const g={chatId:e,userMessage:r,userInputDeviceLastUsed:a,chatHistory:u,canvasHistory:i},A=new AbortController,x=mn(t,g,{authorizationToken:d,signal:A.signal}),L=new Promise(N=>setTimeout(()=>{A.abort(),N({items:[{id:fn,hardStopped:!0,type:Bt}]})},go));_=await Promise.race([x,L])}catch(g){console.error("Error in getNewAgentMessage",g);const{text:A,type:x}=_o(g);return{text:A,type:x,id:crypto.randomUUID()}}const p=_.items[0];if(!p)return null;const E=p.text!=null&&p.text!==""?p.text:un(typeof p.content=="string"?p.content:"");return{text:typeof E=="string"?E:"",id:p.id,...p.chatId!=null&&{chatId:p.chatId},...p.timedOut!=null&&{timedOut:p.timedOut},...p.deferred!=null&&{deferred:p.deferred},...p.hardStopped!=null&&{hardStopped:p.hardStopped},type:p.type,...p.element!=null&&{element:p.element},...p.followUpPrompts!=null&&{followUpPrompts:p.followUpPrompts}}},yo=e=>new Date(e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),To=[{field:"title",headerName:"Conversation",flex:1},{field:"updatedAt",headerName:"Last Conversation",width:140,valueFormatter:({value:e})=>yo(e)}],Eo={sortable:!1,filter:!1,resizable:!1,editable:!1,suppressHeaderMenuButton:!0},Ao=e=>{for(let t=e.length-1;t>=0;t-=1){const r=e[t];if(r.type===mt)return r.followUpPrompts??null}return null},So=(e,t,r)=>{if(r)return e!==null&&e.length>0?e:e===null?null:t.followUpPrompts},an="NONE",wo="KEYBOARD",No="VOICE",xo="MIXED",Ro=2e4,ko=15,Co=(e,t)=>new Promise(r=>{if(t!=null&&t.aborted){r(!1);return}const a=setTimeout(()=>{t==null||t.removeEventListener("abort",u),r(!0)},e),u=()=>{clearTimeout(a),r(!1)};t==null||t.addEventListener("abort",u)}),hn=({title:e,connector:t,newChatUrl:r,lockConversation:a=!1,messageLimit:u,chatId:i,speechEnabled:d=!0,speechLanguage:h="en-GB",speechSubmissionDelay:_=1e3,chatHistory:p,canvasHistory:E,refreshAgentMessages:S,startQuery:g,slashMenuItems:A,menuContent:x,samplePrompts:L,dailyPrompt:N,prompts:w,promptLibrary:j,placeholder:ue="Explain what you need in your own words...",introHeading:U="Get instant answers from your MIS",introBody:$="Type a question about your students, staff or school and get the answer in seconds. No reports to run, no clicking around - just ask!",onClose:M,onNavigate:Y,onRatingPopupOpen:de,focusDelay:V})=>{const F=(()=>{if(j&&j.length>0)return j;if(!w||w.trim()==="")return[];try{const c=JSON.parse(w);return Array.isArray(c)&&c.length>0?c:[]}catch{return[]}})(),ce=l.useRef(!1),y=c=>{ce.current=c},v=ys(),H=l.useRef(null),ee=l.useRef(null),O=l.useRef(null),z=l.useRef(null),fe=l.useRef(null),Ce=l.useRef(null),[Oe,P]=l.useState(()=>i?"":g??""),[te,ht]=l.useState(i),[X,_t]=l.useState([]),[$t,Je]=l.useState([]),Qe=c=>{(!ce.current||c.id==="DEEP_THINKING_MESSAGE")&&_t(T=>[...T,c])},[He,Le]=l.useState(!1),[D,et]=l.useState(!1),[B,tt]=l.useState(!1),G=l.useRef(!1),Se=l.useRef(null),gt=l.useRef(!1),[ye,It]=l.useState(!1),[ze,nt]=l.useState(an),[De,Te]=l.useState(!1),[Ge,we]=l.useState(!0),[rt,Be]=l.useState(!1),[Me,st]=l.useState("getting-started"),[Ie,We]=l.useState([]),[ot,bt]=l.useState(!1),$e=Es(u,0),at=$e>0&&X.length>=$e,yt=He||D;bs(()=>{if(!!(g!=null&&g.trim())&&!i||V==null&&!g)return;const T=setTimeout(()=>{var k;(k=H.current)==null||k.focus()},V??0);return()=>clearTimeout(T)});const[it,Pe]=l.useState(!1),me=!window.webkitSpeechRecognition&&!window.SpeechRecognition,Ye=typeof navigator<"u"&&navigator.userAgent.toLowerCase().includes("firefox"),vt=async()=>{let c=!1;if(navigator.permissions)try{c=(await navigator.permissions.query({name:"microphone"})).state==="denied"}catch(T){console.warn("Could not check microphone permission:",T)}return!d||me||Ye||c};l.useEffect(()=>{(async()=>{const T=await vt();Pe(T)})()},[d,De]),l.useEffect(()=>{p&&p.length>0&&(_t(p),Je(Ao(p)))},[p]);const Ke=async(c=te)=>{if(!t.canLoadHistory||!c)return;et(!0);const T=await t.loadHistory(c);if(v.current){if(JSON.stringify(T)===JSON.stringify(X)||!T){et(!1);return}return T.chatItems.length>0&&_t(T.chatItems),Je(T.followUpPrompts),et(!1),It(!0),T}};l.useEffect(()=>{S&&!ce.current&&Ke()},[S]),l.useEffect(()=>{v.current&&t.canLoadHistory&&i&&(ye||Ke(i))},[i,t.canLoadHistory,ye]),l.useLayoutEffect(()=>{O.current&&O.current.scrollTo({top:O.current.scrollHeight,behavior:"smooth"})},[X]);const Tt=c=>{const T=Ss(c),k=/\['Canvas_Element_ID'\s*:\s*'([^']+)',\s*'Title'\s*:\s*'([^']+)'\]/g;return T.replace(k,(oe,_e,le)=>`<span class="chat-panel__message-tag">@${le}</span>`)},Ot=async({maxAttempts:c=6,chatIdToFetch:T,signal:k}={})=>{const oe=new Set(X.map(({id:Pt})=>Pt));let _e=0,le;for(;_e<c;){if(k!=null&&k.aborted||!await Co(Ro,k)||(le=await Ke(T),k!=null&&k.aborted))return;if(((le==null?void 0:le.chatItems)||[]).some(jt=>jt.type!==Ze&&!oe.has(jt.id)))break;_e++}if(Number.isFinite(c)&&_e>=c){Qe({text:ls,id:fn,type:Ae});return}return le},Ne=()=>{setTimeout(()=>{var c;(c=H.current)==null||c.focus()},0)},ct=async c=>{Je(null),Le(!0);const T=await t.sendMessage({chatId:te,userMessage:c,userInputDeviceLastUsed:ze,chatHistory:X,canvasHistory:E});if(!T){Le(!1),Ne();return}if(T.deferred===!0){T.chatId&&ht(T.chatId);const k=T.chatId||te;Se.current=new AbortController;try{await Ot({maxAttempts:ko,chatIdToFetch:k,signal:Se.current.signal})}finally{Se.current=null}v.current&&(Le(!1),Ne());return}if(T.hardStopped===!0){!G.current&&t.canSendNotification&&te&&await t.sendNotification({chatId:te})&&(G.current=!0),v.current&&(tt(!0),Le(!1),Ne());return}Qe({text:oo(T.text),type:T.type,id:T.id,...T.element!=null&&{element:T.element}}),T.chatId&&ht(T.chatId),Je(T.followUpPrompts??null),Le(!1),Ne()},Z=async({prompt:c=null,allowDoubleMessage:T=!1}={})=>{var _e;let k=null;if(c!=null&&c.trim()!==""&&(k=c.trim()),k===null&&(k=ao(Oe).trim()),!k||He||D)return;const oe=X.slice().reverse().find(le=>le.type===Ze);if(!T&&oe&&oe.text===k){console.warn("Duplicate message detected, not adding:",k);return}(_e=Ce.current)==null||_e.cancel(),he(),tt(!1),G.current=!1,Qe({type:Ze,text:k,id:Ts()}),P(""),Ne(),y(!1),await ct(k),nt(an)};l.useEffect(()=>{if(gt.current||!(g!=null&&g.trim())||i)return;gt.current=!0;const c=setTimeout(()=>{Z({prompt:g})},V??0);return()=>clearTimeout(c)},[]);const he=()=>{fe.current&&(fe.current.stop(),fe.current=null),Te(!1),z.current&&(clearTimeout(z.current),z.current=null)},lt=Tr(c=>{he(),c.trim().length>0&&Ge&&Z()},_);Ce.current=lt;const ut=c=>{if(ze===an){nt(c);return}if(ze!==c){nt(xo);return}},Yt=()=>{if(He||D)return;ut(No),we(!0);const c=new window.webkitSpeechRecognition;fe.current=c,c.continuous=!0,c.interimResults=!0,c.lang=h,c.start(),c.onstart=()=>{Te(!0)},c.onresult=T=>{const k=Array.from(T.results).map(oe=>oe[0]).map(oe=>oe.transcript).join("");k!==Oe&&P(k),lt(k)},c.onerror=()=>{he()}},Lt=()=>{De?he():Yt()},Et=!D&&!He&&Oe.trim().length>0;l.useEffect(()=>()=>{var c;(c=Se.current)==null||c.abort()},[]),l.useEffect(()=>{if(!t.canListInteractions)return;let c=!1;return bt(!0),t.listInteractions().then(T=>{c||We(T??[])}).catch(()=>{c||We([])}).finally(()=>{c||bt(!1)}),()=>{c=!0}},[t]);const Dt=()=>A!=null&&A.length?A.map(c=>{let T=c.url;return te&&T.includes("/chat-id/")&&(T.match(/\/chat-id\/[^/]+$/)||(T=`${T}${te}`)),{reference:c.label,description:c.label,link:T,icon:c.icon}}):[],At=c=>{c.key!=="Enter"&&(ut(wo),De&&we(!1),c.key==="/"&&Oe.length===0&&(A!=null&&A.length)&&(Be(!0),c.preventDefault())),c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),Et&&Z({allowDoubleMessage:!0})),c.key==="Escape"&&rt&&Be(!1)},Kt=()=>{Be(!1),setTimeout(()=>{var c;(c=H.current)==null||c.focus()},0)},qe=l.useCallback(c=>{P(c),setTimeout(()=>{H.current&&(H.current.focus(),H.current.selectionStart=H.current.value.length,H.current.selectionEnd=H.current.value.length)},0)},[]),qt=l.useCallback(async()=>!t.canSendNotification||!te?!1:t.sendNotification({chatId:te}),[te,t]),Mt=l.useCallback(()=>{tt(!1),M==null||M()},[M]),W=l.useCallback((c,T)=>{te&&t.rateMessage({rating:c,messageId:T,chatId:te})},[te,t]);return s.jsxs("section",{"aria-label":e?`Chat Panel: ${e}`:"Chat Panel",className:"chat-panel",children:[r&&X.length>0&&s.jsx("section",{className:"chat-panel__active-chat-header",children:s.jsx("a",{href:r,className:"chat-panel__new-chat-button",onClick:c=>{Y&&(c.preventDefault(),Y(r))},children:"New"})}),(X.length>0||!a&&!at)&&s.jsxs("div",{className:pe("chat-panel__body",{"chat-panel__body--no-messages":X.length===0}),children:[X.length>0&&s.jsxs("div",{className:"chat-panel__message-list-wrapper",children:[s.jsxs("ul",{className:"chat-panel-message-list",ref:O,children:[X.map((c,T)=>{const k=T===X.length-1,oe=So($t,c,k),_e=c.id===fn,le=k;return s.jsx(ts,{id:c.id,type:c.type,text:c.text,chatId:te,onRate:t.canRate?W:void 0,ratingPopupUrls:t.ratingPopupUrls,showRating:le,followUpPrompts:oe,onFollowUpPromptClick:qe,processCanvasReferences:Tt,isFallbackMessage:_e,onRatingPopupOpen:de},`${c.id}_${T}`)}),yt&&s.jsx(gs,{showNotifyLaterButton:t.canSendNotification&&!!te,onNotifyLater:qt,onNotificationRegisteredGotIt:Mt}),B&&s.jsx("li",{className:"chat-panel__hard-stop-banner","data-testid":"hard-stop-banner",children:s.jsxs("div",{className:"chat-panel__notify-later",children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"This one's taking longer than usual. We'll notify you in the notifications panel on the left of your MIS when it's done."}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:Mt,"aria-label":"Got it",children:"Got it"})]})})]}),$e>0&&X.length>0&&s.jsxs("div",{className:"chat-panel__message-limit",children:[X.length," ","/",$e]})]}),!a&&!at&&s.jsxs(s.Fragment,{children:[X.length===0&&!D&&s.jsxs("div",{className:"chat-panel__chat-intro",children:[s.jsxs("div",{className:"chat-panel__chat-intro-frame",children:[s.jsx("span",{className:"chat-panel__chat-intro-icon",children:s.jsx(Er,{})}),s.jsx("h3",{className:"chat-panel__chat-intro-heading",children:U})]}),s.jsx("p",{className:"chat-panel__chat-intro-body",children:$})]}),s.jsx("div",{className:"chat-panel__input-container",children:s.jsxs("div",{className:"chat-panel__input-wrapper",ref:ee,children:[rt&&s.jsx(tr,{anchorRef:ee,menuItems:Dt(),onClose:Kt,onNavigate:Y}),s.jsx(Jn,{ref:H,value:Oe,onChange:P,onKeyDown:At,placeholder:ue,onSubmit:()=>{Oe.trim()&&Z({allowDoubleMessage:!0})},onMicClick:Lt,onStopClick:()=>{De&&he()},isProcessing:He,speechEngaged:De,showMicButton:!it&&d&&!Ye,ariaLabel:"Chat panel input",menuContent:x,onNavigate:Y,showDisclaimer:X.length>0})]})})]})]}),X.length===0&&s.jsxs(s.Fragment,{children:[it&&s.jsx("div",{className:"chat-panel__speech-disabled-wrapper",children:Ye?s.jsxs(s.Fragment,{children:[" ","Speech isn't supported in Firefox. To enable speech, please use Google Chrome."]}):s.jsx(s.Fragment,{children:" To use speech, please allow Arbor to use your microphone."})}),s.jsxs(be.Tabs,{className:"chat-panel__tabs",children:[s.jsx(be.Tabs.Item,{active:Me==="getting-started",tabElementProps:{onClick:()=>st("getting-started")},children:"Getting started"}),s.jsx(be.Tabs.Item,{active:Me==="recent",tabElementProps:{onClick:()=>st("recent")},children:"Recent"})]}),s.jsxs("div",{className:"chat-panel__tab-content",children:[Me==="getting-started"&&s.jsxs(s.Fragment,{children:[F.length>0&&s.jsx("div",{className:"chat-panel__sample-prompt-container",children:s.jsx(wr,{onSelectPrompt:c=>{Z({prompt:c,allowDoubleMessage:!0})},onPromptHover:c=>{c!=null&&P(c)},categories:F})}),(L&&L.length>0&&F.length===0||!!(N!=null&&N.trim()))&&s.jsxs("div",{className:"chat-panel__sample-prompt-container",children:[L==null?void 0:L.map((c,T)=>s.jsx("button",{type:"button",className:"chat-panel__sample-prompt",onClick:()=>Z({prompt:c,allowDoubleMessage:!0}),children:c},`sample-${T}`)),N&&s.jsx("button",{type:"button",className:"chat-panel__daily-prompt",onClick:()=>Z({prompt:N,allowDoubleMessage:!0}),children:s.jsxs("span",{children:["✨"," ",s.jsx("strong",{children:"Daily Prompt:"}),s.jsx("br",{}),N]})},"daily-prompt")]})]}),Me==="recent"&&s.jsx("div",{className:"chat-panel__tab-panel--recent",children:ot?s.jsx("div",{className:"chat-panel__ai-interactions-loading",children:"Loading..."}):Ie.length===0?s.jsx("div",{className:"chat-panel__ai-interactions-empty",children:"No previous chats found."}):s.jsx(be.Table,{wrapperClassName:"chat-panel__ai-interactions-table",hasSearch:!1,tableTheme:"tidy",domLayout:"autoHeight",rowData:Ie,columnDefs:To,defaultColDef:Eo,getRowId:({data:c})=>c.id,onRowClicked:({data:c})=>{!c||!t.canLoadHistory||(ht(c.chatId),Ke(c.chatId))}})})]})]}),at&&s.jsx("div",{className:"chat-panel-footer",children:"You've reached the maximum number of messages for this conversation"})]})};class Io{constructor(){Nn(this,"events");this.events={}}subscribe(t,r){const a=crypto.randomUUID();return this.events[t]=this.events[t]??{},this.events[t][a]=r,a}unsubscribe(t,r){typeof this.events[t]<"u"&&delete this.events[t][r]}publish(t,r){this.events[t]&&Object.keys(this.events[t]).forEach(a=>{const u=this.events[t][a];u==null||u(r)})}}const Kn=new Io;function vo({isOpen:e,...t}){const{onClose:r}=t;return l.useEffect(()=>{const a=Kn.subscribe("ds-remove-slideover",()=>r==null?void 0:r());return()=>Kn.unsubscribe("ds-remove-slideover",a)},[r]),e?qn.createPortal(s.jsx(be.Slideover,{children:s.jsx("div",{className:"ask-arbor-widget__panel",children:s.jsx(hn,{...t,focusDelay:200})})}),document.body):null}function Oo(e){switch(e.toLowerCase()){case dn:return Ze;case co:return mt;default:return null}}function Lo(e){const t=[];for(const r of e.messages??[]){const a=Oo(r.role);!a||!r.content||t.push({id:r.message_id,type:a,text:r.content})}return{chatItems:t,followUpPrompts:[]}}const Do=async(e,t)=>{try{const r=await ar(e,void 0,void 0,t);if(ir(e)&&Array.isArray(r==null?void 0:r.messages))return Lo(r);if(!(r!=null&&r.items))return console.error("Invalid response in getHistoricMessages",e,r),{chatItems:[],followUpPrompts:[]};let a=[],u=[];return r.items.forEach(i=>{if("chatItems"in i)a=i.chatItems.map(({id:d,type:h,text:_,content:p,...E})=>{const S=_!=null&&_!==""?_:un(typeof p=="string"?p:"");return{id:d,type:h.toUpperCase(),text:S,...E.element!=null&&{element:E.element}}});else if("id"in i&&"type"in i){const d=i.text!=null&&i.text!==""?i.text:un(typeof i.content=="string"?i.content:"");a.push({id:i.id,type:i.type.toUpperCase(),text:d,...i.element!=null&&{element:i.element}})}"followUpPrompts"in i&&(u=i.followUpPrompts||[])}),{chatItems:a,followUpPrompts:u}}catch(r){return console.error("Error in getHistoricMessages",r,e),{chatItems:[],followUpPrompts:[]}}},Mo=async({rating:e,messageId:t,chatId:r,ratingUrl:a,authorizationToken:u})=>{try{await mn(a,{messageId:t,rating:e,chatId:r},{authorizationToken:u})}catch(i){console.error("Error rating message",i)}},Po=async({chatId:e,notificationCallbackUrl:t,authorizationToken:r})=>{try{return await mn(t,{chatId:e},{authorizationToken:r}),!0}catch(a){return console.error("Error sending notification",a),!1}};function jo(e){return(e.conversations??[]).map(t=>{var r,a;return{id:t.session_id,chatId:t.session_id,title:((r=t.title)==null?void 0:r.trim())||((a=t.preview)==null?void 0:a.trim())||"Untitled conversation",updatedAt:t.updated_at??t.created_at??""}})}class cr{constructor(t){this.config=t}get canRate(){return!!this.config.ratingUrl}get canLoadHistory(){return!!this.config.historicChatUrl}get canListInteractions(){return!!this.config.aiInteractionsUrl}get canSendNotification(){return!!this.config.notificationCallbackUrl}get ratingPopupUrls(){return{up:this.config.upRatingPopupUrl,down:this.config.downRatingPopupUrl}}async sendMessage(t){return bo({chatUrl:this.config.chatUrl,authorizationToken:this.config.authorizationToken,agentCompletionsConfig:this.config.agentCompletionsConfig,...t})}async loadHistory(t){return this.config.historicChatUrl?Do(`${this.config.historicChatUrl}/${t}`,this.config.authorizationToken):null}async listInteractions(){if(!this.config.aiInteractionsUrl)return null;try{const t=await ar(this.config.aiInteractionsUrl,void 0,void 0,this.config.authorizationToken);return ir(this.config.aiInteractionsUrl)&&Array.isArray(t.conversations)?jo(t):Array.isArray(t)?t:Array.isArray(t.items)?t.items:[]}catch{return null}}async rateMessage(t){this.config.ratingUrl&&await Mo({ratingUrl:this.config.ratingUrl,authorizationToken:this.config.authorizationToken,...t})}async sendNotification(t){return this.config.notificationCallbackUrl?Po({notificationCallbackUrl:this.config.notificationCallbackUrl,authorizationToken:this.config.authorizationToken,...t}):!1}}const Uo={create(e){const t=e.model||e.agentName||e.systemPrompt||e.mcps?{...e.model&&{model:e.model},...e.agentName&&{agentName:e.agentName},...e.systemPrompt&&{systemPrompt:e.systemPrompt},...e.mcps&&{mcps:e.mcps}}:void 0;return new cr({chatUrl:e.chatUrl,authorizationToken:e.authorizationToken??void 0,historicChatUrl:e.historicChatUrl??void 0,aiInteractionsUrl:e.aiInteractionsUrl??void 0,ratingUrl:e.ratingUrl??void 0,upRatingPopupUrl:e.upRatingPopupUrl??void 0,downRatingPopupUrl:e.downRatingPopupUrl??void 0,notificationCallbackUrl:e.notificationCallbackUrl??void 0,agentCompletionsConfig:t})}};exports.AIServiceConnectorFactory=Uo;exports.AskArborSlideover=vo;exports.AskArborWidget=hn;exports.CHAT_RESPONSE_TYPE_AGENT=mt;exports.CHAT_RESPONSE_TYPE_ERROR=Ae;exports.CHAT_RESPONSE_TYPE_INFO=Bt;exports.CHAT_RESPONSE_TYPE_USER=Ze;exports.CHAT_RESPONSE_TYPE_WARNING=Ct;exports.ChatPanel=hn;exports.FollowUpPromptButton=Qn;exports.HttpAIServiceConnector=cr;
|
|
70
|
+
*/const ls=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],us=Tt("x",ls),yt="AGENT",ot="USER",qt="INFO",Pt="WARNING",Oe="ERROR",on="up",Ln="down",Dn=10,ds=({message:e,onRate:t,upRatingPopupUrl:r,downRatingPopupUrl:o,onRatingPopupOpen:c})=>{const[i,d]=l.useState(null),_=g=>{const h=g===on?r:o;h!=null&&h.trim()&&(c?c(h.trim()):window.open(h.trim(),"_blank","noopener,noreferrer"))},m=g=>{d(g),t(g),_(g)};return s.jsxs("div",{className:"chat-message__feedback",children:[s.jsx("span",{className:"chat-message__feedback-question",children:"How did Ask Arbor do?"}),s.jsxs("div",{className:"chat-message__feedback-buttons",children:[s.jsxs("button",{type:"button","aria-label":"Rate message as good response",title:"Good response",className:ye("chat-message__feedback-button","chat-message__feedback-button--up",{"chat-message__feedback-button--selected":i===on}),onClick:()=>m(on),children:[s.jsx(as,{size:Dn,strokeWidth:1.5,className:"chat-message__feedback-button-icon","aria-hidden":!0}),s.jsx("span",{className:"chat-message__feedback-button-text",children:"Nailed it"})]}),s.jsxs("button",{type:"button","aria-label":"Rate message as bad response",title:"Bad response",className:ye("chat-message__feedback-button","chat-message__feedback-button--down",{"chat-message__feedback-button--selected":i===Ln}),onClick:()=>m(Ln),children:[s.jsx(ns,{size:Dn,strokeWidth:1.5,className:"chat-message__feedback-button-icon","aria-hidden":!0}),s.jsx("span",{className:"chat-message__feedback-button-text",children:"Missed the mark"})]})]})]})},fs=se.Button,ir=({prompt:e,onClick:t})=>s.jsx(fs,{type:"button",variant:"secondary",size:"S",onClick:()=>t(e),children:e}),ps=({id:e,text:t,type:r,onRate:o,ratingPopupUrls:c={},chatId:i,showRating:d=!1,followUpPrompts:_,onFollowUpPromptClick:m,processCanvasReferences:g,isFallbackMessage:h,onRatingPopupOpen:w,children:T})=>{const S=r===yt,k=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:ye("chat-message",{"chat-message--user":r===ot,"chat-message--agent":r===yt,"chat-message--info":r===qt,"chat-message--error":r===Oe,"chat-message--warning":r===Pt}),children:[r===qt&&s.jsx(ss,{className:"chat-message__icon","aria-label":"Information",size:20}),r===Pt&&s.jsx(cs,{className:"chat-message__icon","aria-label":"Warning",size:20}),r===Oe&&s.jsx(es,{className:"chat-message__icon","aria-label":"Error",size:20}),T??s.jsx("span",{dangerouslySetInnerHTML:{__html:g(t)}})]}),S&&s.jsxs("div",{className:"chat-message__footer-actions",children:[s.jsx("div",{className:"chat-message__footer-icons",children:d&&o&&i&&s.jsx(ds,{upRatingPopupUrl:c.up,downRatingPopupUrl:c.down,message:{id:e,type:r,text:t},onRate:M=>o(M,e),onRatingPopupOpen:w})}),s.jsx("div",{className:"chat-message__follow-up-prompts",children:_&&_.length>0&&!h&&s.jsx("ul",{className:"chat-message__follow-up-prompts-list",children:_.map((M,N)=>s.jsx("li",{children:s.jsx(ir,{prompt:M,onClick:A=>m==null?void 0:m(A)})},`follow-up-prompt-${N}`))})})]})]});return s.jsx("li",{className:ye("chat-message-container",{"chat-message-container--user":r===ot,"chat-message-container--agent":S}),children:S?s.jsx("div",{className:"chat-message-container__content",children:k}):k})},ms="Not authorised. Your session could have expired or is invalid. Please refresh the page and try again.",hs="You do not have permission to use this feature. Please contact your administrator if you need access.",_s="The chat service could not be found. Please check your configuration and try again.",gs="It looks like this request took too long to complete. Please try again.",bs="Whoops! Too many requests. Please wait a moment and try again.",ys="The chat service is temporarily unavailable. Please try again later.",Ts="Unable to reach the chat service. Please check your connection and try again.",cr="Something went wrong. Please try again later.",Es="Something went wrong while trying to get a new agent message. Please try again later.",Mn="keyboard-shortcut-menu-portal";function Ss(){let e=document.getElementById(Mn);return e||(e=document.createElement("div"),e.id=Mn,e.style.cssText="position:fixed;left:0;top:0;z-index:19950;pointer-events:none;",document.body.appendChild(e)),e}const Vt=200;function As(e){const t=window.innerHeight,r=e.top+e.height>t-Vt,o=e.top<Vt;return r?"above":o?"below":"above"}function ws(e){const t=As(e),r=8;return t==="below"?{left:e.left,width:e.width,top:e.bottom+r,placement:"below"}:{left:e.left,width:e.width,bottom:window.innerHeight-e.top+r,placement:"above"}}function jn(e,t){if(t){t(e);return}/^https?:\/\//.test(e)?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e}const xs=({anchorRef:e,...t})=>{const[r,o]=l.useState(null);if(l.useLayoutEffect(()=>{const i=()=>{const g=e.current;if(!g)return;const h=g.getBoundingClientRect();o(ws(h))};i();const d=requestAnimationFrame(()=>i()),_=()=>i(),m=()=>i();return document.addEventListener("scroll",_,!0),window.addEventListener("resize",m),()=>{cancelAnimationFrame(d),document.removeEventListener("scroll",_,!0),window.removeEventListener("resize",m)}},[e]),!r)return null;const c={position:"fixed",left:r.left,width:r.width,pointerEvents:"auto"};return r.placement==="below"?c.top=r.top:c.bottom=r.bottom,er.createPortal(s.jsx(lr,{...t,portalStyle:c}),Ss())},lr=e=>{const{menuItems:t=[],onSelectItem:r,onClose:o,hideReferenceFromList:c=!1,anchorRef:i,portalStyle:d,onNavigate:_}=e,[m,g]=l.useState(0),[h,w]=l.useState(""),[T,S]=l.useState(t),k=l.useRef(null),M=l.useRef(null),N=l.useRef(null),[A,U]=l.useState(!1),[de,$]=l.useState(!1),G=d?d.top!=null:A,z=d?!0:de;l.useEffect(()=>{g(0),w("")},[]),l.useEffect(()=>{d&&setTimeout(()=>{var y;return(y=N.current)==null?void 0:y.focus()},0)},[d]),l.useEffect(()=>{if(d||i||!k.current)return;const y=k.current.getBoundingClientRect(),O=window.innerHeight,K=y.top,te=K+y.height>O-Vt,L=K<Vt;U(te?!1:!!L),$(!0),setTimeout(()=>{var C;return(C=N.current)==null?void 0:C.focus()},0)},[i]),l.useEffect(()=>{if(M.current){const y=M.current.querySelector(".keyboard-shortcut-menu__items"),O=y==null?void 0:y.querySelector(".keyboard-shortcut-menu__item--selected");O&&O.scrollIntoView({behavior:"smooth",block:"nearest"})}},[m]),l.useEffect(()=>{S(h?t.filter(y=>y.reference.toLowerCase().includes(h.toLowerCase())||y.description.toLowerCase().includes(h.toLowerCase())):t)},[h,t]);const X=y=>{var O;r&&T[y]&&!T[y].link&&r(T[y]),o&&!((O=T[y])!=null&&O.link)&&o()};l.useEffect(()=>{const y=K=>{K.key==="Escape"&&o&&(K.preventDefault(),o())},O=K=>{k.current&&!k.current.contains(K.target)&&o&&o()};return document.addEventListener("keydown",y),document.addEventListener("mousedown",O),()=>{document.removeEventListener("keydown",y),document.removeEventListener("mousedown",O)}},[o]);const fe=y=>{switch(y.key){case"ArrowDown":y.preventDefault(),g(O=>O<T.length-1?O+1:O);break;case"ArrowUp":y.preventDefault(),g(O=>O>0?O-1:0);break;case"Enter":y.preventDefault(),T[m]&&(T[m].link?jn(T[m].link.replace(/\/\?/g,""),_):X(m));break;case"Escape":y.preventDefault(),o&&o();break}},oe=y=>{w(y),g(0)},B=(y,O)=>{const K=O===m,te=y.icon?s.jsxs(s.Fragment,{children:[s.jsx(se.Icon,{name:y.icon,size:12}),s.jsx("span",{className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-main",children:y.description})]}):s.jsx(s.Fragment,{children:c?s.jsx("span",{"data-testid":"keyboard-shortcut-menu-item",className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-main",children:y.description}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"keyboard-shortcut-menu__item-reference keyboard-shortcut-menu__item-main",children:y.reference}),s.jsx("span",{className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-secondary",children:y.description})]})});if(y.link){const L=y.link.replace(/\/\?/g,"");return s.jsx("li",{role:"menuitem",children:s.jsx("a",{href:L,className:ye("keyboard-shortcut-menu__item-main keyboard-shortcut-menu__item",{"keyboard-shortcut-menu__item--selected":K,"keyboard-shortcut-menu__item--with-icon":!!y.icon}),onClick:C=>{C.preventDefault(),jn(L,_),o==null||o()},children:te})},y.reference)}return s.jsx("li",{role:"menuitem",className:ye("keyboard-shortcut-menu__item",{"keyboard-shortcut-menu__item--selected":K,"keyboard-shortcut-menu__item--with-icon":!!y.icon}),onClick:()=>{r&&r(y),o&&o()},"aria-selected":K,children:te},y.reference)},Ae=s.jsx("div",{className:ye("keyboard-shortcut-menu",{"keyboard-shortcut-menu-below":G,"keyboard-shortcut-menu-hidden":!z}),onKeyDown:fe,tabIndex:0,"aria-label":"Keyboard shortcut menu","data-testid":"keyboard-shortcut-menu",ref:k,children:s.jsxs("div",{className:"keyboard-shortcut-menu__content",ref:M,children:[s.jsxs("div",{className:"keyboard-shortcut-menu__header",children:[s.jsx("div",{className:"keyboard-shortcut-menu__search",children:s.jsx("input",{type:"text",value:h,onChange:y=>oe(y.target.value),placeholder:"Search...",autoFocus:!0,ref:N})}),o&&s.jsx("button",{type:"button",className:"keyboard-shortcut-menu__close",onClick:o,"aria-label":"Close menu",children:s.jsx(us,{size:12,className:"keyboard-shortcut-menu__close-icon"})})]}),s.jsx("ul",{className:"keyboard-shortcut-menu__items",role:"menu","aria-label":"Menu options",children:T.length===0?s.jsx("li",{className:"keyboard-shortcut-menu__no-results",role:"menuitem",children:"No results found"}):T.map((y,O)=>B(y,O))})]})});return i&&!d?s.jsx(xs,{anchorRef:i,menuItems:t,onSelectItem:r,onClose:o,hideReferenceFromList:e.hideReferenceFromList,title:e.title,onNavigate:_}):d?s.jsx("div",{style:d,children:Ae}):Ae},Pn=({className:e})=>s.jsx("div",{className:ye("loading-spinner",e),"aria-label":"Loading",role:"img",children:s.jsxs("div",{className:"loading-spinner__inner",role:"presentation",children:[s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-left",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-top",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-right",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-bottom",role:"presentation"})]})}),Ns=4e3,Rs=500,ks=8e3,an=["I'm working on it…","Generating insights…","Piecing things together…","Processing your request…","Refining the details…","Just a moment…","Organising the information…","Bringing it all together…","Gathering facts…","Crafting a response…","Thinking things through…","Preparing results…","Double-checking my output…","Reviewing the options…","Gathering data…","Looking at data…","Digging deeper…","Reaching a conclusion…","Checking the data…","Thinking…","Putting ideas together…","Cross-checking information…","Filling in the gaps…","Finding the answers…","Organising my thoughts…","On it…","Working on my response…","Building your response…","Exploring the possibilities…","Completing the task…","Shaping the outcome…","Fine-tuning the details…","Crunching the data…","Looking up insights…","Composing an answer…","Pulling it all together…","Preparing a solution…","Making connections…","Polishing the results…","Steady progress…","Testing assumptions…","Checking possibilities…","Sifting through some ideas…","Organising concepts…","Analysing your query…","Analysing results…","Working through the details…"],Is=({loadingPhrase:e,showSpinnerAsIcon:t=!0,showNotifyLaterButton:r=!1,onNotifyLater:o,onNotificationRegisteredGotIt:c})=>{const i=()=>Math.floor(Math.random()*an.length),d=l.useRef(null),[_,m]=l.useState(e||an[i()]),[g,h]=l.useState("fade-in"),[w,T]=l.useState(!1),[S,k]=l.useState(!1);l.useEffect(()=>{r||k(!1)},[r]),l.useEffect(()=>{if(!r||!o)return;const A=setTimeout(()=>{T(!0)},ks);return()=>{clearTimeout(A)}},[r,o]);const M=async()=>{if(!o)return;await o()&&k(!0)},N=()=>{k(!1),c==null||c()};return l.useEffect(()=>{let A=null;return e?(m(e),h("fade-in")):A=setInterval(()=>{h("fade-out"),setTimeout(()=>{let U;do U=i();while(U===d.current);d.current=U,m(an[U]),h("fade-in")},Rs)},Ns),()=>{A&&clearInterval(A)}},[e]),s.jsxs("li",{"aria-label":"Loading response",className:"chat-panel__loading-container","data-testid":"loading-widget",children:[s.jsxs("div",{className:"chat-panel__loading-content",children:[t?s.jsx(Pn,{className:"chat-panel__loading-spinner"}):s.jsx("span",{className:"chat-panel__loading-spinner-container",children:s.jsx(Pn,{className:"chat-panel__loading-spinner"})}),s.jsx("span",{className:`chat-panel__loading-phrase ${g}`,children:_})]}),r&&o&&w&&s.jsx("div",{className:"chat-panel__notify-later",children:S?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"We'll notify you in the notifications panel on the left of your MIS."}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:N,"aria-label":"Got it",children:"Got it"})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"This one's taking a bit longer than usual"}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:M,"aria-label":"Let me know when it's done",children:"Let me know when it's done"})]})})]})};function Cs(e){l.useEffect(e,[])}function vs(){const e=l.useRef(!1);return l.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Un(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2)+Date.now().toString(36)}function Os(e,t=0){if(typeof e=="number"&&e>0)return e;if(typeof e=="string"){const r=parseInt(e,10);if(!isNaN(r)&&r>0)return r}return t}const Ls=/\*\*(.+?)\*\*/g;function Ds(e){return e.replace(Ls,"<strong>$1</strong>")}/*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */function Fn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function Ms(e){if(Array.isArray(e))return e}function js(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,c,i,d,_=[],m=!0,g=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(m=(o=i.call(r)).done)&&(_.push(o.value),_.length!==t);m=!0);}catch(h){g=!0,c=h}finally{try{if(!m&&r.return!=null&&(d=r.return(),Object(d)!==d))return}finally{if(g)throw c}}return _}}function Ps(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
71
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Us(e,t){return Ms(e)||js(e,t)||Fs(e,t)||Ps()}function Fs(e,t){if(e){if(typeof e=="string")return Fn(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Fn(e,t):void 0}}const ur=Object.entries,zn=Object.setPrototypeOf,zs=Object.isFrozen,Hs=Object.getPrototypeOf,Gs=Object.getOwnPropertyDescriptor;let le=Object.freeze,ue=Object.seal,bt=Object.create,dr=typeof Reflect<"u"&&Reflect,hn=dr.apply,_n=dr.construct;le||(le=function(t){return t});ue||(ue=function(t){return t});hn||(hn=function(t,r){for(var o=arguments.length,c=new Array(o>2?o-2:0),i=2;i<o;i++)c[i-2]=arguments[i];return t.apply(r,c)});_n||(_n=function(t){for(var r=arguments.length,o=new Array(r>1?r-1:0),c=1;c<r;c++)o[c-1]=arguments[c];return new t(...o)});const vt=Q(Array.prototype.forEach),Bs=Q(Array.prototype.lastIndexOf),Hn=Q(Array.prototype.pop),gt=Q(Array.prototype.push),Ws=Q(Array.prototype.splice),st=Array.isArray,Mt=Q(String.prototype.toLowerCase),cn=Q(String.prototype.toString),Gn=Q(String.prototype.match),Ot=Q(String.prototype.replace),Bn=Q(String.prototype.indexOf),$s=Q(String.prototype.trim),Ys=Q(Number.prototype.toString),Ks=Q(Boolean.prototype.toString),Wn=typeof BigInt>"u"?null:Q(BigInt.prototype.toString),$n=typeof Symbol>"u"?null:Q(Symbol.prototype.toString),re=Q(Object.prototype.hasOwnProperty),Lt=Q(Object.prototype.toString),ce=Q(RegExp.prototype.test),dt=qs(TypeError);function Q(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,o=new Array(r>1?r-1:0),c=1;c<r;c++)o[c-1]=arguments[c];return hn(e,t,o)}}function qs(e){return function(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return _n(e,r)}}function D(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mt;if(zn&&zn(e,null),!st(t))return e;let o=t.length;for(;o--;){let c=t[o];if(typeof c=="string"){const i=r(c);i!==c&&(zs(t)||(t[o]=i),c=i)}e[c]=!0}return e}function Vs(e){for(let t=0;t<e.length;t++)re(e,t)||(e[t]=null);return e}function be(e){const t=bt(null);for(const o of ur(e)){var r=Us(o,2);const c=r[0],i=r[1];re(e,c)&&(st(i)?t[c]=Vs(i):i&&typeof i=="object"&&i.constructor===Object?t[c]=be(i):t[c]=i)}return t}function Xs(e){switch(typeof e){case"string":return e;case"number":return Ys(e);case"boolean":return Ks(e);case"bigint":return Wn?Wn(e):"0";case"symbol":return $n?$n(e):"Symbol()";case"undefined":return Lt(e);case"function":case"object":{if(e===null)return Lt(e);const t=e,r=He(t,"toString");if(typeof r=="function"){const o=r(t);return typeof o=="string"?o:Lt(o)}return Lt(e)}default:return Lt(e)}}function He(e,t){for(;e!==null;){const o=Gs(e,t);if(o){if(o.get)return Q(o.get);if(typeof o.value=="function")return Q(o.value)}e=Hs(e)}function r(){return null}return r}function Zs(e){try{return ce(e,""),!0}catch{return!1}}const Yn=le(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ln=le(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),un=le(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Js=le(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),dn=le(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Qs=le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kn=le(["#text"]),qn=le(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),fn=le(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Vn=le(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Yt=le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),eo=ue(/{{[\w\W]*|^[\w\W]*}}/g),to=ue(/<%[\w\W]*|^[\w\W]*%>/g),no=ue(/\${[\w\W]*/g),ro=ue(/^data-[\-\w.\u00B7-\uFFFF]+$/),so=ue(/^aria-[\-\w]+$/),Xn=ue(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),oo=ue(/^(?:\w+script|data):/i),ao=ue(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),io=ue(/^html$/i),co=ue(/^[a-z][.\w]*(-[.\w]+)+$/i),Zn=ue(/<[/\w!]/g),lo=ue(/<[/\w]/g),uo=ue(/<\/no(script|embed|frames)/i),fo=ue(/\/>/i),ze={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},po=function(){return typeof window>"u"?null:window},mo=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const c="data-tt-policy-suffix";r&&r.hasAttribute(c)&&(o=r.getAttribute(c));const i="dompurify"+(o?"#"+o:"");try{return t.createPolicy(i,{createHTML(d){return d},createScriptURL(d){return d}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Jn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},rt=function(t,r,o,c){return re(t,r)&&st(t[r])?D(c.base?be(c.base):{},t[r],c.transform):o};function fr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:po();const t=p=>fr(p);if(t.version="3.4.11",t.removed=[],!e||!e.document||e.document.nodeType!==ze.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const o=r,c=o.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,d=e.Node,_=e.Element,m=e.NodeFilter,g=e.NamedNodeMap;g===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const h=e.DOMParser,w=e.trustedTypes,T=_.prototype,S=He(T,"cloneNode"),k=He(T,"remove"),M=He(T,"nextSibling"),N=He(T,"childNodes"),A=He(T,"parentNode"),U=He(T,"shadowRoot"),de=He(T,"attributes"),$=d&&d.prototype?He(d.prototype,"nodeType"):null,G=d&&d.prototype?He(d.prototype,"nodeName"):null;if(typeof i=="function"){const p=r.createElement("template");p.content&&p.content.ownerDocument&&(r=p.content.ownerDocument)}let z,X="",fe,oe=!1,B=0;const Ae=function(){if(B>0)throw dt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},y=function(n){Ae(),B++;try{return z.createHTML(n)}finally{B--}},O=function(n){Ae(),B++;try{return z.createScriptURL(n)}finally{B--}},K=function(){return oe||(fe=mo(w,c),oe=!0),fe},te=r,L=te.implementation,C=te.createNodeIterator,ae=te.createDocumentFragment,Te=te.getElementsByTagName,we=o.importNode;let H=Jn();t.isSupported=typeof ur=="function"&&typeof A=="function"&&L&&L.createHTMLDocument!==void 0;const Ve=eo,Ne=to,Le=no,Ce=ro,Ge=so,q=oo,Be=ao,Z=co;let Xe=Xn,W=null;const De=D({},[...Yn,...ln,...un,...dn,...Kn]);let j=null;const Me=D({},[...qn,...fn,...Vn,...Yt]);let F=Object.seal(bt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),xe=null,Ze=null;const Re=Object.seal(bt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let We=!0,je=!0,b=!1,v=!0,V=!1,me=!0,ie=!1,Pe=!1,Ee=null,at=null,Et=!1,$e=!1,it=!1,Je=!1,ct=!0,St=!1;const At="user-content-";let ft=!0,wt=!1,Ye={},he=null;const lt=D({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Ut=null;const xt=D({},["audio","video","img","source","image","track"]);let Nt=null;const Ft=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Qe="http://www.w3.org/1998/Math/MathML",pt="http://www.w3.org/2000/svg",_e="http://www.w3.org/1999/xhtml";let et=_e,Rt=!1,Ue=null;const Xt=D({},[Qe,pt,_e],cn),Fe=le(["mi","mo","mn","ms","mtext"]);let Ke=D({},Fe);const kt=le(["annotation-xml"]);let mt=D({},kt);const Zt=D({},["title","style","font","a","script"]);let ut=null;const Jt=["application/xhtml+xml","text/html"],Qt="text/html";let Y=null,tt=null;const en=r.createElement("form"),zt=function(n){return n instanceof RegExp||n instanceof Function},ht=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(tt&&tt===n)return;(!n||typeof n!="object")&&(n={}),n=be(n),ut=Jt.indexOf(n.PARSER_MEDIA_TYPE)===-1?Qt:n.PARSER_MEDIA_TYPE,Y=ut==="application/xhtml+xml"?cn:Mt,W=rt(n,"ALLOWED_TAGS",De,{transform:Y}),j=rt(n,"ALLOWED_ATTR",Me,{transform:Y}),Ue=rt(n,"ALLOWED_NAMESPACES",Xt,{transform:cn}),Nt=rt(n,"ADD_URI_SAFE_ATTR",Ft,{transform:Y,base:Ft}),Ut=rt(n,"ADD_DATA_URI_TAGS",xt,{transform:Y,base:xt}),he=rt(n,"FORBID_CONTENTS",lt,{transform:Y}),xe=rt(n,"FORBID_TAGS",be({}),{transform:Y}),Ze=rt(n,"FORBID_ATTR",be({}),{transform:Y}),Ye=re(n,"USE_PROFILES")?n.USE_PROFILES&&typeof n.USE_PROFILES=="object"?be(n.USE_PROFILES):n.USE_PROFILES:!1,We=n.ALLOW_ARIA_ATTR!==!1,je=n.ALLOW_DATA_ATTR!==!1,b=n.ALLOW_UNKNOWN_PROTOCOLS||!1,v=n.ALLOW_SELF_CLOSE_IN_ATTR!==!1,V=n.SAFE_FOR_TEMPLATES||!1,me=n.SAFE_FOR_XML!==!1,ie=n.WHOLE_DOCUMENT||!1,$e=n.RETURN_DOM||!1,it=n.RETURN_DOM_FRAGMENT||!1,Je=n.RETURN_TRUSTED_TYPE||!1,Et=n.FORCE_BODY||!1,ct=n.SANITIZE_DOM!==!1,St=n.SANITIZE_NAMED_PROPS||!1,ft=n.KEEP_CONTENT!==!1,wt=n.IN_PLACE||!1,Xe=Zs(n.ALLOWED_URI_REGEXP)?n.ALLOWED_URI_REGEXP:Xn,et=typeof n.NAMESPACE=="string"?n.NAMESPACE:_e,Ke=re(n,"MATHML_TEXT_INTEGRATION_POINTS")&&n.MATHML_TEXT_INTEGRATION_POINTS&&typeof n.MATHML_TEXT_INTEGRATION_POINTS=="object"?be(n.MATHML_TEXT_INTEGRATION_POINTS):D({},Fe),mt=re(n,"HTML_INTEGRATION_POINTS")&&n.HTML_INTEGRATION_POINTS&&typeof n.HTML_INTEGRATION_POINTS=="object"?be(n.HTML_INTEGRATION_POINTS):D({},kt);const a=re(n,"CUSTOM_ELEMENT_HANDLING")&&n.CUSTOM_ELEMENT_HANDLING&&typeof n.CUSTOM_ELEMENT_HANDLING=="object"?be(n.CUSTOM_ELEMENT_HANDLING):bt(null);if(F=bt(null),re(a,"tagNameCheck")&&zt(a.tagNameCheck)&&(F.tagNameCheck=a.tagNameCheck),re(a,"attributeNameCheck")&&zt(a.attributeNameCheck)&&(F.attributeNameCheck=a.attributeNameCheck),re(a,"allowCustomizedBuiltInElements")&&typeof a.allowCustomizedBuiltInElements=="boolean"&&(F.allowCustomizedBuiltInElements=a.allowCustomizedBuiltInElements),ue(F),V&&(je=!1),it&&($e=!0),Ye&&(W=D({},Kn),j=bt(null),Ye.html===!0&&(D(W,Yn),D(j,qn)),Ye.svg===!0&&(D(W,ln),D(j,fn),D(j,Yt)),Ye.svgFilters===!0&&(D(W,un),D(j,fn),D(j,Yt)),Ye.mathMl===!0&&(D(W,dn),D(j,Vn),D(j,Yt))),Re.tagCheck=null,Re.attributeCheck=null,re(n,"ADD_TAGS")&&(typeof n.ADD_TAGS=="function"?Re.tagCheck=n.ADD_TAGS:st(n.ADD_TAGS)&&(W===De&&(W=be(W)),D(W,n.ADD_TAGS,Y))),re(n,"ADD_ATTR")&&(typeof n.ADD_ATTR=="function"?Re.attributeCheck=n.ADD_ATTR:st(n.ADD_ATTR)&&(j===Me&&(j=be(j)),D(j,n.ADD_ATTR,Y))),re(n,"ADD_URI_SAFE_ATTR")&&st(n.ADD_URI_SAFE_ATTR)&&D(Nt,n.ADD_URI_SAFE_ATTR,Y),re(n,"FORBID_CONTENTS")&&st(n.FORBID_CONTENTS)&&(he===lt&&(he=be(he)),D(he,n.FORBID_CONTENTS,Y)),re(n,"ADD_FORBID_CONTENTS")&&st(n.ADD_FORBID_CONTENTS)&&(he===lt&&(he=be(he)),D(he,n.ADD_FORBID_CONTENTS,Y)),ft&&(W["#text"]=!0),ie&&D(W,["html","head","body"]),W.table&&(D(W,["tbody"]),delete xe.tbody),n.TRUSTED_TYPES_POLICY){if(typeof n.TRUSTED_TYPES_POLICY.createHTML!="function")throw dt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof n.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw dt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const f=z;z=n.TRUSTED_TYPES_POLICY;try{X=y("")}catch(E){throw z=f,E}}else n.TRUSTED_TYPES_POLICY===null?(z=void 0,X=""):(z===void 0&&(z=K()),z&&typeof X=="string"&&(X=y("")));le&&le(n),tt=n},Ht=D({},[...ln,...un,...Js]),u=D({},[...dn,...Qs]),R=function(n,a,f){return a.namespaceURI===_e?n==="svg":a.namespaceURI===Qe?n==="svg"&&(f==="annotation-xml"||Ke[f]):!!Ht[n]},x=function(n,a,f){return a.namespaceURI===_e?n==="math":a.namespaceURI===pt?n==="math"&&mt[f]:!!u[n]},pe=function(n,a,f){return a.namespaceURI===pt&&!mt[f]||a.namespaceURI===Qe&&!Ke[f]?!1:!u[n]&&(Zt[n]||!Ht[n])},Se=function(n){let a=A(n);(!a||!a.tagName)&&(a={namespaceURI:et,tagName:"template"});const f=Mt(n.tagName),E=Mt(a.tagName);return Ue[n.namespaceURI]?n.namespaceURI===pt?R(f,a,E):n.namespaceURI===Qe?x(f,a,E):n.namespaceURI===_e?pe(f,a,E):!!(ut==="application/xhtml+xml"&&Ue[n.namespaceURI]):!1},ee=function(n){gt(t.removed,{element:n});try{A(n).removeChild(n)}catch{if(k(n),!A(n))throw dt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},nt=function(n){const a=N(n);if(a){const E=[];vt(a,I=>{gt(E,I)}),vt(E,I=>{try{k(I)}catch{}})}const f=de(n);if(f)for(let E=f.length-1;E>=0;--E){const I=f[E],P=I&&I.name;if(typeof P=="string")try{n.removeAttribute(P)}catch{}}},ke=function(n,a){try{gt(t.removed,{attribute:a.getAttributeNode(n),from:a})}catch{gt(t.removed,{attribute:null,from:a})}if(a.removeAttribute(n),n==="is")if($e||it)try{ee(a)}catch{}else try{a.setAttribute(n,"")}catch{}},An=function(n){const a=de(n);if(a)for(let f=a.length-1;f>=0;--f){const E=a[f],I=E&&E.name;if(!(typeof I!="string"||j[Y(I)]))try{n.removeAttribute(I)}catch{}}},Gt=function(n){const a=[n];for(;a.length>0;){const f=a.pop();($?$(f):f.nodeType)===ze.element&&An(f);const I=N(f);if(I)for(let P=I.length-1;P>=0;--P)a.push(I[P])}},wn=function(n){let a=null,f=null;if(Et)n="<remove></remove>"+n;else{const P=Gn(n,/^[\r\n\t ]+/);f=P&&P[0]}ut==="application/xhtml+xml"&&et===_e&&(n='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+n+"</body></html>");const E=z?y(n):n;if(et===_e)try{a=new h().parseFromString(E,ut)}catch{}if(!a||!a.documentElement){a=L.createDocument(et,"template",null);try{a.documentElement.innerHTML=Rt?X:E}catch{}}const I=a.body||a.documentElement;return n&&f&&I.insertBefore(r.createTextNode(f),I.childNodes[0]||null),et===_e?Te.call(a,ie?"html":"body")[0]:ie?a.documentElement:I},xn=function(n){return C.call(n.ownerDocument||n,n,m.SHOW_ELEMENT|m.SHOW_COMMENT|m.SHOW_TEXT|m.SHOW_PROCESSING_INSTRUCTION|m.SHOW_CDATA_SECTION,null)},Bt=function(n){return n=Ot(n,Ve," "),n=Ot(n,Ne," "),n=Ot(n,Le," "),n},tn=function(n){var a;n.normalize();const f=C.call(n.ownerDocument||n,n,m.SHOW_TEXT|m.SHOW_COMMENT|m.SHOW_CDATA_SECTION|m.SHOW_PROCESSING_INSTRUCTION,null);let E=f.nextNode();for(;E;)E.data=Bt(E.data),E=f.nextNode();const I=(a=n.querySelectorAll)===null||a===void 0?void 0:a.call(n,"template");I&&vt(I,P=>{_t(P.content)&&tn(P.content)})},Wt=function(n){const a=G?G(n):null;return typeof a!="string"||Y(a)!=="form"?!1:typeof n.nodeName!="string"||typeof n.textContent!="string"||typeof n.removeChild!="function"||n.attributes!==de(n)||typeof n.removeAttribute!="function"||typeof n.setAttribute!="function"||typeof n.namespaceURI!="string"||typeof n.insertBefore!="function"||typeof n.hasChildNodes!="function"||n.nodeType!==$(n)||n.childNodes!==N(n)},_t=function(n){if(!$||typeof n!="object"||n===null)return!1;try{return $(n)===ze.documentFragment}catch{return!1}},It=function(n){if(!$||typeof n!="object"||n===null)return!1;try{return typeof $(n)=="number"}catch{return!1}};function qe(p,n,a){p.length!==0&&vt(p,f=>{f.call(t,n,a,tt)})}const gr=function(n,a){return!!(me&&n.hasChildNodes()&&!It(n.firstElementChild)&&ce(Zn,n.textContent)&&ce(Zn,n.innerHTML)||me&&n.namespaceURI===_e&&a==="style"&&It(n.firstElementChild)||n.nodeType===ze.processingInstruction||me&&n.nodeType===ze.comment&&ce(lo,n.data))},br=function(n,a){if(!xe[a]&&kn(a)&&(F.tagNameCheck instanceof RegExp&&ce(F.tagNameCheck,a)||F.tagNameCheck instanceof Function&&F.tagNameCheck(a)))return!1;if(ft&&!he[a]){const f=A(n),E=N(n);if(E&&f){const I=E.length;for(let P=I-1;P>=0;--P){const ne=wt?E[P]:S(E[P],!0);f.insertBefore(ne,M(n))}}}return ee(n),!0},Nn=function(n){if(qe(H.beforeSanitizeElements,n,null),Wt(n))return ee(n),!0;const a=Y(G?G(n):n.nodeName);if(qe(H.uponSanitizeElement,n,{tagName:a,allowedTags:W}),gr(n,a))return ee(n),!0;if(xe[a]||!(Re.tagCheck instanceof Function&&Re.tagCheck(a))&&!W[a])return br(n,a);if(($?$(n):n.nodeType)===ze.element&&!Se(n)||(a==="noscript"||a==="noembed"||a==="noframes")&&ce(uo,n.innerHTML))return ee(n),!0;if(V&&n.nodeType===ze.text){const E=Bt(n.textContent);n.textContent!==E&&(gt(t.removed,{element:n.cloneNode()}),n.textContent=E)}return qe(H.afterSanitizeElements,n,null),!1},Rn=function(n,a,f){if(Ze[a]||ct&&(a==="id"||a==="name")&&(f in r||f in en))return!1;const E=j[a]||Re.attributeCheck instanceof Function&&Re.attributeCheck(a,n);if(!(je&&ce(Ce,a))){if(!(We&&ce(Ge,a))){if(E){if(!Nt[a]){if(!ce(Xe,Ot(f,Be,""))){if(!((a==="src"||a==="xlink:href"||a==="href")&&n!=="script"&&Bn(f,"data:")===0&&Ut[n])){if(!(b&&!ce(q,Ot(f,Be,"")))){if(f)return!1}}}}}else if(!(kn(n)&&(F.tagNameCheck instanceof RegExp&&ce(F.tagNameCheck,n)||F.tagNameCheck instanceof Function&&F.tagNameCheck(n))&&(F.attributeNameCheck instanceof RegExp&&ce(F.attributeNameCheck,a)||F.attributeNameCheck instanceof Function&&F.attributeNameCheck(a,n))||a==="is"&&F.allowCustomizedBuiltInElements&&(F.tagNameCheck instanceof RegExp&&ce(F.tagNameCheck,f)||F.tagNameCheck instanceof Function&&F.tagNameCheck(f))))return!1}}return!0},yr=D({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),kn=function(n){return!yr[Mt(n)]&&ce(Z,n)},Tr=function(n,a,f,E){if(z&&typeof w=="object"&&typeof w.getAttributeType=="function"&&!f)switch(w.getAttributeType(n,a)){case"TrustedHTML":return y(E);case"TrustedScriptURL":return O(E)}return E},Er=function(n,a,f,E){try{f?n.setAttributeNS(f,a,E):n.setAttribute(a,E),Wt(n)?ee(n):Hn(t.removed)}catch{ke(a,n)}},In=function(n){qe(H.beforeSanitizeAttributes,n,null);const a=n.attributes;if(!a||Wt(n))return;const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:j,forceKeepAttr:void 0};let E=a.length;const I=Y(n.nodeName);for(;E--;){const P=a[E],ne=P.name,J=P.namespaceURI,Ie=P.value,ve=Y(ne),rn=Ie;let ge=ne==="value"?rn:$s(rn);if(f.attrName=ve,f.attrValue=ge,f.keepAttr=!0,f.forceKeepAttr=void 0,qe(H.uponSanitizeAttribute,n,f),ge=f.attrValue,St&&(ve==="id"||ve==="name")&&Bn(ge,At)!==0&&(ke(ne,n),ge=At+ge),me&&ce(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ge)){ke(ne,n);continue}if(ve==="attributename"&&Gn(ge,"href")){ke(ne,n);continue}if(!f.forceKeepAttr){if(!f.keepAttr){ke(ne,n);continue}if(!v&&ce(fo,ge)){ke(ne,n);continue}if(V&&(ge=Bt(ge)),!Rn(I,ve,ge)){ke(ne,n);continue}ge=Tr(I,ve,J,ge),ge!==rn&&Er(n,ne,J,ge)}}qe(H.afterSanitizeAttributes,n,null)},$t=function(n){let a=null;const f=xn(n);for(qe(H.beforeSanitizeShadowDOM,n,null);a=f.nextNode();)if(qe(H.uponSanitizeShadowNode,a,null),Nn(a),In(a),_t(a.content)&&$t(a.content),($?$(a):a.nodeType)===ze.element){const I=U(a);_t(I)&&(nn(I),$t(I))}qe(H.afterSanitizeShadowDOM,n,null)},nn=function(n){const a=[{node:n,shadow:null}];for(;a.length>0;){const f=a.pop();if(f.shadow){$t(f.shadow);continue}const E=f.node,P=($?$(E):E.nodeType)===ze.element,ne=N(E);if(ne)for(let J=ne.length-1;J>=0;--J)a.push({node:ne[J],shadow:null});if(P){const J=G?G(E):null;if(typeof J=="string"&&Y(J)==="template"){const Ie=E.content;_t(Ie)&&a.push({node:Ie,shadow:null})}}if(P){const J=U(E);_t(J)&&a.push({node:null,shadow:J},{node:J,shadow:null})}}};return t.sanitize=function(p){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=null,f=null,E=null,I=null;if(Rt=!p,Rt&&(p="<!-->"),typeof p!="string"&&!It(p)&&(p=Xs(p),typeof p!="string"))throw dt("dirty is not a string, aborting");if(!t.isSupported)return p;Pe?(W=Ee,j=at):ht(n),(H.uponSanitizeElement.length>0||H.uponSanitizeAttribute.length>0)&&(W=be(W)),H.uponSanitizeAttribute.length>0&&(j=be(j)),t.removed=[];const P=wt&&typeof p!="string"&&It(p);if(P){const Ie=G?G(p):p.nodeName;if(typeof Ie=="string"){const ve=Y(Ie);if(!W[ve]||xe[ve])throw dt("root node is forbidden and cannot be sanitized in-place")}if(Wt(p))throw dt("root node is clobbered and cannot be sanitized in-place");try{nn(p)}catch(ve){throw nt(p),ve}}else if(It(p))a=wn("<!---->"),f=a.ownerDocument.importNode(p,!0),f.nodeType===ze.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?a=f:a.appendChild(f),nn(f);else{if(!$e&&!V&&!ie&&p.indexOf("<")===-1)return z&&Je?y(p):p;if(a=wn(p),!a)return $e?null:Je?X:""}a&&Et&&ee(a.firstChild);const ne=xn(P?p:a);try{for(;E=ne.nextNode();)Nn(E),In(E),_t(E.content)&&$t(E.content)}catch(Ie){throw P&&nt(p),Ie}if(P)return vt(t.removed,Ie=>{Ie.element&&Gt(Ie.element)}),V&&tn(p),p;if($e){if(V&&tn(a),it)for(I=ae.call(a.ownerDocument);a.firstChild;)I.appendChild(a.firstChild);else I=a;return(j.shadowroot||j.shadowrootmode)&&(I=we.call(o,I,!0)),I}let J=ie?a.outerHTML:a.innerHTML;return ie&&W["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&ce(io,a.ownerDocument.doctype.name)&&(J="<!DOCTYPE "+a.ownerDocument.doctype.name+`>
|
|
72
|
+
`+J),V&&(J=Bt(J)),z&&Je?y(J):J},t.setConfig=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ht(p),Pe=!0,Ee=W,at=j},t.clearConfig=function(){tt=null,Pe=!1,Ee=null,at=null,z=fe,X=""},t.isValidAttribute=function(p,n,a){tt||ht({});const f=Y(p),E=Y(n);return Rn(f,E,a)},t.addHook=function(p,n){typeof n=="function"&&re(H,p)&>(H[p],n)},t.removeHook=function(p,n){if(re(H,p)){if(n!==void 0){const a=Bs(H[p],n);return a===-1?void 0:Ws(H[p],a,1)[0]}return Hn(H[p])}},t.removeHooks=function(p){re(H,p)&&(H[p]=[])},t.removeAllHooks=function(){H=Jn()},t}var Kt=fr();const ho=["a","b","br","div","em","i","li","ol","p","s","span","strong","u","ul"];function _o(e){e.hasAttribute("href")&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"))}function go(e){Kt.addHook("afterSanitizeAttributes",_o);const t=Kt.sanitize(e,{ALLOWED_TAGS:[...ho]});return Kt.removeHook("afterSanitizeAttributes"),t}function bo(e){return Kt.sanitize(e,{ALLOWED_TAGS:[]})}class Tn extends Error{constructor(t,r){super(`HTTP ${t}: ${r}`),this.name="HttpError",this.status=t,this.statusText=r}}async function pr(e,t,r,o={}){const{authorizationToken:c,headers:i,...d}=o,_=await fetch(t,{method:e,headers:{"Content-Type":"application/json",...c&&{Authorization:`Bearer ${c}`},...i},body:r!==void 0?JSON.stringify(r):void 0,...d});if(!_.ok)throw new Tn(_.status,_.statusText);return _.json()}const mr=(e,t,r,o)=>pr("GET",e,void 0,{signal:r,authorizationToken:o}),En=(e,t,r={})=>pr("POST",e,t,r);function gn(e){if(e==="")return"";try{const t=JSON.parse(e);return typeof t=="string"?t:String(t??"")}catch{return e}}function yo(e){return e.includes("/chat/agent-completions")}function hr(e){return/\/conversations(?:\/|$)/.test(e.replace(/\?.*$/,""))}const Dt={model:"gpt-4o-mini",agentName:"Group_Ask_Arbor_Agent",systemPrompt:"You are a helpful AI assistant for Arbor Education group MIS users.",modelKwargs:{temperature:1,top_p:1},mcps:[{server:"statsapi",tools:["*"]},{server:"arbormis",tools:["create_pdf","academic_date_range_finder"]}]},bn="user",To="assistant",Eo="system";function So({chatId:e,userMessage:t,chatHistory:r=[],config:o={}}){const c=o.model??Dt.model,i=o.agentName??Dt.agentName,d=o.systemPrompt??Dt.systemPrompt,_=o.modelKwargs??Dt.modelKwargs,m=o.mcps??[...Dt.mcps],g=!e&&r.length===0,w={messages:g?[{role:Eo,content:d},{role:bn,content:t}]:[{role:bn,content:t}],model:c,model_kwargs:_,mcps:m,meta:{feature_id:i,source:"ask-arbor-standalone"},moderation_enabled:!0};return e&&(w.chat_id=e),g&&(w.auto_title=!1),w}function Ao(e){const t=e.trim();if(!t.startsWith("data:"))return null;const r=t.slice(5).trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}async function wo(e){var g,h,w;if((e.headers.get("content-type")??"").includes("application/json")){const S=(g=(await e.json()).items)==null?void 0:g[0];return S?{text:S.text??S.content??"",chatId:S.chatId,messageId:S.id}:null}const r=(h=e.body)==null?void 0:h.getReader();if(!r)return null;const o=new TextDecoder;let c="",i="",d,_=`agent-${Date.now()}`,m=!1;for(;;){const{done:T,value:S}=await r.read();if(T)break;c+=o.decode(S,{stream:!0});const k=c.split(`
|
|
73
|
+
`);c=k.pop()??"";for(const M of k){const N=M.trim();if(N==="event: error"){m=!0;continue}const A=Ao(N);if(!A)continue;if(A.error||m)throw new Error(A.message_text??(typeof A.message=="string"?A.message:"Agent completion stream failed"));m=!1,A.chat_id&&(d=A.chat_id),A.event_id&&(_=A.event_id),A.client_message_id&&(_=A.client_message_id);const U=(w=A.message)==null?void 0:w.content;U&&(i=A.is_final?U:i+U)}}return i?{text:i,chatId:d,messageId:_}:null}async function xo({chatUrl:e,chatId:t,userMessage:r,chatHistory:o,authorizationToken:c,config:i,uploadFiles:d}){const _=So({chatId:t,userMessage:r,chatHistory:o,config:i}),m={Accept:"application/json","X-Trace-Id":crypto.randomUUID(),...c&&{Authorization:`Bearer ${c}`}},g=!!(d&&d.length>0),h=await fetch(e,g?{method:"POST",headers:m,body:No(_,d??[])}:{method:"POST",headers:{...m,"Content-Type":"application/json"},body:JSON.stringify(_)});if(!h.ok)throw new Tn(h.status,h.statusText);return wo(h)}function No(e,t){const r=new FormData;r.append("body",JSON.stringify(e));for(const o of t)r.append("files",o,o.name);return r}function Ro(e){switch(e){case 401:return{text:ms,type:Oe};case 403:return{text:hs,type:Oe};case 404:return{text:_s,type:Oe};case 408:case 504:return{text:gs,type:Pt};case 429:return{text:bs,type:Pt};default:return e>=500?{text:ys,type:Oe}:{text:cr,type:Oe}}}function ko(e){return e instanceof Tn?Ro(e.status):e instanceof TypeError?{text:Ts,type:Oe}:{text:cr,type:Oe}}const Io=55e3,yn="fallback",Co=async({chatId:e=void 0,chatUrl:t,userMessage:r,userInputDeviceLastUsed:o,chatHistory:c,canvasHistory:i,authorizationToken:d,agentCompletionsConfig:_,uploadFiles:m})=>{let g;try{if(yo(t)){const A=await xo({chatUrl:t,chatId:e,userMessage:r,chatHistory:c,authorizationToken:d,config:_,...m&&m.length>0&&{uploadFiles:m}});return A?{text:A.text,id:A.messageId,...A.chatId!=null&&{chatId:A.chatId},type:yt}:null}const S={chatId:e,userMessage:r,userInputDeviceLastUsed:o,chatHistory:c,canvasHistory:i},k=new AbortController,M=En(t,S,{authorizationToken:d,signal:k.signal}),N=new Promise(A=>setTimeout(()=>{k.abort(),A({items:[{id:yn,hardStopped:!0,type:qt}]})},Io));g=await Promise.race([M,N])}catch(S){console.error("Error in getNewAgentMessage",S);const{text:k,type:M}=ko(S);return{text:k,type:M,id:crypto.randomUUID()}}const h=g.items[0];if(!h)return null;const w=h.text!=null&&h.text!==""?h.text:gn(typeof h.content=="string"?h.content:"");return{text:typeof w=="string"?w:"",id:h.id,...h.chatId!=null&&{chatId:h.chatId},...h.timedOut!=null&&{timedOut:h.timedOut},...h.deferred!=null&&{deferred:h.deferred},...h.hardStopped!=null&&{hardStopped:h.hardStopped},type:h.type,...h.element!=null&&{element:h.element},...h.followUpPrompts!=null&&{followUpPrompts:h.followUpPrompts}}},vo=e=>new Date(e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),Oo=[{field:"title",headerName:"Conversation",flex:1},{field:"updatedAt",headerName:"Last Conversation",width:140,valueFormatter:({value:e})=>vo(e)}],Lo={sortable:!1,filter:!1,resizable:!1,editable:!1,suppressHeaderMenuButton:!0},Do=e=>{for(let t=e.length-1;t>=0;t-=1){const r=e[t];if(r.type===yt)return r.followUpPrompts??null}return null},Mo=(e,t,r)=>{if(r)return e!==null&&e.length>0?e:e===null?null:t.followUpPrompts},pn="NONE",jo="KEYBOARD",Po="VOICE",Uo="MIXED",Fo=2e4,zo=15,Ho=(e,t)=>new Promise(r=>{if(t!=null&&t.aborted){r(!1);return}const o=setTimeout(()=>{t==null||t.removeEventListener("abort",c),r(!0)},e),c=()=>{clearTimeout(o),r(!1)};t==null||t.addEventListener("abort",c)}),Sn=({title:e,connector:t,newChatUrl:r,lockConversation:o=!1,messageLimit:c,chatId:i,speechEnabled:d=!0,speechLanguage:_="en-GB",speechSubmissionDelay:m=1e3,chatHistory:g,canvasHistory:h,refreshAgentMessages:w,startQuery:T,slashMenuItems:S,menuContent:k,samplePrompts:M,dailyPrompt:N,prompts:A,promptLibrary:U,placeholder:de="Explain what you need in your own words...",introHeading:$="Get instant answers from your MIS",introBody:G="Type a question about your students, staff or school and get the answer in seconds. No reports to run, no clicking around - just ask!",showTabs:z=!1,onClose:X,onNavigate:fe,onRatingPopupOpen:oe,focusDelay:B,enableUpload:Ae,acceptedFileTypes:y})=>{const O=(()=>{if(U&&U.length>0)return U;if(!A||A.trim()==="")return[];try{const u=JSON.parse(A);return Array.isArray(u)&&u.length>0?u:[]}catch{return[]}})(),K=l.useRef(!1),te=u=>{K.current=u},L=vs(),C=l.useRef(null),ae=l.useRef(null),Te=l.useRef(null),we=l.useRef(null),H=l.useRef(null),Ve=l.useRef(null),[Ne,Le]=l.useState(()=>i?"":T??""),[Ce,Ge]=l.useState([]),[q,Be]=l.useState(i),[Z,Xe]=l.useState([]),[W,De]=l.useState([]),j=u=>{(!K.current||u.id==="DEEP_THINKING_MESSAGE")&&Xe(R=>[...R,u])},[Me,F]=l.useState(!1),[xe,Ze]=l.useState(!1),[Re,We]=l.useState(!1),je=l.useRef(!1),b=l.useRef(null),v=l.useRef(!1),[V,me]=l.useState(!1),[ie,Pe]=l.useState(pn),[Ee,at]=l.useState(!1),[Et,$e]=l.useState(!0),[it,Je]=l.useState(!1),[ct,St]=l.useState("getting-started"),[At,ft]=l.useState([]),[wt,Ye]=l.useState(!1),he=Os(c,0),lt=he>0&&Z.length>=he,Ut=Me||xe;Cs(()=>{if(!!(T!=null&&T.trim())&&!i||B==null&&!T)return;const R=setTimeout(()=>{var x;(x=C.current)==null||x.focus()},B??0);return()=>clearTimeout(R)});const[xt,Nt]=l.useState(!1),Ft=!window.webkitSpeechRecognition&&!window.SpeechRecognition,Qe=typeof navigator<"u"&&navigator.userAgent.toLowerCase().includes("firefox"),pt=async()=>{let u=!1;if(navigator.permissions)try{u=(await navigator.permissions.query({name:"microphone"})).state==="denied"}catch(R){console.warn("Could not check microphone permission:",R)}return!d||Ft||Qe||u};l.useEffect(()=>{(async()=>{const R=await pt();Nt(R)})()},[d,Ee]),l.useEffect(()=>{g&&g.length>0&&(Xe(g),De(Do(g)))},[g]);const _e=async(u=q)=>{if(!t.canLoadHistory||!u)return;Ze(!0);const R=await t.loadHistory(u);if(L.current){if(JSON.stringify(R)===JSON.stringify(Z)||!R){Ze(!1);return}return R.chatItems.length>0&&Xe(R.chatItems),De(R.followUpPrompts),Ze(!1),me(!0),R}};l.useEffect(()=>{w&&!K.current&&_e()},[w]),l.useEffect(()=>{L.current&&t.canLoadHistory&&i&&(V||_e(i))},[i,t.canLoadHistory,V]),l.useLayoutEffect(()=>{Te.current&&Te.current.scrollTo({top:Te.current.scrollHeight,behavior:"smooth"})},[Z]);const et=u=>{const R=Ds(u),x=/\['Canvas_Element_ID'\s*:\s*'([^']+)',\s*'Title'\s*:\s*'([^']+)'\]/g;return R.replace(x,(pe,Se,ee)=>`<span class="chat-panel__message-tag">@${ee}</span>`)},Rt=async({maxAttempts:u=6,chatIdToFetch:R,signal:x}={})=>{const pe=new Set(Z.map(({id:nt})=>nt));let Se=0,ee;for(;Se<u;){if(x!=null&&x.aborted||!await Ho(Fo,x)||(ee=await _e(R),x!=null&&x.aborted))return;if(((ee==null?void 0:ee.chatItems)||[]).some(Gt=>Gt.type!==ot&&!pe.has(Gt.id)))break;Se++}if(Number.isFinite(u)&&Se>=u){j({text:Es,id:yn,type:Oe});return}return ee},Ue=()=>{setTimeout(()=>{var u;(u=C.current)==null||u.focus()},0)},Xt=async(u,R=[])=>{De(null),F(!0);try{const x=await t.sendMessage({chatId:q,userMessage:u,userInputDeviceLastUsed:ie,chatHistory:Z,canvasHistory:h,...R.length>0&&{uploadFiles:R}});if(!x)return F(!1),Ue(),!1;if(x.deferred===!0){x.chatId&&Be(x.chatId);const pe=x.chatId||q;b.current=new AbortController;try{await Rt({maxAttempts:zo,chatIdToFetch:pe,signal:b.current.signal})}finally{b.current=null}return L.current&&(F(!1),Ue()),!0}return x.hardStopped===!0?(!je.current&&t.canSendNotification&&q&&await t.sendNotification({chatId:q})&&(je.current=!0),L.current&&(We(!0),F(!1),Ue()),!0):(j({text:go(x.text),type:x.type,id:x.id,...x.element!=null&&{element:x.element}}),x.chatId&&Be(x.chatId),De(x.followUpPrompts??null),F(!1),Ue(),!0)}catch{return L.current&&(F(!1),Ue()),!1}},Fe=async({prompt:u=null,allowDoubleMessage:R=!1}={})=>{var nt;let x=null;if(u!=null&&u.trim()!==""&&(x=u.trim()),x===null&&(x=bo(Ne).trim()),!x&&Ce.length===0||Me||xe)return;const pe=Z.slice().reverse().find(ke=>ke.type===ot);if(!R&&x&&pe&&pe.text===x){console.warn("Duplicate message detected, not adding:",x);return}(nt=Ve.current)==null||nt.cancel(),Ke(),We(!1),je.current=!1;const Se=[...Ce];x?j({type:ot,text:x,id:Un()}):Se.length>0&&j({type:ot,text:Se.map(ke=>ke.name).join(", "),id:Un()}),Le(""),Ue(),te(!1),await Xt(x??"",Se)?Ge([]):Se.length>0&&Ge(Se),Pe(pn)};l.useEffect(()=>{if(v.current||!(T!=null&&T.trim())||i)return;v.current=!0;const u=setTimeout(()=>{Fe({prompt:T})},B??0);return()=>clearTimeout(u)},[]);const Ke=()=>{H.current&&(H.current.stop(),H.current=null),at(!1),we.current&&(clearTimeout(we.current),we.current=null)},kt=Nr(u=>{Ke(),u.trim().length>0&&Et&&Fe()},m);Ve.current=kt;const mt=u=>{if(ie===pn){Pe(u);return}if(ie!==u){Pe(Uo);return}},Zt=()=>{if(Me||xe)return;mt(Po),$e(!0);const u=new window.webkitSpeechRecognition;H.current=u,u.continuous=!0,u.interimResults=!0,u.lang=_,u.start(),u.onstart=()=>{at(!0)},u.onresult=R=>{const x=Array.from(R.results).map(pe=>pe[0]).map(pe=>pe.transcript).join("");x!==Ne&&Le(x),kt(x)},u.onerror=()=>{Ke()}},ut=()=>{Ee?Ke():Zt()},Jt=!xe&&!Me&&(Ne.trim().length>0||Ae&&Ce.length>0);l.useEffect(()=>()=>{var u;(u=b.current)==null||u.abort()},[]),l.useEffect(()=>{if(!z||!t.canListInteractions)return;let u=!1;return Ye(!0),t.listInteractions().then(R=>{u||ft(R??[])}).catch(()=>{u||ft([])}).finally(()=>{u||Ye(!1)}),()=>{u=!0}},[t,z]);const Qt=()=>S!=null&&S.length?S.map(u=>{let R=u.url;return q&&R.includes("/chat-id/")&&(R.match(/\/chat-id\/[^/]+$/)||(R=`${R}${q}`)),{reference:u.label,description:u.label,link:R,icon:u.icon}}):[],Y=u=>{u.key!=="Enter"&&(mt(jo),Ee&&$e(!1),u.key==="/"&&Ne.length===0&&(S!=null&&S.length)&&(Je(!0),u.preventDefault())),u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),Jt&&Fe({allowDoubleMessage:!0})),u.key==="Escape"&&it&&Je(!1)},tt=()=>{Je(!1),setTimeout(()=>{var u;(u=C.current)==null||u.focus()},0)},en=l.useCallback(u=>{Le(u),setTimeout(()=>{C.current&&(C.current.focus(),C.current.selectionStart=C.current.value.length,C.current.selectionEnd=C.current.value.length)},0)},[]),zt=l.useCallback(async()=>!t.canSendNotification||!q?!1:t.sendNotification({chatId:q}),[q,t]),ht=l.useCallback(()=>{We(!1),X==null||X()},[X]),Ht=l.useCallback((u,R)=>{q&&t.rateMessage({rating:u,messageId:R,chatId:q})},[q,t]);return s.jsxs("section",{"aria-label":e?`Chat Panel: ${e}`:"Chat Panel",className:"chat-panel",children:[r&&Z.length>0&&s.jsx("section",{className:"chat-panel__active-chat-header",children:s.jsx("a",{href:r,className:"chat-panel__new-chat-button",onClick:u=>{fe&&(u.preventDefault(),fe(r))},children:"New"})}),(Z.length>0||!o&&!lt)&&s.jsxs("div",{className:ye("chat-panel__body",{"chat-panel__body--no-messages":Z.length===0}),children:[Z.length>0&&s.jsxs("div",{className:"chat-panel__message-list-wrapper",children:[s.jsxs("ul",{className:"chat-panel-message-list",ref:Te,children:[Z.map((u,R)=>{const x=R===Z.length-1,pe=Mo(W,u,x),Se=u.id===yn,ee=x;return s.jsx(ps,{id:u.id,type:u.type,text:u.text,chatId:q,onRate:t.canRate?Ht:void 0,ratingPopupUrls:t.ratingPopupUrls,showRating:ee,followUpPrompts:pe,onFollowUpPromptClick:en,processCanvasReferences:et,isFallbackMessage:Se,onRatingPopupOpen:oe},`${u.id}_${R}`)}),Ut&&s.jsx(Is,{showNotifyLaterButton:t.canSendNotification&&!!q,onNotifyLater:zt,onNotificationRegisteredGotIt:ht}),Re&&s.jsx("li",{className:"chat-panel__hard-stop-banner","data-testid":"hard-stop-banner",children:s.jsxs("div",{className:"chat-panel__notify-later",children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"This one's taking longer than usual. We'll notify you in the notifications panel on the left of your MIS when it's done."}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:ht,"aria-label":"Got it",children:"Got it"})]})})]}),he>0&&Z.length>0&&s.jsxs("div",{className:"chat-panel__message-limit",children:[Z.length," ","/",he]})]}),!o&&!lt&&s.jsxs(s.Fragment,{children:[Z.length===0&&!xe&&s.jsxs("div",{className:"chat-panel__chat-intro",children:[s.jsxs("div",{className:"chat-panel__chat-intro-frame",children:[s.jsx("span",{className:"chat-panel__chat-intro-icon",children:s.jsx(Rr,{})}),s.jsx("h3",{className:"chat-panel__chat-intro-heading",children:$})]}),s.jsx("p",{className:"chat-panel__chat-intro-body",children:G})]}),s.jsx("div",{className:"chat-panel__input-container",children:s.jsxs("div",{className:"chat-panel__input-wrapper",ref:ae,children:[it&&s.jsx(lr,{anchorRef:ae,menuItems:Qt(),onClose:tt,onNavigate:fe}),s.jsx(or,{ref:C,value:Ne,onChange:Le,onKeyDown:Y,placeholder:de,onSubmit:()=>{!Ne.trim()&&Ce.length===0||Fe({allowDoubleMessage:!0})},onMicClick:ut,onStopClick:()=>{Ee&&Ke()},isProcessing:Me,speechEngaged:Ee,showMicButton:!xt&&d&&!Qe,ariaLabel:"Chat panel input",menuContent:k,onNavigate:fe,showDisclaimer:Z.length>0,...Ae?{enableUpload:!0,uploadedFiles:Ce,onFileChange:Ge,...y!==void 0?{acceptedFileTypes:y}:{}}:{}})]})})]})]}),Z.length===0&&s.jsxs(s.Fragment,{children:[xt&&s.jsx("div",{className:"chat-panel__speech-disabled-wrapper",children:Qe?s.jsxs(s.Fragment,{children:[" ","Speech isn't supported in Firefox. To enable speech, please use Google Chrome."]}):s.jsx(s.Fragment,{children:" To use speech, please allow Arbor to use your microphone."})}),z&&s.jsxs(se.Tabs,{className:"chat-panel__tabs",children:[s.jsx(se.Tabs.Item,{active:ct==="getting-started",tabElementProps:{onClick:()=>St("getting-started")},children:"Getting started"}),s.jsx(se.Tabs.Item,{active:ct==="recent",tabElementProps:{onClick:()=>St("recent")},children:"Recent"})]}),s.jsxs("div",{className:"chat-panel__tab-content",children:[(!z||ct==="getting-started")&&s.jsxs(s.Fragment,{children:[O.length>0&&s.jsx("div",{className:"chat-panel__sample-prompt-container",children:s.jsx(Cr,{onSelectPrompt:u=>{Fe({prompt:u,allowDoubleMessage:!0})},onPromptHover:u=>{u!=null&&Le(u)},categories:O})}),(M&&M.length>0&&O.length===0||!!(N!=null&&N.trim()))&&s.jsxs("div",{className:"chat-panel__sample-prompt-container",children:[M==null?void 0:M.map((u,R)=>s.jsx("button",{type:"button",className:"chat-panel__sample-prompt",onClick:()=>Fe({prompt:u,allowDoubleMessage:!0}),children:u},`sample-${R}`)),N&&s.jsx("button",{type:"button",className:"chat-panel__daily-prompt",onClick:()=>Fe({prompt:N,allowDoubleMessage:!0}),children:s.jsxs("span",{children:["✨"," ",s.jsx("strong",{children:"Daily Prompt:"}),s.jsx("br",{}),N]})},"daily-prompt")]})]}),z&&ct==="recent"&&s.jsx("div",{className:"chat-panel__tab-panel--recent",children:wt?s.jsx("div",{className:"chat-panel__ai-interactions-loading",children:"Loading..."}):At.length===0?s.jsx("div",{className:"chat-panel__ai-interactions-empty",children:"No previous chats found."}):s.jsx(se.Table,{wrapperClassName:"chat-panel__ai-interactions-table",hasSearch:!1,tableTheme:"tidy",domLayout:"autoHeight",rowData:At,columnDefs:Oo,defaultColDef:Lo,getRowId:({data:u})=>u.id,onRowClicked:({data:u})=>{!u||!t.canLoadHistory||(Be(u.chatId),_e(u.chatId))}})})]})]}),lt&&s.jsx("div",{className:"chat-panel-footer",children:"You've reached the maximum number of messages for this conversation"})]})};class Go{constructor(){Cn(this,"events");this.events={}}subscribe(t,r){const o=crypto.randomUUID();return this.events[t]=this.events[t]??{},this.events[t][o]=r,o}unsubscribe(t,r){typeof this.events[t]<"u"&&delete this.events[t][r]}publish(t,r){this.events[t]&&Object.keys(this.events[t]).forEach(o=>{const c=this.events[t][o];c==null||c(r)})}}const Qn=new Go;function Bo({isOpen:e,...t}){const{onClose:r}=t;return l.useEffect(()=>{const o=Qn.subscribe("ds-remove-slideover",()=>r==null?void 0:r());return()=>Qn.unsubscribe("ds-remove-slideover",o)},[r]),e?er.createPortal(s.jsx(se.Slideover,{children:s.jsx("div",{className:"ask-arbor-widget__panel",children:s.jsx(Sn,{...t,focusDelay:200})})}),document.body):null}function Wo(e){switch(e.toLowerCase()){case bn:return ot;case To:return yt;default:return null}}function $o(e){const t=[];for(const r of e.messages??[]){const o=Wo(r.role);!o||!r.content||t.push({id:r.message_id,type:o,text:r.content})}return{chatItems:t,followUpPrompts:[]}}const Yo=async(e,t)=>{try{const r=await mr(e,void 0,void 0,t);if(hr(e)&&Array.isArray(r==null?void 0:r.messages))return $o(r);if(!(r!=null&&r.items))return console.error("Invalid response in getHistoricMessages",e,r),{chatItems:[],followUpPrompts:[]};let o=[],c=[];return r.items.forEach(i=>{if("chatItems"in i)o=i.chatItems.map(({id:d,type:_,text:m,content:g,...h})=>{const w=m!=null&&m!==""?m:gn(typeof g=="string"?g:"");return{id:d,type:_.toUpperCase(),text:w,...h.element!=null&&{element:h.element}}});else if("id"in i&&"type"in i){const d=i.text!=null&&i.text!==""?i.text:gn(typeof i.content=="string"?i.content:"");o.push({id:i.id,type:i.type.toUpperCase(),text:d,...i.element!=null&&{element:i.element}})}"followUpPrompts"in i&&(c=i.followUpPrompts||[])}),{chatItems:o,followUpPrompts:c}}catch(r){return console.error("Error in getHistoricMessages",r,e),{chatItems:[],followUpPrompts:[]}}},Ko=async({rating:e,messageId:t,chatId:r,ratingUrl:o,authorizationToken:c})=>{try{await En(o,{messageId:t,rating:e,chatId:r},{authorizationToken:c})}catch(i){console.error("Error rating message",i)}},qo=async({chatId:e,notificationCallbackUrl:t,authorizationToken:r})=>{try{return await En(t,{chatId:e},{authorizationToken:r}),!0}catch(o){return console.error("Error sending notification",o),!1}};function Vo(e){return(e.conversations??[]).map(t=>{var r,o;return{id:t.session_id,chatId:t.session_id,title:((r=t.title)==null?void 0:r.trim())||((o=t.preview)==null?void 0:o.trim())||"Untitled conversation",updatedAt:t.updated_at??t.created_at??""}})}class _r{constructor(t){this.config=t}get canRate(){return!!this.config.ratingUrl}get canLoadHistory(){return!!this.config.historicChatUrl}get canListInteractions(){return!!this.config.aiInteractionsUrl}get canSendNotification(){return!!this.config.notificationCallbackUrl}get ratingPopupUrls(){return{up:this.config.upRatingPopupUrl,down:this.config.downRatingPopupUrl}}async sendMessage(t){return Co({chatUrl:this.config.chatUrl,authorizationToken:this.config.authorizationToken,agentCompletionsConfig:this.config.agentCompletionsConfig,...t})}async loadHistory(t){return this.config.historicChatUrl?Yo(`${this.config.historicChatUrl}/${t}`,this.config.authorizationToken):null}async listInteractions(){if(!this.config.aiInteractionsUrl)return null;try{const t=await mr(this.config.aiInteractionsUrl,void 0,void 0,this.config.authorizationToken);return hr(this.config.aiInteractionsUrl)&&Array.isArray(t.conversations)?Vo(t):Array.isArray(t)?t:Array.isArray(t.items)?t.items:[]}catch{return null}}async rateMessage(t){this.config.ratingUrl&&await Ko({ratingUrl:this.config.ratingUrl,authorizationToken:this.config.authorizationToken,...t})}async sendNotification(t){return this.config.notificationCallbackUrl?qo({notificationCallbackUrl:this.config.notificationCallbackUrl,authorizationToken:this.config.authorizationToken,...t}):!1}}const Xo={create(e){const t=e.model||e.agentName||e.systemPrompt||e.mcps?{...e.model&&{model:e.model},...e.agentName&&{agentName:e.agentName},...e.systemPrompt&&{systemPrompt:e.systemPrompt},...e.mcps&&{mcps:e.mcps}}:void 0;return new _r({chatUrl:e.chatUrl,authorizationToken:e.authorizationToken??void 0,historicChatUrl:e.historicChatUrl??void 0,aiInteractionsUrl:e.aiInteractionsUrl??void 0,ratingUrl:e.ratingUrl??void 0,upRatingPopupUrl:e.upRatingPopupUrl??void 0,downRatingPopupUrl:e.downRatingPopupUrl??void 0,notificationCallbackUrl:e.notificationCallbackUrl??void 0,agentCompletionsConfig:t})}};exports.AIServiceConnectorFactory=Xo;exports.AskArborSlideover=Bo;exports.AskArborWidget=Sn;exports.CHAT_RESPONSE_TYPE_AGENT=yt;exports.CHAT_RESPONSE_TYPE_ERROR=Oe;exports.CHAT_RESPONSE_TYPE_INFO=qt;exports.CHAT_RESPONSE_TYPE_USER=ot;exports.CHAT_RESPONSE_TYPE_WARNING=Pt;exports.ChatPanel=Sn;exports.FollowUpPromptButton=ir;exports.HttpAIServiceConnector=_r;
|