@deepdesk/deepdesk-sdk 14.3.1-beta.4 → 14.3.1-beta.6
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.js +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/index.iife.js +2 -2
- package/package.json +1 -1
- package/styles/index.js +1 -1
- package/styles.css +1 -1
- package/widget.css +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -22,9 +22,9 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
|
22
22
|
c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
|
|
23
23
|
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var qh=x(T()),tN={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},HE=({className:e,color:t})=>(0,qh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,qh.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:tN[t||"pink"]})});var UE={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var Gh={};at(Gh,{enUS:()=>nN,nlNL:()=>rN});var nN={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},rN={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Vo=x(T()),jE=({onLogIn:e})=>{let t=Y(Gh),n=U("floatingMenu"),r=U("productName"),o=J(),i=M(ct),s=A("FloatingMenu",UE);if(i===null||n===!1)return null;let a=()=>{i===!0?o(Yt(!0)):e()};return(0,Vo.jsxs)("button",{className:(0,zE.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,Vo.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,Vo.jsxs)("div",{className:s.icon,children:[(0,Vo.jsx)(HE,{className:s.logo,color:"pink"}),i===!1&&(0,Vo.jsx)(FE,{className:s.lock})]})]})};var nf=x(F());var BE=x(F());function Xr(e){(0,BE.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function Wo(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}function _n(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input;return i.start!==i.end?!1:i.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(i.end))||r&&new RegExp(r).test(o.substring(0,i.end))?!0:n===!1&&r===!1:!1}var oN={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Zd=({ui:e})=>e.overlayCollapsed,VE=ne({name:"ui",initialState:oN,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputFocus(e,t){e.overlayCollapsedUserOverwrite!==!0&&(t.payload===!0&&(e.overlayCollapsed=!1),e.inputHasFocus=t.payload)},setOverlayCollapsed(e,t){t.payload.collapse===!1&&(e.openOverlayWhenTyping=!1),!(t.payload.skipWhenInputFocus&&e.inputHasFocus)&&(e.overlayCollapsed=t.payload.collapse)},setOpenOverlayWhenTyping(e,t){e.openOverlayWhenTyping=t.payload},setOverlayCollapsedUserOverwrite(e,t){e.overlayCollapsedUserOverwrite=t.payload,e.overlayCollapsed=t.payload}}}),{setShowTabHint:Tl,setInputFocus:Jd,setOverlayCollapsed:Zr,setOpenOverlayWhenTyping:WE,setOverlayCollapsedUserOverwrite:KE}=VE.actions,$E=VE.reducer;var ef=x(F());var vs=x(F());var qE=x(F());function GE(e,t,n){(0,qE.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var YE={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var Ko=x(T()),sN=["search","personal-collection-search","search-autocomplete"];function aN(e,t,n,r={}){var i;let o="";return sN.includes(t)?o=Gb(Nh(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=Nh(e,n,r),r.placeholders===!0&&(o=Yb(o)),o}var lN=()=>{},uN=({selected:e,suggestion:t})=>{let n=U("inlineSuggestions"),r=M(is),o=U("enableSuggestionFeedback"),i=M(c=>c.input.text),s=J(),a=A("TextSuggestion",YE),l=(0,vs.useRef)(null);(0,vs.useEffect)(()=>{let c=setTimeout(()=>{s(D1({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(c)}},[t]),GE(l,"click",()=>{s(un({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,vs.useMemo)(()=>aN(t.text,t.source,r,{stripAgentPart:n,placeholders:!0,searchKeywords:t.searchKeywords}),[n,t.text,t.source,r,t.searchKeywords]);return t.source==="gpt"&&!n?null:(0,Ko.jsxs)("div",{className:a.root,children:[(0,Ko.jsx)(ue,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:lN,children:(0,Ko.jsx)(cs,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),o&&(0,Ko.jsx)("div",{className:a.actions,children:(0,Ko.jsx)(Gd,{source:"overlay",context:i,suggestion:t})})]})},QE=uN;var Yh=x(T()),cN=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,ef.useMemo)(()=>{let o=e.map((i,s)=>(0,Yh.jsx)(QE,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,Yh.jsx)(ef.Fragment,{children:r})},tf=cN;var XE={root:"dd-PfvRI",paper:"dd-HYlyY"};var Cl=x(T()),dN=({textSuggestions:e,selectedIndex:t})=>{let n=(0,nf.useRef)(null),r=A("InlineSuggestionsOverlay",XE),o=M(_n),i=J(),s=M(ct),a=M(os),l=M(Zd),u=U("showTextSuggestions");return Xr(()=>{setTimeout(()=>{i(Zr({collapse:!0,skipWhenInputFocus:!0}))})}),(0,nf.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let f=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-f.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,Cl.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,Cl.jsx)("div",{ref:n,className:r.paper,children:(0,Cl.jsx)(wt,{children:(0,Cl.jsx)(tf,{suggestions:e,selectedIndex:t})})})})},fN=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),ZE=ko(fN)(dN);var kl=x(T()),pN=({children:e})=>{let n=U("locale").replace("-","");return(0,kl.jsx)(vh.Provider,{value:n,children:e})},mN=({store:e,customStyles:t={},children:n})=>(0,kl.jsx)(Xg,{store:e,children:(0,kl.jsx)(pN,{children:(0,kl.jsx)(Fs.Provider,{value:t,children:n})})}),$o=mN;var of=x(le()),Ss=x(F());var JE=x(F());function eT(e,t){let[n,r]=(0,JE.useState)(()=>{if(typeof window=="undefined")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return z.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window!="undefined"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){z.error(s)}}]}var tT=()=>/Mac/i.test(navigator.platform);var rT=x(le()),ur=x(F());var Qh={};at(Qh,{enUS:()=>gN,nlNL:()=>hN});var gN={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Sign in"}]},{type:0,value:" to enable "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze for "},{type:8,value:"min",children:[{type:0,value:"10 minutes"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 hour"}]},{type:0,value:" or "},{type:8,value:"day",children:[{type:0,value:"1 day"}]}]},hN={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Log in"}]},{type:0,value:" bij "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze voor "},{type:8,value:"min",children:[{type:0,value:"10 minuten"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 uur"}]},{type:0,value:" of "},{type:8,value:"day",children:[{type:0,value:"1 dag"}]}]};var nT={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var Jr=x(T()),Xh=(e,t,n)=>r=>(0,Jr.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),yN=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=Y(Qh),s=kt(),a=A("Login",nT),l=U("productName"),u=(0,ur.useCallback)(p=>{p.preventDefault(),r&&r(parseInt(p.target.value,10))},[]),c=(0,ur.useCallback)(p=>{p.preventDefault(),s.send(ls,!0)},[t]),f=(0,ur.useMemo)(()=>p=>(0,Jr.jsx)("a",{onClick:h=>{h.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:p},"login"),[t]),d=(0,ur.useCallback)(p=>(0,Jr.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:p},"prompt"),[c]),{min:m,hour:y,day:v}=(0,ur.useMemo)(()=>({min:Xh(a,60*10,u),hour:Xh(a,60*60,u),day:Xh(a,60*60*12,u)}),[]);return(0,Jr.jsxs)("div",{className:(0,rT.default)(e,a.root),children:[i("loginPlease",{login:n?d:f,productName:l}),r&&(0,Jr.jsxs)(ur.Fragment,{children:[(0,Jr.jsx)("br",{}),i("snooze",{min:m,hour:y,day:v})]})]})},rf=yN;var oT={root:"dd-DoQhb",text:"dd-Jwnev"};var Rl=x(T()),vN=({title:e})=>{let t=A("SearchTrigger",oT),n=J();return(0,Rl.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(Yt(!0)),children:[(0,Rl.jsx)(fs,{}),(0,Rl.jsx)("span",{className:t.text,children:e})]})},iT=vN;var Zh={};at(Zh,{enUS:()=>SN,nlNL:()=>xN});var SN={arrowHint:[{type:0,value:"Tip: use arrow keys to navigate suggestions"}],searchHintWindows:[{type:0,value:"Press CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],searchHintMac:[{type:0,value:"Press CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Close"}],search:[{type:0,value:"Search"}]},xN={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}]};var sT={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2"};var be=x(T()),wN=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=A("SuggestionsOverlay",sT),o=Y(Zh),i=M(_n),s=M1(),a=J(),l=(0,Ss.useRef)(null),u=U("searchTriggerKey"),c=U("productName"),f=M(Zd),d=M(ct),m=M(os),[y,v]=(0,Ss.useState)(null),p=U("showSearch"),g=U("showTextSuggestions"),h=U("adminUrl"),S=U("isEmbedded"),[w,C]=eT("dd-snooze-until-ms",0),E=f||w>Date.now(),P=e.filter(q=>q.source!=="gpt").length,N=()=>{E&&C(0),a(KE(!E))},_=q=>{let B=Date.now()+q*1e3;C(B),z.info(`Snooze until: ${new Date(B)}`),a(Zr({collapse:!0}))};return(0,Ss.useEffect)(()=>{P===0&&v(null)},[e,P]),Xr(()=>{a(Zr({collapse:!0,skipWhenInputFocus:!0}))}),d===null||m===!1?null:d===!1?(0,be.jsxs)("div",{ref:l,className:(0,of.default)(r.root,{[r.isCollapsed]:E}),children:[!E&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1}}),(0,be.jsx)("div",{className:r.triggersRight,children:(0,be.jsx)(lo,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})})]}),(0,be.jsx)("div",{className:r.toggleButtonWrapper,children:(0,be.jsx)(lo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),(0,be.jsx)("div",{className:r.collapsible,children:(0,be.jsx)(rf,{loginUrl:h,isEmbedded:S,onLogIn:n,onSnooze:_})})]}):!s||!i?null:(0,be.jsxs)("div",{ref:l,className:(0,of.default)(r.root,{[r.isCollapsed]:E}),children:[!E&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1},children:p&&(0,be.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>v(o(tT()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>v(null),children:(0,be.jsx)(iT,{title:o("search")})})}),(0,be.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,be.jsx)("div",{className:(0,of.default)(!y&&r.hintsHidden,r.hints),children:y}),(0,be.jsx)(lo,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})]})]}),(0,be.jsx)("div",{className:r.toggleButtonWrapper,children:(0,be.jsx)(lo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),P>0&&g&&(0,be.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,be.jsx)(wt,{children:(0,be.jsx)(tf,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},bN=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),aT=ko(bN)(wN);var xf=x(le());var pr=x(F());var xs=x(F());function sf(e){return e.contentEditable==="true"}function EN(e){let t=0,n=0,r=window.getSelection();if(r.rangeCount!==0){let o=r.getRangeAt(0),i=o.cloneRange();i.selectNodeContents(e),i.setEnd(o.endContainer,o.endOffset),n=i.toString().length,i.selectNodeContents(e),i.setEnd(o.startContainer,o.startOffset),t=i.toString().length}return{selectionStart:t,selectionEnd:n}}function lT(e){let{selectionStart:t,selectionEnd:n}=sf(e)?EN(e):e;return[t,n]}function uT(e){let[,t]=(0,xs.useState)(),n=(0,xs.useRef)(null);return n.current=lT(e),(0,xs.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=lT(e);(!s||o!==s[0]||i!==s[1])&&(n.current=s,t({}))};return e.addEventListener("keyup",r),e.addEventListener("click",r),e.addEventListener("focus",r),document.addEventListener("selectionchange",r),()=>{e.removeEventListener("keyup",r),e.removeEventListener("click",r),e.removeEventListener("focus",r),document.removeEventListener("selectionchange",r)}},[e]),n.current}function cT(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(su);if(!s||s.length===0)return;let a=0;s.find(l=>{let u=r.indexOf(l,a);return o>u&&i<u+l.length?(n.selectionStart=u,n.selectionEnd=u+l.length,!0):(a=u+l.length,!1)})}var dT=x(F()),TN=["div","span","mark","strong","b","i","u","em"];function Jh(e,t,n=0){var i;let r=e[e.length-1],o=typeof r=="object"&&r!==null?(i=r.props)==null?void 0:i.tagName:void 0;if(o==="br")return e.pop(),[...e,...t,r];if(TN.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,dT.cloneElement)(r,{children:Jh(s,t,n+1)})]}return[...e,...t]}function qo(e){return e.tagName.toLowerCase()==="textarea"}var fT={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var bT=x(le());var gf=x(F());var ws=x(F());function pT(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function af(e){let t=(0,ws.useRef)(null),[n,r]=(0,ws.useState)(!1);return(0,ws.useEffect)(()=>{var c;let o=!1,i=parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[s,a]=pT((f,d)=>{let m=t.current;if(!m)return;let y=f/i,v=d/i,p=m.getBoundingClientRect(),g=y>p.x&&y<p.x+p.width&&v>p.y&&v<p.y+p.height;g&&!o?(o=!0,r(!0)):!g&&o&&(o=!1,r(!1))},({clientX:f,clientY:d})=>[f,d]),[l,u]=pT(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",l),()=>{a(),u(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}function mT(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function lf(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function gT(e){return e!=null}var ty=x(le()),Xt=x(F());var uf=x(F()),CN=["bottom","height","left","right","top","width"],kN=(e={},t={})=>CN.some(n=>e[n]!==t[n]),cr=new Map,hT,yT=()=>{let e=[],t=[];cr.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();kN(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{cr.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),hT=window.requestAnimationFrame(yT)};function RN(e,t){return{observe(){let n=cr.size===0;if(cr.has(e)){let r=cr.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else cr.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&yT()},unobserve(){let n=cr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||cr.delete(e),cr.size||cancelAnimationFrame(hT)}}}}function ey(e){let[t,n]=(0,uf.useState)(null);return(0,uf.useLayoutEffect)(()=>{if(!e.current)return;let r=RN(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var bs=x(F()),ST=x(xc());var vT={root:"dd-r-dgo"};var xT=({children:e,parentNode:t})=>{let[n,r]=(0,bs.useState)(null),o=(0,bs.useContext)(Fs);return(0,bs.useLayoutEffect)(()=>{let i=document.createElement("div");return Wo(i),i.classList.add(vT.root),o!=null&&o.portalRootNode&&i.classList.add(o==null?void 0:o.portalRootNode),(t||document.body).appendChild(i),r(i),()=>{i.isConnected&&i.remove()}},[]),n?(0,ST.createPortal)(e,n):null};var Mn={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};var cf=x(T()),df=(e=!1)=>{let[t,n]=(0,Xt.useState)(e),r=(0,Xt.useCallback)(()=>n(!0),[]),o=(0,Xt.useCallback)(()=>n(!1),[]),i=(0,Xt.useCallback)(()=>n(a=>!a),[]),s=(0,Xt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function ny(e,t=null,n=0){if(!e)return{display:"none"};let r=t?e.top-t.top<0||e.top<t.top-n?t.top-n:e.top+e.height>t.top+t.height+n?t.top+t.height+n-e.height:e.top:e.top,o=t?e.left<t.left-n?t.left-n:e.left+e.width>t.left+t.width+n?t.left+t.width+n-e.width:e.left:e.left;return{top:r,left:o,height:e.height,width:e.width}}var Es=u=>{var c=u,{className:e,triggerRef:t,boundaryRef:n=(0,Xt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=ny,parentNode:a}=c,l=ee(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let f=ey(t),d=ey(n),m=(0,Xt.useMemo)(()=>s(f,d,0),[f,d]);return(0,cf.jsx)(xT,{parentNode:a,children:(0,cf.jsx)("div",I(k({className:(0,ty.default)(Mn.ref,{[Mn.positionAbove]:r==="above",[Mn.positionBelow]:r==="below",[Mn.positionLeft]:r==="left",[Mn.positionRight]:r==="right",[Mn.alignStart]:o==="start",[Mn.alignCenter]:o==="center",[Mn.alignEnd]:o==="end"}),style:m},l),{role:"dialog",children:(0,cf.jsx)("div",{className:(0,ty.default)(e,Mn.root),children:i})}))})};var wT=x(le()),ff=x(F());var dr={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var ry=x(T()),pf=(0,ff.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=ee(i,["className","children"]);let s=(0,ff.useRef)(null),a=A("TabCompletion",dr);return(0,ry.jsx)("div",I(k({ref:lf([s,r]),className:(0,wT.default)(e,a.popoverContentContainer)},n),{children:(0,ry.jsx)("div",{className:a.popoverContent,children:t})}))});var eo=x(T()),PN=e=>t=>{let n=ny(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},LN=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=A("TabCompletion",dr),s=df(),a=(0,gf.useMemo)(()=>PN(e.getBoundingClientRect()),[e]),[l,u]=af(e);return(0,gf.useEffect)(()=>{u?s.open():s.close()},[u]),(0,eo.jsxs)("span",{children:[(0,eo.jsx)("mark",{ref:lf([l,s.triggerRef]),className:(0,bT.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,eo.jsx)(Es,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,eo.jsx)(pf,{style:n,children:(0,eo.jsx)("div",{className:i.hintText,children:o})})})]})},mf=class extends ir{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,r){return r.keywordMatches&&r.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=r.keywordMatches.map(o=>I(k({},o),{keywordRegex:new RegExp(`\\b${mT(o.keyword)}\\b`,"i")})),this.keywordMatches=r.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let r=this.preparedKeywordMatches.map(i=>{if(this.usedKeywordMatches.has(i))return null;let s=n.match(i.keywordRegex);if(!s)return null;let a=n.charAt(s.index-1),l=n.charAt(s.index+i.keyword.length);return a==="{"&&l==="}"?null:{index:s.index,length:s[0].length,match:s[0],matchString:s[0],suggestion:i.suggestion,preparedKeywordMatch:i,valid:!0}}).filter(gT);if(r.length===0)return null;let o=r.reduce((i,s)=>s.index<i.index?s:i);return this.usedKeywordMatches.add(o.preparedKeywordMatch),o}replaceWith(n,r){return(0,eo.jsx)(LN,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var ET=x(le());var oy=x(T()),AN=({inputElement:e,children:t})=>{let n=A("TabCompletion",dr),[r,o]=af(e);return(0,oy.jsx)("mark",{ref:r,className:(0,ET.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},hf=class extends ir{match(t){let n=t.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(t,n){return(0,oy.jsx)(AN,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var vf=x(le());var mt=x(F());var iy=x(T()),TT=()=>(0,iy.jsx)("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:(0,iy.jsx)("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});var Dn=x(F());var kT=x(Eh());var CT={root:"dd-ky-Bv",content:"dd-kV5e1"};function yf(e,t,n){var o;let r=((o=e.imageSizes)==null?void 0:o[t])||e.image||n;if(!r)return null;try{return new URL(r).toString()}catch(i){return null}}function sy(e){return e.replace("https://www.","").replace("https://","")}var Zt=x(T()),IN=3,ON=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),NN=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=IN})=>{let i=A("LinkSearch",CT),[s,a]=(0,Dn.useState)(""),l=J(),u=M(RE("url")),c=M(nb("URL")),f=(0,Dn.useMemo)(()=>c.map(ON),[c]),[d,m]=(0,Dn.useState)(f.length-1),y=U("fallbackImage"),v=S=>{let w=S.target;a(w.value)},p=(S,w)=>{S.stopPropagation(),S.preventDefault(),window.open(w,"_blank")},g=S=>{var E;let w=d-1<0?f.length-1:d-1,C=d+1===f.length?0:d+1;S.code==="Escape"&&(a(""),t()),S.code==="ArrowUp"&&m(w),S.code==="ArrowDown"&&m(C),S.code==="Enter"&&e(((E=f[d])==null?void 0:E.text)||s)},h=(0,Dn.useCallback)((0,kT.default)(S=>{l(Lo({query:S,type:"URL",tags:["link-search"]}))},300),[]);return(0,Dn.useEffect)(()=>{s&&h(s)},[s]),(0,Dn.useEffect)(()=>()=>{l(gd())},[]),(0,Zt.jsxs)("div",{className:i.root,children:[(0,Zt.jsx)(wt,{withDivider:!0,children:(s?f:u).slice(0,o).map((S,w)=>(0,Zt.jsx)(ue,{selected:d===w,onClick:()=>e(S.text),"data-testid":"linksearch-suggestion",children:(0,Zt.jsxs)(ye,{children:[(0,Zt.jsx)(ye.Image,{src:yf(S,"small",y||void 0),title:S.title||S.text}),(0,Zt.jsxs)(ye.Content,{className:i.content,cropText:!0,children:[(0,Zt.jsx)(ye.Title,{children:S.title||sy(S.text)}),S.title&&sy(S.text)]}),(0,Zt.jsx)(ue.Actions,{children:(0,Zt.jsx)(ue.ActionButton,{label:r,onClick:C=>p(C,S.text)})})]})},S.text))}),(0,Zt.jsx)(tl,{value:s,onChange:v,autoFocus:!0,placeholder:n,onKeyUp:g})]})},RT=NN;var ay={};at(ay,{enUS:()=>_N,nlNL:()=>MN});var _N={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},MN={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var pt=x(T()),DN=(0,mt.forwardRef)((e,t)=>{let n=A("TabCompletion",dr);return(0,pt.jsx)("mark",{ref:t,className:(0,vf.default)(n.matchSelection)},"selection-start")}),FN=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=Y(ay),s=A("TabCompletion",dr),a=(0,mt.useRef)(null),l=(0,mt.useRef)(null),[u,c]=(0,mt.useState)(null),f=J(),d=df(document.activeElement===r),[m]=(0,mt.useState)(()=>document.createRange());d.triggerRef.current=m,(0,mt.useEffect)(()=>()=>m.detach(),[]),(0,mt.useEffect)(()=>{let v=e.current,p=a.current;!v||!p||(m.setStart(v,0),m.setEnd(p,0))},[e.current,a.current]),Xr(()=>{d.close()});let y=(0,mt.useCallback)(v=>{let p=m.toString(),g=/^http(s?):\/\//.test(v)?v:`https://${v}`;f(ud({text:`[${p}](${g})`,replace:"selection"}))},[]);return(0,pt.jsxs)("span",{children:[(0,pt.jsx)("mark",{ref:a,className:(0,vf.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,pt.jsx)(Es,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,pt.jsxs)(pf,{style:n,ref:l,children:[(0,pt.jsx)("div",{className:(0,vf.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,pt.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,pt.jsx)(TT,{}),(0,pt.jsx)("span",{children:"\xA0"}),(0,pt.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,pt.jsx)(RT,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:y,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},Sf=class extends ir{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,r){return this.props=r,this.charCount=0,this.startRef=(0,mt.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[r,o]=this.props.selection;if(r===o)return null;let i=this.foundIndex===0?r:o,s=i>=this.charCount&&i<=this.charCount+n.length?{index:i-this.charCount,length:0,match:"",valid:!0}:null;s&&this.foundIndex++;let a=this.foundIndex===1;return s&&a?this.charCount+=i-this.charCount:this.charCount+=n.length,s?k({isStart:a},s):null}replaceWith(n,r){return r.isStart?(0,pt.jsx)(DN,{ref:this.startRef}):(0,pt.jsx)(FN,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var fr=x(T()),HN=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=A("TabCompletion",fT),c=U("insertLink"),f=U("showMidSentenceSuggestions"),d=U("inlineSuggestions"),m=uT(a),y=(0,pr.useRef)(null),v=M(ct);(0,pr.useEffect)(()=>{qo(a)&&m&&cT(a,m)},[m]);let p=(0,pr.useCallback)(S=>{if(!o||!n)return S;let w=[(0,fr.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,fr.jsx)("span",{"data-testid":"tab-completion",className:(0,xf.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&w.push((0,fr.jsx)("span",{className:(0,xf.default)(u.hint,u.resetIndent),children:(0,fr.jsx)(ru,{keyCode:"tab"},"tabHint")})),Jh(S,w)},[o,n,r]),g=(0,pr.useMemo)(()=>{let S=[];return c&&S.push(new Sf("selection")),S.push(new hf("placeholders")),i&&S.push(new mf("keywords")),S},[d,c,i]),h=(0,pr.useMemo)(()=>{let S=window.getComputedStyle(a);return{"--dd-color":S.color,"--dd-font-size":S.fontSize,"--dd-font-family":S.fontFamily,"--dd-font-variant":S.fontVariant}},[]);return!e||!v?null:(0,fr.jsxs)("div",{ref:S=>{S!=null&&S.parentElement&&(y.current=S==null?void 0:S.parentElement)},className:u.root,style:h,children:[(0,fr.jsx)(cs,{tagName:"span",containerTagName:"div",className:(0,xf.default)(u.container,u.agentText),disableLineBreaks:qo(a),content:t||"\u200B",onAfterParse:p,matchers:g,selection:m,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:y,inlineSuggestionsOnlyAtEnd:!f}),(0,fr.jsx)("br",{})]})},UN=e=>{var p,g,h;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=ss({input:t}),a=(s==null?void 0:s.text)||"",l=(s==null?void 0:s.source)||"",u=(p=t.html)!=null?p:ds(t.text),c=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:f}=n,{isSupported:d}=i,{showTabCompletion:m,visible:y,showStyleSuggestions:v}=r;return{showTabHint:f,showStyleSuggestions:v,showTabCompletion:m&&_n(e),content:u,tabText:c,source:l,keywordMatches:(h=(g=o.list)==null?void 0:g.keywordMatches)!=null?h:[],enabled:y&&d!==!1}},PT=ko(UN)(HN);var kC=x(le()),ks=x(F());var zN={token:null,interval:null},ly=X("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>R(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),uy=X("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(ly()),setInterval(()=>r(ly()),n)}),LT=ne({name:"passwordlessToken",initialState:zN,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(ly.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(uy.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:AT}=LT.actions,IT=LT.reducer;var OT={excludeFromWidget:!1},cy={cues:[],fetchState:"idle"},NT=e=>{var t;return(t=e.rules)==null?void 0:t.cues},jN=Le("rules/resetCues"),Go=X("rules/evaluate",(e,t)=>R(void 0,null,function*(){var n,r;try{let{deepdeskAPI:o}=t.extra,i=t.getState(),{platformVariables:s}=i.info,a=(n=i.conversation.current)==null?void 0:n.id;if(!a)throw new Error("No current conversation to evaluate rules");if(!(yield o.getAccount()).ruleEngine)throw new Error("Rule engine is not enabled for this account");if(!(yield o.getRules()).filter(d=>d.isEnabled).some(d=>d.label===e.label))throw new Error(`No enabled rules found with label: ${e.label}`);let f=yield o.evaluateRule(e.label,a,k({tags:((r=i.conversation.current)==null?void 0:r.tags)||void 0},e.params));return s&&(f=f.map(d=>I(k({},d),{title:We(d.title,s),text:We(d.text,s)}))),{cues:f,options:e.options}}catch(o){let i=o.message;return z.warn(i),t.rejectWithValue(i)}})),_T=ne({name:"answer",initialState:cy,reducers:{removeCue(e,t){e.cues=e.cues.filter(n=>n.rule.id!==t.payload.id)}},extraReducers:e=>{e.addCase(Go.pending,t=>{t.fetchState="loading"}).addCase(Go.rejected,t=>{t.fetchState="error"}).addCase(Go.fulfilled,(t,n)=>{var i;if((i=n.payload.options)!=null&&i.excludeFromWidget){t.fetchState="done";return}let r=n.payload.cues.map(s=>s.rule.id),o=t.cues.filter(s=>!r.includes(s.rule.id));t.fetchState="done",t.cues=[...n.payload.cues,...o]}).addCase(Ae,()=>cy).addCase(jN.toString(),()=>cy)}}),{removeCue:MT}=_T.actions,DT=_T.reducer;function BN(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var FT=ln([NT,Ib],(e,t)=>{let n=t.map(r=>({text:r.response,title:r.name,callToAction:r.callToAction,isLoading:r.isLoading,rule:{id:BN(r.code),label:r.code,name:r.name,description:r.name}}));return[...e,...n]});var wf=x(F());var fy=x(le());var dy=x(T()),Pl=()=>(0,dy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,dy.jsx)("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var HT={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var Fn=x(T()),VN=({entities:e})=>{let t=A("EntitiesWidgetList",HT),[n,r]=(0,wf.useState)(void 0),o=J(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Nn(a.text),o(Gt({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,wf.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,Fn.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,Fn.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,Fn.jsx)("span",{className:t.entityText,children:a.text}),(0,Fn.jsxs)("span",{className:t.iconWrapper,children:[(0,Fn.jsx)("span",{className:(0,fy.default)(t.icon),children:(0,Fn.jsx)(Pl,{})}),(0,Fn.jsx)("span",{className:(0,fy.default)(t.icon,n===l&&t.iconClicked),children:(0,Fn.jsx)(Pl,{})})]})]},a.text))})},UT=VN;var py=x(T()),zT=()=>(0,py.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,py.jsx)("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});var my=x(T()),jT=()=>(0,my.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,my.jsx)("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});var gy=x(T()),BT=()=>(0,gy.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,gy.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var qT=x(F());var VT=x(F()),WT=e=>{(0,VT.useEffect)(()=>{let t=e.current;t&&t.scrollIntoView({behavior:"smooth"})},[])};var KT={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var $T=x(T()),WN=({width:e})=>{let t=A("LoadingProgressBar",KT);return(0,$T.jsx)("div",{className:t.loadingBar,style:{width:e}})},bf=WN;var mr=x(T()),Ef=({title:e})=>{let t=(0,qT.useRef)(null);return WT(t),(0,mr.jsx)(ue,{ref:t,children:(0,mr.jsx)(ye,{children:(0,mr.jsxs)(ye.Content,{children:[(0,mr.jsx)(ye.Title,{children:e}),(0,mr.jsx)(bf,{width:"60%"}),(0,mr.jsx)(bf,{width:"90%"}),(0,mr.jsx)(bf,{width:"50%"})]})})})};var fC=x(F());var{entries:rC,setPrototypeOf:GT,isFrozen:KN,getPrototypeOf:$N,getOwnPropertyDescriptor:qN}=Object,{freeze:ht,seal:Jt,create:oC}=Object,{apply:wy,construct:by}=typeof Reflect!="undefined"&&Reflect;ht||(ht=function(t){return t});Jt||(Jt=function(t){return t});wy||(wy=function(t,n,r){return t.apply(n,r)});by||(by=function(t,n){return new t(...n)});var Tf=Rt(Array.prototype.forEach),YT=Rt(Array.prototype.pop),Ll=Rt(Array.prototype.push),Rf=Rt(String.prototype.toLowerCase),hy=Rt(String.prototype.toString),QT=Rt(String.prototype.match),Al=Rt(String.prototype.replace),GN=Rt(String.prototype.indexOf),YN=Rt(String.prototype.trim),hn=Rt(Object.prototype.hasOwnProperty),gt=Rt(RegExp.prototype.test),Il=QN(TypeError),XT=Rt(Number.isNaN);function Rt(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return wy(e,t,r)}}function QN(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return by(e,n)}}function te(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Rf;GT&>(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let i=n(o);i!==o&&(KN(t)||(t[r]=i),o=i)}e[o]=!0}return e}function XN(e){for(let t=0;t<e.length;t++)hn(e,t)||(e[t]=null);return e}function Qo(e){let t=oC(null);for(let[n,r]of rC(e))hn(e,n)&&(Array.isArray(r)?t[n]=XN(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Qo(r):t[n]=r);return t}function Cf(e,t){for(;e!==null;){let r=qN(e,t);if(r){if(r.get)return Rt(r.get);if(typeof r.value=="function")return Rt(r.value)}e=$N(e)}function n(){return null}return n}var ZT=ht(["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","section","select","shadow","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"]),yy=ht(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),vy=ht(["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"]),ZN=ht(["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"]),Sy=ht(["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"]),JN=ht(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),JT=ht(["#text"]),eC=ht(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","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","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),xy=ht(["accent-height","accumulate","additive","alignment-baseline","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","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","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","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","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","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"]),tC=ht(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),kf=ht(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),e_=Jt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),t_=Jt(/<%[\w\W]*|[\w\W]*%>/gm),n_=Jt(/\${[\w\W]*}/gm),r_=Jt(/^data-[\-\w.\u00B7-\uFFFF]/),o_=Jt(/^aria-[\-\w]+$/),iC=Jt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),i_=Jt(/^(?:\w+script|data):/i),s_=Jt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),sC=Jt(/^html$/i),a_=Jt(/^[a-z][.\w]*(-[.\w]+)+$/i),nC=Object.freeze({__proto__:null,MUSTACHE_EXPR:e_,ERB_EXPR:t_,TMPLIT_EXPR:n_,DATA_ATTR:r_,ARIA_ATTR:o_,IS_ALLOWED_URI:iC,IS_SCRIPT_OR_DATA:i_,ATTR_WHITESPACE:s_,DOCTYPE_NAME:sC,CUSTOM_ELEMENT:a_}),Yo={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},l_=function(){return typeof window=="undefined"?null:window},u_=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));let i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function aC(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:l_(),t=j=>aC(j);if(t.version="3.1.3",t.removed=[],!e||!e.document||e.document.nodeType!==Yo.document)return t.isSupported=!1,t;let{document:n}=e,r=n,o=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:s,Node:a,Element:l,NodeFilter:u,NamedNodeMap:c=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:f,DOMParser:d,trustedTypes:m}=e,y=l.prototype,v=Cf(y,"cloneNode"),p=Cf(y,"nextSibling"),g=Cf(y,"childNodes"),h=Cf(y,"parentNode");if(typeof s=="function"){let j=n.createElement("template");j.content&&j.content.ownerDocument&&(n=j.content.ownerDocument)}let S,w="",{implementation:C,createNodeIterator:E,createDocumentFragment:P,getElementsByTagName:N}=n,{importNode:_}=r,q={};t.isSupported=typeof rC=="function"&&typeof h=="function"&&C&&C.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:B,ERB_EXPR:V,TMPLIT_EXPR:fe,DATA_ATTR:Ge,ARIA_ATTR:it,IS_SCRIPT_OR_DATA:ro,ATTR_WHITESPACE:zn,CUSTOM_ELEMENT:Sn}=nC,{IS_ALLOWED_URI:W}=nC,Z=null,Mt=te({},[...ZT,...yy,...vy,...Sy,...JT]),pe=null,Ee=te({},[...eC,...xy,...tC,...kf]),G=Object.seal(oC(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}})),ri=null,oo=null,oi=!0,ii=!0,jl=!1,io=!0,xn=!1,Bl=!0,De=!1,jn=!1,Uf=!1,si=!1,Vl=!1,Wl=!1,zy=!0,jy=!1,Sk="user-content-",zf=!0,Os=!1,ai={},li=null,By=te({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Vy=null,Wy=te({},["audio","video","img","source","image","track"]),jf=null,Ky=te({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Kl="http://www.w3.org/1998/Math/MathML",$l="http://www.w3.org/2000/svg",Bn="http://www.w3.org/1999/xhtml",ui=Bn,Bf=!1,Vf=null,xk=te({},[Kl,$l,Bn],hy),Ns=null,wk=["application/xhtml+xml","text/html"],bk="text/html",Fe=null,ci=null,$y=255,Ek=n.createElement("form"),qy=function(b){return b instanceof RegExp||b instanceof Function},Wf=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ci&&ci===b)){if((!b||typeof b!="object")&&(b={}),b=Qo(b),Ns=wk.indexOf(b.PARSER_MEDIA_TYPE)===-1?bk:b.PARSER_MEDIA_TYPE,Fe=Ns==="application/xhtml+xml"?hy:Rf,Z=hn(b,"ALLOWED_TAGS")?te({},b.ALLOWED_TAGS,Fe):Mt,pe=hn(b,"ALLOWED_ATTR")?te({},b.ALLOWED_ATTR,Fe):Ee,Vf=hn(b,"ALLOWED_NAMESPACES")?te({},b.ALLOWED_NAMESPACES,hy):xk,jf=hn(b,"ADD_URI_SAFE_ATTR")?te(Qo(Ky),b.ADD_URI_SAFE_ATTR,Fe):Ky,Vy=hn(b,"ADD_DATA_URI_TAGS")?te(Qo(Wy),b.ADD_DATA_URI_TAGS,Fe):Wy,li=hn(b,"FORBID_CONTENTS")?te({},b.FORBID_CONTENTS,Fe):By,ri=hn(b,"FORBID_TAGS")?te({},b.FORBID_TAGS,Fe):{},oo=hn(b,"FORBID_ATTR")?te({},b.FORBID_ATTR,Fe):{},ai=hn(b,"USE_PROFILES")?b.USE_PROFILES:!1,oi=b.ALLOW_ARIA_ATTR!==!1,ii=b.ALLOW_DATA_ATTR!==!1,jl=b.ALLOW_UNKNOWN_PROTOCOLS||!1,io=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xn=b.SAFE_FOR_TEMPLATES||!1,Bl=b.SAFE_FOR_XML!==!1,De=b.WHOLE_DOCUMENT||!1,si=b.RETURN_DOM||!1,Vl=b.RETURN_DOM_FRAGMENT||!1,Wl=b.RETURN_TRUSTED_TYPE||!1,Uf=b.FORCE_BODY||!1,zy=b.SANITIZE_DOM!==!1,jy=b.SANITIZE_NAMED_PROPS||!1,zf=b.KEEP_CONTENT!==!1,Os=b.IN_PLACE||!1,W=b.ALLOWED_URI_REGEXP||iC,ui=b.NAMESPACE||Bn,G=b.CUSTOM_ELEMENT_HANDLING||{},b.CUSTOM_ELEMENT_HANDLING&&qy(b.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(G.tagNameCheck=b.CUSTOM_ELEMENT_HANDLING.tagNameCheck),b.CUSTOM_ELEMENT_HANDLING&&qy(b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(G.attributeNameCheck=b.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),b.CUSTOM_ELEMENT_HANDLING&&typeof b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(G.allowCustomizedBuiltInElements=b.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),xn&&(ii=!1),Vl&&(si=!0),ai&&(Z=te({},JT),pe=[],ai.html===!0&&(te(Z,ZT),te(pe,eC)),ai.svg===!0&&(te(Z,yy),te(pe,xy),te(pe,kf)),ai.svgFilters===!0&&(te(Z,vy),te(pe,xy),te(pe,kf)),ai.mathMl===!0&&(te(Z,Sy),te(pe,tC),te(pe,kf))),b.ADD_TAGS&&(Z===Mt&&(Z=Qo(Z)),te(Z,b.ADD_TAGS,Fe)),b.ADD_ATTR&&(pe===Ee&&(pe=Qo(pe)),te(pe,b.ADD_ATTR,Fe)),b.ADD_URI_SAFE_ATTR&&te(jf,b.ADD_URI_SAFE_ATTR,Fe),b.FORBID_CONTENTS&&(li===By&&(li=Qo(li)),te(li,b.FORBID_CONTENTS,Fe)),zf&&(Z["#text"]=!0),De&&te(Z,["html","head","body"]),Z.table&&(te(Z,["tbody"]),delete ri.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=b.TRUSTED_TYPES_POLICY,w=S.createHTML("")}else S===void 0&&(S=u_(m,o)),S!==null&&typeof w=="string"&&(w=S.createHTML(""));ht&&ht(b),ci=b}},Gy=te({},["mi","mo","mn","ms","mtext"]),Yy=te({},["foreignobject","annotation-xml"]),Tk=te({},["title","style","font","a","script"]),Qy=te({},[...yy,...vy,...ZN]),Xy=te({},[...Sy,...JN]),Ck=function(b){let L=h(b);(!L||!L.tagName)&&(L={namespaceURI:ui,tagName:"template"});let H=Rf(b.tagName),Q=Rf(L.tagName);return Vf[b.namespaceURI]?b.namespaceURI===$l?L.namespaceURI===Bn?H==="svg":L.namespaceURI===Kl?H==="svg"&&(Q==="annotation-xml"||Gy[Q]):!!Qy[H]:b.namespaceURI===Kl?L.namespaceURI===Bn?H==="math":L.namespaceURI===$l?H==="math"&&Yy[Q]:!!Xy[H]:b.namespaceURI===Bn?L.namespaceURI===$l&&!Yy[Q]||L.namespaceURI===Kl&&!Gy[Q]?!1:!Xy[H]&&(Tk[H]||!Qy[H]):!!(Ns==="application/xhtml+xml"&&Vf[b.namespaceURI]):!1},Dt=function(b){Ll(t.removed,{element:b});try{b.parentNode.removeChild(b)}catch(L){b.remove()}},ql=function(b,L){try{Ll(t.removed,{attribute:L.getAttributeNode(b),from:L})}catch(H){Ll(t.removed,{attribute:null,from:L})}if(L.removeAttribute(b),b==="is"&&!pe[b])if(si||Vl)try{Dt(L)}catch(H){}else try{L.setAttribute(b,"")}catch(H){}},Zy=function(b){let L=null,H=null;if(Uf)b="<remove></remove>"+b;else{let ze=QT(b,/^[\r\n\t ]+/);H=ze&&ze[0]}Ns==="application/xhtml+xml"&&ui===Bn&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");let Q=S?S.createHTML(b):b;if(ui===Bn)try{L=new d().parseFromString(Q,Ns)}catch(ze){}if(!L||!L.documentElement){L=C.createDocument(ui,"template",null);try{L.documentElement.innerHTML=Bf?w:Q}catch(ze){}}let Ye=L.body||L.documentElement;return b&&H&&Ye.insertBefore(n.createTextNode(H),Ye.childNodes[0]||null),ui===Bn?N.call(L,De?"html":"body")[0]:De?L.documentElement:Ye},Jy=function(b){return E.call(b.ownerDocument||b,b,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},ev=function(b){return b instanceof f&&(typeof b.__depth!="undefined"&&typeof b.__depth!="number"||typeof b.__removalCount!="undefined"&&typeof b.__removalCount!="number"||typeof b.nodeName!="string"||typeof b.textContent!="string"||typeof b.removeChild!="function"||!(b.attributes instanceof c)||typeof b.removeAttribute!="function"||typeof b.setAttribute!="function"||typeof b.namespaceURI!="string"||typeof b.insertBefore!="function"||typeof b.hasChildNodes!="function")},tv=function(b){return typeof a=="function"&&b instanceof a},Vn=function(b,L,H){q[b]&&Tf(q[b],Q=>{Q.call(t,L,H,ci)})},nv=function(b){let L=null;if(Vn("beforeSanitizeElements",b,null),ev(b))return Dt(b),!0;let H=Fe(b.nodeName);if(Vn("uponSanitizeElement",b,{tagName:H,allowedTags:Z}),b.hasChildNodes()&&!tv(b.firstElementChild)&>(/<[/\w]/g,b.innerHTML)&>(/<[/\w]/g,b.textContent)||b.nodeType===Yo.progressingInstruction||Bl&&b.nodeType===Yo.comment&>(/<[/\w]/g,b.data))return Dt(b),!0;if(!Z[H]||ri[H]){if(!ri[H]&&ov(H)&&(G.tagNameCheck instanceof RegExp&>(G.tagNameCheck,H)||G.tagNameCheck instanceof Function&&G.tagNameCheck(H)))return!1;if(zf&&!li[H]){let Q=h(b)||b.parentNode,Ye=g(b)||b.childNodes;if(Ye&&Q){let ze=Ye.length;for(let yt=ze-1;yt>=0;--yt){let vt=v(Ye[yt],!0);vt.__removalCount=(b.__removalCount||0)+1,Q.insertBefore(vt,p(b))}}}return Dt(b),!0}return b instanceof l&&!Ck(b)||(H==="noscript"||H==="noembed"||H==="noframes")&>(/<\/no(script|embed|frames)/i,b.innerHTML)?(Dt(b),!0):(xn&&b.nodeType===Yo.text&&(L=b.textContent,Tf([B,V,fe],Q=>{L=Al(L,Q," ")}),b.textContent!==L&&(Ll(t.removed,{element:b.cloneNode()}),b.textContent=L)),Vn("afterSanitizeElements",b,null),!1)},rv=function(b,L,H){if(zy&&(L==="id"||L==="name")&&(H in n||H in Ek||H==="__depth"||H==="__removalCount"))return!1;if(!(ii&&!oo[L]&>(Ge,L))){if(!(oi&>(it,L))){if(!pe[L]||oo[L]){if(!(ov(b)&&(G.tagNameCheck instanceof RegExp&>(G.tagNameCheck,b)||G.tagNameCheck instanceof Function&&G.tagNameCheck(b))&&(G.attributeNameCheck instanceof RegExp&>(G.attributeNameCheck,L)||G.attributeNameCheck instanceof Function&&G.attributeNameCheck(L))||L==="is"&&G.allowCustomizedBuiltInElements&&(G.tagNameCheck instanceof RegExp&>(G.tagNameCheck,H)||G.tagNameCheck instanceof Function&&G.tagNameCheck(H))))return!1}else if(!jf[L]){if(!gt(W,Al(H,zn,""))){if(!((L==="src"||L==="xlink:href"||L==="href")&&b!=="script"&&GN(H,"data:")===0&&Vy[b])){if(!(jl&&!gt(ro,Al(H,zn,"")))){if(H)return!1}}}}}}return!0},ov=function(b){return b!=="annotation-xml"&&QT(b,Sn)},iv=function(b){Vn("beforeSanitizeAttributes",b,null);let{attributes:L}=b;if(!L)return;let H={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:pe},Q=L.length;for(;Q--;){let Ye=L[Q],{name:ze,namespaceURI:yt,value:vt}=Ye,_s=Fe(ze),st=ze==="value"?vt:YN(vt);if(H.attrName=_s,H.attrValue=st,H.keepAttr=!0,H.forceKeepAttr=void 0,Vn("uponSanitizeAttribute",b,H),st=H.attrValue,H.forceKeepAttr||(ql(ze,b),!H.keepAttr))continue;if(!io&>(/\/>/i,st)){ql(ze,b);continue}if(Bl&>(/((--!?|])>)|<\/(style|title)/i,st)){ql(ze,b);continue}xn&&Tf([B,V,fe],av=>{st=Al(st,av," ")});let sv=Fe(b.nodeName);if(rv(sv,_s,st)){if(jy&&(_s==="id"||_s==="name")&&(ql(ze,b),st=Sk+st),S&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!yt)switch(m.getAttributeType(sv,_s)){case"TrustedHTML":{st=S.createHTML(st);break}case"TrustedScriptURL":{st=S.createScriptURL(st);break}}try{yt?b.setAttributeNS(yt,ze,st):b.setAttribute(ze,st),ev(b)?Dt(b):YT(t.removed)}catch(av){}}}Vn("afterSanitizeAttributes",b,null)},kk=function j(b){let L=null,H=Jy(b);for(Vn("beforeSanitizeShadowDOM",b,null);L=H.nextNode();){if(Vn("uponSanitizeShadowNode",L,null),nv(L))continue;let Q=h(L);L.nodeType===Yo.element&&(Q&&Q.__depth?L.__depth=(L.__removalCount||0)+Q.__depth+1:L.__depth=1),(L.__depth>=$y||L.__depth<0||XT(L.__depth))&&Dt(L),L.content instanceof i&&(L.content.__depth=L.__depth,j(L.content)),iv(L)}Vn("afterSanitizeShadowDOM",b,null)};return t.sanitize=function(j){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},L=null,H=null,Q=null,Ye=null;if(Bf=!j,Bf&&(j="<!-->"),typeof j!="string"&&!tv(j))if(typeof j.toString=="function"){if(j=j.toString(),typeof j!="string")throw Il("dirty is not a string, aborting")}else throw Il("toString is not a function");if(!t.isSupported)return j;if(jn||Wf(b),t.removed=[],typeof j=="string"&&(Os=!1),Os){if(j.nodeName){let vt=Fe(j.nodeName);if(!Z[vt]||ri[vt])throw Il("root node is forbidden and cannot be sanitized in-place")}}else if(j instanceof a)L=Zy("<!---->"),H=L.ownerDocument.importNode(j,!0),H.nodeType===Yo.element&&H.nodeName==="BODY"||H.nodeName==="HTML"?L=H:L.appendChild(H);else{if(!si&&!xn&&!De&&j.indexOf("<")===-1)return S&&Wl?S.createHTML(j):j;if(L=Zy(j),!L)return si?null:Wl?w:""}L&&Uf&&Dt(L.firstChild);let ze=Jy(Os?j:L);for(;Q=ze.nextNode();){if(nv(Q))continue;let vt=h(Q);Q.nodeType===Yo.element&&(vt&&vt.__depth?Q.__depth=(Q.__removalCount||0)+vt.__depth+1:Q.__depth=1),(Q.__depth>=$y||Q.__depth<0||XT(Q.__depth))&&Dt(Q),Q.content instanceof i&&(Q.content.__depth=Q.__depth,kk(Q.content)),iv(Q)}if(Os)return j;if(si){if(Vl)for(Ye=P.call(L.ownerDocument);L.firstChild;)Ye.appendChild(L.firstChild);else Ye=L;return(pe.shadowroot||pe.shadowrootmode)&&(Ye=_.call(r,Ye,!0)),Ye}let yt=De?L.outerHTML:L.innerHTML;return De&&Z["!doctype"]&&L.ownerDocument&&L.ownerDocument.doctype&&L.ownerDocument.doctype.name&>(sC,L.ownerDocument.doctype.name)&&(yt="<!DOCTYPE "+L.ownerDocument.doctype.name+`>
|
|
24
24
|
`+yt),xn&&Tf([B,V,fe],vt=>{yt=Al(yt,vt," ")}),S&&Wl?S.createHTML(yt):yt},t.setConfig=function(){let j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Wf(j),jn=!0},t.clearConfig=function(){ci=null,jn=!1},t.isValidAttribute=function(j,b,L){ci||Wf({});let H=Fe(j),Q=Fe(b);return rv(H,Q,L)},t.addHook=function(j,b){typeof b=="function"&&(q[j]=q[j]||[],Ll(q[j],b))},t.removeHook=function(j){if(q[j])return YT(q[j])},t.removeHooks=function(j){q[j]&&(q[j]=[])},t.removeAllHooks=function(){q={}},t}var lC=aC();var gr=x(F());var c_={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function uC(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function Ol(e){return(e+"").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Nl(e,t){var n,r,o,i,s,a=/((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,l=[],u="",c=t||{},f=0;function d(y){var v=c_[y[1]||""],p=l[l.length-1]==y;return v?v[1]?(p?l.pop():l.push(y),v[0|p]):v[0]:y}function m(){for(var y="";l.length;)y+=d(l[l.length-1]);return y}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(y,v,p){return c[v.toLowerCase()]=p,""}).replace(/^\n+|\n+$/g,"");o=a.exec(e);)r=e.substring(f,o.index),f=a.lastIndex,n=o[0],r.match(/[^\\](\\\\)*\\$/)||((s=o[3]||o[4])?n='<pre class="code '+(o[4]?"poetry":o[2].toLowerCase())+'"><code'+(o[2]?' class="language-'+o[2].toLowerCase()+'"':"")+">"+uC(Ol(s).replace(/^\n+|\n+$/g,""))+"</code></pre>":(s=o[6])?(s.match(/\./)&&(o[5]=o[5].replace(/^\d+/gm,"")),i=Nl(uC(o[5].replace(/^\s*[>*+.-]/gm,""))),s==">"?s="blockquote":(s=s.match(/\./)?"ol":"ul",i=i.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),n="<"+s+">"+i+"</"+s+">"):o[8]?n='<img src="'+Ol(o[8])+'" alt="'+Ol(o[7])+'">':o[10]?(u=u.replace("<a>",'<a href="'+Ol(o[11]||c[r.toLowerCase()])+'">'),n=m()+"</a>"):o[9]?n="<a>":o[12]||o[14]?n="<"+(s="h"+(o[14]?o[14].length:o[13]>"="?1:2))+">"+Nl(o[12]||o[15],c)+"</"+s+">":o[16]?n="<code>"+Ol(o[16])+"</code>":(o[17]||o[1])&&(n=d(o[17]||"--"))),u+=r,u+=n;return(u+e.substring(f)+m()).replace(/^\n+|\n+$/g,"")}var cC={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};var yn=x(T());function d_(e){return`<button type="button" data-copy-icon class=${e}><svg version="1.1" x="0px" y="0px" viewBox="0 0 115.77 122.88" width="10px" height="10px" fill="black"><g><path d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"/></g></svg></button>`}function Ey(e){var n;let t=e.cloneNode(!0);return t.querySelectorAll("div,button").forEach(r=>r.remove()),(n=t.textContent)!=null?n:""}function f_(e){return e.replace(/\r\n/g,`
|
|
25
|
-
`)}var p_=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=A("Markdown",cC),s=(0,gr.useRef)(null),[a,l]=(0,gr.useState)(null),u=(0,gr.useMemo)(()=>{let v=Nl(f_(e));return lC.sanitize(v).replaceAll("</code>",`${d_(i.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[e]),c=v=>{var h;let p=v.target,g=!!((h=s.current)!=null&&h.querySelector("code"));if(["A","BUTTON"].includes(p.tagName)){l(null);return}a||g&&p.tagName!=="CODE"||!g&&p!==s.current||(p.addEventListener("mouseleave",()=>l(null),{once:!0}),l(p))},f=()=>{if(!a)return;l(null);let v=a.querySelector("button");v&&(gs(v,i.fadeup),r(Ey(a)))},d=v=>{let p=v.target;if(p.tagName==="A"){v.stopPropagation();return}"copyIcon"in p.dataset&&(gs(p,i.fadeup),r(Ey(p.parentElement)))},m=()=>{!a||!o||(l(null),o(Ey(a)))},y=v=>{if(v===null)return;let p=v.getBoundingClientRect();p.left<0?v.style.transform=`translateX(${-p.left+2}px)`:p.right>window.innerWidth&&(v.style.transform=`translateX(${window.innerWidth-p.right-2}px)`)};return(0,yn.jsxs)(gr.Fragment,{children:[a&&(0,yn.jsxs)(Es,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,yn.jsxs)("div",{className:i.options,ref:y,children:[(0,yn.jsx)("button",{type:"button",className:i.option,onClick:f,children:n}),o&&(0,yn.jsxs)(gr.Fragment,{children:[(0,yn.jsx)("div",{className:i.divider}),(0,yn.jsx)("button",{type:"button",className:i.option,onClick:m,children:t})]})]}),(0,yn.jsx)("div",{className:i.arrow})]}),(0,yn.jsx)("div",{ref:s,className:i.root,dangerouslySetInnerHTML:{__html:u},onMouseOver:c,onClick:d})]})},Pf=p_;var Ty={};at(Ty,{enUS:()=>m_,nlNL:()=>g_});var m_={useCue:[{type:0,value:"Add to message"}],__summarizerAssistant__:[{type:0,value:"Summary"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},g_={useCue:[{type:0,value:"Voeg toe aan bericht"}],__summarizerAssistant__:[{type:0,value:"Samenvatting"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var dC={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l",form:"dd-sPNU2",formInput:"dd-F3E4I",formSubmit:"dd-vw5S0",actionButton:"dd-cCWyJ",inputSpace:"dd-DGYB1"};var en=x(T()),h_=({cue:e,onCallToAction:t,onRemove:n,onCopy:r,onUse:o})=>{let i=A("WidgetCue",dC),s=Y(Ty),a=Qr(),l=U("hasKeyboardInput"),u=()=>{t&&t(e),n(e)},c=m=>{r&&r(m,e)},f=m=>{o&&o(m,e)},d=m=>{m.preventDefault(),m.stopPropagation(),n(e)};return(0,fC.useEffect)(()=>{a("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,en.jsxs)(ue,{"data-testid":"cue",children:[(0,en.jsx)(ye,{children:(0,en.jsxs)(ye.Content,{children:[e.title&&(0,en.jsx)(ye.Title,{className:i.title,"data-testid":"widget-cue-title",children:e.rule.label.startsWith("__")?s(e.rule.label):e.title}),(0,en.jsx)(Pf,{content:e.text,useLabel:s("useCue"),copyLabel:s("copyCue"),onCopy:c,onUse:l?f:void 0})]})}),(0,en.jsxs)(ue.ButtonsContainer,{children:[(0,en.jsxs)("div",{className:i.actions,children:[e.callToAction&&(0,en.jsx)(ue.Button,{onClick:u,children:e.callToAction.label}),(0,en.jsx)(ue.Button,{onClick:d,children:s("removeCue")})]}),(0,en.jsx)(ys,{eventName:"Assistant response feedback",eventData:{name:e.rule.name,group:e.rule.label,description:e.rule.description,cueText:e.text},feedbackText:e.text,feedbackType:"assistant"})]})]})},pC=h_;var Ts=x(T()),y_=({cues:e})=>{let t=J(),n=kt(),r=Qr(),o=l=>{t(MT({id:l.rule.id})),t(Nb({code:l.rule.label})),r("Assistant response closed",{name:l.rule.name,group:l.rule.label,description:l.rule.description,cueText:l.text})},i=(l,u)=>{Nn(l),r("Assistant response copied",{name:u.rule.name,group:u.rule.label,description:u.rule.description,copiedText:l})},s=l=>{l.callToAction&&(t(Nd(l)),r("Assistant call to action",{name:l.rule.name,group:l.rule.label,description:l.rule.description,eventName:l.callToAction.event,value:l.callToAction.value}))},a=(l,u)=>{n.send(In,{text:l,suggestion:{source:"cue",sourceText:l}}),r("Assistant response used",{name:u.rule.name,group:u.rule.label,description:u.rule.description,usedText:l})};return(0,Ts.jsx)(Ts.Fragment,{children:e.map(l=>l.isLoading?(0,Ts.jsx)(Ef,{title:l.title},l.rule.id):(0,Ts.jsx)(pC,{cue:l,onCallToAction:s,onRemove:o,onCopy:i,onUse:a},l.rule.id))})},mC=y_;var Lf=x(F());var gC={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var vn=x(T());function v_(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var hC=({data:e,schema:t})=>{let n=A("WidgetCustomData",gC),r=o=>{Nn(o)};return(0,Lf.useEffect)(()=>{z.info("Custom data",e,t)},[e]),(0,vn.jsx)("dl",{className:n.root,children:t.map(o=>{let i=v_(e,o.path);return(0,vn.jsxs)(Lf.Fragment,{children:[(0,vn.jsx)("dt",{className:n.label,children:o.label}),(0,vn.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,vn.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,vn.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,vn.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,vn.jsx)("span",{className:n.copyButtonText,children:i}),(0,vn.jsx)(Pl,{})]}):"-"})]},o.label)})})};var Pt=x(F());var Cy=x(T()),yC=()=>(0,Cy.jsx)("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"ReplayIcon",children:(0,Cy.jsx)("path",{d:"M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8"})});var Cs={};at(Cs,{enUS:()=>S_,nlNL:()=>x_});var S_={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"What is your question?"}],useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Submit"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},x_={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"Wat is je vraag?"}],useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Verzend"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var ky={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",sources:"dd-xf9c6",source:"dd-a-vyX",link:"dd-PyUPS",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};var ge=x(T()),w_=3,b_=({sources:e,onClick:t})=>{let n=Y(Cs),r=A("WidgetKnowledgeAssistant",ky),[o,i]=(0,Pt.useState)(!1),s=o?e:e.slice(0,w_);return s.length===0?null:(0,ge.jsxs)("ul",{className:r.sources,children:[s.map(a=>(0,ge.jsx)("li",{className:r.source,"data-testid":"knowledge-assist-source",children:(0,ge.jsx)("a",{className:r.link,rel:"noreferrer",target:"_blank",href:a.url,onClick:l=>{l.stopPropagation(),t(a)},"data-tooltip":a.url?decodeURIComponent(a.url):void 0,children:(0,ge.jsx)("span",{className:r.linkContent,children:a.name})})},a.name)),s<e&&(0,ge.jsx)("button",{type:"button",className:r.showMoreSources,onClick:()=>i(!0),children:n("showMore",{amount:e.length-s.length})})]})},E_=({innerRef:e,item:t,index:n,hasKeyboardInput:r,onCopy:o,onUse:i,onSourceClick:s})=>{var l;let a=Y(Cs);return(0,ge.jsxs)(ue,{"data-testid":"knowledge-assist-answer",ref:e,children:[(0,ge.jsx)(ye,{children:(0,ge.jsxs)(ye.Content,{children:[(0,ge.jsx)(ye.Title,{children:t.question}),(0,ge.jsx)(Pf,{content:t.answer.answer,useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:o,onUse:r?i:void 0}),(0,ge.jsx)(b_,{sources:(l=t.answer.sources)!=null?l:[],onClick:u=>s(u,t.question)})]})}),(0,ge.jsxs)(ue.ButtonsContainer,{children:[(0,ge.jsx)("div",{}),(0,ge.jsx)(ys,{eventName:"knowledge assist feedback",eventData:{question:t.question,isFollowUpQuestion:n>0,isAgent:!0,answer:t.answer.answer},feedbackText:t.answer.answer,feedbackType:"assistant"})]})]})},Ry=(0,Pt.createContext)(null),vC=({children:e})=>{let[t,n]=(0,Pt.useState)(null),r=M(ul("knowledge-assist")),[o,i]=(0,Pt.useState)(!1),[s,a]=(0,Pt.useState)(null),l=J(),u=Uo(d=>il({input:d,threadId:t,onNewThreadId(m){n(m)}})),c={isEnabled:r,isSubmitting:o,threadId:t,pendingInput:s,onSubmit(d){return R(this,null,function*(){i(!0),a(d),yield u.call(d),i(!1),a(null)})},onReset(){t&&l(us(t))}};return(0,ge.jsx)(Ry.Provider,{value:c,children:e})},SC=()=>{let e=Y(Cs),t=A("WidgetKnowledgeAssistant",ky),n=(0,Pt.useContext)(Ry),r=(0,Pt.useRef)(null),[o,i]=(0,Pt.useState)(""),s=u=>{i(u.target.value)},a=u=>{u.preventDefault(),n.onSubmit(o).then(()=>{var c;r.current&&((c=r.current)==null||c.focus(),i(""))})},l=u=>{u.preventDefault(),n.onReset()};return n.isEnabled?(0,ge.jsxs)("form",{className:t.form,onSubmit:a,children:[(0,ge.jsx)("input",{ref:r,className:t.formInput,placeholder:e("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:o,onChange:s}),(0,ge.jsx)("button",{type:"submit",disabled:n.isSubmitting||o==="",className:t.formSubmit,children:e("submitLabel")}),(0,ge.jsx)("button",{type:"button",title:e("resetLabel"),disabled:n.threadId===null||n.isSubmitting,onClick:l,className:t.actionButton,children:(0,ge.jsx)(yC,{})})]}):null},xC=()=>{var c,f;let e=Y(Cs),t=Qr(),n=(0,Pt.useRef)(null),r=(0,Pt.useContext)(Ry),o=(f=M(ol((c=r.threadId)!=null?c:-1)))!=null?f:[],i=U("hasKeyboardInput"),s=kt(),a=d=>{Nn(d),t("Assistant response copied",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",copiedText:d})},l=(d,m)=>{t("knowledge assist source viewed",{question:m,sourceViewed:d.url||d.name})},u=d=>{s.send(In,{text:d,suggestion:{source:"cue",sourceText:d}}),t("Assistant response used",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",usedText:d})};return!r.isEnabled||(o==null?void 0:o.length)===0&&!r.isSubmitting?null:(0,ge.jsx)(wn,{type:"knowledge",title:e("titleKnowledgeAssistant"),"data-testid":"knowledge",children:(0,ge.jsxs)(wt,{withDivider:!0,children:[o.map((d,m)=>(0,ge.jsx)(E_,{innerRef:m===o.length-1?n:void 0,item:d,index:m,hasKeyboardInput:i,onCopy:a,onUse:u,onSourceClick:l},`${d.question}_${d.answer}_${m}`)),r.pendingInput&&(0,ge.jsx)(Ef,{title:r.pendingInput})]})})};var bC=x(F());var C_=/(https?:\/\/[^\s]+)/,wC=e=>e.split(" ").find(t=>C_.test(t));var tn=x(T()),k_=({suggestion:e,lines:t,onUse:n})=>{var f;let r=e.text||e.url||e.message,o=wC(r),i=Y(xl),s=U("showImages"),a=U("fallbackImage"),l=U("hasKeyboardInput"),u=d=>{d.preventDefault(),d.stopPropagation(),l&&n(r)},c=(0,bC.useCallback)(d=>{window.open(o,"_blank"),d.stopPropagation(),d.preventDefault()},[o]);return(0,tn.jsxs)(ue,{onClick:l?u:void 0,"data-testid":"edit-suggestion",children:[(0,tn.jsxs)(ye,{children:[s&&e.image&&(0,tn.jsx)(ye.Image,{src:yf(e,"small",a||void 0),title:e.title}),(0,tn.jsxs)(ye.Content,{children:[e.title&&(0,tn.jsx)(ye.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((f=e.searchKeywords)==null?void 0:f.length)>0&&(0,tn.jsx)(ue.Labels,{labels:e.searchKeywords}),(0,tn.jsx)(ye.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,tn.jsxs)(ue.Actions,{children:[o&&(0,tn.jsx)(ue.ActionButton,{onClick:c,label:i("visitUrl")}),l&&(0,tn.jsx)(ue.ActionButton,{primary:!0,onClick:u,label:i("useSuggestion")})]})]})},EC=k_;var _l=x(T()),R_=({lines:e,suggestions:t})=>{let n=kt(),r=(o,i)=>{n.send(In,{text:o,suggestion:I(k({},i),{source:i.source,sourceText:i.text})})};return(0,_l.jsx)(_l.Fragment,{children:t.map(o=>(0,_l.jsx)(EC,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},TC=R_;var Ml={};at(Ml,{enUS:()=>P_,nlNL:()=>L_});var P_={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},L_={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Xo={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",sectionList:"dd-bF9pF",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};var K=x(T()),RC=(e,t)=>{let n=M(ct);(0,ks.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},A_=({onLogIn:e})=>{let t=A("Widget",Xo),n=U("isEmbedded"),r=U("adminUrl");return(0,K.jsx)("div",{className:t.loginText,children:(0,K.jsx)("div",{children:(0,K.jsx)(rf,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},CC=({text:e})=>{let t=A("Widget",Xo);return(0,K.jsx)("div",{className:t.stateText,children:(0,K.jsx)("div",{children:(0,K.jsx)("p",{children:e})})},"notification")},I_=()=>{let e=Y(Ml),t=A("Widget",Xo),n=Uo(()=>On({})),r=U("showSummaryCommand"),o=M(ul("knowledge-assist"));return(0,K.jsx)(K.Fragment,{children:r&&o&&(0,K.jsx)("button",{type:"button",disabled:n.state==="loading",className:t.footerShortcut,onClick:()=>n.call(),children:e("linkSummary")})})},O_=()=>{let e=Y(Ml),t=J(),n=A("Widget",Xo),r=U("showSearch"),o=U("showSummaryCommand"),i=U("showKnowledgeSearch"),s=M(ul("knowledge-assist")),a=U("isEmbedded"),l=M(hs("/admin/")),u=kt(),c=U("productName"),f=U("hasKeyboardInput"),d=Uo(()=>On({})),m=r||o||i||l;return RC(()=>{if(a)return t(uy()),()=>{t(AT())}},[t,a]),!m||!f?null:(0,K.jsx)(wn,{title:e("actions"),type:"shortcuts",children:(0,K.jsxs)("div",{className:n.shortcutList,children:[r&&(0,K.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":e("linkSearch"),onClick:()=>u.send("ShowCommandPalette",{isOpen:!0}),children:[(0,K.jsx)(fs,{}),e("linkSearch")]}),o&&!s&&(0,K.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":e("linkSummary"),disabled:d.state==="loading",onClick:()=>d.call(),children:[(0,K.jsx)(BT,{}),e("linkSummary")]}),i&&!s&&(0,K.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":e("linkKnowledgeSearch"),onClick:()=>u.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,K.jsx)(jT,{}),e("linkKnowledgeSearch")]}),l&&(0,K.jsxs)("a",{className:n.shortcut,target:"_blank",href:l,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:c}),rel:"noreferrer",children:[(0,K.jsx)(zT,{}),e("linkStudioLogin",{productName:c})]})]})})},N_=()=>{let e=J(),t=M(ll),n=M(Fb),r=M(FT),o=M(q1),i=M(Kd),s=M(Yd),a=M(Oo),l=M(An);return(0,ks.useEffect)(()=>{!!o&&!n&&z.warn("Custom data provided, but no schema.")},[o,n]),RC(()=>{t.forEach(({type:u})=>{u==="entities"?e(mn()):au.includes(u)||e(gn(u))})},[e,l,a]),(0,ks.useEffect)(()=>{r.length>0&&!t.some(u=>u.type==="cues")&&z.warn("Received cues, but cues are not configured in widget.")},[t,r]),(0,K.jsx)(ks.Fragment,{children:t.map(({type:u,title:c,amount:f,lines:d,schema:m})=>{var y,v;switch(u){case"entities":return i&&i.length>0&&(0,K.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,K.jsx)(UT,{entities:i})},u);case"cues":return r&&r.length>0&&(0,K.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,K.jsx)(wt,{withDivider:!0,children:(0,K.jsx)(mC,{cues:r})})},u);case"custom-data":return o&&m&&(0,K.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,K.jsx)(wt,{withDivider:!0,children:(0,K.jsx)(hC,{data:o,schema:m})})},u);default:return((v=(y=s[u])==null?void 0:y.suggestions)==null?void 0:v.length)>0&&(0,K.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,K.jsx)(wt,{withDivider:!0,children:(0,K.jsx)(TC,{lines:d,contentType:u,suggestions:s[u].suggestions.slice(0,f)||[]})})},u)}})})},__=({children:e})=>{let t=A("Widget",Xo);return(0,K.jsx)("div",{className:t.footer,children:e})},M_=({onLogIn:e})=>{let t=Y(Ml),n=A("Widget",Xo),r=M(os),o=M(ct),i=M(O1),s=M(Oo);return r===!1?(0,K.jsx)(CC,{text:t("notSupported")}):o===!1?(0,K.jsx)(A_,{onLogIn:e}):!s||!i||o===null?(0,K.jsx)(CC,{text:t("waiting")}):(0,K.jsx)("div",{className:(0,kC.default)(n.root),"data-testid":"widget",children:(0,K.jsxs)(vC,{children:[(0,K.jsxs)(ou,{className:n.sectionList,children:[(0,K.jsx)(O_,{}),(0,K.jsx)(N_,{}),(0,K.jsx)(xC,{})]}),(0,K.jsxs)(__,{children:[(0,K.jsx)(SC,{}),(0,K.jsx)(I_,{})]})]})})},PC=M_;function Rs(e){let t=new Range;return t.selectNodeContents(e),t}function LC(e,t,n){try{return to(e,t,n),!0}catch(r){return!1}}function Af(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function If(e){return"tagName"in e&&e.tagName==="BR"}var Dl=/[\u200B-\u200D\uFEFF]/g;function to(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(l))return u;for(let d=0;d<=l.length;d++)if(f.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(Dl,""),f=o+c.length,d=t>=o&&t<=f,m=n>=o&&n<=f;if(d){let y=s(u,t-o);y===0&&!m?r.setStartBefore(l):r.setStart(l,y)}m&&(r.setEnd(l,s(u,n-o)),i=!0),o=f;break}case Node.ELEMENT_NODE:{if(If(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let c=0;c<l.childNodes.length&&(a(l.childNodes[c]),!i);c++);let u=l.lastChild;Af(l)&&u&&!Af(u)&&!If(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Fl(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(f){let d=f===e,m=f===n,y=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let v=f.textContent;m&&(a=u+v.substring(0,r).replace(Dl,"").length),y&&(l=u+v.substring(0,i).replace(Dl,"").length),u+=v.replace(Dl,"").length;break}case Node.ELEMENT_NODE:{if(If(f)&&f.nextSibling){u++;break}!d&&Af(f)&&f.previousSibling&&u++;for(let v=0;v<f.childNodes.length;v++){let p=m&&v===r,g=y&&v===i;if(p&&(a=u),g&&(l=u),l!==void 0||((!p||!s)&&c(f.childNodes[v]),y&&v===i-1&&(l=u),l!==void 0))break}y&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:l,end:l}}function Hl(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a=0,l="";function u(c){let f=c===e,d=c===n,m=c===o;switch(d&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let y=d?r:0,v=m?i:void 0;l+=c.textContent.replace(Dl,"").substring(y,v);break}case Node.ELEMENT_NODE:{if(!s&&a===1&&If(c)&&c.nextSibling){l+=`
|
|
25
|
+
`)}var p_=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=A("Markdown",cC),s=(0,gr.useRef)(null),[a,l]=(0,gr.useState)(null),u=(0,gr.useMemo)(()=>{let v=Nl(f_(e));return lC.sanitize(v).replaceAll("</code>",`${d_(i.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[e]),c=v=>{var h;let p=v.target,g=!!((h=s.current)!=null&&h.querySelector("code"));if(["A","BUTTON"].includes(p.tagName)){l(null);return}a||g&&p.tagName!=="CODE"||!g&&p!==s.current||(p.addEventListener("mouseleave",()=>l(null),{once:!0}),l(p))},f=()=>{if(!a)return;l(null);let v=a.querySelector("button");v&&(gs(v,i.fadeup),r(Ey(a)))},d=v=>{let p=v.target;if(p.tagName==="A"){v.stopPropagation();return}"copyIcon"in p.dataset&&(gs(p,i.fadeup),r(Ey(p.parentElement)))},m=()=>{!a||!o||(l(null),o(Ey(a)))},y=v=>{if(v===null)return;let p=v.getBoundingClientRect();p.left<0?v.style.transform=`translateX(${-p.left+2}px)`:p.right>window.innerWidth&&(v.style.transform=`translateX(${window.innerWidth-p.right-2}px)`)};return(0,yn.jsxs)(gr.Fragment,{children:[a&&(0,yn.jsxs)(Es,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,yn.jsxs)("div",{className:i.options,ref:y,children:[(0,yn.jsx)("button",{type:"button",className:i.option,onClick:f,children:n}),o&&(0,yn.jsxs)(gr.Fragment,{children:[(0,yn.jsx)("div",{className:i.divider}),(0,yn.jsx)("button",{type:"button",className:i.option,onClick:m,children:t})]})]}),(0,yn.jsx)("div",{className:i.arrow})]}),(0,yn.jsx)("div",{ref:s,"data-testid":"widget-markdown-content",className:i.root,dangerouslySetInnerHTML:{__html:u},onMouseOver:c,onClick:d})]})},Pf=p_;var Ty={};at(Ty,{enUS:()=>m_,nlNL:()=>g_});var m_={useCue:[{type:0,value:"Add to message"}],__summarizerAssistant__:[{type:0,value:"Summary"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},g_={useCue:[{type:0,value:"Voeg toe aan bericht"}],__summarizerAssistant__:[{type:0,value:"Samenvatting"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var dC={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l",form:"dd-sPNU2",formInput:"dd-F3E4I",formSubmit:"dd-vw5S0",actionButton:"dd-cCWyJ",inputSpace:"dd-DGYB1"};var en=x(T()),h_=({cue:e,onCallToAction:t,onRemove:n,onCopy:r,onUse:o})=>{let i=A("WidgetCue",dC),s=Y(Ty),a=Qr(),l=U("hasKeyboardInput"),u=()=>{t&&t(e),n(e)},c=m=>{r&&r(m,e)},f=m=>{o&&o(m,e)},d=m=>{m.preventDefault(),m.stopPropagation(),n(e)};return(0,fC.useEffect)(()=>{a("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,en.jsxs)(ue,{"data-testid":"cue",children:[(0,en.jsx)(ye,{children:(0,en.jsxs)(ye.Content,{children:[e.title&&(0,en.jsx)(ye.Title,{className:i.title,"data-testid":"widget-cue-title",children:e.rule.label.startsWith("__")?s(e.rule.label):e.title}),(0,en.jsx)(Pf,{content:e.text,useLabel:s("useCue"),copyLabel:s("copyCue"),onCopy:c,onUse:l?f:void 0})]})}),(0,en.jsxs)(ue.ButtonsContainer,{children:[(0,en.jsxs)("div",{className:i.actions,children:[e.callToAction&&(0,en.jsx)(ue.Button,{onClick:u,children:e.callToAction.label}),(0,en.jsx)(ue.Button,{onClick:d,children:s("removeCue")})]}),(0,en.jsx)(ys,{eventName:"Assistant response feedback",eventData:{name:e.rule.name,group:e.rule.label,description:e.rule.description,cueText:e.text},feedbackText:e.text,feedbackType:"assistant"})]})]})},pC=h_;var Ts=x(T()),y_=({cues:e})=>{let t=J(),n=kt(),r=Qr(),o=l=>{t(MT({id:l.rule.id})),t(Nb({code:l.rule.label})),r("Assistant response closed",{name:l.rule.name,group:l.rule.label,description:l.rule.description,cueText:l.text})},i=(l,u)=>{Nn(l),r("Assistant response copied",{name:u.rule.name,group:u.rule.label,description:u.rule.description,copiedText:l})},s=l=>{l.callToAction&&(t(Nd(l)),r("Assistant call to action",{name:l.rule.name,group:l.rule.label,description:l.rule.description,eventName:l.callToAction.event,value:l.callToAction.value}))},a=(l,u)=>{n.send(In,{text:l,suggestion:{source:"cue",sourceText:l}}),r("Assistant response used",{name:u.rule.name,group:u.rule.label,description:u.rule.description,usedText:l})};return(0,Ts.jsx)(Ts.Fragment,{children:e.map(l=>l.isLoading?(0,Ts.jsx)(Ef,{title:l.title},l.rule.id):(0,Ts.jsx)(pC,{cue:l,onCallToAction:s,onRemove:o,onCopy:i,onUse:a},l.rule.id))})},mC=y_;var Lf=x(F());var gC={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var vn=x(T());function v_(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var hC=({data:e,schema:t})=>{let n=A("WidgetCustomData",gC),r=o=>{Nn(o)};return(0,Lf.useEffect)(()=>{z.info("Custom data",e,t)},[e]),(0,vn.jsx)("dl",{className:n.root,children:t.map(o=>{let i=v_(e,o.path);return(0,vn.jsxs)(Lf.Fragment,{children:[(0,vn.jsx)("dt",{className:n.label,children:o.label}),(0,vn.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,vn.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,vn.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,vn.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,vn.jsx)("span",{className:n.copyButtonText,children:i}),(0,vn.jsx)(Pl,{})]}):"-"})]},o.label)})})};var Pt=x(F());var Cy=x(T()),yC=()=>(0,Cy.jsx)("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"ReplayIcon",children:(0,Cy.jsx)("path",{d:"M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8"})});var Cs={};at(Cs,{enUS:()=>S_,nlNL:()=>x_});var S_={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"What is your question?"}],useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Submit"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},x_={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"Wat is je vraag?"}],useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Verzend"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var ky={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",sources:"dd-xf9c6",source:"dd-a-vyX",link:"dd-PyUPS",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};var ge=x(T()),w_=3,b_=({sources:e,onClick:t})=>{let n=Y(Cs),r=A("WidgetKnowledgeAssistant",ky),[o,i]=(0,Pt.useState)(!1),s=o?e:e.slice(0,w_);return s.length===0?null:(0,ge.jsxs)("ul",{className:r.sources,children:[s.map(a=>(0,ge.jsx)("li",{className:r.source,"data-testid":"knowledge-assist-source",children:(0,ge.jsx)("a",{className:r.link,rel:"noreferrer",target:"_blank",href:a.url,onClick:l=>{l.stopPropagation(),t(a)},"data-tooltip":a.url?decodeURIComponent(a.url):void 0,children:(0,ge.jsx)("span",{className:r.linkContent,children:a.name})})},a.name)),s<e&&(0,ge.jsx)("button",{type:"button",className:r.showMoreSources,onClick:()=>i(!0),children:n("showMore",{amount:e.length-s.length})})]})},E_=({innerRef:e,item:t,index:n,hasKeyboardInput:r,onCopy:o,onUse:i,onSourceClick:s})=>{var l;let a=Y(Cs);return(0,ge.jsxs)(ue,{"data-testid":"knowledge-assist-answer",ref:e,children:[(0,ge.jsx)(ye,{children:(0,ge.jsxs)(ye.Content,{children:[(0,ge.jsx)(ye.Title,{children:t.question}),(0,ge.jsx)(Pf,{content:t.answer.answer,useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:o,onUse:r?i:void 0}),(0,ge.jsx)(b_,{sources:(l=t.answer.sources)!=null?l:[],onClick:u=>s(u,t.question)})]})}),(0,ge.jsxs)(ue.ButtonsContainer,{children:[(0,ge.jsx)("div",{}),(0,ge.jsx)(ys,{eventName:"knowledge assist feedback",eventData:{question:t.question,isFollowUpQuestion:n>0,isAgent:!0,answer:t.answer.answer},feedbackText:t.answer.answer,feedbackType:"assistant"})]})]})},Ry=(0,Pt.createContext)(null),vC=({children:e})=>{let[t,n]=(0,Pt.useState)(null),r=M(ul("knowledge-assist")),[o,i]=(0,Pt.useState)(!1),[s,a]=(0,Pt.useState)(null),l=J(),u=Uo(d=>il({input:d,threadId:t,onNewThreadId(m){n(m)}})),c={isEnabled:r,isSubmitting:o,threadId:t,pendingInput:s,onSubmit(d){return R(this,null,function*(){i(!0),a(d),yield u.call(d),i(!1),a(null)})},onReset(){t&&l(us(t))}};return(0,ge.jsx)(Ry.Provider,{value:c,children:e})},SC=()=>{let e=Y(Cs),t=A("WidgetKnowledgeAssistant",ky),n=(0,Pt.useContext)(Ry),r=(0,Pt.useRef)(null),[o,i]=(0,Pt.useState)(""),s=u=>{i(u.target.value)},a=u=>{u.preventDefault(),n.onSubmit(o).then(()=>{var c;r.current&&((c=r.current)==null||c.focus(),i(""))})},l=u=>{u.preventDefault(),n.onReset()};return n.isEnabled?(0,ge.jsxs)("form",{className:t.form,onSubmit:a,children:[(0,ge.jsx)("input",{ref:r,className:t.formInput,placeholder:e("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:o,onChange:s}),(0,ge.jsx)("button",{type:"submit",disabled:n.isSubmitting||o==="",className:t.formSubmit,children:e("submitLabel")}),(0,ge.jsx)("button",{type:"button",title:e("resetLabel"),disabled:n.threadId===null||n.isSubmitting,onClick:l,className:t.actionButton,children:(0,ge.jsx)(yC,{})})]}):null},xC=()=>{var c,f;let e=Y(Cs),t=Qr(),n=(0,Pt.useRef)(null),r=(0,Pt.useContext)(Ry),o=(f=M(ol((c=r.threadId)!=null?c:-1)))!=null?f:[],i=U("hasKeyboardInput"),s=kt(),a=d=>{Nn(d),t("Assistant response copied",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",copiedText:d})},l=(d,m)=>{t("knowledge assist source viewed",{question:m,sourceViewed:d.url||d.name})},u=d=>{s.send(In,{text:d,suggestion:{source:"cue",sourceText:d}}),t("Assistant response used",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",usedText:d})};return!r.isEnabled||(o==null?void 0:o.length)===0&&!r.isSubmitting?null:(0,ge.jsx)(wn,{type:"knowledge",title:e("titleKnowledgeAssistant"),"data-testid":"knowledge",children:(0,ge.jsxs)(wt,{withDivider:!0,children:[o.map((d,m)=>(0,ge.jsx)(E_,{innerRef:m===o.length-1?n:void 0,item:d,index:m,hasKeyboardInput:i,onCopy:a,onUse:u,onSourceClick:l},`${d.question}_${d.answer}_${m}`)),r.pendingInput&&(0,ge.jsx)(Ef,{title:r.pendingInput})]})})};var bC=x(F());var C_=/(https?:\/\/[^\s]+)/,wC=e=>e.split(" ").find(t=>C_.test(t));var tn=x(T()),k_=({suggestion:e,lines:t,onUse:n})=>{var f;let r=e.text||e.url||e.message,o=wC(r),i=Y(xl),s=U("showImages"),a=U("fallbackImage"),l=U("hasKeyboardInput"),u=d=>{d.preventDefault(),d.stopPropagation(),l&&n(r)},c=(0,bC.useCallback)(d=>{window.open(o,"_blank"),d.stopPropagation(),d.preventDefault()},[o]);return(0,tn.jsxs)(ue,{onClick:l?u:void 0,"data-testid":"edit-suggestion",children:[(0,tn.jsxs)(ye,{children:[s&&e.image&&(0,tn.jsx)(ye.Image,{src:yf(e,"small",a||void 0),title:e.title}),(0,tn.jsxs)(ye.Content,{children:[e.title&&(0,tn.jsx)(ye.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((f=e.searchKeywords)==null?void 0:f.length)>0&&(0,tn.jsx)(ue.Labels,{labels:e.searchKeywords}),(0,tn.jsx)(ye.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,tn.jsxs)(ue.Actions,{children:[o&&(0,tn.jsx)(ue.ActionButton,{onClick:c,label:i("visitUrl")}),l&&(0,tn.jsx)(ue.ActionButton,{primary:!0,onClick:u,label:i("useSuggestion")})]})]})},EC=k_;var _l=x(T()),R_=({lines:e,suggestions:t})=>{let n=kt(),r=(o,i)=>{n.send(In,{text:o,suggestion:I(k({},i),{source:i.source,sourceText:i.text})})};return(0,_l.jsx)(_l.Fragment,{children:t.map(o=>(0,_l.jsx)(EC,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},TC=R_;var Ml={};at(Ml,{enUS:()=>P_,nlNL:()=>L_});var P_={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},L_={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Xo={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",sectionList:"dd-bF9pF",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};var K=x(T()),RC=(e,t)=>{let n=M(ct);(0,ks.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},A_=({onLogIn:e})=>{let t=A("Widget",Xo),n=U("isEmbedded"),r=U("adminUrl");return(0,K.jsx)("div",{className:t.loginText,children:(0,K.jsx)("div",{children:(0,K.jsx)(rf,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},CC=({text:e})=>{let t=A("Widget",Xo);return(0,K.jsx)("div",{className:t.stateText,children:(0,K.jsx)("div",{children:(0,K.jsx)("p",{children:e})})},"notification")},I_=()=>{let e=Y(Ml),t=A("Widget",Xo),n=Uo(()=>On({})),r=U("showSummaryCommand"),o=M(ul("knowledge-assist"));return(0,K.jsx)(K.Fragment,{children:r&&o&&(0,K.jsx)("button",{type:"button",disabled:n.state==="loading",className:t.footerShortcut,onClick:()=>n.call(),children:e("linkSummary")})})},O_=()=>{let e=Y(Ml),t=J(),n=A("Widget",Xo),r=U("showSearch"),o=U("showSummaryCommand"),i=U("showKnowledgeSearch"),s=M(ul("knowledge-assist")),a=U("isEmbedded"),l=M(hs("/admin/")),u=kt(),c=U("productName"),f=U("hasKeyboardInput"),d=Uo(()=>On({})),m=r||o||i||l;return RC(()=>{if(a)return t(uy()),()=>{t(AT())}},[t,a]),!m||!f?null:(0,K.jsx)(wn,{title:e("actions"),type:"shortcuts",children:(0,K.jsxs)("div",{className:n.shortcutList,children:[r&&(0,K.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":e("linkSearch"),onClick:()=>u.send("ShowCommandPalette",{isOpen:!0}),children:[(0,K.jsx)(fs,{}),e("linkSearch")]}),o&&!s&&(0,K.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":e("linkSummary"),disabled:d.state==="loading",onClick:()=>d.call(),children:[(0,K.jsx)(BT,{}),e("linkSummary")]}),i&&!s&&(0,K.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":e("linkKnowledgeSearch"),onClick:()=>u.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,K.jsx)(jT,{}),e("linkKnowledgeSearch")]}),l&&(0,K.jsxs)("a",{className:n.shortcut,target:"_blank",href:l,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:c}),rel:"noreferrer",children:[(0,K.jsx)(zT,{}),e("linkStudioLogin",{productName:c})]})]})})},N_=()=>{let e=J(),t=M(ll),n=M(Fb),r=M(FT),o=M(q1),i=M(Kd),s=M(Yd),a=M(Oo),l=M(An);return(0,ks.useEffect)(()=>{!!o&&!n&&z.warn("Custom data provided, but no schema.")},[o,n]),RC(()=>{t.forEach(({type:u})=>{u==="entities"?e(mn()):au.includes(u)||e(gn(u))})},[e,l,a]),(0,ks.useEffect)(()=>{r.length>0&&!t.some(u=>u.type==="cues")&&z.warn("Received cues, but cues are not configured in widget.")},[t,r]),(0,K.jsx)(ks.Fragment,{children:t.map(({type:u,title:c,amount:f,lines:d,schema:m})=>{var y,v;switch(u){case"entities":return i&&i.length>0&&(0,K.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,K.jsx)(UT,{entities:i})},u);case"cues":return r&&r.length>0&&(0,K.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,K.jsx)(wt,{withDivider:!0,children:(0,K.jsx)(mC,{cues:r})})},u);case"custom-data":return o&&m&&(0,K.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,K.jsx)(wt,{withDivider:!0,children:(0,K.jsx)(hC,{data:o,schema:m})})},u);default:return((v=(y=s[u])==null?void 0:y.suggestions)==null?void 0:v.length)>0&&(0,K.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,K.jsx)(wt,{withDivider:!0,children:(0,K.jsx)(TC,{lines:d,contentType:u,suggestions:s[u].suggestions.slice(0,f)||[]})})},u)}})})},__=({children:e})=>{let t=A("Widget",Xo);return(0,K.jsx)("div",{className:t.footer,children:e})},M_=({onLogIn:e})=>{let t=Y(Ml),n=A("Widget",Xo),r=M(os),o=M(ct),i=M(O1),s=M(Oo);return r===!1?(0,K.jsx)(CC,{text:t("notSupported")}):o===!1?(0,K.jsx)(A_,{onLogIn:e}):!s||!i||o===null?(0,K.jsx)(CC,{text:t("waiting")}):(0,K.jsx)("div",{className:(0,kC.default)(n.root),"data-testid":"widget",children:(0,K.jsxs)(vC,{children:[(0,K.jsxs)(ou,{className:n.sectionList,children:[(0,K.jsx)(O_,{}),(0,K.jsx)(N_,{}),(0,K.jsx)(xC,{})]}),(0,K.jsxs)(__,{children:[(0,K.jsx)(SC,{}),(0,K.jsx)(I_,{})]})]})})},PC=M_;function Rs(e){let t=new Range;return t.selectNodeContents(e),t}function LC(e,t,n){try{return to(e,t,n),!0}catch(r){return!1}}function Af(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function If(e){return"tagName"in e&&e.tagName==="BR"}var Dl=/[\u200B-\u200D\uFEFF]/g;function to(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(l))return u;for(let d=0;d<=l.length;d++)if(f.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(Dl,""),f=o+c.length,d=t>=o&&t<=f,m=n>=o&&n<=f;if(d){let y=s(u,t-o);y===0&&!m?r.setStartBefore(l):r.setStart(l,y)}m&&(r.setEnd(l,s(u,n-o)),i=!0),o=f;break}case Node.ELEMENT_NODE:{if(If(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let c=0;c<l.childNodes.length&&(a(l.childNodes[c]),!i);c++);let u=l.lastChild;Af(l)&&u&&!Af(u)&&!If(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Fl(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(f){let d=f===e,m=f===n,y=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let v=f.textContent;m&&(a=u+v.substring(0,r).replace(Dl,"").length),y&&(l=u+v.substring(0,i).replace(Dl,"").length),u+=v.replace(Dl,"").length;break}case Node.ELEMENT_NODE:{if(If(f)&&f.nextSibling){u++;break}!d&&Af(f)&&f.previousSibling&&u++;for(let v=0;v<f.childNodes.length;v++){let p=m&&v===r,g=y&&v===i;if(p&&(a=u),g&&(l=u),l!==void 0||((!p||!s)&&c(f.childNodes[v]),y&&v===i-1&&(l=u),l!==void 0))break}y&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:l,end:l}}function Hl(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a=0,l="";function u(c){let f=c===e,d=c===n,m=c===o;switch(d&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let y=d?r:0,v=m?i:void 0;l+=c.textContent.replace(Dl,"").substring(y,v);break}case Node.ELEMENT_NODE:{if(!s&&a===1&&If(c)&&c.nextSibling){l+=`
|
|
26
26
|
`;break}!f&&!s&&a===1&&Af(c)&&c.previousSibling&&(l+=`
|
|
27
|
-
`);let y=d?r:0,v=m?Math.min(i,c.childNodes.length):c.childNodes.length;for(let p=y;p<v&&(u(c.childNodes[p]),a!==2);p++);break}default:break}m&&(a=2)}return u(e),l}var AC=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(AC||{}),hr=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.cachedCaretPosition===null;if(!this.isActive||(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText?(this.cachedText=t,this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,o=!0,this.emit("selection",r)),!o))return;let i=this.getCaretPosition();Kr(i,this.cachedCaretPosition)||(this.cachedCaretPosition=i,this.emit("caretposition",i))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(AC).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function IC(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Zo=class extends hr{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Hl(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var s;let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o="getComposedRanges"in r&&n instanceof ShadowRoot?(s=r.getComposedRanges(n))==null?void 0:s[0]:r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let i=this.element.ownerDocument.createRange();return i.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),i.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!i||!this.element.contains(i.startContainer)||!this.element.contains(i.endContainer)?null:i}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!IC(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!IC(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Fl(this.element,n);let r=this.lastKnownSelection;if(r&&LC(this.element,r.start,r.end))return r;let o=Rs(this.element);return o.collapse(!1),Fl(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Hl(this.element,to(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(i=>{var s,a;i.length===2&&i[0].addedNodes.length===1&&((s=i[0].addedNodes[0])==null?void 0:s.textContent)==="\u2060"&&((a=i[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var D_=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function OC(e,t){let n="mozInnerScreenX"in window,r=document.createElement("div");r.id="input-textarea-caret-position-mirror-div";let o=r.style,i=window.getComputedStyle(e),s=e.ownerDocument.body;o.whiteSpace="pre-wrap",o.wordWrap="break-word",o.position="absolute",o.visibility="hidden",D_.forEach(function(c){o[c]=i[c]}),n?e.scrollHeight>parseInt(i.height)&&(o.overflowY="scroll"):o.overflow="hidden",r.textContent=e.value.substring(0,t);let a=document.createElement("span");a.textContent=e.value.substring(t)||".",r.appendChild(a),s.appendChild(r);let l=e.getBoundingClientRect(),u={top:l.top-e.scrollTop+a.offsetTop+parseInt(i.borderTopWidth)+a.offsetHeight,left:l.left-e.scrollLeft+a.offsetLeft+parseInt(i.borderLeftWidth)};return s.removeChild(r),u}var Jo=class extends hr{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return OC(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function NC(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let i=document.createElement("iframe"),s=new URL(t);return Object.entries(n).forEach(([a,l])=>{s.searchParams.append(a,l)}),i.style.position="absolute",i.style.left="-999em",i.style.width="0px",i.style.height="0px",i.tabIndex=-1,i.id=r,i.title=`iframe-${e}`,i.src=s.toString(),window.document.body.appendChild(i),i}function F_(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var Py=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},Ly=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=NC(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},Ay=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),z.info("Set sessionId",t),this.sessionId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new Ly(t,this.deepdeskUrl,{debug:!0}):new Py(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=F_(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(z.info("Received broadcast event",this.sessionId,o),(a=(s=this.eventMap)[i.name])==null||a.call(s,i.payload))};return n.onMessage(r),n}send(t,n,r){var s,a;z.info("Broadcast event",{sessionId:this.sessionId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(s=this.eventMap)[t])==null||a.call(s,n));let i=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;i==null||i.postMessage(I(k({},o),{channel:this.sessionId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),delete this.channel,t&&((r=this.defaultChannel)==null||r.close(),delete this.defaultChannel)}},_C=Ay;function H_(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function he(e){return Array.isArray(e)?e.map(he):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(k({},t),{[H_(n)]:he(e[n])}),{}):e}function U_(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function qe(e){return Array.isArray(e)?e.map(qe):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(k({},t),{[U_(n)]:qe(e[n])}),{}):e}var Ps=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Iy=e=>new Promise(t=>{setTimeout(t,e)});var Ls=class extends Ps{constructor(){super(...arguments);this.name="ClientError"}},Ny=class extends Ps{constructor(){super(...arguments);this.name="ServerError"}},Oy=new Map;function z_(e){return R(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(z.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var no=class no{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",E=n,{useCache:u=!1,abortLatest:c=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:m=!0,retryOnError:y=P=>P instanceof TypeError,retryOnResponse:v=P=>P.status>=500,version:p=null}=E,g=ee(E,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u)if(l){if(Oy.has(s)){r(Oy.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h=I(k({credentials:"include"},g),{headers:k({Accept:"application/json","Content-Type":"application/json"},g.headers)});!l&&this.csrfToken&&(h.headers=I(k({},h.headers),{"X-CSRFToken":this.csrfToken})),typeof p=="string"&&(h.headers=I(k({},h.headers),{"X-Deepdesk-API-Version":p}));let S=f,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let C=()=>R(this,null,function*(){return S--,a(s,h).then(P=>R(this,null,function*(){return v(P)&&!i.isAborted&&S>0?(yield Iy(d),C()):P.status===401&&m===!0&&w===!1?(w=!0,yield this.refreshToken(),C()):P})).catch(P=>R(this,null,function*(){if(y(P)&&!i.isAborted&&S>0)return yield Iy(d),C();throw P}))});C().then(P=>R(this,null,function*(){let N=yield z_(P);if(delete this.latestRequestByUrl[s],P.status>=500){o(new Ny("Server Error",N));return}else if(P.status===401){o(new Ls("Unauthorized",N));return}else if(P.status===403){o(new Ls("Forbidden",N));return}else if(P.status===404){o(new Ls("Not Found",N));return}else if(P.status>=400){o(new Ls("Bad Request",N));return}u&&Oy.set(s,N),r(N)})).catch(P=>{o(P)})})}validateToken(){return R(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)try{yield this.refreshToken()}catch(r){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/");return!!n})}refreshToken(){return no.refreshingToken||(no.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{no.refreshingToken=null},1e3*60)})),no.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,k({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,k({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,k({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,k({method:"DELETE"},n))}};no.refreshingToken=null;var ei=no;var MC;(t=>{let e;(s=>(s.SEND_MESSAGE="Send Message",s.HANDLING_TIME="Handling Time",s.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",s.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(e=t.EventType||(t.EventType={}))})(MC||(MC={}));function Of(e){return I(k({},he(e)),{tags:e.tags})}var ti=class ti{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new ei(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>R(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return R(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(ti.exchangeTokenPromise||(ti.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),ti.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return R(this,null,function*(){yield this.preflight(),z.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",I(k({},qe(t)),{tags:t.tags}),{version:"v2"});return Of(n)})}getMe(){return R(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return he(t)})}postIdentity(t){return R(this,null,function*(){yield this.client.post("/apis/admin/session/me/identities/",qe(t))})}patchMe(t){return R(this,null,function*(){let n=yield this.client.patch("/apis/admin/session/me/",qe(t));return he(n)})}getProfile(t){return R(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return he(n)})}getKnowledgeAssistant(t){return R(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return he(n)})}getContentTypes(){return R(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return he(t)})}getAccount(){return R(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return he(t)})}getPlatformConfig(t){return R(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return he(r)})}checkUserExists(t){return R(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationBySessionId(r){return R(this,arguments,function*(t,n={}){yield this.preflight(),z.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:i=1e3}=n,s=yield this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return z.info(`Successfully retrieved conversation ${s.id} for session ${t}`),Of(s)})}isConversationSupported(r){return R(this,arguments,function*(t,n={}){z.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:i=1e3}=n;return(yield this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"})).has_active_profile})}updateConversation(t,n){return R(this,null,function*(){let r=qe(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Of(o)})}postMessages(t,n){return R(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>I(k({},qe(o)),{tags:o.tags})),{version:"v2"})).map(o=>Of(o))})}sendEvent(t,n){return R(this,null,function*(){let s=n,{data:r}=s,o=ee(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>I(k({},a),{[l]:u}),{});return this.client.post("/api/events",qe(I(k(k({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return R(this,null,function*(){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>I(k({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:qe(k(k({},n),r))},{version:"v1"})})}getEntities(t){return R(this,null,function*(){return(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)},{version:"v1"})).entities})}getTemporaryExchangeToken(){return R(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(t){return R(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw z.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return R(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",qe(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return R(this,arguments,function*(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,qe(n),{abortLatest:!0,version:"v1"})).map(s=>I(k({},he(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(u=>u.text===s.text))})}isLoggedIn(){return R(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return R(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/autocomplete`,qe(n),{abortLatest:!0,version:"v1"})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return R(this,null,function*(){let n=yield this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0,version:"v1"});return he(n).map(r=>I(k({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return R(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",qe(t),{abortLatest:!0,version:"v1"});return he(n)})}search(t){return R(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,qe(t),{version:"v2"});return he(n)})}knowledgeAssist(i,s,a){return R(this,arguments,function*(t,n,r,o={}){let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,qe({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(u=>({question:u.question,answer:u.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return he(l)})}requestLoginByEmail(t){return R(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return he(n)})}requestPasswordlessToken(){return R(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return he(t.token)})}getCsrfToken(){return R(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return R(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return he(n)})}evaluateRule(i,s,a){return R(this,arguments,function*(t,n,r,o={}){let l=new URLSearchParams;o.raiseForFailingConditions&&l.set("raise_for_failing_conditions","true");let u=yield this.client.post(`/api/conversations/${n}/rules/${t}/evaluate?${l.toString()}`,r,{version:"v2"});return u?he(u.cues):[]})}getSummary(r){return R(this,arguments,function*(t,n={}){let o=yield this.client.post("/api/summary",{conversation:{messages:t.filter(i=>i.text&&i.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model},{version:"v1"});return he(o)})}evaluateAssistant(t,n){return R(this,null,function*(){var a;let r=new URLSearchParams,{expectFormat:o="text"}=n||{};if(o.startsWith("json-schema:")){let l=o.replace("json-schema:","");r.append("expect_response_format","json-schema"),r.append("expect_response_format_schema",l)}else r.append("expect_response_format",o);n!=null&&n.externalConversationId&&r.append("external_conversation_id",n.externalConversationId);let i=n!=null&&n.threadId?`/api/v2/assistants/${t}/threads/${n==null?void 0:n.threadId}/evaluate?${r.toString()}`:`/api/v2/assistants/${t}/evaluate?${r.toString()}`,s=yield this.client.post(i,{input:(a=n==null?void 0:n.input)!=null?a:{},conversation:n==null?void 0:n.transcript});return he(s.output)})}createAssistantThread(t){return R(this,null,function*(){let{assistantCode:n}=t,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return he(r)})}postMessageToAssistantThread(t){return R(this,null,function*(){let{assistantCode:n,threadId:r,message:o}=t,i=yield this.client.post(`/apis/admin/assistants/${n}/threads/${r}/messages/`,{content:o,role:"user"});return he(i)})}getRules(){return R(this,null,function*(){let t=new URLSearchParams,n=yield this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{useCache:!0});return he(n)})}translateMessages(t){return R(this,null,function*(){let n=yield this.client.post("/api/translate",qe(t),{version:"v2"});return he(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(e0);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&z.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};ti.exchangeTokenPromise=null;var yr=ti;var DC={startTime:null,stopTime:null},FC=e=>e.handlingTime,HC=ne({name:"handlingTime",initialState:DC,reducers:{handlingTimeStart(e){if(e.startTime&&!e.stopTime)throw new Error("Timing already started");e.startTime=new Date,e.stopTime=null},handlingTimeStop(e){if(!e.startTime)throw new Error("Timing not started");e.stopTime=new Date},handlingTimeReset(e){e.startTime=null,e.stopTime=null}},extraReducers:e=>{e.addCase(Ae,()=>DC)}}),{handlingTimeStart:UC,handlingTimeStop:Nf,handlingTimeReset:zC}=HC.actions,jC=HC.reducer;var BC=(e={})=>{let t=k({onAuthError:rs(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var _f={list:{keywordMatches:[]},fetchState:"idle"};var ni=X("styleSuggestions/getAll",(n,r)=>R(void 0,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(l=i.conversation.current)==null?void 0:l.profileCode;if(!s)return _f.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),j_=ne({name:"styleSuggestions",initialState:_f,reducers:{},extraReducers:e=>{e.addCase(ni.pending,t=>{t.fetchState="loading"}).addCase(ni.rejected,t=>{t.fetchState="error"}).addCase(ni.fulfilled,(t,n)=>{t.fetchState="done",Kr(t.list,n.payload)||(t.list=n.payload)}).addCase(Po,t=>{t.list=_f.list}).addCase(Ae,()=>_f)}}),VC=j_.reducer;var WC=(e={})=>{let t,n=!0,r=k({getStyleSuggestions:ni,debounce:500},e);return o=>i=>s=>{var m;let a=o.getState().input.text,l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:c}=u.settings;if(!((m=u.conversation.current)==null?void 0:m.id)||!c)return l;let{text:d}=u.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function B_(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var KC=(e={})=>{let t=k({getTextSuggestions:gn,getAutocompleteSuggestions:bl,debounce:200,check:_n},e),n;return r=>o=>i=>{var v;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,f=(v=l.conversation.current)==null?void 0:v.id,d=i.type===Qd.toString();if(!f||!u&&!c)return a;let{input:m}=l;return B_(m,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let p=is(l);p===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(p))},d?0:t.debounce)),a}};var $C=ni.fulfilled.toString();function V_(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let i=e.keywordMatches.filter(l=>l.keyword===o),s=t.keywordMatches.filter(l=>l.keyword===o),a=s.length-i.length;a<=0||r.push(...s.slice(0,a))}),r}var qC=e=>t=>n=>r=>{var u;if(r.type!==$C){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(u=i.conversation)==null?void 0:u.current;if(o===s)return;let l=V_(o,s);r.type===$C&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var W_=Rc({assistants:_b,auth:b1,conversation:N1,contentTypes:Db,passwordlessToken:IT,entities:uE,knowledgeAssistant:Lb,handlingTime:jC,info:Z1,input:K1,settings:g1,profile:Hb,search:ob,styleSuggestions:VC,ui:$E,rules:DT,textSuggestions:AE});function GC(e){return ww({reducer:W_,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}),BC(),KC({debounce:200}),WC({debounce:500}),qC(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var K_=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},$_=e=>t=>n=>r=>{var a,l,u,c,f,d,m;let o=t.getState(),i=Jg("inlineSuggestions")(o);switch(r.type){case rs.toString():{!r.payload&&e.emit("logout",void 0);break}case mn.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(a=o.conversation.current)==null?void 0:a.id,data:{entities:r.payload}});break;case Gt.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((u=o.conversation.current)==null?void 0:u.id),data:r.payload.data});break;case Po.toString():e.logSendMessage(r.payload);break;case Go.fulfilled.toString():r.isBroadcasted||e.broadcast(lh,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;case Nd.toString():e.emit("call-to-action",{cue:r.payload});break;case rr.fulfilled.toString():r.isBroadcasted||e.broadcast(uh,r,!1);break;default:break}let s=n(r);switch(r.type){case Po.toString():e.handleAfterSendMessage(r.payload);break;case Tl.toString():e.onUpdateShowTabHint(r.payload);break;case Nf.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case ud.toString():{let{start:y,end:v}=o.input.selection;e.emit("replace",I(k({},r.payload),{replace:r.payload.replace==="selection"?{start:y,end:v}:{start:0,end:v}}));break}case un.toString():{let{start:y,end:v}=o.input.selection;e.emit("select-suggestion",I(k({type:K_(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:y,end:v}:{start:0,end:v}})),i&&t.dispatch($r([]));break}case cd.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case $r.toString():{i&&r.payload.length>0&&t.dispatch(dd(0));break}case On.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload,assistant:(m=t.getState().profile.data)==null?void 0:m.summarizerAssistantNew}});break}default:break}return s},YC=$_;function _y(e){return e.toISOString().replace("T"," ").replace("Z","")}var q_=(e,t)=>t.version,QC=ln([as,An,FC,q_],(e,t,n,r)=>{if(!t)return z.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:i}=n;return!o||!i?(z.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:t,clientVersion:r,agentId:e==null?void 0:e.agentId,agentName:e==null?void 0:e.agentName,agentEmail:e==null?void 0:e.agentEmail,timeStart:_y(o),timeStop:_y(i)}});function XC(e,t,n){var N,_,q,B;let r=(N=t.conversation.current)==null?void 0:N.id;if(!r)return z.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:u,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:f,pastes:d,cuts:m,deletions:y,textSuggestions:v,offeredTextSuggestions:p}}=t[e],g=o.length,S=v.reduce((V,{text:fe,searchTerm:Ge})=>V+fe.length-(Ge?Ge.length:0),0),w=c!=null?c:Date.now(),C=(Date.now()-w)/1e3+(f||0),E=i/C,P=v.reduce((V,{searchTerm:fe})=>V+(fe?fe.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:m,deletions:y,lenTextTyped:i+P,lenTextTotal:g,lenTextAssisted:S,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:C,charsPerSecond:E,numPastes:u,textSuggestionsV2:v,suggestionsCounters:[{source:"gpt",countOffered:p.filter(V=>V.source==="gpt").length}],agentId:(_=t.info.agentInfo)==null?void 0:_.agentId,agentName:(q=t.info.agentInfo)==null?void 0:q.agentName,agentEmail:(B=t.info.agentInfo)==null?void 0:B.agentEmail}}function My(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return My(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?My(o,t):null}function ZC(e,t){return My(e,t)}function JC(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function G_(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Mf(e){return G_(e)&&(qo(e)||sf(e))}var tk,Hn=new Map,Y_=["bottom","height","left","right","top","width"],ek=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:Y_.some(n=>e[n]!==t[n]);function nk(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...nk(t)]:[]}function rk(e,t){return!e||!t?null:I(k({},e),{top:e.top+t.top,left:e.left+t.left})}var Df=!1,ok=()=>{Df=!0;let e=[];if(Hn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Hn.delete(n);return}let r=n.getBoundingClientRect();ek(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(rk,t.rect):t.rect;ek(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Hn.size===0){Df=!1;return}tk=window.requestAnimationFrame(ok)};function Dy(e,t){let n=nk(e),r=[],o=n.map((i,s)=>Dy(i,a=>{r[s]=a;let l=Hn.get(e);if(!l)return;let u=r.reduce(rk,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Hn.has(e)){let s=Hn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Hn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Df&&ok()},unobserve(){o.forEach(s=>s.unobserve());let i=Hn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Hn.delete(e),Hn.size||(cancelAnimationFrame(tk),Df=!1)}}}}var ik,Un=new Map,sk=()=>{Un.forEach((e,t)=>{if(!t.isConnected){Un.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(i=>i(e.visible)))}),Un.size!==0&&(ik=window.requestAnimationFrame(sk))};function ak(e,t){return{observe(){let n=Un.size===0;Un.has(e)?Un.get(e).callbacks.push(t):Un.set(e,{visible:void 0,callbacks:[t]}),n&&sk()},unobserve(){let n=Un.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Un.delete(e),Un.size||cancelAnimationFrame(ik)}}}}var Fy=["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","borderStyle","boxSizing","color","overflowWrap","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontWeight","fontKerning","lineHeight","letterSpacing","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","textIndent","whiteSpace","wordBreak","wordSpacing","wordWrap"];function Hy(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function As(e){return parseFloat(e)}function Ff(e){return Math.round(e*1e6)}function lk(e){return e/1e6}function Uy(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=As(e.width),i=As(e.borderLeftWidth),s=As(e.borderRightWidth),a=As(e.paddingRight),l=lk(Ff(o)-Ff(i)-Ff(s)),u=lk(Ff(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function Ul(e,t={}){var c,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=t.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",Wo(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};Hy(r,n,Fy),Uy(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=ak(e,()=>{Hy(r,n,Fy),Uy(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Dy(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(Hy(r,n,Fy),Uy(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let m=t.closestScrollElement.getBoundingClientRect(),y=window.getComputedStyle(t.closestScrollElement),v=As(y.borderTopWidth),p=As(y.borderBottomWidth),g=m.top+v-d.top,h=d.top+d.height+-(m.top+m.height-p);n.style.clipPath=`inset(${g}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var uk=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){z.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Q_(e){return e.offsetParent!==null}function ck(e){if(!Q_(e))return!1;let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}function Hf(e,t,n=100){let r=ck(e);t({isVisible:r});let o=setInterval(()=>{let i=ck(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Me=x(T());var dk=uk("showTabHint",!0),Is=class Is{constructor({deepdeskUrl:t,version:n=Is.version||"unknown",locale:r="en-US",token:o,fetch:i,productName:s,createCustomChannel:a}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=t.replace(/\/api$/,"");this.deepdeskApi=new yr(l,{token:o,fetch:i}),this.version=n,this.instanceId=Is.count++;let u={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[YC({broadcast:(c,f,d)=>{this.broadcastEvents.send(c,f,d)},emit:(c,f)=>this.emit(c,f),handleAfterSendMessage:c=>this.handleAfterSendMessage(c),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:c=>this.logSendMessage(c),onUpdateShowTabHint:c=>dk.update(c),sendEvent:(c,f)=>this.deepdeskApi.sendEvent(c,f)})]};this.store=GC(u),this.broadcastEvents=new _C({debug:!0,deepdeskUrl:l,eventMap:ib(this.store),createCustomChannel:a}),this.store.dispatch(Tl(dk.value())),this.store.dispatch(rd({locale:r,adminUrl:l,productName:s}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(z.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(z.warn("Profile has not been loaded (yet)"),!0):(z.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(rs(null)),this.store.dispatch(er()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();ct(r)&&h1(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return R(this,null,function*(){return(yield this.store.dispatch(er())).payload})}isConversationSupported(t,n){return R(this,null,function*(){return(yield this.store.dispatch(nh({sessionId:t,options:n}))).payload})}createConversation(t){return R(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(id(t))).payload})}getConversationBySessionId(t,n){return R(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(sd({sessionId:t,options:n}))).payload})}upsertConversation(t){return R(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(rh(t))).payload})}postMessages(t){return R(this,null,function*(){return(yield this.store.dispatch(ld(t))).payload})}updateConversation(t){return R(this,null,function*(){return(yield this.store.dispatch(ad(t))).payload})}resetConversation(){this.store.dispatch(Ae()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(rd(t))}setVisitorInfo(t){this.store.dispatch(Y1(t))}setCustomData(t){this.store.dispatch(Q1(t))}setAgentInfo(t,n){return R(this,null,function*(){yield this.store.dispatch(qa(k(k({},t),n)))})}setAgentSettings(t){return R(this,null,function*(){yield this.store.dispatch(ih(t))})}getAgentSettings(){return R(this,null,function*(){return(yield this.store.dispatch(sh())).payload})}refresh(){return R(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(fd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(Qd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(un(t))}evaluateRule(o){return R(this,arguments,function*(t,n={},r=OT){return(yield this.store.dispatch(Go({label:t,params:n,options:r}))).payload.cues})}evaluateAssistant(t,n){return R(this,null,function*(){let c=n||{},{input:r={},transcript:o,showCuesInWidget:i=!0,includeTags:s,expectFormat:a}=c,l=ee(c,["input","transcript","showCuesInWidget","includeTags","expectFormat"]);Object.assign(r,l);let u=yield this.store.dispatch(rr({assistantCode:t,expectFormat:a||"json-schema:cues",transcript:o,includeTags:s,input:r,skipState:!i}));if(u.error)throw new Error(u.error.message);return u.payload})}evaluateConversationAssistant(t,n){return R(this,null,function*(){yield this.loadProfileConfig();let r={accepted:"conversationAcceptedAssistant","new-message":"conversationNewMessageAssistant",ended:"conversationEndedAssistant"},o=this.state.profile.data[r[t]];if(!o){z.warn(`No assistant set in profile for conversation event "${t}"`);return}yield this.evaluateAssistant(o,k({transcript:"stored-transcript",includeTags:!0},n))})}getSummary(){return R(this,null,function*(){var n;if(!this.hasConversation())return z.warn("No conversation to create summary for."),null;(n=this.state.profile.data)!=null&&n.summarizerAssistantNew||z.warn("No profile loaded yet, or no summarizer assistant set in profile");let t=yield this.store.dispatch(On({}));if(t.error)throw new Error(t.error.message);return t.payload})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:l}=this.state.settings,u=a?"below":"above",c=o.length>0;if(!_n(this.state)||(this.store.dispatch(H1(oh(t))),t.key!=="Tab"&&!l))return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(j1()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(B1()),t.preventDefault()))};switch(t.key){case"ArrowUp":u==="below"?d():f();break;case"ArrowDown":{u==="below"?f():d();break}case"Escape":{n||(this.store.dispatch(dd(-1)),this.store.dispatch(Zr({collapse:!0})),this.store.dispatch(WE(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let m=ss(this.state);if(!m)return;this.store.dispatch(Tl(!1)),this.store.dispatch(un({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.state.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let m=ss(this.state);if(!m)return;this.store.dispatch(un({text:m.text,suggestion:m,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.state.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let m=ss(this.state);if(!m)return;this.store.dispatch(un({text:m.text,suggestion:m,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(Zr({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch($r([]))}handlingTimeStart(){this.state.handlingTime.startTime||(z.info("Start handling time"),this.store.dispatch(UC()))}handlingTimeStop(){this.state.handlingTime.startTime&&(z.info("Stop handling time"),this.store.dispatch(Nf()))}logSendMessage(t){let n=XC("input",this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let t=QC(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(zC()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Po((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(W1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){z.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),z.error(i)}})}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}setPlatformVariables(t){this.store.dispatch(X1(t))}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=Ul(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,nn.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i?i.ownerDocument.defaultView:null;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=Ul(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,nn.unmountComponentAtNode)(o),u()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return Wo(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,nn.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),z.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(z.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(V1(r.metrics))):z.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Mf(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:f,detectSubmit:d,insertLink:m,inputMediator:y,closestScrollSelector:v,appendOverlayTo:p,inlineSuggestions:g,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:m,isEmbedded:f,inlineSuggestions:g,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),Wo(t),this.inputMediator=y||(qo(t)?new Jo(t):new Zo(t)),this.inputMediator.on("change",({plainText:C,rawHTML:E})=>{this.store.dispatch(fd({text:C,html:E}))}),this.inputMediator.on("keyup",C=>{this.store.dispatch(U1(oh(C)))}),this.inputMediator.on("keydown",C=>{this.handleKeyDown(C)}),this.inputMediator.on("paste",({pastedText:C,selectionText:E})=>{this.store.dispatch(z1({text:C,selectionText:E}))}),this.inputMediator.on("cut",({selectionText:C})=>{this.store.dispatch(F1(C))});let S;this.inputMediator.on("selection",C=>{clearTimeout(S),C===null?S=setTimeout(()=>{C!==null&&this.store.dispatch(pd(C))},500):this.store.dispatch(pd(C))}),this.inputMediator.on("disabled",()=>{var C;(C=this.inputMediator)==null||C.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(Jd(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Jd(!0))});let w=v&&ZC(t,v)||void 0;if(g){let{customStyles:C,appendOverlayTo:E}=n,P=this.createInlineContainer(t,"deepdesk-caret");(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:C,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(ZE,{})})}),P),this.inputMediator.on("caretposition",_=>{_?(P.style.display="block",P.style.top=`${_.top}px`,P.style.left=`${_.left}px`):P.style.display="none"});let N=this.overlayContainerFactory("floating-menu",w||t,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:E},C==null?void 0:C.floatingMenuRootNode);(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:C,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(jE,{onLogIn:()=>this.loginViaPopup().catch(_=>z.warn(_.message))})})}),N)}else{let C=this.overlayContainerFactory("deepdesk-tab-completion",w||t,{appendTo:p,closestScrollElement:w,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),E=this.overlayContainerFactory("deepdesk-suggestions-overlay",w||t,{appendTo:p},r==null?void 0:r.suggestionsRootNode);(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:r,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(PT,{inputElement:t})})}),C),(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:r,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(aT,{onLogIn:()=>this.loginViaPopup().catch(P=>z.warn(P.message))})})}),E)}(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:r,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(DE,{})})}),this.createContainer("deepdesk-overlays")),this.store.dispatch(fd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(pd(this.inputMediator.getSelection())),this.store.dispatch(Jd(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var C;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((C=this.state.conversation.current)==null?void 0:C.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&z.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:r,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(PC,{onLogIn:()=>this.loginViaPopup().catch(s=>z.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,nn.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Hf(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){JC(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>R(this,null,function*(){yield this.store.dispatch(al());let t=Oo(this.state);t&&(yield this.store.dispatch(nl()),this.store.dispatch(rd({showSearch:t.search,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:!!t.summarizerAssistantNew||t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistantNew||!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))})),this.loadProfileConfigPromise)}loginViaPopup(t){return R(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.state.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,u=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",f),clearInterval(d)};i.onmessage=m=>R(this,null,function*(){var y,v;if((y=m.data)!=null&&y.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((v=m.data)==null?void 0:v.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Ya),l=!0,o.port1.close(),n()}catch(p){console.error(p),r(p)}finally{l=!0,u()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let f=m=>R(this,null,function*(){var y;if(m.origin===a.origin)switch((y=m.data)==null?void 0:y.type){case"deepdesk-popup-loaded":{try{let v=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(v,a.origin,[o.port2])}catch(v){z.error("Error posting message to popup",v),r(v)}break}case"deepdesk-popup-error":{u(),m.data.message==="Timeout"&&z.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(m.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{c&&!c.closed||(u(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(u)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return R(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(z.info("Trial is active"),!(yield this.deepdeskApi.checkUserExists(t)))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;z.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return R(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=ll(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(mn()):au.includes(r)||this.store.dispatch(gn(r))})}catch(r){this.handleError(r)}})}};Is.version="14.3.1-beta.4",Is.count=0;var zl=Is;function X_(e){return R(this,null,function*(){var o,i,s;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(s=(i=e.mimeType)!=null?i:n.headers.get("Content-Type"))!=null?s:"image/jpeg"})})}function fk(e,t){return R(this,null,function*(){let n=yield X_(t),r=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(e,"files",{configurable:!0,get:()=>[n]}),e.dispatchEvent(r)}finally{Object.hasOwn(e,"files")&&delete e.files}})}function pk(e,t,n){return R(this,null,function*(){yield new yr(e).authenticateWithKey(t,n)})}function mk(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function gk(r,o){return R(this,arguments,function*(e,t,n={}){var f,d;let{value:i}=e,{start:s,end:a}=(f=n.replace)!=null?f:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,u=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(c()).then(()=>{e.selectionStart=u.start,e.selectionEnd=u.end,e.blur(),e.focus()})})}function hk(r,o){return R(this,arguments,function*(e,t,n={}){let i=n.replace?to(e,n.replace.start,n.replace.end):Rs(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
|
|
27
|
+
`);let y=d?r:0,v=m?Math.min(i,c.childNodes.length):c.childNodes.length;for(let p=y;p<v&&(u(c.childNodes[p]),a!==2);p++);break}default:break}m&&(a=2)}return u(e),l}var AC=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(AC||{}),hr=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.cachedCaretPosition===null;if(!this.isActive||(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText?(this.cachedText=t,this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,o=!0,this.emit("selection",r)),!o))return;let i=this.getCaretPosition();Kr(i,this.cachedCaretPosition)||(this.cachedCaretPosition=i,this.emit("caretposition",i))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(AC).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function IC(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Zo=class extends hr{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Hl(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var s;let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o="getComposedRanges"in r&&n instanceof ShadowRoot?(s=r.getComposedRanges(n))==null?void 0:s[0]:r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let i=this.element.ownerDocument.createRange();return i.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),i.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!i||!this.element.contains(i.startContainer)||!this.element.contains(i.endContainer)?null:i}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!IC(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!IC(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Fl(this.element,n);let r=this.lastKnownSelection;if(r&&LC(this.element,r.start,r.end))return r;let o=Rs(this.element);return o.collapse(!1),Fl(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Hl(this.element,to(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(i=>{var s,a;i.length===2&&i[0].addedNodes.length===1&&((s=i[0].addedNodes[0])==null?void 0:s.textContent)==="\u2060"&&((a=i[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var D_=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function OC(e,t){let n="mozInnerScreenX"in window,r=document.createElement("div");r.id="input-textarea-caret-position-mirror-div";let o=r.style,i=window.getComputedStyle(e),s=e.ownerDocument.body;o.whiteSpace="pre-wrap",o.wordWrap="break-word",o.position="absolute",o.visibility="hidden",D_.forEach(function(c){o[c]=i[c]}),n?e.scrollHeight>parseInt(i.height)&&(o.overflowY="scroll"):o.overflow="hidden",r.textContent=e.value.substring(0,t);let a=document.createElement("span");a.textContent=e.value.substring(t)||".",r.appendChild(a),s.appendChild(r);let l=e.getBoundingClientRect(),u={top:l.top-e.scrollTop+a.offsetTop+parseInt(i.borderTopWidth)+a.offsetHeight,left:l.left-e.scrollLeft+a.offsetLeft+parseInt(i.borderLeftWidth)};return s.removeChild(r),u}var Jo=class extends hr{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return OC(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function NC(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let i=document.createElement("iframe"),s=new URL(t);return Object.entries(n).forEach(([a,l])=>{s.searchParams.append(a,l)}),i.style.position="absolute",i.style.left="-999em",i.style.width="0px",i.style.height="0px",i.tabIndex=-1,i.id=r,i.title=`iframe-${e}`,i.src=s.toString(),window.document.body.appendChild(i),i}function F_(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var Py=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},Ly=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=NC(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},Ay=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),z.info("Set sessionId",t),this.sessionId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new Ly(t,this.deepdeskUrl,{debug:!0}):new Py(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=F_(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(z.info("Received broadcast event",this.sessionId,o),(a=(s=this.eventMap)[i.name])==null||a.call(s,i.payload))};return n.onMessage(r),n}send(t,n,r){var s,a;z.info("Broadcast event",{sessionId:this.sessionId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(s=this.eventMap)[t])==null||a.call(s,n));let i=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;i==null||i.postMessage(I(k({},o),{channel:this.sessionId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),delete this.channel,t&&((r=this.defaultChannel)==null||r.close(),delete this.defaultChannel)}},_C=Ay;function H_(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function he(e){return Array.isArray(e)?e.map(he):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(k({},t),{[H_(n)]:he(e[n])}),{}):e}function U_(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function qe(e){return Array.isArray(e)?e.map(qe):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(k({},t),{[U_(n)]:qe(e[n])}),{}):e}var Ps=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Iy=e=>new Promise(t=>{setTimeout(t,e)});var Ls=class extends Ps{constructor(){super(...arguments);this.name="ClientError"}},Ny=class extends Ps{constructor(){super(...arguments);this.name="ServerError"}},Oy=new Map;function z_(e){return R(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(z.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var no=class no{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",E=n,{useCache:u=!1,abortLatest:c=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:m=!0,retryOnError:y=P=>P instanceof TypeError,retryOnResponse:v=P=>P.status>=500,version:p=null}=E,g=ee(E,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u)if(l){if(Oy.has(s)){r(Oy.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h=I(k({credentials:"include"},g),{headers:k({Accept:"application/json","Content-Type":"application/json"},g.headers)});!l&&this.csrfToken&&(h.headers=I(k({},h.headers),{"X-CSRFToken":this.csrfToken})),typeof p=="string"&&(h.headers=I(k({},h.headers),{"X-Deepdesk-API-Version":p}));let S=f,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let C=()=>R(this,null,function*(){return S--,a(s,h).then(P=>R(this,null,function*(){return v(P)&&!i.isAborted&&S>0?(yield Iy(d),C()):P.status===401&&m===!0&&w===!1?(w=!0,yield this.refreshToken(),C()):P})).catch(P=>R(this,null,function*(){if(y(P)&&!i.isAborted&&S>0)return yield Iy(d),C();throw P}))});C().then(P=>R(this,null,function*(){let N=yield z_(P);if(delete this.latestRequestByUrl[s],P.status>=500){o(new Ny("Server Error",N));return}else if(P.status===401){o(new Ls("Unauthorized",N));return}else if(P.status===403){o(new Ls("Forbidden",N));return}else if(P.status===404){o(new Ls("Not Found",N));return}else if(P.status>=400){o(new Ls("Bad Request",N));return}u&&Oy.set(s,N),r(N)})).catch(P=>{o(P)})})}validateToken(){return R(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)try{yield this.refreshToken()}catch(r){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/");return!!n})}refreshToken(){return no.refreshingToken||(no.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{no.refreshingToken=null},1e3*60)})),no.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,k({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,k({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,k({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,k({method:"DELETE"},n))}};no.refreshingToken=null;var ei=no;var MC;(t=>{let e;(s=>(s.SEND_MESSAGE="Send Message",s.HANDLING_TIME="Handling Time",s.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",s.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(e=t.EventType||(t.EventType={}))})(MC||(MC={}));function Of(e){return I(k({},he(e)),{tags:e.tags})}var ti=class ti{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new ei(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>R(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return R(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(ti.exchangeTokenPromise||(ti.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),ti.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return R(this,null,function*(){yield this.preflight(),z.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",I(k({},qe(t)),{tags:t.tags}),{version:"v2"});return Of(n)})}getMe(){return R(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return he(t)})}postIdentity(t){return R(this,null,function*(){yield this.client.post("/apis/admin/session/me/identities/",qe(t))})}patchMe(t){return R(this,null,function*(){let n=yield this.client.patch("/apis/admin/session/me/",qe(t));return he(n)})}getProfile(t){return R(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return he(n)})}getKnowledgeAssistant(t){return R(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return he(n)})}getContentTypes(){return R(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return he(t)})}getAccount(){return R(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return he(t)})}getPlatformConfig(t){return R(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return he(r)})}checkUserExists(t){return R(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationBySessionId(r){return R(this,arguments,function*(t,n={}){yield this.preflight(),z.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:i=1e3}=n,s=yield this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return z.info(`Successfully retrieved conversation ${s.id} for session ${t}`),Of(s)})}isConversationSupported(r){return R(this,arguments,function*(t,n={}){z.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:i=1e3}=n;return(yield this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"})).has_active_profile})}updateConversation(t,n){return R(this,null,function*(){let r=qe(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Of(o)})}postMessages(t,n){return R(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>I(k({},qe(o)),{tags:o.tags})),{version:"v2"})).map(o=>Of(o))})}sendEvent(t,n){return R(this,null,function*(){let s=n,{data:r}=s,o=ee(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>I(k({},a),{[l]:u}),{});return this.client.post("/api/events",qe(I(k(k({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return R(this,null,function*(){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>I(k({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:qe(k(k({},n),r))},{version:"v1"})})}getEntities(t){return R(this,null,function*(){return(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)},{version:"v1"})).entities})}getTemporaryExchangeToken(){return R(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(t){return R(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw z.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return R(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",qe(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return R(this,arguments,function*(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,qe(n),{abortLatest:!0,version:"v1"})).map(s=>I(k({},he(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(u=>u.text===s.text))})}isLoggedIn(){return R(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return R(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/autocomplete`,qe(n),{abortLatest:!0,version:"v1"})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return R(this,null,function*(){let n=yield this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0,version:"v1"});return he(n).map(r=>I(k({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return R(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",qe(t),{abortLatest:!0,version:"v1"});return he(n)})}search(t){return R(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,qe(t),{version:"v2"});return he(n)})}knowledgeAssist(i,s,a){return R(this,arguments,function*(t,n,r,o={}){let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,qe({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(u=>({question:u.question,answer:u.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return he(l)})}requestLoginByEmail(t){return R(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return he(n)})}requestPasswordlessToken(){return R(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return he(t.token)})}getCsrfToken(){return R(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return R(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return he(n)})}evaluateRule(i,s,a){return R(this,arguments,function*(t,n,r,o={}){let l=new URLSearchParams;o.raiseForFailingConditions&&l.set("raise_for_failing_conditions","true");let u=yield this.client.post(`/api/conversations/${n}/rules/${t}/evaluate?${l.toString()}`,r,{version:"v2"});return u?he(u.cues):[]})}getSummary(r){return R(this,arguments,function*(t,n={}){let o=yield this.client.post("/api/summary",{conversation:{messages:t.filter(i=>i.text&&i.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model},{version:"v1"});return he(o)})}evaluateAssistant(t,n){return R(this,null,function*(){var a;let r=new URLSearchParams,{expectFormat:o="text"}=n||{};if(o.startsWith("json-schema:")){let l=o.replace("json-schema:","");r.append("expect_response_format","json-schema"),r.append("expect_response_format_schema",l)}else r.append("expect_response_format",o);n!=null&&n.externalConversationId&&r.append("external_conversation_id",n.externalConversationId);let i=n!=null&&n.threadId?`/api/v2/assistants/${t}/threads/${n==null?void 0:n.threadId}/evaluate?${r.toString()}`:`/api/v2/assistants/${t}/evaluate?${r.toString()}`,s=yield this.client.post(i,{input:(a=n==null?void 0:n.input)!=null?a:{},conversation:n==null?void 0:n.transcript});return he(s.output)})}createAssistantThread(t){return R(this,null,function*(){let{assistantCode:n}=t,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return he(r)})}postMessageToAssistantThread(t){return R(this,null,function*(){let{assistantCode:n,threadId:r,message:o}=t,i=yield this.client.post(`/apis/admin/assistants/${n}/threads/${r}/messages/`,{content:o,role:"user"});return he(i)})}getRules(){return R(this,null,function*(){let t=new URLSearchParams,n=yield this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{useCache:!0});return he(n)})}translateMessages(t){return R(this,null,function*(){let n=yield this.client.post("/api/translate",qe(t),{version:"v2"});return he(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(e0);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&z.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};ti.exchangeTokenPromise=null;var yr=ti;var DC={startTime:null,stopTime:null},FC=e=>e.handlingTime,HC=ne({name:"handlingTime",initialState:DC,reducers:{handlingTimeStart(e){if(e.startTime&&!e.stopTime)throw new Error("Timing already started");e.startTime=new Date,e.stopTime=null},handlingTimeStop(e){if(!e.startTime)throw new Error("Timing not started");e.stopTime=new Date},handlingTimeReset(e){e.startTime=null,e.stopTime=null}},extraReducers:e=>{e.addCase(Ae,()=>DC)}}),{handlingTimeStart:UC,handlingTimeStop:Nf,handlingTimeReset:zC}=HC.actions,jC=HC.reducer;var BC=(e={})=>{let t=k({onAuthError:rs(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var _f={list:{keywordMatches:[]},fetchState:"idle"};var ni=X("styleSuggestions/getAll",(n,r)=>R(void 0,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(l=i.conversation.current)==null?void 0:l.profileCode;if(!s)return _f.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),j_=ne({name:"styleSuggestions",initialState:_f,reducers:{},extraReducers:e=>{e.addCase(ni.pending,t=>{t.fetchState="loading"}).addCase(ni.rejected,t=>{t.fetchState="error"}).addCase(ni.fulfilled,(t,n)=>{t.fetchState="done",Kr(t.list,n.payload)||(t.list=n.payload)}).addCase(Po,t=>{t.list=_f.list}).addCase(Ae,()=>_f)}}),VC=j_.reducer;var WC=(e={})=>{let t,n=!0,r=k({getStyleSuggestions:ni,debounce:500},e);return o=>i=>s=>{var m;let a=o.getState().input.text,l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:c}=u.settings;if(!((m=u.conversation.current)==null?void 0:m.id)||!c)return l;let{text:d}=u.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function B_(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var KC=(e={})=>{let t=k({getTextSuggestions:gn,getAutocompleteSuggestions:bl,debounce:200,check:_n},e),n;return r=>o=>i=>{var v;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,f=(v=l.conversation.current)==null?void 0:v.id,d=i.type===Qd.toString();if(!f||!u&&!c)return a;let{input:m}=l;return B_(m,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let p=is(l);p===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(p))},d?0:t.debounce)),a}};var $C=ni.fulfilled.toString();function V_(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let i=e.keywordMatches.filter(l=>l.keyword===o),s=t.keywordMatches.filter(l=>l.keyword===o),a=s.length-i.length;a<=0||r.push(...s.slice(0,a))}),r}var qC=e=>t=>n=>r=>{var u;if(r.type!==$C){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(u=i.conversation)==null?void 0:u.current;if(o===s)return;let l=V_(o,s);r.type===$C&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var W_=Rc({assistants:_b,auth:b1,conversation:N1,contentTypes:Db,passwordlessToken:IT,entities:uE,knowledgeAssistant:Lb,handlingTime:jC,info:Z1,input:K1,settings:g1,profile:Hb,search:ob,styleSuggestions:VC,ui:$E,rules:DT,textSuggestions:AE});function GC(e){return ww({reducer:W_,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}),BC(),KC({debounce:200}),WC({debounce:500}),qC(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var K_=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},$_=e=>t=>n=>r=>{var a,l,u,c,f,d,m;let o=t.getState(),i=Jg("inlineSuggestions")(o);switch(r.type){case rs.toString():{!r.payload&&e.emit("logout",void 0);break}case mn.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(a=o.conversation.current)==null?void 0:a.id,data:{entities:r.payload}});break;case Gt.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((u=o.conversation.current)==null?void 0:u.id),data:r.payload.data});break;case Po.toString():e.logSendMessage(r.payload);break;case Go.fulfilled.toString():r.isBroadcasted||e.broadcast(lh,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;case Nd.toString():e.emit("call-to-action",{cue:r.payload});break;case rr.fulfilled.toString():r.isBroadcasted||e.broadcast(uh,r,!1);break;default:break}let s=n(r);switch(r.type){case Po.toString():e.handleAfterSendMessage(r.payload);break;case Tl.toString():e.onUpdateShowTabHint(r.payload);break;case Nf.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case ud.toString():{let{start:y,end:v}=o.input.selection;e.emit("replace",I(k({},r.payload),{replace:r.payload.replace==="selection"?{start:y,end:v}:{start:0,end:v}}));break}case un.toString():{let{start:y,end:v}=o.input.selection;e.emit("select-suggestion",I(k({type:K_(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:y,end:v}:{start:0,end:v}})),i&&t.dispatch($r([]));break}case cd.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case $r.toString():{i&&r.payload.length>0&&t.dispatch(dd(0));break}case On.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload,assistant:(m=t.getState().profile.data)==null?void 0:m.summarizerAssistantNew}});break}default:break}return s},YC=$_;function _y(e){return e.toISOString().replace("T"," ").replace("Z","")}var q_=(e,t)=>t.version,QC=ln([as,An,FC,q_],(e,t,n,r)=>{if(!t)return z.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:i}=n;return!o||!i?(z.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:t,clientVersion:r,agentId:e==null?void 0:e.agentId,agentName:e==null?void 0:e.agentName,agentEmail:e==null?void 0:e.agentEmail,timeStart:_y(o),timeStop:_y(i)}});function XC(e,t,n){var N,_,q,B;let r=(N=t.conversation.current)==null?void 0:N.id;if(!r)return z.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:u,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:f,pastes:d,cuts:m,deletions:y,textSuggestions:v,offeredTextSuggestions:p}}=t[e],g=o.length,S=v.reduce((V,{text:fe,searchTerm:Ge})=>V+fe.length-(Ge?Ge.length:0),0),w=c!=null?c:Date.now(),C=(Date.now()-w)/1e3+(f||0),E=i/C,P=v.reduce((V,{searchTerm:fe})=>V+(fe?fe.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:m,deletions:y,lenTextTyped:i+P,lenTextTotal:g,lenTextAssisted:S,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:C,charsPerSecond:E,numPastes:u,textSuggestionsV2:v,suggestionsCounters:[{source:"gpt",countOffered:p.filter(V=>V.source==="gpt").length}],agentId:(_=t.info.agentInfo)==null?void 0:_.agentId,agentName:(q=t.info.agentInfo)==null?void 0:q.agentName,agentEmail:(B=t.info.agentInfo)==null?void 0:B.agentEmail}}function My(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return My(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?My(o,t):null}function ZC(e,t){return My(e,t)}function JC(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function G_(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Mf(e){return G_(e)&&(qo(e)||sf(e))}var tk,Hn=new Map,Y_=["bottom","height","left","right","top","width"],ek=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:Y_.some(n=>e[n]!==t[n]);function nk(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...nk(t)]:[]}function rk(e,t){return!e||!t?null:I(k({},e),{top:e.top+t.top,left:e.left+t.left})}var Df=!1,ok=()=>{Df=!0;let e=[];if(Hn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Hn.delete(n);return}let r=n.getBoundingClientRect();ek(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(rk,t.rect):t.rect;ek(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Hn.size===0){Df=!1;return}tk=window.requestAnimationFrame(ok)};function Dy(e,t){let n=nk(e),r=[],o=n.map((i,s)=>Dy(i,a=>{r[s]=a;let l=Hn.get(e);if(!l)return;let u=r.reduce(rk,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Hn.has(e)){let s=Hn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Hn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Df&&ok()},unobserve(){o.forEach(s=>s.unobserve());let i=Hn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Hn.delete(e),Hn.size||(cancelAnimationFrame(tk),Df=!1)}}}}var ik,Un=new Map,sk=()=>{Un.forEach((e,t)=>{if(!t.isConnected){Un.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(i=>i(e.visible)))}),Un.size!==0&&(ik=window.requestAnimationFrame(sk))};function ak(e,t){return{observe(){let n=Un.size===0;Un.has(e)?Un.get(e).callbacks.push(t):Un.set(e,{visible:void 0,callbacks:[t]}),n&&sk()},unobserve(){let n=Un.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Un.delete(e),Un.size||cancelAnimationFrame(ik)}}}}var Fy=["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","borderStyle","boxSizing","color","overflowWrap","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontWeight","fontKerning","lineHeight","letterSpacing","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","textIndent","whiteSpace","wordBreak","wordSpacing","wordWrap"];function Hy(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function As(e){return parseFloat(e)}function Ff(e){return Math.round(e*1e6)}function lk(e){return e/1e6}function Uy(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=As(e.width),i=As(e.borderLeftWidth),s=As(e.borderRightWidth),a=As(e.paddingRight),l=lk(Ff(o)-Ff(i)-Ff(s)),u=lk(Ff(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function Ul(e,t={}){var c,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=t.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",Wo(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};Hy(r,n,Fy),Uy(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=ak(e,()=>{Hy(r,n,Fy),Uy(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Dy(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(Hy(r,n,Fy),Uy(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let m=t.closestScrollElement.getBoundingClientRect(),y=window.getComputedStyle(t.closestScrollElement),v=As(y.borderTopWidth),p=As(y.borderBottomWidth),g=m.top+v-d.top,h=d.top+d.height+-(m.top+m.height-p);n.style.clipPath=`inset(${g}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var uk=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){z.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Q_(e){return e.offsetParent!==null}function ck(e){if(!Q_(e))return!1;let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}function Hf(e,t,n=100){let r=ck(e);t({isVisible:r});let o=setInterval(()=>{let i=ck(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Me=x(T());var dk=uk("showTabHint",!0),Is=class Is{constructor({deepdeskUrl:t,version:n=Is.version||"unknown",locale:r="en-US",token:o,fetch:i,productName:s,createCustomChannel:a}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=t.replace(/\/api$/,"");this.deepdeskApi=new yr(l,{token:o,fetch:i}),this.version=n,this.instanceId=Is.count++;let u={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[YC({broadcast:(c,f,d)=>{this.broadcastEvents.send(c,f,d)},emit:(c,f)=>this.emit(c,f),handleAfterSendMessage:c=>this.handleAfterSendMessage(c),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:c=>this.logSendMessage(c),onUpdateShowTabHint:c=>dk.update(c),sendEvent:(c,f)=>this.deepdeskApi.sendEvent(c,f)})]};this.store=GC(u),this.broadcastEvents=new _C({debug:!0,deepdeskUrl:l,eventMap:ib(this.store),createCustomChannel:a}),this.store.dispatch(Tl(dk.value())),this.store.dispatch(rd({locale:r,adminUrl:l,productName:s}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(z.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(z.warn("Profile has not been loaded (yet)"),!0):(z.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(rs(null)),this.store.dispatch(er()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();ct(r)&&h1(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return R(this,null,function*(){return(yield this.store.dispatch(er())).payload})}isConversationSupported(t,n){return R(this,null,function*(){return(yield this.store.dispatch(nh({sessionId:t,options:n}))).payload})}createConversation(t){return R(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(id(t))).payload})}getConversationBySessionId(t,n){return R(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(sd({sessionId:t,options:n}))).payload})}upsertConversation(t){return R(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(rh(t))).payload})}postMessages(t){return R(this,null,function*(){return(yield this.store.dispatch(ld(t))).payload})}updateConversation(t){return R(this,null,function*(){return(yield this.store.dispatch(ad(t))).payload})}resetConversation(){this.store.dispatch(Ae()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(rd(t))}setVisitorInfo(t){this.store.dispatch(Y1(t))}setCustomData(t){this.store.dispatch(Q1(t))}setAgentInfo(t,n){return R(this,null,function*(){yield this.store.dispatch(qa(k(k({},t),n)))})}setAgentSettings(t){return R(this,null,function*(){yield this.store.dispatch(ih(t))})}getAgentSettings(){return R(this,null,function*(){return(yield this.store.dispatch(sh())).payload})}refresh(){return R(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(fd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(Qd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(un(t))}evaluateRule(o){return R(this,arguments,function*(t,n={},r=OT){return(yield this.store.dispatch(Go({label:t,params:n,options:r}))).payload.cues})}evaluateAssistant(t,n){return R(this,null,function*(){let c=n||{},{input:r={},transcript:o,showCuesInWidget:i=!0,includeTags:s,expectFormat:a}=c,l=ee(c,["input","transcript","showCuesInWidget","includeTags","expectFormat"]);Object.assign(r,l);let u=yield this.store.dispatch(rr({assistantCode:t,expectFormat:a||"json-schema:cues",transcript:o,includeTags:s,input:r,skipState:!i}));if(u.error)throw new Error(u.error.message);return u.payload})}evaluateConversationAssistant(t,n){return R(this,null,function*(){yield this.loadProfileConfig();let r={accepted:"conversationAcceptedAssistant","new-message":"conversationNewMessageAssistant",ended:"conversationEndedAssistant"},o=this.state.profile.data[r[t]];if(!o){z.warn(`No assistant set in profile for conversation event "${t}"`);return}yield this.evaluateAssistant(o,k({transcript:"stored-transcript",includeTags:!0},n))})}getSummary(){return R(this,null,function*(){var n;if(!this.hasConversation())return z.warn("No conversation to create summary for."),null;(n=this.state.profile.data)!=null&&n.summarizerAssistantNew||z.warn("No profile loaded yet, or no summarizer assistant set in profile");let t=yield this.store.dispatch(On({}));if(t.error)throw new Error(t.error.message);return t.payload})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:l}=this.state.settings,u=a?"below":"above",c=o.length>0;if(!_n(this.state)||(this.store.dispatch(H1(oh(t))),t.key!=="Tab"&&!l))return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(j1()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(B1()),t.preventDefault()))};switch(t.key){case"ArrowUp":u==="below"?d():f();break;case"ArrowDown":{u==="below"?f():d();break}case"Escape":{n||(this.store.dispatch(dd(-1)),this.store.dispatch(Zr({collapse:!0})),this.store.dispatch(WE(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let m=ss(this.state);if(!m)return;this.store.dispatch(Tl(!1)),this.store.dispatch(un({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.state.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let m=ss(this.state);if(!m)return;this.store.dispatch(un({text:m.text,suggestion:m,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.state.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let m=ss(this.state);if(!m)return;this.store.dispatch(un({text:m.text,suggestion:m,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(Zr({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch($r([]))}handlingTimeStart(){this.state.handlingTime.startTime||(z.info("Start handling time"),this.store.dispatch(UC()))}handlingTimeStop(){this.state.handlingTime.startTime&&(z.info("Stop handling time"),this.store.dispatch(Nf()))}logSendMessage(t){let n=XC("input",this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let t=QC(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(zC()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Po((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(W1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){z.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),z.error(i)}})}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}setPlatformVariables(t){this.store.dispatch(X1(t))}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=Ul(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,nn.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i?i.ownerDocument.defaultView:null;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=Ul(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,nn.unmountComponentAtNode)(o),u()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return Wo(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,nn.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),z.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(z.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(V1(r.metrics))):z.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Mf(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:f,detectSubmit:d,insertLink:m,inputMediator:y,closestScrollSelector:v,appendOverlayTo:p,inlineSuggestions:g,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:m,isEmbedded:f,inlineSuggestions:g,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),Wo(t),this.inputMediator=y||(qo(t)?new Jo(t):new Zo(t)),this.inputMediator.on("change",({plainText:C,rawHTML:E})=>{this.store.dispatch(fd({text:C,html:E}))}),this.inputMediator.on("keyup",C=>{this.store.dispatch(U1(oh(C)))}),this.inputMediator.on("keydown",C=>{this.handleKeyDown(C)}),this.inputMediator.on("paste",({pastedText:C,selectionText:E})=>{this.store.dispatch(z1({text:C,selectionText:E}))}),this.inputMediator.on("cut",({selectionText:C})=>{this.store.dispatch(F1(C))});let S;this.inputMediator.on("selection",C=>{clearTimeout(S),C===null?S=setTimeout(()=>{C!==null&&this.store.dispatch(pd(C))},500):this.store.dispatch(pd(C))}),this.inputMediator.on("disabled",()=>{var C;(C=this.inputMediator)==null||C.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(Jd(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Jd(!0))});let w=v&&ZC(t,v)||void 0;if(g){let{customStyles:C,appendOverlayTo:E}=n,P=this.createInlineContainer(t,"deepdesk-caret");(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:C,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(ZE,{})})}),P),this.inputMediator.on("caretposition",_=>{_?(P.style.display="block",P.style.top=`${_.top}px`,P.style.left=`${_.left}px`):P.style.display="none"});let N=this.overlayContainerFactory("floating-menu",w||t,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:E},C==null?void 0:C.floatingMenuRootNode);(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:C,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(jE,{onLogIn:()=>this.loginViaPopup().catch(_=>z.warn(_.message))})})}),N)}else{let C=this.overlayContainerFactory("deepdesk-tab-completion",w||t,{appendTo:p,closestScrollElement:w,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),E=this.overlayContainerFactory("deepdesk-suggestions-overlay",w||t,{appendTo:p},r==null?void 0:r.suggestionsRootNode);(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:r,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(PT,{inputElement:t})})}),C),(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:r,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(aT,{onLogIn:()=>this.loginViaPopup().catch(P=>z.warn(P.message))})})}),E)}(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:r,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(DE,{})})}),this.createContainer("deepdesk-overlays")),this.store.dispatch(fd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(pd(this.inputMediator.getSelection())),this.store.dispatch(Jd(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var C;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((C=this.state.conversation.current)==null?void 0:C.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&z.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,nn.render)((0,Me.jsx)($o,{store:this.store,customStyles:r,children:(0,Me.jsx)(Ao,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(PC,{onLogIn:()=>this.loginViaPopup().catch(s=>z.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,nn.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Hf(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){JC(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>R(this,null,function*(){yield this.store.dispatch(al());let t=Oo(this.state);t&&(yield this.store.dispatch(nl()),this.store.dispatch(rd({showSearch:t.search,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:!!t.summarizerAssistantNew||t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistantNew||!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))})),this.loadProfileConfigPromise)}loginViaPopup(t){return R(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.state.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,u=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",f),clearInterval(d)};i.onmessage=m=>R(this,null,function*(){var y,v;if((y=m.data)!=null&&y.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((v=m.data)==null?void 0:v.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Ya),l=!0,o.port1.close(),n()}catch(p){console.error(p),r(p)}finally{l=!0,u()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let f=m=>R(this,null,function*(){var y;if(m.origin===a.origin)switch((y=m.data)==null?void 0:y.type){case"deepdesk-popup-loaded":{try{let v=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(v,a.origin,[o.port2])}catch(v){z.error("Error posting message to popup",v),r(v)}break}case"deepdesk-popup-error":{u(),m.data.message==="Timeout"&&z.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(m.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{c&&!c.closed||(u(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(u)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return R(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(z.info("Trial is active"),!(yield this.deepdeskApi.checkUserExists(t)))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;z.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return R(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=ll(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(mn()):au.includes(r)||this.store.dispatch(gn(r))})}catch(r){this.handleError(r)}})}};Is.version="14.3.1-beta.6",Is.count=0;var zl=Is;function X_(e){return R(this,null,function*(){var o,i,s;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(s=(i=e.mimeType)!=null?i:n.headers.get("Content-Type"))!=null?s:"image/jpeg"})})}function fk(e,t){return R(this,null,function*(){let n=yield X_(t),r=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(e,"files",{configurable:!0,get:()=>[n]}),e.dispatchEvent(r)}finally{Object.hasOwn(e,"files")&&delete e.files}})}function pk(e,t,n){return R(this,null,function*(){yield new yr(e).authenticateWithKey(t,n)})}function mk(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function gk(r,o){return R(this,arguments,function*(e,t,n={}){var f,d;let{value:i}=e,{start:s,end:a}=(f=n.replace)!=null?f:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,u=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(c()).then(()=>{e.selectionStart=u.start,e.selectionEnd=u.end,e.blur(),e.focus()})})}function hk(r,o){return R(this,arguments,function*(e,t,n={}){let i=n.replace?to(e,n.replace.start,n.replace.end):Rs(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
|
|
28
28
|
`).reverse().forEach((l,u)=>{u>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(l))}):i.insertNode(document.createTextNode(t))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let l=n.selectionAfter?to(e,n.selectionAfter.start,n.selectionAfter.end):(i.collapse(!1),i),u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(l)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}function Z_(e){let t=document.createElement("template");return t.innerHTML=e.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),t.content}function J_(e){let t=document.createDocumentFragment();return e.split(`
|
|
29
29
|
`).forEach((n,r)=>{r>0&&t.appendChild(document.createElement("br"));let o={index:0},i=0;for(;o=n.slice(i).match(/(\[([^\]]+)])\(([^)]+)\)/);){let s=document.createElement("a");s.href=o[3],s.setAttribute("target","_blank"),s.setAttribute("rel","noopener noreferrer"),s.appendChild(document.createTextNode(o[2])),t.appendChild(document.createTextNode(n.slice(i,i+o.index))),t.appendChild(s),i=i+o.index+o[0].length}t.appendChild(document.createTextNode(n.slice(i)))}),t}function yk(e,t){let n=e.parentElement;if(!n){console.warn("No insert point found");return}let{display:r}=window.getComputedStyle(n);r.includes("block")||r==="table-cell"?n==null||n.insertBefore(t,e.nextSibling):yk(n,t)}function vk(o,i){return R(this,arguments,function*(e,t,{isBlock:n,isHTML:r}={}){let s;e.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0}));let a=()=>{var d;let l=(d=e.ownerDocument.defaultView)!=null?d:window,u=l.getSelection();if((!u||u.rangeCount===0)&&(e.focus(),u=l.getSelection()),!u||u.rangeCount===0)return;let c=u.getRangeAt(0);if(!c)return;s=document.createElement("span"),c.insertNode(s);let f=r?Z_(t):J_(t);n?yk(c.startContainer,f):(c.insertNode(f),c.collapse(!1))};return Promise.resolve(a()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}return Nk(e2);})();
|
|
30
30
|
/*! Bundled license information:
|