@deepdesk/deepdesk-sdk 19.1.1-beta.2 → 19.1.1-beta.4
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 +8 -8
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.esm.js +8 -8
- package/dist/index.iife.js +22 -22
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var yi=Object.defineProperty,Np=Object.defineProperties;var Op=Object.getOwnPropertyDescriptors;var zn=Object.getOwnPropertySymbols;var vi=Object.prototype.hasOwnProperty,xi=Object.prototype.propertyIsEnumerable;var hi=(t,e,n)=>e in t?yi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))vi.call(e,n)&&hi(t,n,e[n]);if(zn)for(var n of zn(e))xi.call(e,n)&&hi(t,n,e[n]);return t},S=(t,e)=>Np(t,Op(e));var A=(t,e)=>{var n={};for(var o in t)vi.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&zn)for(var o of zn(t))e.indexOf(o)<0&&xi.call(t,o)&&(n[o]=t[o]);return n};var X=(t,e)=>{for(var n in e)yi(t,n,{get:e[n],enumerable:!0})};var v=(t,e,n)=>new Promise((o,s)=>{var r=d=>{try{a(n.next(d))}catch(l){s(l)}},i=d=>{try{a(n.throw(d))}catch(l){s(l)}},a=d=>d.done?o(d.value):Promise.resolve(d.value).then(r,i);a((n=n.apply(t,e)).next())});import bi from"classnames";import Bp,{createContext as Up,useContext as ws,useEffect as Kp,useState as zp}from"react";import Dp,{useContext as _p}from"react";import Fp from"classnames";var sn=Dp.createContext({});function x(t,e){let r=_p(sn),{debug:n}=r,s=A(r,["debug"])[t];return Object.entries(e).reduce((i,[a,d])=>{let l=s==null?void 0:s[a];return S(y({},i),{[a]:Fp(d,l,n?`${t}__${a}`:!1)})},{})}var Si={root:"dd-4s9wq"};import{jsx as Wn,jsxs as Hp}from"react/jsx-runtime";var Vn=()=>Hp("svg",{className:Si.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[Wn("defs",{children:Wn("style",{children:".cls-1 { fill: #b3b3b3; }"})}),Wn("title",{children:"Failed loading image"}),Wn("path",{className:"cls-1",d:"M15 130.896V16.994c0-1.097.898-1.994 2.007-1.994h150.986A2 2 0 0 1 170 16.994v69.147L133.015 51 87.26 120.377l-35.863-17.758L15 130.896zM2 0C.895 0 0 .887 0 2v166c0 1.105.887 2 2 2h181c1.105 0 2-.887 2-2V2c0-1.105-.887-2-2-2H2zm49 72c11.046 0 20-9.178 20-20.5S62.046 31 51 31s-20 9.178-20 20.5S39.954 72 51 72z",fillRule:"evenodd"})]});var Ts={root:"dd-c9KvZ",imageWrapper:"dd-sE7D9",image:"dd-bEGMz",content:"dd-oFIQa",title:"dd-mSgoo",contentIsCropped:"dd-Uvjv4",lineClamp:"dd-ApQo-"};import{jsx as wt}from"react/jsx-runtime";var jn=Up(Ts),Wp=({title:t,src:e})=>{let n=ws(jn),[o,s]=zp(!1);return Kp(()=>{s(!1)},[e]),wt("div",{className:n.imageWrapper,children:e&&!o?wt("img",{className:n.image,alt:t,src:e,onError:()=>s(!0)}):wt(Vn,{})})},Vp=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let s=ws(jn);return wt("div",{className:bi(s.content,t,{[s.contentIsCropped]:n,[s.lineClamp]:e}),children:o})},jp=r=>{var i=r,{as:t="h1",cropText:e=!1,className:n,children:o}=i,s=A(i,["as","cropText","className","children"]);let a=ws(jn);return Bp.createElement(t,y({className:bi(a.title,n,{[a.contentIsCropped]:e})},s),o)},$n=({children:t})=>{let e=x("Card",Ts);return wt("div",{className:e.root,children:wt(jn.Provider,{value:e,children:t})})};$n.Image=Wp;$n.Content=Vp;$n.Title=jp;var D=$n;import $p from"classnames";var Ci={root:"dd-llBx9"};import{jsx as Xp}from"react/jsx-runtime";var Gp={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},qp=o=>{var s=o,{className:t,keyCode:e}=s,n=A(s,["className","keyCode"]);let r=x("KeyboardHint",Ci);return Xp("span",y({"data-key":Gp[e],className:$p(t,r.root)},n))},Es=qp;import Jp from"classnames";var Ti={root:"dd-e6HXZ"};import{jsx as Yp}from"react/jsx-runtime";var Qp=o=>{var s=o,{className:t,children:e}=s,n=A(s,["className","children"]);let r=x("Label",Ti);return Yp("span",S(y({},n),{className:Jp(t,r.root),children:e}))},Zp=Qp;var wi={root:"dd-FiMI7",subTitleContainer:"dd-98jc7",subtitle:"dd-3MnW8",suggestions:"dd-0SGL8"};import{jsx as ks,jsxs as tu}from"react/jsx-runtime";var eu=s=>{var r=s,{title:t,children:e,type:n}=r,o=A(r,["title","children","type"]);let i=x("Section",wi);return tu("section",S(y({},o),{className:i.root,"data-section-type":n,children:[t&&ks("div",{className:i.subTitleContainer,children:ks("span",{className:i.subtitle,children:t})}),ks("div",{className:i.suggestions,children:e})]}))},Ie=eu;import au from"classnames";import{useRef as lu}from"react";import{createContext as nu,useCallback as ou,useContext as su,useEffect as ru}from"react";import{jsx as iu}from"react/jsx-runtime";var Ei=nu(null),ki=({scrollContainerRef:t,children:e})=>{let n=ou(o=>{let s=t.current;if(!s||s.scrollHeight<=s.clientHeight)return;let{top:r}=s.getBoundingClientRect(),{top:i}=o.getBoundingClientRect();"scrollTo"in s?s.scrollTo({top:i-r}):s.scrollTop=i-r},[]);return iu(Ei.Provider,{value:n,children:e})},Gn=t=>{let e=su(Ei);ru(()=>{let n=t.current;n&&e(n)},[])};var Ri={root:"dd-uoTXh"};import{jsx as Pi}from"react/jsx-runtime";var du=({className:t,children:e})=>{let n=x("SectionList",Ri),o=lu(null);return Pi(ki,{scrollContainerRef:o,children:Pi("div",{ref:o,className:au(n.root,t),children:e})})},rn=du;import an from"classnames";import cu,{createContext as pu,useCallback as uu,useContext as nt}from"react";var Rs={root:"dd-1g-A9",fadein:"dd-McXxq",isClickable:"dd-CTG8E",isSelected:"dd-yhg27",actions:"dd-Nlm6p",actionsIsFixed:"dd-OK-kw",actionButton:"dd-zbXsQ",dropdownList:"dd-AvwWP",dropdownButton:"dd-piaJi",dropdownItem:"dd-qgkTO",dropdownItemButton:"dd-sTE2D",actionButtonIsPrimary:"dd-mhkWS",actionButtonIsDisabled:"dd-0eKLQ",labels:"dd-QKJu6",label:"dd-aMplE",buttonsContainer:"dd-uRYN4",button:"dd-9UE-x",buttonPrimary:"dd-aYDCB",buttonSecondary:"dd--cpPL",buttonWithIcon:"dd-MQVt5",icon:"dd-Jr-ww",buttonDisabled:"dd-agTuH"};import{jsx as pe,jsxs as Ii}from"react/jsx-runtime";var We=pu(Rs),gu=o=>{var s=o,{fixed:t,children:e}=s,n=A(s,["fixed","children"]);let r=nt(We);return pe("div",S(y({},n),{className:an(r.actions,{[r.actionsIsFixed]:t}),children:e}))};function mu(d){var l=d,{as:t,className:e,icon:n,title:o,children:s,disabled:r,variant:i}=l,a=A(l,["as","className","icon","title","children","disabled","variant"]);let c=nt(We);return Ii(t||"button",S(y({type:"button",className:an(c.button,{[c.buttonWithIcon]:n,[c.buttonDisabled]:r,[c.buttonPrimary]:i==="primary",[c.buttonSecondary]:i==="secondary"},e),title:o,"aria-label":o},a),{children:[n&&pe("span",{className:c.icon,children:n}),s]}))}var fu=({children:t})=>{let e=nt(We);return pe("div",{className:e.buttonsContainer,children:t})},hu=({className:t,primary:e,disabled:n,label:o,children:s})=>{let r=nt(We);return Ii("div",{className:an(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,pe("ul",{className:r.dropdownList,children:s})]})},yu=({index:t,label:e,onClick:n})=>{let o=nt(We);return pe("li",{className:o.dropdownItem,children:pe("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},vu=({className:t,primary:e,disabled:n,onClick:o,label:s})=>{let r=nt(We);return pe("button",{type:"button",className:an(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onClick:o!=null?o:(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:s})},xu=({labels:t})=>{let e=nt(We);return pe("div",{className:e.labels,children:t.map(n=>pe("span",{className:e.label,children:n},n))})},Ve=cu.forwardRef((a,i)=>{var d=a,{className:t,selected:e,onClick:n,children:o,as:s="div"}=d,r=A(d,["className","selected","onClick","children","as"]);let l=x("Suggestion",Rs),c=uu(u=>{u.preventDefault(),n&&n(u)},[n]);return pe(s,S(y({},r),{ref:i,className:an(t,l.root,{[l.isSelected]:e,[l.isClickable]:!!n}),onClick:c,children:pe(We.Provider,{value:l,children:o})}))});Ve.Labels=xu;Ve.Actions=gu;Ve.ActionButton=vu;Ve.DropdownButton=hu;Ve.DropdownItem=yu;Ve.ButtonsContainer=fu;Ve.Button=mu;var M=Ve;import Su from"classnames";var Li={root:"dd-W35K-",isWithDivider:"dd-sscOy"};import{jsx as Cu}from"react/jsx-runtime";var bu=({withDivider:t,children:e})=>{let n=x("SuggestionList",Li);return Cu("div",{"data-testid":"suggestions-overlay-list",className:Su(n.root,{[n.isWithDivider]:t}),children:e})},te=bu;import Tu from"classnames";var Ai={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};import{jsx as Ps}from"react/jsx-runtime";var wu=({className:t,isCollapsed:e,title:n,onClick:o})=>{let s=x("ToggleButton",Ai);return Ps("button",{type:"button",className:Tu(s.root,t,{[s.isCollapsed]:e}),onClick:o,title:n,children:Ps("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:Ps("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Et=wu;var Mi=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,qn=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Ni=/x-deepdesk-(([a-z0-9\-_])+-version)/,Xn=["cues","custom-data","custom-data-banner","knowledge-assist"],Oi=Intl.DateTimeFormat().resolvedOptions().timeZone,je=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(je||{}),kt=(i=>(i.ENTER="enter",i.TAB="tab",i.ARROW="arrow",i.HOTKEY="hotkey",i.MOUSE="mouse",i.SPACE="space",i))(kt||{});import{createRoot as tt}from"react-dom/client";import{Fragment as Pf}from"react";import{createSlice as Eu}from"@reduxjs/toolkit";import{useSelector as ku}from"react-redux";var Jn=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(Jn||{});var Ru={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,addToPersonalCollection:!1,inlineSuggestions:!1,suggestionsPlacement:"above",floatingMenu:!1,detectSubmit:!1,automaticHandlingTime:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!0,adminUrl:void 0,productName:"Deepdesk",hasKeyboardInput:!0},Di=Eu({name:"settings",initialState:Ru,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,s]=n;typeof s!="undefined"&&(t[o]=s)})}}}),{set:Qn}=Di.actions,Rt=t=>e=>e.settings[t],E=t=>ku(Rt(t)),_i=Di.reducer;import{useSelector as Ka}from"react-redux";import{createAsyncThunk as Is,createSlice as Pu}from"@reduxjs/toolkit";var Iu={isLoggedIn:null,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1,loginError:null},J=t=>t.auth.isLoggedIn;var Fi=t=>t.auth.verifyFetchState,Hi=t=>t.auth.showLoginOverlay,Bi=t=>t.auth.loginError,Le=Is("auth/validate",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.isLoggedIn()})),Ui=Is("auth/requestLogin",(n,o)=>v(null,[n,o],function*({email:t},e){let{deepdeskAPI:s}=e.extra;return s.requestLoginByEmail(t)})),ln=Is("auth/verifyLoginToken",(n,o)=>v(null,[n,o],function*({token:t},e){let{deepdeskAPI:s}=e.extra;return s.verifyLoginToken(t)})),Ki=Pu({name:"auth",initialState:Iu,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload},setLoginError(t,e){t.loginError=e.payload},clearLoginError(t){t.loginError=null}},extraReducers:t=>{t.addCase(Le.pending,e=>{e.loginFetchState="loading"}),t.addCase(Le.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(Le.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(ln.pending,e=>{e.verifyFetchState="loading"}),t.addCase(ln.rejected,e=>{e.verifyFetchState="error"}),t.addCase(ln.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Pt,setShowLoginOverlay:zi,setLoginError:Ls,clearLoginError:Zn}=Ki.actions,Wi=Ki.reducer;import{createAction as Bu,createSelector as Ji,createSlice as Uu}from"@reduxjs/toolkit";import{diffChars as Ku}from"diff";function Vi(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function $e(t,e,n=10){let o=typeof t,s=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==s?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>$e(r,e[i],n-1)):Vi(t)&&Vi(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>$e(t[i],e[i],n-1)):!1}function Lu(t){return Math.max(...t.map(e=>e.length))}function Au(t,e){let n=t.reduce((o,s)=>{if(s){let r=o[s]?o[s]+1:1;return S(y({},o),{[s]:r})}return o},{});return Object.keys(n).reduce((o,s)=>(n[s]<e&&o.push(s),o),[])}function ji(t,e){let o=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Lu(o);s++){let r=Au(o.map(a=>a[s]),e),i=o.filter(a=>!r.includes(a[s]));if(i.length>=e)o=i;else return{text:o[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Mu=2;function $i(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=ji(t,Mu);return n&&n.text!==e?n:t[0]}import{createAction as Ou,createAsyncThunk as It,createSlice as Du}from"@reduxjs/toolkit";var Nu={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=Nu;var Gi={current:null,isSupported:null},V=Ou("resetConversation"),qi=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.externalId)||null},xe=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Lt=t=>t.conversation.isSupported,As=It("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),Yn=It("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),eo=It("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),to=It("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=xe(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),Ms=It("conversation/upsert",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId).catch(()=>null).then(o=>{if(!o)return n.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,metadata:d}=t;return n.updateConversation(o.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,metadata:d})})}),Ns=It("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=xe(e.getState());if(!o)throw new Error("No current conversation to update messages");return n.postMessages(o,t.map(s=>y({},s)))}),_u=[Yn.rejected,eo.rejected,to.rejected,Ns.rejected].map(t=>t==null?void 0:t.toString());function Fu(t){return _u.includes(t.type)}var Hu=Du({name:"conversation",initialState:Gi,reducers:{},extraReducers:t=>{t.addCase(As.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(Yn.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(eo.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Ms.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(to.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(V,()=>Gi).addMatcher(Fu,(e,n)=>{var o;throw k.info("Conversation action rejected",n.type,((o=n.error)==null?void 0:o.message)||"No message"),new Error(n.error.message)})}}),Xi=Hu.reducer;var ot={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],pinnedSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Os(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}}var no=Bu("input/applyImageSuggestion"),Qi=Uu({name:"input",initialState:ot,reducers:{setInput(t,e){var r,i;let{beforeInputChange:n}=t,{text:o,html:s}=e.payload;if(t.text=o,t.html=s!=null?s:null,o==="")t.metrics=ot.metrics,t.textSuggestions=[],t.mixedSuggestion=null;else if(n!==null&&t.text!==n.text){let{key:a,shiftKey:d,ctrlKey:l,metaKey:c,altKey:u}=n.keyDown;switch(a){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:p}=t,f=Ku(n.text,p);n.text.length-p.length>1&&t.metrics.deletions.push(...f.filter(m=>m.removed).map(m=>m.value)),t.metrics.numCharsDeleted+=n.text.length-p.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(l||c)break;default:if(!l&&!c&&!u){t.metrics.numCharsTyped+=1;let p=((r=n.selection)==null?void 0:r.start)!==void 0&&((i=n.selection)==null?void 0:i.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;p&&p.length>0&&(t.metrics.numCharsDeleted+=p.length,t.metrics.deletions.push(p))}}t.metrics.agentStartedTypingTimestamp||(t.metrics.agentStartedTypingTimestamp=Date.now())}t.beforeInputChange=null},sendMessage(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(n=>!t.metrics.textSuggestions.some(o=>o.text===n.text&&o.source===n.source))},setSelection(t,e){e.payload!==null&&($e(t.selection,e.payload)||(t.selection=e.payload))},commitSuggestion(t,e){let n=e.payload,{text:o,suggestion:{source:s,abVariant:r,abTestName:i,trainingJobs:a,sourceText:d,searchTerm:l,assistantCode:c,text:u},eventMetrics:{inputType:p},replace:f}=n,m=s==="search"||s==="personal-collection-search",g=o.slice(t.text.substring(0,t.selection.start).length);(m||f==="selection")&&(g=o),n.suggestion.source==="search-overlay"&&(g=u),t.metrics.textSuggestions.push({text:g,source:s,assistantCode:c,abVariant:r,abTestName:i,inputType:p,sourceText:d,trainingJobs:a||[],searchTerm:m?t.text:l}),t.textSuggestions=[],t.selectedSuggestionIndex=-1},offeredTextSuggestion(t,e){let{text:n,suggestion:{source:o}}=e.payload;t.metrics.offeredTextSuggestions.find(r=>r.text===n)||t.metrics.offeredTextSuggestions.push({text:n,source:o})},registerKeyDown(t,e){let{key:n}=e.payload;["Control","Meta","Shift","Alt"].includes(n)||(t.beforeInputChange={text:t.text,selection:t.selection,keyDown:e.payload})},registerKeyUp(t,e){},registerCut(t,e){let{metrics:n}=t,o=e.payload;t.metrics=S(y({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:s}=e.payload,r=n.numCharsDeleted+(s!=null&&s.length?s.length:0),i=s!=null&&s.length?[...n.deletions,s]:n.deletions;t.metrics=S(y({},t.metrics),{numCharsDeleted:r,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},selectPreviousTextSuggestion(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},selectTextSuggestionByIndex(t,e){t.selectedSuggestionIndex=e.payload},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0){t.mixedSuggestion=null;return}let n=t.text.substring(0,t.selection.end),o=$i(e.payload,n);t.mixedSuggestion=o!=null&&o.text.includes(n)?o:null},setPinnedSuggestions(t,e){t.pinnedSuggestions=e.payload},removePinnedSuggestions(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(o=>o.source!==e.payload.source||e.payload.assistantCode&&o.assistantCode!==e.payload.assistantCode?!0:e.payload.text?o.text!==e.payload.text:!1);let n=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex>n-1&&(t.selectedSuggestionIndex=-1)},setMetrics(t,{payload:e}){t.metrics=e},resetMetrics(t){t.metrics=ot.metrics}},extraReducers:t=>{t.addCase(V,e=>{e.mixedSuggestion=ot.mixedSuggestion,e.textSuggestions=ot.textSuggestions,e.selectedSuggestionIndex=ot.selectedSuggestionIndex,e.metrics=ot.metrics})}}),At=t=>t.input.text.substring(0,t.input.selection.end),zu=t=>t.input.mixedSuggestion,Wu=t=>t.input.pinnedSuggestions,Vu=t=>t.input.textSuggestions,dn=t=>t.input.selectedSuggestionIndex,st=Ji([Vu,Wu],(t,e)=>[...t,...e]),Mt=Ji([st,zu,dn],(t,e,n)=>n>-1?t[n]:e),Zi=t=>t.input.selection,{commitSuggestion:se,offeredTextSuggestion:Yi,registerCut:ea,registerKeyDown:ta,registerKeyUp:na,registerPaste:oa,selectNextTextSuggestion:sa,selectPreviousTextSuggestion:ra,selectTextSuggestionByIndex:oo,setInput:so,setMetrics:ia,setPinnedSuggestions:Nt,removePinnedSuggestions:rt,setSelection:ro,setTextSuggestions:Ge,resetMetrics:aa,sendMessage:it}=Qi.actions,la=Qi.reducer;import{createAsyncThunk as qu,createSelector as Xu,createSlice as Ju}from"@reduxjs/toolkit";import{createAsyncThunk as io,createSlice as ju}from"@reduxjs/toolkit";function da(t){try{return Intl.DateTimeFormat(void 0,{timeZone:t}),!0}catch(e){return!1}}var $u={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle",showNicknameDialog:!1},Ot=t=>{var e;return(e=t.info.agentInfo)!=null?e:null},ca=t=>{var e;return(e=t.info.visitorInfo)!=null?e:null},pa=t=>{var e;return(e=t.info.customData)!=null?e:null},pn=({info:{visitorInfo:t,agentInfo:e}})=>{var n,o;return{timezone:t!=null&&t.visitorTimeZone&&da(t.visitorTimeZone)?t.visitorTimeZone:Oi,agentName:(n=e==null?void 0:e.agentNickname)!=null?n:"",visitorName:(o=t==null?void 0:t.visitorName)!=null?o:""}},Gu=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],ua=io("info/setAgentNickname",(n,o)=>v(null,[n,o],function*({agentNickname:t},e){var i;let{deepdeskAPI:s}=e.extra,r=yield s.patchMe({nickname:t});return{agentNickname:(i=r==null?void 0:r.nickname)!=null?i:t}})),cn=io("info/setAgentInfo",(t,e)=>v(null,null,function*(){var r,i,a;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=[];if(t.agentId&&t.skipSync!==!0&&s.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let d=Gu.reduce((l,[c,u])=>!o[u]&&c in t?S(y({},l),{[u]:t[c]}):l,{});Object.keys(d).length>0&&s.push(n.patchMe(d).then(l=>o=l))}return s.length>0&&(yield Promise.all(s)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(r=o.nickname)!=null?r:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(a=o.defaultLocale)!=null?a:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),Ds=io("info/setAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=y(y({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:s}),s})),_s=io("info/getAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),ga=ju({name:"info",initialState:$u,reducers:{setVisitorInfo(t,e){t.visitorInfo=y(y({},t.visitorInfo),e.payload)},setCustomData(t,e){t.customData=e.payload},setPlatformVariables(t,e){t.platformVariables=e.payload},setShowNicknameDialog(t,e){t.showNicknameDialog=e.payload}},extraReducers:t=>{t.addCase(cn.pending,(e,n)=>{e.fetchState="loading",e.agentInfo=y(y({},e.agentInfo),n.meta.arg)}).addCase(cn.rejected,e=>{e.fetchState="error"}).addCase(cn.fulfilled,(e,n)=>{e.fetchState="done",e.agentInfo=n.payload}).addCase(Ds.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(_s.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(V,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:ma,setCustomData:fa,setPlatformVariables:ha,setShowNicknameDialog:ya}=ga.actions,va=ga.reducer;function ge(t,e){return e?Object.entries(e).reduce((n,[o,s])=>n.replaceAll(o,s),t):t}var ao={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},xa=t=>t.search.isOpen,Sa=t=>t.search.page,Fs=t=>t.search.list,ba=t=>t.search.aggregates,Qu=Xu([Fs,(t,e)=>e],(t,e)=>t.filter(n=>n.type===e)),Ca=t=>e=>Qu(e,t),at=qu("search/getAll",(t,e)=>v(null,null,function*(){var d;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(d=o.conversation.current)==null?void 0:d.profileCode,{platformVariables:r}=o.info;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:pn(o)});return{results:i.map(l=>S(y(y({},l),l.title&&r?{title:ge(l.title,r)}:{}),{text:ge(l.text,r!=null?r:{}),source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:a}})),Ta=Ju({name:"search",initialState:ao,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ao.fetchState,t.list=ao.list}},extraReducers:t=>{t.addCase(at.pending,e=>{e.fetchState="loading"}).addCase(at.rejected,(e,n)=>{e.fetchState="error",k.error(n.error)}).addCase(at.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload.results,e.aggregates=n.payload.aggregates||{}}).addCase(V,()=>ao)}}),{resetSearch:lo,setIsOpen:me,setPage:Dt}=Ta.actions,wa=Ta.reducer;var Hs="SetOutputs",_t="ShowLoginOverlay",un="UserLoggedIn",Zu="UserLoggedOut",Ae="ApplySuggestion",Bs="ApplyImageSuggestion",Yu="ShowCommandPalette",co="ShowNicknameDialog",po="ReduxAction",eg="RemovePinnedSuggestion",tg=t=>({[Hs]:e=>{t.dispatch(S(y({},e),{isBroadcasted:!0}))},[po]:e=>{e.isBroadcasted||t.dispatch(S(y({},e),{isBroadcasted:!0}))},[eg]:e=>{t.dispatch(rt(e))},[Yu]:e=>{t.dispatch(me(e.isOpen)),e.page&&t.dispatch(Dt(e.page))},[co]:e=>{t.dispatch(ya(e.showNicknameDialog))},[_t]:e=>{t.dispatch(zi(e))},[un]:()=>{t.dispatch(Le())},[Zu]:()=>{t.dispatch(Le())},[Bs]:e=>{t.dispatch(no({suggestion:e.suggestion}))},[Ae]:e=>{t.dispatch(se(S(y({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),Ea=tg;import ka,{useContext as ng}from"react";import{jsx as og}from"react/jsx-runtime";var Ra=ka.createContext(null),Me=({broadcastEvents:t,children:e})=>{let n=ka.useMemo(()=>t,[]);return og(Ra.Provider,{value:n,children:e})},ne=()=>{let t=ng(Ra);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import Js from"classnames";import{useCallback as Ba,useEffect as Pg,useMemo as Ig,useState as Qs}from"react";import{useDispatch as Lg,useSelector as Ag}from"react-redux";import{createContext as hg,useContext as yg}from"react";var Us=function(t,e){return Us=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},Us(t,e)};function gn(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Us(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var re=function(){return re=Object.assign||function(e){for(var n,o=1,s=arguments.length;o<s;o++){n=arguments[o];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},re.apply(this,arguments)};function Pa(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(n[o[s]]=t[o[s]]);return n}function uo(t,e,n){if(n||arguments.length===2)for(var o=0,s=e.length,r;o<s;o++)(r||!(o in e))&&(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}function go(t,e){var n=e&&e.cache?e.cache:cg,o=e&&e.serializer?e.serializer:lg,s=e&&e.strategy?e.strategy:rg;return s(t,{cache:n,serializer:o})}function sg(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Ia(t,e,n,o){var s=sg(o)?o:n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.call(this,o),e.set(s,r)),r}function La(t,e,n){var o=Array.prototype.slice.call(arguments,3),s=n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.apply(this,o),e.set(s,r)),r}function Ks(t,e,n,o,s){return n.bind(e,t,o,s)}function rg(t,e){var n=t.length===1?Ia:La;return Ks(t,this,n,e.cache.create(),e.serializer)}function ig(t,e){return Ks(t,this,La,e.cache.create(),e.serializer)}function ag(t,e){return Ks(t,this,Ia,e.cache.create(),e.serializer)}var lg=function(){return JSON.stringify(arguments)},dg=(function(){function t(){this.cache=Object.create(null)}return t.prototype.get=function(e){return this.cache[e]},t.prototype.set=function(e,n){this.cache[e]=n},t})(),cg={create:function(){return new dg}},mo={variadic:ig,monadic:ag};var fo;(function(t){t[t.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",t[t.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",t[t.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",t[t.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",t[t.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",t[t.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",t[t.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",t[t.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",t[t.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",t[t.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",t[t.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",t[t.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",t[t.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",t[t.INVALID_TAG=23]="INVALID_TAG",t[t.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",t[t.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",t[t.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(fo||(fo={}));var ho=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var de;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(de||(de={}));var yo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(yo||(yo={}));function zs(t){return t.type===de.literal}function Ws(t){return t.type===de.argument}function mn(t){return t.type===de.number}function fn(t){return t.type===de.date}function hn(t){return t.type===de.time}function yn(t){return t.type===de.select}function vn(t){return t.type===de.plural}function Aa(t){return t.type===de.pound}function xn(t){return t.type===de.tag}function vo(t){return!!(t&&typeof t=="object"&&t.type===yo.number)}function Sn(t){return!!(t&&typeof t=="object"&&t.type===yo.dateTime)}function Vs(t){t.forEach(function(e){if(delete e.location,yn(e)||vn(e))for(var n in e.options)delete e.options[n].location,Vs(e.options[n].value);else mn(e)&&vo(e.style)||(fn(e)||hn(e))&&Sn(e.style)?delete e.style.location:xn(e)&&Vs(e.children)})}function Ma(t,e){e===void 0&&(e={}),e=re({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new ho(t,e).parse();if(n.err){var o=SyntaxError(fo[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||Vs(n.val),n.val}var lt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(lt||(lt={}));var bn=(function(t){gn(e,t);function e(n,o,s){var r=t.call(this,n)||this;return r.code=o,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e})(Error);var js=(function(t){gn(e,t);function e(n,o,s,r){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(s).join('", "'),'"'),lt.INVALID_VALUE,r)||this}return e})(bn);var Na=(function(t){gn(e,t);function e(n,o,s){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),lt.INVALID_VALUE,s)||this}return e})(bn);var Oa=(function(t){gn(e,t);function e(n,o){return t.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(o,'"'),lt.MISSING_VALUE,o)||this}return e})(bn);var Q;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(Q||(Q={}));function pg(t){return t.length<2?t:t.reduce(function(e,n){var o=e[e.length-1];return!o||o.type!==Q.literal||n.type!==Q.literal?e.push(n):o.value+=n.value,e},[])}function ug(t){return typeof t=="function"}function Cn(t,e,n,o,s,r,i){if(t.length===1&&zs(t[0]))return[{type:Q.literal,value:t[0].value}];for(var a=[],d=0,l=t;d<l.length;d++){var c=l[d];if(zs(c)){a.push({type:Q.literal,value:c.value});continue}if(Aa(c)){typeof r=="number"&&a.push({type:Q.literal,value:n.getNumberFormat(e).format(r)});continue}var u=c.value;if(!(s&&u in s))throw new Oa(u,i);var p=s[u];if(Ws(c)){(!p||typeof p=="string"||typeof p=="number")&&(p=typeof p=="string"||typeof p=="number"?String(p):""),a.push({type:typeof p=="string"?Q.literal:Q.object,value:p});continue}if(fn(c)){var f=typeof c.style=="string"?o.date[c.style]:Sn(c.style)?c.style.parsedOptions:void 0;a.push({type:Q.literal,value:n.getDateTimeFormat(e,f).format(p)});continue}if(hn(c)){var f=typeof c.style=="string"?o.time[c.style]:Sn(c.style)?c.style.parsedOptions:o.time.medium;a.push({type:Q.literal,value:n.getDateTimeFormat(e,f).format(p)});continue}if(mn(c)){var f=typeof c.style=="string"?o.number[c.style]:vo(c.style)?c.style.parsedOptions:void 0;f&&f.scale&&(p=p*(f.scale||1)),a.push({type:Q.literal,value:n.getNumberFormat(e,f).format(p)});continue}if(xn(c)){var m=c.children,g=c.value,h=s[g];if(!ug(h))throw new Na(g,"function",i);var b=Cn(m,e,n,o,s,r),T=h(b.map(function(I){return I.value}));Array.isArray(T)||(T=[T]),a.push.apply(a,T.map(function(I){return{type:typeof I=="string"?Q.literal:Q.object,value:I}}))}if(yn(c)){var C=c.options[p]||c.options.other;if(!C)throw new js(c.value,p,Object.keys(c.options),i);a.push.apply(a,Cn(C.value,e,n,o,s));continue}if(vn(c)){var C=c.options["=".concat(p)];if(!C){if(!Intl.PluralRules)throw new bn(`Intl.PluralRules is not available in this environment.
|
|
1
|
+
var vi=Object.defineProperty,Np=Object.defineProperties;var Op=Object.getOwnPropertyDescriptors;var zn=Object.getOwnPropertySymbols;var xi=Object.prototype.hasOwnProperty,Si=Object.prototype.propertyIsEnumerable;var yi=(t,e,n)=>e in t?vi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))xi.call(e,n)&&yi(t,n,e[n]);if(zn)for(var n of zn(e))Si.call(e,n)&&yi(t,n,e[n]);return t},S=(t,e)=>Np(t,Op(e));var A=(t,e)=>{var n={};for(var o in t)xi.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&zn)for(var o of zn(t))e.indexOf(o)<0&&Si.call(t,o)&&(n[o]=t[o]);return n};var X=(t,e)=>{for(var n in e)vi(t,n,{get:e[n],enumerable:!0})};var v=(t,e,n)=>new Promise((o,s)=>{var r=d=>{try{a(n.next(d))}catch(l){s(l)}},i=d=>{try{a(n.throw(d))}catch(l){s(l)}},a=d=>d.done?o(d.value):Promise.resolve(d.value).then(r,i);a((n=n.apply(t,e)).next())});import Ci from"classnames";import Bp,{createContext as Up,useContext as Es,useEffect as Kp,useState as zp}from"react";import Dp,{useContext as _p}from"react";import Fp from"classnames";var sn=Dp.createContext({});function x(t,e){let r=_p(sn),{debug:n}=r,s=A(r,["debug"])[t];return Object.entries(e).reduce((i,[a,d])=>{let l=s==null?void 0:s[a];return S(y({},i),{[a]:Fp(d,l,n?`${t}__${a}`:!1)})},{})}var bi={root:"dd-4s9wq"};import{jsx as Wn,jsxs as Hp}from"react/jsx-runtime";var Vn=()=>Hp("svg",{className:bi.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[Wn("defs",{children:Wn("style",{children:".cls-1 { fill: #b3b3b3; }"})}),Wn("title",{children:"Failed loading image"}),Wn("path",{className:"cls-1",d:"M15 130.896V16.994c0-1.097.898-1.994 2.007-1.994h150.986A2 2 0 0 1 170 16.994v69.147L133.015 51 87.26 120.377l-35.863-17.758L15 130.896zM2 0C.895 0 0 .887 0 2v166c0 1.105.887 2 2 2h181c1.105 0 2-.887 2-2V2c0-1.105-.887-2-2-2H2zm49 72c11.046 0 20-9.178 20-20.5S62.046 31 51 31s-20 9.178-20 20.5S39.954 72 51 72z",fillRule:"evenodd"})]});var ws={root:"dd-c9KvZ",imageWrapper:"dd-sE7D9",image:"dd-bEGMz",content:"dd-oFIQa",title:"dd-mSgoo",contentIsCropped:"dd-Uvjv4",lineClamp:"dd-ApQo-"};import{jsx as wt}from"react/jsx-runtime";var jn=Up(ws),Wp=({title:t,src:e})=>{let n=Es(jn),[o,s]=zp(!1);return Kp(()=>{s(!1)},[e]),wt("div",{className:n.imageWrapper,children:e&&!o?wt("img",{className:n.image,alt:t,src:e,onError:()=>s(!0)}):wt(Vn,{})})},Vp=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let s=Es(jn);return wt("div",{className:Ci(s.content,t,{[s.contentIsCropped]:n,[s.lineClamp]:e}),children:o})},jp=r=>{var i=r,{as:t="h1",cropText:e=!1,className:n,children:o}=i,s=A(i,["as","cropText","className","children"]);let a=Es(jn);return Bp.createElement(t,y({className:Ci(a.title,n,{[a.contentIsCropped]:e})},s),o)},$n=({children:t})=>{let e=x("Card",ws);return wt("div",{className:e.root,children:wt(jn.Provider,{value:e,children:t})})};$n.Image=Wp;$n.Content=Vp;$n.Title=jp;var D=$n;import $p from"classnames";var Ti={root:"dd-llBx9"};import{jsx as Xp}from"react/jsx-runtime";var Gp={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},qp=o=>{var s=o,{className:t,keyCode:e}=s,n=A(s,["className","keyCode"]);let r=x("KeyboardHint",Ti);return Xp("span",y({"data-key":Gp[e],className:$p(t,r.root)},n))},ks=qp;import Jp from"classnames";var wi={root:"dd-e6HXZ"};import{jsx as Yp}from"react/jsx-runtime";var Qp=o=>{var s=o,{className:t,children:e}=s,n=A(s,["className","children"]);let r=x("Label",wi);return Yp("span",S(y({},n),{className:Jp(t,r.root),children:e}))},Zp=Qp;var Ei={root:"dd-FiMI7",subTitleContainer:"dd-98jc7",subtitle:"dd-3MnW8",suggestions:"dd-0SGL8"};import{jsx as Rs,jsxs as tu}from"react/jsx-runtime";var eu=s=>{var r=s,{title:t,children:e,type:n}=r,o=A(r,["title","children","type"]);let i=x("Section",Ei);return tu("section",S(y({},o),{className:i.root,"data-section-type":n,children:[t&&Rs("div",{className:i.subTitleContainer,children:Rs("span",{className:i.subtitle,children:t})}),Rs("div",{className:i.suggestions,children:e})]}))},Ie=eu;import au from"classnames";import{useRef as lu}from"react";import{createContext as nu,useCallback as ou,useContext as su,useEffect as ru}from"react";import{jsx as iu}from"react/jsx-runtime";var ki=nu(null),Ri=({scrollContainerRef:t,children:e})=>{let n=ou(o=>{let s=t.current;if(!s||s.scrollHeight<=s.clientHeight)return;let{top:r}=s.getBoundingClientRect(),{top:i}=o.getBoundingClientRect();"scrollTo"in s?s.scrollTo({top:i-r}):s.scrollTop=i-r},[]);return iu(ki.Provider,{value:n,children:e})},Gn=t=>{let e=su(ki);ru(()=>{let n=t.current;n&&e(n)},[])};var Pi={root:"dd-uoTXh"};import{jsx as Ii}from"react/jsx-runtime";var du=({className:t,children:e})=>{let n=x("SectionList",Pi),o=lu(null);return Ii(Ri,{scrollContainerRef:o,children:Ii("div",{ref:o,className:au(n.root,t),children:e})})},rn=du;import an from"classnames";import cu,{createContext as pu,useCallback as uu,useContext as nt}from"react";var Ps={root:"dd-1g-A9",fadein:"dd-McXxq",isClickable:"dd-CTG8E",isSelected:"dd-yhg27",actions:"dd-Nlm6p",actionsIsFixed:"dd-OK-kw",actionButton:"dd-zbXsQ",dropdownList:"dd-AvwWP",dropdownButton:"dd-piaJi",dropdownItem:"dd-qgkTO",dropdownItemButton:"dd-sTE2D",actionButtonIsPrimary:"dd-mhkWS",actionButtonIsDisabled:"dd-0eKLQ",labels:"dd-QKJu6",label:"dd-aMplE",buttonsContainer:"dd-uRYN4",button:"dd-9UE-x",buttonPrimary:"dd-aYDCB",buttonSecondary:"dd--cpPL",buttonWithIcon:"dd-MQVt5",icon:"dd-Jr-ww",buttonDisabled:"dd-agTuH"};import{jsx as pe,jsxs as Li}from"react/jsx-runtime";var We=pu(Ps),mu=o=>{var s=o,{fixed:t,children:e}=s,n=A(s,["fixed","children"]);let r=nt(We);return pe("div",S(y({},n),{className:an(r.actions,{[r.actionsIsFixed]:t}),children:e}))};function gu(d){var l=d,{as:t,className:e,icon:n,title:o,children:s,disabled:r,variant:i}=l,a=A(l,["as","className","icon","title","children","disabled","variant"]);let c=nt(We);return Li(t||"button",S(y({type:"button",className:an(c.button,{[c.buttonWithIcon]:n,[c.buttonDisabled]:r,[c.buttonPrimary]:i==="primary",[c.buttonSecondary]:i==="secondary"},e),title:o,"aria-label":o},a),{children:[n&&pe("span",{className:c.icon,children:n}),s]}))}var fu=({children:t})=>{let e=nt(We);return pe("div",{className:e.buttonsContainer,children:t})},hu=({className:t,primary:e,disabled:n,label:o,children:s})=>{let r=nt(We);return Li("div",{className:an(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,pe("ul",{className:r.dropdownList,children:s})]})},yu=({index:t,label:e,onClick:n})=>{let o=nt(We);return pe("li",{className:o.dropdownItem,children:pe("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},vu=({className:t,primary:e,disabled:n,onClick:o,label:s})=>{let r=nt(We);return pe("button",{type:"button",className:an(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onClick:o!=null?o:(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:s})},xu=({labels:t})=>{let e=nt(We);return pe("div",{className:e.labels,children:t.map(n=>pe("span",{className:e.label,children:n},n))})},Ve=cu.forwardRef((a,i)=>{var d=a,{className:t,selected:e,onClick:n,children:o,as:s="div"}=d,r=A(d,["className","selected","onClick","children","as"]);let l=x("Suggestion",Ps),c=uu(u=>{u.preventDefault(),n&&n(u)},[n]);return pe(s,S(y({},r),{ref:i,className:an(t,l.root,{[l.isSelected]:e,[l.isClickable]:!!n}),onClick:c,children:pe(We.Provider,{value:l,children:o})}))});Ve.Labels=xu;Ve.Actions=mu;Ve.ActionButton=vu;Ve.DropdownButton=hu;Ve.DropdownItem=yu;Ve.ButtonsContainer=fu;Ve.Button=gu;var M=Ve;import Su from"classnames";var Ai={root:"dd-W35K-",isWithDivider:"dd-sscOy"};import{jsx as Cu}from"react/jsx-runtime";var bu=({withDivider:t,children:e})=>{let n=x("SuggestionList",Ai);return Cu("div",{"data-testid":"suggestions-overlay-list",className:Su(n.root,{[n.isWithDivider]:t}),children:e})},te=bu;import Tu from"classnames";var Mi={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};import{jsx as Is}from"react/jsx-runtime";var wu=({className:t,isCollapsed:e,title:n,onClick:o})=>{let s=x("ToggleButton",Mi);return Is("button",{type:"button",className:Tu(s.root,t,{[s.isCollapsed]:e}),onClick:o,title:n,children:Is("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:Is("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Et=wu;var Ni=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,qn=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Oi=/x-deepdesk-(([a-z0-9\-_])+-version)/,Xn=["cues","custom-data","custom-data-banner","knowledge-assist"],Di=Intl.DateTimeFormat().resolvedOptions().timeZone,je=(m=>(m.SEARCH="search",m.TEMPLATE="template",m.ELASTIC_SEARCH="search-autocomplete",m.GPT="gpt",m.TRIE="trie",m.TRIE_WITH_TYPOS="trie-with-typos",m.SEMANTIC="semantic",m.TEXT_RECOMMENDATION="text_recommendation",m.URL_RECOMMENDATION="url_recommendation",m.LINK_RECOMMENDATION="link_recommendation",m.PERSONAL_COLLECTION="personal-collection",m.PERSONAL_COLLECTION_SEARCH="personal-collection-search",m.SEARCH_OVERLAY="search-overlay",m.SEARCH_PREVIEW="search-preview",m.SEARCH_URL="search-url",m))(je||{}),kt=(i=>(i.ENTER="enter",i.TAB="tab",i.ARROW="arrow",i.HOTKEY="hotkey",i.MOUSE="mouse",i.SPACE="space",i))(kt||{});import{createRoot as tt}from"react-dom/client";import{Fragment as Pf}from"react";import{createSlice as Eu}from"@reduxjs/toolkit";import{useSelector as ku}from"react-redux";var Jn=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(Jn||{});var Ru={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,addToPersonalCollection:!1,inlineSuggestions:!1,suggestionsPlacement:"above",floatingMenu:!1,detectSubmit:!1,automaticHandlingTime:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!0,adminUrl:void 0,productName:"Deepdesk",hasKeyboardInput:!0},_i=Eu({name:"settings",initialState:Ru,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,s]=n;typeof s!="undefined"&&(t[o]=s)})}}}),{set:Qn}=_i.actions,Rt=t=>e=>e.settings[t],E=t=>ku(Rt(t)),Fi=_i.reducer;import{useSelector as za}from"react-redux";import{createAsyncThunk as Ls,createSlice as Pu}from"@reduxjs/toolkit";var Iu={isLoggedIn:null,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1,loginError:null},J=t=>t.auth.isLoggedIn;var Hi=t=>t.auth.verifyFetchState,Bi=t=>t.auth.showLoginOverlay,Ui=t=>t.auth.loginError,Le=Ls("auth/validate",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.isLoggedIn()})),Ki=Ls("auth/requestLogin",(n,o)=>v(null,[n,o],function*({email:t},e){let{deepdeskAPI:s}=e.extra;return s.requestLoginByEmail(t)})),ln=Ls("auth/verifyLoginToken",(n,o)=>v(null,[n,o],function*({token:t},e){let{deepdeskAPI:s}=e.extra;return s.verifyLoginToken(t)})),zi=Pu({name:"auth",initialState:Iu,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload},setLoginError(t,e){t.loginError=e.payload},clearLoginError(t){t.loginError=null}},extraReducers:t=>{t.addCase(Le.pending,e=>{e.loginFetchState="loading"}),t.addCase(Le.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(Le.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(ln.pending,e=>{e.verifyFetchState="loading"}),t.addCase(ln.rejected,e=>{e.verifyFetchState="error"}),t.addCase(ln.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Pt,setShowLoginOverlay:Wi,setLoginError:As,clearLoginError:Zn}=zi.actions,Vi=zi.reducer;import{createAction as Bu,createSelector as Qi,createSlice as Uu}from"@reduxjs/toolkit";import{diffChars as Ku}from"diff";function ji(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function $e(t,e,n=10){let o=typeof t,s=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==s?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>$e(r,e[i],n-1)):ji(t)&&ji(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>$e(t[i],e[i],n-1)):!1}function Lu(t){return Math.max(...t.map(e=>e.length))}function Au(t,e){let n=t.reduce((o,s)=>{if(s){let r=o[s]?o[s]+1:1;return S(y({},o),{[s]:r})}return o},{});return Object.keys(n).reduce((o,s)=>(n[s]<e&&o.push(s),o),[])}function $i(t,e){let o=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Lu(o);s++){let r=Au(o.map(a=>a[s]),e),i=o.filter(a=>!r.includes(a[s]));if(i.length>=e)o=i;else return{text:o[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Mu=2;function Gi(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=$i(t,Mu);return n&&n.text!==e?n:t[0]}import{createAction as Ou,createAsyncThunk as It,createSlice as Du}from"@reduxjs/toolkit";var Nu={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=Nu;var qi={current:null,isSupported:null},V=Ou("resetConversation"),Xi=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.externalId)||null},xe=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Lt=t=>t.conversation.isSupported,Ms=It("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),Yn=It("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),eo=It("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),to=It("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=xe(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),Ns=It("conversation/upsert",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId).catch(()=>null).then(o=>{if(!o)return n.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,metadata:d}=t;return n.updateConversation(o.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,metadata:d})})}),Os=It("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=xe(e.getState());if(!o)throw new Error("No current conversation to update messages");return n.postMessages(o,t.map(s=>y({},s)))}),_u=[Yn.rejected,eo.rejected,to.rejected,Os.rejected].map(t=>t==null?void 0:t.toString());function Fu(t){return _u.includes(t.type)}var Hu=Du({name:"conversation",initialState:qi,reducers:{},extraReducers:t=>{t.addCase(Ms.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(Yn.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(eo.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Ns.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(to.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(V,()=>qi).addMatcher(Fu,(e,n)=>{var o;throw k.info("Conversation action rejected",n.type,((o=n.error)==null?void 0:o.message)||"No message"),new Error(n.error.message)})}}),Ji=Hu.reducer;var ot={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],pinnedSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Ds(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}}var no=Bu("input/applyImageSuggestion"),Zi=Uu({name:"input",initialState:ot,reducers:{setInput(t,e){var r,i;let{beforeInputChange:n}=t,{text:o,html:s}=e.payload;if(t.text=o,t.html=s!=null?s:null,o==="")t.metrics=ot.metrics,t.textSuggestions=[],t.mixedSuggestion=null;else if(n!==null&&t.text!==n.text){let{key:a,shiftKey:d,ctrlKey:l,metaKey:c,altKey:u}=n.keyDown;switch(a){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:p}=t,f=Ku(n.text,p);n.text.length-p.length>1&&t.metrics.deletions.push(...f.filter(g=>g.removed).map(g=>g.value)),t.metrics.numCharsDeleted+=n.text.length-p.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(l||c)break;default:if(!l&&!c&&!u){t.metrics.numCharsTyped+=1;let p=((r=n.selection)==null?void 0:r.start)!==void 0&&((i=n.selection)==null?void 0:i.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;p&&p.length>0&&(t.metrics.numCharsDeleted+=p.length,t.metrics.deletions.push(p))}}t.metrics.agentStartedTypingTimestamp||(t.metrics.agentStartedTypingTimestamp=Date.now())}t.beforeInputChange=null},sendMessage(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(n=>!t.metrics.textSuggestions.some(o=>o.text===n.text&&o.source===n.source))},setSelection(t,e){e.payload!==null&&($e(t.selection,e.payload)||(t.selection=e.payload))},commitSuggestion(t,e){let n=e.payload,{text:o,suggestion:{source:s,abVariant:r,abTestName:i,trainingJobs:a,sourceText:d,searchTerm:l,assistantCode:c,text:u},eventMetrics:{inputType:p},replace:f}=n,g=s==="search"||s==="personal-collection-search",m=o.slice(t.text.substring(0,t.selection.start).length);(g||f==="selection")&&(m=o),n.suggestion.source==="search-overlay"&&(m=u),t.metrics.textSuggestions.push({text:m,source:s,assistantCode:c,abVariant:r,abTestName:i,inputType:p,sourceText:d,trainingJobs:a||[],searchTerm:g?t.text:l}),t.textSuggestions=[],t.selectedSuggestionIndex=-1},offeredTextSuggestion(t,e){let{text:n,suggestion:{source:o}}=e.payload;t.metrics.offeredTextSuggestions.find(r=>r.text===n)||t.metrics.offeredTextSuggestions.push({text:n,source:o})},registerKeyDown(t,e){let{key:n}=e.payload;["Control","Meta","Shift","Alt"].includes(n)||(t.beforeInputChange={text:t.text,selection:t.selection,keyDown:e.payload})},registerKeyUp(t,e){},registerCut(t,e){let{metrics:n}=t,o=e.payload;t.metrics=S(y({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:s}=e.payload,r=n.numCharsDeleted+(s!=null&&s.length?s.length:0),i=s!=null&&s.length?[...n.deletions,s]:n.deletions;t.metrics=S(y({},t.metrics),{numCharsDeleted:r,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},selectPreviousTextSuggestion(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},selectTextSuggestionByIndex(t,e){t.selectedSuggestionIndex=e.payload},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0){t.mixedSuggestion=null;return}let n=t.text.substring(0,t.selection.end),o=Gi(e.payload,n);t.mixedSuggestion=o!=null&&o.text.includes(n)?o:null},setPinnedSuggestions(t,e){t.pinnedSuggestions=e.payload},removePinnedSuggestions(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(o=>o.source!==e.payload.source||e.payload.assistantCode&&o.assistantCode!==e.payload.assistantCode?!0:e.payload.text?o.text!==e.payload.text:!1);let n=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex>n-1&&(t.selectedSuggestionIndex=-1)},setMetrics(t,{payload:e}){t.metrics=e},resetMetrics(t){t.metrics=ot.metrics}},extraReducers:t=>{t.addCase(V,e=>{e.mixedSuggestion=ot.mixedSuggestion,e.textSuggestions=ot.textSuggestions,e.selectedSuggestionIndex=ot.selectedSuggestionIndex,e.metrics=ot.metrics})}}),At=t=>t.input.text.substring(0,t.input.selection.end),zu=t=>t.input.mixedSuggestion,Wu=t=>t.input.pinnedSuggestions,Vu=t=>t.input.textSuggestions,dn=t=>t.input.selectedSuggestionIndex,st=Qi([Vu,Wu],(t,e)=>[...t,...e]),Mt=Qi([st,zu,dn],(t,e,n)=>n>-1?t[n]:e),Yi=t=>t.input.selection,{commitSuggestion:se,offeredTextSuggestion:ea,registerCut:ta,registerKeyDown:na,registerKeyUp:oa,registerPaste:sa,selectNextTextSuggestion:ra,selectPreviousTextSuggestion:ia,selectTextSuggestionByIndex:oo,setInput:so,setMetrics:aa,setPinnedSuggestions:Nt,removePinnedSuggestions:rt,setSelection:ro,setTextSuggestions:Ge,resetMetrics:la,sendMessage:it}=Zi.actions,da=Zi.reducer;import{createAsyncThunk as qu,createSelector as Xu,createSlice as Ju}from"@reduxjs/toolkit";import{createAsyncThunk as io,createSlice as ju}from"@reduxjs/toolkit";function ca(t){try{return Intl.DateTimeFormat(void 0,{timeZone:t}),!0}catch(e){return!1}}var $u={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle",showNicknameDialog:!1},Ot=t=>{var e;return(e=t.info.agentInfo)!=null?e:null},pa=t=>{var e;return(e=t.info.visitorInfo)!=null?e:null},ua=t=>{var e;return(e=t.info.customData)!=null?e:null},pn=({info:{visitorInfo:t,agentInfo:e}})=>{var n,o;return{timezone:t!=null&&t.visitorTimeZone&&ca(t.visitorTimeZone)?t.visitorTimeZone:Di,agentName:(n=e==null?void 0:e.agentNickname)!=null?n:"",visitorName:(o=t==null?void 0:t.visitorName)!=null?o:""}},Gu=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],ma=io("info/setAgentNickname",(n,o)=>v(null,[n,o],function*({agentNickname:t},e){var i;let{deepdeskAPI:s}=e.extra,r=yield s.patchMe({nickname:t});return{agentNickname:(i=r==null?void 0:r.nickname)!=null?i:t}})),cn=io("info/setAgentInfo",(t,e)=>v(null,null,function*(){var r,i,a;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=[];if(t.agentId&&t.skipSync!==!0&&s.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let d=Gu.reduce((l,[c,u])=>!o[u]&&c in t?S(y({},l),{[u]:t[c]}):l,{});Object.keys(d).length>0&&s.push(n.patchMe(d).then(l=>o=l))}return s.length>0&&(yield Promise.all(s)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(r=o.nickname)!=null?r:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(a=o.defaultLocale)!=null?a:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),_s=io("info/setAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=y(y({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:s}),s})),Fs=io("info/getAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),ga=ju({name:"info",initialState:$u,reducers:{setVisitorInfo(t,e){t.visitorInfo=y(y({},t.visitorInfo),e.payload)},setCustomData(t,e){t.customData=e.payload},setPlatformVariables(t,e){t.platformVariables=e.payload},setShowNicknameDialog(t,e){t.showNicknameDialog=e.payload}},extraReducers:t=>{t.addCase(cn.pending,(e,n)=>{e.fetchState="loading",e.agentInfo=y(y({},e.agentInfo),n.meta.arg)}).addCase(cn.rejected,e=>{e.fetchState="error"}).addCase(cn.fulfilled,(e,n)=>{e.fetchState="done",e.agentInfo=n.payload}).addCase(_s.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(Fs.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(V,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:fa,setCustomData:ha,setPlatformVariables:ya,setShowNicknameDialog:va}=ga.actions,xa=ga.reducer;function me(t,e){return e?t==null?(k.warn("replaceVars called with non-string text; upstream contract violation",{keys:Object.keys(e)}),t):Object.entries(e).reduce((n,[o,s])=>n.replaceAll(o,s),t):t}var ao={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},Sa=t=>t.search.isOpen,ba=t=>t.search.page,Hs=t=>t.search.list,Ca=t=>t.search.aggregates,Qu=Xu([Hs,(t,e)=>e],(t,e)=>t.filter(n=>n.type===e)),Ta=t=>e=>Qu(e,t),at=qu("search/getAll",(t,e)=>v(null,null,function*(){var d;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(d=o.conversation.current)==null?void 0:d.profileCode,{platformVariables:r}=o.info;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:pn(o)});return{results:i.map(l=>S(y(y({},l),l.title&&r?{title:me(l.title,r)}:{}),{text:me(l.text,r!=null?r:{}),source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:a}})),wa=Ju({name:"search",initialState:ao,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ao.fetchState,t.list=ao.list}},extraReducers:t=>{t.addCase(at.pending,e=>{e.fetchState="loading"}).addCase(at.rejected,(e,n)=>{e.fetchState="error",k.error(n.error)}).addCase(at.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload.results,e.aggregates=n.payload.aggregates||{}}).addCase(V,()=>ao)}}),{resetSearch:lo,setIsOpen:ge,setPage:Dt}=wa.actions,Ea=wa.reducer;var Bs="SetOutputs",_t="ShowLoginOverlay",un="UserLoggedIn",Zu="UserLoggedOut",Ae="ApplySuggestion",Us="ApplyImageSuggestion",Yu="ShowCommandPalette",co="ShowNicknameDialog",po="ReduxAction",em="RemovePinnedSuggestion",tm=t=>({[Bs]:e=>{t.dispatch(S(y({},e),{isBroadcasted:!0}))},[po]:e=>{e.isBroadcasted||t.dispatch(S(y({},e),{isBroadcasted:!0}))},[em]:e=>{t.dispatch(rt(e))},[Yu]:e=>{t.dispatch(ge(e.isOpen)),e.page&&t.dispatch(Dt(e.page))},[co]:e=>{t.dispatch(va(e.showNicknameDialog))},[_t]:e=>{t.dispatch(Wi(e))},[un]:()=>{t.dispatch(Le())},[Zu]:()=>{t.dispatch(Le())},[Us]:e=>{t.dispatch(no({suggestion:e.suggestion}))},[Ae]:e=>{t.dispatch(se(S(y({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),ka=tm;import Ra,{useContext as nm}from"react";import{jsx as om}from"react/jsx-runtime";var Pa=Ra.createContext(null),Me=({broadcastEvents:t,children:e})=>{let n=Ra.useMemo(()=>t,[]);return om(Pa.Provider,{value:n,children:e})},ne=()=>{let t=nm(Pa);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import Qs from"classnames";import{useCallback as Ua,useEffect as Pm,useMemo as Im,useState as Zs}from"react";import{useDispatch as Lm,useSelector as Am}from"react-redux";import{createContext as hm,useContext as ym}from"react";var Ks=function(t,e){return Ks=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},Ks(t,e)};function mn(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ks(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var re=function(){return re=Object.assign||function(e){for(var n,o=1,s=arguments.length;o<s;o++){n=arguments[o];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},re.apply(this,arguments)};function Ia(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(n[o[s]]=t[o[s]]);return n}function uo(t,e,n){if(n||arguments.length===2)for(var o=0,s=e.length,r;o<s;o++)(r||!(o in e))&&(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}function mo(t,e){var n=e&&e.cache?e.cache:cm,o=e&&e.serializer?e.serializer:lm,s=e&&e.strategy?e.strategy:rm;return s(t,{cache:n,serializer:o})}function sm(t){return t==null||typeof t=="number"||typeof t=="boolean"}function La(t,e,n,o){var s=sm(o)?o:n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.call(this,o),e.set(s,r)),r}function Aa(t,e,n){var o=Array.prototype.slice.call(arguments,3),s=n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.apply(this,o),e.set(s,r)),r}function zs(t,e,n,o,s){return n.bind(e,t,o,s)}function rm(t,e){var n=t.length===1?La:Aa;return zs(t,this,n,e.cache.create(),e.serializer)}function im(t,e){return zs(t,this,Aa,e.cache.create(),e.serializer)}function am(t,e){return zs(t,this,La,e.cache.create(),e.serializer)}var lm=function(){return JSON.stringify(arguments)},dm=(function(){function t(){this.cache=Object.create(null)}return t.prototype.get=function(e){return this.cache[e]},t.prototype.set=function(e,n){this.cache[e]=n},t})(),cm={create:function(){return new dm}},go={variadic:im,monadic:am};var fo;(function(t){t[t.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",t[t.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",t[t.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",t[t.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",t[t.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",t[t.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",t[t.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",t[t.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",t[t.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",t[t.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",t[t.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",t[t.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",t[t.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",t[t.INVALID_TAG=23]="INVALID_TAG",t[t.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",t[t.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",t[t.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(fo||(fo={}));var ho=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var de;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(de||(de={}));var yo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(yo||(yo={}));function Ws(t){return t.type===de.literal}function Vs(t){return t.type===de.argument}function gn(t){return t.type===de.number}function fn(t){return t.type===de.date}function hn(t){return t.type===de.time}function yn(t){return t.type===de.select}function vn(t){return t.type===de.plural}function Ma(t){return t.type===de.pound}function xn(t){return t.type===de.tag}function vo(t){return!!(t&&typeof t=="object"&&t.type===yo.number)}function Sn(t){return!!(t&&typeof t=="object"&&t.type===yo.dateTime)}function js(t){t.forEach(function(e){if(delete e.location,yn(e)||vn(e))for(var n in e.options)delete e.options[n].location,js(e.options[n].value);else gn(e)&&vo(e.style)||(fn(e)||hn(e))&&Sn(e.style)?delete e.style.location:xn(e)&&js(e.children)})}function Na(t,e){e===void 0&&(e={}),e=re({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new ho(t,e).parse();if(n.err){var o=SyntaxError(fo[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||js(n.val),n.val}var lt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(lt||(lt={}));var bn=(function(t){mn(e,t);function e(n,o,s){var r=t.call(this,n)||this;return r.code=o,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e})(Error);var $s=(function(t){mn(e,t);function e(n,o,s,r){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(s).join('", "'),'"'),lt.INVALID_VALUE,r)||this}return e})(bn);var Oa=(function(t){mn(e,t);function e(n,o,s){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),lt.INVALID_VALUE,s)||this}return e})(bn);var Da=(function(t){mn(e,t);function e(n,o){return t.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(o,'"'),lt.MISSING_VALUE,o)||this}return e})(bn);var Q;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(Q||(Q={}));function pm(t){return t.length<2?t:t.reduce(function(e,n){var o=e[e.length-1];return!o||o.type!==Q.literal||n.type!==Q.literal?e.push(n):o.value+=n.value,e},[])}function um(t){return typeof t=="function"}function Cn(t,e,n,o,s,r,i){if(t.length===1&&Ws(t[0]))return[{type:Q.literal,value:t[0].value}];for(var a=[],d=0,l=t;d<l.length;d++){var c=l[d];if(Ws(c)){a.push({type:Q.literal,value:c.value});continue}if(Ma(c)){typeof r=="number"&&a.push({type:Q.literal,value:n.getNumberFormat(e).format(r)});continue}var u=c.value;if(!(s&&u in s))throw new Da(u,i);var p=s[u];if(Vs(c)){(!p||typeof p=="string"||typeof p=="number")&&(p=typeof p=="string"||typeof p=="number"?String(p):""),a.push({type:typeof p=="string"?Q.literal:Q.object,value:p});continue}if(fn(c)){var f=typeof c.style=="string"?o.date[c.style]:Sn(c.style)?c.style.parsedOptions:void 0;a.push({type:Q.literal,value:n.getDateTimeFormat(e,f).format(p)});continue}if(hn(c)){var f=typeof c.style=="string"?o.time[c.style]:Sn(c.style)?c.style.parsedOptions:o.time.medium;a.push({type:Q.literal,value:n.getDateTimeFormat(e,f).format(p)});continue}if(gn(c)){var f=typeof c.style=="string"?o.number[c.style]:vo(c.style)?c.style.parsedOptions:void 0;f&&f.scale&&(p=p*(f.scale||1)),a.push({type:Q.literal,value:n.getNumberFormat(e,f).format(p)});continue}if(xn(c)){var g=c.children,m=c.value,h=s[m];if(!um(h))throw new Oa(m,"function",i);var b=Cn(g,e,n,o,s,r),T=h(b.map(function(I){return I.value}));Array.isArray(T)||(T=[T]),a.push.apply(a,T.map(function(I){return{type:typeof I=="string"?Q.literal:Q.object,value:I}}))}if(yn(c)){var C=c.options[p]||c.options.other;if(!C)throw new $s(c.value,p,Object.keys(c.options),i);a.push.apply(a,Cn(C.value,e,n,o,s));continue}if(vn(c)){var C=c.options["=".concat(p)];if(!C){if(!Intl.PluralRules)throw new bn(`Intl.PluralRules is not available in this environment.
|
|
2
2
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
3
|
-
`,lt.MISSING_INTL_API,i);var w=n.getPluralRules(e,{type:c.pluralType}).select(p-(c.offset||0));C=c.options[w]||c.options.other}if(!C)throw new js(c.value,p,Object.keys(c.options),i);a.push.apply(a,Cn(C.value,e,n,o,s,p-(c.offset||0)));continue}}return pg(a)}function gg(t,e){return e?re(re(re({},t||{}),e||{}),Object.keys(t).reduce(function(n,o){return n[o]=re(re({},t[o]),e[o]||{}),n},{})):t}function mg(t,e){return e?Object.keys(t).reduce(function(n,o){return n[o]=gg(t[o],e[o]),n},re({},t)):t}function $s(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,n){t[e]=n}}}}}function fg(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:go(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,uo([void 0],n,!1)))},{cache:$s(t.number),strategy:mo.variadic}),getDateTimeFormat:go(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,uo([void 0],n,!1)))},{cache:$s(t.dateTime),strategy:mo.variadic}),getPluralRules:go(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,uo([void 0],n,!1)))},{cache:$s(t.pluralRules),strategy:mo.variadic})}}var Gs=(function(){function t(e,n,o,s){n===void 0&&(n=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(l){var c=r.formatToParts(l);if(c.length===1)return c[0].value;var u=c.reduce(function(p,f){return!p.length||f.type!==Q.literal||typeof p[p.length-1]!="string"?p.push(f.value):p[p.length-1]+=f.value,p},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(l){return Cn(r.ast,r.locales,r.formatters,r.formats,l,void 0,r.message)},this.resolvedOptions=function(){var l;return{locale:((l=r.resolvedLocale)===null||l===void 0?void 0:l.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=n,this.resolvedLocale=t.resolveLocale(n),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,d=Pa(i,["formatters"]);this.ast=t.__parse(e,re(re({},d),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=mg(t.formats,o),this.formatters=s&&s.formatters||fg(this.formatterCache)}return Object.defineProperty(t,"defaultLocale",{get:function(){return t.memoizedDefaultLocale||(t.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),t.memoizedDefaultLocale},enumerable:!1,configurable:!0}),t.memoizedDefaultLocale=null,t.resolveLocale=function(e){if(typeof Intl.Locale!="undefined"){var n=Intl.NumberFormat.supportedLocalesOf(e);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Ma,t.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},t})();function vg(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var xg="dummy",qs=hg(null);function R(t){var o;let e=yg(qs);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=(o=t[e])!=null?o:{};return(s,r)=>{let i=vg(n,s);return i?new Gs(i).format(r):(e!==xg&&console.warn(`${s} does not exist in messages of ${e}`),`[${s}]`)}}import{useEffect as Sg,useRef as bg}from"react";var Da={root:"dd-tvkOF",content:"dd-eXA1D"};import{jsx as _a}from"react/jsx-runtime";var Cg=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:s,onKeyDown:r,overlayAriaLabel:i,contentAriaLabel:a})=>{let d=bg(null),l=x("Dialog",Da),c=p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),s();return}r&&r(p)},u=p=>{p.target===d.current&&t&&o()};return Sg(()=>{var p,f;!d.current||!t||!e||(f=(p=d.current)==null?void 0:p.querySelector("input, textarea"))==null||f.focus()},[t,e,d]),t?_a("div",{role:"dialog","data-testid":"dialog",className:l.root,"aria-label":i,ref:d,onKeyDown:c,onMouseDown:u,children:_a("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:n})}):null},Ft=Cg;import Tg from"classnames";var Fa={root:"dd-ranhW"};import{jsx as Eg}from"react/jsx-runtime";var wg=o=>{var s=o,{className:t,value:e}=s,n=A(s,["className","value"]);let r=x("TextInput",Fa);return Eg("input",y({className:Tg(t,r.root),type:"text",value:e},n))},Tn=wg;var Xs={};X(Xs,{enUS:()=>kg,nlNL:()=>Rg});var kg={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},Rg={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var Ha={root:"dd-lWxnE",anchorButton:"dd-TZ4in",errorMessage:"dd-fIsPg",title:"dd-pGhJx",subtitle:"dd-f5l29",text:"dd-iamoD",input:"dd-uhQZ3",actions:"dd-lubvx",button:"dd-CJsNI",primaryButton:"dd-MWBfl"};import{jsx as oe,jsxs as xo}from"react/jsx-runtime";var Mg=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch(e){return t}},Ng=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:s})=>{let r=R(Xs),i=x("LoginTokenDialog",Ha),a=Ag(Fi),d=Lg(),l=E("productName"),[c,u]=Qs(t||""),[p,f]=Qs(0),[m,g]=Qs(""),h=Ba(w=>v(null,null,function*(){w.preventDefault(),d(Ui({email:c})),f(1)}),[n,c]),b=()=>{g(""),f(0)},T=Ba(w=>v(null,null,function*(){w.preventDefault();let I=Mg(w.target.elements.token.value);if(!I){g(r("verifyCodeError",{login:C}));return}d(ln({token:I}))}),[n]),C=Ig(()=>w=>oe("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:b,children:w},"back-button"),[]);return Pg(()=>{a==="error"&&g(r("verifyCodeError",{login:C})),a==="done"&&o()},[a]),oe(Ft,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:l}),overlayAriaLabel:r("promptTitle",{productName:l}),onClose:s,onBack:s,children:xo("div",{className:i.root,children:[oe("h1",{className:i.title,children:r("promptTitle",{productName:l})}),p===0&&xo("form",{onSubmit:h,children:[oe("h2",{className:i.subtitle,children:r("requestCodeTitle")}),oe("p",{className:i.text,children:r("requestCodeBody",{productName:l})}),oe(Tn,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:c,onChange:w=>u(w.target.value)}),oe("div",{className:i.actions,children:oe("button",{type:"submit",className:Js(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),p===1&&xo("form",{onSubmit:T,children:[oe("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),oe("p",{className:i.text,children:r("verifyCodeBody")}),oe(Tn,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&oe("div",{className:i.errorMessage,children:m}),xo("div",{className:i.actions,children:[oe("button",{type:"button",className:Js(i.button),onClick:b,children:r("back")}),oe("button",{type:"submit",className:Js(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Ua=Ng;import{jsx as Dg}from"react/jsx-runtime";var Og=()=>{let t=Ka(Hi),e=Ka(Ot),n=E("adminUrl"),o=ne(),s=()=>o.send(_t,!1),r=()=>{o.send(_t,!1),o.send(un)};return Dg(Ua,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:s,onSuccess:r})},za=Og;import xf from"lodash.debounce";import{Fragment as Sf,useCallback as Fl,useEffect as Hl,useMemo as bf,useState as ur}from"react";import{useDispatch as Cf,useSelector as ut}from"react-redux";import{createAsyncThunk as _g,createSlice as Fg}from"@reduxjs/toolkit";var Hg={data:null,fetchState:"idle"},Wa=t=>t.contentTypes.data,wn=_g("contentTypes/getContentTypes",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),Bg=Fg({name:"contentTypes",initialState:Hg,reducers:{},extraReducers:t=>{t.addCase(wn.pending,e=>{e.fetchState="loading"}).addCase(wn.rejected,e=>{e.fetchState="error"}).addCase(wn.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),Va=Bg.reducer;import{createAsyncThunk as Ug,createSelector as Kg,createSlice as zg}from"@reduxjs/toolkit";var Wg={data:null,fetchState:"idle"},Vg=[],dt=t=>t.profile.data,jg=t=>t.profile.data?t.profile.data.uiConfig.widget.types:Vg,kn=Kg([jg],t=>t.filter(e=>e.isActive)),ja=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},$a=t=>e=>kn(e).find(n=>n.type===t),Ga=t=>t.profile.data?!!t.profile.data.uiConfig.widget.types.find(e=>e.type==="custom-data"):!1,qa=t=>{var e,n;return(n=(e=t.profile.data)==null?void 0:e.knowledgeAssistantNew)!=null?n:null},En=Ug("profile/getProfile",(t,e)=>v(null,null,function*(){var r;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=o.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=o.profile.data)==null?void 0:r.code)===s.profileCode?o.profile.data:n.getProfile(s.profileCode)})),$g=zg({name:"profile",initialState:Wg,reducers:{},extraReducers:t=>{t.addCase(En.pending,e=>{e.fetchState="loading"}).addCase(En.rejected,e=>{e.fetchState="error"}).addCase(En.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),Xa=$g.reducer;function Se(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}import{useEffect as yl,useState as Dm,useRef as _m,useCallback as Fm}from"react";import{useState as Xg}from"react";import Zs from"classnames";var ie={root:"dd-U2SX4",list:"dd-cYTlj",listWrapper:"dd-GLQFR",listHorizontal:"dd-x-knl",page:"dd-1F4vk",search:"dd-nvbxc",pageNav:"dd-sRUuT",pageTitle:"dd-t-MKS",pageBackButton:"dd-cjptm",listHeader:"dd-Fg666",listHeading:"dd-w-xhJ",listMoreButton:"dd--mKep",listItem:"dd-wpvuA",listItemContent:"dd-V-mKo",listItemText:"dd-ukCHL",listItemDescription:"dd-sSyu4",listItemActions:"dd-xelho",listItemTooltip:"dd-SWFsE",listItemTooltipContent:"dd-I7J9N",truncate:"dd-IlopJ",lineClamp:"dd-Twaca",listItemTitle:"dd-lMGHq",listItemAction:"dd-xPLAs",listItemSelected:"dd-jFX0Y",sources:"dd-pZx4v",sourcesTitle:"dd-phYVd",source:"dd-DaR6h",sourceShowMore:"dd-M1-8j",icon:"dd-m6yxD",searchIcon:"dd-0AU-O",searchInputWrapper:"dd-DUFcE",searchInput:"dd-ukrlD",select:"dd--Tifv",selectType:"dd-IkZb2",selectWrapper:"dd-J14mx",image:"dd-RQgsB",imageSrc:"dd-jxh8F",imageSrcHidden:"dd-e20Jk",imageSrcStatus:"dd-j50Tt",imageTitle:"dd-qCjfW",actions:"dd-3mfWc",actionsWrapper:"dd-TjDyI",actionsBar:"dd-LiA35",actionButton:"dd-4wk0u",hasShortKeys:"dd-XilV-",actionShortcut:"dd-s4Mla",actionShortcutFixKerning:"dd-lyh5e"};var Ne={};X(Ne,{enUS:()=>Gg,nlNL:()=>qg});var Gg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}],sources:[{type:0,value:"Sources"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},qg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}],sources:[{type:0,value:"Bronnen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};import{jsx as Rn,jsxs as Qg}from"react/jsx-runtime";var Jg=({src:t,title:e})=>{let n=x("CommandPalette",ie),[o,s]=Xg("loading"),r=R(Ne);return Qg("div",{className:n.image,children:[Rn("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:Zs(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&Rn("span",{className:Zs(n.imageSrc,n.imageSrcStatus),children:r("loading")}),o==="error"&&Rn("span",{className:Zs(n.imageSrc,n.imageSrcStatus),children:Rn(Vn,{})}),e&&Rn("span",{className:n.imageTitle,children:e})]})},Ja=Jg;import Zg from"react";import Yg from"classnames";import{jsx as Ys,jsxs as Qa}from"react/jsx-runtime";function er({children:t,heading:e,orientation:n,hasMore:o,onShowAll:s}){let r=R(Ne),i=x("CommandPalette",ie);return Zg.Children.count(t)===0?null:Qa("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||o)&&Qa("div",{className:i.listHeader,children:[e&&Ys("h4",{className:i.listHeading,children:e}),o&&s&&Ys("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),Ys("div",{className:Yg(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}import Co from"classnames";import{Interweave as il}from"interweave";import{useEffect as Em,useMemo as al,useState as ll}from"react";var em=/[.*+?^${}()|[\]\\]/g,tm=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function nm(t){return t.replace(em,"\\$&")}function om(t,e){let n=t.split("").findIndex((o,s)=>o!==e[s]);return n>-1?n:Math.min(t.length,e.length)}function sm(t){return t.search(tm)}function Za(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let s=new RegExp(`\\b(${nm(o)})\\b`,"gi");n=n.replace(s,"<strong>$1</strong>")}),n}function Ya(t){return t.replace(qn,'<mark data-type="placeholder">$1</mark>')}function Pn(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function rm(t,e){return t.split("").map((i,a)=>({char:i,index:a})).filter(({char:i,index:a})=>/\s/.test(i)&&a<=e).map(({index:i})=>i).reverse()[0]}function tr(t,e,n={}){if(e){let o=om(e.toLowerCase(),t.toLowerCase()),s=Pn(t.substring(o,t.length));if(n.stripAgentPart){let d=t.substring(0,o),l=sm(d);return`<span style="opacity: 0.5">${d.substring(l+1)}</span>${s}`}let i=e.split(Mi).length>3||e.length>30?rm(e.trim(),o):0;return`${`${i>0?"\u2026":""}${Pn(t.substring(i,o))}`}<strong>${s}</strong>`}return t}var im=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function So(t){return im.test(t)}function nr(t){var n;let e=document.createElement("template");return e.innerHTML=t,(n=e.content.textContent)!=null?n:""}import or from"react";import{jsx as am}from"react/jsx-runtime";var el=or.createContext(void 0);function Ht(){let t=or.useContext(el);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var tl=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r})=>{let i=or.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r}),[n,e,s]);return am(el.Provider,{value:i,children:t})};import*as be from"react";import{useFloating as lm,autoUpdate as dm,useClick as cm,useDismiss as pm,useRole as um,useInteractions as gm,useMergeRefs as ol,FloatingPortal as mm,FloatingFocusManager as fm,useHover as hm,offset as ym,flip as vm,shift as xm,safePolygon as Sm}from"@floating-ui/react";var bo={tooltip:"dd-XpCXd",tooltipTrigger:"dd-8TKeF",arrow:"dd-ZEu2Y"};import{jsx as qe,jsxs as nl}from"react/jsx-runtime";function bm({initialOpen:t=!1,placement:e="bottom",modal:n,tooltip:o,open:s,onOpenChange:r}={}){let[i,a]=be.useState(t),d=s!=null?s:i,l=r!=null?r:a,c=lm({placement:e,open:d,onOpenChange:l,whileElementsMounted:dm,middleware:[ym(5),vm({crossAxis:e.includes("-"),fallbackAxisSideDirection:"end",padding:5}),xm({padding:10})]}),u=c.context,p=cm(u,{enabled:s==null}),f=pm(u),m=um(u),g=hm(u,{enabled:o!=null?o:!1,handleClose:Sm()}),h=gm([p,f,m,g]);return be.useMemo(()=>S(y(y({open:d,setOpen:l},h),c),{modal:n}),[d,l,h,c,n])}var sl=be.createContext(null),sr=()=>{let t=be.useContext(sl);if(t==null)throw new Error("Popover components must be wrapped in <Popover />");return t},ct=o=>{var s=o,{children:t,modal:e=!1}=s,n=A(s,["children","modal"]);let r=bm(y({modal:e},n));return qe(sl.Provider,{value:r,children:t})};function Cm(o){var s=o,{as:t,children:e}=s,n=A(s,["as","children"]);let r=sr(),i=t||"button",a=e.ref,d=ol([r.refs.setReference,a]);return qe(i,S(y({ref:d,type:"button"},r.getReferenceProps(n)),{children:e}))}var Tm=be.forwardRef(function(s,o){var r=s,{style:e}=r,n=A(r,["style"]);let l=sr(),{context:i}=l,a=A(l,["context"]),d=ol([a.refs.setFloating,o]);return i.open?qe(mm,{children:qe(fm,{context:i,modal:a.modal,disabled:n.disableFocusManager,children:qe("div",S(y({ref:d,style:y(S(y({},a.floatingStyles),{zIndex:1e7}),e)},a.getFloatingProps(n)),{children:n.children}))})}):null});function wm(s){var r=s,{as:t,children:e,onClick:n}=r,o=A(r,["as","children","onClick"]);let{setOpen:i}=sr();return qe(t||"button",S(y({type:"button",onClick:l=>{n(l),i(!1),l.stopPropagation()}},o),{children:e}))}function rl({trigger:t,children:e,placement:n="top"}){return nl(ct,{tooltip:!0,placement:n,children:[nl(ct.Content,{className:bo.tooltip,children:[e,qe("div",{className:bo.arrow})]}),qe(ct.Trigger,{className:bo.tooltipTrigger,children:t})]})}ct.Trigger=Cm;ct.Content=Tm;ct.Button=wm;var $=ct;import{jsx as Oe,jsxs as To}from"react/jsx-runtime";var km=3,Rm=90,dl=({children:t})=>{let e=x("CommandPalette",ie);return Oe("div",{className:e.listItemActions,children:t})};function rr(f){var m=f,{closeOnSelect:t=!0,lineClamp:e,tooltip:n,children:o,onClick:s,extra:r,onSourceClick:i,description:a,sources:d,id:l,styles:c,defaultSourcesAmount:u=km}=m,p=A(m,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var ae;let g=R(Ne),[h,b]=ll(!1),{selected:T,onChangeOpen:C}=Ht(),[w,I]=ll(!1),N=x("CommandPalette",ie);function _(O){s(O),t&&C(!1)}let W=al(()=>typeof a!="string"?a:So(a)?nr(a).trim():a,[a]),ce=al(()=>typeof n!="string"?n:So(n)?nr(n).trim():n,[n]);return Em(()=>{I(T===l)},[T]),To("div",{className:Co(N.listItem,l===T&&N.listItemSelected),children:[To($,{placement:"right-start",tooltip:!0,onOpenChange:I,open:w,children:[Oe($.Trigger,S(y({className:N.listItemAction,"aria-disabled":(ae=p.disabled)!=null?ae:!1,onClick:_,"data-command-palette-item":!0,"data-item-id":l},p),{children:To("div",{className:N.listItemContent,children:[typeof o=="string"?Oe("p",{className:Co(N.listItemText,N.truncate,c==null?void 0:c.title),children:o}):o,W&&typeof W=="string"?Oe(il,{tagName:"p",allowList:[],content:W,className:Co(N.listItemDescription,c==null?void 0:c.description,e?N.lineClamp:N.truncate)}):a]})})),ce&&ce.length>Rm&&Oe($.Content,{className:N.listItemTooltip,disableFocusManager:!0,children:Oe(il,{className:N.listItemTooltipContent,allowList:["h1","h2","h3","h4","h5","h6","a","p","br"],tagName:"div",content:ce.replace(/\n/g,"<br />")})})]}),l===T&&r,d&&d.length>0&&To("div",{className:N.sources,children:[Oe("span",{className:N.sourcesTitle,children:g("sources")}),d.slice(0,h?d.length:u).map(O=>Oe("a",{className:N.source,href:O.url,target:"_blank",title:O.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i==null?void 0:i(O),children:O.name},O.url)),!h&&d.length>u&&Oe("button",{className:Co(N.source,N.sourceShowMore),type:"button",onClick:()=>b(!0),children:g("showMore",{amount:d.length-u})})]})]})}import{jsx as cl,jsxs as Pm}from"react/jsx-runtime";var pl=()=>Pm("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[cl("title",{id:"angleLeftTitle",children:"AngleLeft"}),cl("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});import{jsx as ul,jsxs as ir}from"react/jsx-runtime";function ar({children:t,title:e,id:n,onDismiss:o}){let s=R(Ne),r=x("CommandPalette",ie),{page:i}=Ht();return i!==n?null:ir("div",{className:r.page,id:`page_${n}`,tabIndex:-1,children:[o&&ir("div",{className:r.pageNav,children:[ir("button",{className:r.pageBackButton,type:"button",onClick:o,children:[ul(pl,{}),s("back")]}),e&&ul("h3",{className:r.pageTitle,children:e})]}),t]})}import{forwardRef as Lm}from"react";import{jsx as gl,jsxs as Im}from"react/jsx-runtime";var Bt=()=>Im("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[gl("path",{d:"M0 0h24v24H0z",fill:"none"}),gl("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});import{jsx as Ut,jsxs as lr}from"react/jsx-runtime";function Am({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:s,value:r,selectedType:i},a){let d=x("CommandPalette",ie);return lr("div",{className:d.search,children:[Ut("div",{className:d.searchIcon,children:Ut(Bt,{})}),lr("div",{className:d.searchInputWrapper,children:[Ut("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:l=>{t(l.currentTarget.value)},onFocus:l=>{l.currentTarget.select()},className:d.searchInput,placeholder:n,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&Ut("div",{className:d.selectWrapper,children:lr("select",{"data-testid":"command-palette-type-select",className:d.select,onChange:l=>e(l.target.value===o?void 0:l.target.value),value:i||o,children:[o&&Ut("option",{children:o}),s.map(l=>Ut("option",{value:l.value,children:l.label},l.value))]})})]})]})}var ml=Lm(Am);import fl from"classnames";import{jsx as Nm,jsxs as Om}from"react/jsx-runtime";var Mm=s=>{var r=s,{onClick:t,shortKeys:e,children:n}=r,o=A(r,["onClick","shortKeys","children"]);let i=x("CommandPalette",ie);return Om("button",S(y({type:"button"},o),{onClick:t,className:fl(i.actionButton,o.className,{[i.hasShortKeys]:e&&e.length>0}),children:[n,e==null?void 0:e.map(a=>Nm("span",{className:fl(i.actionShortcut,a===8629&&i.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},hl=Mm;import{jsx as vl,jsxs as Bm}from"react/jsx-runtime";var Hm="[data-command-palette-item]";function pt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:d,types:l,children:c,isOpen:u,search:p,updateDeps:f=[]}){let[m,g]=Dm(),h=_m(null),b=()=>{s&&s(n),i(void 0),r(""),a(!1)},T=()=>{var O;if(o!==n&&s){s(n);return}if(d&&i){i(void 0),(O=h.current)==null||O.focus();return}if(p.length>0){r("");return}a(!1)},C=()=>{let O=w();O.length!==0&&g(O[0].dataset.itemId)},w=()=>Array.from(document.querySelectorAll(Hm)||[]),I=O=>document.querySelector(`[data-item-id=${O}]`),N=O=>{let U=I(O);U&&g(U.dataset.itemId)},_=O=>{let U=I(O);U&&U.scrollIntoView({behavior:"smooth"})},W=()=>{if(!m)return;let O=w(),U=I(m);if(!U)return;let Pe=O.indexOf(U),le=O[Pe+1];le!=null&&le.dataset.itemId?N(le.dataset.itemId):C()},ce=()=>{if(!m)return;let O=w(),U=I(m);if(!U)return;let Pe=O.indexOf(U),le=O[Pe-1];le!=null&&le.dataset.itemId?N(le.dataset.itemId):N(O[O.length-1].dataset.itemId)},ae=Fm(O=>{switch(O.key){case"ArrowDown":{O.preventDefault(),W();break}case"ArrowUp":{O.preventDefault(),ce();break}case"Enter":{if(m){let U=I(m);U==null||U.click()}break}}},[m]);return yl(()=>{C()},[p,o,d,u,...f]),yl(()=>{m&&_(m)},[m]),vl(Ft,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:T,onClose:b,onKeyDown:ae,children:Bm(tl,{selected:m,setSelected:g,isOpen:u,onChangeOpen:a,page:o,children:[o===n&&vl(ml,{ref:h,onChange:r,onChangeType:i,placeholder:t,value:p,selectedType:d,types:l,typePlaceholder:e}),c]})})}pt.Page=ar;pt.List=er;pt.Image=Ja;pt.ListItem=rr;pt.ListItemActions=dl;pt.Button=hl;var G=pt;import{useEffect as Um}from"react";function xl(t,e){Um(()=>{let n=o=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}import{useEffect as Tl,useRef as Xm}from"react";import{useSelector as Jm,useDispatch as Qm}from"react-redux";import{createAsyncThunk as Km,createSelector as zm,createSlice as Wm}from"@reduxjs/toolkit";var Sl={data:null,fetchState:"idle"},Vm=t=>{var e;return(e=t.entities.data)!=null?e:null},wo=zm([Vm,Ot,ca],(t,e,n)=>{var a;let o=[],{visitorName:s}=n!=null?n:{},{agentName:r,agentNickname:i}=e!=null?e:{};return r&&r!==s&&o.push(r),i&&i!==s&&o.push(i),(a=t==null?void 0:t.filter(d=>!o.includes(d.text)))!=null?a:null}),fe=Km("entities/getEntities",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let s=o.conversationQuery,r=yield s();return r.length===0?Promise.resolve([]):n.getEntities(r)})),jm=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),$m=Wm({name:"entities",initialState:Sl,reducers:{},extraReducers:t=>{t.addCase(fe.pending,e=>{e.fetchState="loading"}).addCase(fe.rejected,e=>{e.fetchState="error"}).addCase(fe.fulfilled,(e,n)=>{e.fetchState="done",e.data=jm(e.data?[...e.data,...n.payload]:n.payload)}).addCase(V,()=>Sl)}}),bl=$m.reducer;var dr={};X(dr,{enUS:()=>Gm,nlNL:()=>qm});var Gm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},qm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Cl={root:"dd-TYTKs",empty:"dd-AU7uT"};import{jsx as cr,jsxs as Ym}from"react/jsx-runtime";var Zm=({onCopy:t})=>{let e=Xm(null),n=x("EntitiesList",Cl),o=Jm(wo),{setSelected:s}=Ht(),r=R(dr),i=Qm();return Tl(()=>{i(fe())},[]),Tl(()=>{e.current&&(e.current.focus(),s("entity-0"))},[e]),Ym("div",{className:n.root,ref:e,tabIndex:-1,children:[o&&o.length>0&&cr(G.List,{children:o.map((a,d)=>cr(G.ListItem,{id:`entity-${d}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),o&&o.length===0&&cr("p",{className:n.empty,children:r("noResults")})]})},wl=Zm;import{jsx as El}from"react/jsx-runtime";var Eo=t=>El("svg",S(y({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},t),{children:El("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})}));var In={};X(In,{enUS:()=>ef,nlNL:()=>tf});var ef={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},tf={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var Xe=t=>e=>{let{passwordlessToken:{token:n},settings:{isEmbedded:o,adminUrl:s}}=e,r=s||window.location.origin;return o&&!n?null:o&&n?`${r}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${r}${t}`};import{useSelector as kl}from"react-redux";var ko={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};import{useDispatch as of}from"react-redux";import{createAsyncThunk as nf}from"@reduxjs/toolkit";function pr(t){return nf("analytics/logEvent",(e,n)=>{var r,i,a;let o=(i=(r=n.getState())==null?void 0:r.conversation.current)==null?void 0:i.id,s=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,S(y({conversationId:o},s),{data:e.data}))})(t)}function K(){let t=of();return(e,n)=>v(null,null,function*(){yield t(pr({name:e,data:n}))})}import{jsx as Ro,jsxs as rf}from"react/jsx-runtime";var sf=({suggestion:t,source:e,context:n})=>{let o=R(In),s=kl(xe),r=K(),i=E("enableSuggestionFeedback"),a=`${t.text}`,d=kl(Xe(`/admin/feedback?conversationId=${s}&type=${e}&text=${a}&data=${JSON.stringify({context:n})}`)),l=()=>{r("suggestion feedback",{text:t.text,source:e,context:n})};return!i||!d?null:rf($,{placement:"top-end",children:[Ro($.Trigger,{className:ko.trigger,children:Ro(Eo,{"data-testid":"feedback-dropdown-trigger"})}),Ro($.Content,{className:ko.content,children:Ro($.Button,{className:ko.item,as:"a",onClick:l,target:"_blank",href:d,children:o("giveFeedback")})})]})},Po=sf;var Ln={};X(Ln,{enUS:()=>af,nlNL:()=>lf});var af={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"URL suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},lf={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"URL suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};import{useEffect as gf}from"react";import{useDispatch as mf,useSelector as ff}from"react-redux";import{createAction as pf,createAsyncThunk as Ll,createSlice as uf}from"@reduxjs/toolkit";var df=["{amount}"," {amount}","{date}","{email}","{iban}","{name}","{postal_code}","{street}","{tarif}","{usage}","{3_digits}","{4_digits}","{5_digits}","{6_digits}","{7_digits}","{8_digits}","{9_digits}","{10_digits}"],cf=new RegExp(df.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Rl(t,e){let n=t.split(cf),o=0,s=[];for(let r=0;r<n.length;r++){let i=n[r];if(s.push(i),r===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[r+1],d=r===n.length-2;o+=i.length;let l=o;if(d){let u=a.charAt(0),p=0;do l=u?e.indexOf(u,l+1):-1,p+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&p>2)return t}else l=a&&a!==""?e.indexOf(a,o):-1;let c=l===-1?e.slice(o):e.slice(o,l);s.push(c),o=l}return s.join("")}function Pl(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Al={suggestions:[],fetchState:"idle"},Il={default:Al},Ml=t=>e=>{var n,o;return(o=(n=e.textSuggestions[t])==null?void 0:n.suggestions)!=null?o:[]},Io=t=>t.textSuggestions,Nl=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Lo=pf("textSuggestions/refresh"),he=Ll("textSuggestions/recommendations",(t,e)=>v(null,null,function*(){var c,u,p;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:s}=o.info,{textSuggestionsCount:r,inlineSuggestions:i}=o.settings,a=At(o),d=(c=o.conversation.current)==null?void 0:c.id;if(!d)throw new Error("No current conversation to fetch text suggestions");if(!((u=o.profile.data)!=null&&u.recommendationEngine))return[];let l=[];if(t==="sticky-messages"){let f=(p=o.profile.data)==null?void 0:p.code;if(!f)throw new Error("No current profile to fetch pinned messages");l=yield n.getPinnedMessages(f)}else l=yield n.getTextSuggestions(d,pn(o),t);if(s&&(l=l.map(f=>y(S(y({},f),{text:ge(f.text,s)}),f.title?{title:ge(f.title,s)}:{}))),t==="default"){let f=i?l.filter(Nl(a)):l;e.dispatch(Ge(f.slice(0,r)))}return l})),An=Ll("textSuggestions/autocompletions",(t,e)=>v(null,null,function*(){var c,u;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(c=o.conversation.current)==null?void 0:c.id,{platformVariables:r}=o.info,{textSuggestionsCount:i,deanonymize:a,inlineSuggestions:d}=o.settings;if(!((u=o.profile.data)!=null&&u.recommendationEngine))return[];if(!s)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(s,S(y({},pn(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return d&&(l=l.filter(Nl(t))),r&&(l=l.map(p=>S(y({},p),{text:ge(p.text,r)}))),a&&(l=l.map(p=>S(y({},p),{text:p.source!=="trie-with-typos"?Rl(p.text,t):p.text}))),l=Pl(l,i),e.dispatch(Ge(l)),l})),Ol=uf({name:"textSuggestions",initialState:Il,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:n}=e.payload;t[n].fetchState="done",t[n].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}}},extraReducers:t=>{t.addCase(he.pending,(e,n)=>{let o=n.meta.arg,s=e[o]||Al;return S(y({},e),{[o]:S(y({},s),{fetchState:"loading"})})}).addCase(he.rejected,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="error")}).addCase(he.fulfilled,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="done",e[o].suggestions=n.payload)}).addCase(An.pending,e=>{e.default.fetchState="loading"}).addCase(An.rejected,e=>{e.default.fetchState="error"}).addCase(An.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(V,()=>Il)}}),{setTextSuggestions:AE}=Ol.actions,Dl=Ol.reducer;import{jsx as Ao,jsxs as yf}from"react/jsx-runtime";var hf=({types:t,commands:e,onClick:n})=>{let o=mf(),s=R(Ln),r=ff(Io);return gf(()=>{t.forEach(({type:i})=>{(!r[i]||r[i].suggestions.length===0)&&o(he(i))})},[]),yf("div",{children:[e.length>0&&Ao(G.List,{heading:s("commands"),children:e.map((i,a)=>Ao(G.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:i.onClick,children:i.label},i.label))}),t.map(({type:i,title:a})=>{var d;return Ao(G.List,{heading:a,orientation:"vertical",children:(d=r[i])==null?void 0:d.suggestions.map((l,c)=>Ao(G.ListItem,{id:`${i}-${c}`,closeOnSelect:!1,description:l.title&&l.text,onClick:()=>n(l.text,l),"data-testid":"search-overlay-suggestion",children:l.title||l.text},`${l.id}-${l.text}`))},i)})]})},_l=hf;import{jsx as Ce,jsxs as mr}from"react/jsx-runtime";var Tf=200,wf=5,Ef=4,gr=(t,e,n)=>t.slice(0,n?10:e.toLowerCase()==="image"?Ef:wf),kf=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Rf=()=>{var Pe,le,fi;let t=Cf(),e=ne(),n=R(Ln),[o,s]=ur(!1),[r,i]=ur(""),a=ut(Sa),d=ut(dt),[l,c]=ur(),u=ut(J),p=E("showSearch"),f=E("enableSuggestionFeedback"),m=E("showEntitiesCommand"),g=E("showImageSearch"),h=E("searchTriggerKey"),b=ut(Wa),T=ut(Fs),C=ut(ba),w=ut(xa),I=((fi=(le=(Pe=d==null?void 0:d.uiConfig)==null?void 0:Pe.search)==null?void 0:le.initialTypes)==null?void 0:fi.filter(({isActive:L})=>L))||[],N=K(),_=bf(()=>{let L=ee=>gr(T.filter(z=>z.type===ee.toUpperCase()),ee,l),j=(b==null?void 0:b.map(ee=>({value:ee.code.toUpperCase(),label:`${ee.name}s`,list:L(ee.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(j.push({value:"PERSONAL",label:n("personalSuggestions"),list:L("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:L("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:L("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),g&&j.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:L("IMAGE"),listOrientation:"horizontal"}),I.length===0)return j;let on=I.map(ee=>j.find(z=>z.value.toLowerCase()===ee.type)).filter(ee=>!!ee),Cs=j.filter(ee=>!on.find(z=>z.value===ee.value));return[...on,...Cs]},[b,I,g,l]),W=[{label:n("entitiesClipboard"),onClick:()=>t(Dt("entities")),shouldShow:m&&kf(n("entitiesClipboard"),r)}].filter(L=>L.shouldShow).filter(()=>!l),ce=Fl(xf((L,j)=>{t(at({query:L,type:j,tags:["search-overlay"],size:l?50:20}))},Tf),[l]),ae=Fl((L,j)=>{j.type==="IMAGE"?e.send(Bs,{suggestion:j}):e.send(Ae,{text:L,suggestion:j}),t(me(!1))},[t]),O=L=>{Se(L.text),N("entity copied",{entity:L,type:"copy"}),t(me(!1))};function U(L){return j=>{o?window.confirm(n("warning"))&&(L(j),s(!1)):L(j)}}return Hl(()=>{r?ce(r,l):t(lo())},[r,l]),Hl(()=>{u&&t(wn())},[u]),xl(h,()=>{t(me(!0)),N("open search",{via:"ctrl+k"})}),!p||!d?null:mr(G,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:U(L=>t(me(L))),onChangeType:L=>c(L),onChangePage:U(L=>t(Dt(L))),selectedType:l,search:r,page:a,isOpen:w,types:_,updateDeps:[T],children:[mr(G.Page,{id:"search",children:[r.length===0&&Ce(_l,{types:I,commands:W,onClick:ae}),r.length>0&&mr(Sf,{children:[W.length>0&&Ce(G.List,{heading:n("commands"),children:W.map((L,j)=>Ce(G.ListItem,{closeOnSelect:!1,onClick:L.onClick,id:`commands-${j}`,children:L.label},L.label))}),_.map(({value:L,label:j,list:on,lineClamp:Cs,listOrientation:ee})=>Ce(G.List,{heading:j,orientation:ee==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(L),hasMore:!l&&C[L.toLowerCase()]>gr(on,L,l).length,children:gr(on,L,l).map(z=>Ce(G.ListItem,{id:`${L}-${z.id}`,closeOnSelect:!1,lineClamp:Cs,onClick:()=>ae(z.text,z),description:L!=="IMAGE"?z.title&&z.text:void 0,tooltip:z.text,extra:f&&Ce(G.ListItemActions,{children:Ce(Po,{context:r,source:"search",suggestion:z})}),children:L==="IMAGE"?Ce(G.Image,{title:z.title||z.text,src:z.image}):z.title||z.text},`${z.id}-${z.text}`))},L))]})]}),Ce(G.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:U(()=>{t(Dt("search"))}),children:Ce(wl,{onCopy:O})})]})},Bl=Rf;import{jsx as Ul,jsxs as Lf}from"react/jsx-runtime";var If=()=>{let t=E("showSearch"),e=E("isEmbedded");return Lf(Pf,{children:[t&&Ul(Bl,{}),e&&Ul(za,{})]})},Kl=If;import Of from"classnames";import{useSelector as Df}from"react-redux";import{jsx as fr}from"react/jsx-runtime";var zl=({className:t})=>fr("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:t,children:fr("g",{children:fr("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
3
|
+
`,lt.MISSING_INTL_API,i);var w=n.getPluralRules(e,{type:c.pluralType}).select(p-(c.offset||0));C=c.options[w]||c.options.other}if(!C)throw new $s(c.value,p,Object.keys(c.options),i);a.push.apply(a,Cn(C.value,e,n,o,s,p-(c.offset||0)));continue}}return pm(a)}function mm(t,e){return e?re(re(re({},t||{}),e||{}),Object.keys(t).reduce(function(n,o){return n[o]=re(re({},t[o]),e[o]||{}),n},{})):t}function gm(t,e){return e?Object.keys(t).reduce(function(n,o){return n[o]=mm(t[o],e[o]),n},re({},t)):t}function Gs(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,n){t[e]=n}}}}}function fm(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:mo(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,uo([void 0],n,!1)))},{cache:Gs(t.number),strategy:go.variadic}),getDateTimeFormat:mo(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,uo([void 0],n,!1)))},{cache:Gs(t.dateTime),strategy:go.variadic}),getPluralRules:mo(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,uo([void 0],n,!1)))},{cache:Gs(t.pluralRules),strategy:go.variadic})}}var qs=(function(){function t(e,n,o,s){n===void 0&&(n=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(l){var c=r.formatToParts(l);if(c.length===1)return c[0].value;var u=c.reduce(function(p,f){return!p.length||f.type!==Q.literal||typeof p[p.length-1]!="string"?p.push(f.value):p[p.length-1]+=f.value,p},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(l){return Cn(r.ast,r.locales,r.formatters,r.formats,l,void 0,r.message)},this.resolvedOptions=function(){var l;return{locale:((l=r.resolvedLocale)===null||l===void 0?void 0:l.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=n,this.resolvedLocale=t.resolveLocale(n),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,d=Ia(i,["formatters"]);this.ast=t.__parse(e,re(re({},d),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=gm(t.formats,o),this.formatters=s&&s.formatters||fm(this.formatterCache)}return Object.defineProperty(t,"defaultLocale",{get:function(){return t.memoizedDefaultLocale||(t.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),t.memoizedDefaultLocale},enumerable:!1,configurable:!0}),t.memoizedDefaultLocale=null,t.resolveLocale=function(e){if(typeof Intl.Locale!="undefined"){var n=Intl.NumberFormat.supportedLocalesOf(e);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Na,t.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},t})();function vm(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var xm="dummy",Xs=hm(null);function R(t){var o;let e=ym(Xs);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=(o=t[e])!=null?o:{};return(s,r)=>{let i=vm(n,s);return i?new qs(i).format(r):(e!==xm&&console.warn(`${s} does not exist in messages of ${e}`),`[${s}]`)}}import{useEffect as Sm,useRef as bm}from"react";var _a={root:"dd-tvkOF",content:"dd-eXA1D"};import{jsx as Fa}from"react/jsx-runtime";var Cm=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:s,onKeyDown:r,overlayAriaLabel:i,contentAriaLabel:a})=>{let d=bm(null),l=x("Dialog",_a),c=p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),s();return}r&&r(p)},u=p=>{p.target===d.current&&t&&o()};return Sm(()=>{var p,f;!d.current||!t||!e||(f=(p=d.current)==null?void 0:p.querySelector("input, textarea"))==null||f.focus()},[t,e,d]),t?Fa("div",{role:"dialog","data-testid":"dialog",className:l.root,"aria-label":i,ref:d,onKeyDown:c,onMouseDown:u,children:Fa("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:n})}):null},Ft=Cm;import Tm from"classnames";var Ha={root:"dd-ranhW"};import{jsx as Em}from"react/jsx-runtime";var wm=o=>{var s=o,{className:t,value:e}=s,n=A(s,["className","value"]);let r=x("TextInput",Ha);return Em("input",y({className:Tm(t,r.root),type:"text",value:e},n))},Tn=wm;var Js={};X(Js,{enUS:()=>km,nlNL:()=>Rm});var km={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},Rm={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var Ba={root:"dd-lWxnE",anchorButton:"dd-TZ4in",errorMessage:"dd-fIsPg",title:"dd-pGhJx",subtitle:"dd-f5l29",text:"dd-iamoD",input:"dd-uhQZ3",actions:"dd-lubvx",button:"dd-CJsNI",primaryButton:"dd-MWBfl"};import{jsx as oe,jsxs as xo}from"react/jsx-runtime";var Mm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch(e){return t}},Nm=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:s})=>{let r=R(Js),i=x("LoginTokenDialog",Ba),a=Am(Hi),d=Lm(),l=E("productName"),[c,u]=Zs(t||""),[p,f]=Zs(0),[g,m]=Zs(""),h=Ua(w=>v(null,null,function*(){w.preventDefault(),d(Ki({email:c})),f(1)}),[n,c]),b=()=>{m(""),f(0)},T=Ua(w=>v(null,null,function*(){w.preventDefault();let I=Mm(w.target.elements.token.value);if(!I){m(r("verifyCodeError",{login:C}));return}d(ln({token:I}))}),[n]),C=Im(()=>w=>oe("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:b,children:w},"back-button"),[]);return Pm(()=>{a==="error"&&m(r("verifyCodeError",{login:C})),a==="done"&&o()},[a]),oe(Ft,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:l}),overlayAriaLabel:r("promptTitle",{productName:l}),onClose:s,onBack:s,children:xo("div",{className:i.root,children:[oe("h1",{className:i.title,children:r("promptTitle",{productName:l})}),p===0&&xo("form",{onSubmit:h,children:[oe("h2",{className:i.subtitle,children:r("requestCodeTitle")}),oe("p",{className:i.text,children:r("requestCodeBody",{productName:l})}),oe(Tn,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:c,onChange:w=>u(w.target.value)}),oe("div",{className:i.actions,children:oe("button",{type:"submit",className:Qs(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),p===1&&xo("form",{onSubmit:T,children:[oe("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),oe("p",{className:i.text,children:r("verifyCodeBody")}),oe(Tn,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),g&&oe("div",{className:i.errorMessage,children:g}),xo("div",{className:i.actions,children:[oe("button",{type:"button",className:Qs(i.button),onClick:b,children:r("back")}),oe("button",{type:"submit",className:Qs(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Ka=Nm;import{jsx as Dm}from"react/jsx-runtime";var Om=()=>{let t=za(Bi),e=za(Ot),n=E("adminUrl"),o=ne(),s=()=>o.send(_t,!1),r=()=>{o.send(_t,!1),o.send(un)};return Dm(Ka,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:s,onSuccess:r})},Wa=Om;import xf from"lodash.debounce";import{Fragment as Sf,useCallback as Hl,useEffect as Bl,useMemo as bf,useState as mr}from"react";import{useDispatch as Cf,useSelector as ut}from"react-redux";import{createAsyncThunk as _m,createSlice as Fm}from"@reduxjs/toolkit";var Hm={data:null,fetchState:"idle"},Va=t=>t.contentTypes.data,wn=_m("contentTypes/getContentTypes",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),Bm=Fm({name:"contentTypes",initialState:Hm,reducers:{},extraReducers:t=>{t.addCase(wn.pending,e=>{e.fetchState="loading"}).addCase(wn.rejected,e=>{e.fetchState="error"}).addCase(wn.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),ja=Bm.reducer;import{createAsyncThunk as Um,createSelector as Km,createSlice as zm}from"@reduxjs/toolkit";var Wm={data:null,fetchState:"idle"},Vm=[],dt=t=>t.profile.data,jm=t=>t.profile.data?t.profile.data.uiConfig.widget.types:Vm,kn=Km([jm],t=>t.filter(e=>e.isActive)),$a=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},Ga=t=>e=>kn(e).find(n=>n.type===t),qa=t=>t.profile.data?!!t.profile.data.uiConfig.widget.types.find(e=>e.type==="custom-data"):!1,Xa=t=>{var e,n;return(n=(e=t.profile.data)==null?void 0:e.knowledgeAssistantNew)!=null?n:null},En=Um("profile/getProfile",(t,e)=>v(null,null,function*(){var r;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=o.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=o.profile.data)==null?void 0:r.code)===s.profileCode?o.profile.data:n.getProfile(s.profileCode)})),$m=zm({name:"profile",initialState:Wm,reducers:{},extraReducers:t=>{t.addCase(En.pending,e=>{e.fetchState="loading"}).addCase(En.rejected,e=>{e.fetchState="error"}).addCase(En.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),Ja=$m.reducer;function Se(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}import{useEffect as vl,useState as Dg,useRef as _g,useCallback as Fg}from"react";import{useState as Xm}from"react";import Ys from"classnames";var ie={root:"dd-U2SX4",list:"dd-cYTlj",listWrapper:"dd-GLQFR",listHorizontal:"dd-x-knl",page:"dd-1F4vk",search:"dd-nvbxc",pageNav:"dd-sRUuT",pageTitle:"dd-t-MKS",pageBackButton:"dd-cjptm",listHeader:"dd-Fg666",listHeading:"dd-w-xhJ",listMoreButton:"dd--mKep",listItem:"dd-wpvuA",listItemContent:"dd-V-mKo",listItemText:"dd-ukCHL",listItemDescription:"dd-sSyu4",listItemActions:"dd-xelho",listItemTooltip:"dd-SWFsE",listItemTooltipContent:"dd-I7J9N",truncate:"dd-IlopJ",lineClamp:"dd-Twaca",listItemTitle:"dd-lMGHq",listItemAction:"dd-xPLAs",listItemSelected:"dd-jFX0Y",sources:"dd-pZx4v",sourcesTitle:"dd-phYVd",source:"dd-DaR6h",sourceShowMore:"dd-M1-8j",icon:"dd-m6yxD",searchIcon:"dd-0AU-O",searchInputWrapper:"dd-DUFcE",searchInput:"dd-ukrlD",select:"dd--Tifv",selectType:"dd-IkZb2",selectWrapper:"dd-J14mx",image:"dd-RQgsB",imageSrc:"dd-jxh8F",imageSrcHidden:"dd-e20Jk",imageSrcStatus:"dd-j50Tt",imageTitle:"dd-qCjfW",actions:"dd-3mfWc",actionsWrapper:"dd-TjDyI",actionsBar:"dd-LiA35",actionButton:"dd-4wk0u",hasShortKeys:"dd-XilV-",actionShortcut:"dd-s4Mla",actionShortcutFixKerning:"dd-lyh5e"};var Ne={};X(Ne,{enUS:()=>Gm,nlNL:()=>qm});var Gm={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}],sources:[{type:0,value:"Sources"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},qm={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}],sources:[{type:0,value:"Bronnen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};import{jsx as Rn,jsxs as Qm}from"react/jsx-runtime";var Jm=({src:t,title:e})=>{let n=x("CommandPalette",ie),[o,s]=Xm("loading"),r=R(Ne);return Qm("div",{className:n.image,children:[Rn("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:Ys(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&Rn("span",{className:Ys(n.imageSrc,n.imageSrcStatus),children:r("loading")}),o==="error"&&Rn("span",{className:Ys(n.imageSrc,n.imageSrcStatus),children:Rn(Vn,{})}),e&&Rn("span",{className:n.imageTitle,children:e})]})},Qa=Jm;import Zm from"react";import Ym from"classnames";import{jsx as er,jsxs as Za}from"react/jsx-runtime";function tr({children:t,heading:e,orientation:n,hasMore:o,onShowAll:s}){let r=R(Ne),i=x("CommandPalette",ie);return Zm.Children.count(t)===0?null:Za("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||o)&&Za("div",{className:i.listHeader,children:[e&&er("h4",{className:i.listHeading,children:e}),o&&s&&er("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),er("div",{className:Ym(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}import Co from"classnames";import{Interweave as al}from"interweave";import{useEffect as Eg,useMemo as ll,useState as dl}from"react";var eg=/[.*+?^${}()|[\]\\]/g,tg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function ng(t){return t.replace(eg,"\\$&")}function og(t,e){let n=t.split("").findIndex((o,s)=>o!==e[s]);return n>-1?n:Math.min(t.length,e.length)}function sg(t){return t.search(tg)}function Ya(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let s=new RegExp(`\\b(${ng(o)})\\b`,"gi");n=n.replace(s,"<strong>$1</strong>")}),n}function el(t){return t.replace(qn,'<mark data-type="placeholder">$1</mark>')}function Pn(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function rg(t,e){return t.split("").map((i,a)=>({char:i,index:a})).filter(({char:i,index:a})=>/\s/.test(i)&&a<=e).map(({index:i})=>i).reverse()[0]}function nr(t,e,n={}){if(e){let o=og(e.toLowerCase(),t.toLowerCase()),s=Pn(t.substring(o,t.length));if(n.stripAgentPart){let d=t.substring(0,o),l=sg(d);return`<span style="opacity: 0.5">${d.substring(l+1)}</span>${s}`}let i=e.split(Ni).length>3||e.length>30?rg(e.trim(),o):0;return`${`${i>0?"\u2026":""}${Pn(t.substring(i,o))}`}<strong>${s}</strong>`}return t}var ig=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function So(t){return ig.test(t)}function or(t){var n;let e=document.createElement("template");return e.innerHTML=t,(n=e.content.textContent)!=null?n:""}import sr from"react";import{jsx as ag}from"react/jsx-runtime";var tl=sr.createContext(void 0);function Ht(){let t=sr.useContext(tl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var nl=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r})=>{let i=sr.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r}),[n,e,s]);return ag(tl.Provider,{value:i,children:t})};import*as be from"react";import{useFloating as lg,autoUpdate as dg,useClick as cg,useDismiss as pg,useRole as ug,useInteractions as mg,useMergeRefs as sl,FloatingPortal as gg,FloatingFocusManager as fg,useHover as hg,offset as yg,flip as vg,shift as xg,safePolygon as Sg}from"@floating-ui/react";var bo={tooltip:"dd-XpCXd",tooltipTrigger:"dd-8TKeF",arrow:"dd-ZEu2Y"};import{jsx as qe,jsxs as ol}from"react/jsx-runtime";function bg({initialOpen:t=!1,placement:e="bottom",modal:n,tooltip:o,open:s,onOpenChange:r}={}){let[i,a]=be.useState(t),d=s!=null?s:i,l=r!=null?r:a,c=lg({placement:e,open:d,onOpenChange:l,whileElementsMounted:dg,middleware:[yg(5),vg({crossAxis:e.includes("-"),fallbackAxisSideDirection:"end",padding:5}),xg({padding:10})]}),u=c.context,p=cg(u,{enabled:s==null}),f=pg(u),g=ug(u),m=hg(u,{enabled:o!=null?o:!1,handleClose:Sg()}),h=mg([p,f,g,m]);return be.useMemo(()=>S(y(y({open:d,setOpen:l},h),c),{modal:n}),[d,l,h,c,n])}var rl=be.createContext(null),rr=()=>{let t=be.useContext(rl);if(t==null)throw new Error("Popover components must be wrapped in <Popover />");return t},ct=o=>{var s=o,{children:t,modal:e=!1}=s,n=A(s,["children","modal"]);let r=bg(y({modal:e},n));return qe(rl.Provider,{value:r,children:t})};function Cg(o){var s=o,{as:t,children:e}=s,n=A(s,["as","children"]);let r=rr(),i=t||"button",a=e.ref,d=sl([r.refs.setReference,a]);return qe(i,S(y({ref:d,type:"button"},r.getReferenceProps(n)),{children:e}))}var Tg=be.forwardRef(function(s,o){var r=s,{style:e}=r,n=A(r,["style"]);let l=rr(),{context:i}=l,a=A(l,["context"]),d=sl([a.refs.setFloating,o]);return i.open?qe(gg,{children:qe(fg,{context:i,modal:a.modal,disabled:n.disableFocusManager,children:qe("div",S(y({ref:d,style:y(S(y({},a.floatingStyles),{zIndex:1e7}),e)},a.getFloatingProps(n)),{children:n.children}))})}):null});function wg(s){var r=s,{as:t,children:e,onClick:n}=r,o=A(r,["as","children","onClick"]);let{setOpen:i}=rr();return qe(t||"button",S(y({type:"button",onClick:l=>{n(l),i(!1),l.stopPropagation()}},o),{children:e}))}function il({trigger:t,children:e,placement:n="top"}){return ol(ct,{tooltip:!0,placement:n,children:[ol(ct.Content,{className:bo.tooltip,children:[e,qe("div",{className:bo.arrow})]}),qe(ct.Trigger,{className:bo.tooltipTrigger,children:t})]})}ct.Trigger=Cg;ct.Content=Tg;ct.Button=wg;var $=ct;import{jsx as Oe,jsxs as To}from"react/jsx-runtime";var kg=3,Rg=90,cl=({children:t})=>{let e=x("CommandPalette",ie);return Oe("div",{className:e.listItemActions,children:t})};function ir(f){var g=f,{closeOnSelect:t=!0,lineClamp:e,tooltip:n,children:o,onClick:s,extra:r,onSourceClick:i,description:a,sources:d,id:l,styles:c,defaultSourcesAmount:u=kg}=g,p=A(g,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var ae;let m=R(Ne),[h,b]=dl(!1),{selected:T,onChangeOpen:C}=Ht(),[w,I]=dl(!1),N=x("CommandPalette",ie);function _(O){s(O),t&&C(!1)}let W=ll(()=>typeof a!="string"?a:So(a)?or(a).trim():a,[a]),ce=ll(()=>typeof n!="string"?n:So(n)?or(n).trim():n,[n]);return Eg(()=>{I(T===l)},[T]),To("div",{className:Co(N.listItem,l===T&&N.listItemSelected),children:[To($,{placement:"right-start",tooltip:!0,onOpenChange:I,open:w,children:[Oe($.Trigger,S(y({className:N.listItemAction,"aria-disabled":(ae=p.disabled)!=null?ae:!1,onClick:_,"data-command-palette-item":!0,"data-item-id":l},p),{children:To("div",{className:N.listItemContent,children:[typeof o=="string"?Oe("p",{className:Co(N.listItemText,N.truncate,c==null?void 0:c.title),children:o}):o,W&&typeof W=="string"?Oe(al,{tagName:"p",allowList:[],content:W,className:Co(N.listItemDescription,c==null?void 0:c.description,e?N.lineClamp:N.truncate)}):a]})})),ce&&ce.length>Rg&&Oe($.Content,{className:N.listItemTooltip,disableFocusManager:!0,children:Oe(al,{className:N.listItemTooltipContent,allowList:["h1","h2","h3","h4","h5","h6","a","p","br"],tagName:"div",content:ce.replace(/\n/g,"<br />")})})]}),l===T&&r,d&&d.length>0&&To("div",{className:N.sources,children:[Oe("span",{className:N.sourcesTitle,children:m("sources")}),d.slice(0,h?d.length:u).map(O=>Oe("a",{className:N.source,href:O.url,target:"_blank",title:O.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i==null?void 0:i(O),children:O.name},O.url)),!h&&d.length>u&&Oe("button",{className:Co(N.source,N.sourceShowMore),type:"button",onClick:()=>b(!0),children:m("showMore",{amount:d.length-u})})]})]})}import{jsx as pl,jsxs as Pg}from"react/jsx-runtime";var ul=()=>Pg("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[pl("title",{id:"angleLeftTitle",children:"AngleLeft"}),pl("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});import{jsx as ml,jsxs as ar}from"react/jsx-runtime";function lr({children:t,title:e,id:n,onDismiss:o}){let s=R(Ne),r=x("CommandPalette",ie),{page:i}=Ht();return i!==n?null:ar("div",{className:r.page,id:`page_${n}`,tabIndex:-1,children:[o&&ar("div",{className:r.pageNav,children:[ar("button",{className:r.pageBackButton,type:"button",onClick:o,children:[ml(ul,{}),s("back")]}),e&&ml("h3",{className:r.pageTitle,children:e})]}),t]})}import{forwardRef as Lg}from"react";import{jsx as gl,jsxs as Ig}from"react/jsx-runtime";var Bt=()=>Ig("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[gl("path",{d:"M0 0h24v24H0z",fill:"none"}),gl("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});import{jsx as Ut,jsxs as dr}from"react/jsx-runtime";function Ag({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:s,value:r,selectedType:i},a){let d=x("CommandPalette",ie);return dr("div",{className:d.search,children:[Ut("div",{className:d.searchIcon,children:Ut(Bt,{})}),dr("div",{className:d.searchInputWrapper,children:[Ut("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:l=>{t(l.currentTarget.value)},onFocus:l=>{l.currentTarget.select()},className:d.searchInput,placeholder:n,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&Ut("div",{className:d.selectWrapper,children:dr("select",{"data-testid":"command-palette-type-select",className:d.select,onChange:l=>e(l.target.value===o?void 0:l.target.value),value:i||o,children:[o&&Ut("option",{children:o}),s.map(l=>Ut("option",{value:l.value,children:l.label},l.value))]})})]})]})}var fl=Lg(Ag);import hl from"classnames";import{jsx as Ng,jsxs as Og}from"react/jsx-runtime";var Mg=s=>{var r=s,{onClick:t,shortKeys:e,children:n}=r,o=A(r,["onClick","shortKeys","children"]);let i=x("CommandPalette",ie);return Og("button",S(y({type:"button"},o),{onClick:t,className:hl(i.actionButton,o.className,{[i.hasShortKeys]:e&&e.length>0}),children:[n,e==null?void 0:e.map(a=>Ng("span",{className:hl(i.actionShortcut,a===8629&&i.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},yl=Mg;import{jsx as xl,jsxs as Bg}from"react/jsx-runtime";var Hg="[data-command-palette-item]";function pt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:d,types:l,children:c,isOpen:u,search:p,updateDeps:f=[]}){let[g,m]=Dg(),h=_g(null),b=()=>{s&&s(n),i(void 0),r(""),a(!1)},T=()=>{var O;if(o!==n&&s){s(n);return}if(d&&i){i(void 0),(O=h.current)==null||O.focus();return}if(p.length>0){r("");return}a(!1)},C=()=>{let O=w();O.length!==0&&m(O[0].dataset.itemId)},w=()=>Array.from(document.querySelectorAll(Hg)||[]),I=O=>document.querySelector(`[data-item-id=${O}]`),N=O=>{let U=I(O);U&&m(U.dataset.itemId)},_=O=>{let U=I(O);U&&U.scrollIntoView({behavior:"smooth"})},W=()=>{if(!g)return;let O=w(),U=I(g);if(!U)return;let Pe=O.indexOf(U),le=O[Pe+1];le!=null&&le.dataset.itemId?N(le.dataset.itemId):C()},ce=()=>{if(!g)return;let O=w(),U=I(g);if(!U)return;let Pe=O.indexOf(U),le=O[Pe-1];le!=null&&le.dataset.itemId?N(le.dataset.itemId):N(O[O.length-1].dataset.itemId)},ae=Fg(O=>{switch(O.key){case"ArrowDown":{O.preventDefault(),W();break}case"ArrowUp":{O.preventDefault(),ce();break}case"Enter":{if(g){let U=I(g);U==null||U.click()}break}}},[g]);return vl(()=>{C()},[p,o,d,u,...f]),vl(()=>{g&&_(g)},[g]),xl(Ft,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:T,onClose:b,onKeyDown:ae,children:Bg(nl,{selected:g,setSelected:m,isOpen:u,onChangeOpen:a,page:o,children:[o===n&&xl(fl,{ref:h,onChange:r,onChangeType:i,placeholder:t,value:p,selectedType:d,types:l,typePlaceholder:e}),c]})})}pt.Page=lr;pt.List=tr;pt.Image=Qa;pt.ListItem=ir;pt.ListItemActions=cl;pt.Button=yl;var G=pt;import{useEffect as Ug}from"react";function Sl(t,e){Ug(()=>{let n=o=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}import{useEffect as wl,useRef as Xg}from"react";import{useSelector as Jg,useDispatch as Qg}from"react-redux";import{createAsyncThunk as Kg,createSelector as zg,createSlice as Wg}from"@reduxjs/toolkit";var bl={data:null,fetchState:"idle"},Vg=t=>{var e;return(e=t.entities.data)!=null?e:null},wo=zg([Vg,Ot,pa],(t,e,n)=>{var a;let o=[],{visitorName:s}=n!=null?n:{},{agentName:r,agentNickname:i}=e!=null?e:{};return r&&r!==s&&o.push(r),i&&i!==s&&o.push(i),(a=t==null?void 0:t.filter(d=>!o.includes(d.text)))!=null?a:null}),fe=Kg("entities/getEntities",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let s=o.conversationQuery,r=yield s();return r.length===0?Promise.resolve([]):n.getEntities(r)})),jg=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),$g=Wg({name:"entities",initialState:bl,reducers:{},extraReducers:t=>{t.addCase(fe.pending,e=>{e.fetchState="loading"}).addCase(fe.rejected,e=>{e.fetchState="error"}).addCase(fe.fulfilled,(e,n)=>{e.fetchState="done",e.data=jg(e.data?[...e.data,...n.payload]:n.payload)}).addCase(V,()=>bl)}}),Cl=$g.reducer;var cr={};X(cr,{enUS:()=>Gg,nlNL:()=>qg});var Gg={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},qg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Tl={root:"dd-TYTKs",empty:"dd-AU7uT"};import{jsx as pr,jsxs as Yg}from"react/jsx-runtime";var Zg=({onCopy:t})=>{let e=Xg(null),n=x("EntitiesList",Tl),o=Jg(wo),{setSelected:s}=Ht(),r=R(cr),i=Qg();return wl(()=>{i(fe())},[]),wl(()=>{e.current&&(e.current.focus(),s("entity-0"))},[e]),Yg("div",{className:n.root,ref:e,tabIndex:-1,children:[o&&o.length>0&&pr(G.List,{children:o.map((a,d)=>pr(G.ListItem,{id:`entity-${d}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),o&&o.length===0&&pr("p",{className:n.empty,children:r("noResults")})]})},El=Zg;import{jsx as kl}from"react/jsx-runtime";var Eo=t=>kl("svg",S(y({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},t),{children:kl("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})}));var In={};X(In,{enUS:()=>ef,nlNL:()=>tf});var ef={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},tf={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var Xe=t=>e=>{let{passwordlessToken:{token:n},settings:{isEmbedded:o,adminUrl:s}}=e,r=s||window.location.origin;return o&&!n?null:o&&n?`${r}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${r}${t}`};import{useSelector as Rl}from"react-redux";var ko={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};import{useDispatch as of}from"react-redux";import{createAsyncThunk as nf}from"@reduxjs/toolkit";function ur(t){return nf("analytics/logEvent",(e,n)=>{var r,i,a;let o=(i=(r=n.getState())==null?void 0:r.conversation.current)==null?void 0:i.id,s=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,S(y({conversationId:o},s),{data:e.data}))})(t)}function K(){let t=of();return(e,n)=>v(null,null,function*(){yield t(ur({name:e,data:n}))})}import{jsx as Ro,jsxs as rf}from"react/jsx-runtime";var sf=({suggestion:t,source:e,context:n})=>{let o=R(In),s=Rl(xe),r=K(),i=E("enableSuggestionFeedback"),a=`${t.text}`,d=Rl(Xe(`/admin/feedback?conversationId=${s}&type=${e}&text=${a}&data=${JSON.stringify({context:n})}`)),l=()=>{r("suggestion feedback",{text:t.text,source:e,context:n})};return!i||!d?null:rf($,{placement:"top-end",children:[Ro($.Trigger,{className:ko.trigger,children:Ro(Eo,{"data-testid":"feedback-dropdown-trigger"})}),Ro($.Content,{className:ko.content,children:Ro($.Button,{className:ko.item,as:"a",onClick:l,target:"_blank",href:d,children:o("giveFeedback")})})]})},Po=sf;var Ln={};X(Ln,{enUS:()=>af,nlNL:()=>lf});var af={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"URL suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},lf={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"URL suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};import{useEffect as mf}from"react";import{useDispatch as gf,useSelector as ff}from"react-redux";import{createAction as pf,createAsyncThunk as Al,createSlice as uf}from"@reduxjs/toolkit";var df=["{amount}"," {amount}","{date}","{email}","{iban}","{name}","{postal_code}","{street}","{tarif}","{usage}","{3_digits}","{4_digits}","{5_digits}","{6_digits}","{7_digits}","{8_digits}","{9_digits}","{10_digits}"],cf=new RegExp(df.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Pl(t,e){let n=t.split(cf),o=0,s=[];for(let r=0;r<n.length;r++){let i=n[r];if(s.push(i),r===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[r+1],d=r===n.length-2;o+=i.length;let l=o;if(d){let u=a.charAt(0),p=0;do l=u?e.indexOf(u,l+1):-1,p+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&p>2)return t}else l=a&&a!==""?e.indexOf(a,o):-1;let c=l===-1?e.slice(o):e.slice(o,l);s.push(c),o=l}return s.join("")}function Il(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Ml={suggestions:[],fetchState:"idle"},Ll={default:Ml},Nl=t=>e=>{var n,o;return(o=(n=e.textSuggestions[t])==null?void 0:n.suggestions)!=null?o:[]},Io=t=>t.textSuggestions,Ol=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Lo=pf("textSuggestions/refresh"),he=Al("textSuggestions/recommendations",(t,e)=>v(null,null,function*(){var c,u,p;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:s}=o.info,{textSuggestionsCount:r,inlineSuggestions:i}=o.settings,a=At(o),d=(c=o.conversation.current)==null?void 0:c.id;if(!d)throw new Error("No current conversation to fetch text suggestions");if(!((u=o.profile.data)!=null&&u.recommendationEngine))return[];let l=[];if(t==="sticky-messages"){let f=(p=o.profile.data)==null?void 0:p.code;if(!f)throw new Error("No current profile to fetch pinned messages");l=yield n.getPinnedMessages(f)}else l=yield n.getTextSuggestions(d,pn(o),t);if(s&&(l=l.map(f=>y(S(y({},f),{text:me(f.text,s)}),f.title?{title:me(f.title,s)}:{}))),t==="default"){let f=i?l.filter(Ol(a)):l;e.dispatch(Ge(f.slice(0,r)))}return l})),An=Al("textSuggestions/autocompletions",(t,e)=>v(null,null,function*(){var c,u;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(c=o.conversation.current)==null?void 0:c.id,{platformVariables:r}=o.info,{textSuggestionsCount:i,deanonymize:a,inlineSuggestions:d}=o.settings;if(!((u=o.profile.data)!=null&&u.recommendationEngine))return[];if(!s)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(s,S(y({},pn(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return d&&(l=l.filter(Ol(t))),r&&(l=l.map(p=>S(y({},p),{text:me(p.text,r)}))),a&&(l=l.map(p=>S(y({},p),{text:p.source!=="trie-with-typos"?Pl(p.text,t):p.text}))),l=Il(l,i),e.dispatch(Ge(l)),l})),Dl=uf({name:"textSuggestions",initialState:Ll,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:n}=e.payload;t[n].fetchState="done",t[n].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}}},extraReducers:t=>{t.addCase(he.pending,(e,n)=>{let o=n.meta.arg,s=e[o]||Ml;return S(y({},e),{[o]:S(y({},s),{fetchState:"loading"})})}).addCase(he.rejected,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="error")}).addCase(he.fulfilled,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="done",e[o].suggestions=n.payload)}).addCase(An.pending,e=>{e.default.fetchState="loading"}).addCase(An.rejected,e=>{e.default.fetchState="error"}).addCase(An.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(V,()=>Ll)}}),{setTextSuggestions:NE}=Dl.actions,_l=Dl.reducer;import{jsx as Ao,jsxs as yf}from"react/jsx-runtime";var hf=({types:t,commands:e,onClick:n})=>{let o=gf(),s=R(Ln),r=ff(Io);return mf(()=>{t.forEach(({type:i})=>{(!r[i]||r[i].suggestions.length===0)&&o(he(i))})},[]),yf("div",{children:[e.length>0&&Ao(G.List,{heading:s("commands"),children:e.map((i,a)=>Ao(G.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:i.onClick,children:i.label},i.label))}),t.map(({type:i,title:a})=>{var d;return Ao(G.List,{heading:a,orientation:"vertical",children:(d=r[i])==null?void 0:d.suggestions.map((l,c)=>Ao(G.ListItem,{id:`${i}-${c}`,closeOnSelect:!1,description:l.title&&l.text,onClick:()=>n(l.text,l),"data-testid":"search-overlay-suggestion",children:l.title||l.text},`${l.id}-${l.text}`))},i)})]})},Fl=hf;import{jsx as Ce,jsxs as fr}from"react/jsx-runtime";var Tf=200,wf=5,Ef=4,gr=(t,e,n)=>t.slice(0,n?10:e.toLowerCase()==="image"?Ef:wf),kf=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Rf=()=>{var Pe,le,hi;let t=Cf(),e=ne(),n=R(Ln),[o,s]=mr(!1),[r,i]=mr(""),a=ut(ba),d=ut(dt),[l,c]=mr(),u=ut(J),p=E("showSearch"),f=E("enableSuggestionFeedback"),g=E("showEntitiesCommand"),m=E("showImageSearch"),h=E("searchTriggerKey"),b=ut(Va),T=ut(Hs),C=ut(Ca),w=ut(Sa),I=((hi=(le=(Pe=d==null?void 0:d.uiConfig)==null?void 0:Pe.search)==null?void 0:le.initialTypes)==null?void 0:hi.filter(({isActive:L})=>L))||[],N=K(),_=bf(()=>{let L=ee=>gr(T.filter(z=>z.type===ee.toUpperCase()),ee,l),j=(b==null?void 0:b.map(ee=>({value:ee.code.toUpperCase(),label:`${ee.name}s`,list:L(ee.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(j.push({value:"PERSONAL",label:n("personalSuggestions"),list:L("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:L("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:L("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),m&&j.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:L("IMAGE"),listOrientation:"horizontal"}),I.length===0)return j;let on=I.map(ee=>j.find(z=>z.value.toLowerCase()===ee.type)).filter(ee=>!!ee),Ts=j.filter(ee=>!on.find(z=>z.value===ee.value));return[...on,...Ts]},[b,I,m,l]),W=[{label:n("entitiesClipboard"),onClick:()=>t(Dt("entities")),shouldShow:g&&kf(n("entitiesClipboard"),r)}].filter(L=>L.shouldShow).filter(()=>!l),ce=Hl(xf((L,j)=>{t(at({query:L,type:j,tags:["search-overlay"],size:l?50:20}))},Tf),[l]),ae=Hl((L,j)=>{j.type==="IMAGE"?e.send(Us,{suggestion:j}):e.send(Ae,{text:L,suggestion:j}),t(ge(!1))},[t]),O=L=>{Se(L.text),N("entity copied",{entity:L,type:"copy"}),t(ge(!1))};function U(L){return j=>{o?window.confirm(n("warning"))&&(L(j),s(!1)):L(j)}}return Bl(()=>{r?ce(r,l):t(lo())},[r,l]),Bl(()=>{u&&t(wn())},[u]),Sl(h,()=>{t(ge(!0)),N("open search",{via:"ctrl+k"})}),!p||!d?null:fr(G,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:U(L=>t(ge(L))),onChangeType:L=>c(L),onChangePage:U(L=>t(Dt(L))),selectedType:l,search:r,page:a,isOpen:w,types:_,updateDeps:[T],children:[fr(G.Page,{id:"search",children:[r.length===0&&Ce(Fl,{types:I,commands:W,onClick:ae}),r.length>0&&fr(Sf,{children:[W.length>0&&Ce(G.List,{heading:n("commands"),children:W.map((L,j)=>Ce(G.ListItem,{closeOnSelect:!1,onClick:L.onClick,id:`commands-${j}`,children:L.label},L.label))}),_.map(({value:L,label:j,list:on,lineClamp:Ts,listOrientation:ee})=>Ce(G.List,{heading:j,orientation:ee==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(L),hasMore:!l&&C[L.toLowerCase()]>gr(on,L,l).length,children:gr(on,L,l).map(z=>Ce(G.ListItem,{id:`${L}-${z.id}`,closeOnSelect:!1,lineClamp:Ts,onClick:()=>ae(z.text,z),description:L!=="IMAGE"?z.title&&z.text:void 0,tooltip:z.text,extra:f&&Ce(G.ListItemActions,{children:Ce(Po,{context:r,source:"search",suggestion:z})}),children:L==="IMAGE"?Ce(G.Image,{title:z.title||z.text,src:z.image}):z.title||z.text},`${z.id}-${z.text}`))},L))]})]}),Ce(G.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:U(()=>{t(Dt("search"))}),children:Ce(El,{onCopy:O})})]})},Ul=Rf;import{jsx as Kl,jsxs as Lf}from"react/jsx-runtime";var If=()=>{let t=E("showSearch"),e=E("isEmbedded");return Lf(Pf,{children:[t&&Kl(Ul,{}),e&&Kl(Wa,{})]})},zl=If;import Of from"classnames";import{useSelector as Df}from"react-redux";import{jsx as hr}from"react/jsx-runtime";var Wl=({className:t})=>hr("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:t,children:hr("g",{children:hr("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
4
4
|
c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
|
|
5
5
|
c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
|
|
6
6
|
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
|
|
7
|
-
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`})})});import{jsx as Wl}from"react/jsx-runtime";var Af={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Vl=({className:t,color:e})=>Wl("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Wl("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:Af[e||"pink"]})});var jl={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var hr={};X(hr,{enUS:()=>Mf,nlNL:()=>Nf});var Mf={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Nf={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};import{useDispatch as _f}from"react-redux";import{jsx as yr,jsxs as $l}from"react/jsx-runtime";var Gl=({onLogIn:t})=>{let e=R(hr),n=E("floatingMenu"),o=E("productName"),s=_f(),r=Df(J),i=x("FloatingMenu",jl);if(r===null||n===!1)return null;let a=()=>{r===!0?s(me(!0)):t()};return $l("button",{type:"button",className:Of(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[yr("div",{className:i.text,children:e(r?"search":"signin",{productName:o})}),$l("div",{className:i.icon,children:[yr(Vl,{className:i.logo,color:"pink"}),r===!1&&yr(zl,{className:i.lock})]})]})};import{useEffect as oh,useRef as sh}from"react";import{useDispatch as rh,useSelector as Kt}from"react-redux";import{useEffect as Ff}from"react";function gt(t){Ff(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function mt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}function Te(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:s,selection:r}=t.input;return r.start!==r.end?!1:r.end>=s.length?!0:e?n&&new RegExp(n).test(s.substring(r.end))||o&&new RegExp(o).test(s.substring(0,r.end))?!0:n===!1&&o===!1:!1}import{createSlice as Hf}from"@reduxjs/toolkit";var Bf={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Mo=({ui:t})=>t.overlayCollapsed,ql=Hf({name:"ui",initialState:Bf,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:Mn,setInputFocus:No,setOverlayCollapsed:Je,setOpenOverlayWhenTyping:Xl,setOverlayCollapsedUserOverwrite:Jl}=ql.actions,Ql=ql.reducer;import{useMemo as eh}from"react";import{Interweave as nd}from"interweave";import{useEffect as jf,useMemo as $f,useRef as Gf,useState as qf}from"react";import{useDispatch as Xf,useSelector as od}from"react-redux";import{useEffect as Uf}from"react";function Zl(t,e,n){Uf(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var Yl={root:"dd-1MBCO",actions:"dd--x4cy",closeIconContainer:"dd-1z5NR",closeIcon:"dd-8qMF-",badge:"dd-4Fpkz",formattedText:"dd-EzvTB",assistantContainer:"dd-j6o8F",formattedTextTruncated:"dd-fv169",assistantBadge:"dd-VD57E"};import{jsx as ed,jsxs as Kf}from"react/jsx-runtime";var td=({title:t})=>Kf("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24","aria-labelledby":"closeTitle",children:[ed("title",{id:"closeTitle",children:t}),ed("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})]});var vr={};X(vr,{enUS:()=>zf,nlNL:()=>Wf});var zf={assistant:[{type:0,value:"Assistant"}],close:[{type:0,value:"Close"}]},Wf={assistant:[{type:0,value:"Assistent"}],close:[{type:0,value:"Sluiten"}]};import{jsx as De,jsxs as sd}from"react/jsx-runtime";var Jf=["search","personal-collection-search","search-autocomplete"];function Qf(t,e,n,o={}){var r;let s="";return Jf.includes(e)?s=Za(tr(t,n,{stripAgentPart:!0}),(r=o.searchKeywords)!=null?r:[n]):s=tr(t,n,o),o.placeholders===!0&&(s=Ya(s)),s}var Zf=()=>{},Yf=({selected:t,suggestion:e})=>{let n=R(vr),o=E("inlineSuggestions"),s=od(At),[r,i]=qf(!1),a=E("enableSuggestionFeedback"),d=od(h=>h.input.text),l=Xf(),c=x("TextSuggestion",Yl),u=Gf(null),p=e.source==="assistant",f=a&&!p;jf(()=>{let h=setTimeout(()=>{l(Yi({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(h)}},[e]),Zl(u,"click",()=>{l(se({suggestion:e,text:e.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let m=()=>{l(rt({source:e.source,text:e.text,assistantCode:e.assistantCode}))},g=$f(()=>Qf(e.text,e.source,s,{stripAgentPart:o,placeholders:!0,searchKeywords:e.searchKeywords}),[o,e.text,e.source,s,e.searchKeywords]);return e.source==="gpt"&&!o?null:sd("div",{className:c.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[De(M,{ref:u,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:Zf,children:e.source==="assistant"?sd("div",{className:c.assistantContainer,children:[De(nd,{containerTagName:"div",tagName:"span",className:c.formattedTextTruncated,content:g}),De("span",{className:c.assistantBadge,children:n("assistant")})]}):De(nd,{containerTagName:"div",tagName:"span",className:c.formattedText,content:g})}),f&&r&&De("div",{className:c.actions,children:De(Po,{source:"overlay",context:d,suggestion:e})}),p&&r&&De("div",{className:c.closeIconContainer,children:De("button",{type:"button",className:c.closeIcon,onClick:m,title:n("close"),children:De(td,{title:n("close")})})})]})},rd=Yf;import{jsx as nh}from"react/jsx-runtime";var th=({suggestions:t,selectedIndex:e,reverse:n})=>eh(()=>{let s=t.map((r,i)=>nh(rd,{index:i,selected:i===e,suggestion:r},`${r.text}-${r.source}`));return n?s.reverse():s},[t,e,n]),Oo=th;var id={root:"dd-PfvRI",paper:"dd-HYlyY"};import{jsx as Do}from"react/jsx-runtime";var ih=()=>{let t=sh(null),e=x("InlineSuggestionsOverlay",id),n=Kt(Te),o=rh(),s=Kt(J),r=Kt(Lt),i=Kt(Mo),a=E("showTextSuggestions"),d=Kt(st),l=Kt(dn);return gt(()=>{setTimeout(()=>{o(Je({collapse:!0,skipWhenInputFocus:!0}))})}),oh(()=>{let c=t.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let u=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-u.right,0)}px`}),i||!n||!a||d.length===0||s!==!0||r===!1?null:Do("div",{className:e.root,"data-variant":"inline",children:Do("div",{ref:t,className:e.paper,children:Do(te,{children:Do(Oo,{suggestions:d,selectedIndex:l})})})})},ad=ih;import{Provider as ah}from"react-redux";import{jsx as _o}from"react/jsx-runtime";var lh=({children:t})=>{let n=E("locale").replace("-","");return _o(qs.Provider,{value:n,children:t})},dh=({store:t,customStyles:e={},children:n})=>_o(ah,{store:t,children:_o(lh,{children:_o(sn.Provider,{value:e,children:n})})}),_e=dh;import Tr from"classnames";import{useEffect as bh,useRef as Ch,useState as Th}from"react";import{useDispatch as wh,useSelector as Qe}from"react-redux";import{useState as ch}from"react";function ld(t,e){let[n,o]=ch(()=>{if(typeof window=="undefined")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return k.error(r),e}});return[n,r=>{try{let i=r instanceof Function?r(n):r;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){k.error(i)}}]}var dd=()=>/Mac/i.test(navigator.platform);import gh from"classnames";import{Fragment as mh,useCallback as Sr,useMemo as pd}from"react";var xr={};X(xr,{enUS:()=>ph,nlNL:()=>uh});var ph={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"}]}]},uh={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 cd={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};import{jsx as Fo,jsxs as ud}from"react/jsx-runtime";var br=(t,e,n)=>o=>Fo("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),fh=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o,onLogIn:s})=>{let r=R(xr),i=ne(),a=x("Login",cd),d=E("productName"),l=Sr(h=>{h.preventDefault(),o&&o(Number.parseInt(h.target.value,10))},[]),c=Sr(h=>{h.preventDefault(),i.send(_t,!0)},[e]),u=pd(()=>h=>Fo("a",{onClick:T=>{T.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),p=Sr(h=>Fo("button",{type:"button",className:a.anchorButton,onClick:c,children:h},"prompt"),[c]),{min:f,hour:m,day:g}=pd(()=>({min:br(a,600,l),hour:br(a,3600,l),day:br(a,3600*12,l)}),[]);return ud("div",{className:gh(t,a.root),children:[r("loginPlease",{login:n?p:u,productName:d}),o&&ud(mh,{children:[Fo("br",{}),r("snooze",{min:f,hour:m,day:g})]})]})},Ho=fh;import{useDispatch as hh}from"react-redux";var gd={root:"dd-DoQhb",text:"dd-Jwnev"};import{jsx as md,jsxs as vh}from"react/jsx-runtime";var yh=({title:t})=>{let e=x("SearchTrigger",gd),n=hh(),o=K();return vh("button",{type:"button",className:e.root,onClick:()=>{n(me(!0)),o("open search",{via:"autocomplete-overlay"})},children:[md(Bt,{}),md("span",{className:e.text,children:t})]})},fd=yh;var Cr={};X(Cr,{enUS:()=>xh,nlNL:()=>Sh});var xh={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"}],dismiss:[{type:0,value:"Dismiss"}],dismissError:[{type:0,value:"Dismiss error"}]},Sh={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"}],dismiss:[{type:0,value:"Sluiten"}],dismissError:[{type:0,value:"Foutmelding sluiten"}]};var hd={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",loginError:"dd-KCXeb",loginErrorMessage:"dd-Bv-BG",loginErrorDismiss:"dd-iSCjU"};import{jsx as q,jsxs as ft}from"react/jsx-runtime";var Eh=({onLogIn:t})=>{let e=x("SuggestionsOverlay",hd),n=R(Cr),o=Qe(Te),s=Qe(Zi),r=wh(),i=Ch(null),a=E("searchTriggerKey"),d=E("productName"),l=Qe(Mo),c=Qe(J),u=Qe(Bi),p=Qe(Lt),[f,m]=Th(null),g=E("showSearch"),h=E("showTextSuggestions"),b=E("adminUrl"),T=E("isEmbedded"),C=E("suggestionsPlacement"),[w,I]=ld("dd-snooze-until-ms",0),N=l||w>Date.now(),_=Qe(st),W=Qe(dn),ce=_.filter(U=>U.source!=="gpt").length,ae=()=>{N&&I(0),r(Jl(!N))},O=U=>{let Pe=Date.now()+U*1e3;I(Pe),k.info(`Snooze until: ${new Date(Pe)}`),r(Je({collapse:!0}))};return bh(()=>{ce===0&&m(null)},[_,ce]),gt(()=>{r(Je({collapse:!0,skipWhenInputFocus:!0}))}),c===null||p===!1?null:c===!1?ft("div",{ref:i,className:Tr(e.root,{[e.isCollapsed]:N}),children:[!N&&ft("div",{className:e.triggers,children:[q("div",{style:{flex:1}}),q("div",{className:e.triggersRight,children:q(Et,{className:e.toggleButton,title:n("collapse"),onClick:ae,isCollapsed:!1})})]}),q("div",{className:e.toggleButtonWrapper,children:q(Et,{className:e.toggleButton,title:n("open",{productName:d}),onClick:ae,isCollapsed:!0})}),ft("div",{className:e.collapsible,children:[u&&ft("div",{className:e.loginError,children:[q("span",{className:e.loginErrorMessage,children:u}),q("button",{type:"button",className:e.loginErrorDismiss,onClick:()=>r(Zn()),"aria-label":n("dismissError"),children:n("dismiss")})]}),q(Ho,{loginUrl:b,isEmbedded:T,onLogIn:t,onSnooze:O})]})]}):!s||!o?null:ft("div",{ref:i,className:Tr(e.root,{[e.isCollapsed]:N}),children:[!N&&ft("div",{className:e.triggers,children:[q("div",{style:{flex:1},children:g&&q("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(n(dd()?"searchHintMac":"searchHintWindows",{searchTriggerKey:a.toUpperCase()})),onMouseLeave:()=>m(null),children:q(fd,{title:n("search")})})}),ft("div",{className:e.triggersRight,onFocus:()=>{},children:[q("div",{className:Tr(!f&&e.hintsHidden,e.hints),children:f}),q(Et,{className:e.toggleButton,title:n("collapse"),onClick:ae,isCollapsed:!1})]})]}),q("div",{className:e.toggleButtonWrapper,children:q(Et,{className:e.toggleButton,title:n("open",{productName:d}),onClick:ae,isCollapsed:!0})}),ce>0&&h&&q("div",{className:e.collapsible,onFocus:()=>{},children:q(te,{children:q(Oo,{suggestions:_,selectedIndex:W,reverse:C==="above"})})})]})},yd=Eh;import Nr from"classnames";import{Interweave as wy}from"interweave";import{useCallback as Ey,useEffect as ky,useMemo as zd,useRef as Ry}from"react";import{connect as Py}from"react-redux";import{useEffect as kh,useRef as Rh,useState as Ph}from"react";function Bo(t){return t.contentEditable==="true"}function Ih(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let s=o.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),n=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:n}}function vd(t){let{selectionStart:e,selectionEnd:n}=Bo(t)?Ih(t):t;return[e,n]}function xd(t){let[,e]=Ph(),n=Rh(null);return n.current=vd(t),kh(()=>{let o=()=>{var a;let[s,r]=(a=n.current)!=null?a:[],i=vd(t);(!i||s!==i[0]||r!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function Sd(t,e){if(!e)return;let n=t,{value:o}=n,[s,r]=e,i=o.match(qn);if(!i||i.length===0)return;let a=0;i.find(d=>{let l=o.indexOf(d,a);return s>l&&r<l+d.length?(n.selectionStart=l,n.selectionEnd=l+d.length,!0):(a=l+d.length,!1)})}import{cloneElement as Lh}from"react";var Ah=["div","span","mark","strong","b","i","u","em"];function wr(t,e,n=0){var r;let o=t[t.length-1],s=typeof o=="object"&&o!==null?(r=o.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,o];if(Ah.includes(s)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),Lh(o,{children:wr(i,e,n+1)})]}return[...t,...e]}function ht(t){return t.tagName.toLowerCase()==="textarea"}var bd={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"};import Qh from"classnames";import{Matcher as Zh}from"interweave";import{useEffect as Yh,useMemo as ey}from"react";import{useEffect as Mh,useRef as Nh,useState as Oh}from"react";function Cd(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let s=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(n)]}function Uo(t){let e=Nh(null),[n,o]=Oh(!1);return Mh(()=>{var c;let s=!1,r=Number.parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[i,a]=Cd((u,p)=>{let f=e.current;if(!f)return;let m=u/r,g=p/r,h=f.getBoundingClientRect(),b=m>h.x&&m<h.x+h.width&&g>h.y&&g<h.y+h.height;b&&!s?(s=!0,o(!0)):!b&&s&&(s=!1,o(!1))},({clientX:u,clientY:p})=>[u,p]),[d,l]=Cd(()=>{s=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",d),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",d)}},[e]),[e,n]}function Td(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Ko(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function wd(t){return t!=null}import Id from"classnames";import{createRef as Vh,useCallback as kr,useMemo as jh,useRef as $h,useState as Gh}from"react";import{useState as Dh,useLayoutEffect as _h}from"react";var Fh=["bottom","height","left","right","top","width"],Hh=(t={},e={})=>Fh.some(n=>t[n]!==e[n]),Fe=new Map,Ed,kd=()=>{let t=[],e=[];Fe.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let s=o.getBoundingClientRect();Hh(s,n.rect)&&(n.rect=s,t.push(n))}),e.forEach(n=>{Fe.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),Ed=window.requestAnimationFrame(kd)};function Bh(t,e){return{observe(){let n=Fe.size===0;if(Fe.has(t)){let o=Fe.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else Fe.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&kd()},unobserve(){let n=Fe.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||Fe.delete(t),Fe.size||cancelAnimationFrame(Ed)}}}}function Er(t){let[e,n]=Dh(null);return _h(()=>{if(!t.current)return;let o=Bh(t.current,s=>{n(s)});return o.observe(),()=>{o.unobserve()}},[t]),e}import{useContext as Uh,useLayoutEffect as Kh,useState as zh}from"react";import{createPortal as Wh}from"react-dom";var Rd={root:"dd-r-dgo"};var Pd=({children:t,parentNode:e})=>{let[n,o]=zh(null),s=Uh(sn);return Kh(()=>{let r=document.createElement("div");return mt(r),r.classList.add(Rd.root),s!=null&&s.portalRootNode&&r.classList.add(s==null?void 0:s.portalRootNode),(e||document.body).appendChild(r),o(r),()=>{r.isConnected&&r.remove()}},[]),n?Wh(t,n):null};var we={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"};import{jsx as Rr}from"react/jsx-runtime";var zo=(t=!1)=>{let[e,n]=Gh(t),o=kr(()=>n(!0),[]),s=kr(()=>n(!1),[]),r=kr(()=>n(a=>!a),[]),i=$h(null);return{opened:e,open:o,close:s,toggle:r,triggerRef:i}};function Pr(t,e=null,n=0){if(!t)return{display:"none"};let o=e?t.top-e.top<0||t.top<e.top-n?e.top-n:t.top+t.height>e.top+e.height+n?e.top+e.height+n-t.height:t.top:t.top,s=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:s,height:t.height,width:t.width}}var zt=l=>{var c=l,{className:t,triggerRef:e,boundaryRef:n=Vh(),position:o="above",align:s="center",children:r,toStyle:i=Pr,parentNode:a}=c,d=A(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let u=Er(e),p=Er(n),f=jh(()=>i(u,p,0),[u,p]);return Rr(Pd,{parentNode:a,children:Rr("div",S(y({className:Id(we.ref,{[we.positionAbove]:o==="above",[we.positionBelow]:o==="below",[we.positionLeft]:o==="left",[we.positionRight]:o==="right",[we.alignStart]:s==="start",[we.alignCenter]:s==="center",[we.alignEnd]:s==="end"}),style:f},d),{role:"dialog",children:Rr("div",{className:Id(t,we.root),children:r})}))})};import qh from"classnames";import{forwardRef as Xh,useRef as Jh}from"react";var He={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"};import{jsx as Ld}from"react/jsx-runtime";var Wo=Xh((s,o)=>{var r=s,{className:t,children:e}=r,n=A(r,["className","children"]);let i=Jh(null),a=x("TabCompletion",He);return Ld("div",S(y({ref:Ko([i,o]),className:qh(t,a.popoverContentContainer)},n),{children:Ld("div",{className:a.popoverContent,children:e})}))});import{jsx as Nn,jsxs as oy}from"react/jsx-runtime";var ty=t=>e=>{let n=Pr(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},ny=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:s})=>{let r=x("TabCompletion",He),i=zo(),a=ey(()=>ty(t.getBoundingClientRect()),[t]),[d,l]=Uo(t);return Yh(()=>{l?i.open():i.close()},[l]),oy("span",{children:[Nn("mark",{ref:Ko([d,i.triggerRef]),className:Qh(r.matchKeyword,{[r.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&Nn(zt,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:Nn(Wo,{style:n,children:Nn("div",{className:r.hintText,children:s})})})]})},Vo=class extends Zh{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(s=>S(y({},s),{keywordRegex:new RegExp(`\\b${Td(s.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=this.preparedKeywordMatches.map(r=>{if(this.usedKeywordMatches.has(r))return null;let i=n.match(r.keywordRegex);if(!i)return null;let a=n.charAt(i.index-1),d=n.charAt(i.index+r.keyword.length);return a==="{"&&d==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:r.suggestion,preparedKeywordMatch:r,valid:!0}}).filter(wd);if(o.length===0)return null;let s=o.reduce((r,i)=>i.index<r.index?i:r);return this.usedKeywordMatches.add(s.preparedKeywordMatch),s}replaceWith(n,o){return Nn(ny,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:n},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{Matcher as sy}from"interweave";import ry from"classnames";import{jsx as Ad}from"react/jsx-runtime";var iy=({inputElement:t,children:e})=>{let n=x("TabCompletion",He),[o,s]=Uo(t);return Ad("mark",{ref:o,className:ry(n.matchPlaceholder,{[n.hover]:s}),children:e})},jo=class extends sy{match(e){let n=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(e,n){return Ad(iy,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};import Mr from"classnames";import{Matcher as hy}from"interweave";import{createRef as yy,forwardRef as vy,useCallback as xy,useEffect as Bd,useRef as Ud,useState as Kd}from"react";import{useDispatch as Sy,useSelector as by}from"react-redux";import{jsx as Md}from"react/jsx-runtime";var Nd=()=>Md("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:Md("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"})});import{useCallback as ay,useEffect as Dd,useMemo as ly,useState as _d}from"react";import{useDispatch as dy,useSelector as Fd}from"react-redux";import cy from"lodash.debounce";var Od={root:"dd-ky-Bv",content:"dd-kV5e1"};function $o(t,e,n){var s;let o=((s=t.imageSizes)==null?void 0:s[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(r){return null}}function Ir(t){return t.replace("https://www.","").replace("https://","")}import{jsx as yt,jsxs as Lr}from"react/jsx-runtime";var py=3,uy=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),gy=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:s=py})=>{let r=x("LinkSearch",Od),[i,a]=_d(""),d=dy(),l=Fd(Ml("url")),c=Fd(Ca("URL")),u=ly(()=>c.map(uy),[c]),[p,f]=_d(u.length-1),m=E("fallbackImage"),g=C=>{let w=C.target;a(w.value)},h=(C,w)=>{C.stopPropagation(),C.preventDefault(),window.open(w,"_blank")},b=C=>{var N;let w=p-1<0?u.length-1:p-1,I=p+1===u.length?0:p+1;C.code==="Escape"&&(a(""),e()),C.code==="ArrowUp"&&f(w),C.code==="ArrowDown"&&f(I),C.code==="Enter"&&t(((N=u[p])==null?void 0:N.text)||i)},T=ay(cy(C=>{d(at({query:C,type:"URL",tags:["link-search"]}))},300),[]);return Dd(()=>{i&&T(i)},[i]),Dd(()=>()=>{d(lo())},[]),Lr("div",{className:r.root,children:[yt(te,{withDivider:!0,children:(i?u:l).slice(0,s).map((C,w)=>yt(M,{selected:p===w,onClick:()=>t(C.text),"data-testid":"linksearch-suggestion",children:Lr(D,{children:[yt(D.Image,{src:$o(C,"small",m||void 0),title:C.title||C.text}),Lr(D.Content,{className:r.content,cropText:!0,children:[yt(D.Title,{children:C.title||Ir(C.text)}),C.title&&Ir(C.text)]}),yt(M.Actions,{children:yt(M.ActionButton,{label:o,onClick:I=>h(I,C.text)})})]})},C.text))}),yt(Tn,{value:i,onChange:g,autoFocus:!0,placeholder:n,onKeyUp:b})]})},Hd=gy;var Ar={};X(Ar,{enUS:()=>my,nlNL:()=>fy});var my={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}],addToPersonalCollection:[{type:0,value:"Add to Personal Collection"}]},fy={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}],addToPersonalCollection:[{type:0,value:"Toevoegen aan Personal Collection"}]};import{jsx as ye,jsxs as Go}from"react/jsx-runtime";var Cy=vy((t,e)=>{let n=x("TabCompletion",He);return ye("mark",{ref:e,className:Mr(n.matchSelection)},"selection-start")}),Ty=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:s})=>{let r=R(Ar),i=x("TabCompletion",He),a=E("addToPersonalCollection"),d=by(Xe("/admin/personal-collection/new")),l=Ud(null),c=Ud(null),[u,p]=Kd(null),f=Sy(),m=zo(document.activeElement===o),[g]=Kd(()=>document.createRange());m.triggerRef.current=g,Bd(()=>()=>g.detach(),[]),Bd(()=>{let b=t.current,T=l.current;!b||!T||(g.setStart(b,0),g.setEnd(T,0))},[t.current,l.current]),gt(()=>{m.close()});let h=xy(b=>{let T=g.toString(),C=/^http(s?):\/\//.test(b)?b:`https://${b}`,w=`[${T}](${C})`;f(se({text:w,suggestion:{text:w,source:"search-url",type:"url"},eventMetrics:{inputType:"mouse"},replace:"selection"}))},[]);return Go("span",{children:[ye("mark",{ref:l,className:Mr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":m.opened?"true":"false",children:s}),m.opened&&ye(zt,{className:i.popoverRoot,triggerRef:m.triggerRef,boundaryRef:e,position:"above",align:"start",children:Go(Wo,{style:n,ref:c,children:[Go("div",{className:Mr(i.selectionOptions,{[i.selectionOptionsIsHidden]:u!==null}),children:[Go("button",{type:"button",tabIndex:u===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[ye(Nd,{}),ye("span",{children:"\xA0"}),ye("span",{children:r("insertLink")})]}),a&&d&&ye("button",{type:"button",tabIndex:u===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>{let b=g.toString(),T=`${d}?text=${encodeURIComponent(b)}`;window.open(T,"_blank")},children:ye("span",{children:r("addToPersonalCollection")})})]}),u==="insertLink"&&ye(Hd,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{p(null),m.close()}})]})})]},"selection-end")},qo=class extends hy{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,o){return this.props=o,this.charCount=0,this.startRef=yy(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,s]=this.props.selection;if(o===s)return null;let r=this.foundIndex===0?o:s,i=r>=this.charCount&&r<=this.charCount+n.length?{index:r-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let a=this.foundIndex===1;return i&&a?this.charCount+=r-this.charCount:this.charCount+=n.length,i?y({isStart:a},i):null}replaceWith(n,o){return o.isStart?ye(Cy,{ref:this.startRef}):ye(Ty,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{useSelector as Iy}from"react-redux";import{jsx as Wt,jsxs as My}from"react/jsx-runtime";var Ly=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:d})=>{let l=x("TabCompletion",bd),c=E("insertLink"),u=E("addToPersonalCollection"),p=E("showMidSentenceSuggestions"),f=E("inlineSuggestions"),m=xd(a),g=Ry(null),h=Iy(J);ky(()=>{ht(a)&&m&&Sd(a,m)},[m]);let b=Ey(w=>{if(!s||!n)return w;let I=[Wt("span",{className:l.resetIndent,children:"\u200B"},"u200B"),Wt("span",{"data-testid":"tab-completion",className:Nr(l.tabText,l.resetIndent),"data-source":d,children:n},"tabText")];return o&&I.push(Wt("span",{className:Nr(l.hint,l.resetIndent),children:Wt(Es,{keyCode:"tab"},"tabHint")},"tabHint")),wr(w,I)},[s,n,o]),T=zd(()=>{let w=[];return(c||u)&&w.push(new qo("selection")),w.push(new jo("placeholders")),r&&w.push(new Vo("keywords")),w},[f,c,u,r]),C=zd(()=>{let w=window.getComputedStyle(a);return{"--dd-color":w.color,"--dd-font-size":w.fontSize,"--dd-font-family":w.fontFamily,"--dd-font-variant":w.fontVariant}},[]);return!t||!h?null:My("div",{ref:w=>{w!=null&&w.parentElement&&(g.current=w==null?void 0:w.parentElement)},className:l.root,style:C,children:[Wt(wy,{tagName:"span",containerTagName:"div",className:Nr(l.container,l.agentText),disableLineBreaks:ht(a),content:e||"\u200B",onAfterParse:b,matchers:T,selection:m,keywordMatches:i,inputElement:a,inputStyle:C,boundaryRef:g,inlineSuggestionsOnlyAtEnd:!p}),Wt("br",{})]},"tab-completion")},Ay=t=>{var h,b,T;let{input:e,ui:n,settings:o,styleSuggestions:s,conversation:r}=t,i=Mt({input:e}),a=(i==null?void 0:i.text)||"",d=(i==null?void 0:i.source)||"",l=(h=e.html)!=null?h:Pn(e.text),c=a.indexOf(e.text)===0?a.slice(e.text.length):"",{showTabHint:u}=n,{isSupported:p}=r,{showTabCompletion:f,visible:m,showStyleSuggestions:g}=o;return{showTabHint:u,showStyleSuggestions:g,showTabCompletion:f&&Te(t),content:l,tabText:c,source:d,keywordMatches:(T=(b=s.list)==null?void 0:b.keywordMatches)!=null?T:[],enabled:m&&p!==!1}},Wd=Py(Ay)(Ly);import{Fragment as Zv,useEffect as qr,useState as Yv}from"react";import{useDispatch as Vc,useSelector as Z}from"react-redux";import{createAction as $d,createAsyncThunk as Gd,createSlice as Oy}from"@reduxjs/toolkit";import{Marked as Ny}from"marked";var Vd=(t,e)=>{let n=[],o=new Ny,s=r=>{r.type==="code"&&r.lang===e&&n.push(r.text)};return o.use({walkTokens:s}),o.parse(t),n};var jd={cues:[],threads:{},pending:[]},qd=t=>{var e;return(e=t.assistants)==null?void 0:e.cues};var Xd=t=>e=>{var n,o;return(o=(n=e.assistants)==null?void 0:n.threads[t])!=null?o:null},Xo=$d("assistants/callToAction"),On=Gd("assistants/evaluateKnowledgeAssistant",(t,e)=>v(null,null,function*(){var l;let{threadId:n}=t,{onNewThreadId:o}=t,{deepdeskAPI:s}=e.extra,r=e.getState(),{platformVariables:i}=r.info;n||(n=(yield s.createAssistantThread({assistantCode:t.assistantCode})).id,o&&o(n)),yield s.postMessageToAssistantThread({assistantCode:t.assistantCode,threadId:n,message:t.input});let a=yield e.dispatch(Ee(S(y({skipState:!0},t),{input:{},threadId:n})));if(a.error)throw new Error(a.error.message);let d=a.payload.output[0];return{threadId:n,question:t.input,evaluationId:a.payload.evaluationId,answer:{answer:ge(d.response,i!=null?i:{}),sources:(l=d.sources)!=null?l:[]}}})),cM=$d("assistants/extractedTextSuggestions"),Ee=Gd("assistants/evaluate",(t,e)=>v(null,null,function*(){var g;let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra,{transcript:s,input:r={},threadId:i}=t,a=e.getState(),{platformVariables:d}=a.info,l=(g=a.conversation.current)==null?void 0:g.externalId,c;if(s==="in-memory-transcript"){if(!o.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");c=yield o.conversationQuery()}else Array.isArray(s)&&(c=s);if(t.includeMetadata){if(!a.conversation.current)throw new Error("Can't include metadata, no current conversation");let{metadata:h}=a.conversation.current;Object.assign(r,{metadata:h})}let u=yield n.evaluateAssistant(t.assistantCode,{input:r,transcript:c,externalConversationId:l,threadId:i});if(u.evaluationStatus!=="success")return e.rejectWithValue(`Assistant ${t.assistantCode} evaluation failed: ${u.evaluationStatus}`);let f=(Array.isArray(u.output)?u.output:[u.output]).map(h=>S(y({},h),{name:ge(h.name,d),response:ge(h.response,d)})),m=[];return f.forEach(h=>{let b=Vd(h.response,"reply"),T=b.length>0?b:[h.response];m.push(...T.map(C=>({text:C,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name})))}),m.length>0&&e.dispatch(Nt(m)),S(y({},u),{output:f})})),Jd=Oy({name:"assistants",initialState:jd,reducers:{resetCues(t){t.cues=[]},removeCueByCode(t,e){t.cues=t.cues.filter(n=>n.code!==e.payload.code)},removeThreadById(t,e){delete t.threads[e.payload]},receiveChunk(t,e){let{code:n,name:o,payload:s,evaluationId:r}=e.payload,i=t.cues.findIndex(a=>a.code===n);i!==-1?t.cues[i].response+=s.text:t.cues.push({code:n,name:o,evaluationId:r,response:s.text})},userNotification(t,e){let n=t.cues.filter(d=>d.code!==e.payload.code),{code:o,name:s,evaluationId:r,payload:i}=e.payload,{callToAction:a}=i;t.cues=[...n,{code:o,name:s,evaluationId:r,response:i.message,editable:i.editableMessage,callToAction:a&&{label:a.displayName,event:a.onClickEvent,value:a.eventPayload}}]}},extraReducers:t=>{t.addCase(Ee.pending,(e,n)=>{e.pending.includes(n.meta.arg.assistantCode)&&k.warn(`Assistant ${n.meta.arg.assistantCode} already evaluating`),e.pending.push(n.meta.arg.assistantCode)}).addCase(Ee.rejected,(e,n)=>{var s;k.warn((s=n.error)==null?void 0:s.message);let o=e.pending.indexOf(n.meta.arg.assistantCode);o!==-1&&e.pending.splice(o,1)}).addCase(Ee.fulfilled,(e,n)=>{let o=e.pending.indexOf(n.meta.arg.assistantCode);if(o!==-1&&e.pending.splice(o,1),n.meta.arg.skipState)return;let{evaluationId:s,output:r}=n.payload,i=r.map(l=>l.code),a=e.cues.filter(l=>!i.includes(l.code)),d=r.map(l=>S(y({},l),{evaluationId:s}));e.cues=[...a,...d]}).addCase(On.fulfilled,(e,n)=>{let r=n.payload,{threadId:o}=r,s=A(r,["threadId"]);e.threads[o]=[...e.threads[o]||[],s]}).addCase(V,()=>jd)}}),{removeCueByCode:Jo,resetCues:pM,removeThreadById:Qd,receiveChunk:Zd,userNotification:Yd}=Jd.actions,ec=Jd.reducer;import{createAsyncThunk as tc,createSlice as Dy}from"@reduxjs/toolkit";var _y={token:null,interval:null},Or=tc("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),Dr=tc("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(Or()),setInterval(()=>o(Or()),n)}),nc=Dy({name:"passwordlessToken",initialState:_y,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Or.fulfilled,(e,n)=>{e.token=n.payload.token}),t.addCase(Dr.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollPasswordlessToken:oc}=nc.actions,sc=nc.reducer;import{createSelector as Fy}from"@reduxjs/toolkit";function Hy(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}var rc=Fy([qd],t=>t.map(n=>({text:n.response,title:n.name,callToAction:n.callToAction,editable:n.editable,isLoading:n.isLoading,evaluationId:n.evaluationId,rule:{id:Hy(n.code),label:n.code,name:n.name,description:n.name}})));import{useEffect as By,useState as Uy}from"react";import lc from"classnames";import{jsx as ic}from"react/jsx-runtime";var Vt=()=>ic("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:ic("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 ac={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};import{jsx as jt,jsxs as dc}from"react/jsx-runtime";var Ky=({entities:t})=>{let e=x("EntitiesWidgetList",ac),[n,o]=Uy(void 0),s=K(),r=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),Se(a.text),s("entity copied",{entity:a,type:"copy"}))};return By(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[n]),!t||t.length===0?null:jt("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,d)=>dc("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[jt("span",{className:e.entityText,children:a.text}),dc("span",{className:e.iconWrapper,children:[jt("span",{className:lc(e.icon),children:jt(Vt,{})}),jt("span",{className:lc(e.icon,n===d&&e.iconClicked),children:jt(Vt,{})})]})]},a.text))})},cc=Ky;import{jsx as pc}from"react/jsx-runtime";var uc=()=>pc("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:pc("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});import{useRef as Xy}from"react";import{useSelector as Jy}from"react-redux";import{useRef as zy,useState as _r}from"react";import{useDispatch as Wy}from"react-redux";function Qo(t,e){let n=zy(t);n.current=t;let[o,s]=_r(void 0),[r,i]=_r(void 0),[a,d]=_r("idle"),l=Wy();return{error:r,state:a,data:o,call:p=>v(null,null,function*(){d("loading"),yield l(n.current(p)).unwrap().then(f=>{s(f),d("done"),e!=null&&e.onSuccess&&(e==null||e.onSuccess(f))}).catch(f=>{i(f),d("error"),e!=null&&e.onError&&(e==null||e.onError(f))})}),reset:()=>{d("idle"),s(void 0),i(void 0)}}}var gc={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var mc={root:"dd-nazq3",rotation:"dd-3EHTv"};import{jsx as jy}from"react/jsx-runtime";var Vy=({size:t=12})=>{let e=x("LoadingSpinner",mc);return jy("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},fc=Vy;import{jsx as hc}from"react/jsx-runtime";var yc=()=>hc("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:hc("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});import{jsx as vc,jsxs as $y}from"react/jsx-runtime";var xc=t=>$y("svg",S(y({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},t),{children:[vc("title",{id:"checkTitle",children:"Check"}),vc("path",{fill:"#666",d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"})]}));var Fr={};X(Fr,{enUS:()=>Gy,nlNL:()=>qy});var Gy={error:[{type:0,value:"Something went wrong"}]},qy={error:[{type:0,value:"Er ging iets fout"}]};import{jsx as Be,jsxs as Sc}from"react/jsx-runtime";var Qy=3e3,Zy=({assistantOptions:t})=>{let e=x("OnDemandAssistants",gc),n=R(Fr),o=Xy(),s=Qo(Ee),r=Jy(ja),i=K(),a=r.filter(c=>c.isPinned),d=r.filter(c=>!c.isPinned),l=c=>v(null,null,function*(){clearTimeout(o.current),i("trigger on demand assistant",{assistantCode:c}),yield s.call(S(y({},t),{assistantCode:c})),o.current=setTimeout(()=>s.reset(),Qy)});return r.length===0?null:Sc("div",{className:e.root,children:[a.map(({assistant:c,assistantName:u,displayName:p})=>Be("button",{type:"button",className:e.button,disabled:s.state==="loading",onClick:()=>l(c),children:p||u},c)),d.length>0&&Sc($,{placement:"top-end",children:[Be($.Trigger,{className:e.trigger,disabled:s.state==="loading",children:Be(Eo,{"data-testid":"trigger"})}),Be($.Content,{className:e.nav,"data-testid":"popover",children:d.map(({assistant:c,assistantName:u,displayName:p})=>Be($.Button,{className:e.item,disabled:s.state==="loading",onClick:()=>l(c),children:p||u},c))})]}),s.state==="loading"&&Be(fc,{}),s.state==="done"&&Be(xc,{"data-testid":"trigger-done"}),s.state==="error"&&Be(rl,{trigger:Be(yc,{}),children:n("error")})]})},bc=Zy;import{useDispatch as wv}from"react-redux";import{useRef as tv}from"react";var Cc={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};import{jsx as ev}from"react/jsx-runtime";var Yy=({width:t})=>{let e=x("LoadingProgressBar",Cc);return ev("div",{className:e.loadingBar,style:{width:t}})},Zo=Yy;import{jsx as $t,jsxs as nv}from"react/jsx-runtime";var Yo=({title:t})=>{let e=tv(null);return Gn(e),$t(M,{ref:e,children:$t(D,{children:nv(D.Content,{children:[$t(D.Title,{children:t}),$t(Zo,{width:"60%"}),$t(Zo,{width:"90%"}),$t(Zo,{width:"50%"})]})})})};var Dn={};X(Dn,{enUS:()=>ov,nlNL:()=>sv});var ov={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"}]},sv={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"}]};import{useEffect as Lc,useRef as vv,useState as xv}from"react";import Ur from"classnames";import{useState as av}from"react";import{jsx as Tc}from"react/jsx-runtime";var Hr=t=>Tc("svg",S(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Tc("path",{fillRule:"evenodd",d:"M6.57086468,14.9173453 C6.38997052,14.9711236 6.19835748,15 6,15 L4,15 C2.8954305,15 2,14.1045695 2,13 L2,4 C2,2.8954305 2.8954305,2 4,2 L6,2 C6.68685475,2 7.29284112,2.34623869 7.65294381,2.87370078 C7.95642355,2.67736738 8.29504785,2.51351337 8.66312366,2.3818197 C9.50544052,2.08044754 10.3408482,1.9879107 10.9989281,1.99971266 C11.0150698,2.00005426 13.3487605,2.00015005 18,2 C20.7551411,2 22,6.05643086 22,12 C22,13.6824804 20.8695981,15 19,15 L15.9269768,15 C15.9359266,15.0245465 15.9451954,15.0497804 15.9547911,15.0757271 C16.007193,15.2174219 16.2391583,15.8256341 16.2970775,15.9810953 C16.4872151,16.4914441 16.6259612,16.9026411 16.7382242,17.3098712 C16.9079007,17.9253665 17,18.4798886 17,19 C17,20.4720069 16.091867,21.3862822 14.748281,21.777514 C14.1422801,21.9539723 13.6147967,22.0000922 13.0076976,22.0000008 L12.5204954,22 L12.2202699,21.6261158 C11.2556275,20.4248034 7.64562469,16.4822788 6.57086468,14.9173453 Z M8,13 C8,13.2401953 8.04443154,13.4528921 8.14171093,13.6800176 C8.40663864,14.2985643 11.914268,18.1371493 13.4599624,19.9848695 C13.7113931,19.9660111 13.9483736,19.9273712 14.1891338,19.8572655 C14.7621788,19.6904035 15,19.4509737 15,19 C15,18.6834183 14.9359344,18.2976852 14.8101464,17.8413935 C14.7161494,17.500423 14.5944107,17.1396301 14.4229225,16.6793379 C14.3689242,16.5344009 14.1358033,15.923159 14.0789589,15.7694517 C13.9489218,15.4178313 13.8632547,15.1589343 13.8046536,14.9236885 C13.5555377,13.9236468 13.8054549,13 15,13 L19,13 C19.6912225,13 20,12.6401099 20,12 C20,7.20925475 19.015127,4 18,4 C15.9322103,4 15.9322103,4 10.9655994,3.99940813 C10.5253746,3.99154158 9.91062406,4.05963657 9.33687634,4.2649175 C8.45196659,4.58152894 8,5.09776992 8,6 L8,13 Z M4,4 L4,13 L6,13 L6,4 L4,4 Z"})}));import{jsx as wc}from"react/jsx-runtime";var Ec=t=>wc("svg",S(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:wc("path",{fillRule:"evenodd",d:"M7.65336736,21.1256786 C7.2933164,21.6534897 6.68712411,22 6,22 L4,22 C2.8954305,22 2,21.1045695 2,20 L2,11 C2,9.8954305 2.8954305,9 4,9 L6,9 C6.198171,9 6.38961023,9.02882212 6.57035446,9.08250314 C7.6444817,7.51807482 11.2554748,3.57449216 12.2202699,2.37298955 L12.5204954,1.99910538 L13,1.99910538 C13.6147967,1.99901314 14.1422801,2.04513312 14.748281,2.22159137 C16.091867,2.61282321 17,3.52709845 17,4.99910538 C17,5.51921677 16.9079007,6.07373891 16.7382242,6.68923415 C16.6259612,7.09646424 16.4872151,7.50766133 16.2970775,8.01801005 C16.2391583,8.17347129 16.007193,8.78168345 15.9547911,8.92337824 C15.9451954,8.94932503 15.9359266,8.9745589 15.9269768,8.99910538 L19,8.99910538 C20.8695981,8.99910538 22,10.316625 22,11.9991054 C22,17.9426745 20.7551411,21.9991054 18,21.9991054 L11.0344006,21.9985135 C10.3408482,22.0111947 9.50544052,21.9186578 8.66312366,21.6172857 C8.29521907,21.4856533 7.9567386,21.3218904 7.65336736,21.1256786 Z M8,17.9991054 C8,18.9013355 8.45196659,19.4175764 9.33687634,19.7341879 C9.91062406,19.9394688 10.5253746,20.0075638 10.963066,19.9997143 C10.9703499,19.9995545 10.9703499,19.9995545 11,19.9991054 L18,19.9991054 C19.015127,19.9991054 20,16.7898506 20,11.9991054 C20,11.3589955 19.6912225,10.9991054 19,10.9991054 L15,10.9991054 C13.8054549,10.9991054 13.5555377,10.0754586 13.8046536,9.07541689 C13.8632547,8.84017106 13.9489218,8.5812741 14.0789589,8.22965366 C14.1358033,8.07594642 14.3689242,7.46470447 14.4229225,7.31976744 C14.5944107,6.85947528 14.7161494,6.4986824 14.8101464,6.1577119 C14.9359344,5.70142019 15,5.31568707 15,4.99910538 C15,4.54813166 14.7621788,4.30870189 14.1891338,4.1418399 C13.9483736,4.07173418 13.7113931,4.0330943 13.4599624,4.01423587 C11.914268,5.86195611 8.40663864,9.70054105 8.14171093,10.3190878 C8.04443154,10.5462133 8,10.7589101 8,10.9991054 L8,17.9991054 Z M4,11 L4,20 L6,20 L6,11 L4,11 Z"})}));function Ze(t,e){var s;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(r=>{n.classList.add(r)}),n.addEventListener("animationend",()=>n.remove()),(s=t.parentElement)==null||s.appendChild(n)}var Br={};X(Br,{enUS:()=>rv,nlNL:()=>iv});var rv={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},iv={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var kc={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};import{useSelector as Rc}from"react-redux";import{jsx as Gt,jsxs as dv}from"react/jsx-runtime";var lv=({assistantCode:t,assistantOutput:e,evaluationId:n,feedbackType:o,feedbackText:s})=>{let r=x("FeedbackThumbs",kc),i=E("enableFeedbackForm"),a=Rc(xe),d=Rc(Xe(`/admin/feedback?conversationId=${a}&evaluationId=${n}&type=${o}&text=${s}&assistantCode=${t}&assistantOutput=${e}`)),l=R(Br),c=K(),[u,p]=av(null),f=h=>{c("Assistant response feedback",{assistantCode:t,assistantOutput:e,evaluationId:n,rating:h})},m=h=>{h.stopPropagation(),Ze(h.target,r.fadeup),p("up"),f("up")},g=h=>{h.stopPropagation(),Ze(h.target,r.fadedown),p("down"),f("down")};return dv("div",{className:r.thumbs,children:[Gt(M.Button,{title:l("thumbsUp"),onClick:m,icon:Gt(Ec,{}),className:Ur(r.thumbsUp,u==="up"&&r.selected),disabled:!!u}),i&&d?Gt(M.Button,{as:"a",title:l("thumbsDown"),href:d,target:"_blank",rel:"noreferrer",onClick:g,icon:Gt(Hr,{}),className:Ur(r.thumbsDown,u==="down"&&r.selected),disabled:!!u}):Gt(M.Button,{title:l("thumbsDown"),onClick:g,icon:Gt(Hr,{}),className:Ur(r.thumbsDown,u==="down"&&r.selected),disabled:!!u})]})},es=lv;import cv from"dompurify";import{Fragment as Ic,useMemo as pv,useRef as uv,useState as gv}from"react";var Pc={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};import{marked as mv}from"marked";import{jsx as _n,jsxs as ts}from"react/jsx-runtime";function fv(t){return`<button type="button" data-copy-icon class=${t}><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 Kr(t){var n,o;let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(s=>s.remove()),(o=(n=e.textContent)==null?void 0:n.trim())!=null?o:""}function hv(t){return t.replace(/\r\n/g,`
|
|
8
|
-
`)}var yv=({content:t,useLabel:e,copyLabel:n,onCopy:o,onUse:s})=>{let r=x("Markdown",Pc),i=uv(null),[a,d]=gv(null),l=pv(()=>{let g=mv.parse(hv(t));return cv.sanitize(g.toString()).replaceAll("</code>",`${fv(r.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[t]),c=g=>{var T;let h=g.target,b=!!((T=i.current)!=null&&T.querySelector("code"));if(["A","BUTTON"].includes(h.tagName)){d(null);return}a||b&&h.tagName!=="CODE"||!b&&h!==i.current||(h.addEventListener("mouseleave",()=>d(null),{once:!0}),d(h))},u=()=>{if(!a)return;d(null);let g=a.querySelector("button");g&&(Ze(g,r.fadeup),o==null||o(Kr(a)))},p=g=>{let h=g.target,b=h instanceof HTMLElement?h:null;if(h instanceof Element?h.closest("a"):null){g.stopPropagation();return}b&&"copyIcon"in b.dataset&&(Ze(b,r.fadeup),o==null||o(Kr(b.parentElement)))},f=()=>{!a||!s||(d(null),s(Kr(a)))},m=g=>{if(g===null)return;let h=g.getBoundingClientRect();h.left<0?g.style.transform=`translateX(${-h.left+2}px)`:h.right>window.innerWidth&&(g.style.transform=`translateX(${window.innerWidth-h.right-2}px)`)};return ts(Ic,{children:[a&&(o||s)&&ts(zt,{triggerRef:{current:a},className:r.popover,parentNode:a,children:[ts("div",{className:r.options,ref:m,children:[o&&(a==null?void 0:a.tagName)==="CODE"&&_n("button",{type:"button",className:r.option,onClick:u,children:n}),s&&ts(Ic,{children:[_n("div",{className:r.divider}),_n("button",{type:"button",className:r.option,onClick:f,children:e})]})]}),_n("div",{className:r.arrow})]}),_n("div",{ref:i,"data-testid":"widget-markdown-content",className:r.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:c,onClick:p})]})},vt=yv;var zr={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",editableCue:"dd-nWSD-",inputSpace:"dd-DGYB1"};import{jsx as Ue,jsxs as ns}from"react/jsx-runtime";var Sv=500,bv=100,Cv=({content:t,onChange:e,onCopy:n})=>{let o=vv(null),s=x("WidgetCue",zr);return Lc(()=>{let r=o.current;if(!r)return;r.style.setProperty("height","0px");let i=Math.min(Math.max(r.scrollHeight,bv),Sv);r.style.setProperty("height",`${i}px`)},[t]),Ue("textarea",{ref:o,className:s.editableCue,onCopy:n,onChange:e,value:t})},Tv=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:s})=>{let r=x("WidgetCue",zr),i=R(Dn),a=K(),d=E("hasKeyboardInput"),[l,c]=xv(t.text),u=()=>{e&&e(l,t),n(t)},p=(g,h)=>{o&&o(g,t),h&&Ze(h,r.fadeup)},f=g=>{s&&s(g,t)},m=g=>{g.preventDefault(),g.stopPropagation(),n(t)};return Lc(()=>{a("Assistant response displayed",{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text})},[]),ns(M,{"data-testid":"cue",children:[Ue(D,{children:ns(D.Content,{children:[t.title&&Ue(D.Title,{className:r.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?i(t.rule.label):t.title}),t.editable?Ue(Cv,{content:l,onCopy:()=>{let g=document.getSelection();g&&p(g.toString())},onChange:g=>{var h;return c((h=g.target.value)!=null?h:"")}}):Ue(vt,{content:t.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:p,onUse:d?f:void 0})]})}),ns(M.ButtonsContainer,{children:[ns("div",{className:r.actions,children:[Ue(M.Button,{onClick:g=>p(l,g.target),variant:"primary",children:i("copyCue")}),t.callToAction&&Ue(M.Button,{onClick:u,variant:"primary",children:t.callToAction.label}),Ue(M.Button,{onClick:m,variant:"secondary",children:i("removeCue")})]}),Ue(es,{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text,feedbackText:t.text,feedbackType:"assistant"})]})]})},Ac=Tv;import{Fragment as kv,jsx as Wr}from"react/jsx-runtime";var Ev=({cues:t})=>{let e=wv(),n=ne(),o=R(Dn),s=K(),r=l=>{e(Jo({code:l.rule.label})),s("Assistant response closed",{evaluationId:l.evaluationId,assistantCode:l.rule.label,assistantOutput:l.text})},i=(l,c)=>{Se(l),s("Assistant response copied",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,copiedText:l})},a=(l,c)=>{var u;c.callToAction&&(e(Xo(c)),s("Assistant call to action",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,eventName:c.callToAction.event,value:(u=c.callToAction.value)!=null?u:l}))},d=(l,c)=>{var u;n.send(Ae,{text:l,suggestion:{source:"assistant",assistantCode:(u=c.rule)==null?void 0:u.label,sourceText:l}}),s("Assistant response used",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,usedText:l})};return Wr(kv,{children:t.map(l=>l.isLoading?Wr(Yo,{title:l.rule.label.startsWith("__")?o(l.rule.label):l.title},l.rule.id):Wr(Ac,{cue:l,onCallToAction:a,onRemove:r,onCopy:i,onUse:d},l.evaluationId))})},Mc=Ev;import{Fragment as Rv,useEffect as Pv}from"react";var Nc={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};import{jsx as Ke,jsxs as Vr}from"react/jsx-runtime";function Iv(t,e){return e.split(".").reduce((n,o)=>!n||typeof n!="object"||!(o in n)?null:n[o],t)}var Oc=({data:t,schema:e})=>{let n=x("WidgetCustomData",Nc),o=s=>{Se(s)};return Pv(()=>{k.info("Custom data",t,e)},[t]),Ke("dl",{className:n.root,children:e.map(s=>{let r=Iv(t,s.path);return Vr(Rv,{children:[Ke("dt",{className:n.label,children:s.label}),Ke("dd",{className:n.value,children:s.type==="boolean"&&r?Ke("span",{className:n.isTrue,children:s.trueValue}):s.type==="boolean"&&!r?Ke("span",{className:n.isFalse,children:s.falseValue}):s.type==="array"&&Array.isArray(r)&&r.length>0?Vr("button",{type:"button",onClick:()=>o(r.join(", ")),className:n.copyButton,children:[Ke("span",{className:n.copyButtonText,children:r.join(", ")}),Ke(Vt,{})]}):typeof r=="string"||typeof r=="number"?Vr("button",{type:"button",onClick:()=>o(`${r}`),className:n.copyButton,children:[Ke("span",{className:n.copyButtonText,children:r}),Ke(Vt,{})]}):"-"})]},s.label)})})};import{createContext as _v,Fragment as Fv,useContext as $r,useEffect as Hv,useRef as Hc,useState as xt}from"react";import{useDispatch as Bv,useSelector as Uv}from"react-redux";var qt={};X(qt,{enUS:()=>Lv,nlNL:()=>Av});var Lv={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"}]},Av={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:"Gesprek wissen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var os={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",resetContainer:"dd-qKIDX",sources:"dd-xf9c6",source:"dd-a-vyX",tooltip:"dd-EsgcZ",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};import{useRef as Ov}from"react";var Dc={error:"dd-CoAuB"};var jr={};X(jr,{enUS:()=>Mv,nlNL:()=>Nv});var Mv={errorPrefix:[{type:0,value:"Error:"}]},Nv={errorPrefix:[{type:0,value:"Foutmelding:"}]};import{jsx as _c,jsxs as Dv}from"react/jsx-runtime";var Fc=({message:t})=>{let e=Ov(null),n=x("WidgetCardError",Dc),o=R(jr);return Gn(e),_c(M,{ref:e,children:_c(D,{children:Dv(D.Content,{className:n.error,children:[o("errorPrefix")," ",t]})})})};import{jsx as H,jsxs as ze}from"react/jsx-runtime";var Kv=3,zv=({sources:t,onClick:e})=>{let n=R(qt),o=x("WidgetKnowledgeAssistant",os),[s,r]=xt(!1),i=s?t:t.slice(0,Kv);return i.length===0?null:ze("ul",{className:o.sources,children:[i.map(a=>H("li",{className:o.source,"data-testid":"knowledge-assist-source",children:ze($,{tooltip:!0,placement:"top-start",children:[H($.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:d=>{d.stopPropagation(),e(a)},children:H("span",{className:o.linkContent,children:a.name})}),a.url&&H($.Content,{className:o.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),i<t&&H("button",{type:"button",className:o.showMoreSources,onClick:()=>r(!0),children:n("showMore",{amount:t.length-i.length})})]})},Wv=({title:t,description:e})=>H(M,{"data-testid":"knowledge-assist-empty-state",children:H(D,{children:ze(D.Content,{children:[H(D.Title,{children:t}),H(vt,{content:e})]})})}),Vv=({innerRef:t,item:e,hasKeyboardInput:n,onCopy:o,onUse:s,onSourceClick:r})=>{var d;let i=R(qt),a=$r(ss);return ze(M,{"data-testid":"knowledge-assist-answer",ref:t,children:[H(D,{children:ze(D.Content,{children:[H(D.Title,{children:e.question}),H(vt,{content:e.answer.answer,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:o,onUse:n?s:void 0}),H(zv,{sources:(d=e.answer.sources)!=null?d:[],onClick:r})]})}),a.assistantCode&&ze(M.ButtonsContainer,{children:[H("div",{}),H(es,{evaluationId:e.evaluationId,feedbackType:"assistant",assistantCode:a.assistantCode,assistantOutput:e.answer.answer,feedbackText:e.answer.answer})]})]})},ss=_v(null),rs=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,children:o})=>{let[s,r]=xt(null),[i,a]=xt(!1),[d,l]=xt(null),[c,u]=xt(!!n),[p,f]=xt(null),m=Bv(),g=K(),h=Qo(C=>{if(!t)throw new Error("No knowledge assistant was defined");return l(null),e({assistantCode:t,input:C,threadId:s,onNewThreadId(w){r(w)}})},{onSuccess(C){var w;g("Assistant response displayed",{evaluationId:C.evaluationId,assistantCode:t,assistantOutput:C.answer.answer,input:C.question,sources:(w=C.answer.sources)!=null?w:[]}),u(!1)},onError(C){var w;l((w=C.message)!=null?w:"Unknown error")}}),b=C=>v(null,null,function*(){a(!0),f(C),yield h.call(C),a(!1),f(null)}),T={isEnabled:!!t,assistantCode:t,isSubmitting:i,threadId:s,pendingInput:p,errorMessage:d,onSubmit:b,onReset(){s&&m(Qd(s)),l(null),r(null),t&&g("Assistant thread reset",{threadId:s!=null?s:void 0,assistantCode:t})}};return Hv(()=>{n&&T.isEnabled&&b(n)},[n]),H(ss.Provider,{value:T,children:o})},is=()=>{let t=R(qt),e=x("WidgetKnowledgeAssistant",os),n=$r(ss),o=Hc(null),[s,r]=xt(""),i=d=>{r(d.target.value)},a=d=>{d.preventDefault(),n.onSubmit(s).then(()=>{var l;o.current&&((l=o.current)==null||l.focus(),r(""))})};return n.isEnabled?ze("form",{className:e.form,onSubmit:a,children:[H("input",{ref:o,className:e.formInput,placeholder:t("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:s,onChange:i}),H("button",{type:"submit",disabled:n.isSubmitting||s==="",className:e.formSubmit,children:t("submitLabel")})]}):null},as=({title:t,emptyState:e})=>{var m,g;let n=R(qt),o=K(),s=x("WidgetKnowledgeAssistant",os),r=Hc(null),i=$r(ss),a=(g=Uv(Xd((m=i.threadId)!=null?m:-1)))!=null?g:[],d=E("hasKeyboardInput"),l=ne(),c=(h,b)=>{Se(h),i.assistantCode&&o("Assistant response copied",{assistantCode:i.assistantCode,assistantOutput:h,copiedText:h,evaluationId:b.evaluationId})},u=(h,b)=>{i.assistantCode&&o("Assistant source clicked",{evaluationId:b.evaluationId,assistantCode:i.assistantCode,source:h})},p=h=>{h.preventDefault(),i.onReset()},f=(h,b)=>{l.send(Ae,{text:h,suggestion:{source:"assistant",sourceText:h}}),i.assistantCode&&o("Assistant response used",{assistantCode:i.assistantCode,evaluationId:b.evaluationId,assistantOutput:b.answer.answer,usedText:h})};return!i.isEnabled||(a==null?void 0:a.length)===0&&!i.isSubmitting&&!e&&!i.errorMessage?null:ze(Fv,{children:[H(Ie,{type:"knowledge",title:t,"data-testid":"knowledge",children:ze(te,{withDivider:!0,children:[e&&a.length===0&&!i.pendingInput&&H(Wv,y({},e)),a.map((h,b)=>H(Vv,{innerRef:b===a.length-1?r:void 0,item:h,hasKeyboardInput:d,onCopy:T=>c(T,h),onUse:T=>f(T,h),onSourceClick:T=>u(T,h)},`${h.question}_${h.answer}_${b}`)),i.pendingInput&&H(Yo,{title:i.pendingInput}),i.errorMessage&&H(Fc,{message:i.errorMessage})]})}),a.length>0&&H("div",{className:s.resetContainer,children:H(M.Button,{disabled:i.threadId===null||i.isSubmitting,onClick:p,children:n("resetLabel")})})]})};import{useCallback as $v}from"react";var jv=/(https?:\/\/[^\s]+)/,Uc=t=>t.split(" ").find(e=>jv.test(e));import{jsx as Xt,jsxs as ls}from"react/jsx-runtime";var Gv=({suggestion:t,lines:e,onUse:n})=>{var u;let o=t.text||t.url||t.message,s=Uc(o),r=R(In),i=E("showImages"),a=E("fallbackImage"),d=E("hasKeyboardInput"),l=p=>{p.preventDefault(),p.stopPropagation(),d&&n(o)},c=$v(p=>{window.open(s,"_blank"),p.stopPropagation(),p.preventDefault()},[s]);return ls(M,{onClick:d?l:void 0,"data-testid":"edit-suggestion",children:[ls(D,{children:[i&&t.image&&Xt(D.Image,{src:$o(t,"small",a||void 0),title:t.title}),ls(D.Content,{children:[t.title&&Xt(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&Xt(M.Labels,{labels:t.searchKeywords}),Xt(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:o})]})]}),ls(M.Actions,{children:[s&&Xt(M.ActionButton,{onClick:c,label:r("visitUrl")}),d&&Xt(M.ActionButton,{primary:!0,onClick:l,label:r("useSuggestion")})]})]})},Kc=Gv;import{Fragment as Xv,jsx as zc}from"react/jsx-runtime";var qv=({lines:t,suggestions:e})=>{let n=ne(),o=(s,r)=>{n.send(Ae,{text:s,suggestion:S(y({},r),{source:r.source,sourceText:r.text})})};return zc(Xv,{children:e.map(s=>zc(Kc,{suggestion:s,lines:t,onUse:r=>o(r,s)},s.text||s.url||s.message))})},Wc=qv;var Fn={};X(Fn,{enUS:()=>Jv,nlNL:()=>Qv});var Jv={waiting:[{type:0,value:"Loading\u2026"}],waitingForConversation:[{type:0,value:"Waiting for conversation\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"}],close:[{type:0,value:"Close"}]},Qv={waiting:[{type:0,value:"Laden\u2026"}],waitingForConversation:[{type:0,value:"Wachten op gesprek\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"}],close:[{type:0,value:"Sluiten"}]};var Jt={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};import{jsx as P,jsxs as Hn}from"react/jsx-runtime";var jc=(t,e)=>{let n=Z(J);qr(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},ex=({onLogIn:t})=>{let e=x("Widget",Jt),n=E("isEmbedded"),o=E("adminUrl");return P("div",{className:e.loginText,children:P("div",{children:P(Ho,{isEmbedded:n,loginUrl:o,onLogIn:t})})},"login")},Gr=({text:t})=>{let e=x("Widget",Jt);return P("div",{className:e.stateText,children:P("div",{children:P("p",{children:t})})},"notification")},tx=()=>{let t=R(Fn),e=Vc(),n=x("Widget",Jt),o=E("showSearch"),s=E("isEmbedded"),r=Z(Xe("/admin/")),i=ne(),a=E("productName"),d=K();return jc(()=>{if(s)return e(Dr()),()=>{e(oc())}},[e,s]),!o&&!r?null:Hn("div",{className:n.shortcutList,children:[o&&P(M.Button,{"data-testid":"shortcut-search","aria-label":t("linkSearch"),className:n.shortcut,icon:P(Bt,{}),onClick:()=>{i.send("ShowCommandPalette",{isOpen:!0}),d("open search",{via:"widget-shortcut"})},children:t("linkSearch")}),r&&P(M.Button,{as:"a",target:"_blank",icon:P(uc,{}),href:r,"data-testid":"shortcut-studio-login","aria-label":t("linkStudioLogin",{productName:a}),className:n.shortcut,rel:"noreferrer",onClick:()=>{d("open my deepdesk",{via:"widget-shortcut"})},children:t("linkStudioLogin",{productName:a})})]})},nx=({title:t,content:e})=>{let n=R(Fn),[o,s]=Yv(!0);return o?P(Ie,{"data-testid":"custom-data-banner",type:"custom-data-banner",title:t,children:P(te,{withDivider:!0,children:Hn(M,{children:[P(D,{children:P(D.Content,{children:P(vt,{content:e})})}),P(M.ButtonsContainer,{children:P(M.Button,{onClick:()=>s(!1),children:n("close")})})]})})}):null},ox=()=>{let t=Vc(),e=Z(kn),n=Z(Ga),o=Z(rc),s=Z(pa),r=Z(wo),i=Z(Io),a=Z(dt),d=Z(xe);return qr(()=>{s&&!n&&k.warn("Custom data provided, but no schema.")},[s,n]),jc(()=>{e.forEach(({type:l})=>{l==="entities"?t(fe()):Xn.includes(l)||t(he(l))})},[t,d,a]),qr(()=>{o.length>0&&!e.some(l=>l.type==="cues")&&k.warn("Received cues, but cues are not configured in widget.")},[e,o]),P(Zv,{children:e.map(({type:l,title:c,amount:u,lines:p,schema:f,property:m})=>{var g,h;switch(l){case"entities":return r&&r.length>0&&P(Ie,{type:l,title:c,"data-testid":`type-${l}`,children:P(cc,{entities:r})},l);case"cues":return o&&o.length>0&&P(Ie,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P(Mc,{cues:o})})},l);case"custom-data-banner":return s&&m&&s[m]&&P(nx,{title:c,content:String(s[m])},l);case"custom-data":return s&&f&&P(Ie,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P(Oc,{data:s,schema:f})})},l);default:return((h=(g=i[l])==null?void 0:g.suggestions)==null?void 0:h.length)>0&&P(Ie,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P(Wc,{lines:p,contentType:l,suggestions:i[l].suggestions.slice(0,u)||[]})})},l)}})})},Xr=({children:t})=>{let e=x("Widget",Jt);return P("div",{className:e.footer,children:t})},Jr=({children:t})=>{let e=x("Widget",Jt);return P("div",{className:e.root,"data-testid":"widget",children:t})},sx=({onLogIn:t,knowledgeAssistOptions:e={},assistantOptions:n={transcript:"in-memory-transcript"}})=>{let o=R(Fn),s=Z(Lt),r=Z(J),i=Z(qi),a=Z(dt),d=Z($a("knowledge-assist")),l=Z(qa);return s===!1?P(Gr,{text:o("notSupported")}):r===!1?P(ex,{onLogIn:t}):r===null?P(Gr,{text:o("waiting")}):!i||!a?P(Gr,{text:o("waitingForConversation")}):P(Jr,{children:Hn(rs,{initialQuestion:e.initialQuestion,assistantCode:l!=null?l:void 0,evaluateKnowledgeAssistFn:On,children:[Hn(rn,{children:[P(tx,{}),P(ox,{}),d&&P(as,{title:d.title,emptyState:e.emptyState})]}),Hn(Xr,{children:[d&&P(is,{}),P(bc,{assistantOptions:n})]})]})})},$c=sx;function Un(t){let e=new Range;return e.selectNodeContents(t),e}function Gc(t,e,n){try{return St(t,e,n),!0}catch(o){return!1}}function ds(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function cs(t){return"tagName"in t&&t.tagName==="BR"}var Bn=/[\u200B-\u200D\uFEFF]/g;function St(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let s=0,r=!1;function i(d,l){let c=-1,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(d))return l;for(let p=0;p<=d.length;p++)if(u.test(d[p])||c++,c===l)return p;throw new Error("Offset out of range")}function a(d){switch(d.nodeType){case Node.TEXT_NODE:{let l=d.textContent,c=l.replace(Bn,""),u=s+c.length,p=e>=s&&e<=u,f=n>=s&&n<=u;if(p){let m=i(l,e-s);m===0&&!f?o.setStartBefore(d):o.setStart(d,m)}f&&(o.setEnd(d,i(l,n-s)),r=!0),s=u;break}case Node.ELEMENT_NODE:{if(cs(d)&&(s===e&&o.setStartBefore(d),s++,s===n)){o.setEndAfter(d),r=!0;return}for(let c=0;c<d.childNodes.length&&(a(d.childNodes[c]),!r);c++);let l=d.lastChild;ds(d)&&l&&!ds(l)&&!cs(l)&&s++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function ps(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r,collapsed:i}=e,a,d,l=0;function c(u){let p=u===t,f=u===n,m=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let g=u.textContent;f&&(a=l+g.substring(0,o).replace(Bn,"").length),m&&(d=l+g.substring(0,r).replace(Bn,"").length),l+=g.replace(Bn,"").length;break}case Node.ELEMENT_NODE:{if(cs(u)&&u.nextSibling){l++;break}!p&&ds(u)&&u.previousSibling&&l++;for(let g=0;g<u.childNodes.length;g++){let h=f&&g===o,b=m&&g===r;if(h&&(a=l),b&&(d=l),d!==void 0||((!h||!i)&&c(u.childNodes[g]),m&&g===r-1&&(d=l),d!==void 0))break}m&&(d=l);break}default:break}}if(c(t),d===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:d,end:d}}function us(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r,collapsed:i}=e,a=0,d="";function l(c){let u=c===t,p=c===n,f=c===s;switch(p&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let m=p?o:0,g=f?r:void 0;d+=c.textContent.replace(Bn,"").substring(m,g);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&cs(c)&&c.nextSibling){d+=`
|
|
9
|
-
`;break}!u&&!i&&a===1&&
|
|
10
|
-
`);let m=p?o:0,g=f?Math.min(r,c.childNodes.length):c.childNodes.length;for(let h=m;h<g&&(l(c.childNodes[h]),a!==2);h++);break}default:break}f&&(a=2)}return l(t),d}var qc=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(qc||{}),Ye=class{constructor(e){this.element=e;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(e,n){let o=s=>{n(s)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}handleInteraction(){let e=this.getText(),n=this.getHTML(),o=this.getSelection(),s=this.cachedCaretPosition===null;if(!this.isActive||(e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),e!==this.cachedText?(this.cachedText=e,this.cachedHTML=n,s=!0,this.emit("change",{plainText:e,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,s=!0,this.emit("change",{plainText:e,rawHTML:n})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,s=!0,this.emit("selection",o)),!s))return;let r=this.getCaretPosition();$e(r,this.cachedCaretPosition)||(this.cachedCaretPosition=r,this.emit("caretposition",r))}handleClick(){this.handleInteraction()}handleFocus(){let e=!this.isFocused;this.isFocused=!0,e&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let e=this.isFocused;this.isFocused=!1,e&&this.emit("blur")}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(qc).includes(n)||n.toLowerCase()==="z"&&(o||s),this.emit("keydown",e)}handleKeyUp(e){this.handleInteraction(),this.emit("keyup",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var o,s;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((s=e.clipboardData)==null?void 0:s.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 e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()})}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}off(e,n){if(!this.eventListeners[e])return;let o=this.eventListeners[e].indexOf(n);o!==-1&&this.eventListeners[e].splice(o,1)}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function Xc(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Qt=class extends Ye{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),us(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){let n=this.getRootNode();if(n.activeElement!==this.element)return null;let o="getSelection"in n?n.getSelection():window.getSelection();if(!o)return null;let s=o.rangeCount>0?o.getRangeAt(0):null;if(!s)return null;let r=this.element.ownerDocument.createRange();return r.setStart(s==null?void 0:s.startContainer,s==null?void 0:s.startOffset),r.setEnd(s==null?void 0:s.endContainer,s==null?void 0:s.endOffset),!r||!this.element.contains(r.startContainer)||!this.element.contains(r.endContainer)?null:r}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let o=n.getBoundingClientRect();return!Xc(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!Xc(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let n=this.getRange();if(n)return ps(this.element,n);let o=this.lastKnownSelection;if(o&&Gc(this.element,o.start,o.end))return o;let s=Un(this.element);return s.collapse(!1),ps(this.element,s)}getSelectedText(){let{start:n,end:o}=this.getSelection();return us(this.element,St(this.element,n,o))}listen(){super.listen();let n=new MutationObserver(r=>{var i,a;r.length===2&&r[0].addedNodes.length===1&&((i=r[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=r[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 o=this.element.isContentEditable,s=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>s.disconnect())}};var rx=["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 Jc(t,e){let n="mozInnerScreenX"in window,o=document.createElement("div");o.id="input-textarea-caret-position-mirror-div";let s=o.style,r=window.getComputedStyle(t),i=t.ownerDocument.body;s.whiteSpace="pre-wrap",s.wordWrap="break-word",s.position="absolute",s.visibility="hidden",rx.forEach(c=>{s[c]=r[c]}),n?t.scrollHeight>Number.parseInt(r.height)&&(s.overflowY="scroll"):s.overflow="hidden",o.textContent=t.value.substring(0,e);let a=document.createElement("span");a.textContent=t.value.substring(e)||".",o.appendChild(a),i.appendChild(o);let d=t.getBoundingClientRect(),l={top:d.top-t.scrollTop+a.offsetTop+Number.parseInt(r.borderTopWidth)+a.offsetHeight,left:d.left-t.scrollLeft+a.offsetLeft+Number.parseInt(r.borderLeftWidth)};return i.removeChild(o),l}var Zt=class extends Ye{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:o}=this.element;return{start:n,end:o}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return Jc(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 r;return(r=n==null?void 0:n.get)==null?void 0:r.call(this.element)},set:r=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,r),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let o=this.element.disabled,s=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>s.disconnect())}};function Qc(t,e,n){let o=`deepdesk-iframe-${t}`,s=document.getElementById(o);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(n).forEach(([a,d])=>{i.searchParams.append(a,d)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=o,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}function ix(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch(e){return t}}var Qr=class{constructor(e){this.name=e;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(e)}onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(JSON.stringify(e))}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Zr=class{constructor(e,n,o){this.name=e;this.targetOrigin=n;this.options=o;this.disposeHandlers=[];this.iframe=Qc(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(n=>n()),(e=this.iframe)==null||e.remove()}},Yr=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(e){this.externalId!==e&&(this.cleanup(),k.info("Set externalId",e),this.externalId=e,this.channel=this.createChannel(e))}createChannel(e){let n=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Zr(e,this.deepdeskUrl,{debug:!0}):new Qr(e),o=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=ix(s.data);typeof r!="object"||r.type!=="event"||r.channel!==e||(k.info("Received broadcast event",this.externalId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return n.onMessage(o),n}send(e,n,o){var i,a;k.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let s={type:"event",name:e,payload:n};o!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,n));let r=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage(S(y({},s),{channel:this.externalId}))}cleanup(e=!1){var n,o;(n=this.channel)==null||n.close(),this.channel=void 0,e&&((o=this.defaultChannel)==null||o.close(),this.defaultChannel=void 0)}},Zc=Yr;function ax(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function B(t){return Array.isArray(t)?t.map(B):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>S(y({},e),{[ax(n)]:B(t[n])}),{}):t}function lx(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function Y(t){return Array.isArray(t)?t.map(Y):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>S(y({},e),{[lx(n)]:Y(t[n])}),{}):t}var Yt=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var ei=t=>new Promise(e=>{setTimeout(e,t)});var bt=class extends Yt{constructor(){super(...arguments);this.name="ClientError"}},ni=class extends Yt{constructor(){super(...arguments);this.name="ServerError"}},ti=new Map;function dx(t){return v(this,null,function*(){if(t.status===204)return t.text().catch(()=>{}),null;let e=t.headers.get("content-type");if(e!=null&&e.includes("application/json"))return t.json();let n=yield t.text();return n===""?null:(k.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var en=class{constructor(e="",n={}){this.baseUrl=e;this.options=n;this.latestRequestByUrl={};this.refreshingToken=null;this.lastFailedRefreshAt=null;this.failedRefreshCooldown=1e4;var o;this.fetch=(o=n.fetch)!=null?o:window.fetch.bind(window)}patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,n={}){return new Promise((o,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,d=n.method===void 0||n.method.toLowerCase()==="get",N=n,{useCache:l=!1,abortLatest:c=!1,attempts:u=1,retryDelay:p=500,refreshTokenOn401:f=!0,retryOnError:m=_=>_ instanceof TypeError,retryOnResponse:g=_=>_.status>=500,version:h=null}=N,b=A(N,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(l){if(!d)throw new Error(`Can't use 'useCache' for ${n.method}`);if(ti.has(i)){o(ti.get(i));return}}let T=S(y({credentials:"include"},b),{headers:y({Accept:"application/json","Content-Type":"application/json"},b.headers)});!d&&this.csrfToken&&(T.headers=S(y({},T.headers),{"X-CSRFToken":this.csrfToken})),typeof h=="string"&&(T.headers=S(y({},T.headers),{"X-Deepdesk-API-Version":h}));let C=u,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&c&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let I=()=>v(this,null,function*(){return C--,a(i,T).then(_=>v(this,null,function*(){return g(_)&&!r.isAborted&&C>0?(yield ei(p),I()):_.status===401&&f===!0&&w===!1?(w=!0,yield this.refreshToken(),I()):_})).catch(_=>v(this,null,function*(){if(m(_)&&!r.isAborted&&C>0)return yield ei(p),I();throw _}))});I().then(_=>v(this,null,function*(){let W=yield dx(_);if(delete this.latestRequestByUrl[i],_.status>=500){s(new ni("Server Error",W));return}if(_.status===401){s(new bt("Unauthorized",W));return}if(_.status===403){s(new bt("Forbidden",W));return}if(_.status===404){s(new bt("Not Found",W));return}if(_.status>=400){s(new bt("Bad Request",W));return}l&&ti.set(i,W),o(W)})).catch(_=>{s(_)})})}validateToken(){return v(this,null,function*(){let e,n,o;try{({has_valid_access_token:e,is_logged_in:n,has_valid_refresh_token:o}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1}))}catch(s){return!1}if(!e){if(!o)return!1;try{yield this.refreshToken();let{is_logged_in:s}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return s}catch(s){return!1}}return n})}refreshToken(){let e=Date.now();return this.lastFailedRefreshAt&&e-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new bt("Unauthorized","Failed to refresh token")):this.refreshingToken?this.refreshingToken:(this.refreshingToken=this.get("/apis/admin/session/refresh/",{refreshTokenOn401:!1}).catch(n=>{throw(n==null?void 0:n.message)==="Unauthorized"&&(this.lastFailedRefreshAt=Date.now()),n}).finally(()=>{this.refreshingToken=null}),this.refreshingToken)}get(e,n){return this.request(e,n)}post(e,n,o){return this.request(e,y({method:"POST",body:JSON.stringify(n)},o))}patch(e,n,o){return this.request(e,y({method:"PATCH",body:JSON.stringify(n)},o))}put(e,n,o){return this.request(e,y({method:"PUT",body:JSON.stringify(n)},o))}delete(e,n){return this.request(e,y({method:"DELETE"},n))}};var Yc;(e=>{let t;(a=>(a.SUCCESS="success",a.FAILURE="failure",a.CONDITIONS_NOT_MET="conditions_not_met",a.MAX_RECURSION_LEVEL="max_recursion_level",a.NO_ACCESS_TO_ASSISTANT="no_access_to_assistant"))(t=e.EvaluationStatus||(e.EvaluationStatus={}))})(Yc||(Yc={}));function oi(t){return S(y({},B(t)),{metadata:t.metadata})}var Ct=class Ct{constructor(e,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new en(e,{fetch:n.fetch}),this.client.patchFetch(o=>(s,r)=>v(this,null,function*(){let i=yield o(s,r);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return v(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=yield this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(Ct.exchangeTokenPromise||(Ct.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),Ct.exchangeTokenPromise):Promise.resolve()})}createConversation(e){return v(this,null,function*(){var o;yield this.preflight(),k.info(`Creating conversation for session ${e.externalId} and agent ${e.agentId}`);let n=yield this.client.post("/api/v2/conversations",S(y({chat_start_time:new Date().toISOString()},Y(e)),{metadata:(o=e.metadata)!=null?o:{}}));return oi(n)})}getMe(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/session/me/");return B(e)})}postIdentity(e){return v(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",Y(e))})}patchMe(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",Y(e));return B(n)})}getProfile(e){return v(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${e}/`,{useCache:!0});return B(n)})}getKnowledgeAssistant(e){return v(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{useCache:!0});return B(n)})}getContentTypes(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return B(e)})}getAccount(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/account/",{useCache:!0});return B(e)})}getPlatformConfig(e){return v(this,null,function*(){let n=e!==void 0?`/platform/config/${e}/`:"/platform/config/",{config:o}=yield this.client.get(n,{useCache:!0});return B(o)})}checkUserExists(e){return v(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${e}`,{version:"v1"});return n})}getConversationByExternalId(o){return v(this,arguments,function*(e,n={}){yield this.preflight(),k.info(`Getting conversation for session ${e}`);let{attempts:s=1,retryDelay:r=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return k.info(`Successfully retrieved conversation ${i.id} for session ${e}`),oi(i)})}isConversationSupported(o){return v(this,arguments,function*(e,n={}){k.info(`Check if conversation for session ${e} is supported`);let{attempts:s=1,retryDelay:r=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(e,n){return v(this,null,function*(){var r;yield this.preflight();let o=Y(n);n.metadata&&(o.metadata=(r=n.metadata)!=null?r:{});let s=yield this.client.put(`/api/v2/conversations/${e}`,o);return oi(s)})}postMessages(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${e}/messages`,n.map(o=>S(y({},Y(o)),{metadata:o.metadata})))})}sendEvent(e,n){return v(this,null,function*(){yield this.preflight();let a=n,{data:o}=a,s=A(a,["data"]),r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((d,[l,c])=>S(y({},d),{[l]:c}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((d,l)=>(s[l]&&(d[l]=s[l]),d),{});return this.client.post("/api/v2/events",Y(S(y(y({},r),i),{data:o,name:e})),{version:"v2"})})}getEntities(e){return v(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:e.filter(o=>o.text)})})}getTemporaryExchangeToken(){return v(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(e){return v(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:e}).catch(n=>{throw k.warn(`Invalid token '${e}'`),n})})}authenticateWithKey(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Y(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(s){return v(this,arguments,function*(e,n={},o){if(yield this.preflight(),o==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${e}/recommend/${o}`,Y(n),{abortLatest:!0})).map(i=>S(y({},B(i)),{text:i.text||i.url||i.message,source:o,type:o})).filter((i,a,d)=>a===d.findIndex(l=>l.text===i.text))})}isLoggedIn(){return v(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(e,n){return v(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${e}/autocomplete`,Y(n),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))})}getPinnedMessages(e){return v(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return B(n).map(o=>S(y({},o),{text:o.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(e){return v(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",Y(e),{abortLatest:!0,version:"v2"});return B(n)})}search(e){return v(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${e.profile}/search`,Y(e));return B(n)})}requestLoginByEmail(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:e});return B(n)})}requestPasswordlessToken(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/session/passwordless/request/");return B(e.token)})}getCsrfToken(){return v(this,null,function*(){let{token:e}=yield this.client.get("/apis/admin/session/csrf/");return e})}verifyLoginToken(e){return v(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:e});return B(n)})}evaluateAssistant(e,n){return v(this,null,function*(){var i;yield this.preflight();let o=new URLSearchParams;n!=null&&n.externalConversationId&&o.append("external_conversation_id",n.externalConversationId);let s=n!=null&&n.threadId?`/api/v2/assistants/${e}/threads/${n==null?void 0:n.threadId}/evaluate?${o.toString()}`:`/api/v2/assistants/${e}/evaluate?${o.toString()}`,r=yield this.client.post(s,{input:(i=n==null?void 0:n.input)!=null?i:{},conversation:n==null?void 0:n.transcript});return B(r)})}createAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n}=e,o=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return B(o)})}postMessageToAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:s}=e,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:s,role:"user"});return B(r)})}translateMessages(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",Y(e));return B(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let s=o.toLowerCase(),r=s.match(Ni);if(!n||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&k.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};Ct.exchangeTokenPromise=null;var et=Ct;import{combineReducers as hx,configureStore as yx}from"@reduxjs/toolkit";import{createSlice as cx}from"@reduxjs/toolkit";var ep={startTime:null,stopTime:null},tp=t=>t.handlingTime,np=cx({name:"handlingTime",initialState:ep,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(V,()=>ep)}}),{handlingTimeStart:op,handlingTimeStop:gs,handlingTimeReset:sp}=np.actions,rp=np.reducer;var ip=(t={})=>{let e=y({onAuthError:Pt(!1)},t);return n=>o=>s=>("error"in s&&s.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(s))};import{createAsyncThunk as px,createSlice as ux}from"@reduxjs/toolkit";var ms={list:{keywordMatches:[]},fetchState:"idle"};var Tt=px("styleSuggestions/getAll",(n,o)=>v(null,[n,o],function*({text:t},e){var d;let{deepdeskAPI:s}=e.extra,r=e.getState(),{showStyleSuggestions:i}=r.settings,a=(d=r.conversation.current)==null?void 0:d.profileCode;if(!i)return ms.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return s.getStyleSuggestions({profileCode:a,message:t})})),gx=ux({name:"styleSuggestions",initialState:ms,reducers:{},extraReducers:t=>{t.addCase(Tt.pending,e=>{e.fetchState="loading"}).addCase(Tt.rejected,e=>{e.fetchState="error"}).addCase(Tt.fulfilled,(e,n)=>{e.fetchState="done",$e(e.list,n.payload)||(e.list=n.payload)}).addCase(it,e=>{e.list=ms.list}).addCase(V,()=>ms)}}),ap=gx.reducer;var lp=(t={})=>{let e,n=!0,o=y({getStyleSuggestions:Tt,debounce:500},t);return s=>r=>i=>{var f;let a=s.getState().input.text,d=r(i),l=s.getState();if(l.auth.isLoggedIn!==!0)return d;let{showStyleSuggestions:c}=l.settings;if(!((f=l.conversation.current)==null?void 0:f.id)||!c)return d;let{text:p}=l.input;return p===a&&!n||(clearTimeout(e),p==="")||(e=setTimeout(()=>{n=!1,s.dispatch(o.getStyleSuggestions({text:p}))},t.debounce)),d}};function mx(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var dp=(t={})=>{let e=y({getTextSuggestions:he,getAutocompleteSuggestions:An,debounce:200,check:Te},t),n;return o=>s=>r=>{var g;let{input:i}=o.getState(),a=s(r),d=o.getState();if(d.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:c}=d.settings,u=(g=d.conversation.current)==null?void 0:g.id,p=r.type===Lo.toString();if(!u||!l&&!c)return a;let{input:f}=d;return mx(f,i)&&!p||(clearTimeout(n),!e.check(d))||(n=setTimeout(()=>{let h=At(d);h===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(h))},p?0:e.debounce)),a}};var cp=Tt.fulfilled.toString();function fx(t,e){let n=new Set([...e.keywordMatches.map(s=>s.keyword)]),o=[];return n.forEach(s=>{let r=t.keywordMatches.filter(d=>d.keyword===s),i=e.keywordMatches.filter(d=>d.keyword===s),a=i.length-r.length;a<=0||o.push(...i.slice(0,a))}),o}var pp=t=>e=>n=>o=>{var l;if(o.type!==cp){n(o);return}let s=e.getState().styleSuggestions.list;n(o);let r=e.getState(),i=r.styleSuggestions.list,a=(l=r.conversation)==null?void 0:l.current;if(s===i)return;let d=fx(s,i);o.type===cp&&d.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:d}})};var vx=hx({assistants:ec,auth:Wi,conversation:Xi,contentTypes:Va,passwordlessToken:sc,entities:bl,handlingTime:rp,info:va,input:la,settings:_i,profile:Xa,search:wa,styleSuggestions:ap,ui:Ql,textSuggestions:Dl});function up(t){return yx({reducer:vx,middleware:e=>{var o;let n=e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}).concat(ip()).concat(dp({debounce:200})).concat(lp({debounce:500})).concat(pp(t.deepdeskAPI));return((o=t.middleware)!=null?o:[]).reduce((s,r)=>s.concat(r),n)},preloadedState:t.preloadedState})}var xx=t=>{var e,n;return(n=(e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())!=null?n:"unknown"},Sx=t=>e=>n=>o=>{var a,d;let s=e.getState(),r=Rt("inlineSuggestions")(s);switch(o.type){case Pt.toString():{!o.payload&&t.emit("logout",void 0);break}case fe.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:(a=s.conversation.current)==null?void 0:a.id,data:{entities:o.payload}});break;case it.toString():t.logSendMessage(o.payload);break;case Xo.toString():t.emit("call-to-action",{cue:o.payload});break;case Ee.fulfilled.toString():o.isBroadcasted||t.broadcast(Hs,o,!1);break;default:break}let i=n(o);switch(o.type){case it.toString():t.handleAfterSendMessage(o.payload);break;case Mn.toString():t.onUpdateShowTabHint(o.payload);break;case gs.toString():t.logHandlingTime();break;case Nt.toString():t.broadcast(po,o);break;case rt.toString():t.broadcast(po,o);break;case Jo.toString():e.dispatch(rt({source:"assistant",assistantCode:o.payload.code}));break;case"analytics/logEvent/fulfilled":{let l=s.assistants.cues.find(c=>c.code===o.meta.arg.data.assistantCode);t.emit("event",S(y({},o.meta.arg),{cue:l}));break}case se.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",S(y({type:xx(o.payload.suggestion)},o.payload),{replace:o.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}})),r&&e.dispatch(Ge([]));break}case no.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(d=s.conversation.current)==null?void 0:d.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Ge.toString():{r&&o.payload.length>0&&e.dispatch(oo(0));break}default:break}return i},gp=Sx;import{createSelector as bx}from"@reduxjs/toolkit";function si(t){return t.toISOString().replace("T"," ").replace("Z","")}var Cx=(t,e)=>e.version,mp=bx([Ot,xe,tp,Cx],(t,e,n,o)=>{if(!e)return k.warn("No conversationId for handling time metrics"),null;let{startTime:s,stopTime:r}=n;return!s||!r?(k.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:e,clientVersion:o,agentId:t==null?void 0:t.agentId,agentName:t==null?void 0:t.agentName,agentEmail:t==null?void 0:t.agentEmail,timeStart:si(s),timeStop:si(r)}});function fp(t,e){let{text:n,metrics:{numPaste:o,pastes:s,textSuggestions:r}}=t.input,i=n.length;return{source:"agent",clientVersion:e.version,pastes:s,lenTextTotal:i,numPastes:o,suggestions:r}}function ri(t,e){var r;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return ri(o,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?ri(s,e):null}function ii(t,e){return ri(t,e)}function hp(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Tx(t){return typeof t=="object"&&t!==null&&"tagName"in t}function ai(t){return Tx(t)&&(ht(t)||Bo(t))}var vp,ke=new Map,wx=["bottom","height","left","right","top","width"],yp=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:wx.some(n=>t[n]!==e[n]);function xp(t){var n,o,s;if(t.ownerDocument===document)return[];let e=(s=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?s:null;return e?[e,...xp(e)]:[]}function Sp(t,e){return!t||!e?null:S(y({},t),{top:t.top+e.top,left:t.left+e.left})}var fs=!1,bp=()=>{fs=!0;let t=[];if(ke.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),ke.delete(n);return}let o=n.getBoundingClientRect();yp(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{let n=e.parentRects?e.parentRects.reduce(Sp,e.rect):e.rect;yp(n,e.totalRect)&&e.callbacks.forEach(o=>o(n)),e.totalRect=n}),ke.size===0){fs=!1;return}vp=window.requestAnimationFrame(bp)};function li(t,e){let n=xp(t),o=[],s=n.map((r,i)=>li(r,a=>{o[i]=a;let d=ke.get(t);if(!d)return;let l=o.reduce(Sp,d.rect);d.callbacks.forEach(c=>c(l))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),ke.has(t)){let i=ke.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else ke.set(t,{rect:void 0,callbacks:[e],parentRects:o});r&&!fs&&bp()},unobserve(){s.forEach(i=>i.unobserve());let r=ke.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||ke.delete(t),ke.size||(cancelAnimationFrame(vp),fs=!1)}}}}var Cp,Re=new Map,Tp=()=>{Re.forEach((t,e)=>{if(!e.isConnected){Re.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,s=o>n;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),Re.size!==0&&(Cp=window.requestAnimationFrame(Tp))};function wp(t,e){return{observe(){let n=Re.size===0;Re.has(t)?Re.get(t).callbacks.push(e):Re.set(t,{visible:void 0,callbacks:[e]}),n&&Tp()},unobserve(){let n=Re.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||Re.delete(t),Re.size||cancelAnimationFrame(Cp)}}}}var di=["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 ci(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function tn(t){return Number.parseFloat(t)}function hs(t){return Math.round(t*1e6)}function Ep(t){return t/1e6}function pi(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,s=tn(t.width),r=tn(t.borderLeftWidth),i=tn(t.borderRightWidth),a=tn(t.paddingRight),d=Ep(hs(s)-hs(r)-hs(i)),l=Ep(hs(o));if(d-l>2){let c=d-l;n.style.paddingRight=`${a+c}px`}}function ys(t,e={}){var c,u;let n=e.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=e.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",mt(n);let o=window.getComputedStyle(t),s=!0,r=()=>{n.scrollTop=t.scrollTop};ci(o,n,di),pi(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",r));let i=wp(t,()=>{ci(o,n,di),pi(o,t,n),r(),setTimeout(r,0)}),a,d=!0,l=li(t,p=>{if(p===null){e.onRemove&&e.onRemove(),n.remove();return}if(!d&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),d=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),d=!1},200),p.height===0&&p.width===0){if(s===!0)return;e.onHide&&e.onHide(),n.style.display="none",s=!0;return}if(ci(o,n,di),pi(o,t,n),r(),e.placement==="below"&&n.classList.add("below"),n.style.top=`${p.top}px`,n.style.left=`${p.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let f=e.closestScrollElement.getBoundingClientRect(),m=window.getComputedStyle(e.closestScrollElement),g=tn(m.borderTopWidth),h=tn(m.borderBottomWidth),b=f.top+g-p.top,T=p.top+p.height+-(f.top+f.height-h);n.style.clipPath=`inset(${b}px 0px ${T}px 0px)`}s&&(n.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(n):(u=t.parentElement)==null||u.appendChild(n),l.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",r),l.unobserve(),i.unobserve(),n.remove()}]}var kp=(t,e)=>({value(){try{let n=sessionStorage.getItem(`dd-${t}`);if(!n)return e;try{return JSON.parse(n)}catch(o){return e}}catch(n){return e}},update(n){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(n))}catch(o){k.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Ex(t){return t.offsetParent!==null}function Rp(t){if(!Ex(t))return!1;let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function ui(t,e,n=100){let o=Rp(t);e({isVisible:o});let s=setInterval(()=>{let r=Rp(t);r!==o&&(o=r,e({isVisible:o}))},n);return()=>{clearTimeout(s)}}var Kn=class extends Error{};function kx(){let t,e;return{promise:new Promise((o,s)=>{t=o,e=s}),resolve:t,reject:e}}var vs=class{constructor(){this.queues={}}push(e,n){let o=()=>{let r=this.queues[e][1];r?(this.queues[e]=[r.promise,null],r.resolve()):delete this.queues[e]};if(!this.queues[e]){let r=n().finally(o);return this.queues[e]=[r,null],r}this.queues[e][1]&&this.queues[e][1].reject(new Kn("Queued async function is outdated"));let s=kx();return this.queues[e][1]=s,s.promise.then(()=>n().finally(o))}};var Rx={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},Pp=(t,e)=>{var s,r,i;if(!((i=(r=(s=t.uiConfig)==null?void 0:s.widget)==null?void 0:r.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return k.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let o=t[Rx[e]];return o&&o.length>0?o.map(a=>a.code):(k.warn(`No assistant set in profile for conversation event "${e}"`),[])};var xs=class{constructor(e){this.options=e;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,o;this.socket,this.eventListeners=new Map,this.url=e.url,this.maxReconnectAttempts=(n=e.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(o=e.reconnectInterval)!=null?o:this.reconnectInterval,this.shouldReconnect=e.shouldReconnect}connect(){let e=()=>this.cleanup();window.addEventListener("beforeunload",e),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",e)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=e=>{var n;try{let o=B(JSON.parse(e.data));o.event&&this.eventListeners.has(o.event)&&((n=this.eventListeners.get(o.event))==null||n.forEach(s=>s(o.data)))}catch(o){console.error("Error parsing WebSocket message:",o)}},this.socket.onclose=e=>{console.log("WebSocket connection closed:",e),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=e=>{console.error("WebSocket error:",e)})}reconnect(){var e,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(e=this.socket)==null||e.close();return}if(!this.shouldReconnect()){console.error("Should not reconnect, closing WebSocket connection."),(n=this.socket)==null||n.close();return}this.socket&&(this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this.socket=new WebSocket(this.url),this.setupListeners(),this.maxReconnectAttempts--}send(e,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:e,data:n}))}on(e,n){this.eventListeners.has(e)||this.eventListeners.set(e,[]);let o=this.eventListeners.get(e);o&&!o.includes(n)&&o.push(n)}close(){var e;(e=this.socket)==null||e.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(e=>e()),this.cleanupCallbacks=[]}};import Lx,{useState as mi,useEffect as Ax}from"react";var Ip={root:"dd-7zvcP",dialogContent:"dd-4C0lK",continueButton:"dd-YUPQW",buttonContinueWrapper:"dd-IKpYs",nicknameInput:"dd-rxhGp",titleWrapper:"dd-nw3nD",title:"dd-5iof5",closeButtonWrapper:"dd-UUAzA",closeButton:"dd-7rjP5",buttonsWrapper:"dd-5e9Xb",errorMessage:"dd--5VgX",errorLink:"dd-u461n"};import{useSelector as Mx}from"react-redux";var gi={};X(gi,{enUS:()=>Px,nlNL:()=>Ix});var Px={title:[{type:0,value:"Enter your nickname"}],close:[{type:0,value:"Close"}],nicknameDialogTitle:[{type:0,value:"Please enter the name you'd like customers to see during chat conversations. This nickname will be used across your Deepdesk environment."}],nicknameDialogInputPlaceholder:[{type:0,value:"Enter your nickname"}],nicknameDialogContinueButton:[{type:0,value:"Continue"}],nicknameDialogError:[{type:0,value:"Nickname cannot be empty or spaces only"}],nicknameDialogEmojiError:[{type:0,value:"You cannot use emojis in this field."}],nicknameDialogSaveError:[{type:0,value:"We couldn't save your details just now. Please try again, or update it at "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We couldn\u2019t save your details just now. Please try again later, or update them in My Deepdesk \u2192 Settings."}]},Ix={title:[{type:0,value:"Voer je bijnaam in"}],close:[{type:0,value:"Sluiten"}],nicknameDialogTitle:[{type:0,value:"Voer de naam in die je wilt dat klanten zien tijdens chatgesprekken. Deze bijnaam wordt gebruikt in je Deepdesk-omgeving."}],nicknameDialogInputPlaceholder:[{type:0,value:"Voer je bijnaam in"}],nicknameDialogContinueButton:[{type:0,value:"Doorgaan"}],nicknameDialogError:[{type:0,value:"Bijnaam mag niet leeg of alleen spaties zijn"}],nicknameDialogEmojiError:[{type:0,value:"Je kunt geen emoji's gebruiken in dit veld."}],nicknameDialogSaveError:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw of werk het bij op "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw later, of werk ze bij in My Deepdesk \u2192 Instellingen."}]};import{Fragment as Nx,jsx as ve,jsxs as Ss}from"react/jsx-runtime";var Lp=({onClose:t,onSave:e,id:n,error:o})=>{let[s,r]=mi(""),[i,a]=mi(!1),[d,l]=mi(!1),c=x("Nickname",Ip),u=Lx.useRef(null),p=Mx(b=>b.info.showNicknameDialog),f=R(gi),m=E("adminUrl");Ax(()=>{o&&a(!0)},[o]);let g=()=>{if(!u.current)return;s.trim()?u.current.setCustomValidity(""):u.current.setCustomValidity(f("nicknameDialogError")),u.current.reportValidity()},h=b=>{b.preventDefault();let T=s.trim(),C=b.currentTarget.querySelector("#nickname-input");if(!T){C.setCustomValidity(f("nicknameDialogError")),C.reportValidity();return}C.setCustomValidity(""),e(T)};return Ss(Ft,{isOpen:p,"datatest-id":n,onClose:t||(()=>{}),onBack:t||(()=>{}),children:[ve("div",{className:c.titleWrapper,children:ve("h1",{className:c.title,children:f("title")})}),Ss("form",{className:c.dialogContent,onSubmit:h,children:[ve("p",{children:f("nicknameDialogTitle")}),i&&o&&ve("div",{className:c.errorMessage,children:m?(()=>{let b=f("nicknameDialogSaveError",{account:m}),T=`${m}.deepdesk.com/admin/user-settings`,C=b.indexOf(T);if(C!==-1){let w=b.substring(0,C),I=b.substring(C+T.length);return Ss(Nx,{children:[w,ve("a",{href:T,target:"_blank",rel:"noopener noreferrer",className:c.errorLink,children:T}),I]})}return b})():f("nicknameDialogSaveErrorWithoutLink")}),ve("input",{required:!0,minLength:1,maxLength:20,"data-testid":"nickname-input",id:"nickname-input",className:c.nicknameInput,type:"text",placeholder:f("nicknameDialogInputPlaceholder"),value:s,onChange:b=>{l(new RegExp("\\p{Extended_Pictographic}","u").test(b.target.value)),r(b.target.value)},onBlur:g,ref:u}),d&&ve("div",{className:c.errorMessage,role:"alert",children:f("nicknameDialogEmojiError")}),Ss("div",{className:c.buttonsWrapper,children:[o?ve("div",{className:c.closeButtonWrapper,children:ve("button",{type:"button",className:c.closeButton,onClick:()=>t==null?void 0:t(),children:f("close")})}):null,ve("div",{className:c.buttonContinueWrapper,children:ve("button",{type:"submit",className:c.continueButton,disabled:!s.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(s),children:f("nicknameDialogContinueButton")})})]})]})]})};import{jsx as F,jsxs as Ox}from"react/jsx-runtime";var Ap=kp("showTabHint",!0),nn=class nn{constructor({deepdeskUrl:e,version:n=nn.version||"unknown",locale:o="en-US",token:s,fetch:r,productName:i,createCustomChannel:a,websocketClient:d=xs}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.disposeHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.belowSuggestions=null;this.floatingMenu=null;this.widgetElement=null;this.widgetRoot=null;this.nicknameDialogUnsubscribe=null;this.nicknameDialogFailed=!1;this.dynamicThunkObject={};this.queues=new vs;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=e.replace(/\/api$/,"");this.deepdeskApi=new et(l,{token:s,fetch:r}),this.version=n,this.instanceId=nn.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[gp({broadcast:(m,g,h)=>{this.broadcastEvents.send(m,g,h)},emit:(m,g)=>this.emit(m,g),handleAfterSendMessage:m=>this.handleAfterSendMessage(m),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:m=>this.logSendMessage(m),onUpdateShowTabHint:m=>Ap.update(m),sendEvent:(m,g)=>this.deepdeskApi.sendEvent(m,g)})]};this.store=up(c),this.broadcastEvents=new Zc({debug:!0,deepdeskUrl:l,eventMap:Ea(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new d({url:`${l}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>v(this,null,function*(){var m;return(m=J(this.state))!=null?m:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(Mn(Ap.value())),this.store.dispatch(Qn({locale:o,adminUrl:l,productName:i}));let u=[],p=m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(Yd(m))};this.hasConversation()?g():u.push(g)};this.ws.on("assistants::direct_response",p),this.ws.on("assistants::user_notification",p),this.ws.on("assistants::response_chunk",m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(Zd(m))};this.hasConversation()?g():u.push(g)}),this.ws.on("assistants::suggest_as_reply",m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(Nt([{text:m.payload.message,type:"text",source:"assistant",assistantCode:m.code,sourceLabel:m.name}]))};this.hasConversation()?g():u.push(g)});let f=this.whenConversationLoaded(()=>{var m;this.broadcastEvents.setExternalId((m=this.state.conversation.current)==null?void 0:m.externalId),u.forEach(g=>g()),u.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),u.length=0,f()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var e;return(e=st(this.state)[this.state.input.selectedSuggestionIndex])!=null?e:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}externalId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.externalId}shouldAbort(){return this.state.conversation.isSupported===!1?(k.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(k.warn("Profile has not been loaded (yet)"),!0):(k.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(e){if(J(this.state))e();else{let n=this.subscribe(J,o=>{o&&e()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch(Pt(null)),this.store.dispatch(Le()),new Promise(e=>{this.whenLoggedIn(()=>e())})}isLoggedIn(){return v(this,null,function*(){return(yield this.store.dispatch(Le())).payload})}isConversationSupported(e,n){return v(this,null,function*(){return(yield this.store.dispatch(As({externalId:e,options:n}))).payload})}createConversation(e){return v(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Yn(S(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}getConversationByExternalId(e,n){return v(this,null,function*(){return this.hasConversation()&&this.externalId()!==e&&this.resetConversation(),(yield this.store.dispatch(eo({externalId:e,options:n}))).payload})}upsertConversation(e){return v(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Ms(S(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return v(this,null,function*(){yield this.store.dispatch(Ns(e))})}updateConversation(e){return v(this,null,function*(){return(yield this.store.dispatch(to(e))).payload})}resetConversation(){this.store.dispatch(V()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(Qn(e))}setVisitorInfo(e){this.store.dispatch(ma(e))}setCustomData(e){this.store.dispatch(fa(e))}setAgentInfo(e,n){return v(this,null,function*(){var s;yield this.store.dispatch(cn(y(y({},e),n))),(s=this.state.info.agentInfo)!=null&&s.agentNickname||this.broadcastEvents.send(co,{showNicknameDialog:!0})})}setAgentSettings(e){return v(this,null,function*(){yield this.store.dispatch(Ds(e))})}getAgentSettings(){return v(this,null,function*(){return(yield this.store.dispatch(_s())).payload})}refresh(){return v(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let e=[];return e.push(this.refreshTextSuggestions()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(so({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}))}notifyExternalSuggestion(e){this.store.dispatch(se(e))}evaluateAssistant(e,n){return v(this,null,function*(){var d;let{input:o={},transcript:s,showCuesInWidget:r=!0,includeMetadata:i}=n||{},a=yield this.store.dispatch(Ee({assistantCode:e,transcript:s,includeMetadata:i,input:o,skipState:!r}));if(a.error)throw new Error(`Assistant evaluation failed: ${(d=a.payload)!=null?d:a.error.message}`);return a.payload.output})}evaluateConversationAssistant(e,n){return v(this,null,function*(){yield this.loadProfileConfig();let o=this.state.profile.data;if(!o){k.warn("Can't evaluate assistant when profile is not loaded yet.");return}let s=Pp(o,e);yield Promise.all(s.map(r=>this.queues.push(r,()=>v(this,null,function*(){yield this.evaluateAssistant(r,y({includeMetadata:!0},n))})).catch(i=>{if(i instanceof Kn){k.warn(`Queued assistant "${r}" was outdated and dropped`);return}throw i})))})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:s,selectedSuggestionIndex:r,selection:i}=this.state.input,{inlineSuggestions:a,showTextSuggestions:d,suggestionsPlacement:l}=this.settings,c=l==="inline"||l==="below"?"below":"above",u=s.length>0;if(this.store.dispatch(ta(Os(e))),!Te(this.state)||e.key!=="Tab"&&!d)return;let p=()=>{n||!u||i&&(e.shiftKey||(this.store.dispatch(sa()),e.preventDefault()))},f=()=>{n||!u||a&&r<=0||i&&(e.shiftKey||(this.store.dispatch(ra()),e.preventDefault()))};switch(e.key){case"ArrowUp":c==="below"?f():p();break;case"ArrowDown":{c==="below"?p():f();break}case"Escape":{n||(this.store.dispatch(oo(-1)),this.store.dispatch(Je({collapse:!0})),this.store.dispatch(Xl(!0)),e.preventDefault());break}case"Tab":{e.preventDefault();let m=Mt(this.state);if(!m)return;this.store.dispatch(Mn(!1)),this.store.dispatch(se({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let m=Mt(this.state);if(!m)return;this.store.dispatch(se({text:m.text,suggestion:m,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.settings.inlineSuggestions||e.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let m=Mt(this.state);if(!m)return;this.store.dispatch(se({text:m.text,suggestion:m,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),e.preventDefault();break}default:}n&&o&&this.store.dispatch(Je({collapse:!1}))}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ge([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(op()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(gs()))}logSendMessage(e){let n=fp(this.state,{version:this.version});n&&(e&&(Object.assign(n,{text:e}),Object.assign(n,{lenTextTotal:e.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let e=mp(this.state,{version:this.version});e&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:e}),this.store.dispatch(sp()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch(it((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(aa()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(s=>{try{s(n)}catch(r){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.error(r)}})}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}setPlatformVariables(e){this.store.dispatch(ha(e))}whenConversationLoaded(e){let n=r=>{var i;return(i=r.conversation.current)==null?void 0:i.id},o=()=>this.loadProfileConfig().then(()=>e());return n(this.state)&&o(),this.subscribe(n,r=>{r&&o()})}overlayContainerFactory(e,n,o,s){let[r,i]=ys(n,o);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),[r,i]}createInlineContainer(e,n){var a;let o=document.createElement("div");o.style.position="absolute",o.style.top="0px",o.style.left="0px",o.style.height="0px",o.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",o.appendChild(s);let r=(a=e.ownerDocument.defaultView)==null?void 0:a.frameElement,i=r?r.ownerDocument.defaultView:null;if(r&&(i===window||(i==null?void 0:i.parent)===window)){let[d,l]=ys(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});d.dataset.testid=n,d.style.zIndex="2",d.appendChild(o),this.unmountHandlers.push(()=>{l()})}else document.body.appendChild(o);return s}createContainer(e,n=document.body){let o=window.getComputedStyle(n),s=document.createElement("div");return mt(s),s.dataset.testid=e,s.style.color=o.color,s.style.fontSize=o.fontSize,s.style.fontFamily=o.fontFamily,s.style.fontVariant=o.fontVariant,s.setAttribute("translate","no"),n.appendChild(s),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,n),k.info(`Stored analytics for ${this.conversationId()}`)}catch(e){}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(e);if(!n)return;let o=JSON.parse(n);o.text.trim()===this.state.input.text.trim()?(k.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(ia(o.metrics))):k.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch(e){}}mount(e,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!ai(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let p=n,{customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i,inputMediator:a}=p,d=A(p,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i};this.configure(d),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),mt(e),this.inputMediator=a||(ht(e)?new Zt(e):new Qt(e)),this.inputMediator.on("change",({plainText:f,rawHTML:m})=>{this.store.dispatch(so({text:f,html:m}))}),this.inputMediator.on("keyup",f=>{this.store.dispatch(na(Os(f)))}),this.inputMediator.on("keydown",f=>{this.handleKeyDown(f)}),this.inputMediator.on("paste",({pastedText:f,selectionText:m})=>{this.store.dispatch(oa({text:f,selectionText:m}))}),this.inputMediator.on("cut",({selectionText:f})=>{this.store.dispatch(ea(f))});let c;this.inputMediator.on("selection",f=>{clearTimeout(c),f===null?c=setTimeout(()=>{f!==null&&this.store.dispatch(ro(f))},500):this.store.dispatch(ro(f))}),this.unmountHandlers.push(()=>{clearTimeout(c)}),this.inputMediator.on("disabled",()=>{var f;(f=this.inputMediator)==null||f.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(No(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(No(!0))}),this.renderSuggestions(e,l),this.subscribe(Rt("inlineSuggestions"),()=>{this.renderSuggestions(e,l)}),this.subscribe(Rt("suggestionsPlacement"),()=>{this.renderSuggestions(e,l)});let u=this.renderOverlays(n);this.unmountHandlers.push(()=>{u.unmount()}),this.store.dispatch(so({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(ro(this.inputMediator.getSelection())),this.store.dispatch(No(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{this.restoreMetrics(),this.syncInputMediator(),this.refreshTextSuggestions(),this.promptForNickname()}),this.isMounted=!0}promptForNickname(e){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let o=tt(n),s=null,r=a=>{s=a,i()},i=()=>{o==null||o.render(F(_e,{store:this.store,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(Lp,{id:"deepdesk-nickname-dialog",error:s,onSave:a=>v(this,null,function*(){try{yield this.store.dispatch(ua({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(co,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(d){k.error("Error setting agent nickname",d),r("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{o.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(e,n){let o=e(this.store.getState());return this.store.subscribe(()=>{let s=e(this.store.getState());s!==o&&(o=s,n(o))})}unmount(){var e,n,o,s,r;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.belowSuggestions)==null||o.unmount(),(s=this.floatingMenu)==null||s.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(r=this.inputMediator)==null||r.dispose(),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe(),this.isMounted=!1}dispose(){this.unmount(),this.unmountWidget(),this.disposeHandlers.forEach(e=>e()),this.disposeHandlers=[],this.off()}renderSuggestions(e,n){var o,s,r,i;(o=this.floatingMenu)==null||o.unmount(),(s=this.inlineSuggestions)==null||s.unmount(),(r=this.aboveSuggestions)==null||r.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(e,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(e,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(e,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(e,n,"above")}renderInlineSuggestions(e,n){let{customStyles:o}=n,s=this.createInlineContainer(e,"deepdesk-caret"),r=tt(s);r.render(F(_e,{store:this.store,customStyles:o,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(ad,{})})}));let i=a=>{a?(s.style.display="block",s.style.top=`${a.top}px`,s.style.left=`${a.left}px`):s.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),r.unmount(),s.remove()}}}renderAboveOrBelowSuggestions(e,n,o){let{customStyles:s,closestScrollSelector:r,appendOverlayTo:i}=n,a=r&&ii(e,r)||void 0,[d,l]=this.overlayContainerFactory("deepdesk-tab-completion",a||e,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},s==null?void 0:s.rootNode),[c,u]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||e,{appendTo:i,placement:o},s==null?void 0:s.suggestionsRootNode),p=tt(d);p.render(F(_e,{store:this.store,customStyles:s,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(Wd,{inputElement:e})})}));let f=tt(c);return f.render(F(_e,{store:this.store,customStyles:s,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(yd,{onLogIn:()=>this.loginViaPopup().catch(m=>k.warn(m.message))})})})),{unmount(){p.unmount(),f.unmount(),l(),u()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:s,appendOverlayTo:r,floatingMenuParent:i}=n,a=s&&ii(e,s)||void 0,[d,l]=this.overlayContainerFactory("floating-menu",a||e,{appendTo:i!=null?i:r},o==null?void 0:o.floatingMenuParent),c=tt(d);return c.render(F(_e,{store:this.store,customStyles:o,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(Gl,{onLogIn:()=>this.loginViaPopup().catch(u=>k.warn(u.message))})})})),{unmount(){c.unmount(),l()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays"),s=tt(o);return s.render(F(_e,{store:this.store,customStyles:n,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(Kl,{})})})),{unmount(){s.unmount(),o.remove()}}}renderWidget(e,n={}){if(this.widgetElement&&k.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:s,isEmbedded:r}=n;this.widgetElement=e,this.configure({showImages:s,isEmbedded:r}),this.widgetRoot=tt(e),this.widgetRoot.render(F(_e,{store:this.store,customStyles:o,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F($c,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(i=>k.warn(i.message))})})}))}unmountWidget(){var e,n;(n=(e=this.widgetRoot)==null?void 0:e.unmount)==null||n.call(e),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(e,n,o={}){let{customStyles:s,initialQuestion:r}=o,i=tt(n);return i.render(F(_e,{store:this.store,customStyles:s,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(Jr,{children:Ox(rs,{assistantCode:e,initialQuestion:r,evaluateKnowledgeAssistFn:On,children:[F(rn,{children:F(as,{title:o.title,emptyState:o.emptyState})}),F(Xr,{children:F(is,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(e){let n=ui(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){hp(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>v(this,null,function*(){yield this.store.dispatch(En());let e=dt(this.state);e&&this.store.dispatch(Qn({showSearch:e.search,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:!!e.summarizerAssistantNew,showKnowledgeSearch:!!e.knowledgeAssistantNew||!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions}))})),this.loadProfileConfigPromise)}loginViaPopup(e){return v(this,null,function*(){return new Promise((n,o)=>{this.store.dispatch(Zn());let s=new MessageChannel,r=s.port1,i=this.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let d=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",u),clearInterval(p)};r.onmessage=f=>v(this,null,function*(){var m,g;if((m=f.data)!=null&&m.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((g=f.data)==null?void 0:g.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(un),d=!0,s.port1.close(),n()}catch(h){console.error(h),o(h)}finally{d=!0,l()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&o(new Error("Popup blocked by browser"));let u=f=>v(this,null,function*(){var m;if(f.origin===a.origin)switch((m=f.data)==null?void 0:m.type){case"deepdesk-popup-request-origin":{try{let g=JSON.stringify({type:"deepdesk-popup-parent-origin"});c==null||c.postMessage(g,a.origin)}catch(g){k.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-loaded":{try{let g=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(g,a.origin,[s.port2])}catch(g){k.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-error":{if(l(),f.data.message==="Platform account url mismatch"){let g=`Please contact your administrator: The platform account url (${f.data.targetOrigin}) is misconfigured as it differs from the origin of the page that opened the popup (${f.data.openerOrigin}).`;k.warn(g),this.store.dispatch(Ls(g)),o(new Error(g))}if(f.data.message==="Timeout"){let g="Please contact your administrator: Popup timed out. Check if the account's platform url is configured correctly.";k.warn(g),this.store.dispatch(Ls(g)),o(new Error(g))}o(new Error(f.data.message));break}}});window.addEventListener("message",u);let p=setInterval(()=>{c&&!c.closed||(l(),d||o(new Error("Popup closed by user")))},200);this.disposeHandlers.push(l)})})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}refreshTextSuggestions(){return v(this,null,function*(){this.isMounted&&(yield this.store.dispatch(Lo()))})}refreshWidgetSuggestions(){return v(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=kn(this.state);try{n.forEach(({type:o})=>{switch(o){case"entities":this.store.dispatch(fe());break;case"pinned-messages":case"sticky-messages":break;default:Xn.includes(o)||this.store.dispatch(he(o))}})}catch(o){this.handleError(o)}})}};nn.version="19.1.1-beta.2",nn.count=0;var bs=nn;function Dx(t){return v(this,null,function*(){var s,r,i;let n=yield((s=t.fetch)!=null?s:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(r=t.mimeType)!=null?r:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function _x(t,e){return v(this,null,function*(){let n=yield Dx(e),o=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[n]}),t.dispatchEvent(o)}finally{Object.hasOwn(t,"files")&&delete t.files}})}function Fx(t,e,n){return v(this,null,function*(){yield new et(t).authenticateWithKey(e,n)})}function Hx(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Bx(o,s){return v(this,arguments,function*(t,e,n={}){var u,p;let{value:r}=t,{start:i,end:a}=(u=n.replace)!=null?u:{start:0,end:r.length},d=`${r.slice(0,i)}${e}${r.slice(a)}`,l=(p=n.selectionAfter)!=null?p:{start:i+e.length,end:i+e.length},c=()=>{if(n.setValue)return n.setValue(d);t.value=d};return Promise.resolve(c()).then(()=>{t.selectionStart=l.start,t.selectionEnd=l.end,t.blur(),t.focus()})})}function Ux(o,s){return v(this,arguments,function*(t,e,n={}){let r=n.replace?St(t,n.replace.start,n.replace.end):Un(t),i,a=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),i=document.createElement("span"),r.insertNode(i),n.insertBRs!==!1?e.split(`
|
|
11
|
-
`).reverse().forEach((d,l)=>{l>0&&r.insertNode(document.createElement("br")),r.insertNode(document.createTextNode(d))}):r.insertNode(document.createTextNode(e))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let d=n.selectionAfter?St(t,n.selectionAfter.start,n.selectionAfter.end):(r.collapse(!1),r),l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(d)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function
|
|
12
|
-
`).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=n.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(n.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(n.slice(r)))}),e}function Mp(t,e){let n=t.parentElement;if(!n){console.warn("No insert point found");return}let{display:o}=window.getComputedStyle(n);o.includes("block")||o==="table-cell"?n==null||n.insertBefore(e,t.nextSibling):Mp(n,e)}function
|
|
7
|
+
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`})})});import{jsx as Vl}from"react/jsx-runtime";var Af={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},jl=({className:t,color:e})=>Vl("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Vl("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:Af[e||"pink"]})});var $l={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var yr={};X(yr,{enUS:()=>Mf,nlNL:()=>Nf});var Mf={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Nf={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};import{useDispatch as _f}from"react-redux";import{jsx as vr,jsxs as Gl}from"react/jsx-runtime";var ql=({onLogIn:t})=>{let e=R(yr),n=E("floatingMenu"),o=E("productName"),s=_f(),r=Df(J),i=x("FloatingMenu",$l);if(r===null||n===!1)return null;let a=()=>{r===!0?s(ge(!0)):t()};return Gl("button",{type:"button",className:Of(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[vr("div",{className:i.text,children:e(r?"search":"signin",{productName:o})}),Gl("div",{className:i.icon,children:[vr(jl,{className:i.logo,color:"pink"}),r===!1&&vr(Wl,{className:i.lock})]})]})};import{useEffect as oh,useRef as sh}from"react";import{useDispatch as rh,useSelector as Kt}from"react-redux";import{useEffect as Ff}from"react";function mt(t){Ff(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function gt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}function Te(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:s,selection:r}=t.input;return r.start!==r.end?!1:r.end>=s.length?!0:e?n&&new RegExp(n).test(s.substring(r.end))||o&&new RegExp(o).test(s.substring(0,r.end))?!0:n===!1&&o===!1:!1}import{createSlice as Hf}from"@reduxjs/toolkit";var Bf={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Mo=({ui:t})=>t.overlayCollapsed,Xl=Hf({name:"ui",initialState:Bf,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:Mn,setInputFocus:No,setOverlayCollapsed:Je,setOpenOverlayWhenTyping:Jl,setOverlayCollapsedUserOverwrite:Ql}=Xl.actions,Zl=Xl.reducer;import{useMemo as eh}from"react";import{Interweave as od}from"interweave";import{useEffect as jf,useMemo as $f,useRef as Gf,useState as qf}from"react";import{useDispatch as Xf,useSelector as sd}from"react-redux";import{useEffect as Uf}from"react";function Yl(t,e,n){Uf(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var ed={root:"dd-1MBCO",actions:"dd--x4cy",closeIconContainer:"dd-1z5NR",closeIcon:"dd-8qMF-",badge:"dd-4Fpkz",formattedText:"dd-EzvTB",assistantContainer:"dd-j6o8F",formattedTextTruncated:"dd-fv169",assistantBadge:"dd-VD57E"};import{jsx as td,jsxs as Kf}from"react/jsx-runtime";var nd=({title:t})=>Kf("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24","aria-labelledby":"closeTitle",children:[td("title",{id:"closeTitle",children:t}),td("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})]});var xr={};X(xr,{enUS:()=>zf,nlNL:()=>Wf});var zf={assistant:[{type:0,value:"Assistant"}],close:[{type:0,value:"Close"}]},Wf={assistant:[{type:0,value:"Assistent"}],close:[{type:0,value:"Sluiten"}]};import{jsx as De,jsxs as rd}from"react/jsx-runtime";var Jf=["search","personal-collection-search","search-autocomplete"];function Qf(t,e,n,o={}){var r;let s="";return Jf.includes(e)?s=Ya(nr(t,n,{stripAgentPart:!0}),(r=o.searchKeywords)!=null?r:[n]):s=nr(t,n,o),o.placeholders===!0&&(s=el(s)),s}var Zf=()=>{},Yf=({selected:t,suggestion:e})=>{let n=R(xr),o=E("inlineSuggestions"),s=sd(At),[r,i]=qf(!1),a=E("enableSuggestionFeedback"),d=sd(h=>h.input.text),l=Xf(),c=x("TextSuggestion",ed),u=Gf(null),p=e.source==="assistant",f=a&&!p;jf(()=>{let h=setTimeout(()=>{l(ea({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(h)}},[e]),Yl(u,"click",()=>{l(se({suggestion:e,text:e.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let g=()=>{l(rt({source:e.source,text:e.text,assistantCode:e.assistantCode}))},m=$f(()=>Qf(e.text,e.source,s,{stripAgentPart:o,placeholders:!0,searchKeywords:e.searchKeywords}),[o,e.text,e.source,s,e.searchKeywords]);return e.source==="gpt"&&!o?null:rd("div",{className:c.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[De(M,{ref:u,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:Zf,children:e.source==="assistant"?rd("div",{className:c.assistantContainer,children:[De(od,{containerTagName:"div",tagName:"span",className:c.formattedTextTruncated,content:m}),De("span",{className:c.assistantBadge,children:n("assistant")})]}):De(od,{containerTagName:"div",tagName:"span",className:c.formattedText,content:m})}),f&&r&&De("div",{className:c.actions,children:De(Po,{source:"overlay",context:d,suggestion:e})}),p&&r&&De("div",{className:c.closeIconContainer,children:De("button",{type:"button",className:c.closeIcon,onClick:g,title:n("close"),children:De(nd,{title:n("close")})})})]})},id=Yf;import{jsx as nh}from"react/jsx-runtime";var th=({suggestions:t,selectedIndex:e,reverse:n})=>eh(()=>{let s=t.map((r,i)=>nh(id,{index:i,selected:i===e,suggestion:r},`${r.text}-${r.source}`));return n?s.reverse():s},[t,e,n]),Oo=th;var ad={root:"dd-PfvRI",paper:"dd-HYlyY"};import{jsx as Do}from"react/jsx-runtime";var ih=()=>{let t=sh(null),e=x("InlineSuggestionsOverlay",ad),n=Kt(Te),o=rh(),s=Kt(J),r=Kt(Lt),i=Kt(Mo),a=E("showTextSuggestions"),d=Kt(st),l=Kt(dn);return mt(()=>{setTimeout(()=>{o(Je({collapse:!0,skipWhenInputFocus:!0}))})}),oh(()=>{let c=t.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let u=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-u.right,0)}px`}),i||!n||!a||d.length===0||s!==!0||r===!1?null:Do("div",{className:e.root,"data-variant":"inline",children:Do("div",{ref:t,className:e.paper,children:Do(te,{children:Do(Oo,{suggestions:d,selectedIndex:l})})})})},ld=ih;import{Provider as ah}from"react-redux";import{jsx as _o}from"react/jsx-runtime";var lh=({children:t})=>{let n=E("locale").replace("-","");return _o(Xs.Provider,{value:n,children:t})},dh=({store:t,customStyles:e={},children:n})=>_o(ah,{store:t,children:_o(lh,{children:_o(sn.Provider,{value:e,children:n})})}),_e=dh;import wr from"classnames";import{useEffect as bh,useRef as Ch,useState as Th}from"react";import{useDispatch as wh,useSelector as Qe}from"react-redux";import{useState as ch}from"react";function dd(t,e){let[n,o]=ch(()=>{if(typeof window=="undefined")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return k.error(r),e}});return[n,r=>{try{let i=r instanceof Function?r(n):r;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){k.error(i)}}]}var cd=()=>/Mac/i.test(navigator.platform);import mh from"classnames";import{Fragment as gh,useCallback as br,useMemo as ud}from"react";var Sr={};X(Sr,{enUS:()=>ph,nlNL:()=>uh});var ph={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"}]}]},uh={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 pd={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};import{jsx as Fo,jsxs as md}from"react/jsx-runtime";var Cr=(t,e,n)=>o=>Fo("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),fh=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o,onLogIn:s})=>{let r=R(Sr),i=ne(),a=x("Login",pd),d=E("productName"),l=br(h=>{h.preventDefault(),o&&o(Number.parseInt(h.target.value,10))},[]),c=br(h=>{h.preventDefault(),i.send(_t,!0)},[e]),u=ud(()=>h=>Fo("a",{onClick:T=>{T.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),p=br(h=>Fo("button",{type:"button",className:a.anchorButton,onClick:c,children:h},"prompt"),[c]),{min:f,hour:g,day:m}=ud(()=>({min:Cr(a,600,l),hour:Cr(a,3600,l),day:Cr(a,3600*12,l)}),[]);return md("div",{className:mh(t,a.root),children:[r("loginPlease",{login:n?p:u,productName:d}),o&&md(gh,{children:[Fo("br",{}),r("snooze",{min:f,hour:g,day:m})]})]})},Ho=fh;import{useDispatch as hh}from"react-redux";var gd={root:"dd-DoQhb",text:"dd-Jwnev"};import{jsx as fd,jsxs as vh}from"react/jsx-runtime";var yh=({title:t})=>{let e=x("SearchTrigger",gd),n=hh(),o=K();return vh("button",{type:"button",className:e.root,onClick:()=>{n(ge(!0)),o("open search",{via:"autocomplete-overlay"})},children:[fd(Bt,{}),fd("span",{className:e.text,children:t})]})},hd=yh;var Tr={};X(Tr,{enUS:()=>xh,nlNL:()=>Sh});var xh={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"}],dismiss:[{type:0,value:"Dismiss"}],dismissError:[{type:0,value:"Dismiss error"}]},Sh={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"}],dismiss:[{type:0,value:"Sluiten"}],dismissError:[{type:0,value:"Foutmelding sluiten"}]};var yd={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",loginError:"dd-KCXeb",loginErrorMessage:"dd-Bv-BG",loginErrorDismiss:"dd-iSCjU"};import{jsx as q,jsxs as ft}from"react/jsx-runtime";var Eh=({onLogIn:t})=>{let e=x("SuggestionsOverlay",yd),n=R(Tr),o=Qe(Te),s=Qe(Yi),r=wh(),i=Ch(null),a=E("searchTriggerKey"),d=E("productName"),l=Qe(Mo),c=Qe(J),u=Qe(Ui),p=Qe(Lt),[f,g]=Th(null),m=E("showSearch"),h=E("showTextSuggestions"),b=E("adminUrl"),T=E("isEmbedded"),C=E("suggestionsPlacement"),[w,I]=dd("dd-snooze-until-ms",0),N=l||w>Date.now(),_=Qe(st),W=Qe(dn),ce=_.filter(U=>U.source!=="gpt").length,ae=()=>{N&&I(0),r(Ql(!N))},O=U=>{let Pe=Date.now()+U*1e3;I(Pe),k.info(`Snooze until: ${new Date(Pe)}`),r(Je({collapse:!0}))};return bh(()=>{ce===0&&g(null)},[_,ce]),mt(()=>{r(Je({collapse:!0,skipWhenInputFocus:!0}))}),c===null||p===!1?null:c===!1?ft("div",{ref:i,className:wr(e.root,{[e.isCollapsed]:N}),children:[!N&&ft("div",{className:e.triggers,children:[q("div",{style:{flex:1}}),q("div",{className:e.triggersRight,children:q(Et,{className:e.toggleButton,title:n("collapse"),onClick:ae,isCollapsed:!1})})]}),q("div",{className:e.toggleButtonWrapper,children:q(Et,{className:e.toggleButton,title:n("open",{productName:d}),onClick:ae,isCollapsed:!0})}),ft("div",{className:e.collapsible,children:[u&&ft("div",{className:e.loginError,children:[q("span",{className:e.loginErrorMessage,children:u}),q("button",{type:"button",className:e.loginErrorDismiss,onClick:()=>r(Zn()),"aria-label":n("dismissError"),children:n("dismiss")})]}),q(Ho,{loginUrl:b,isEmbedded:T,onLogIn:t,onSnooze:O})]})]}):!s||!o?null:ft("div",{ref:i,className:wr(e.root,{[e.isCollapsed]:N}),children:[!N&&ft("div",{className:e.triggers,children:[q("div",{style:{flex:1},children:m&&q("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>g(n(cd()?"searchHintMac":"searchHintWindows",{searchTriggerKey:a.toUpperCase()})),onMouseLeave:()=>g(null),children:q(hd,{title:n("search")})})}),ft("div",{className:e.triggersRight,onFocus:()=>{},children:[q("div",{className:wr(!f&&e.hintsHidden,e.hints),children:f}),q(Et,{className:e.toggleButton,title:n("collapse"),onClick:ae,isCollapsed:!1})]})]}),q("div",{className:e.toggleButtonWrapper,children:q(Et,{className:e.toggleButton,title:n("open",{productName:d}),onClick:ae,isCollapsed:!0})}),ce>0&&h&&q("div",{className:e.collapsible,onFocus:()=>{},children:q(te,{children:q(Oo,{suggestions:_,selectedIndex:W,reverse:C==="above"})})})]})},vd=Eh;import Or from"classnames";import{Interweave as wy}from"interweave";import{useCallback as Ey,useEffect as ky,useMemo as Wd,useRef as Ry}from"react";import{connect as Py}from"react-redux";import{useEffect as kh,useRef as Rh,useState as Ph}from"react";function Bo(t){return t.contentEditable==="true"}function Ih(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let s=o.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),n=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:n}}function xd(t){let{selectionStart:e,selectionEnd:n}=Bo(t)?Ih(t):t;return[e,n]}function Sd(t){let[,e]=Ph(),n=Rh(null);return n.current=xd(t),kh(()=>{let o=()=>{var a;let[s,r]=(a=n.current)!=null?a:[],i=xd(t);(!i||s!==i[0]||r!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function bd(t,e){if(!e)return;let n=t,{value:o}=n,[s,r]=e,i=o.match(qn);if(!i||i.length===0)return;let a=0;i.find(d=>{let l=o.indexOf(d,a);return s>l&&r<l+d.length?(n.selectionStart=l,n.selectionEnd=l+d.length,!0):(a=l+d.length,!1)})}import{cloneElement as Lh}from"react";var Ah=["div","span","mark","strong","b","i","u","em"];function Er(t,e,n=0){var r;let o=t[t.length-1],s=typeof o=="object"&&o!==null?(r=o.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,o];if(Ah.includes(s)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),Lh(o,{children:Er(i,e,n+1)})]}return[...t,...e]}function ht(t){return t.tagName.toLowerCase()==="textarea"}var Cd={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"};import Qh from"classnames";import{Matcher as Zh}from"interweave";import{useEffect as Yh,useMemo as ey}from"react";import{useEffect as Mh,useRef as Nh,useState as Oh}from"react";function Td(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let s=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(n)]}function Uo(t){let e=Nh(null),[n,o]=Oh(!1);return Mh(()=>{var c;let s=!1,r=Number.parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[i,a]=Td((u,p)=>{let f=e.current;if(!f)return;let g=u/r,m=p/r,h=f.getBoundingClientRect(),b=g>h.x&&g<h.x+h.width&&m>h.y&&m<h.y+h.height;b&&!s?(s=!0,o(!0)):!b&&s&&(s=!1,o(!1))},({clientX:u,clientY:p})=>[u,p]),[d,l]=Td(()=>{s=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",d),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",d)}},[e]),[e,n]}function wd(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Ko(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function Ed(t){return t!=null}import Ld from"classnames";import{createRef as Vh,useCallback as Rr,useMemo as jh,useRef as $h,useState as Gh}from"react";import{useState as Dh,useLayoutEffect as _h}from"react";var Fh=["bottom","height","left","right","top","width"],Hh=(t={},e={})=>Fh.some(n=>t[n]!==e[n]),Fe=new Map,kd,Rd=()=>{let t=[],e=[];Fe.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let s=o.getBoundingClientRect();Hh(s,n.rect)&&(n.rect=s,t.push(n))}),e.forEach(n=>{Fe.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),kd=window.requestAnimationFrame(Rd)};function Bh(t,e){return{observe(){let n=Fe.size===0;if(Fe.has(t)){let o=Fe.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else Fe.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&Rd()},unobserve(){let n=Fe.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||Fe.delete(t),Fe.size||cancelAnimationFrame(kd)}}}}function kr(t){let[e,n]=Dh(null);return _h(()=>{if(!t.current)return;let o=Bh(t.current,s=>{n(s)});return o.observe(),()=>{o.unobserve()}},[t]),e}import{useContext as Uh,useLayoutEffect as Kh,useState as zh}from"react";import{createPortal as Wh}from"react-dom";var Pd={root:"dd-r-dgo"};var Id=({children:t,parentNode:e})=>{let[n,o]=zh(null),s=Uh(sn);return Kh(()=>{let r=document.createElement("div");return gt(r),r.classList.add(Pd.root),s!=null&&s.portalRootNode&&r.classList.add(s==null?void 0:s.portalRootNode),(e||document.body).appendChild(r),o(r),()=>{r.isConnected&&r.remove()}},[]),n?Wh(t,n):null};var we={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"};import{jsx as Pr}from"react/jsx-runtime";var zo=(t=!1)=>{let[e,n]=Gh(t),o=Rr(()=>n(!0),[]),s=Rr(()=>n(!1),[]),r=Rr(()=>n(a=>!a),[]),i=$h(null);return{opened:e,open:o,close:s,toggle:r,triggerRef:i}};function Ir(t,e=null,n=0){if(!t)return{display:"none"};let o=e?t.top-e.top<0||t.top<e.top-n?e.top-n:t.top+t.height>e.top+e.height+n?e.top+e.height+n-t.height:t.top:t.top,s=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:s,height:t.height,width:t.width}}var zt=l=>{var c=l,{className:t,triggerRef:e,boundaryRef:n=Vh(),position:o="above",align:s="center",children:r,toStyle:i=Ir,parentNode:a}=c,d=A(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let u=kr(e),p=kr(n),f=jh(()=>i(u,p,0),[u,p]);return Pr(Id,{parentNode:a,children:Pr("div",S(y({className:Ld(we.ref,{[we.positionAbove]:o==="above",[we.positionBelow]:o==="below",[we.positionLeft]:o==="left",[we.positionRight]:o==="right",[we.alignStart]:s==="start",[we.alignCenter]:s==="center",[we.alignEnd]:s==="end"}),style:f},d),{role:"dialog",children:Pr("div",{className:Ld(t,we.root),children:r})}))})};import qh from"classnames";import{forwardRef as Xh,useRef as Jh}from"react";var He={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"};import{jsx as Ad}from"react/jsx-runtime";var Wo=Xh((s,o)=>{var r=s,{className:t,children:e}=r,n=A(r,["className","children"]);let i=Jh(null),a=x("TabCompletion",He);return Ad("div",S(y({ref:Ko([i,o]),className:qh(t,a.popoverContentContainer)},n),{children:Ad("div",{className:a.popoverContent,children:e})}))});import{jsx as Nn,jsxs as oy}from"react/jsx-runtime";var ty=t=>e=>{let n=Ir(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},ny=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:s})=>{let r=x("TabCompletion",He),i=zo(),a=ey(()=>ty(t.getBoundingClientRect()),[t]),[d,l]=Uo(t);return Yh(()=>{l?i.open():i.close()},[l]),oy("span",{children:[Nn("mark",{ref:Ko([d,i.triggerRef]),className:Qh(r.matchKeyword,{[r.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&Nn(zt,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:Nn(Wo,{style:n,children:Nn("div",{className:r.hintText,children:s})})})]})},Vo=class extends Zh{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(s=>S(y({},s),{keywordRegex:new RegExp(`\\b${wd(s.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=this.preparedKeywordMatches.map(r=>{if(this.usedKeywordMatches.has(r))return null;let i=n.match(r.keywordRegex);if(!i)return null;let a=n.charAt(i.index-1),d=n.charAt(i.index+r.keyword.length);return a==="{"&&d==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:r.suggestion,preparedKeywordMatch:r,valid:!0}}).filter(Ed);if(o.length===0)return null;let s=o.reduce((r,i)=>i.index<r.index?i:r);return this.usedKeywordMatches.add(s.preparedKeywordMatch),s}replaceWith(n,o){return Nn(ny,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:n},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{Matcher as sy}from"interweave";import ry from"classnames";import{jsx as Md}from"react/jsx-runtime";var iy=({inputElement:t,children:e})=>{let n=x("TabCompletion",He),[o,s]=Uo(t);return Md("mark",{ref:o,className:ry(n.matchPlaceholder,{[n.hover]:s}),children:e})},jo=class extends sy{match(e){let n=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(e,n){return Md(iy,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};import Nr from"classnames";import{Matcher as hy}from"interweave";import{createRef as yy,forwardRef as vy,useCallback as xy,useEffect as Ud,useRef as Kd,useState as zd}from"react";import{useDispatch as Sy,useSelector as by}from"react-redux";import{jsx as Nd}from"react/jsx-runtime";var Od=()=>Nd("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:Nd("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"})});import{useCallback as ay,useEffect as _d,useMemo as ly,useState as Fd}from"react";import{useDispatch as dy,useSelector as Hd}from"react-redux";import cy from"lodash.debounce";var Dd={root:"dd-ky-Bv",content:"dd-kV5e1"};function $o(t,e,n){var s;let o=((s=t.imageSizes)==null?void 0:s[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(r){return null}}function Lr(t){return t.replace("https://www.","").replace("https://","")}import{jsx as yt,jsxs as Ar}from"react/jsx-runtime";var py=3,uy=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),my=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:s=py})=>{let r=x("LinkSearch",Dd),[i,a]=Fd(""),d=dy(),l=Hd(Nl("url")),c=Hd(Ta("URL")),u=ly(()=>c.map(uy),[c]),[p,f]=Fd(u.length-1),g=E("fallbackImage"),m=C=>{let w=C.target;a(w.value)},h=(C,w)=>{C.stopPropagation(),C.preventDefault(),window.open(w,"_blank")},b=C=>{var N;let w=p-1<0?u.length-1:p-1,I=p+1===u.length?0:p+1;C.code==="Escape"&&(a(""),e()),C.code==="ArrowUp"&&f(w),C.code==="ArrowDown"&&f(I),C.code==="Enter"&&t(((N=u[p])==null?void 0:N.text)||i)},T=ay(cy(C=>{d(at({query:C,type:"URL",tags:["link-search"]}))},300),[]);return _d(()=>{i&&T(i)},[i]),_d(()=>()=>{d(lo())},[]),Ar("div",{className:r.root,children:[yt(te,{withDivider:!0,children:(i?u:l).slice(0,s).map((C,w)=>yt(M,{selected:p===w,onClick:()=>t(C.text),"data-testid":"linksearch-suggestion",children:Ar(D,{children:[yt(D.Image,{src:$o(C,"small",g||void 0),title:C.title||C.text}),Ar(D.Content,{className:r.content,cropText:!0,children:[yt(D.Title,{children:C.title||Lr(C.text)}),C.title&&Lr(C.text)]}),yt(M.Actions,{children:yt(M.ActionButton,{label:o,onClick:I=>h(I,C.text)})})]})},C.text))}),yt(Tn,{value:i,onChange:m,autoFocus:!0,placeholder:n,onKeyUp:b})]})},Bd=my;var Mr={};X(Mr,{enUS:()=>gy,nlNL:()=>fy});var gy={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}],addToPersonalCollection:[{type:0,value:"Add to Personal Collection"}]},fy={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}],addToPersonalCollection:[{type:0,value:"Toevoegen aan Personal Collection"}]};import{jsx as ye,jsxs as Go}from"react/jsx-runtime";var Cy=vy((t,e)=>{let n=x("TabCompletion",He);return ye("mark",{ref:e,className:Nr(n.matchSelection)},"selection-start")}),Ty=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:s})=>{let r=R(Mr),i=x("TabCompletion",He),a=E("addToPersonalCollection"),d=by(Xe("/admin/personal-collection/new")),l=Kd(null),c=Kd(null),[u,p]=zd(null),f=Sy(),g=zo(document.activeElement===o),[m]=zd(()=>document.createRange());g.triggerRef.current=m,Ud(()=>()=>m.detach(),[]),Ud(()=>{let b=t.current,T=l.current;!b||!T||(m.setStart(b,0),m.setEnd(T,0))},[t.current,l.current]),mt(()=>{g.close()});let h=xy(b=>{let T=m.toString(),C=/^http(s?):\/\//.test(b)?b:`https://${b}`,w=`[${T}](${C})`;f(se({text:w,suggestion:{text:w,source:"search-url",type:"url"},eventMetrics:{inputType:"mouse"},replace:"selection"}))},[]);return Go("span",{children:[ye("mark",{ref:l,className:Nr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":g.opened?"true":"false",children:s}),g.opened&&ye(zt,{className:i.popoverRoot,triggerRef:g.triggerRef,boundaryRef:e,position:"above",align:"start",children:Go(Wo,{style:n,ref:c,children:[Go("div",{className:Nr(i.selectionOptions,{[i.selectionOptionsIsHidden]:u!==null}),children:[Go("button",{type:"button",tabIndex:u===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[ye(Od,{}),ye("span",{children:"\xA0"}),ye("span",{children:r("insertLink")})]}),a&&d&&ye("button",{type:"button",tabIndex:u===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>{let b=m.toString(),T=`${d}?text=${encodeURIComponent(b)}`;window.open(T,"_blank")},children:ye("span",{children:r("addToPersonalCollection")})})]}),u==="insertLink"&&ye(Bd,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{p(null),g.close()}})]})})]},"selection-end")},qo=class extends hy{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,o){return this.props=o,this.charCount=0,this.startRef=yy(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,s]=this.props.selection;if(o===s)return null;let r=this.foundIndex===0?o:s,i=r>=this.charCount&&r<=this.charCount+n.length?{index:r-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let a=this.foundIndex===1;return i&&a?this.charCount+=r-this.charCount:this.charCount+=n.length,i?y({isStart:a},i):null}replaceWith(n,o){return o.isStart?ye(Cy,{ref:this.startRef}):ye(Ty,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{useSelector as Iy}from"react-redux";import{jsx as Wt,jsxs as My}from"react/jsx-runtime";var Ly=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:d})=>{let l=x("TabCompletion",Cd),c=E("insertLink"),u=E("addToPersonalCollection"),p=E("showMidSentenceSuggestions"),f=E("inlineSuggestions"),g=Sd(a),m=Ry(null),h=Iy(J);ky(()=>{ht(a)&&g&&bd(a,g)},[g]);let b=Ey(w=>{if(!s||!n)return w;let I=[Wt("span",{className:l.resetIndent,children:"\u200B"},"u200B"),Wt("span",{"data-testid":"tab-completion",className:Or(l.tabText,l.resetIndent),"data-source":d,children:n},"tabText")];return o&&I.push(Wt("span",{className:Or(l.hint,l.resetIndent),children:Wt(ks,{keyCode:"tab"},"tabHint")},"tabHint")),Er(w,I)},[s,n,o]),T=Wd(()=>{let w=[];return(c||u)&&w.push(new qo("selection")),w.push(new jo("placeholders")),r&&w.push(new Vo("keywords")),w},[f,c,u,r]),C=Wd(()=>{let w=window.getComputedStyle(a);return{"--dd-color":w.color,"--dd-font-size":w.fontSize,"--dd-font-family":w.fontFamily,"--dd-font-variant":w.fontVariant}},[]);return!t||!h?null:My("div",{ref:w=>{w!=null&&w.parentElement&&(m.current=w==null?void 0:w.parentElement)},className:l.root,style:C,children:[Wt(wy,{tagName:"span",containerTagName:"div",className:Or(l.container,l.agentText),disableLineBreaks:ht(a),content:e||"\u200B",onAfterParse:b,matchers:T,selection:g,keywordMatches:i,inputElement:a,inputStyle:C,boundaryRef:m,inlineSuggestionsOnlyAtEnd:!p}),Wt("br",{})]},"tab-completion")},Ay=t=>{var h,b,T;let{input:e,ui:n,settings:o,styleSuggestions:s,conversation:r}=t,i=Mt({input:e}),a=(i==null?void 0:i.text)||"",d=(i==null?void 0:i.source)||"",l=(h=e.html)!=null?h:Pn(e.text),c=a.indexOf(e.text)===0?a.slice(e.text.length):"",{showTabHint:u}=n,{isSupported:p}=r,{showTabCompletion:f,visible:g,showStyleSuggestions:m}=o;return{showTabHint:u,showStyleSuggestions:m,showTabCompletion:f&&Te(t),content:l,tabText:c,source:d,keywordMatches:(T=(b=s.list)==null?void 0:b.keywordMatches)!=null?T:[],enabled:g&&p!==!1}},Vd=Py(Ay)(Ly);import{Fragment as Yv,useEffect as Xr,useState as ex}from"react";import{useDispatch as Vc,useSelector as Z}from"react-redux";import{createAction as $d,createAsyncThunk as Gd,createSlice as Oy}from"@reduxjs/toolkit";import{Marked as Ny}from"marked";var Xo=(t,e)=>{let n=[],o=new Ny,s=r=>{r.type==="code"&&r.lang===e&&n.push(r.text)};return o.use({walkTokens:s}),o.parse(t),n};var jd={cues:[],threads:{},pending:[]},qd=t=>{var e;return(e=t.assistants)==null?void 0:e.cues};var Xd=t=>e=>{var n,o;return(o=(n=e.assistants)==null?void 0:n.threads[t])!=null?o:null},Jo=$d("assistants/callToAction"),On=Gd("assistants/evaluateKnowledgeAssistant",(t,e)=>v(null,null,function*(){var l,c,u;let{threadId:n}=t,{onNewThreadId:o}=t,{deepdeskAPI:s}=e.extra,r=e.getState(),{platformVariables:i}=r.info;n||(n=(yield s.createAssistantThread({assistantCode:t.assistantCode})).id,o&&o(n)),yield s.postMessageToAssistantThread({assistantCode:t.assistantCode,threadId:n,message:t.input});let a=yield e.dispatch(Ee(S(y({skipState:!0},t),{input:{},threadId:n})));if(a.error)throw new Error(a.error.message);let d=(l=a.payload.output[0])!=null?l:{response:"",sources:[]};return{threadId:n,question:t.input,evaluationId:a.payload.evaluationId,answer:{answer:(c=me(d.response,i!=null?i:{}))!=null?c:"",sources:(u=d.sources)!=null?u:[]}}})),uM=$d("assistants/extractedTextSuggestions");function Dy(t,e){return Array.isArray(t.output)?t.output:[y({code:e,name:e},t.output)]}var Ee=Gd("assistants/evaluate",(t,e)=>v(null,null,function*(){var m;let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra,{transcript:s,input:r={},threadId:i}=t,a=e.getState(),{platformVariables:d}=a.info,l=(m=a.conversation.current)==null?void 0:m.externalId,c;if(s==="in-memory-transcript"){if(!o.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");c=yield o.conversationQuery()}else Array.isArray(s)&&(c=s);if(t.includeMetadata){if(!a.conversation.current)throw new Error("Can't include metadata, no current conversation");let{metadata:h}=a.conversation.current;Object.assign(r,{metadata:h})}let u=yield n.evaluateAssistant(t.assistantCode,{input:r,transcript:c,externalConversationId:l,threadId:i});if(u.evaluationStatus!=="success")return e.rejectWithValue(`Assistant ${t.assistantCode} evaluation failed: ${u.evaluationStatus}`);let f=Dy(u,t.assistantCode).map(h=>S(y({},h),{name:me(h.name,d),response:me(h.response,d)||""})),g=[];return f.forEach(h=>{if(!h.response)return;let b=Xo(h.response,"reply"),T=b.length>0?b:[h.response];g.push(...T.map(C=>({text:C,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name})))}),g.length>0&&e.dispatch(Nt(g)),S(y({},u),{output:f})})),Jd=Oy({name:"assistants",initialState:jd,reducers:{resetCues(t){t.cues=[]},removeCueByCode(t,e){t.cues=t.cues.filter(n=>n.code!==e.payload.code)},removeThreadById(t,e){delete t.threads[e.payload]},receiveChunk(t,e){let{code:n,name:o,payload:s,evaluationId:r}=e.payload,i=t.cues.findIndex(a=>a.code===n);i!==-1?t.cues[i].response+=s.text:t.cues.push({code:n,name:o,evaluationId:r,response:s.text})},userNotification(t,e){let n=t.cues.filter(d=>d.code!==e.payload.code),{code:o,name:s,evaluationId:r,payload:i}=e.payload,{callToAction:a}=i;t.cues=[...n,{code:o,name:s,evaluationId:r,response:i.message,editable:i.editableMessage,callToAction:a&&{label:a.displayName,event:a.onClickEvent,value:a.eventPayload}}]}},extraReducers:t=>{t.addCase(Ee.pending,(e,n)=>{e.pending.includes(n.meta.arg.assistantCode)&&k.warn(`Assistant ${n.meta.arg.assistantCode} already evaluating`),e.pending.push(n.meta.arg.assistantCode)}).addCase(Ee.rejected,(e,n)=>{var s;k.warn((s=n.error)==null?void 0:s.message);let o=e.pending.indexOf(n.meta.arg.assistantCode);o!==-1&&e.pending.splice(o,1)}).addCase(Ee.fulfilled,(e,n)=>{let o=e.pending.indexOf(n.meta.arg.assistantCode);if(o!==-1&&e.pending.splice(o,1),n.meta.arg.skipState)return;let{evaluationId:s,output:r}=n.payload,i=r.map(l=>l.code),a=e.cues.filter(l=>!i.includes(l.code)),d=r.map(l=>S(y({},l),{evaluationId:s}));e.cues=[...a,...d]}).addCase(On.fulfilled,(e,n)=>{let r=n.payload,{threadId:o}=r,s=A(r,["threadId"]);e.threads[o]=[...e.threads[o]||[],s]}).addCase(V,()=>jd)}}),{removeCueByCode:Qo,resetCues:mM,removeThreadById:Qd,receiveChunk:Zd,userNotification:Yd}=Jd.actions,ec=Jd.reducer;import{createAsyncThunk as tc,createSlice as _y}from"@reduxjs/toolkit";var Fy={token:null,interval:null},Dr=tc("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),_r=tc("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(Dr()),setInterval(()=>o(Dr()),n)}),nc=_y({name:"passwordlessToken",initialState:Fy,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Dr.fulfilled,(e,n)=>{e.token=n.payload.token}),t.addCase(_r.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollPasswordlessToken:oc}=nc.actions,sc=nc.reducer;import{createSelector as Hy}from"@reduxjs/toolkit";function By(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}var rc=Hy([qd],t=>t.map(n=>({text:n.response,title:n.name,callToAction:n.callToAction,editable:n.editable,isLoading:n.isLoading,evaluationId:n.evaluationId,rule:{id:By(n.code),label:n.code,name:n.name,description:n.name}})));import{useEffect as Uy,useState as Ky}from"react";import lc from"classnames";import{jsx as ic}from"react/jsx-runtime";var Vt=()=>ic("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:ic("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 ac={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};import{jsx as jt,jsxs as dc}from"react/jsx-runtime";var zy=({entities:t})=>{let e=x("EntitiesWidgetList",ac),[n,o]=Ky(void 0),s=K(),r=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),Se(a.text),s("entity copied",{entity:a,type:"copy"}))};return Uy(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[n]),!t||t.length===0?null:jt("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,d)=>dc("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[jt("span",{className:e.entityText,children:a.text}),dc("span",{className:e.iconWrapper,children:[jt("span",{className:lc(e.icon),children:jt(Vt,{})}),jt("span",{className:lc(e.icon,n===d&&e.iconClicked),children:jt(Vt,{})})]})]},a.text))})},cc=zy;import{jsx as pc}from"react/jsx-runtime";var uc=()=>pc("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:pc("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});import{useRef as Jy}from"react";import{useSelector as Qy}from"react-redux";import{useRef as Wy,useState as Fr}from"react";import{useDispatch as Vy}from"react-redux";function Zo(t,e){let n=Wy(t);n.current=t;let[o,s]=Fr(void 0),[r,i]=Fr(void 0),[a,d]=Fr("idle"),l=Vy();return{error:r,state:a,data:o,call:p=>v(null,null,function*(){d("loading"),yield l(n.current(p)).unwrap().then(f=>{s(f),d("done"),e!=null&&e.onSuccess&&(e==null||e.onSuccess(f))}).catch(f=>{i(f),d("error"),e!=null&&e.onError&&(e==null||e.onError(f))})}),reset:()=>{d("idle"),s(void 0),i(void 0)}}}var mc={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var gc={root:"dd-nazq3",rotation:"dd-3EHTv"};import{jsx as $y}from"react/jsx-runtime";var jy=({size:t=12})=>{let e=x("LoadingSpinner",gc);return $y("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},fc=jy;import{jsx as hc}from"react/jsx-runtime";var yc=()=>hc("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:hc("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});import{jsx as vc,jsxs as Gy}from"react/jsx-runtime";var xc=t=>Gy("svg",S(y({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},t),{children:[vc("title",{id:"checkTitle",children:"Check"}),vc("path",{fill:"#666",d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"})]}));var Hr={};X(Hr,{enUS:()=>qy,nlNL:()=>Xy});var qy={error:[{type:0,value:"Something went wrong"}]},Xy={error:[{type:0,value:"Er ging iets fout"}]};import{jsx as Be,jsxs as Sc}from"react/jsx-runtime";var Zy=3e3,Yy=({assistantOptions:t})=>{let e=x("OnDemandAssistants",mc),n=R(Hr),o=Jy(),s=Zo(Ee),r=Qy($a),i=K(),a=r.filter(c=>c.isPinned),d=r.filter(c=>!c.isPinned),l=c=>v(null,null,function*(){clearTimeout(o.current),i("trigger on demand assistant",{assistantCode:c}),yield s.call(S(y({},t),{assistantCode:c})),o.current=setTimeout(()=>s.reset(),Zy)});return r.length===0?null:Sc("div",{className:e.root,children:[a.map(({assistant:c,assistantName:u,displayName:p})=>Be("button",{type:"button",className:e.button,disabled:s.state==="loading",onClick:()=>l(c),children:p||u},c)),d.length>0&&Sc($,{placement:"top-end",children:[Be($.Trigger,{className:e.trigger,disabled:s.state==="loading",children:Be(Eo,{"data-testid":"trigger"})}),Be($.Content,{className:e.nav,"data-testid":"popover",children:d.map(({assistant:c,assistantName:u,displayName:p})=>Be($.Button,{className:e.item,disabled:s.state==="loading",onClick:()=>l(c),children:p||u},c))})]}),s.state==="loading"&&Be(fc,{}),s.state==="done"&&Be(xc,{"data-testid":"trigger-done"}),s.state==="error"&&Be(il,{trigger:Be(yc,{}),children:n("error")})]})},bc=Yy;import{useDispatch as Ev}from"react-redux";import{useRef as nv}from"react";var Cc={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};import{jsx as tv}from"react/jsx-runtime";var ev=({width:t})=>{let e=x("LoadingProgressBar",Cc);return tv("div",{className:e.loadingBar,style:{width:t}})},Yo=ev;import{jsx as $t,jsxs as ov}from"react/jsx-runtime";var es=({title:t})=>{let e=nv(null);return Gn(e),$t(M,{ref:e,children:$t(D,{children:ov(D.Content,{children:[$t(D.Title,{children:t}),$t(Yo,{width:"60%"}),$t(Yo,{width:"90%"}),$t(Yo,{width:"50%"})]})})})};var Dn={};X(Dn,{enUS:()=>sv,nlNL:()=>rv});var sv={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"}]},rv={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"}]};import{useEffect as Lc,useRef as xv,useState as Sv}from"react";import Kr from"classnames";import{useState as lv}from"react";import{jsx as Tc}from"react/jsx-runtime";var Br=t=>Tc("svg",S(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Tc("path",{fillRule:"evenodd",d:"M6.57086468,14.9173453 C6.38997052,14.9711236 6.19835748,15 6,15 L4,15 C2.8954305,15 2,14.1045695 2,13 L2,4 C2,2.8954305 2.8954305,2 4,2 L6,2 C6.68685475,2 7.29284112,2.34623869 7.65294381,2.87370078 C7.95642355,2.67736738 8.29504785,2.51351337 8.66312366,2.3818197 C9.50544052,2.08044754 10.3408482,1.9879107 10.9989281,1.99971266 C11.0150698,2.00005426 13.3487605,2.00015005 18,2 C20.7551411,2 22,6.05643086 22,12 C22,13.6824804 20.8695981,15 19,15 L15.9269768,15 C15.9359266,15.0245465 15.9451954,15.0497804 15.9547911,15.0757271 C16.007193,15.2174219 16.2391583,15.8256341 16.2970775,15.9810953 C16.4872151,16.4914441 16.6259612,16.9026411 16.7382242,17.3098712 C16.9079007,17.9253665 17,18.4798886 17,19 C17,20.4720069 16.091867,21.3862822 14.748281,21.777514 C14.1422801,21.9539723 13.6147967,22.0000922 13.0076976,22.0000008 L12.5204954,22 L12.2202699,21.6261158 C11.2556275,20.4248034 7.64562469,16.4822788 6.57086468,14.9173453 Z M8,13 C8,13.2401953 8.04443154,13.4528921 8.14171093,13.6800176 C8.40663864,14.2985643 11.914268,18.1371493 13.4599624,19.9848695 C13.7113931,19.9660111 13.9483736,19.9273712 14.1891338,19.8572655 C14.7621788,19.6904035 15,19.4509737 15,19 C15,18.6834183 14.9359344,18.2976852 14.8101464,17.8413935 C14.7161494,17.500423 14.5944107,17.1396301 14.4229225,16.6793379 C14.3689242,16.5344009 14.1358033,15.923159 14.0789589,15.7694517 C13.9489218,15.4178313 13.8632547,15.1589343 13.8046536,14.9236885 C13.5555377,13.9236468 13.8054549,13 15,13 L19,13 C19.6912225,13 20,12.6401099 20,12 C20,7.20925475 19.015127,4 18,4 C15.9322103,4 15.9322103,4 10.9655994,3.99940813 C10.5253746,3.99154158 9.91062406,4.05963657 9.33687634,4.2649175 C8.45196659,4.58152894 8,5.09776992 8,6 L8,13 Z M4,4 L4,13 L6,13 L6,4 L4,4 Z"})}));import{jsx as wc}from"react/jsx-runtime";var Ec=t=>wc("svg",S(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:wc("path",{fillRule:"evenodd",d:"M7.65336736,21.1256786 C7.2933164,21.6534897 6.68712411,22 6,22 L4,22 C2.8954305,22 2,21.1045695 2,20 L2,11 C2,9.8954305 2.8954305,9 4,9 L6,9 C6.198171,9 6.38961023,9.02882212 6.57035446,9.08250314 C7.6444817,7.51807482 11.2554748,3.57449216 12.2202699,2.37298955 L12.5204954,1.99910538 L13,1.99910538 C13.6147967,1.99901314 14.1422801,2.04513312 14.748281,2.22159137 C16.091867,2.61282321 17,3.52709845 17,4.99910538 C17,5.51921677 16.9079007,6.07373891 16.7382242,6.68923415 C16.6259612,7.09646424 16.4872151,7.50766133 16.2970775,8.01801005 C16.2391583,8.17347129 16.007193,8.78168345 15.9547911,8.92337824 C15.9451954,8.94932503 15.9359266,8.9745589 15.9269768,8.99910538 L19,8.99910538 C20.8695981,8.99910538 22,10.316625 22,11.9991054 C22,17.9426745 20.7551411,21.9991054 18,21.9991054 L11.0344006,21.9985135 C10.3408482,22.0111947 9.50544052,21.9186578 8.66312366,21.6172857 C8.29521907,21.4856533 7.9567386,21.3218904 7.65336736,21.1256786 Z M8,17.9991054 C8,18.9013355 8.45196659,19.4175764 9.33687634,19.7341879 C9.91062406,19.9394688 10.5253746,20.0075638 10.963066,19.9997143 C10.9703499,19.9995545 10.9703499,19.9995545 11,19.9991054 L18,19.9991054 C19.015127,19.9991054 20,16.7898506 20,11.9991054 C20,11.3589955 19.6912225,10.9991054 19,10.9991054 L15,10.9991054 C13.8054549,10.9991054 13.5555377,10.0754586 13.8046536,9.07541689 C13.8632547,8.84017106 13.9489218,8.5812741 14.0789589,8.22965366 C14.1358033,8.07594642 14.3689242,7.46470447 14.4229225,7.31976744 C14.5944107,6.85947528 14.7161494,6.4986824 14.8101464,6.1577119 C14.9359344,5.70142019 15,5.31568707 15,4.99910538 C15,4.54813166 14.7621788,4.30870189 14.1891338,4.1418399 C13.9483736,4.07173418 13.7113931,4.0330943 13.4599624,4.01423587 C11.914268,5.86195611 8.40663864,9.70054105 8.14171093,10.3190878 C8.04443154,10.5462133 8,10.7589101 8,10.9991054 L8,17.9991054 Z M4,11 L4,20 L6,20 L6,11 L4,11 Z"})}));function Ze(t,e){var s;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(r=>{n.classList.add(r)}),n.addEventListener("animationend",()=>n.remove()),(s=t.parentElement)==null||s.appendChild(n)}var Ur={};X(Ur,{enUS:()=>iv,nlNL:()=>av});var iv={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},av={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var kc={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};import{useSelector as Rc}from"react-redux";import{jsx as Gt,jsxs as cv}from"react/jsx-runtime";var dv=({assistantCode:t,assistantOutput:e,evaluationId:n,feedbackType:o,feedbackText:s})=>{let r=x("FeedbackThumbs",kc),i=E("enableFeedbackForm"),a=Rc(xe),d=Rc(Xe(`/admin/feedback?conversationId=${a}&evaluationId=${n}&type=${o}&text=${s}&assistantCode=${t}&assistantOutput=${e}`)),l=R(Ur),c=K(),[u,p]=lv(null),f=h=>{c("Assistant response feedback",{assistantCode:t,assistantOutput:e,evaluationId:n,rating:h})},g=h=>{h.stopPropagation(),Ze(h.target,r.fadeup),p("up"),f("up")},m=h=>{h.stopPropagation(),Ze(h.target,r.fadedown),p("down"),f("down")};return cv("div",{className:r.thumbs,children:[Gt(M.Button,{title:l("thumbsUp"),onClick:g,icon:Gt(Ec,{}),className:Kr(r.thumbsUp,u==="up"&&r.selected),disabled:!!u}),i&&d?Gt(M.Button,{as:"a",title:l("thumbsDown"),href:d,target:"_blank",rel:"noreferrer",onClick:m,icon:Gt(Br,{}),className:Kr(r.thumbsDown,u==="down"&&r.selected),disabled:!!u}):Gt(M.Button,{title:l("thumbsDown"),onClick:m,icon:Gt(Br,{}),className:Kr(r.thumbsDown,u==="down"&&r.selected),disabled:!!u})]})},ts=dv;import pv from"dompurify";import{Fragment as Ic,useMemo as uv,useRef as mv,useState as gv}from"react";var Pc={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};import{marked as fv}from"marked";import{jsx as _n,jsxs as ns}from"react/jsx-runtime";function hv(t){return`<button type="button" data-copy-icon class=${t}><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 zr(t){var n,o;let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(s=>s.remove()),(o=(n=e.textContent)==null?void 0:n.trim())!=null?o:""}function yv(t){return t.replace(/\r\n/g,`
|
|
8
|
+
`)}var vv=({content:t,useLabel:e,copyLabel:n,onCopy:o,onUse:s})=>{let r=x("Markdown",Pc),i=mv(null),[a,d]=gv(null),l=uv(()=>{let m=fv.parse(yv(t));return pv.sanitize(m.toString()).replaceAll("</code>",`${hv(r.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[t]),c=m=>{var T;let h=m.target,b=!!((T=i.current)!=null&&T.querySelector("code"));if(["A","BUTTON"].includes(h.tagName)){d(null);return}a||b&&h.tagName!=="CODE"||!b&&h!==i.current||(h.addEventListener("mouseleave",()=>d(null),{once:!0}),d(h))},u=()=>{if(!a)return;d(null);let m=a.querySelector("button");m&&(Ze(m,r.fadeup),o==null||o(zr(a)))},p=m=>{let h=m.target,b=h instanceof HTMLElement?h:null;if(h instanceof Element?h.closest("a"):null){m.stopPropagation();return}b&&"copyIcon"in b.dataset&&(Ze(b,r.fadeup),o==null||o(zr(b.parentElement)))},f=()=>{!a||!s||(d(null),s(zr(a)))},g=m=>{if(m===null)return;let h=m.getBoundingClientRect();h.left<0?m.style.transform=`translateX(${-h.left+2}px)`:h.right>window.innerWidth&&(m.style.transform=`translateX(${window.innerWidth-h.right-2}px)`)};return ns(Ic,{children:[a&&(o||s)&&ns(zt,{triggerRef:{current:a},className:r.popover,parentNode:a,children:[ns("div",{className:r.options,ref:g,children:[o&&(a==null?void 0:a.tagName)==="CODE"&&_n("button",{type:"button",className:r.option,onClick:u,children:n}),s&&ns(Ic,{children:[_n("div",{className:r.divider}),_n("button",{type:"button",className:r.option,onClick:f,children:e})]})]}),_n("div",{className:r.arrow})]}),_n("div",{ref:i,"data-testid":"widget-markdown-content",className:r.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:c,onClick:p})]})},vt=vv;var Wr={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",editableCue:"dd-nWSD-",inputSpace:"dd-DGYB1"};import{jsx as Ue,jsxs as os}from"react/jsx-runtime";var bv=500,Cv=100,Tv=({content:t,onChange:e,onCopy:n})=>{let o=xv(null),s=x("WidgetCue",Wr);return Lc(()=>{let r=o.current;if(!r)return;r.style.setProperty("height","0px");let i=Math.min(Math.max(r.scrollHeight,Cv),bv);r.style.setProperty("height",`${i}px`)},[t]),Ue("textarea",{ref:o,className:s.editableCue,onCopy:n,onChange:e,value:t})},wv=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:s})=>{let r=x("WidgetCue",Wr),i=R(Dn),a=K(),d=E("hasKeyboardInput"),[l,c]=Sv(t.text),u=()=>{e&&e(l,t),n(t)},p=(m,h)=>{o&&o(m,t),h&&Ze(h,r.fadeup)},f=m=>{s&&s(m,t)},g=m=>{m.preventDefault(),m.stopPropagation(),n(t)};return Lc(()=>{a("Assistant response displayed",{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text})},[]),os(M,{"data-testid":"cue",children:[Ue(D,{children:os(D.Content,{children:[t.title&&Ue(D.Title,{className:r.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?i(t.rule.label):t.title}),t.editable?Ue(Tv,{content:l,onCopy:()=>{let m=document.getSelection();m&&p(m.toString())},onChange:m=>{var h;return c((h=m.target.value)!=null?h:"")}}):Ue(vt,{content:t.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:p,onUse:d?f:void 0})]})}),os(M.ButtonsContainer,{children:[os("div",{className:r.actions,children:[Ue(M.Button,{onClick:m=>{var h;return p((h=Xo(l,"reply")[0])!=null?h:l,m.target)},variant:"primary",children:i("copyCue")}),t.callToAction&&Ue(M.Button,{onClick:u,variant:"primary",children:t.callToAction.label}),Ue(M.Button,{onClick:g,variant:"secondary",children:i("removeCue")})]}),Ue(ts,{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text,feedbackText:t.text,feedbackType:"assistant"})]})]})},Ac=wv;import{Fragment as Rv,jsx as Vr}from"react/jsx-runtime";var kv=({cues:t})=>{let e=Ev(),n=ne(),o=R(Dn),s=K(),r=l=>{e(Qo({code:l.rule.label})),s("Assistant response closed",{evaluationId:l.evaluationId,assistantCode:l.rule.label,assistantOutput:l.text})},i=(l,c)=>{Se(l),s("Assistant response copied",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,copiedText:l})},a=(l,c)=>{var u;c.callToAction&&(e(Jo(c)),s("Assistant call to action",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,eventName:c.callToAction.event,value:(u=c.callToAction.value)!=null?u:l}))},d=(l,c)=>{var u;n.send(Ae,{text:l,suggestion:{source:"assistant",assistantCode:(u=c.rule)==null?void 0:u.label,sourceText:l}}),s("Assistant response used",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,usedText:l})};return Vr(Rv,{children:t.map(l=>l.isLoading?Vr(es,{title:l.rule.label.startsWith("__")?o(l.rule.label):l.title},l.rule.id):Vr(Ac,{cue:l,onCallToAction:a,onRemove:r,onCopy:i,onUse:d},l.evaluationId))})},Mc=kv;import{Fragment as Pv,useEffect as Iv}from"react";var Nc={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};import{jsx as Ke,jsxs as jr}from"react/jsx-runtime";function Lv(t,e){return e.split(".").reduce((n,o)=>!n||typeof n!="object"||!(o in n)?null:n[o],t)}var Oc=({data:t,schema:e})=>{let n=x("WidgetCustomData",Nc),o=s=>{Se(s)};return Iv(()=>{k.info("Custom data",t,e)},[t]),Ke("dl",{className:n.root,children:e.map(s=>{let r=Lv(t,s.path);return jr(Pv,{children:[Ke("dt",{className:n.label,children:s.label}),Ke("dd",{className:n.value,children:s.type==="boolean"&&r?Ke("span",{className:n.isTrue,children:s.trueValue}):s.type==="boolean"&&!r?Ke("span",{className:n.isFalse,children:s.falseValue}):s.type==="array"&&Array.isArray(r)&&r.length>0?jr("button",{type:"button",onClick:()=>o(r.join(", ")),className:n.copyButton,children:[Ke("span",{className:n.copyButtonText,children:r.join(", ")}),Ke(Vt,{})]}):typeof r=="string"||typeof r=="number"?jr("button",{type:"button",onClick:()=>o(`${r}`),className:n.copyButton,children:[Ke("span",{className:n.copyButtonText,children:r}),Ke(Vt,{})]}):"-"})]},s.label)})})};import{createContext as Fv,Fragment as Hv,useContext as Gr,useEffect as Bv,useRef as Hc,useState as xt}from"react";import{useDispatch as Uv,useSelector as Kv}from"react-redux";var qt={};X(qt,{enUS:()=>Av,nlNL:()=>Mv});var Av={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"}]},Mv={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:"Gesprek wissen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var ss={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",resetContainer:"dd-qKIDX",sources:"dd-xf9c6",source:"dd-a-vyX",tooltip:"dd-EsgcZ",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};import{useRef as Dv}from"react";var Dc={error:"dd-CoAuB"};var $r={};X($r,{enUS:()=>Nv,nlNL:()=>Ov});var Nv={errorPrefix:[{type:0,value:"Error:"}]},Ov={errorPrefix:[{type:0,value:"Foutmelding:"}]};import{jsx as _c,jsxs as _v}from"react/jsx-runtime";var Fc=({message:t})=>{let e=Dv(null),n=x("WidgetCardError",Dc),o=R($r);return Gn(e),_c(M,{ref:e,children:_c(D,{children:_v(D.Content,{className:n.error,children:[o("errorPrefix")," ",t]})})})};import{jsx as H,jsxs as ze}from"react/jsx-runtime";var zv=3,Wv=({sources:t,onClick:e})=>{let n=R(qt),o=x("WidgetKnowledgeAssistant",ss),[s,r]=xt(!1),i=s?t:t.slice(0,zv);return i.length===0?null:ze("ul",{className:o.sources,children:[i.map(a=>H("li",{className:o.source,"data-testid":"knowledge-assist-source",children:ze($,{tooltip:!0,placement:"top-start",children:[H($.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:d=>{d.stopPropagation(),e(a)},children:H("span",{className:o.linkContent,children:a.name})}),a.url&&H($.Content,{className:o.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),i<t&&H("button",{type:"button",className:o.showMoreSources,onClick:()=>r(!0),children:n("showMore",{amount:t.length-i.length})})]})},Vv=({title:t,description:e})=>H(M,{"data-testid":"knowledge-assist-empty-state",children:H(D,{children:ze(D.Content,{children:[H(D.Title,{children:t}),H(vt,{content:e})]})})}),jv=({innerRef:t,item:e,hasKeyboardInput:n,onCopy:o,onUse:s,onSourceClick:r})=>{var d;let i=R(qt),a=Gr(rs);return ze(M,{"data-testid":"knowledge-assist-answer",ref:t,children:[H(D,{children:ze(D.Content,{children:[H(D.Title,{children:e.question}),H(vt,{content:e.answer.answer,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:o,onUse:n?s:void 0}),H(Wv,{sources:(d=e.answer.sources)!=null?d:[],onClick:r})]})}),a.assistantCode&&ze(M.ButtonsContainer,{children:[H("div",{}),H(ts,{evaluationId:e.evaluationId,feedbackType:"assistant",assistantCode:a.assistantCode,assistantOutput:e.answer.answer,feedbackText:e.answer.answer})]})]})},rs=Fv(null),is=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,children:o})=>{let[s,r]=xt(null),[i,a]=xt(!1),[d,l]=xt(null),[c,u]=xt(!!n),[p,f]=xt(null),g=Uv(),m=K(),h=Zo(C=>{if(!t)throw new Error("No knowledge assistant was defined");return l(null),e({assistantCode:t,input:C,threadId:s,onNewThreadId(w){r(w)}})},{onSuccess(C){var w;m("Assistant response displayed",{evaluationId:C.evaluationId,assistantCode:t,assistantOutput:C.answer.answer,input:C.question,sources:(w=C.answer.sources)!=null?w:[]}),u(!1)},onError(C){var w;l((w=C.message)!=null?w:"Unknown error")}}),b=C=>v(null,null,function*(){a(!0),f(C),yield h.call(C),a(!1),f(null)}),T={isEnabled:!!t,assistantCode:t,isSubmitting:i,threadId:s,pendingInput:p,errorMessage:d,onSubmit:b,onReset(){s&&g(Qd(s)),l(null),r(null),t&&m("Assistant thread reset",{threadId:s!=null?s:void 0,assistantCode:t})}};return Bv(()=>{n&&T.isEnabled&&b(n)},[n]),H(rs.Provider,{value:T,children:o})},as=()=>{let t=R(qt),e=x("WidgetKnowledgeAssistant",ss),n=Gr(rs),o=Hc(null),[s,r]=xt(""),i=d=>{r(d.target.value)},a=d=>{d.preventDefault(),n.onSubmit(s).then(()=>{var l;o.current&&((l=o.current)==null||l.focus(),r(""))})};return n.isEnabled?ze("form",{className:e.form,onSubmit:a,children:[H("input",{ref:o,className:e.formInput,placeholder:t("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:s,onChange:i}),H("button",{type:"submit",disabled:n.isSubmitting||s==="",className:e.formSubmit,children:t("submitLabel")})]}):null},ls=({title:t,emptyState:e})=>{var g,m;let n=R(qt),o=K(),s=x("WidgetKnowledgeAssistant",ss),r=Hc(null),i=Gr(rs),a=(m=Kv(Xd((g=i.threadId)!=null?g:-1)))!=null?m:[],d=E("hasKeyboardInput"),l=ne(),c=(h,b)=>{Se(h),i.assistantCode&&o("Assistant response copied",{assistantCode:i.assistantCode,assistantOutput:h,copiedText:h,evaluationId:b.evaluationId})},u=(h,b)=>{i.assistantCode&&o("Assistant source clicked",{evaluationId:b.evaluationId,assistantCode:i.assistantCode,source:h})},p=h=>{h.preventDefault(),i.onReset()},f=(h,b)=>{l.send(Ae,{text:h,suggestion:{source:"assistant",sourceText:h}}),i.assistantCode&&o("Assistant response used",{assistantCode:i.assistantCode,evaluationId:b.evaluationId,assistantOutput:b.answer.answer,usedText:h})};return!i.isEnabled||(a==null?void 0:a.length)===0&&!i.isSubmitting&&!e&&!i.errorMessage?null:ze(Hv,{children:[H(Ie,{type:"knowledge",title:t,"data-testid":"knowledge",children:ze(te,{withDivider:!0,children:[e&&a.length===0&&!i.pendingInput&&H(Vv,y({},e)),a.map((h,b)=>H(jv,{innerRef:b===a.length-1?r:void 0,item:h,hasKeyboardInput:d,onCopy:T=>c(T,h),onUse:T=>f(T,h),onSourceClick:T=>u(T,h)},`${h.question}_${h.answer}_${b}`)),i.pendingInput&&H(es,{title:i.pendingInput}),i.errorMessage&&H(Fc,{message:i.errorMessage})]})}),a.length>0&&H("div",{className:s.resetContainer,children:H(M.Button,{disabled:i.threadId===null||i.isSubmitting,onClick:p,children:n("resetLabel")})})]})};import{useCallback as Gv}from"react";var $v=/(https?:\/\/[^\s]+)/,Uc=t=>t.split(" ").find(e=>$v.test(e));import{jsx as Xt,jsxs as ds}from"react/jsx-runtime";var qv=({suggestion:t,lines:e,onUse:n})=>{var u;let o=t.text||t.url||t.message,s=Uc(o),r=R(In),i=E("showImages"),a=E("fallbackImage"),d=E("hasKeyboardInput"),l=p=>{p.preventDefault(),p.stopPropagation(),d&&n(o)},c=Gv(p=>{window.open(s,"_blank"),p.stopPropagation(),p.preventDefault()},[s]);return ds(M,{onClick:d?l:void 0,"data-testid":"edit-suggestion",children:[ds(D,{children:[i&&t.image&&Xt(D.Image,{src:$o(t,"small",a||void 0),title:t.title}),ds(D.Content,{children:[t.title&&Xt(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&Xt(M.Labels,{labels:t.searchKeywords}),Xt(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:o})]})]}),ds(M.Actions,{children:[s&&Xt(M.ActionButton,{onClick:c,label:r("visitUrl")}),d&&Xt(M.ActionButton,{primary:!0,onClick:l,label:r("useSuggestion")})]})]})},Kc=qv;import{Fragment as Jv,jsx as zc}from"react/jsx-runtime";var Xv=({lines:t,suggestions:e})=>{let n=ne(),o=(s,r)=>{n.send(Ae,{text:s,suggestion:S(y({},r),{source:r.source,sourceText:r.text})})};return zc(Jv,{children:e.map(s=>zc(Kc,{suggestion:s,lines:t,onUse:r=>o(r,s)},s.text||s.url||s.message))})},Wc=Xv;var Fn={};X(Fn,{enUS:()=>Qv,nlNL:()=>Zv});var Qv={waiting:[{type:0,value:"Loading\u2026"}],waitingForConversation:[{type:0,value:"Waiting for conversation\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"}],close:[{type:0,value:"Close"}]},Zv={waiting:[{type:0,value:"Laden\u2026"}],waitingForConversation:[{type:0,value:"Wachten op gesprek\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"}],close:[{type:0,value:"Sluiten"}]};var Jt={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};import{jsx as P,jsxs as Hn}from"react/jsx-runtime";var jc=(t,e)=>{let n=Z(J);Xr(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},tx=({onLogIn:t})=>{let e=x("Widget",Jt),n=E("isEmbedded"),o=E("adminUrl");return P("div",{className:e.loginText,children:P("div",{children:P(Ho,{isEmbedded:n,loginUrl:o,onLogIn:t})})},"login")},qr=({text:t})=>{let e=x("Widget",Jt);return P("div",{className:e.stateText,children:P("div",{children:P("p",{children:t})})},"notification")},nx=()=>{let t=R(Fn),e=Vc(),n=x("Widget",Jt),o=E("showSearch"),s=E("isEmbedded"),r=Z(Xe("/admin/")),i=ne(),a=E("productName"),d=K();return jc(()=>{if(s)return e(_r()),()=>{e(oc())}},[e,s]),!o&&!r?null:Hn("div",{className:n.shortcutList,children:[o&&P(M.Button,{"data-testid":"shortcut-search","aria-label":t("linkSearch"),className:n.shortcut,icon:P(Bt,{}),onClick:()=>{i.send("ShowCommandPalette",{isOpen:!0}),d("open search",{via:"widget-shortcut"})},children:t("linkSearch")}),r&&P(M.Button,{as:"a",target:"_blank",icon:P(uc,{}),href:r,"data-testid":"shortcut-studio-login","aria-label":t("linkStudioLogin",{productName:a}),className:n.shortcut,rel:"noreferrer",onClick:()=>{d("open my deepdesk",{via:"widget-shortcut"})},children:t("linkStudioLogin",{productName:a})})]})},ox=({title:t,content:e})=>{let n=R(Fn),[o,s]=ex(!0);return o?P(Ie,{"data-testid":"custom-data-banner",type:"custom-data-banner",title:t,children:P(te,{withDivider:!0,children:Hn(M,{children:[P(D,{children:P(D.Content,{children:P(vt,{content:e})})}),P(M.ButtonsContainer,{children:P(M.Button,{onClick:()=>s(!1),children:n("close")})})]})})}):null},sx=()=>{let t=Vc(),e=Z(kn),n=Z(qa),o=Z(rc),s=Z(ua),r=Z(wo),i=Z(Io),a=Z(dt),d=Z(xe);return Xr(()=>{s&&!n&&k.warn("Custom data provided, but no schema.")},[s,n]),jc(()=>{e.forEach(({type:l})=>{l==="entities"?t(fe()):Xn.includes(l)||t(he(l))})},[t,d,a]),Xr(()=>{o.length>0&&!e.some(l=>l.type==="cues")&&k.warn("Received cues, but cues are not configured in widget.")},[e,o]),P(Yv,{children:e.map(({type:l,title:c,amount:u,lines:p,schema:f,property:g})=>{var m,h;switch(l){case"entities":return r&&r.length>0&&P(Ie,{type:l,title:c,"data-testid":`type-${l}`,children:P(cc,{entities:r})},l);case"cues":return o&&o.length>0&&P(Ie,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P(Mc,{cues:o})})},l);case"custom-data-banner":return s&&g&&s[g]&&P(ox,{title:c,content:String(s[g])},l);case"custom-data":return s&&f&&P(Ie,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P(Oc,{data:s,schema:f})})},l);default:return((h=(m=i[l])==null?void 0:m.suggestions)==null?void 0:h.length)>0&&P(Ie,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P(Wc,{lines:p,contentType:l,suggestions:i[l].suggestions.slice(0,u)||[]})})},l)}})})},Jr=({children:t})=>{let e=x("Widget",Jt);return P("div",{className:e.footer,children:t})},Qr=({children:t})=>{let e=x("Widget",Jt);return P("div",{className:e.root,"data-testid":"widget",children:t})},rx=({onLogIn:t,knowledgeAssistOptions:e={},assistantOptions:n={transcript:"in-memory-transcript"}})=>{let o=R(Fn),s=Z(Lt),r=Z(J),i=Z(Xi),a=Z(dt),d=Z(Ga("knowledge-assist")),l=Z(Xa);return s===!1?P(qr,{text:o("notSupported")}):r===!1?P(tx,{onLogIn:t}):r===null?P(qr,{text:o("waiting")}):!i||!a?P(qr,{text:o("waitingForConversation")}):P(Qr,{children:Hn(is,{initialQuestion:e.initialQuestion,assistantCode:l!=null?l:void 0,evaluateKnowledgeAssistFn:On,children:[Hn(rn,{children:[P(nx,{}),P(sx,{}),d&&P(ls,{title:d.title,emptyState:e.emptyState})]}),Hn(Jr,{children:[d&&P(as,{}),P(bc,{assistantOptions:n})]})]})})},$c=rx;function Un(t){let e=new Range;return e.selectNodeContents(t),e}function Gc(t,e,n){try{return St(t,e,n),!0}catch(o){return!1}}function cs(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function ps(t){return"tagName"in t&&t.tagName==="BR"}var Bn=/[\u200B-\u200D\uFEFF]/g;function St(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let s=0,r=!1;function i(d,l){let c=-1,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(d))return l;for(let p=0;p<=d.length;p++)if(u.test(d[p])||c++,c===l)return p;throw new Error("Offset out of range")}function a(d){switch(d.nodeType){case Node.TEXT_NODE:{let l=d.textContent,c=l.replace(Bn,""),u=s+c.length,p=e>=s&&e<=u,f=n>=s&&n<=u;if(p){let g=i(l,e-s);g===0&&!f?o.setStartBefore(d):o.setStart(d,g)}f&&(o.setEnd(d,i(l,n-s)),r=!0),s=u;break}case Node.ELEMENT_NODE:{if(ps(d)&&(s===e&&o.setStartBefore(d),s++,s===n)){o.setEndAfter(d),r=!0;return}for(let c=0;c<d.childNodes.length&&(a(d.childNodes[c]),!r);c++);let l=d.lastChild;cs(d)&&l&&!cs(l)&&!ps(l)&&s++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function us(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r,collapsed:i}=e,a,d,l=0;function c(u){let p=u===t,f=u===n,g=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let m=u.textContent;f&&(a=l+m.substring(0,o).replace(Bn,"").length),g&&(d=l+m.substring(0,r).replace(Bn,"").length),l+=m.replace(Bn,"").length;break}case Node.ELEMENT_NODE:{if(ps(u)&&u.nextSibling){l++;break}!p&&cs(u)&&u.previousSibling&&l++;for(let m=0;m<u.childNodes.length;m++){let h=f&&m===o,b=g&&m===r;if(h&&(a=l),b&&(d=l),d!==void 0||((!h||!i)&&c(u.childNodes[m]),g&&m===r-1&&(d=l),d!==void 0))break}g&&(d=l);break}default:break}}if(c(t),d===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:d,end:d}}function ms(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r,collapsed:i}=e,a=0,d="";function l(c){let u=c===t,p=c===n,f=c===s;switch(p&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let g=p?o:0,m=f?r:void 0;d+=c.textContent.replace(Bn,"").substring(g,m);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&ps(c)&&c.nextSibling){d+=`
|
|
9
|
+
`;break}!u&&!i&&a===1&&cs(c)&&c.previousSibling&&(d+=`
|
|
10
|
+
`);let g=p?o:0,m=f?Math.min(r,c.childNodes.length):c.childNodes.length;for(let h=g;h<m&&(l(c.childNodes[h]),a!==2);h++);break}default:break}f&&(a=2)}return l(t),d}var qc=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(qc||{}),Ye=class{constructor(e){this.element=e;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(e,n){let o=s=>{n(s)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}handleInteraction(){let e=this.getText(),n=this.getHTML(),o=this.getSelection(),s=this.cachedCaretPosition===null;if(!this.isActive||(e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),e!==this.cachedText?(this.cachedText=e,this.cachedHTML=n,s=!0,this.emit("change",{plainText:e,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,s=!0,this.emit("change",{plainText:e,rawHTML:n})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,s=!0,this.emit("selection",o)),!s))return;let r=this.getCaretPosition();$e(r,this.cachedCaretPosition)||(this.cachedCaretPosition=r,this.emit("caretposition",r))}handleClick(){this.handleInteraction()}handleFocus(){let e=!this.isFocused;this.isFocused=!0,e&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let e=this.isFocused;this.isFocused=!1,e&&this.emit("blur")}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(qc).includes(n)||n.toLowerCase()==="z"&&(o||s),this.emit("keydown",e)}handleKeyUp(e){this.handleInteraction(),this.emit("keyup",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var o,s;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((s=e.clipboardData)==null?void 0:s.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 e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()})}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}off(e,n){if(!this.eventListeners[e])return;let o=this.eventListeners[e].indexOf(n);o!==-1&&this.eventListeners[e].splice(o,1)}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function Xc(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Qt=class extends Ye{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),ms(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){let n=this.getRootNode();if(n.activeElement!==this.element)return null;let o="getSelection"in n?n.getSelection():window.getSelection();if(!o)return null;let s=o.rangeCount>0?o.getRangeAt(0):null;if(!s)return null;let r=this.element.ownerDocument.createRange();return r.setStart(s==null?void 0:s.startContainer,s==null?void 0:s.startOffset),r.setEnd(s==null?void 0:s.endContainer,s==null?void 0:s.endOffset),!r||!this.element.contains(r.startContainer)||!this.element.contains(r.endContainer)?null:r}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let o=n.getBoundingClientRect();return!Xc(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!Xc(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let n=this.getRange();if(n)return us(this.element,n);let o=this.lastKnownSelection;if(o&&Gc(this.element,o.start,o.end))return o;let s=Un(this.element);return s.collapse(!1),us(this.element,s)}getSelectedText(){let{start:n,end:o}=this.getSelection();return ms(this.element,St(this.element,n,o))}listen(){super.listen();let n=new MutationObserver(r=>{var i,a;r.length===2&&r[0].addedNodes.length===1&&((i=r[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=r[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 o=this.element.isContentEditable,s=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>s.disconnect())}};var ix=["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 Jc(t,e){let n="mozInnerScreenX"in window,o=document.createElement("div");o.id="input-textarea-caret-position-mirror-div";let s=o.style,r=window.getComputedStyle(t),i=t.ownerDocument.body;s.whiteSpace="pre-wrap",s.wordWrap="break-word",s.position="absolute",s.visibility="hidden",ix.forEach(c=>{s[c]=r[c]}),n?t.scrollHeight>Number.parseInt(r.height)&&(s.overflowY="scroll"):s.overflow="hidden",o.textContent=t.value.substring(0,e);let a=document.createElement("span");a.textContent=t.value.substring(e)||".",o.appendChild(a),i.appendChild(o);let d=t.getBoundingClientRect(),l={top:d.top-t.scrollTop+a.offsetTop+Number.parseInt(r.borderTopWidth)+a.offsetHeight,left:d.left-t.scrollLeft+a.offsetLeft+Number.parseInt(r.borderLeftWidth)};return i.removeChild(o),l}var Zt=class extends Ye{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:o}=this.element;return{start:n,end:o}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return Jc(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 r;return(r=n==null?void 0:n.get)==null?void 0:r.call(this.element)},set:r=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,r),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let o=this.element.disabled,s=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>s.disconnect())}};function Qc(t,e,n){let o=`deepdesk-iframe-${t}`,s=document.getElementById(o);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(n).forEach(([a,d])=>{i.searchParams.append(a,d)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=o,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}function ax(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch(e){return t}}var Zr=class{constructor(e){this.name=e;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(e)}onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(JSON.stringify(e))}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Yr=class{constructor(e,n,o){this.name=e;this.targetOrigin=n;this.options=o;this.disposeHandlers=[];this.iframe=Qc(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(n=>n()),(e=this.iframe)==null||e.remove()}},ei=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(e){this.externalId!==e&&(this.cleanup(),k.info("Set externalId",e),this.externalId=e,this.channel=this.createChannel(e))}createChannel(e){let n=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Yr(e,this.deepdeskUrl,{debug:!0}):new Zr(e),o=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=ax(s.data);typeof r!="object"||r.type!=="event"||r.channel!==e||(k.info("Received broadcast event",this.externalId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return n.onMessage(o),n}send(e,n,o){var i,a;k.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let s={type:"event",name:e,payload:n};o!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,n));let r=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage(S(y({},s),{channel:this.externalId}))}cleanup(e=!1){var n,o;(n=this.channel)==null||n.close(),this.channel=void 0,e&&((o=this.defaultChannel)==null||o.close(),this.defaultChannel=void 0)}},Zc=ei;function lx(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function B(t){return Array.isArray(t)?t.map(B):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>S(y({},e),{[lx(n)]:B(t[n])}),{}):t}function dx(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function Y(t){return Array.isArray(t)?t.map(Y):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>S(y({},e),{[dx(n)]:Y(t[n])}),{}):t}var Yt=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var ti=t=>new Promise(e=>{setTimeout(e,t)});var bt=class extends Yt{constructor(){super(...arguments);this.name="ClientError"}},oi=class extends Yt{constructor(){super(...arguments);this.name="ServerError"}},ni=new Map;function cx(t){return v(this,null,function*(){if(t.status===204)return t.text().catch(()=>{}),null;let e=t.headers.get("content-type");if(e!=null&&e.includes("application/json"))return t.json();let n=yield t.text();return n===""?null:(k.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var en=class{constructor(e="",n={}){this.baseUrl=e;this.options=n;this.latestRequestByUrl={};this.refreshingToken=null;this.lastFailedRefreshAt=null;this.failedRefreshCooldown=1e4;var o;this.fetch=(o=n.fetch)!=null?o:window.fetch.bind(window)}patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,n={}){return new Promise((o,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,d=n.method===void 0||n.method.toLowerCase()==="get",N=n,{useCache:l=!1,abortLatest:c=!1,attempts:u=1,retryDelay:p=500,refreshTokenOn401:f=!0,retryOnError:g=_=>_ instanceof TypeError,retryOnResponse:m=_=>_.status>=500,version:h=null}=N,b=A(N,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(l){if(!d)throw new Error(`Can't use 'useCache' for ${n.method}`);if(ni.has(i)){o(ni.get(i));return}}let T=S(y({credentials:"include"},b),{headers:y({Accept:"application/json","Content-Type":"application/json"},b.headers)});!d&&this.csrfToken&&(T.headers=S(y({},T.headers),{"X-CSRFToken":this.csrfToken})),typeof h=="string"&&(T.headers=S(y({},T.headers),{"X-Deepdesk-API-Version":h}));let C=u,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&c&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let I=()=>v(this,null,function*(){return C--,a(i,T).then(_=>v(this,null,function*(){return m(_)&&!r.isAborted&&C>0?(yield ti(p),I()):_.status===401&&f===!0&&w===!1?(w=!0,yield this.refreshToken(),I()):_})).catch(_=>v(this,null,function*(){if(g(_)&&!r.isAborted&&C>0)return yield ti(p),I();throw _}))});I().then(_=>v(this,null,function*(){let W=yield cx(_);if(delete this.latestRequestByUrl[i],_.status>=500){s(new oi("Server Error",W));return}if(_.status===401){s(new bt("Unauthorized",W));return}if(_.status===403){s(new bt("Forbidden",W));return}if(_.status===404){s(new bt("Not Found",W));return}if(_.status>=400){s(new bt("Bad Request",W));return}l&&ni.set(i,W),o(W)})).catch(_=>{s(_)})})}validateToken(){return v(this,null,function*(){let e,n,o;try{({has_valid_access_token:e,is_logged_in:n,has_valid_refresh_token:o}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1}))}catch(s){return!1}if(!e){if(!o)return!1;try{yield this.refreshToken();let{is_logged_in:s}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return s}catch(s){return!1}}return n})}refreshToken(){let e=Date.now();return this.lastFailedRefreshAt&&e-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new bt("Unauthorized","Failed to refresh token")):this.refreshingToken?this.refreshingToken:(this.refreshingToken=this.get("/apis/admin/session/refresh/",{refreshTokenOn401:!1}).catch(n=>{throw(n==null?void 0:n.message)==="Unauthorized"&&(this.lastFailedRefreshAt=Date.now()),n}).finally(()=>{this.refreshingToken=null}),this.refreshingToken)}get(e,n){return this.request(e,n)}post(e,n,o){return this.request(e,y({method:"POST",body:JSON.stringify(n)},o))}patch(e,n,o){return this.request(e,y({method:"PATCH",body:JSON.stringify(n)},o))}put(e,n,o){return this.request(e,y({method:"PUT",body:JSON.stringify(n)},o))}delete(e,n){return this.request(e,y({method:"DELETE"},n))}};var Yc;(e=>{let t;(a=>(a.SUCCESS="success",a.FAILURE="failure",a.CONDITIONS_NOT_MET="conditions_not_met",a.MAX_RECURSION_LEVEL="max_recursion_level",a.NO_ACCESS_TO_ASSISTANT="no_access_to_assistant"))(t=e.EvaluationStatus||(e.EvaluationStatus={}))})(Yc||(Yc={}));function si(t){return S(y({},B(t)),{metadata:t.metadata})}var Ct=class Ct{constructor(e,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new en(e,{fetch:n.fetch}),this.client.patchFetch(o=>(s,r)=>v(this,null,function*(){let i=yield o(s,r);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return v(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=yield this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(Ct.exchangeTokenPromise||(Ct.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),Ct.exchangeTokenPromise):Promise.resolve()})}createConversation(e){return v(this,null,function*(){var o;yield this.preflight(),k.info(`Creating conversation for session ${e.externalId} and agent ${e.agentId}`);let n=yield this.client.post("/api/v2/conversations",S(y({chat_start_time:new Date().toISOString()},Y(e)),{metadata:(o=e.metadata)!=null?o:{}}));return si(n)})}getMe(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/session/me/");return B(e)})}postIdentity(e){return v(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",Y(e))})}patchMe(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",Y(e));return B(n)})}getProfile(e){return v(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${e}/`,{useCache:!0});return B(n)})}getKnowledgeAssistant(e){return v(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{useCache:!0});return B(n)})}getContentTypes(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return B(e)})}getAccount(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/account/",{useCache:!0});return B(e)})}getPlatformConfig(e){return v(this,null,function*(){let n=e!==void 0?`/platform/config/${e}/`:"/platform/config/",{config:o}=yield this.client.get(n,{useCache:!0});return B(o)})}checkUserExists(e){return v(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${e}`,{version:"v1"});return n})}getConversationByExternalId(o){return v(this,arguments,function*(e,n={}){yield this.preflight(),k.info(`Getting conversation for session ${e}`);let{attempts:s=1,retryDelay:r=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return k.info(`Successfully retrieved conversation ${i.id} for session ${e}`),si(i)})}isConversationSupported(o){return v(this,arguments,function*(e,n={}){k.info(`Check if conversation for session ${e} is supported`);let{attempts:s=1,retryDelay:r=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(e,n){return v(this,null,function*(){var r;yield this.preflight();let o=Y(n);n.metadata&&(o.metadata=(r=n.metadata)!=null?r:{});let s=yield this.client.put(`/api/v2/conversations/${e}`,o);return si(s)})}postMessages(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${e}/messages`,n.map(o=>S(y({},Y(o)),{metadata:o.metadata})))})}sendEvent(e,n){return v(this,null,function*(){yield this.preflight();let a=n,{data:o}=a,s=A(a,["data"]),r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((d,[l,c])=>S(y({},d),{[l]:c}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((d,l)=>(s[l]&&(d[l]=s[l]),d),{});return this.client.post("/api/v2/events",Y(S(y(y({},r),i),{data:o,name:e})),{version:"v2"})})}getEntities(e){return v(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:e.filter(o=>o.text)})})}getTemporaryExchangeToken(){return v(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(e){return v(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:e}).catch(n=>{throw k.warn(`Invalid token '${e}'`),n})})}authenticateWithKey(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Y(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(s){return v(this,arguments,function*(e,n={},o){if(yield this.preflight(),o==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${e}/recommend/${o}`,Y(n),{abortLatest:!0})).map(i=>S(y({},B(i)),{text:i.text||i.url||i.message,source:o,type:o})).filter((i,a,d)=>a===d.findIndex(l=>l.text===i.text))})}isLoggedIn(){return v(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(e,n){return v(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${e}/autocomplete`,Y(n),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))})}getPinnedMessages(e){return v(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return B(n).map(o=>S(y({},o),{text:o.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(e){return v(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",Y(e),{abortLatest:!0,version:"v2"});return B(n)})}search(e){return v(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${e.profile}/search`,Y(e));return B(n)})}requestLoginByEmail(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:e});return B(n)})}requestPasswordlessToken(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/session/passwordless/request/");return B(e.token)})}getCsrfToken(){return v(this,null,function*(){let{token:e}=yield this.client.get("/apis/admin/session/csrf/");return e})}verifyLoginToken(e){return v(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:e});return B(n)})}evaluateAssistant(e,n){return v(this,null,function*(){var i;yield this.preflight();let o=new URLSearchParams;n!=null&&n.externalConversationId&&o.append("external_conversation_id",n.externalConversationId);let s=n!=null&&n.threadId?`/api/v2/assistants/${e}/threads/${n==null?void 0:n.threadId}/evaluate?${o.toString()}`:`/api/v2/assistants/${e}/evaluate?${o.toString()}`,r=yield this.client.post(s,{input:(i=n==null?void 0:n.input)!=null?i:{},conversation:n==null?void 0:n.transcript});return B(r)})}createAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n}=e,o=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return B(o)})}postMessageToAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:s}=e,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:s,role:"user"});return B(r)})}translateMessages(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",Y(e));return B(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let s=o.toLowerCase(),r=s.match(Oi);if(!n||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&k.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};Ct.exchangeTokenPromise=null;var et=Ct;import{combineReducers as yx,configureStore as vx}from"@reduxjs/toolkit";import{createSlice as px}from"@reduxjs/toolkit";var ep={startTime:null,stopTime:null},tp=t=>t.handlingTime,np=px({name:"handlingTime",initialState:ep,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(V,()=>ep)}}),{handlingTimeStart:op,handlingTimeStop:gs,handlingTimeReset:sp}=np.actions,rp=np.reducer;var ip=(t={})=>{let e=y({onAuthError:Pt(!1)},t);return n=>o=>s=>("error"in s&&s.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(s))};import{createAsyncThunk as ux,createSlice as mx}from"@reduxjs/toolkit";var fs={list:{keywordMatches:[]},fetchState:"idle"};var Tt=ux("styleSuggestions/getAll",(n,o)=>v(null,[n,o],function*({text:t},e){var d;let{deepdeskAPI:s}=e.extra,r=e.getState(),{showStyleSuggestions:i}=r.settings,a=(d=r.conversation.current)==null?void 0:d.profileCode;if(!i)return fs.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return s.getStyleSuggestions({profileCode:a,message:t})})),gx=mx({name:"styleSuggestions",initialState:fs,reducers:{},extraReducers:t=>{t.addCase(Tt.pending,e=>{e.fetchState="loading"}).addCase(Tt.rejected,e=>{e.fetchState="error"}).addCase(Tt.fulfilled,(e,n)=>{e.fetchState="done",$e(e.list,n.payload)||(e.list=n.payload)}).addCase(it,e=>{e.list=fs.list}).addCase(V,()=>fs)}}),ap=gx.reducer;var lp=(t={})=>{let e,n=!0,o=y({getStyleSuggestions:Tt,debounce:500},t);return s=>r=>i=>{var f;let a=s.getState().input.text,d=r(i),l=s.getState();if(l.auth.isLoggedIn!==!0)return d;let{showStyleSuggestions:c}=l.settings;if(!((f=l.conversation.current)==null?void 0:f.id)||!c)return d;let{text:p}=l.input;return p===a&&!n||(clearTimeout(e),p==="")||(e=setTimeout(()=>{n=!1,s.dispatch(o.getStyleSuggestions({text:p}))},t.debounce)),d}};function fx(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var dp=(t={})=>{let e=y({getTextSuggestions:he,getAutocompleteSuggestions:An,debounce:200,check:Te},t),n;return o=>s=>r=>{var m;let{input:i}=o.getState(),a=s(r),d=o.getState();if(d.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:c}=d.settings,u=(m=d.conversation.current)==null?void 0:m.id,p=r.type===Lo.toString();if(!u||!l&&!c)return a;let{input:f}=d;return fx(f,i)&&!p||(clearTimeout(n),!e.check(d))||(n=setTimeout(()=>{let h=At(d);h===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(h))},p?0:e.debounce)),a}};var cp=Tt.fulfilled.toString();function hx(t,e){let n=new Set([...e.keywordMatches.map(s=>s.keyword)]),o=[];return n.forEach(s=>{let r=t.keywordMatches.filter(d=>d.keyword===s),i=e.keywordMatches.filter(d=>d.keyword===s),a=i.length-r.length;a<=0||o.push(...i.slice(0,a))}),o}var pp=t=>e=>n=>o=>{var l;if(o.type!==cp){n(o);return}let s=e.getState().styleSuggestions.list;n(o);let r=e.getState(),i=r.styleSuggestions.list,a=(l=r.conversation)==null?void 0:l.current;if(s===i)return;let d=hx(s,i);o.type===cp&&d.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:d}})};var xx=yx({assistants:ec,auth:Vi,conversation:Ji,contentTypes:ja,passwordlessToken:sc,entities:Cl,handlingTime:rp,info:xa,input:da,settings:Fi,profile:Ja,search:Ea,styleSuggestions:ap,ui:Zl,textSuggestions:_l});function up(t){return vx({reducer:xx,middleware:e=>{var o;let n=e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}).concat(ip()).concat(dp({debounce:200})).concat(lp({debounce:500})).concat(pp(t.deepdeskAPI));return((o=t.middleware)!=null?o:[]).reduce((s,r)=>s.concat(r),n)},preloadedState:t.preloadedState})}var Sx=t=>{var e,n;return(n=(e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())!=null?n:"unknown"},bx=t=>e=>n=>o=>{var a,d;let s=e.getState(),r=Rt("inlineSuggestions")(s);switch(o.type){case Pt.toString():{!o.payload&&t.emit("logout",void 0);break}case fe.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:(a=s.conversation.current)==null?void 0:a.id,data:{entities:o.payload}});break;case it.toString():t.logSendMessage(o.payload);break;case Jo.toString():t.emit("call-to-action",{cue:o.payload});break;case Ee.fulfilled.toString():o.isBroadcasted||t.broadcast(Bs,o,!1);break;default:break}let i=n(o);switch(o.type){case it.toString():t.handleAfterSendMessage(o.payload);break;case Mn.toString():t.onUpdateShowTabHint(o.payload);break;case gs.toString():t.logHandlingTime();break;case Nt.toString():t.broadcast(po,o);break;case rt.toString():t.broadcast(po,o);break;case Qo.toString():e.dispatch(rt({source:"assistant",assistantCode:o.payload.code}));break;case"analytics/logEvent/fulfilled":{let l=s.assistants.cues.find(c=>c.code===o.meta.arg.data.assistantCode);t.emit("event",S(y({},o.meta.arg),{cue:l}));break}case se.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",S(y({type:Sx(o.payload.suggestion)},o.payload),{replace:o.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}})),r&&e.dispatch(Ge([]));break}case no.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(d=s.conversation.current)==null?void 0:d.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Ge.toString():{r&&o.payload.length>0&&e.dispatch(oo(0));break}default:break}return i},mp=bx;import{createSelector as Cx}from"@reduxjs/toolkit";function ri(t){return t.toISOString().replace("T"," ").replace("Z","")}var Tx=(t,e)=>e.version,gp=Cx([Ot,xe,tp,Tx],(t,e,n,o)=>{if(!e)return k.warn("No conversationId for handling time metrics"),null;let{startTime:s,stopTime:r}=n;return!s||!r?(k.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:e,clientVersion:o,agentId:t==null?void 0:t.agentId,agentName:t==null?void 0:t.agentName,agentEmail:t==null?void 0:t.agentEmail,timeStart:ri(s),timeStop:ri(r)}});function fp(t,e){let{text:n,metrics:{numPaste:o,pastes:s,textSuggestions:r}}=t.input,i=n.length;return{source:"agent",clientVersion:e.version,pastes:s,lenTextTotal:i,numPastes:o,suggestions:r}}function ii(t,e){var r;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return ii(o,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?ii(s,e):null}function ai(t,e){return ii(t,e)}function hp(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function wx(t){return typeof t=="object"&&t!==null&&"tagName"in t}function li(t){return wx(t)&&(ht(t)||Bo(t))}var vp,ke=new Map,Ex=["bottom","height","left","right","top","width"],yp=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:Ex.some(n=>t[n]!==e[n]);function xp(t){var n,o,s;if(t.ownerDocument===document)return[];let e=(s=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?s:null;return e?[e,...xp(e)]:[]}function Sp(t,e){return!t||!e?null:S(y({},t),{top:t.top+e.top,left:t.left+e.left})}var hs=!1,bp=()=>{hs=!0;let t=[];if(ke.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),ke.delete(n);return}let o=n.getBoundingClientRect();yp(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{let n=e.parentRects?e.parentRects.reduce(Sp,e.rect):e.rect;yp(n,e.totalRect)&&e.callbacks.forEach(o=>o(n)),e.totalRect=n}),ke.size===0){hs=!1;return}vp=window.requestAnimationFrame(bp)};function di(t,e){let n=xp(t),o=[],s=n.map((r,i)=>di(r,a=>{o[i]=a;let d=ke.get(t);if(!d)return;let l=o.reduce(Sp,d.rect);d.callbacks.forEach(c=>c(l))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),ke.has(t)){let i=ke.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else ke.set(t,{rect:void 0,callbacks:[e],parentRects:o});r&&!hs&&bp()},unobserve(){s.forEach(i=>i.unobserve());let r=ke.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||ke.delete(t),ke.size||(cancelAnimationFrame(vp),hs=!1)}}}}var Cp,Re=new Map,Tp=()=>{Re.forEach((t,e)=>{if(!e.isConnected){Re.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,s=o>n;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),Re.size!==0&&(Cp=window.requestAnimationFrame(Tp))};function wp(t,e){return{observe(){let n=Re.size===0;Re.has(t)?Re.get(t).callbacks.push(e):Re.set(t,{visible:void 0,callbacks:[e]}),n&&Tp()},unobserve(){let n=Re.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||Re.delete(t),Re.size||cancelAnimationFrame(Cp)}}}}var ci=["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 pi(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function tn(t){return Number.parseFloat(t)}function ys(t){return Math.round(t*1e6)}function Ep(t){return t/1e6}function ui(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,s=tn(t.width),r=tn(t.borderLeftWidth),i=tn(t.borderRightWidth),a=tn(t.paddingRight),d=Ep(ys(s)-ys(r)-ys(i)),l=Ep(ys(o));if(d-l>2){let c=d-l;n.style.paddingRight=`${a+c}px`}}function vs(t,e={}){var c,u;let n=e.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=e.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",gt(n);let o=window.getComputedStyle(t),s=!0,r=()=>{n.scrollTop=t.scrollTop};pi(o,n,ci),ui(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",r));let i=wp(t,()=>{pi(o,n,ci),ui(o,t,n),r(),setTimeout(r,0)}),a,d=!0,l=di(t,p=>{if(p===null){e.onRemove&&e.onRemove(),n.remove();return}if(!d&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),d=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),d=!1},200),p.height===0&&p.width===0){if(s===!0)return;e.onHide&&e.onHide(),n.style.display="none",s=!0;return}if(pi(o,n,ci),ui(o,t,n),r(),e.placement==="below"&&n.classList.add("below"),n.style.top=`${p.top}px`,n.style.left=`${p.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let f=e.closestScrollElement.getBoundingClientRect(),g=window.getComputedStyle(e.closestScrollElement),m=tn(g.borderTopWidth),h=tn(g.borderBottomWidth),b=f.top+m-p.top,T=p.top+p.height+-(f.top+f.height-h);n.style.clipPath=`inset(${b}px 0px ${T}px 0px)`}s&&(n.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(n):(u=t.parentElement)==null||u.appendChild(n),l.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",r),l.unobserve(),i.unobserve(),n.remove()}]}var kp=(t,e)=>({value(){try{let n=sessionStorage.getItem(`dd-${t}`);if(!n)return e;try{return JSON.parse(n)}catch(o){return e}}catch(n){return e}},update(n){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(n))}catch(o){k.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function kx(t){return t.offsetParent!==null}function Rp(t){if(!kx(t))return!1;let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function mi(t,e,n=100){let o=Rp(t);e({isVisible:o});let s=setInterval(()=>{let r=Rp(t);r!==o&&(o=r,e({isVisible:o}))},n);return()=>{clearTimeout(s)}}var Kn=class extends Error{};function Rx(){let t,e;return{promise:new Promise((o,s)=>{t=o,e=s}),resolve:t,reject:e}}var xs=class{constructor(){this.queues={}}push(e,n){let o=()=>{let r=this.queues[e][1];r?(this.queues[e]=[r.promise,null],r.resolve()):delete this.queues[e]};if(!this.queues[e]){let r=n().finally(o);return this.queues[e]=[r,null],r}this.queues[e][1]&&this.queues[e][1].reject(new Kn("Queued async function is outdated"));let s=Rx();return this.queues[e][1]=s,s.promise.then(()=>n().finally(o))}};var Px={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},Pp=(t,e)=>{var s,r,i;if(!((i=(r=(s=t.uiConfig)==null?void 0:s.widget)==null?void 0:r.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return k.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let o=t[Px[e]];return o&&o.length>0?o.map(a=>a.code):(k.warn(`No assistant set in profile for conversation event "${e}"`),[])};var Ss=class{constructor(e){this.options=e;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,o;this.socket,this.eventListeners=new Map,this.url=e.url,this.maxReconnectAttempts=(n=e.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(o=e.reconnectInterval)!=null?o:this.reconnectInterval,this.shouldReconnect=e.shouldReconnect}connect(){let e=()=>this.cleanup();window.addEventListener("beforeunload",e),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",e)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=e=>{var n;try{let o=B(JSON.parse(e.data));o.event&&this.eventListeners.has(o.event)&&((n=this.eventListeners.get(o.event))==null||n.forEach(s=>s(o.data)))}catch(o){console.error("Error parsing WebSocket message:",o)}},this.socket.onclose=e=>{console.log("WebSocket connection closed:",e),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=e=>{console.error("WebSocket error:",e)})}reconnect(){var e,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(e=this.socket)==null||e.close();return}if(!this.shouldReconnect()){console.error("Should not reconnect, closing WebSocket connection."),(n=this.socket)==null||n.close();return}this.socket&&(this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this.socket=new WebSocket(this.url),this.setupListeners(),this.maxReconnectAttempts--}send(e,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:e,data:n}))}on(e,n){this.eventListeners.has(e)||this.eventListeners.set(e,[]);let o=this.eventListeners.get(e);o&&!o.includes(n)&&o.push(n)}close(){var e;(e=this.socket)==null||e.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(e=>e()),this.cleanupCallbacks=[]}};import Ax,{useState as fi,useEffect as Mx}from"react";var Ip={root:"dd-7zvcP",dialogContent:"dd-4C0lK",continueButton:"dd-YUPQW",buttonContinueWrapper:"dd-IKpYs",nicknameInput:"dd-rxhGp",titleWrapper:"dd-nw3nD",title:"dd-5iof5",closeButtonWrapper:"dd-UUAzA",closeButton:"dd-7rjP5",buttonsWrapper:"dd-5e9Xb",errorMessage:"dd--5VgX",errorLink:"dd-u461n"};import{useSelector as Nx}from"react-redux";var gi={};X(gi,{enUS:()=>Ix,nlNL:()=>Lx});var Ix={title:[{type:0,value:"Enter your nickname"}],close:[{type:0,value:"Close"}],nicknameDialogTitle:[{type:0,value:"Please enter the name you'd like customers to see during chat conversations. This nickname will be used across your Deepdesk environment."}],nicknameDialogInputPlaceholder:[{type:0,value:"Enter your nickname"}],nicknameDialogContinueButton:[{type:0,value:"Continue"}],nicknameDialogError:[{type:0,value:"Nickname cannot be empty or spaces only"}],nicknameDialogEmojiError:[{type:0,value:"You cannot use emojis in this field."}],nicknameDialogSaveError:[{type:0,value:"We couldn't save your details just now. Please try again, or update it at "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We couldn\u2019t save your details just now. Please try again later, or update them in My Deepdesk \u2192 Settings."}]},Lx={title:[{type:0,value:"Voer je bijnaam in"}],close:[{type:0,value:"Sluiten"}],nicknameDialogTitle:[{type:0,value:"Voer de naam in die je wilt dat klanten zien tijdens chatgesprekken. Deze bijnaam wordt gebruikt in je Deepdesk-omgeving."}],nicknameDialogInputPlaceholder:[{type:0,value:"Voer je bijnaam in"}],nicknameDialogContinueButton:[{type:0,value:"Doorgaan"}],nicknameDialogError:[{type:0,value:"Bijnaam mag niet leeg of alleen spaties zijn"}],nicknameDialogEmojiError:[{type:0,value:"Je kunt geen emoji's gebruiken in dit veld."}],nicknameDialogSaveError:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw of werk het bij op "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw later, of werk ze bij in My Deepdesk \u2192 Instellingen."}]};import{Fragment as Ox,jsx as ve,jsxs as bs}from"react/jsx-runtime";var Lp=({onClose:t,onSave:e,id:n,error:o})=>{let[s,r]=fi(""),[i,a]=fi(!1),[d,l]=fi(!1),c=x("Nickname",Ip),u=Ax.useRef(null),p=Nx(b=>b.info.showNicknameDialog),f=R(gi),g=E("adminUrl");Mx(()=>{o&&a(!0)},[o]);let m=()=>{if(!u.current)return;s.trim()?u.current.setCustomValidity(""):u.current.setCustomValidity(f("nicknameDialogError")),u.current.reportValidity()},h=b=>{b.preventDefault();let T=s.trim(),C=b.currentTarget.querySelector("#nickname-input");if(!T){C.setCustomValidity(f("nicknameDialogError")),C.reportValidity();return}C.setCustomValidity(""),e(T)};return bs(Ft,{isOpen:p,"datatest-id":n,onClose:t||(()=>{}),onBack:t||(()=>{}),children:[ve("div",{className:c.titleWrapper,children:ve("h1",{className:c.title,children:f("title")})}),bs("form",{className:c.dialogContent,onSubmit:h,children:[ve("p",{children:f("nicknameDialogTitle")}),i&&o&&ve("div",{className:c.errorMessage,children:g?(()=>{let b=f("nicknameDialogSaveError",{account:g}),T=`${g}.deepdesk.com/admin/user-settings`,C=b.indexOf(T);if(C!==-1){let w=b.substring(0,C),I=b.substring(C+T.length);return bs(Ox,{children:[w,ve("a",{href:T,target:"_blank",rel:"noopener noreferrer",className:c.errorLink,children:T}),I]})}return b})():f("nicknameDialogSaveErrorWithoutLink")}),ve("input",{required:!0,minLength:1,maxLength:20,"data-testid":"nickname-input",id:"nickname-input",className:c.nicknameInput,type:"text",placeholder:f("nicknameDialogInputPlaceholder"),value:s,onChange:b=>{l(new RegExp("\\p{Extended_Pictographic}","u").test(b.target.value)),r(b.target.value)},onBlur:m,ref:u}),d&&ve("div",{className:c.errorMessage,role:"alert",children:f("nicknameDialogEmojiError")}),bs("div",{className:c.buttonsWrapper,children:[o?ve("div",{className:c.closeButtonWrapper,children:ve("button",{type:"button",className:c.closeButton,onClick:()=>t==null?void 0:t(),children:f("close")})}):null,ve("div",{className:c.buttonContinueWrapper,children:ve("button",{type:"submit",className:c.continueButton,disabled:!s.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(s),children:f("nicknameDialogContinueButton")})})]})]})]})};import{jsx as F,jsxs as Dx}from"react/jsx-runtime";var Ap=kp("showTabHint",!0),nn=class nn{constructor({deepdeskUrl:e,version:n=nn.version||"unknown",locale:o="en-US",token:s,fetch:r,productName:i,createCustomChannel:a,websocketClient:d=Ss}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.disposeHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.belowSuggestions=null;this.floatingMenu=null;this.widgetElement=null;this.widgetRoot=null;this.nicknameDialogUnsubscribe=null;this.nicknameDialogFailed=!1;this.dynamicThunkObject={};this.queues=new xs;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=e.replace(/\/api$/,"");this.deepdeskApi=new et(l,{token:s,fetch:r}),this.version=n,this.instanceId=nn.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[mp({broadcast:(g,m,h)=>{this.broadcastEvents.send(g,m,h)},emit:(g,m)=>this.emit(g,m),handleAfterSendMessage:g=>this.handleAfterSendMessage(g),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:g=>this.logSendMessage(g),onUpdateShowTabHint:g=>Ap.update(g),sendEvent:(g,m)=>this.deepdeskApi.sendEvent(g,m)})]};this.store=up(c),this.broadcastEvents=new Zc({debug:!0,deepdeskUrl:l,eventMap:ka(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new d({url:`${l}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>v(this,null,function*(){var g;return(g=J(this.state))!=null?g:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(Mn(Ap.value())),this.store.dispatch(Qn({locale:o,adminUrl:l,productName:i}));let u=[],p=g=>{if(!g.conversationId)return;let m=()=>{this.conversationId()===g.conversationId&&this.store.dispatch(Yd(g))};this.hasConversation()?m():u.push(m)};this.ws.on("assistants::direct_response",p),this.ws.on("assistants::user_notification",p),this.ws.on("assistants::response_chunk",g=>{if(!g.conversationId)return;let m=()=>{this.conversationId()===g.conversationId&&this.store.dispatch(Zd(g))};this.hasConversation()?m():u.push(m)}),this.ws.on("assistants::suggest_as_reply",g=>{if(!g.conversationId)return;let m=()=>{this.conversationId()===g.conversationId&&this.store.dispatch(Nt([{text:g.payload.message,type:"text",source:"assistant",assistantCode:g.code,sourceLabel:g.name}]))};this.hasConversation()?m():u.push(m)});let f=this.whenConversationLoaded(()=>{var g;this.broadcastEvents.setExternalId((g=this.state.conversation.current)==null?void 0:g.externalId),u.forEach(m=>m()),u.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),u.length=0,f()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var e;return(e=st(this.state)[this.state.input.selectedSuggestionIndex])!=null?e:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}externalId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.externalId}shouldAbort(){return this.state.conversation.isSupported===!1?(k.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(k.warn("Profile has not been loaded (yet)"),!0):(k.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(e){if(J(this.state))e();else{let n=this.subscribe(J,o=>{o&&e()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch(Pt(null)),this.store.dispatch(Le()),new Promise(e=>{this.whenLoggedIn(()=>e())})}isLoggedIn(){return v(this,null,function*(){return(yield this.store.dispatch(Le())).payload})}isConversationSupported(e,n){return v(this,null,function*(){return(yield this.store.dispatch(Ms({externalId:e,options:n}))).payload})}createConversation(e){return v(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Yn(S(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}getConversationByExternalId(e,n){return v(this,null,function*(){return this.hasConversation()&&this.externalId()!==e&&this.resetConversation(),(yield this.store.dispatch(eo({externalId:e,options:n}))).payload})}upsertConversation(e){return v(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Ns(S(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return v(this,null,function*(){yield this.store.dispatch(Os(e))})}updateConversation(e){return v(this,null,function*(){return(yield this.store.dispatch(to(e))).payload})}resetConversation(){this.store.dispatch(V()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(Qn(e))}setVisitorInfo(e){this.store.dispatch(fa(e))}setCustomData(e){this.store.dispatch(ha(e))}setAgentInfo(e,n){return v(this,null,function*(){var s;yield this.store.dispatch(cn(y(y({},e),n))),(s=this.state.info.agentInfo)!=null&&s.agentNickname||this.broadcastEvents.send(co,{showNicknameDialog:!0})})}setAgentSettings(e){return v(this,null,function*(){yield this.store.dispatch(_s(e))})}getAgentSettings(){return v(this,null,function*(){return(yield this.store.dispatch(Fs())).payload})}refresh(){return v(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let e=[];return e.push(this.refreshTextSuggestions()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(so({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}))}notifyExternalSuggestion(e){this.store.dispatch(se(e))}evaluateAssistant(e,n){return v(this,null,function*(){var d;let{input:o={},transcript:s,showCuesInWidget:r=!0,includeMetadata:i}=n||{},a=yield this.store.dispatch(Ee({assistantCode:e,transcript:s,includeMetadata:i,input:o,skipState:!r}));if(a.error)throw new Error(`Assistant evaluation failed: ${(d=a.payload)!=null?d:a.error.message}`);return a.payload.output})}evaluateConversationAssistant(e,n){return v(this,null,function*(){yield this.loadProfileConfig();let o=this.state.profile.data;if(!o){k.warn("Can't evaluate assistant when profile is not loaded yet.");return}let s=Pp(o,e);yield Promise.all(s.map(r=>this.queues.push(r,()=>v(this,null,function*(){yield this.evaluateAssistant(r,y({includeMetadata:!0},n))})).catch(i=>{if(i instanceof Kn){k.warn(`Queued assistant "${r}" was outdated and dropped`);return}throw i})))})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:s,selectedSuggestionIndex:r,selection:i}=this.state.input,{inlineSuggestions:a,showTextSuggestions:d,suggestionsPlacement:l}=this.settings,c=l==="inline"||l==="below"?"below":"above",u=s.length>0;if(this.store.dispatch(na(Ds(e))),!Te(this.state)||e.key!=="Tab"&&!d)return;let p=()=>{n||!u||i&&(e.shiftKey||(this.store.dispatch(ra()),e.preventDefault()))},f=()=>{n||!u||a&&r<=0||i&&(e.shiftKey||(this.store.dispatch(ia()),e.preventDefault()))};switch(e.key){case"ArrowUp":c==="below"?f():p();break;case"ArrowDown":{c==="below"?p():f();break}case"Escape":{n||(this.store.dispatch(oo(-1)),this.store.dispatch(Je({collapse:!0})),this.store.dispatch(Jl(!0)),e.preventDefault());break}case"Tab":{e.preventDefault();let g=Mt(this.state);if(!g)return;this.store.dispatch(Mn(!1)),this.store.dispatch(se({text:g.text,suggestion:g,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let g=Mt(this.state);if(!g)return;this.store.dispatch(se({text:g.text,suggestion:g,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.settings.inlineSuggestions||e.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let g=Mt(this.state);if(!g)return;this.store.dispatch(se({text:g.text,suggestion:g,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),e.preventDefault();break}default:}n&&o&&this.store.dispatch(Je({collapse:!1}))}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ge([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(op()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(gs()))}logSendMessage(e){let n=fp(this.state,{version:this.version});n&&(e&&(Object.assign(n,{text:e}),Object.assign(n,{lenTextTotal:e.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let e=gp(this.state,{version:this.version});e&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:e}),this.store.dispatch(sp()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch(it((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(la()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(s=>{try{s(n)}catch(r){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.error(r)}})}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}setPlatformVariables(e){this.store.dispatch(ya(e))}whenConversationLoaded(e){let n=r=>{var i;return(i=r.conversation.current)==null?void 0:i.id},o=()=>this.loadProfileConfig().then(()=>e());return n(this.state)&&o(),this.subscribe(n,r=>{r&&o()})}overlayContainerFactory(e,n,o,s){let[r,i]=vs(n,o);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),[r,i]}createInlineContainer(e,n){var a;let o=document.createElement("div");o.style.position="absolute",o.style.top="0px",o.style.left="0px",o.style.height="0px",o.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",o.appendChild(s);let r=(a=e.ownerDocument.defaultView)==null?void 0:a.frameElement,i=r?r.ownerDocument.defaultView:null;if(r&&(i===window||(i==null?void 0:i.parent)===window)){let[d,l]=vs(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});d.dataset.testid=n,d.style.zIndex="2",d.appendChild(o),this.unmountHandlers.push(()=>{l()})}else document.body.appendChild(o);return s}createContainer(e,n=document.body){let o=window.getComputedStyle(n),s=document.createElement("div");return gt(s),s.dataset.testid=e,s.style.color=o.color,s.style.fontSize=o.fontSize,s.style.fontFamily=o.fontFamily,s.style.fontVariant=o.fontVariant,s.setAttribute("translate","no"),n.appendChild(s),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,n),k.info(`Stored analytics for ${this.conversationId()}`)}catch(e){}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(e);if(!n)return;let o=JSON.parse(n);o.text.trim()===this.state.input.text.trim()?(k.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(aa(o.metrics))):k.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch(e){}}mount(e,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!li(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let p=n,{customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i,inputMediator:a}=p,d=A(p,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i};this.configure(d),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),gt(e),this.inputMediator=a||(ht(e)?new Zt(e):new Qt(e)),this.inputMediator.on("change",({plainText:f,rawHTML:g})=>{this.store.dispatch(so({text:f,html:g}))}),this.inputMediator.on("keyup",f=>{this.store.dispatch(oa(Ds(f)))}),this.inputMediator.on("keydown",f=>{this.handleKeyDown(f)}),this.inputMediator.on("paste",({pastedText:f,selectionText:g})=>{this.store.dispatch(sa({text:f,selectionText:g}))}),this.inputMediator.on("cut",({selectionText:f})=>{this.store.dispatch(ta(f))});let c;this.inputMediator.on("selection",f=>{clearTimeout(c),f===null?c=setTimeout(()=>{f!==null&&this.store.dispatch(ro(f))},500):this.store.dispatch(ro(f))}),this.unmountHandlers.push(()=>{clearTimeout(c)}),this.inputMediator.on("disabled",()=>{var f;(f=this.inputMediator)==null||f.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(No(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(No(!0))}),this.renderSuggestions(e,l),this.subscribe(Rt("inlineSuggestions"),()=>{this.renderSuggestions(e,l)}),this.subscribe(Rt("suggestionsPlacement"),()=>{this.renderSuggestions(e,l)});let u=this.renderOverlays(n);this.unmountHandlers.push(()=>{u.unmount()}),this.store.dispatch(so({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(ro(this.inputMediator.getSelection())),this.store.dispatch(No(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{this.restoreMetrics(),this.syncInputMediator(),this.refreshTextSuggestions(),this.promptForNickname()}),this.isMounted=!0}promptForNickname(e){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let o=tt(n),s=null,r=a=>{s=a,i()},i=()=>{o==null||o.render(F(_e,{store:this.store,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(Lp,{id:"deepdesk-nickname-dialog",error:s,onSave:a=>v(this,null,function*(){try{yield this.store.dispatch(ma({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(co,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(d){k.error("Error setting agent nickname",d),r("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{o.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(e,n){let o=e(this.store.getState());return this.store.subscribe(()=>{let s=e(this.store.getState());s!==o&&(o=s,n(o))})}unmount(){var e,n,o,s,r;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.belowSuggestions)==null||o.unmount(),(s=this.floatingMenu)==null||s.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(r=this.inputMediator)==null||r.dispose(),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe(),this.isMounted=!1}dispose(){this.unmount(),this.unmountWidget(),this.disposeHandlers.forEach(e=>e()),this.disposeHandlers=[],this.off()}renderSuggestions(e,n){var o,s,r,i;(o=this.floatingMenu)==null||o.unmount(),(s=this.inlineSuggestions)==null||s.unmount(),(r=this.aboveSuggestions)==null||r.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(e,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(e,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(e,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(e,n,"above")}renderInlineSuggestions(e,n){let{customStyles:o}=n,s=this.createInlineContainer(e,"deepdesk-caret"),r=tt(s);r.render(F(_e,{store:this.store,customStyles:o,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(ld,{})})}));let i=a=>{a?(s.style.display="block",s.style.top=`${a.top}px`,s.style.left=`${a.left}px`):s.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),r.unmount(),s.remove()}}}renderAboveOrBelowSuggestions(e,n,o){let{customStyles:s,closestScrollSelector:r,appendOverlayTo:i}=n,a=r&&ai(e,r)||void 0,[d,l]=this.overlayContainerFactory("deepdesk-tab-completion",a||e,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},s==null?void 0:s.rootNode),[c,u]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||e,{appendTo:i,placement:o},s==null?void 0:s.suggestionsRootNode),p=tt(d);p.render(F(_e,{store:this.store,customStyles:s,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(Vd,{inputElement:e})})}));let f=tt(c);return f.render(F(_e,{store:this.store,customStyles:s,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(vd,{onLogIn:()=>this.loginViaPopup().catch(g=>k.warn(g.message))})})})),{unmount(){p.unmount(),f.unmount(),l(),u()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:s,appendOverlayTo:r,floatingMenuParent:i}=n,a=s&&ai(e,s)||void 0,[d,l]=this.overlayContainerFactory("floating-menu",a||e,{appendTo:i!=null?i:r},o==null?void 0:o.floatingMenuParent),c=tt(d);return c.render(F(_e,{store:this.store,customStyles:o,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(ql,{onLogIn:()=>this.loginViaPopup().catch(u=>k.warn(u.message))})})})),{unmount(){c.unmount(),l()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays"),s=tt(o);return s.render(F(_e,{store:this.store,customStyles:n,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(zl,{})})})),{unmount(){s.unmount(),o.remove()}}}renderWidget(e,n={}){if(this.widgetElement&&k.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:s,isEmbedded:r}=n;this.widgetElement=e,this.configure({showImages:s,isEmbedded:r}),this.widgetRoot=tt(e),this.widgetRoot.render(F(_e,{store:this.store,customStyles:o,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F($c,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(i=>k.warn(i.message))})})}))}unmountWidget(){var e,n;(n=(e=this.widgetRoot)==null?void 0:e.unmount)==null||n.call(e),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(e,n,o={}){let{customStyles:s,initialQuestion:r}=o,i=tt(n);return i.render(F(_e,{store:this.store,customStyles:s,children:F(Me,{broadcastEvents:this.broadcastEvents,children:F(Qr,{children:Dx(is,{assistantCode:e,initialQuestion:r,evaluateKnowledgeAssistFn:On,children:[F(rn,{children:F(ls,{title:o.title,emptyState:o.emptyState})}),F(Jr,{children:F(as,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(e){let n=mi(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){hp(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>v(this,null,function*(){yield this.store.dispatch(En());let e=dt(this.state);e&&this.store.dispatch(Qn({showSearch:e.search,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:!!e.summarizerAssistantNew,showKnowledgeSearch:!!e.knowledgeAssistantNew||!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions}))})),this.loadProfileConfigPromise)}loginViaPopup(e){return v(this,null,function*(){return new Promise((n,o)=>{this.store.dispatch(Zn());let s=new MessageChannel,r=s.port1,i=this.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let d=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",u),clearInterval(p)};r.onmessage=f=>v(this,null,function*(){var g,m;if((g=f.data)!=null&&g.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((m=f.data)==null?void 0:m.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(un),d=!0,s.port1.close(),n()}catch(h){console.error(h),o(h)}finally{d=!0,l()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&o(new Error("Popup blocked by browser"));let u=f=>v(this,null,function*(){var g;if(f.origin===a.origin)switch((g=f.data)==null?void 0:g.type){case"deepdesk-popup-request-origin":{try{let m=JSON.stringify({type:"deepdesk-popup-parent-origin"});c==null||c.postMessage(m,a.origin)}catch(m){k.error("Error posting message to popup",m),o(m)}break}case"deepdesk-popup-loaded":{try{let m=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(m,a.origin,[s.port2])}catch(m){k.error("Error posting message to popup",m),o(m)}break}case"deepdesk-popup-error":{if(l(),f.data.message==="Platform account url mismatch"){let m=`Please contact your administrator: The platform account url (${f.data.targetOrigin}) is misconfigured as it differs from the origin of the page that opened the popup (${f.data.openerOrigin}).`;k.warn(m),this.store.dispatch(As(m)),o(new Error(m))}if(f.data.message==="Timeout"){let m="Please contact your administrator: Popup timed out. Check if the account's platform url is configured correctly.";k.warn(m),this.store.dispatch(As(m)),o(new Error(m))}o(new Error(f.data.message));break}}});window.addEventListener("message",u);let p=setInterval(()=>{c&&!c.closed||(l(),d||o(new Error("Popup closed by user")))},200);this.disposeHandlers.push(l)})})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}refreshTextSuggestions(){return v(this,null,function*(){this.isMounted&&(yield this.store.dispatch(Lo()))})}refreshWidgetSuggestions(){return v(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=kn(this.state);try{n.forEach(({type:o})=>{switch(o){case"entities":this.store.dispatch(fe());break;case"pinned-messages":case"sticky-messages":break;default:Xn.includes(o)||this.store.dispatch(he(o))}})}catch(o){this.handleError(o)}})}};nn.version="19.1.1-beta.4",nn.count=0;var Cs=nn;function _x(t){return v(this,null,function*(){var s,r,i;let n=yield((s=t.fetch)!=null?s:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(r=t.mimeType)!=null?r:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function Fx(t,e){return v(this,null,function*(){let n=yield _x(e),o=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[n]}),t.dispatchEvent(o)}finally{Object.hasOwn(t,"files")&&delete t.files}})}function Hx(t,e,n){return v(this,null,function*(){yield new et(t).authenticateWithKey(e,n)})}function Bx(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Ux(o,s){return v(this,arguments,function*(t,e,n={}){var u,p;let{value:r}=t,{start:i,end:a}=(u=n.replace)!=null?u:{start:0,end:r.length},d=`${r.slice(0,i)}${e}${r.slice(a)}`,l=(p=n.selectionAfter)!=null?p:{start:i+e.length,end:i+e.length},c=()=>{if(n.setValue)return n.setValue(d);t.value=d};return Promise.resolve(c()).then(()=>{t.selectionStart=l.start,t.selectionEnd=l.end,t.blur(),t.focus()})})}function Kx(o,s){return v(this,arguments,function*(t,e,n={}){let r=n.replace?St(t,n.replace.start,n.replace.end):Un(t),i,a=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),i=document.createElement("span"),r.insertNode(i),n.insertBRs!==!1?e.split(`
|
|
11
|
+
`).reverse().forEach((d,l)=>{l>0&&r.insertNode(document.createElement("br")),r.insertNode(document.createTextNode(d))}):r.insertNode(document.createTextNode(e))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let d=n.selectionAfter?St(t,n.selectionAfter.start,n.selectionAfter.end):(r.collapse(!1),r),l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(d)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function zx(t){let e=document.createElement("template");return e.innerHTML=t.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),e.content}function Wx(t){let e=document.createDocumentFragment();return t.split(`
|
|
12
|
+
`).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=n.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(n.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(n.slice(r)))}),e}function Mp(t,e){let n=t.parentElement;if(!n){console.warn("No insert point found");return}let{display:o}=window.getComputedStyle(n);o.includes("block")||o==="table-cell"?n==null||n.insertBefore(e,t.nextSibling):Mp(n,e)}function Vx(s,r){return v(this,arguments,function*(t,e,{isBlock:n,isHTML:o}={}){let i;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let a=()=>{var p;let d=(p=t.ownerDocument.defaultView)!=null?p:window,l=d.getSelection();if((!l||l.rangeCount===0)&&(t.focus(),l=d.getSelection()),!l||l.rangeCount===0)return;let c=l.getRangeAt(0);if(!c)return;i=document.createElement("span"),c.insertNode(i);let u=o?zx(e):Wx(e);n?Mp(c.startContainer,u):(c.insertNode(u),c.collapse(!1))};return Promise.resolve(a()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!i)try{i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}export{D as Card,Qt as ContentEditableInput,et as DeepdeskAPI,Cs as DeepdeskSDK,en as HTTPClient,Ye as InputMediator,kt as InputType,ks as KeyboardHint,Zp as Label,Jn as Locale,Ie as Section,rn as SectionList,je as Sources,M as Suggestion,te as SuggestionList,Zt as TextAreaInput,Et as ToggleButton,Fx as attachFile,Hx as authenticateWithKey,Un as createFullRange,vs as createOverlayContainer,St as createRangeFromOffsets,Pn as escapeHTML,Bx as formatTextMarkup,us as getRangeOffsets,ms as getRangeText,Vx as insertCKEditor,So as isHTML,li as isSupportedInputElement,ur as logEvent,Kx as updateContentEditable,Ux as updateTextArea,mt as useClickOutsideRoot,x as useStyles,mi as waitForElementVisibilityChange};
|