@arbor-education/ask-arbor-chat-panel 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +18 -18
- package/dist/index.d.ts +8 -0
- package/dist/index.js +582 -570
- package/dist/style.css +1 -1
- package/dist-iife/ask-arbor-slideover.js +59 -59
- package/dist-iife/ask-arbor-widget.js +59 -59
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var _r=Object.defineProperty;var gr=(e,t,r)=>t in e?_r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Nn=(e,t,r)=>gr(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),be=require("@arbor-education/design-system.components"),l=require("react"),qn=require("react-dom");function br(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vn={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
|
|
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})})};/**
|
|
6
6
|
* @license lucide-react v1.21.0 - ISC
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the ISC license.
|
|
@@ -17,12 +17,12 @@
|
|
|
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 xr=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,a)=>a?a.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 Rn=e=>{const t=
|
|
25
|
+
*/const Rn=e=>{const t=xr(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.
|
|
@@ -32,7 +32,7 @@
|
|
|
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 Rr=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},kr=l.createContext({}),Cr=()=>l.useContext(kr),Ir=l.forwardRef(({color:e,size:t,strokeWidth:r,absoluteStrokeWidth:a,className:u="",children:i,iconNode:d,...h},_)=>{const{size:p=24,strokeWidth:E=2,absoluteStrokeWidth:S=!1,color:g="currentColor",className:A=""}=Cr()??{},x=a??S?Number(r??E)*24/Number(t??p):r??E;return l.createElement("svg",{ref:_,...Jt,width:t??p??Jt.width,height:t??p??Jt.height,stroke:e??g,strokeWidth:x,className:Xn("lucide",A,u),...!i&&!Rr(h)&&{"aria-hidden":"true"},...h},[...d.map(([L,N])=>l.createElement(L,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.
|
|
@@ -42,52 +42,52 @@
|
|
|
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 vr=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Or=ke("arrow-right",vr);/**
|
|
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 Lr=[["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"}]],Dr=ke("circle-alert",Lr);/**
|
|
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 Mr=[["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"}]],Pr=ke("frown",Mr);/**
|
|
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 jr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ur=ke("info",jr);/**
|
|
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 Fr=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]],Hr=ke("mic-off",Fr);/**
|
|
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
|
|
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
71
|
* @license lucide-react v1.21.0 - ISC
|
|
72
72
|
*
|
|
73
73
|
* This source code is licensed under the ISC license.
|
|
74
74
|
* See the LICENSE file in the root directory of this source tree.
|
|
75
|
-
*/const
|
|
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
76
|
* @license lucide-react v1.21.0 - ISC
|
|
77
77
|
*
|
|
78
78
|
* This source code is licensed under the ISC license.
|
|
79
79
|
* See the LICENSE file in the root directory of this source tree.
|
|
80
|
-
*/const
|
|
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
81
|
* @license lucide-react v1.21.0 - ISC
|
|
82
82
|
*
|
|
83
83
|
* This source code is licensed under the ISC license.
|
|
84
84
|
* See the LICENSE file in the root directory of this source tree.
|
|
85
|
-
*/const
|
|
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
86
|
* @license lucide-react v1.21.0 - ISC
|
|
87
87
|
*
|
|
88
88
|
* This source code is licensed under the ISC license.
|
|
89
89
|
* See the LICENSE file in the root directory of this source tree.
|
|
90
|
-
*/const qr=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Vr=ke("x",qr);function Xr(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=m=>{d.current&&!d.current.contains(m.target)&&r.current&&!r.current.contains(m.target)&&t()},_=m=>{m.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:m=>{m.preventDefault(),t(),Xr(h.url,u)},children:[h.icon,s.jsx("span",{className:"ask-arbor-settings__label",children:h.label})]},`${h.label}-${_}`))}):null};Zn.displayName="AskArborSettings";function Zr(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:m,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:v=!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(Ae.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:Zr(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(Br,{size:12,stroke:"#000000"})}),s.jsx(Zn,{isOpen:$,onClose:()=>M(!1),anchorRef:j,items:V,onNavigate:m})]}),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(zr,{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(Fr,{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(vr,{size:12,stroke:"#FFFFFF",strokeWidth:2.5})})]})})]}),v&&s.jsx("p",{className:"ask-arbor-input__disclaimer",children:x})]})});Jn.displayName="AskArborInput";const Rt="AGENT",Ze="USER",Bt="INFO",kt="WARNING",Ee="ERROR",Qt="up",kn="down",In=10,Jr=({message:e,onRate:t,upRatingPopupUrl:r,downRatingPopupUrl:a,onRatingPopupOpen:u})=>{const[i,d]=l.useState(null),h=m=>{const E=m===Qt?r:a;E!=null&&E.trim()&&(u?u(E.trim()):window.open(E.trim(),"_blank","noopener,noreferrer"))},_=m=>{d(m),t(m),h(m)};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($r,{size:In,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(Mr,{size:In,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"})]})]})]})},Qr=({id:e,text:t,type:r,onRate:a,ratingPopupUrls:u={},chatId:i,showRating:d=!1,followUpPrompts:h,onFollowUpPromptClick:_,processCanvasReferences:m,isFallbackMessage:E,onRatingPopupOpen:S,children:g})=>{const A=r===Rt,x=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:pe("chat-message",{"chat-message--user":r===Ze,"chat-message--agent":r===Rt,"chat-message--info":r===Bt,"chat-message--error":r===Ee,"chat-message--warning":r===kt}),children:[r===Bt&&s.jsx(jr,{className:"chat-message__icon","aria-label":"Information",size:20}),r===kt&&s.jsx(Kr,{className:"chat-message__icon","aria-label":"Warning",size:20}),r===Ee&&s.jsx(Lr,{className:"chat-message__icon","aria-label":"Error",size:20}),g??s.jsx("span",{dangerouslySetInnerHTML:{__html:m(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(Jr,{upRatingPopupUrl:u.up,downRatingPopupUrl:u.down,message:{id:e,type:r,text:t},onRate:v=>a(v,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((v,N)=>s.jsx("li",{children:s.jsx("button",{type:"button",className:"chat-message__follow-up-prompt",onClick:()=>_==null?void 0:_(v),children:v})},`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})},es="Not authorised. Your session could have expired or is invalid. Please refresh the page and try again.",ts="You do not have permission to use this feature. Please contact your administrator if you need access.",ns="The chat service could not be found. Please check your configuration and try again.",rs="It looks like this request took too long to complete. Please try again.",ss="Whoops! Too many requests. Please wait a moment and try again.",os="The chat service is temporarily unavailable. Please try again later.",as="Unable to reach the chat service. Please check your connection and try again.",Qn="Something went wrong. Please try again later.",is="Something went wrong while trying to get a new agent message. Please try again later.",Cn="keyboard-shortcut-menu-portal";function cs(){let e=document.getElementById(Cn);return e||(e=document.createElement("div"),e.id=Cn,e.style.cssText="position:fixed;left:0;top:0;z-index:19950;pointer-events:none;",document.body.appendChild(e)),e}const Wt=200;function ls(e){const t=window.innerHeight,r=e.top+e.height>t-Wt,a=e.top<Wt;return r?"above":a?"below":"above"}function us(e){const t=ls(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 ds=({anchorRef:e,...t})=>{const[r,a]=l.useState(null);if(l.useLayoutEffect(()=>{const i=()=>{const m=e.current;if(!m)return;const E=m.getBoundingClientRect();a(us(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(er,{...t,portalStyle:u}),cs())},er=e=>{const{menuItems:t=[],onSelectItem:r,onClose:a,hideReferenceFromList:u=!1,anchorRef:i,portalStyle:d,onNavigate:h}=e,[_,m]=l.useState(0),[E,S]=l.useState(""),[g,A]=l.useState(t),x=l.useRef(null),v=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(()=>{m(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(),O=window.innerHeight,H=y.top,ee=H+y.height>O-Wt,L=H<Wt;j(ee?!1:!!L),U(!0),setTimeout(()=>{var z;return(z=N.current)==null?void 0:z.focus()},0)},[i]),l.useEffect(()=>{if(v.current){const y=v.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"})}},[_]),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 O;r&&g[y]&&!g[y].link&&r(g[y]),a&&!((O=g[y])!=null&&O.link)&&a()};l.useEffect(()=>{const y=H=>{H.key==="Escape"&&a&&(H.preventDefault(),a())},O=H=>{x.current&&!x.current.contains(H.target)&&a&&a()};return document.addEventListener("keydown",y),document.addEventListener("mousedown",O),()=>{document.removeEventListener("keydown",y),document.removeEventListener("mousedown",O)}},[a]);const de=y=>{switch(y.key){case"ArrowDown":y.preventDefault(),m(O=>O<g.length-1?O+1:O);break;case"ArrowUp":y.preventDefault(),m(O=>O>0?O-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),m(0)},F=(y,O)=>{const H=O===_,ee=y.icon?s.jsxs(s.Fragment,{children:[s.jsx(Ae.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 L=y.link.replace(/\/\?/g,"");return s.jsx("li",{role:"menuitem",children:s.jsx("a",{href:L,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(L,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:v,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(Vr,{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,O)=>F(y,O))})]})});return i&&!d?s.jsx(ds,{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"})]})}),fs=4e3,ps=500,ms=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…"],hs=({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()]),[m,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)},ms);return()=>{clearTimeout(w)}},[r,a]);const v=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")},ps)},fs),()=>{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 ${m}`,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:v,"aria-label":"Let me know when it's done",children:"Let me know when it's done"})]})})]})};function _s(e){l.useEffect(e,[])}function gs(){const e=l.useRef(!1);return l.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function bs(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2)+Date.now().toString(36)}function ys(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 Ts=/\*\*(.+?)\*\*/g;function Es(e){return e.replace(Ts,"<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 As(e){if(Array.isArray(e))return e}function Ss(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,m=!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){m=!0,u=E}finally{try{if(!_&&r.return!=null&&(d=r.return(),Object(d)!==d))return}finally{if(m)throw u}}return h}}function Ns(){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 ws(e,t){return As(e)||Ss(e,t)||xs(e,t)||Ns()}function xs(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 tr=Object.entries,Dn=Object.setPrototypeOf,Rs=Object.isFrozen,ks=Object.getPrototypeOf,Is=Object.getOwnPropertyDescriptor;let re=Object.freeze,se=Object.seal,ft=Object.create,nr=typeof Reflect<"u"&&Reflect,cn=nr.apply,ln=nr.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 At=q(Array.prototype.forEach),Cs=q(Array.prototype.lastIndexOf),Mn=q(Array.prototype.pop),dt=q(Array.prototype.push),vs=q(Array.prototype.splice),Fe=Array.isArray,xt=q(String.prototype.toLowerCase),tn=q(String.prototype.toString),Pn=q(String.prototype.match),St=q(String.prototype.replace),jn=q(String.prototype.indexOf),Os=q(String.prototype.trim),Ls=q(Number.prototype.toString),Ds=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),Nt=q(Object.prototype.toString),ne=q(RegExp.prototype.test),Xe=Ms(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 Ms(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 I(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:xt;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&&(Rs(t)||(t[a]=i),u=i)}e[u]=!0}return e}function Ps(e){for(let t=0;t<e.length;t++)Q(e,t)||(e[t]=null);return e}function ie(e){const t=ft(null);for(const a of tr(e)){var r=ws(a,2);const u=r[0],i=r[1];Q(e,u)&&(Fe(i)?t[u]=Ps(i):i&&typeof i=="object"&&i.constructor===Object?t[u]=ie(i):t[u]=i)}return t}function js(e){switch(typeof e){case"string":return e;case"number":return Ls(e);case"boolean":return Ds(e);case"bigint":return Un?Un(e):"0";case"symbol":return Fn?Fn(e):"Symbol()";case"undefined":return Nt(e);case"function":case"object":{if(e===null)return Nt(e);const t=e,r=Re(t,"toString");if(typeof r=="function"){const a=r(t);return typeof a=="string"?a:Nt(a)}return Nt(e)}default:return Nt(e)}}function Re(e,t){for(;e!==null;){const a=Is(e,t);if(a){if(a.get)return q(a.get);if(typeof a.value=="function")return q(a.value)}e=ks(e)}function r(){return null}return r}function Us(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"]),Fs=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"]),Hs=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"]),zs=se(/{{[\w\W]*|^[\w\W]*}}/g),Gs=se(/<%[\w\W]*|^[\w\W]*%>/g),Bs=se(/\${[\w\W]*/g),Ws=se(/^data-[\-\w.\u00B7-\uFFFF]+$/),$s=se(/^aria-[\-\w]+$/),Wn=se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ys=se(/^(?:\w+script|data):/i),Ks=se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),qs=se(/^html$/i),Vs=se(/^[a-z][.\w]*(-[.\w]+)+$/i),$n=se(/<[/\w!]/g),Xs=se(/<[/\w]/g),Zs=se(/<\/no(script|embed|frames)/i),Js=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},Qs=function(){return typeof window>"u"?null:window},eo=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])?I(u.base?ie(u.base):{},t[r],u.transform):a};function rr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Qs();const t=p=>rr(p);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,m=e.NamedNodeMap;m===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"),v=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 p=r.createElement("template");p.content&&p.content.ownerDocument&&(r=p.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--}},O=function(n){ce(),F++;try{return M.createScriptURL(n)}finally{F--}},H=function(){return V||(de=eo(S,u),V=!0),de},ee=r,L=ee.implementation,z=ee.createNodeIterator,fe=ee.createDocumentFragment,Ie=ee.getElementsByTagName,Oe=a.importNode;let P=Yn();t.isSupported=typeof tr=="function"&&typeof w=="function"&&L&&L.createHTMLDocument!==void 0;const te=zs,pt=Gs,X=Bs,mt=Ws,$t=$s,It=Ys,Je=Ks,He=Vs;let Le=Wn,D=null;const Qe=I({},[...Hn,...nn,...rn,...sn,...zn]);let B=null;const et=I({},[...Gn,...on,...Bn,...zt]);let G=Object.seal(ft(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,ht=null;const be=Object.seal(ft(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ct=!0,ze=!0,tt=!1,De=!0,ye=!1,Ge=!0,Ne=!1,nt=!1,Be=null,Me=null,rt=!1,Ce=!1,We=!1,st=!1,_t=!0,$e=!1;const ot="user-content-";let gt=!0,at=!1,Pe={},me=null;const Ye=I({},["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=I({},["audio","video","img","source","image","track"]);let bt=null;const Ot=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),we="http://www.w3.org/1998/Math/MathML",it="http://www.w3.org/2000/svg",Z="http://www.w3.org/1999/xhtml";let he=Z,ct=!1,lt=null;const Yt=I({},[we,it,Z],tn),Lt=re(["mi","mo","mn","ms","mtext"]);let yt=I({},Lt);const Dt=re(["annotation-xml"]);let Tt=I({},Dt);const Kt=I({},["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:xt,D=Ue(n,"ALLOWED_TAGS",Qe,{transform:W}),B=Ue(n,"ALLOWED_ATTR",et,{transform:W}),lt=Ue(n,"ALLOWED_NAMESPACES",Yt,{transform:tn}),bt=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}),ht=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,Ct=n.ALLOW_ARIA_ATTR!==!1,ze=n.ALLOW_DATA_ATTR!==!1,tt=n.ALLOW_UNKNOWN_PROTOCOLS||!1,De=n.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ye=n.SAFE_FOR_TEMPLATES||!1,Ge=n.SAFE_FOR_XML!==!1,Ne=n.WHOLE_DOCUMENT||!1,Ce=n.RETURN_DOM||!1,We=n.RETURN_DOM_FRAGMENT||!1,st=n.RETURN_TRUSTED_TYPE||!1,rt=n.FORCE_BODY||!1,_t=n.SANITIZE_DOM!==!1,$e=n.SANITIZE_NAMED_PROPS||!1,gt=n.KEEP_CONTENT!==!1,at=n.IN_PLACE||!1,Le=Us(n.ALLOWED_URI_REGEXP)?n.ALLOWED_URI_REGEXP:Wn,he=typeof n.NAMESPACE=="string"?n.NAMESPACE:Z,yt=Q(n,"MATHML_TEXT_INTEGRATION_POINTS")&&n.MATHML_TEXT_INTEGRATION_POINTS&&typeof n.MATHML_TEXT_INTEGRATION_POINTS=="object"?ie(n.MATHML_TEXT_INTEGRATION_POINTS):I({},Lt),Tt=Q(n,"HTML_INTEGRATION_POINTS")&&n.HTML_INTEGRATION_POINTS&&typeof n.HTML_INTEGRATION_POINTS=="object"?ie(n.HTML_INTEGRATION_POINTS):I({},Dt);const o=Q(n,"CUSTOM_ELEMENT_HANDLING")&&n.CUSTOM_ELEMENT_HANDLING&&typeof n.CUSTOM_ELEMENT_HANDLING=="object"?ie(n.CUSTOM_ELEMENT_HANDLING):ft(null);if(G=ft(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),ye&&(ze=!1),We&&(Ce=!0),Pe&&(D=I({},zn),B=ft(null),Pe.html===!0&&(I(D,Hn),I(B,Gn)),Pe.svg===!0&&(I(D,nn),I(B,on),I(B,zt)),Pe.svgFilters===!0&&(I(D,rn),I(B,on),I(B,zt)),Pe.mathMl===!0&&(I(D,sn),I(B,Bn),I(B,zt))),be.tagCheck=null,be.attributeCheck=null,Q(n,"ADD_TAGS")&&(typeof n.ADD_TAGS=="function"?be.tagCheck=n.ADD_TAGS:Fe(n.ADD_TAGS)&&(D===Qe&&(D=ie(D)),I(D,n.ADD_TAGS,W))),Q(n,"ADD_ATTR")&&(typeof n.ADD_ATTR=="function"?be.attributeCheck=n.ADD_ATTR:Fe(n.ADD_ATTR)&&(B===et&&(B=ie(B)),I(B,n.ADD_ATTR,W))),Q(n,"ADD_URI_SAFE_ATTR")&&Fe(n.ADD_URI_SAFE_ATTR)&&I(bt,n.ADD_URI_SAFE_ATTR,W),Q(n,"FORBID_CONTENTS")&&Fe(n.FORBID_CONTENTS)&&(me===Ye&&(me=ie(me)),I(me,n.FORBID_CONTENTS,W)),Q(n,"ADD_FORBID_CONTENTS")&&Fe(n.ADD_FORBID_CONTENTS)&&(me===Ye&&(me=ie(me)),I(me,n.ADD_FORBID_CONTENTS,W)),gt&&(D["#text"]=!0),Ne&&I(D,["html","head","body"]),D.table&&(I(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=I({},[...nn,...rn,...Fs]),le=I({},[...sn,...Hs]),Pt=function(n,o,f){return o.namespaceURI===Z?n==="svg":o.namespaceURI===we?n==="svg"&&(f==="annotation-xml"||yt[f]):!!_e[n]},_n=function(n,o,f){return o.namespaceURI===Z?n==="math":o.namespaceURI===it?n==="math"&&Tt[f]:!!le[n]},gn=function(n,o,f){return o.namespaceURI===it&&!Tt[f]||o.namespaceURI===we&&!yt[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=xt(n.tagName),b=xt(o.tagName);return lt[n.namespaceURI]?n.namespaceURI===it?Pt(f,o,b):n.namespaceURI===we?_n(f,o,b):n.namespaceURI===Z?gn(f,o,b):!!(qe==="application/xhtml+xml"&<[n.namespaceURI]):!1},je=function(n){dt(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=[];At(o,R=>{dt(b,R)}),At(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],C=R&&R.name;if(typeof C=="string")try{n.removeAttribute(C)}catch{}}},Ve=function(n,o){try{dt(t.removed,{attribute:o.getAttributeNode(n),from:o})}catch{dt(t.removed,{attribute:null,from:o})}if(o.removeAttribute(n),n==="is")if(Ce||We)try{je(o)}catch{}else try{o.setAttribute(n,"")}catch{}},cr=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{}}},lr=function(n){const o=[n];for(;o.length>0;){const f=o.pop();(U?U(f):f.nodeType)===xe.element&&cr(f);const R=N(f);if(R)for(let C=R.length-1;C>=0;--C)o.push(R[C])}},yn=function(n){let o=null,f=null;if(rt)n="<remove></remove>"+n;else{const C=Pn(n,/^[\r\n\t ]+/);f=C&&C[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=L.createDocument(he,"template",null);try{o.documentElement.innerHTML=ct?Y:b}catch{}}const R=o.body||o.documentElement;return n&&f&&R.insertBefore(r.createTextNode(f),R.childNodes[0]||null),he===Z?Ie.call(o,Ne?"html":"body")[0]:Ne?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=St(n,te," "),n=St(n,pt," "),n=St(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&&At(R,C=>{ut(C.content)&&Vt(C.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)},ut=function(n){if(!U||typeof n!="object"||n===null)return!1;try{return U(n)===xe.documentFragment}catch{return!1}},Et=function(n){if(!U||typeof n!="object"||n===null)return!1;try{return typeof U(n)=="number"}catch{return!1}};function ve(p,n,o){p.length!==0&&At(p,f=>{f.call(t,n,o,c)})}const ur=function(n,o){return!!(Ge&&n.hasChildNodes()&&!Et(n.firstElementChild)&&ne($n,n.textContent)&&ne($n,n.innerHTML)||Ge&&n.namespaceURI===Z&&o==="style"&&Et(n.firstElementChild)||n.nodeType===xe.processingInstruction||Ge&&n.nodeType===xe.comment&&ne(Xs,n.data))},dr=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(gt&&!me[o]){const f=w(n),b=N(n);if(b&&f){const R=b.length;for(let C=R-1;C>=0;--C){const J=at?b[C]:A(b[C],!0);f.insertBefore(J,v(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}),ur(n,o))return je(n),!0;if(Se[o]||!(be.tagCheck instanceof Function&&be.tagCheck(o))&&!D[o])return dr(n,o);if((U?U(n):n.nodeType)===xe.element&&!jt(n)||(o==="noscript"||o==="noembed"||o==="noframes")&&ne(Zs,n.innerHTML))return je(n),!0;if(ye&&n.nodeType===xe.text){const b=Ut(n.textContent);n.textContent!==b&&(dt(t.removed,{element:n.cloneNode()}),n.textContent=b)}return ve(P.afterSanitizeElements,n,null),!1},An=function(n,o,f){if(ht[o]||_t&&(o==="id"||o==="name")&&(f in r||f in T))return!1;const b=B[o]||be.attributeCheck instanceof Function&&be.attributeCheck(o,n);if(!(ze&&ne(mt,o))){if(!(Ct&&ne($t,o))){if(b){if(!bt[o]){if(!ne(Le,St(f,Je,""))){if(!((o==="src"||o==="xlink:href"||o==="href")&&n!=="script"&&jn(f,"data:")===0&&vt[n])){if(!(tt&&!ne(It,St(f,Je,"")))){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},fr=I({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Sn=function(n){return!fr[xt(n)]&&ne(He,n)},pr=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 O(b)}return b},mr=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)}},Nn=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 C=o[b],J=C.name,K=C.namespaceURI,ge=C.value,Te=W(J),Zt=ge;let ae=J==="value"?Zt:Os(Zt);if(f.attrName=Te,f.attrValue=ae,f.keepAttr=!0,f.forceKeepAttr=void 0,ve(P.uponSanitizeAttribute,n,f),ae=f.attrValue,$e&&(Te==="id"||Te==="name")&&jn(ae,ot)!==0&&(Ve(J,n),ae=ot+ae),Ge&&ne(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ae)){Ve(J,n);continue}if(Te==="attributename"&&Pn(ae,"href")){Ve(J,n);continue}if(!f.forceKeepAttr){if(!f.keepAttr){Ve(J,n);continue}if(!De&&ne(Js,ae)){Ve(J,n);continue}if(ye&&(ae=Ut(ae)),!An(R,Te,ae)){Ve(J,n);continue}ae=pr(R,Te,K,ae),ae!==Zt&&mr(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),Nn(o),ut(o.content)&&Ht(o.content),(U?U(o):o.nodeType)===xe.element){const R=j(o);ut(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,C=(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(C){const K=$?$(b):null;if(typeof K=="string"&&W(K)==="template"){const ge=b.content;ut(ge)&&o.push({node:ge,shadow:null})}}if(C){const K=j(b);ut(K)&&o.push({node:null,shadow:K},{node:K,shadow:null})}}};return t.sanitize=function(p){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=null,f=null,b=null,R=null;if(ct=!p,ct&&(p="<!-->"),typeof p!="string"&&!Et(p)&&(p=js(p),typeof p!="string"))throw Xe("dirty is not a string, aborting");if(!t.isSupported)return p;nt?(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 C=at&&typeof p!="string"&&Et(p);if(C){const ge=$?$(p):p.nodeName;if(typeof ge=="string"){const Te=W(ge);if(!D[Te]||Se[Te])throw Xe("root node is forbidden and cannot be sanitized in-place")}if(Ft(p))throw Xe("root node is clobbered and cannot be sanitized in-place");try{Xt(p)}catch(Te){throw bn(p),Te}}else if(Et(p))o=yn("<!---->"),f=o.ownerDocument.importNode(p,!0),f.nodeType===xe.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?o=f:o.appendChild(f),Xt(f);else{if(!Ce&&!ye&&!Ne&&p.indexOf("<")===-1)return M&&st?y(p):p;if(o=yn(p),!o)return Ce?null:st?Y:""}o&&rt&&je(o.firstChild);const J=Tn(C?p:o);try{for(;b=J.nextNode();)En(b),Nn(b),ut(b.content)&&Ht(b.content)}catch(ge){throw C&&bn(p),ge}if(C)return At(t.removed,ge=>{ge.element&&lr(ge.element)}),ye&&Vt(p),p;if(Ce){if(ye&&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=Ne?o.outerHTML:o.innerHTML;return Ne&&D["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&ne(qs,o.ownerDocument.doctype.name)&&(K="<!DOCTYPE "+o.ownerDocument.doctype.name+`>
|
|
92
|
-
`+K),
|
|
93
|
-
`);u=x.pop()??"";for(const v of x){const N=v.trim();if(N==="event: error"){_=!0;continue}const w=lo(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 fo({chatUrl:e,chatId:t,userMessage:r,chatHistory:a,authorizationToken:u,config:i}){const d=co({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 uo(h)}function po(e){switch(e){case 401:return{text:es,type:Ee};case 403:return{text:ts,type:Ee};case 404:return{text:ns,type:Ee};case 408:case 504:return{text:rs,type:kt};case 429:return{text:ss,type:kt};default:return e>=500?{text:os,type:Ee}:{text:Qn,type:Ee}}}function mo(e){return e instanceof pn?po(e.status):e instanceof TypeError?{text:as,type:Ee}:{text:Qn,type:Ee}}const ho=55e3,fn="fallback",_o=async({chatId:e=void 0,chatUrl:t,userMessage:r,userInputDeviceLastUsed:a,chatHistory:u,canvasHistory:i,authorizationToken:d,agentCompletionsConfig:h})=>{let _;try{if(oo(t)){const N=await fo({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:Rt}: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}),v=new Promise(N=>setTimeout(()=>{A.abort(),N({items:[{id:fn,hardStopped:!0,type:Bt}]})},ho));_=await Promise.race([x,v])}catch(g){console.error("Error in getNewAgentMessage",g);const{text:A,type:x}=mo(g);return{text:A,type:x,id:crypto.randomUUID()}}const m=_.items[0];if(!m)return null;const E=m.text!=null&&m.text!==""?m.text:un(typeof m.content=="string"?m.content:"");return{text:typeof E=="string"?E:"",id:m.id,...m.chatId!=null&&{chatId:m.chatId},...m.timedOut!=null&&{timedOut:m.timedOut},...m.deferred!=null&&{deferred:m.deferred},...m.hardStopped!=null&&{hardStopped:m.hardStopped},type:m.type,...m.element!=null&&{element:m.element}}},go=e=>new Date(e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),bo=[{field:"title",headerName:"Conversation",flex:1},{field:"updatedAt",headerName:"Last Conversation",width:140,valueFormatter:({value:e})=>go(e)}],yo={sortable:!1,filter:!1,resizable:!1,editable:!1,suppressHeaderMenuButton:!0},an="NONE",To="KEYBOARD",Eo="VOICE",Ao="MIXED",So=2e4,No=15,wo=(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:m,canvasHistory:E,refreshAgentMessages:S,startQuery:g,slashMenuItems:A,menuContent:x,samplePrompts:v,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},O=gs(),H=l.useRef(null),ee=l.useRef(null),L=l.useRef(null),z=l.useRef(null),fe=l.useRef(null),Ie=l.useRef(null),[Oe,P]=l.useState(()=>i?"":g??""),[te,pt]=l.useState(i),[X,mt]=l.useState([]),[$t,It]=l.useState([]),Je=c=>{(!ce.current||c.id==="DEEP_THINKING_MESSAGE")&&mt(T=>[...T,c])},[He,Le]=l.useState(!1),[D,Qe]=l.useState(!1),[B,et]=l.useState(!1),G=l.useRef(!1),Se=l.useRef(null),ht=l.useRef(!1),[be,Ct]=l.useState(!1),[ze,tt]=l.useState(an),[De,ye]=l.useState(!1),[Ge,Ne]=l.useState(!0),[nt,Be]=l.useState(!1),[Me,rt]=l.useState("getting-started"),[Ce,We]=l.useState([]),[st,_t]=l.useState(!1),$e=ys(u,0),ot=$e>0&&X.length>=$e,gt=He||D;_s(()=>{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[at,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(()=>{m&&m.length>0&&mt(m)},[m]);const Ke=async(c=te)=>{if(!t.canLoadHistory||!c)return;Qe(!0);const T=await t.loadHistory(c);if(O.current){if(JSON.stringify(T)===JSON.stringify(X)||!T){Qe(!1);return}return T.chatItems.length>0&&mt(T.chatItems),It(T.followUpPrompts),Qe(!1),Ct(!0),T}};l.useEffect(()=>{S&&!ce.current&&Ke()},[S]),l.useEffect(()=>{O.current&&t.canLoadHistory&&i&&(be||Ke(i))},[i,t.canLoadHistory,be]),l.useLayoutEffect(()=>{L.current&&L.current.scrollTo({top:L.current.scrollHeight,behavior:"smooth"})},[X]);const bt=c=>{const T=Es(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 wo(So,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){Je({text:is,id:fn,type:Ee});return}return le},we=()=>{setTimeout(()=>{var c;(c=H.current)==null||c.focus()},0)},it=async c=>{It(null),Le(!0);const T=await t.sendMessage({chatId:te,userMessage:c,userInputDeviceLastUsed:ze,chatHistory:X,canvasHistory:E});if(!T){Le(!1),we();return}if(T.deferred===!0){T.chatId&&pt(T.chatId);const k=T.chatId||te;Se.current=new AbortController;try{await Ot({maxAttempts:No,chatIdToFetch:k,signal:Se.current.signal})}finally{Se.current=null}O.current&&(Le(!1),we());return}if(T.hardStopped===!0){!G.current&&t.canSendNotification&&te&&await t.sendNotification({chatId:te})&&(G.current=!0),O.current&&(et(!0),Le(!1),we());return}Je({text:ro(T.text),type:T.type,id:T.id,...T.element!=null&&{element:T.element}}),T.chatId&&pt(T.chatId),Le(!1),we()},Z=async({prompt:c=null,allowDoubleMessage:T=!1}={})=>{var _e;let k=null;if(c!=null&&c.trim()!==""&&(k=c.trim()),k===null&&(k=so(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=Ie.current)==null||_e.cancel(),he(),et(!1),G.current=!1,Je({type:Ze,text:k,id:bs()}),P(""),we(),y(!1),await it(k),tt(an)};l.useEffect(()=>{if(ht.current||!(g!=null&&g.trim())||i)return;ht.current=!0;const c=setTimeout(()=>{Z({prompt:g})},V??0);return()=>clearTimeout(c)},[]);const he=()=>{fe.current&&(fe.current.stop(),fe.current=null),ye(!1),z.current&&(clearTimeout(z.current),z.current=null)},ct=yr(c=>{he(),c.trim().length>0&&Ge&&Z()},_);Ie.current=ct;const lt=c=>{if(ze===an){tt(c);return}if(ze!==c){tt(Ao);return}},Yt=()=>{if(He||D)return;lt(Eo),Ne(!0);const c=new window.webkitSpeechRecognition;fe.current=c,c.continuous=!0,c.interimResults=!0,c.lang=h,c.start(),c.onstart=()=>{ye(!0)},c.onresult=T=>{const k=Array.from(T.results).map(oe=>oe[0]).map(oe=>oe.transcript).join("");k!==Oe&&P(k),ct(k)},c.onerror=()=>{he()}},Lt=()=>{De?he():Yt()},yt=!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 _t(!0),t.listInteractions().then(T=>{c||We(T??[])}).catch(()=>{c||We([])}).finally(()=>{c||_t(!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}}):[],Tt=c=>{c.key!=="Enter"&&(lt(To),De&&Ne(!1),c.key==="/"&&Oe.length===0&&(A!=null&&A.length)&&(Be(!0),c.preventDefault())),c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),yt&&Z({allowDoubleMessage:!0})),c.key==="Escape"&&nt&&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(()=>{et(!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&&!ot)&&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:L,children:[X.map((c,T)=>{const k=T===X.length-1,oe=k?$t:void 0,_e=c.id===fn,le=k;return s.jsx(Qr,{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:bt,isFallbackMessage:_e,onRatingPopupOpen:de},`${c.id}_${T}`)}),gt&&s.jsx(hs,{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&&!ot&&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(Tr,{})}),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:[nt&&s.jsx(er,{anchorRef:ee,menuItems:Dt(),onClose:Kt,onNavigate:Y}),s.jsx(Jn,{ref:H,value:Oe,onChange:P,onKeyDown:Tt,placeholder:ue,onSubmit:()=>{Oe.trim()&&Z({allowDoubleMessage:!0})},onMicClick:Lt,onStopClick:()=>{De&&he()},isProcessing:He,speechEngaged:De,showMicButton:!at&&d&&!Ye,ariaLabel:"Chat panel input",menuContent:x,onNavigate:Y,showDisclaimer:X.length>0})]})})]})]}),X.length===0&&s.jsxs(s.Fragment,{children:[at&&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(Ae.Tabs,{className:"chat-panel__tabs",children:[s.jsx(Ae.Tabs.Item,{active:Me==="getting-started",tabElementProps:{onClick:()=>rt("getting-started")},children:"Getting started"}),s.jsx(Ae.Tabs.Item,{active:Me==="recent",tabElementProps:{onClick:()=>rt("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(Sr,{onSelectPrompt:c=>{Z({prompt:c,allowDoubleMessage:!0})},onPromptHover:c=>{c!=null&&P(c)},categories:F})}),(v&&v.length>0&&F.length===0||!!(N!=null&&N.trim()))&&s.jsxs("div",{className:"chat-panel__sample-prompt-container",children:[v==null?void 0:v.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:st?s.jsx("div",{className:"chat-panel__ai-interactions-loading",children:"Loading..."}):Ce.length===0?s.jsx("div",{className:"chat-panel__ai-interactions-empty",children:"No previous chats found."}):s.jsx(Ae.Table,{wrapperClassName:"chat-panel__ai-interactions-table",hasSearch:!1,tableTheme:"tidy",domLayout:"autoHeight",rowData:Ce,columnDefs:bo,defaultColDef:yo,getRowId:({data:c})=>c.id,onRowClicked:({data:c})=>{!c||!t.canLoadHistory||(pt(c.chatId),Ke(c.chatId))}})})]})]}),ot&&s.jsx("div",{className:"chat-panel-footer",children:"You've reached the maximum number of messages for this conversation"})]})};class xo{constructor(){wn(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 xo;function Ro({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(Ae.Slideover,{children:s.jsx("div",{className:"ask-arbor-widget__panel",children:s.jsx(hn,{...t,focusDelay:200})})}),document.body):null}function ko(e){switch(e.toLowerCase()){case dn:return Ze;case ao:return Rt;default:return null}}function Io(e){const t=[];for(const r of e.messages??[]){const a=ko(r.role);!a||!r.content||t.push({id:r.message_id,type:a,text:r.content})}return{chatItems:t,followUpPrompts:[]}}const Co=async(e,t)=>{try{const r=await or(e,void 0,void 0,t);if(ar(e)&&Array.isArray(r==null?void 0:r.messages))return Io(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:m,...E})=>{const S=_!=null&&_!==""?_:un(typeof m=="string"?m:"");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:[]}}},vo=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)}},Oo=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 Lo(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 ir{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 _o({chatUrl:this.config.chatUrl,authorizationToken:this.config.authorizationToken,agentCompletionsConfig:this.config.agentCompletionsConfig,...t})}async loadHistory(t){return this.config.historicChatUrl?Co(`${this.config.historicChatUrl}/${t}`,this.config.authorizationToken):null}async listInteractions(){if(!this.config.aiInteractionsUrl)return null;try{const t=await or(this.config.aiInteractionsUrl,void 0,void 0,this.config.authorizationToken);return ar(this.config.aiInteractionsUrl)&&Array.isArray(t.conversations)?Lo(t):Array.isArray(t)?t:Array.isArray(t.items)?t.items:[]}catch{return null}}async rateMessage(t){this.config.ratingUrl&&await vo({ratingUrl:this.config.ratingUrl,authorizationToken:this.config.authorizationToken,...t})}async sendNotification(t){return this.config.notificationCallbackUrl?Oo({notificationCallbackUrl:this.config.notificationCallbackUrl,authorizationToken:this.config.authorizationToken,...t}):!1}}const Do={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 ir({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=Do;exports.AskArborSlideover=Ro;exports.AskArborWidget=hn;exports.CHAT_RESPONSE_TYPE_AGENT=Rt;exports.CHAT_RESPONSE_TYPE_ERROR=Ee;exports.CHAT_RESPONSE_TYPE_INFO=Bt;exports.CHAT_RESPONSE_TYPE_USER=Ze;exports.CHAT_RESPONSE_TYPE_WARNING=kt;exports.ChatPanel=hn;exports.HttpAIServiceConnector=ir;
|
|
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;
|
package/dist/index.d.ts
CHANGED
|
@@ -143,6 +143,13 @@ declare type ConnectorConfig_2 = {
|
|
|
143
143
|
|
|
144
144
|
declare type DSIconName = ComponentProps<typeof Icon>['name'];
|
|
145
145
|
|
|
146
|
+
export declare const FollowUpPromptButton: ({ prompt, onClick }: FollowUpPromptButtonProps) => JSX_2.Element;
|
|
147
|
+
|
|
148
|
+
export declare type FollowUpPromptButtonProps = {
|
|
149
|
+
prompt: string;
|
|
150
|
+
onClick: (prompt: string) => void;
|
|
151
|
+
};
|
|
152
|
+
|
|
146
153
|
export declare type HistoricMessages = {
|
|
147
154
|
chatItems: ChatMessage[];
|
|
148
155
|
followUpPrompts: string[];
|
|
@@ -245,6 +252,7 @@ export declare type SendMessageResult = {
|
|
|
245
252
|
hardStopped?: boolean;
|
|
246
253
|
type: MessageType;
|
|
247
254
|
element?: CanvasElement | CanvasElement[];
|
|
255
|
+
followUpPrompts?: string[] | null;
|
|
248
256
|
};
|
|
249
257
|
|
|
250
258
|
export declare type SendNotificationParams = {
|