@deepdesk/deepdesk-sdk 17.0.0-rc.4 → 17.0.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,12 +1,12 @@
1
- "use strict";var Zu=Object.create;var Jn=Object.defineProperty,Qu=Object.defineProperties,Ju=Object.getOwnPropertyDescriptor,Yu=Object.getOwnPropertyDescriptors,em=Object.getOwnPropertyNames,Jo=Object.getOwnPropertySymbols,tm=Object.getPrototypeOf,Hs=Object.prototype.hasOwnProperty,wa=Object.prototype.propertyIsEnumerable;var ba=(t,e,n)=>e in t?Jn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,g=(t,e)=>{for(var n in e||(e={}))Hs.call(e,n)&&ba(t,n,e[n]);if(Jo)for(var n of Jo(e))wa.call(e,n)&&ba(t,n,e[n]);return t},S=(t,e)=>Qu(t,Yu(e));var A=(t,e)=>{var n={};for(var o in t)Hs.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&Jo)for(var o of Jo(t))e.indexOf(o)<0&&wa.call(t,o)&&(n[o]=t[o]);return n};var re=(t,e)=>{for(var n in e)Jn(t,n,{get:e[n],enumerable:!0})},Ca=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of em(e))!Hs.call(t,r)&&r!==n&&Jn(t,r,{get:()=>e[r],enumerable:!(o=Ju(e,r))||o.enumerable});return t};var M=(t,e,n)=>(n=t!=null?Zu(tm(t)):{},Ca(e||!t||!t.__esModule?Jn(n,"default",{value:t,enumerable:!0}):n,t)),nm=t=>Ca(Jn({},"__esModule",{value:!0}),t);var y=(t,e,n)=>new Promise((o,r)=>{var s=d=>{try{l(n.next(d))}catch(a){r(a)}},i=d=>{try{l(n.throw(d))}catch(a){r(a)}},l=d=>d.done?o(d.value):Promise.resolve(d.value).then(s,i);l((n=n.apply(t,e)).next())});var Bh={};re(Bh,{Card:()=>K,ContentEditableInput:()=>pn,DeepdeskAPI:()=>St,DeepdeskSDK:()=>Zo,HTTPClient:()=>mn,InputMediator:()=>xt,InputType:()=>xn,KeyboardHint:()=>or,Label:()=>Aa,Locale:()=>eo,Section:()=>We,SectionList:()=>yn,Sources:()=>tt,Suggestion:()=>F,SuggestionList:()=>ve,TextAreaInput:()=>un,ToggleButton:()=>Bt,attachFile:()=>Bu,authenticateWithKey:()=>Uu,createFullRange:()=>$n,createOverlayContainer:()=>Xo,createRangeFromOffsets:()=>Dt,escapeHTML:()=>An,formatTextMarkup:()=>Vu,getRangeOffsets:()=>$o,getRangeText:()=>Go,insertCKEditor:()=>qu,isHTML:()=>_r,isSupportedInputElement:()=>Ns,updateContentEditable:()=>Wu,updateTextArea:()=>zu,useClickOutsideRoot:()=>It,useStyles:()=>x,waitForElementVisibilityChange:()=>_s});module.exports=nm(Bh);var Bs=M(require("classnames")),ke=M(require("react"));var Yo=M(require("react")),Ta=M(require("classnames"));var Yn=Yo.default.createContext({});function x(t,e){let s=(0,Yo.useContext)(Yn),{debug:n}=s,r=A(s,["debug"])[t];return Object.entries(e).reduce((i,[l,d])=>{let a=r==null?void 0:r[l];return S(g({},i),{[l]:(0,Ta.default)(d,a,n?`${t}__${l}`:!1)})},{})}var Ea={root:"dd-4s9wq"};var Ht=require("react/jsx-runtime"),er=()=>(0,Ht.jsxs)("svg",{className:Ea.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Ht.jsx)("defs",{children:(0,Ht.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Ht.jsx)("title",{children:"Failed loading image"}),(0,Ht.jsx)("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 Ks={root:"dd-c9KvZ",imageWrapper:"dd-sE7D9",image:"dd-bEGMz",content:"dd-oFIQa",title:"dd-mSgoo",contentIsCropped:"dd-Uvjv4",lineClamp:"dd-ApQo-"};var Kt=require("react/jsx-runtime"),tr=(0,ke.createContext)(Ks),om=({title:t,src:e})=>{let n=(0,ke.useContext)(tr),[o,r]=(0,ke.useState)(!1);return(0,ke.useEffect)(()=>{r(!1)},[e]),(0,Kt.jsx)("div",{className:n.imageWrapper,children:e&&!o?(0,Kt.jsx)("img",{className:n.image,alt:t,src:e,onError:()=>r(!0)}):(0,Kt.jsx)(er,{})})},rm=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let r=(0,ke.useContext)(tr);return(0,Kt.jsx)("div",{className:(0,Bs.default)(r.content,t,{[r.contentIsCropped]:n,[r.lineClamp]:e}),children:o})},sm=s=>{var i=s,{as:t="h1",cropText:e=!1,className:n,children:o}=i,r=A(i,["as","cropText","className","children"]);let l=(0,ke.useContext)(tr);return ke.default.createElement(t,g({className:(0,Bs.default)(l.title,n,{[l.contentIsCropped]:e})},r),o)},nr=({children:t})=>{let e=x("Card",Ks);return(0,Kt.jsx)("div",{className:e.root,children:(0,Kt.jsx)(tr.Provider,{value:e,children:t})})};nr.Image=om;nr.Content=rm;nr.Title=sm;var K=nr;var Ra=M(require("classnames"));var ka={root:"dd-llBx9"};var Pa=require("react/jsx-runtime");var im={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},am=o=>{var r=o,{className:t,keyCode:e}=r,n=A(r,["className","keyCode"]);let s=x("KeyboardHint",ka);return(0,Pa.jsx)("span",g({"data-key":im[e],className:(0,Ra.default)(t,s.root)},n))},or=am;var La=M(require("classnames"));var Ia={root:"dd-e6HXZ"};var Ma=require("react/jsx-runtime"),lm=o=>{var r=o,{className:t,children:e}=r,n=A(r,["className","children"]);let s=x("Label",Ia);return(0,Ma.jsx)("span",S(g({},n),{className:(0,La.default)(t,s.root),children:e}))},Aa=lm;var Na={root:"dd-FiMI7",subTitleContainer:"dd-98jc7",subtitle:"dd-3MnW8",suggestions:"dd-0SGL8"};var hn=require("react/jsx-runtime"),dm=r=>{var s=r,{title:t,children:e,type:n}=s,o=A(s,["title","children","type"]);let i=x("Section",Na);return(0,hn.jsxs)("section",S(g({},o),{className:i.root,"data-section-type":n,children:[t&&(0,hn.jsx)("div",{className:i.subTitleContainer,children:(0,hn.jsx)("span",{className:i.subtitle,children:t})}),(0,hn.jsx)("div",{className:i.suggestions,children:e})]}))},We=dm;var Ka=M(require("classnames")),Ba=require("react");var bt=require("react"),Fa=require("react/jsx-runtime"),Oa=(0,bt.createContext)(null),Da=({scrollContainerRef:t,children:e})=>{let n=(0,bt.useCallback)(o=>{let r=t.current;if(!r||r.scrollHeight<=r.clientHeight)return;let{top:s}=r.getBoundingClientRect(),{top:i}=o.getBoundingClientRect();r.scrollTo({top:i-s})},[]);return(0,Fa.jsx)(Oa.Provider,{value:n,children:e})},_a=t=>{let e=(0,bt.useContext)(Oa);(0,bt.useEffect)(()=>{let n=t.current;n&&e(n)},[])};var Ha={root:"dd-uoTXh"};var Us=require("react/jsx-runtime"),cm=({className:t,children:e})=>{let n=x("SectionList",Ha),o=(0,Ba.useRef)(null);return(0,Us.jsx)(Da,{scrollContainerRef:o,children:(0,Us.jsx)("div",{ref:o,className:(0,Ka.default)(n.root,t),children:e})})},yn=cm;var vn=M(require("classnames")),ye=M(require("react"));var Vs={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",buttonWithIcon:"dd-MQVt5",buttonDisabled:"dd-agTuH"};var he=require("react/jsx-runtime"),wt=(0,ye.createContext)(Vs),pm=o=>{var r=o,{fixed:t,children:e}=r,n=A(r,["fixed","children"]);let s=(0,ye.useContext)(wt);return(0,he.jsx)("div",S(g({},n),{className:(0,vn.default)(s.actions,{[s.actionsIsFixed]:t}),children:e}))};function um(l){var d=l,{as:t,className:e,icon:n,title:o,children:r,disabled:s}=d,i=A(d,["as","className","icon","title","children","disabled"]);let a=(0,ye.useContext)(wt);return(0,he.jsxs)(t||"button",S(g({type:"button",className:(0,vn.default)(a.button,{[a.buttonWithIcon]:n,[a.buttonDisabled]:s},e),title:o,"aria-label":o},i),{children:[n,r]}))}var mm=({children:t})=>{let e=(0,ye.useContext)(wt);return(0,he.jsx)("div",{className:e.buttonsContainer,children:t})},gm=({className:t,primary:e,disabled:n,label:o,children:r})=>{let s=(0,ye.useContext)(wt);return(0,he.jsxs)("div",{className:(0,vn.default)(t,s.actionButton,s.dropdownButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,(0,he.jsx)("ul",{className:s.dropdownList,children:r})]})},fm=({index:t,label:e,onClick:n})=>{let o=(0,ye.useContext)(wt);return(0,he.jsx)("li",{className:o.dropdownItem,children:(0,he.jsx)("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},hm=({className:t,primary:e,disabled:n,onClick:o,label:r})=>{let s=(0,ye.useContext)(wt);return(0,he.jsx)("button",{type:"button",className:(0,vn.default)(t,s.actionButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onClick:o!=null?o:i=>i.stopPropagation(),disabled:n,"aria-hidden":n,children:r})},ym=({labels:t})=>{let e=(0,ye.useContext)(wt);return(0,he.jsx)("div",{className:e.labels,children:t.map(n=>(0,he.jsx)("span",{className:e.label,children:n},n))})},Ct=ye.default.forwardRef((l,i)=>{var d=l,{className:t,selected:e,onClick:n,children:o,as:r="div"}=d,s=A(d,["className","selected","onClick","children","as"]);let a=x("Suggestion",Vs),c=(0,ye.useCallback)(u=>{u.preventDefault(),n&&n(u)},[n]);return(0,he.jsx)(r,S(g({},s),{ref:i,className:(0,vn.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!n}),onClick:c,children:(0,he.jsx)(wt.Provider,{value:a,children:o})}))});Ct.Labels=ym;Ct.Actions=pm;Ct.ActionButton=hm;Ct.DropdownButton=gm;Ct.DropdownItem=fm;Ct.ButtonsContainer=mm;Ct.Button=um;var F=Ct;var Va=M(require("classnames"));var Ua={root:"dd-W35K-",isWithDivider:"dd-sscOy"};var za=require("react/jsx-runtime"),vm=({withDivider:t,children:e})=>{let n=x("SuggestionList",Ua);return(0,za.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Va.default)(n.root,{[n.isWithDivider]:t}),children:e})},ve=vm;var ja=M(require("classnames"));var Wa={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};var rr=require("react/jsx-runtime"),xm=({className:t,isCollapsed:e,title:n,onClick:o})=>{let r=x("ToggleButton",Wa);return(0,rr.jsx)("button",{type:"button",className:(0,ja.default)(r.root,t,{[r.isCollapsed]:e}),onClick:o,title:n,children:(0,rr.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,rr.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Bt=xm;var qa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,sr=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var $a=/x-deepdesk-(([a-z0-9\-_])+-version)/,ir=["cues","custom-data"],Ga=Intl.DateTimeFormat().resolvedOptions().timeZone,tt=(h=>(h.SEARCH="search",h.TEMPLATE="template",h.ELASTIC_SEARCH="search-autocomplete",h.GPT="gpt",h.TRIE="trie",h.TRIE_WITH_TYPOS="trie-with-typos",h.SEMANTIC="semantic",h.TEXT_RECOMMENDATION="text_recommendation",h.URL_RECOMMENDATION="url_recommendation",h.LINK_RECOMMENDATION="link_recommendation",h.PERSONAL_COLLECTION="personal-collection",h.PERSONAL_COLLECTION_SEARCH="personal-collection-search",h.SEARCH_OVERLAY="search-overlay",h.SEARCH_PREVIEW="search-preview",h.SEARCH_URL="search-url",h))(tt||{}),xn=(i=>(i.ENTER="enter",i.TAB="tab",i.ARROW="arrow",i.HOTKEY="hotkey",i.MOUSE="mouse",i.SPACE="space",i))(xn||{});var J=require("react-dom");var yc=require("react");var Xa=require("@reduxjs/toolkit"),Za=require("react-redux");var eo=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(eo||{});var Sm={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,inlineSuggestions:!1,floatingMenu:!1,detectSubmit:!1,automaticHandlingTime:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!1,adminUrl:void 0,productName:"Deepdesk",hasKeyboardInput:!0},Qa=(0,Xa.createSlice)({name:"settings",initialState:Sm,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,r]=n;typeof r!="undefined"&&(t[o]=r)})}}}),{set:ar}=Qa.actions,to=t=>e=>e.settings[t],C=t=>(0,Za.useSelector)(to(t)),Ja=Qa.reducer;var li=require("react-redux");var Sn=require("@reduxjs/toolkit");var bm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},de=t=>t.auth.isLoggedIn,Ya=t=>t.auth.loginFetchState,el=t=>t.auth.verifyFetchState,tl=t=>t.auth.showLoginOverlay,nt=(0,Sn.createAsyncThunk)("auth/validate",(t,e)=>y(void 0,null,function*(){return e.extra.deepdeskAPI.isLoggedIn()})),nl=(0,Sn.createAsyncThunk)("auth/requestLogin",(n,o)=>y(void 0,[n,o],function*({email:t},e){let{deepdeskAPI:r}=e.extra;return r.requestLoginByEmail(t)})),no=(0,Sn.createAsyncThunk)("auth/verifyLoginToken",(n,o)=>y(void 0,[n,o],function*({token:t},e){let{deepdeskAPI:r}=e.extra;return r.verifyLoginToken(t)})),ol=(0,Sn.createSlice)({name:"auth",initialState:bm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(nt.pending,e=>{e.loginFetchState="loading"}),t.addCase(nt.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(nt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(no.pending,e=>{e.verifyFetchState="loading"}),t.addCase(no.rejected,e=>{e.verifyFetchState="error"}),t.addCase(no.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:bn,setShowLoginOverlay:rl}=ol.actions,sl=ol.reducer;var Vt=require("@reduxjs/toolkit"),ul=require("diff"),ml=require("react-redux");function il(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Tt(t,e,n=10){let o=typeof t,r=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==r?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((s,i)=>Tt(s,e[i],n-1)):il(t)&&il(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Tt(t[i],e[i],n-1)):!1}function wm(t){return Math.max(...t.map(e=>e.length))}function Cm(t,e){let n=t.reduce((o,r)=>{if(r){let s=o[r]?o[r]+1:1;return S(g({},o),{[r]:s})}return o},{});return Object.keys(n).reduce((o,r)=>(n[r]<e&&o.push(r),o),[])}function al(t,e){let o=[...t.map(({text:r})=>r.split(/\b(\w+)\b/))];for(let r=0;r<wm(o);r++){let s=Cm(o.map(l=>l[r]),e),i=o.filter(l=>!s.includes(l[r]));if(i.length>=e)o=i;else return{text:o[0].slice(0,r).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Tm=2;function ll(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=al(t,Tm);return n&&n.text!==e?n:t[0]}var Oe=require("@reduxjs/toolkit");var Em={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},T=Em;var dl={current:null,isSupported:null},Z=(0,Oe.createAction)("resetConversation"),cl=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.externalId)||null},je=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},wn=t=>t.conversation.isSupported,zs=(0,Oe.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),lr=(0,Oe.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),dr=(0,Oe.createAsyncThunk)("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),cr=(0,Oe.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=je(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),Ws=(0,Oe.createAsyncThunk)("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:r,agentName:s,agentEmail:i,agentNickname:l,metadata:d}=t;return n.updateConversation(o.id,{agentId:r,agentEmail:i,agentName:s,agentNickname:l,metadata:d})})}),pr=(0,Oe.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=je(e.getState());if(!o)throw new Error("No current conversation to update messages");return n.postMessages(o,t.map(r=>g({},r)))}),km=[lr.rejected,dr.rejected,cr.rejected,pr.rejected].map(t=>t==null?void 0:t.toString()),Rm=(0,Oe.createSlice)({name:"conversation",initialState:dl,reducers:{},extraReducers:t=>{t.addCase(zs.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(lr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(dr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Ws.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(cr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(pr.fulfilled,(e,n)=>{e.current&&(e.current.messages=n.payload)}).addCase(Z,()=>dl).addMatcher(e=>km.includes(e.type),(e,n)=>{var o;throw T.info("Conversation action rejected",n.type,((o=n.error)==null?void 0:o.message)||"No message"),new Error(n.error.message)})}}),pl=Rm.reducer;var Ut={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function js(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}}var ur=(0,Vt.createAction)("input/replaceText"),zt=(0,Vt.createAction)("input/sendMessage"),mr=(0,Vt.createAction)("input/applyImageSuggestion"),ot=(0,Vt.createAction)("input/sendEvent"),gl=(0,Vt.createSlice)({name:"input",initialState:Ut,reducers:{setInput(t,e){var s,i;let{beforeInputChange:n}=t,{text:o,html:r}=e.payload;if(t.text=o,t.html=r!=null?r:null,o==="")t.metrics=Ut.metrics,t.textSuggestions=[],t.mixedSuggestion=null;else if(n!==null&&t.text!==n.text){let{key:l,shiftKey:d,ctrlKey:a,metaKey:c,altKey:u}=n.keyDown;switch(l){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:p}=t,m=(0,ul.diffChars)(n.text,p);n.text.length-p.length>1&&t.metrics.deletions.push(...m.filter(f=>f.removed).map(f=>f.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(a||c)break;default:if(!a&&!c&&!u){t.metrics.numCharsTyped+=1;let p=((s=n.selection)==null?void 0:s.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},setSelection(t,e){e.payload!==null&&(Tt(t.selection,e.payload)||(t.selection=e.payload))},commitSuggestion(t,e){let n=e.payload,{text:o,suggestion:{source:r,abVariant:s,abTestName:i,trainingJobs:l,sourceText:d,searchTerm:a,text:c},eventMetrics:{inputType:u},replace:p}=n,m=r==="search"||r==="personal-collection-search",f=o.slice(t.text.substring(0,t.selection.start).length);(m||p==="selection")&&(f=o),n.suggestion.source==="search-overlay"&&(f=c),t.metrics.textSuggestions.push({text:f,source:r,abVariant:s,abTestName:i,inputType:u,sourceText:d,trainingJobs:l||[],searchTerm:m?t.text:a}),t.textSuggestions=[],t.selectedSuggestionIndex=-1},offeredTextSuggestion(t,e){let{text:n,suggestion:{source:o}}=e.payload;t.metrics.offeredTextSuggestions.find(s=>s.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(g({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:r}=e.payload,s=n.numCharsDeleted+(r!=null&&r.length?r.length:0),i=r!=null&&r.length?[...n.deletions,r]:n.deletions;t.metrics=S(g({},t.metrics),{numCharsDeleted:s,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.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=ll(e.payload,n);t.mixedSuggestion=o!=null&&o.text.includes(n)?o:null},setMetrics(t,{payload:e}){t.metrics=e},resetMetrics(t){t.metrics=Ut.metrics}},extraReducers:t=>{t.addCase(Z,e=>{e.mixedSuggestion=Ut.mixedSuggestion,e.textSuggestions=Ut.textSuggestions,e.selectedSuggestionIndex=Ut.selectedSuggestionIndex,e.metrics=Ut.metrics})}}),Cn=t=>t.input.text.substring(0,t.input.selection.end),Pm=t=>t.input.selection,Tn=t=>{let{mixedSuggestion:e,selectedSuggestionIndex:n,textSuggestions:o}=t.input;return n>-1?o[n]:e},fl=()=>(0,ml.useSelector)(Pm),{commitSuggestion:De,offeredTextSuggestion:hl,registerCut:yl,registerKeyDown:vl,registerKeyUp:xl,registerPaste:Sl,selectNextTextSuggestion:bl,selectPreviousTextSuggestion:wl,selectTextSuggestionByIndex:gr,setInput:fr,setMetrics:Cl,setSelection:hr,setTextSuggestions:Et,resetMetrics:Tl}=gl.actions,El=gl.reducer;var Rn=require("@reduxjs/toolkit");var En=require("@reduxjs/toolkit");function kl(t){try{return Intl.DateTimeFormat(void 0,{timeZone:t}),!0}catch(e){return!1}}var Im={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle"},kn=t=>{var e;return(e=t.info.agentInfo)!=null?e:null},Rl=t=>{var e;return(e=t.info.visitorInfo)!=null?e:null},Pl=t=>{var e;return(e=t.info.customData)!=null?e:null},ro=({info:{visitorInfo:t,agentInfo:e}})=>{var n,o;return{timezone:t!=null&&t.visitorTimeZone&&kl(t.visitorTimeZone)?t.visitorTimeZone:Ga,agentName:(n=e==null?void 0:e.agentNickname)!=null?n:"",visitorName:(o=t==null?void 0:t.visitorName)!=null?o:""}},Lm=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],oo=(0,En.createAsyncThunk)("info/setAgentInfo",(t,e)=>y(void 0,null,function*(){var s,i,l;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=[];if(t.agentId&&t.skipSync!==!0&&r.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let d=Lm.reduce((a,[c,u])=>!o[u]&&c in t?S(g({},a),{[u]:t[c]}):a,{});Object.keys(d).length>0&&r.push(n.patchMe(d).then(a=>o=a))}return r.length>0&&(yield Promise.all(r)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(s=o.nickname)!=null?s:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(l=o.defaultLocale)!=null?l:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),qs=(0,En.createAsyncThunk)("info/setAgentSettings",(t,e)=>y(void 0,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=g(g({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:r}),r})),$s=(0,En.createAsyncThunk)("info/getAgentSettings",(t,e)=>y(void 0,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),Il=(0,En.createSlice)({name:"info",initialState:Im,reducers:{setVisitorInfo(t,e){t.visitorInfo=g(g({},t.visitorInfo),e.payload)},setCustomData(t,e){t.customData=e.payload},setPlatformVariables(t,e){t.platformVariables=e.payload}},extraReducers:t=>{t.addCase(oo.pending,(e,n)=>{e.fetchState="loading",e.agentInfo=g(g({},e.agentInfo),n.meta.arg)}).addCase(oo.rejected,e=>{e.fetchState="error"}).addCase(oo.fulfilled,(e,n)=>{e.fetchState="done",e.agentInfo=n.payload}).addCase(qs.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase($s.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(Z,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Ll,setCustomData:Al,setPlatformVariables:Ml}=Il.actions,Nl=Il.reducer;function xe(t,e){return Object.entries(e).reduce((n,[o,r])=>n.replaceAll(o,r),t)}var yr={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},Ol=t=>t.search.isOpen,Dl=t=>t.search.page,Gs=t=>t.search.list,_l=t=>t.search.aggregates,Am=(0,Rn.createSelector)([Gs,(t,e)=>e],(t,e)=>t.filter(n=>n.type===e)),Fl=t=>e=>Am(e,t),Wt=(0,Rn.createAsyncThunk)("search/getAll",(t,e)=>y(void 0,null,function*(){var d;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=(d=o.conversation.current)==null?void 0:d.profileCode,{platformVariables:s}=o.info;if(!r)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:l}=yield n.search({profile:r,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:ro(o)});return{results:i.map(a=>S(g(g({},a),a.title&&s?{title:xe(a.title,s)}:{}),{text:xe(a.text,s!=null?s:{}),source:`search-${a.type.toLowerCase()}`,searchTerm:t.query})),aggregates:l}})),Hl=(0,Rn.createSlice)({name:"search",initialState:yr,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=yr.fetchState,t.list=yr.list}},extraReducers:t=>{t.addCase(Wt.pending,e=>{e.fetchState="loading"}).addCase(Wt.rejected,(e,n)=>{e.fetchState="error",T.error(n.error)}).addCase(Wt.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload.results,e.aggregates=n.payload.aggregates||{}}).addCase(Z,()=>yr)}}),{resetSearch:vr,setIsOpen:Re,setPage:rt}=Hl.actions,Kl=Hl.reducer;var Xs="SetOutputs",Pn="ShowLoginOverlay",so="UserLoggedIn",Mm="UserLoggedOut",qe="ApplySuggestion",Zs="ApplyImageSuggestion",Nm="ShowCommandPalette",Om=t=>({[Xs]:e=>{t.dispatch(S(g({},e),{isBroadcasted:!0}))},[Nm]:e=>{t.dispatch(Re(e.isOpen)),e.page&&t.dispatch(rt(e.page))},[Pn]:e=>{t.dispatch(rl(e))},[so]:()=>{t.dispatch(nt())},[Mm]:()=>{t.dispatch(nt())},[Zs]:e=>{t.dispatch(mr({suggestion:e.suggestion}))},[qe]:e=>{t.dispatch(De(S(g({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),Bl=Om;var io=M(require("react")),Vl=require("react/jsx-runtime"),Ul=io.default.createContext(null),kt=({broadcastEvents:t,children:e})=>{let n=io.default.useMemo(()=>t,[]);return(0,Vl.jsx)(Ul.Provider,{value:n,children:e})},Se=()=>{let t=(0,io.useContext)(Ul);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var Ir=M(require("classnames")),_e=require("react"),Lr=require("react-redux");var kr=require("react");var Qs=function(t,e){return Qs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])},Qs(t,e)};function ao(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Qs(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var we=function(){return we=Object.assign||function(e){for(var n,o=1,r=arguments.length;o<r;o++){n=arguments[o];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},we.apply(this,arguments)};function zl(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 r=0,o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]]);return n}function xr(t,e,n){if(n||arguments.length===2)for(var o=0,r=e.length,s;o<r;o++)(s||!(o in e))&&(s||(s=Array.prototype.slice.call(e,0,o)),s[o]=e[o]);return t.concat(s||Array.prototype.slice.call(e))}function Sr(t,e){var n=e&&e.cache?e.cache:Um,o=e&&e.serializer?e.serializer:Km,r=e&&e.strategy?e.strategy:_m;return r(t,{cache:n,serializer:o})}function Dm(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Wl(t,e,n,o){var r=Dm(o)?o:n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.call(this,o),e.set(r,s)),s}function jl(t,e,n){var o=Array.prototype.slice.call(arguments,3),r=n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.apply(this,o),e.set(r,s)),s}function Js(t,e,n,o,r){return n.bind(e,t,o,r)}function _m(t,e){var n=t.length===1?Wl:jl;return Js(t,this,n,e.cache.create(),e.serializer)}function Fm(t,e){return Js(t,this,jl,e.cache.create(),e.serializer)}function Hm(t,e){return Js(t,this,Wl,e.cache.create(),e.serializer)}var Km=function(){return JSON.stringify(arguments)},Bm=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}(),Um={create:function(){return new Bm}},br={variadic:Fm,monadic:Hm};var wr;(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"})(wr||(wr={}));var Cr=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Pe;(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"})(Pe||(Pe={}));var Tr;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Tr||(Tr={}));function Ys(t){return t.type===Pe.literal}function ei(t){return t.type===Pe.argument}function lo(t){return t.type===Pe.number}function co(t){return t.type===Pe.date}function po(t){return t.type===Pe.time}function uo(t){return t.type===Pe.select}function mo(t){return t.type===Pe.plural}function ql(t){return t.type===Pe.pound}function go(t){return t.type===Pe.tag}function Er(t){return!!(t&&typeof t=="object"&&t.type===Tr.number)}function fo(t){return!!(t&&typeof t=="object"&&t.type===Tr.dateTime)}function ti(t){t.forEach(function(e){if(delete e.location,uo(e)||mo(e))for(var n in e.options)delete e.options[n].location,ti(e.options[n].value);else lo(e)&&Er(e.style)||(co(e)||po(e))&&fo(e.style)?delete e.style.location:go(e)&&ti(e.children)})}function $l(t,e){e===void 0&&(e={}),e=we({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new Cr(t,e).parse();if(n.err){var o=SyntaxError(wr[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||ti(n.val),n.val}var jt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(jt||(jt={}));var ho=function(t){ao(e,t);function e(n,o,r){var s=t.call(this,n)||this;return s.code=o,s.originalMessage=r,s}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var ni=function(t){ao(e,t);function e(n,o,r,s){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(r).join('", "'),'"'),jt.INVALID_VALUE,s)||this}return e}(ho);var Gl=function(t){ao(e,t);function e(n,o,r){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),jt.INVALID_VALUE,r)||this}return e}(ho);var Xl=function(t){ao(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,'"'),jt.MISSING_VALUE,o)||this}return e}(ho);var se;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(se||(se={}));function Vm(t){return t.length<2?t:t.reduce(function(e,n){var o=e[e.length-1];return!o||o.type!==se.literal||n.type!==se.literal?e.push(n):o.value+=n.value,e},[])}function zm(t){return typeof t=="function"}function yo(t,e,n,o,r,s,i){if(t.length===1&&Ys(t[0]))return[{type:se.literal,value:t[0].value}];for(var l=[],d=0,a=t;d<a.length;d++){var c=a[d];if(Ys(c)){l.push({type:se.literal,value:c.value});continue}if(ql(c)){typeof s=="number"&&l.push({type:se.literal,value:n.getNumberFormat(e).format(s)});continue}var u=c.value;if(!(r&&u in r))throw new Xl(u,i);var p=r[u];if(ei(c)){(!p||typeof p=="string"||typeof p=="number")&&(p=typeof p=="string"||typeof p=="number"?String(p):""),l.push({type:typeof p=="string"?se.literal:se.object,value:p});continue}if(co(c)){var m=typeof c.style=="string"?o.date[c.style]:fo(c.style)?c.style.parsedOptions:void 0;l.push({type:se.literal,value:n.getDateTimeFormat(e,m).format(p)});continue}if(po(c)){var m=typeof c.style=="string"?o.time[c.style]:fo(c.style)?c.style.parsedOptions:o.time.medium;l.push({type:se.literal,value:n.getDateTimeFormat(e,m).format(p)});continue}if(lo(c)){var m=typeof c.style=="string"?o.number[c.style]:Er(c.style)?c.style.parsedOptions:void 0;m&&m.scale&&(p=p*(m.scale||1)),l.push({type:se.literal,value:n.getNumberFormat(e,m).format(p)});continue}if(go(c)){var f=c.children,h=c.value,v=r[h];if(!zm(v))throw new Gl(h,"function",i);var w=yo(f,e,n,o,r,s),E=v(w.map(function(N){return N.value}));Array.isArray(E)||(E=[E]),l.push.apply(l,E.map(function(N){return{type:typeof N=="string"?se.literal:se.object,value:N}}))}if(uo(c)){var b=c.options[p]||c.options.other;if(!b)throw new ni(c.value,p,Object.keys(c.options),i);l.push.apply(l,yo(b.value,e,n,o,r));continue}if(mo(c)){var b=c.options["=".concat(p)];if(!b){if(!Intl.PluralRules)throw new ho(`Intl.PluralRules is not available in this environment.
1
+ "use strict";var Gu=Object.create;var Jn=Object.defineProperty,Xu=Object.defineProperties,Zu=Object.getOwnPropertyDescriptor,Qu=Object.getOwnPropertyDescriptors,Ju=Object.getOwnPropertyNames,Jo=Object.getOwnPropertySymbols,Yu=Object.getPrototypeOf,Ks=Object.prototype.hasOwnProperty,ba=Object.prototype.propertyIsEnumerable;var xa=(t,e,n)=>e in t?Jn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,g=(t,e)=>{for(var n in e||(e={}))Ks.call(e,n)&&xa(t,n,e[n]);if(Jo)for(var n of Jo(e))ba.call(e,n)&&xa(t,n,e[n]);return t},x=(t,e)=>Xu(t,Qu(e));var A=(t,e)=>{var n={};for(var o in t)Ks.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&Jo)for(var o of Jo(t))e.indexOf(o)<0&&ba.call(t,o)&&(n[o]=t[o]);return n};var re=(t,e)=>{for(var n in e)Jn(t,n,{get:e[n],enumerable:!0})},wa=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ju(e))!Ks.call(t,r)&&r!==n&&Jn(t,r,{get:()=>e[r],enumerable:!(o=Zu(e,r))||o.enumerable});return t};var M=(t,e,n)=>(n=t!=null?Gu(Yu(t)):{},wa(e||!t||!t.__esModule?Jn(n,"default",{value:t,enumerable:!0}):n,t)),em=t=>wa(Jn({},"__esModule",{value:!0}),t);var v=(t,e,n)=>new Promise((o,r)=>{var s=d=>{try{a(n.next(d))}catch(l){r(l)}},i=d=>{try{a(n.throw(d))}catch(l){r(l)}},a=d=>d.done?o(d.value):Promise.resolve(d.value).then(s,i);a((n=n.apply(t,e)).next())});var Hh={};re(Hh,{Card:()=>K,ContentEditableInput:()=>pn,DeepdeskAPI:()=>xt,DeepdeskSDK:()=>Zo,HTTPClient:()=>mn,InputMediator:()=>St,InputType:()=>Sn,KeyboardHint:()=>or,Label:()=>La,Locale:()=>eo,Section:()=>We,SectionList:()=>yn,Sources:()=>tt,Suggestion:()=>F,SuggestionList:()=>ve,TextAreaInput:()=>un,ToggleButton:()=>Bt,attachFile:()=>Hu,authenticateWithKey:()=>Ku,createFullRange:()=>$n,createOverlayContainer:()=>Xo,createRangeFromOffsets:()=>Dt,escapeHTML:()=>An,formatTextMarkup:()=>Bu,getRangeOffsets:()=>$o,getRangeText:()=>Go,insertCKEditor:()=>Wu,isHTML:()=>_r,isSupportedInputElement:()=>Os,updateContentEditable:()=>Vu,updateTextArea:()=>Uu,useClickOutsideRoot:()=>It,useStyles:()=>S,waitForElementVisibilityChange:()=>Fs});module.exports=em(Hh);var Us=M(require("classnames")),ke=M(require("react"));var Yo=M(require("react")),Ca=M(require("classnames"));var Yn=Yo.default.createContext({});function S(t,e){let s=(0,Yo.useContext)(Yn),{debug:n}=s,r=A(s,["debug"])[t];return Object.entries(e).reduce((i,[a,d])=>{let l=r==null?void 0:r[a];return x(g({},i),{[a]:(0,Ca.default)(d,l,n?`${t}__${a}`:!1)})},{})}var Ta={root:"dd-4s9wq"};var Ht=require("react/jsx-runtime"),er=()=>(0,Ht.jsxs)("svg",{className:Ta.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Ht.jsx)("defs",{children:(0,Ht.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Ht.jsx)("title",{children:"Failed loading image"}),(0,Ht.jsx)("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 Bs={root:"dd-c9KvZ",imageWrapper:"dd-sE7D9",image:"dd-bEGMz",content:"dd-oFIQa",title:"dd-mSgoo",contentIsCropped:"dd-Uvjv4",lineClamp:"dd-ApQo-"};var Kt=require("react/jsx-runtime"),tr=(0,ke.createContext)(Bs),tm=({title:t,src:e})=>{let n=(0,ke.useContext)(tr),[o,r]=(0,ke.useState)(!1);return(0,ke.useEffect)(()=>{r(!1)},[e]),(0,Kt.jsx)("div",{className:n.imageWrapper,children:e&&!o?(0,Kt.jsx)("img",{className:n.image,alt:t,src:e,onError:()=>r(!0)}):(0,Kt.jsx)(er,{})})},nm=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let r=(0,ke.useContext)(tr);return(0,Kt.jsx)("div",{className:(0,Us.default)(r.content,t,{[r.contentIsCropped]:n,[r.lineClamp]:e}),children:o})},om=s=>{var i=s,{as:t="h1",cropText:e=!1,className:n,children:o}=i,r=A(i,["as","cropText","className","children"]);let a=(0,ke.useContext)(tr);return ke.default.createElement(t,g({className:(0,Us.default)(a.title,n,{[a.contentIsCropped]:e})},r),o)},nr=({children:t})=>{let e=S("Card",Bs);return(0,Kt.jsx)("div",{className:e.root,children:(0,Kt.jsx)(tr.Provider,{value:e,children:t})})};nr.Image=tm;nr.Content=nm;nr.Title=om;var K=nr;var ka=M(require("classnames"));var Ea={root:"dd-llBx9"};var Ra=require("react/jsx-runtime");var rm={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},sm=o=>{var r=o,{className:t,keyCode:e}=r,n=A(r,["className","keyCode"]);let s=S("KeyboardHint",Ea);return(0,Ra.jsx)("span",g({"data-key":rm[e],className:(0,ka.default)(t,s.root)},n))},or=sm;var Ia=M(require("classnames"));var Pa={root:"dd-e6HXZ"};var Aa=require("react/jsx-runtime"),im=o=>{var r=o,{className:t,children:e}=r,n=A(r,["className","children"]);let s=S("Label",Pa);return(0,Aa.jsx)("span",x(g({},n),{className:(0,Ia.default)(t,s.root),children:e}))},La=im;var Ma={root:"dd-FiMI7",subTitleContainer:"dd-98jc7",subtitle:"dd-3MnW8",suggestions:"dd-0SGL8"};var hn=require("react/jsx-runtime"),am=r=>{var s=r,{title:t,children:e,type:n}=s,o=A(s,["title","children","type"]);let i=S("Section",Ma);return(0,hn.jsxs)("section",x(g({},o),{className:i.root,"data-section-type":n,children:[t&&(0,hn.jsx)("div",{className:i.subTitleContainer,children:(0,hn.jsx)("span",{className:i.subtitle,children:t})}),(0,hn.jsx)("div",{className:i.suggestions,children:e})]}))},We=am;var Ha=M(require("classnames")),Ka=require("react");var bt=require("react"),_a=require("react/jsx-runtime"),Na=(0,bt.createContext)(null),Oa=({scrollContainerRef:t,children:e})=>{let n=(0,bt.useCallback)(o=>{let r=t.current;if(!r||r.scrollHeight<=r.clientHeight)return;let{top:s}=r.getBoundingClientRect(),{top:i}=o.getBoundingClientRect();r.scrollTo({top:i-s})},[]);return(0,_a.jsx)(Na.Provider,{value:n,children:e})},Da=t=>{let e=(0,bt.useContext)(Na);(0,bt.useEffect)(()=>{let n=t.current;n&&e(n)},[])};var Fa={root:"dd-uoTXh"};var Vs=require("react/jsx-runtime"),lm=({className:t,children:e})=>{let n=S("SectionList",Fa),o=(0,Ka.useRef)(null);return(0,Vs.jsx)(Oa,{scrollContainerRef:o,children:(0,Vs.jsx)("div",{ref:o,className:(0,Ha.default)(n.root,t),children:e})})},yn=lm;var vn=M(require("classnames")),ye=M(require("react"));var zs={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",buttonWithIcon:"dd-MQVt5",buttonDisabled:"dd-agTuH"};var he=require("react/jsx-runtime"),wt=(0,ye.createContext)(zs),dm=o=>{var r=o,{fixed:t,children:e}=r,n=A(r,["fixed","children"]);let s=(0,ye.useContext)(wt);return(0,he.jsx)("div",x(g({},n),{className:(0,vn.default)(s.actions,{[s.actionsIsFixed]:t}),children:e}))};function cm(a){var d=a,{as:t,className:e,icon:n,title:o,children:r,disabled:s}=d,i=A(d,["as","className","icon","title","children","disabled"]);let l=(0,ye.useContext)(wt);return(0,he.jsxs)(t||"button",x(g({type:"button",className:(0,vn.default)(l.button,{[l.buttonWithIcon]:n,[l.buttonDisabled]:s},e),title:o,"aria-label":o},i),{children:[n,r]}))}var pm=({children:t})=>{let e=(0,ye.useContext)(wt);return(0,he.jsx)("div",{className:e.buttonsContainer,children:t})},um=({className:t,primary:e,disabled:n,label:o,children:r})=>{let s=(0,ye.useContext)(wt);return(0,he.jsxs)("div",{className:(0,vn.default)(t,s.actionButton,s.dropdownButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,(0,he.jsx)("ul",{className:s.dropdownList,children:r})]})},mm=({index:t,label:e,onClick:n})=>{let o=(0,ye.useContext)(wt);return(0,he.jsx)("li",{className:o.dropdownItem,children:(0,he.jsx)("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},gm=({className:t,primary:e,disabled:n,onClick:o,label:r})=>{let s=(0,ye.useContext)(wt);return(0,he.jsx)("button",{type:"button",className:(0,vn.default)(t,s.actionButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onClick:o!=null?o:i=>i.stopPropagation(),disabled:n,"aria-hidden":n,children:r})},fm=({labels:t})=>{let e=(0,ye.useContext)(wt);return(0,he.jsx)("div",{className:e.labels,children:t.map(n=>(0,he.jsx)("span",{className:e.label,children:n},n))})},Ct=ye.default.forwardRef((a,i)=>{var d=a,{className:t,selected:e,onClick:n,children:o,as:r="div"}=d,s=A(d,["className","selected","onClick","children","as"]);let l=S("Suggestion",zs),c=(0,ye.useCallback)(u=>{u.preventDefault(),n&&n(u)},[n]);return(0,he.jsx)(r,x(g({},s),{ref:i,className:(0,vn.default)(t,l.root,{[l.isSelected]:e,[l.isClickable]:!!n}),onClick:c,children:(0,he.jsx)(wt.Provider,{value:l,children:o})}))});Ct.Labels=fm;Ct.Actions=dm;Ct.ActionButton=gm;Ct.DropdownButton=um;Ct.DropdownItem=mm;Ct.ButtonsContainer=pm;Ct.Button=cm;var F=Ct;var Ua=M(require("classnames"));var Ba={root:"dd-W35K-",isWithDivider:"dd-sscOy"};var Va=require("react/jsx-runtime"),hm=({withDivider:t,children:e})=>{let n=S("SuggestionList",Ba);return(0,Va.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Ua.default)(n.root,{[n.isWithDivider]:t}),children:e})},ve=hm;var Wa=M(require("classnames"));var za={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};var rr=require("react/jsx-runtime"),ym=({className:t,isCollapsed:e,title:n,onClick:o})=>{let r=S("ToggleButton",za);return(0,rr.jsx)("button",{type:"button",className:(0,Wa.default)(r.root,t,{[r.isCollapsed]:e}),onClick:o,title:n,children:(0,rr.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,rr.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Bt=ym;var qa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,sr=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ja=/x-deepdesk-(([a-z0-9\-_])+-version)/,ir=["cues","custom-data","knowledge-assist"],$a=Intl.DateTimeFormat().resolvedOptions().timeZone,tt=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(tt||{}),Sn=(i=>(i.ENTER="enter",i.TAB="tab",i.ARROW="arrow",i.HOTKEY="hotkey",i.MOUSE="mouse",i.SPACE="space",i))(Sn||{});var Y=require("react-dom");var hc=require("react");var Ga=require("@reduxjs/toolkit"),Xa=require("react-redux");var eo=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(eo||{});var vm={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,inlineSuggestions:!1,floatingMenu:!1,detectSubmit:!1,automaticHandlingTime:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!1,adminUrl:void 0,productName:"Deepdesk",hasKeyboardInput:!0},Za=(0,Ga.createSlice)({name:"settings",initialState:vm,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,r]=n;typeof r!="undefined"&&(t[o]=r)})}}}),{set:ar}=Za.actions,to=t=>e=>e.settings[t],C=t=>(0,Xa.useSelector)(to(t)),Qa=Za.reducer;var di=require("react-redux");var xn=require("@reduxjs/toolkit");var Sm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},de=t=>t.auth.isLoggedIn,Ja=t=>t.auth.loginFetchState,Ya=t=>t.auth.verifyFetchState,el=t=>t.auth.showLoginOverlay,nt=(0,xn.createAsyncThunk)("auth/validate",(t,e)=>v(void 0,null,function*(){return e.extra.deepdeskAPI.isLoggedIn()})),tl=(0,xn.createAsyncThunk)("auth/requestLogin",(n,o)=>v(void 0,[n,o],function*({email:t},e){let{deepdeskAPI:r}=e.extra;return r.requestLoginByEmail(t)})),no=(0,xn.createAsyncThunk)("auth/verifyLoginToken",(n,o)=>v(void 0,[n,o],function*({token:t},e){let{deepdeskAPI:r}=e.extra;return r.verifyLoginToken(t)})),nl=(0,xn.createSlice)({name:"auth",initialState:Sm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(nt.pending,e=>{e.loginFetchState="loading"}),t.addCase(nt.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(nt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(no.pending,e=>{e.verifyFetchState="loading"}),t.addCase(no.rejected,e=>{e.verifyFetchState="error"}),t.addCase(no.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:bn,setShowLoginOverlay:ol}=nl.actions,rl=nl.reducer;var Vt=require("@reduxjs/toolkit"),pl=require("diff"),ul=require("react-redux");function sl(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Tt(t,e,n=10){let o=typeof t,r=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==r?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((s,i)=>Tt(s,e[i],n-1)):sl(t)&&sl(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Tt(t[i],e[i],n-1)):!1}function xm(t){return Math.max(...t.map(e=>e.length))}function bm(t,e){let n=t.reduce((o,r)=>{if(r){let s=o[r]?o[r]+1:1;return x(g({},o),{[r]:s})}return o},{});return Object.keys(n).reduce((o,r)=>(n[r]<e&&o.push(r),o),[])}function il(t,e){let o=[...t.map(({text:r})=>r.split(/\b(\w+)\b/))];for(let r=0;r<xm(o);r++){let s=bm(o.map(a=>a[r]),e),i=o.filter(a=>!s.includes(a[r]));if(i.length>=e)o=i;else return{text:o[0].slice(0,r).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var wm=2;function al(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=il(t,wm);return n&&n.text!==e?n:t[0]}var Oe=require("@reduxjs/toolkit");var Cm={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},T=Cm;var ll={current:null,isSupported:null},Z=(0,Oe.createAction)("resetConversation"),dl=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.externalId)||null},qe=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},wn=t=>t.conversation.isSupported,Ws=(0,Oe.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),lr=(0,Oe.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),dr=(0,Oe.createAsyncThunk)("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),cr=(0,Oe.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=qe(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),qs=(0,Oe.createAsyncThunk)("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:r,agentName:s,agentEmail:i,agentNickname:a,metadata:d}=t;return n.updateConversation(o.id,{agentId:r,agentEmail:i,agentName:s,agentNickname:a,metadata:d})})}),pr=(0,Oe.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=qe(e.getState());if(!o)throw new Error("No current conversation to update messages");return n.postMessages(o,t.map(r=>g({},r)))}),Tm=[lr.rejected,dr.rejected,cr.rejected,pr.rejected].map(t=>t==null?void 0:t.toString()),Em=(0,Oe.createSlice)({name:"conversation",initialState:ll,reducers:{},extraReducers:t=>{t.addCase(Ws.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(lr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(dr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(qs.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(cr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(pr.fulfilled,(e,n)=>{e.current&&(e.current.messages=n.payload)}).addCase(Z,()=>ll).addMatcher(e=>Tm.includes(e.type),(e,n)=>{var o;throw T.info("Conversation action rejected",n.type,((o=n.error)==null?void 0:o.message)||"No message"),new Error(n.error.message)})}}),cl=Em.reducer;var Ut={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function js(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}}var ur=(0,Vt.createAction)("input/replaceText"),zt=(0,Vt.createAction)("input/sendMessage"),mr=(0,Vt.createAction)("input/applyImageSuggestion"),ot=(0,Vt.createAction)("input/sendEvent"),ml=(0,Vt.createSlice)({name:"input",initialState:Ut,reducers:{setInput(t,e){var s,i;let{beforeInputChange:n}=t,{text:o,html:r}=e.payload;if(t.text=o,t.html=r!=null?r:null,o==="")t.metrics=Ut.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,m=(0,pl.diffChars)(n.text,p);n.text.length-p.length>1&&t.metrics.deletions.push(...m.filter(h=>h.removed).map(h=>h.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=((s=n.selection)==null?void 0:s.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},setSelection(t,e){e.payload!==null&&(Tt(t.selection,e.payload)||(t.selection=e.payload))},commitSuggestion(t,e){let n=e.payload,{text:o,suggestion:{source:r,abVariant:s,abTestName:i,trainingJobs:a,sourceText:d,searchTerm:l,text:c},eventMetrics:{inputType:u},replace:p}=n,m=r==="search"||r==="personal-collection-search",h=o.slice(t.text.substring(0,t.selection.start).length);(m||p==="selection")&&(h=o),n.suggestion.source==="search-overlay"&&(h=c),t.metrics.textSuggestions.push({text:h,source:r,abVariant:s,abTestName:i,inputType:u,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(s=>s.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=x(g({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:r}=e.payload,s=n.numCharsDeleted+(r!=null&&r.length?r.length:0),i=r!=null&&r.length?[...n.deletions,r]:n.deletions;t.metrics=x(g({},t.metrics),{numCharsDeleted:s,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.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=al(e.payload,n);t.mixedSuggestion=o!=null&&o.text.includes(n)?o:null},setMetrics(t,{payload:e}){t.metrics=e},resetMetrics(t){t.metrics=Ut.metrics}},extraReducers:t=>{t.addCase(Z,e=>{e.mixedSuggestion=Ut.mixedSuggestion,e.textSuggestions=Ut.textSuggestions,e.selectedSuggestionIndex=Ut.selectedSuggestionIndex,e.metrics=Ut.metrics})}}),Cn=t=>t.input.text.substring(0,t.input.selection.end),km=t=>t.input.selection,Tn=t=>{let{mixedSuggestion:e,selectedSuggestionIndex:n,textSuggestions:o}=t.input;return n>-1?o[n]:e},gl=()=>(0,ul.useSelector)(km),{commitSuggestion:De,offeredTextSuggestion:fl,registerCut:hl,registerKeyDown:yl,registerKeyUp:vl,registerPaste:Sl,selectNextTextSuggestion:xl,selectPreviousTextSuggestion:bl,selectTextSuggestionByIndex:gr,setInput:fr,setMetrics:wl,setSelection:hr,setTextSuggestions:Et,resetMetrics:Cl}=ml.actions,Tl=ml.reducer;var Rn=require("@reduxjs/toolkit");var En=require("@reduxjs/toolkit");function El(t){try{return Intl.DateTimeFormat(void 0,{timeZone:t}),!0}catch(e){return!1}}var Rm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle"},kn=t=>{var e;return(e=t.info.agentInfo)!=null?e:null},kl=t=>{var e;return(e=t.info.visitorInfo)!=null?e:null},Rl=t=>{var e;return(e=t.info.customData)!=null?e:null},ro=({info:{visitorInfo:t,agentInfo:e}})=>{var n,o;return{timezone:t!=null&&t.visitorTimeZone&&El(t.visitorTimeZone)?t.visitorTimeZone:$a,agentName:(n=e==null?void 0:e.agentNickname)!=null?n:"",visitorName:(o=t==null?void 0:t.visitorName)!=null?o:""}},Pm=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],oo=(0,En.createAsyncThunk)("info/setAgentInfo",(t,e)=>v(void 0,null,function*(){var s,i,a;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=[];if(t.agentId&&t.skipSync!==!0&&r.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let d=Pm.reduce((l,[c,u])=>!o[u]&&c in t?x(g({},l),{[u]:t[c]}):l,{});Object.keys(d).length>0&&r.push(n.patchMe(d).then(l=>o=l))}return r.length>0&&(yield Promise.all(r)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(s=o.nickname)!=null?s:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(a=o.defaultLocale)!=null?a:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),$s=(0,En.createAsyncThunk)("info/setAgentSettings",(t,e)=>v(void 0,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=g(g({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:r}),r})),Gs=(0,En.createAsyncThunk)("info/getAgentSettings",(t,e)=>v(void 0,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),Pl=(0,En.createSlice)({name:"info",initialState:Rm,reducers:{setVisitorInfo(t,e){t.visitorInfo=g(g({},t.visitorInfo),e.payload)},setCustomData(t,e){t.customData=e.payload},setPlatformVariables(t,e){t.platformVariables=e.payload}},extraReducers:t=>{t.addCase(oo.pending,(e,n)=>{e.fetchState="loading",e.agentInfo=g(g({},e.agentInfo),n.meta.arg)}).addCase(oo.rejected,e=>{e.fetchState="error"}).addCase(oo.fulfilled,(e,n)=>{e.fetchState="done",e.agentInfo=n.payload}).addCase($s.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(Gs.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(Z,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Il,setCustomData:Ll,setPlatformVariables:Al}=Pl.actions,Ml=Pl.reducer;function Se(t,e){return Object.entries(e).reduce((n,[o,r])=>n.replaceAll(o,r),t)}var yr={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},Nl=t=>t.search.isOpen,Ol=t=>t.search.page,Xs=t=>t.search.list,Dl=t=>t.search.aggregates,Im=(0,Rn.createSelector)([Xs,(t,e)=>e],(t,e)=>t.filter(n=>n.type===e)),_l=t=>e=>Im(e,t),Wt=(0,Rn.createAsyncThunk)("search/getAll",(t,e)=>v(void 0,null,function*(){var d;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=(d=o.conversation.current)==null?void 0:d.profileCode,{platformVariables:s}=o.info;if(!r)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:r,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:ro(o)});return{results:i.map(l=>x(g(g({},l),l.title&&s?{title:Se(l.title,s)}:{}),{text:Se(l.text,s!=null?s:{}),source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:a}})),Fl=(0,Rn.createSlice)({name:"search",initialState:yr,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=yr.fetchState,t.list=yr.list}},extraReducers:t=>{t.addCase(Wt.pending,e=>{e.fetchState="loading"}).addCase(Wt.rejected,(e,n)=>{e.fetchState="error",T.error(n.error)}).addCase(Wt.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload.results,e.aggregates=n.payload.aggregates||{}}).addCase(Z,()=>yr)}}),{resetSearch:vr,setIsOpen:Re,setPage:rt}=Fl.actions,Hl=Fl.reducer;var Zs="SetOutputs",Pn="ShowLoginOverlay",so="UserLoggedIn",Lm="UserLoggedOut",je="ApplySuggestion",Qs="ApplyImageSuggestion",Am="ShowCommandPalette",Mm=t=>({[Zs]:e=>{t.dispatch(x(g({},e),{isBroadcasted:!0}))},[Am]:e=>{t.dispatch(Re(e.isOpen)),e.page&&t.dispatch(rt(e.page))},[Pn]:e=>{t.dispatch(ol(e))},[so]:()=>{t.dispatch(nt())},[Lm]:()=>{t.dispatch(nt())},[Qs]:e=>{t.dispatch(mr({suggestion:e.suggestion}))},[je]:e=>{t.dispatch(De(x(g({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),Kl=Mm;var io=M(require("react")),Ul=require("react/jsx-runtime"),Bl=io.default.createContext(null),kt=({broadcastEvents:t,children:e})=>{let n=io.default.useMemo(()=>t,[]);return(0,Ul.jsx)(Bl.Provider,{value:n,children:e})},xe=()=>{let t=(0,io.useContext)(Bl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var Ir=M(require("classnames")),_e=require("react"),Lr=require("react-redux");var kr=require("react");var Js=function(t,e){return Js=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])},Js(t,e)};function ao(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Js(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var we=function(){return we=Object.assign||function(e){for(var n,o=1,r=arguments.length;o<r;o++){n=arguments[o];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},we.apply(this,arguments)};function Vl(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 r=0,o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]]);return n}function Sr(t,e,n){if(n||arguments.length===2)for(var o=0,r=e.length,s;o<r;o++)(s||!(o in e))&&(s||(s=Array.prototype.slice.call(e,0,o)),s[o]=e[o]);return t.concat(s||Array.prototype.slice.call(e))}function xr(t,e){var n=e&&e.cache?e.cache:Km,o=e&&e.serializer?e.serializer:Fm,r=e&&e.strategy?e.strategy:Om;return r(t,{cache:n,serializer:o})}function Nm(t){return t==null||typeof t=="number"||typeof t=="boolean"}function zl(t,e,n,o){var r=Nm(o)?o:n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.call(this,o),e.set(r,s)),s}function Wl(t,e,n){var o=Array.prototype.slice.call(arguments,3),r=n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.apply(this,o),e.set(r,s)),s}function Ys(t,e,n,o,r){return n.bind(e,t,o,r)}function Om(t,e){var n=t.length===1?zl:Wl;return Ys(t,this,n,e.cache.create(),e.serializer)}function Dm(t,e){return Ys(t,this,Wl,e.cache.create(),e.serializer)}function _m(t,e){return Ys(t,this,zl,e.cache.create(),e.serializer)}var Fm=function(){return JSON.stringify(arguments)},Hm=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}(),Km={create:function(){return new Hm}},br={variadic:Dm,monadic:_m};var wr;(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"})(wr||(wr={}));var Cr=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Pe;(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"})(Pe||(Pe={}));var Tr;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Tr||(Tr={}));function ei(t){return t.type===Pe.literal}function ti(t){return t.type===Pe.argument}function lo(t){return t.type===Pe.number}function co(t){return t.type===Pe.date}function po(t){return t.type===Pe.time}function uo(t){return t.type===Pe.select}function mo(t){return t.type===Pe.plural}function ql(t){return t.type===Pe.pound}function go(t){return t.type===Pe.tag}function Er(t){return!!(t&&typeof t=="object"&&t.type===Tr.number)}function fo(t){return!!(t&&typeof t=="object"&&t.type===Tr.dateTime)}function ni(t){t.forEach(function(e){if(delete e.location,uo(e)||mo(e))for(var n in e.options)delete e.options[n].location,ni(e.options[n].value);else lo(e)&&Er(e.style)||(co(e)||po(e))&&fo(e.style)?delete e.style.location:go(e)&&ni(e.children)})}function jl(t,e){e===void 0&&(e={}),e=we({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new Cr(t,e).parse();if(n.err){var o=SyntaxError(wr[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||ni(n.val),n.val}var qt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(qt||(qt={}));var ho=function(t){ao(e,t);function e(n,o,r){var s=t.call(this,n)||this;return s.code=o,s.originalMessage=r,s}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var oi=function(t){ao(e,t);function e(n,o,r,s){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(r).join('", "'),'"'),qt.INVALID_VALUE,s)||this}return e}(ho);var $l=function(t){ao(e,t);function e(n,o,r){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),qt.INVALID_VALUE,r)||this}return e}(ho);var Gl=function(t){ao(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,'"'),qt.MISSING_VALUE,o)||this}return e}(ho);var se;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(se||(se={}));function Bm(t){return t.length<2?t:t.reduce(function(e,n){var o=e[e.length-1];return!o||o.type!==se.literal||n.type!==se.literal?e.push(n):o.value+=n.value,e},[])}function Um(t){return typeof t=="function"}function yo(t,e,n,o,r,s,i){if(t.length===1&&ei(t[0]))return[{type:se.literal,value:t[0].value}];for(var a=[],d=0,l=t;d<l.length;d++){var c=l[d];if(ei(c)){a.push({type:se.literal,value:c.value});continue}if(ql(c)){typeof s=="number"&&a.push({type:se.literal,value:n.getNumberFormat(e).format(s)});continue}var u=c.value;if(!(r&&u in r))throw new Gl(u,i);var p=r[u];if(ti(c)){(!p||typeof p=="string"||typeof p=="number")&&(p=typeof p=="string"||typeof p=="number"?String(p):""),a.push({type:typeof p=="string"?se.literal:se.object,value:p});continue}if(co(c)){var m=typeof c.style=="string"?o.date[c.style]:fo(c.style)?c.style.parsedOptions:void 0;a.push({type:se.literal,value:n.getDateTimeFormat(e,m).format(p)});continue}if(po(c)){var m=typeof c.style=="string"?o.time[c.style]:fo(c.style)?c.style.parsedOptions:o.time.medium;a.push({type:se.literal,value:n.getDateTimeFormat(e,m).format(p)});continue}if(lo(c)){var m=typeof c.style=="string"?o.number[c.style]:Er(c.style)?c.style.parsedOptions:void 0;m&&m.scale&&(p=p*(m.scale||1)),a.push({type:se.literal,value:n.getNumberFormat(e,m).format(p)});continue}if(go(c)){var h=c.children,f=c.value,y=r[f];if(!Um(y))throw new $l(f,"function",i);var b=yo(h,e,n,o,r,s),E=y(b.map(function(N){return N.value}));Array.isArray(E)||(E=[E]),a.push.apply(a,E.map(function(N){return{type:typeof N=="string"?se.literal:se.object,value:N}}))}if(uo(c)){var w=c.options[p]||c.options.other;if(!w)throw new oi(c.value,p,Object.keys(c.options),i);a.push.apply(a,yo(w.value,e,n,o,r));continue}if(mo(c)){var w=c.options["=".concat(p)];if(!w){if(!Intl.PluralRules)throw new ho(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,jt.MISSING_INTL_API,i);var I=n.getPluralRules(e,{type:c.pluralType}).select(p-(c.offset||0));b=c.options[I]||c.options.other}if(!b)throw new ni(c.value,p,Object.keys(c.options),i);l.push.apply(l,yo(b.value,e,n,o,r,p-(c.offset||0)));continue}}return Vm(l)}function Wm(t,e){return e?we(we(we({},t||{}),e||{}),Object.keys(t).reduce(function(n,o){return n[o]=we(we({},t[o]),e[o]||{}),n},{})):t}function jm(t,e){return e?Object.keys(t).reduce(function(n,o){return n[o]=Wm(t[o],e[o]),n},we({},t)):t}function oi(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,n){t[e]=n}}}}}function qm(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Sr(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,xr([void 0],n,!1)))},{cache:oi(t.number),strategy:br.variadic}),getDateTimeFormat:Sr(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,xr([void 0],n,!1)))},{cache:oi(t.dateTime),strategy:br.variadic}),getPluralRules:Sr(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,xr([void 0],n,!1)))},{cache:oi(t.pluralRules),strategy:br.variadic})}}var ri=function(){function t(e,n,o,r){n===void 0&&(n=t.defaultLocale);var s=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(a){var c=s.formatToParts(a);if(c.length===1)return c[0].value;var u=c.reduce(function(p,m){return!p.length||m.type!==se.literal||typeof p[p.length-1]!="string"?p.push(m.value):p[p.length-1]+=m.value,p},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(a){return yo(s.ast,s.locales,s.formatters,s.formats,a,void 0,s.message)},this.resolvedOptions=function(){var a;return{locale:((a=s.resolvedLocale)===null||a===void 0?void 0:a.toString())||Intl.NumberFormat.supportedLocalesOf(s.locales)[0]}},this.getAst=function(){return s.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=r||{},l=i.formatters,d=zl(i,["formatters"]);this.ast=t.__parse(e,we(we({},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=jm(t.formats,o),this.formatters=r&&r.formatters||qm(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=$l,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 $m(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var Gm="dummy",si=(0,kr.createContext)(null);function k(t){var o;let e=(0,kr.useContext)(si);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(r,s)=>{let i=$m(n,r);return i?new ri(i).format(s):(e!==Gm&&console.warn(`${r} does not exist in messages of ${e}`),`[${r}]`)}}var Rr=require("react");var Zl={root:"dd-tvkOF",content:"dd-eXA1D"};var ii=require("react/jsx-runtime"),Xm=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:r,onKeyDown:s,overlayAriaLabel:i,contentAriaLabel:l})=>{let d=(0,Rr.useRef)(null),a=x("Dialog",Zl),c=p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),r();return}s&&s(p)},u=p=>{p.target===d.current&&t&&o()};return(0,Rr.useEffect)(()=>{var p,m;!d.current||!t||!e||(m=(p=d.current)==null?void 0:p.querySelector("input, textarea"))==null||m.focus()},[t,e,d]),t?(0,ii.jsx)("div",{role:"dialog","data-testid":"dialog",className:a.root,"aria-label":i,ref:d,onKeyDown:c,onMouseDown:u,children:(0,ii.jsx)("div",{"data-testid":"dialog-content",className:a.content,"aria-label":l,children:n})}):null},Pr=Xm;var Jl=M(require("classnames"));var Ql={root:"dd-ranhW"};var Yl=require("react/jsx-runtime"),Zm=o=>{var r=o,{className:t,value:e}=r,n=A(r,["className","value"]);let s=x("TextInput",Ql);return(0,Yl.jsx)("input",g({className:(0,Jl.default)(t,s.root),type:"text",value:e},n))},vo=Zm;var ai={};re(ai,{enUS:()=>Qm,nlNL:()=>Jm});var Qm={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"}]},Jm={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 ed={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"};var X=require("react/jsx-runtime");var Ym=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch(e){return t}},eg=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:r})=>{let s=k(ai),i=x("LoginTokenDialog",ed),l=(0,Lr.useSelector)(el),d=(0,Lr.useDispatch)(),a=C("productName"),[c,u]=(0,_e.useState)(t||""),[p,m]=(0,_e.useState)(0),[f,h]=(0,_e.useState)(""),v=(0,_e.useCallback)(I=>y(void 0,null,function*(){I.preventDefault(),d(nl({email:c})),m(1)}),[n,c]),w=()=>{h(""),m(0)},E=(0,_e.useCallback)(I=>y(void 0,null,function*(){I.preventDefault();let N=Ym(I.target.elements.token.value);if(!N){h(s("verifyCodeError",{login:b}));return}d(no({token:N}))}),[n]),b=(0,_e.useMemo)(()=>I=>(0,X.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:I},"back-button"),[]);return(0,_e.useEffect)(()=>{l==="error"&&h(s("verifyCodeError",{login:b})),l==="done"&&o()},[l]),(0,X.jsx)(Pr,{autoFocus:!0,isOpen:e,contentAriaLabel:s("promptTitle",{productName:a}),overlayAriaLabel:s("promptTitle",{productName:a}),onClose:r,onBack:r,children:(0,X.jsxs)("div",{className:i.root,children:[(0,X.jsx)("h1",{className:i.title,children:s("promptTitle",{productName:a})}),p===0&&(0,X.jsxs)("form",{onSubmit:v,children:[(0,X.jsx)("h2",{className:i.subtitle,children:s("requestCodeTitle")}),(0,X.jsx)("p",{className:i.text,children:s("requestCodeBody",{productName:a})}),(0,X.jsx)(vo,{className:i.input,name:"email",placeholder:s("requestCodeInputPlaceholder"),value:c,onChange:I=>u(I.target.value)}),(0,X.jsx)("div",{className:i.actions,children:(0,X.jsx)("button",{type:"submit",className:(0,Ir.default)(i.button,i.primaryButton),children:s("requestCodeSubmitLabel")})})]}),p===1&&(0,X.jsxs)("form",{onSubmit:E,children:[(0,X.jsx)("h2",{className:i.subtitle,children:s("verifyCodeTitle")}),(0,X.jsx)("p",{className:i.text,children:s("verifyCodeBody")}),(0,X.jsx)(vo,{className:i.input,name:"token",placeholder:s("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(l)}),f&&(0,X.jsx)("div",{className:i.errorMessage,children:f}),(0,X.jsxs)("div",{className:i.actions,children:[(0,X.jsx)("button",{type:"button",className:(0,Ir.default)(i.button),onClick:w,children:s("back")}),(0,X.jsx)("button",{type:"submit",className:(0,Ir.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(l),children:s("verifyCodeSubmitLabel")})]})]})]})})},td=eg;var od=require("react/jsx-runtime"),tg=()=>{let t=(0,li.useSelector)(tl),e=(0,li.useSelector)(kn),n=C("adminUrl"),o=Se(),r=()=>o.send(Pn,!1),s=()=>{o.send(Pn,!1),o.send(so)};return(0,od.jsx)(td,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:r,onSuccess:s})},nd=tg;var fc=M(require("lodash.debounce")),pe=require("react"),Ae=require("react-redux");var st=require("@reduxjs/toolkit");var xo="__summarizerAssistant__",rd={cues:[],threads:{},fetchState:"idle"},sd=t=>{var e;return(e=t.assistants)==null?void 0:e.cues};var So=t=>e=>{var n,o;return(o=(n=e.assistants)==null?void 0:n.threads[t])!=null?o:null},Ar=(0,st.createAction)("assistants/callToAction"),Fe=(0,st.createAsyncThunk)("assistants/evaluateSummaryAssistant",(t,e)=>y(void 0,null,function*(){let o=e.getState().profile.data;if(!o)throw new Error("No Profile is loaded");let{summarizerAssistantNew:r}=o;if(!r)throw new Error("No Summarizer Assistant set in Profile");let s=yield e.dispatch(He(g({assistantCode:r,expectFormat:"text",transcript:"in-memory-transcript",skipState:!0},t)));if(s.error)throw new Error(s.error.message);if(typeof s.payload!="string")throw T.warn("Unexpected summary output",s),new Error("Unexpected summary output");return s.payload})),ng=1,qt=(0,st.createAsyncThunk)("assistants/evaluateKnowledgeAssistantLegacy",(t,e)=>y(void 0,null,function*(){var m,f,h,v;let{threadId:n}=t,{onNewThreadId:o,input:r}=t,{deepdeskAPI:s}=e.extra,i=e.getState(),{platformVariables:l}=i.info;n||(n=ng++,o&&o(n));let d=(m=So(n)(i))!=null?m:[],a=yield s.getKnowledgeAssistant(t.assistantCode),c=(f=i.conversation.current)==null?void 0:f.externalId,u=(v=(h=i.info)==null?void 0:h.agentInfo)==null?void 0:v.agentId;if(!a)throw new Error("KnowledgeAssistant is not found");let p=yield s.knowledgeAssist({customerInstruction:a.customerInstruction,doNotKnowAnswer:a.doNotKnowAnswer,question:r},d,a.code,{agentId:u,conversationId:c});return l&&(p.answer=xe(p.answer,l)),{threadId:n,question:r,answer:p}})),$t=(0,st.createAsyncThunk)("assistants/evaluateKnowledgeAssistant",(t,e)=>y(void 0,null,function*(){let{threadId:n}=t,{onNewThreadId:o}=t,{deepdeskAPI:r}=e.extra,s=e.getState(),{platformVariables:i}=s.info;n||(n=(yield r.createAssistantThread({assistantCode:t.assistantCode})).id,o&&o(n)),yield r.postMessageToAssistantThread({assistantCode:t.assistantCode,threadId:n,message:t.input});let l=yield e.dispatch(He(S(g({expectFormat:"json-schema:knowledge-assist",skipState:!0},t),{input:{},threadId:n})));if(l.error)throw new Error(l.error.message);let d=l.payload;return{threadId:n,question:t.input,answer:{answer:xe(d.response,i!=null?i:{}),sources:d.sources}}})),He=(0,st.createAsyncThunk)("assistants/evaluate",(t,e)=>y(void 0,null,function*(){var m;let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra,{transcript:r,input:s={},expectFormat:i,threadId:l}=t,d=e.getState(),{platformVariables:a}=d.info,c=(m=d.conversation.current)==null?void 0:m.externalId,u;if(r==="in-memory-transcript"){if(!o.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");u=yield o.conversationQuery()}else if(r==="stored-transcript"){if(!d.conversation.current)throw new Error("Can't include stored-transcript, no current conversation");u=d.conversation.current.messages.map(f=>({text:f.text,source:f.source}))}else Array.isArray(r)&&(u=r);if(t.includeMetadata){if(!d.conversation.current)throw new Error("Can't include metadata, no current conversation");let{metadata:f}=d.conversation.current;Object.assign(s,{metadata:f})}let p=yield n.evaluateAssistant(t.assistantCode,{expectFormat:i,input:s,transcript:u,externalConversationId:c,threadId:l});if(!a)return p;switch(i){case"text":return xe(p,a);case"json-schema:cues":return p.map(f=>S(g({},f),{name:xe(f.name,a),response:xe(f.response,a)}));case"json-schema:knowledge-assist":{let f=p;return S(g({},f),{answer:xe(f.response,a)})}default:return p}})),id=(0,st.createSlice)({name:"assistants",initialState:rd,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]}},extraReducers:t=>{t.addCase(He.pending,(e,n)=>{n.meta.arg.skipState||(e.fetchState="loading")}).addCase(He.rejected,(e,n)=>{var o;T.warn((o=n.error)==null?void 0:o.message),!n.meta.arg.skipState&&(e.fetchState="error")}).addCase(He.fulfilled,(e,n)=>{if(!n.meta.arg.skipState)switch(n.meta.arg.expectFormat){case"json-schema:cues":{let o=n.payload,r=o.map(i=>i.code),s=e.cues.filter(i=>!r.includes(i.code));e.fetchState="done",e.cues=[...s,...o];break}}}).addCase($t.fulfilled,(e,n)=>{let s=n.payload,{threadId:o}=s,r=A(s,["threadId"]);e.threads[o]=[...e.threads[o]||[],r]}).addCase(qt.fulfilled,(e,n)=>{let s=n.payload,{threadId:o}=s,r=A(s,["threadId"]);e.threads[o]=[...e.threads[o]||[],r]}).addCase(Fe.pending,e=>{let n={code:xo,name:"Summary",response:"",isLoading:!0},o=e.cues.filter(r=>r.code!==xo);e.cues=[...o,n]}).addCase(Fe.rejected,e=>{let n=e.cues.filter(o=>o.code!==xo);e.cues=n}).addCase(Fe.fulfilled,(e,n)=>{let o={code:xo,name:"Summary",response:n.payload,specialType:"summary"},r=e.cues.filter(s=>s.code!==xo);e.cues=[...r,o]}).addCase(Z,()=>rd)}}),{removeCueByCode:ad,resetCues:BS,removeThreadById:In}=id.actions,ld=id.reducer;var Mr=require("@reduxjs/toolkit");var og={data:null,fetchState:"idle"},dd=t=>t.contentTypes.data,bo=(0,Mr.createAsyncThunk)("contentTypes/getContentTypes",(t,e)=>y(void 0,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),rg=(0,Mr.createSlice)({name:"contentTypes",initialState:og,reducers:{},extraReducers:t=>{t.addCase(bo.pending,e=>{e.fetchState="loading"}).addCase(bo.rejected,e=>{e.fetchState="error"}).addCase(bo.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),cd=rg.reducer;var Ln=require("@reduxjs/toolkit");var sg={data:null,fetchState:"idle"},ig=[],Gt=t=>t.profile.data,ag=t=>t.profile.data?t.profile.data.uiConfig.widget.types:ig,Co=(0,Ln.createSelector)([ag],t=>t.filter(e=>e.isActive)),pd=t=>{var e;return(e=t.profile.data)==null?void 0:e.summarizerAssistantNew},ud=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},di=t=>e=>Co(e).some(n=>n.type===t),md=t=>t.profile.data?!!t.profile.data.uiConfig.widget.types.find(e=>e.type==="custom-data"):!1,Nr=t=>{var e;return(e=t.profile.data)==null?void 0:e.knowledgeAssistantNew},Or=t=>{var e;return(e=t.profile.data)==null?void 0:e.knowledgeAssistant},wo=(0,Ln.createAsyncThunk)("profile/getProfile",(t,e)=>y(void 0,null,function*(){var s;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=o.conversation.current;if(!r||!r.profileCode)throw new Error("No conversation of conversation profileCode found");return((s=o.profile.data)==null?void 0:s.code)===r.profileCode?o.profile.data:n.getProfile(r.profileCode)})),lg=(0,Ln.createSlice)({name:"profile",initialState:sg,reducers:{},extraReducers:t=>{t.addCase(wo.pending,e=>{e.fetchState="loading"}).addCase(wo.rejected,e=>{e.fetchState="error"}).addCase(wo.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),gd=lg.reducer;function $e(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()}var at=require("react");var fd=require("react"),Dr=M(require("classnames"));var Ce={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 it={};re(it,{enUS:()=>dg,nlNL:()=>cg});var dg={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"}]},cg={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"}]};var Rt=require("react/jsx-runtime"),pg=({src:t,title:e})=>{let n=x("CommandPalette",Ce),[o,r]=(0,fd.useState)("loading"),s=k(it);return(0,Rt.jsxs)("div",{className:n.image,children:[(0,Rt.jsx)("img",{src:t,alt:e,onLoad:()=>r("done"),onError:()=>r("error"),className:(0,Dr.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&(0,Rt.jsx)("span",{className:(0,Dr.default)(n.imageSrc,n.imageSrcStatus),children:s("loading")}),o==="error"&&(0,Rt.jsx)("span",{className:(0,Dr.default)(n.imageSrc,n.imageSrcStatus),children:(0,Rt.jsx)(er,{})}),e&&(0,Rt.jsx)("span",{className:n.imageTitle,children:e})]})},hd=pg;var yd=M(require("react")),vd=M(require("classnames"));var Xt=require("react/jsx-runtime");function ci({children:t,heading:e,orientation:n,hasMore:o,onShowAll:r}){let s=k(it),i=x("CommandPalette",Ce);return yd.default.Children.count(t)===0?null:(0,Xt.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||o)&&(0,Xt.jsxs)("div",{className:i.listHeader,children:[e&&(0,Xt.jsx)("h4",{className:i.listHeading,children:e}),o&&r&&(0,Xt.jsx)("button",{onClick:r,className:i.listMoreButton,type:"button",children:s("showAll")})]}),(0,Xt.jsx)("div",{className:(0,vd.default)(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}var To=M(require("classnames")),mi=require("interweave"),Eo=require("react");var ug=/[.*+?^${}()|[\]\\]/g,mg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function gg(t){return t.replace(ug,"\\$&")}function fg(t,e){let n=t.split("").findIndex((o,r)=>o!==e[r]);return n>-1?n:Math.min(t.length,e.length)}function hg(t){return t.search(mg)}function xd(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let r=new RegExp(`\\b(${gg(o)})\\b`,"gi");n=n.replace(r,"<strong>$1</strong>")}),n}function Sd(t){return t.replace(sr,'<mark data-type="placeholder">$1</mark>')}function An(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function yg(t,e){return t.split("").map((i,l)=>({char:i,index:l})).filter(({char:i,index:l})=>/\s/.test(i)&&l<=e).map(({index:i})=>i).reverse()[0]}function pi(t,e,n={}){if(e){let o=fg(e.toLowerCase(),t.toLowerCase()),r=An(t.substring(o,t.length));if(n.stripAgentPart){let d=t.substring(0,o),a=hg(d);return`<span style="opacity: 0.5">${d.substring(a+1)}</span>${r}`}let i=e.split(qa).length>3||e.length>30?yg(e.trim(),o):0;return`${`${i>0?"\u2026":""}${An(t.substring(i,o))}`}<strong>${r}</strong>`}return t}var vg=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function _r(t){return vg.test(t)}function bd(t){var n;let e=document.createElement("template");return e.innerHTML=t,(n=e.content.textContent)!=null?n:""}var Fr=M(require("react")),Td=require("react/jsx-runtime"),wd=Fr.default.createContext(void 0);function Pt(){let t=Fr.default.useContext(wd);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Cd=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:r,setSelected:s})=>{let i=Fr.default.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:r,setSelected:s}),[n,e,r]);return(0,Td.jsx)(wd.Provider,{value:i,children:t})};var Ge=M(require("react")),H=require("@floating-ui/react");var Hr={tooltip:"dd-XpCXd",tooltipTrigger:"dd-8TKeF",arrow:"dd-ZEu2Y"};var Ie=require("react/jsx-runtime");function xg({initialOpen:t=!1,placement:e="bottom",modal:n,tooltip:o,open:r,onOpenChange:s}={}){let[i,l]=Ge.useState(t),d=r!=null?r:i,a=s!=null?s:l,c=(0,H.useFloating)({placement:e,open:d,onOpenChange:a,whileElementsMounted:H.autoUpdate,middleware:[(0,H.offset)(5),(0,H.flip)({crossAxis:e.includes("-"),fallbackAxisSideDirection:"end",padding:5}),(0,H.shift)({padding:10})]}),u=c.context,p=(0,H.useClick)(u,{enabled:r==null}),m=(0,H.useDismiss)(u),f=(0,H.useRole)(u),h=(0,H.useHover)(u,{enabled:o!=null?o:!1,handleClose:(0,H.safePolygon)()}),v=(0,H.useInteractions)([p,m,f,h]);return Ge.useMemo(()=>S(g(g({open:d,setOpen:a},v),c),{modal:n}),[d,a,v,c,n])}var Ed=Ge.createContext(null),ui=()=>{let t=Ge.useContext(Ed);if(t==null)throw new Error("Popover components must be wrapped in <Popover />");return t},Zt=o=>{var r=o,{children:t,modal:e=!1}=r,n=A(r,["children","modal"]);let s=xg(g({modal:e},n));return(0,Ie.jsx)(Ed.Provider,{value:s,children:t})};function Sg(o){var r=o,{as:t,children:e}=r,n=A(r,["as","children"]);let s=ui(),i=t||"button",l=e.ref,d=(0,H.useMergeRefs)([s.refs.setReference,l]);return(0,Ie.jsx)(i,S(g({ref:d,type:"button"},s.getReferenceProps(n)),{children:e}))}var bg=Ge.forwardRef(function(r,o){var s=r,{style:e}=s,n=A(s,["style"]);let a=ui(),{context:i}=a,l=A(a,["context"]),d=(0,H.useMergeRefs)([l.refs.setFloating,o]);return i.open?(0,Ie.jsx)(H.FloatingPortal,{children:(0,Ie.jsx)(H.FloatingFocusManager,{context:i,modal:l.modal,children:(0,Ie.jsx)("div",S(g({ref:d,style:g(S(g({},l.floatingStyles),{zIndex:1e7}),e)},l.getFloatingProps(n)),{children:n.children}))})}):null});function wg(r){var s=r,{as:t,children:e,onClick:n}=s,o=A(s,["as","children","onClick"]);let{setOpen:i}=ui();return(0,Ie.jsx)(t||"button",S(g({type:"button",onClick:a=>{n(a),i(!1),a.stopPropagation()}},o),{children:e}))}function kd({trigger:t,children:e,placement:n="top"}){return(0,Ie.jsxs)(Zt,{tooltip:!0,placement:n,children:[(0,Ie.jsxs)(Zt.Content,{className:Hr.tooltip,children:[e,(0,Ie.jsx)("div",{className:Hr.arrow})]}),(0,Ie.jsx)(Zt.Trigger,{className:Hr.tooltipTrigger,children:t})]})}Zt.Trigger=Sg;Zt.Content=bg;Zt.Button=wg;var Y=Zt;var ce=require("react/jsx-runtime"),Cg=3,Tg=90,Rd=({children:t})=>{let e=x("CommandPalette",Ce);return(0,ce.jsx)("div",{className:e.listItemActions,children:t})};function gi(m){var f=m,{closeOnSelect:t=!0,lineClamp:e,tooltip:n,children:o,onClick:r,extra:s,onSourceClick:i,description:l,sources:d,id:a,styles:c,defaultSourcesAmount:u=Cg}=f,p=A(f,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var j;let h=k(it),[v,w]=(0,Eo.useState)(!1),{selected:E,onChangeOpen:b}=Pt(),[I,N]=(0,Eo.useState)(!1),L=x("CommandPalette",Ce);function D(oe){r(oe),t&&b(!1)}return(0,Eo.useEffect)(()=>{N(E===a)},[E]),(0,ce.jsxs)("div",{className:(0,To.default)(L.listItem,a===E&&L.listItemSelected),children:[(0,ce.jsxs)(Y,{placement:"right-start",tooltip:!0,onOpenChange:N,open:I,children:[(0,ce.jsx)(Y.Trigger,S(g({className:L.listItemAction,"aria-disabled":(j=p.disabled)!=null?j:!1,onClick:D,"data-command-palette-item":!0,"data-item-id":a},p),{children:(0,ce.jsxs)("div",{className:L.listItemContent,children:[typeof o=="string"?(0,ce.jsx)("p",{className:(0,To.default)(L.listItemText,L.truncate,c==null?void 0:c.title),children:o}):o,l&&typeof l=="string"?(0,ce.jsx)(mi.Interweave,{tagName:"p",allowList:[],content:_r(l)?bd(l):l,className:(0,To.default)(L.listItemDescription,c==null?void 0:c.description,e?L.lineClamp:L.truncate)}):l]})})),n&&n.toString().length>Tg&&(0,ce.jsx)(Y.Content,{className:L.listItemTooltip,children:(0,ce.jsx)(mi.Interweave,{className:L.listItemTooltipContent,allowList:["h1","h2","h3","h4","h5","h6","a","p"],tagName:"div",content:n})})]}),a===E&&s,d&&d.length>0&&(0,ce.jsxs)("div",{className:L.sources,children:[(0,ce.jsx)("span",{className:L.sourcesTitle,children:h("sources")}),d.slice(0,v?d.length:u).map(oe=>(0,ce.jsx)("a",{className:L.source,href:oe.url,target:"_blank",title:oe.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i==null?void 0:i(oe),children:oe.name},oe.url)),!v&&d.length>u&&(0,ce.jsx)("button",{className:(0,To.default)(L.source,L.sourceShowMore),type:"button",onClick:()=>w(!0),children:h("showMore",{amount:d.length-u})})]})]})}var ko=require("react/jsx-runtime"),Pd=()=>(0,ko.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,ko.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,ko.jsx)("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"})]});var Qt=require("react/jsx-runtime");function fi({children:t,title:e,id:n,onDismiss:o}){let r=k(it),s=x("CommandPalette",Ce),{page:i}=Pt();return i!==n?null:(0,Qt.jsxs)("div",{className:s.page,id:`page_${n}`,tabIndex:-1,children:[o&&(0,Qt.jsxs)("div",{className:s.pageNav,children:[(0,Qt.jsxs)("button",{className:s.pageBackButton,type:"button",onClick:o,children:[(0,Qt.jsx)(Pd,{}),r("back")]}),e&&(0,Qt.jsx)("h3",{className:s.pageTitle,children:e})]}),t]})}var Id=require("react");var Ro=require("react/jsx-runtime"),Mn=()=>(0,Ro.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Ro.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Ro.jsx)("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"})]});var Ke=require("react/jsx-runtime");function Eg({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:r,value:s,selectedType:i},l){let d=x("CommandPalette",Ce);return(0,Ke.jsxs)("div",{className:d.search,children:[(0,Ke.jsx)("div",{className:d.searchIcon,children:(0,Ke.jsx)(Mn,{})}),(0,Ke.jsxs)("div",{className:d.searchInputWrapper,children:[(0,Ke.jsx)("input",{ref:l,spellCheck:!1,autoComplete:"off",onChange:a=>{t(a.currentTarget.value)},onFocus:a=>{a.currentTarget.select()},className:d.searchInput,placeholder:n,value:s,type:"text",id:"command-palette-search-input",autoFocus:!0}),r&&r.length>0&&(0,Ke.jsx)("div",{className:d.selectWrapper,children:(0,Ke.jsxs)("select",{"data-testid":"command-palette-type-select",className:d.select,onChange:a=>e(a.target.value===o?void 0:a.target.value),value:i||o,children:[o&&(0,Ke.jsx)("option",{children:o}),r.map(a=>(0,Ke.jsx)("option",{value:a.value,children:a.label},a.value))]})})]})]})}var Ld=(0,Id.forwardRef)(Eg);var hi=M(require("classnames"));var Kr=require("react/jsx-runtime"),kg=r=>{var s=r,{onClick:t,shortKeys:e,children:n}=s,o=A(s,["onClick","shortKeys","children"]);let i=x("CommandPalette",Ce);return(0,Kr.jsxs)("button",S(g({type:"button"},o),{onClick:t,className:(0,hi.default)(i.actionButton,o.className,{[i.hasShortKeys]:e&&e.length>0}),children:[n,e==null?void 0:e.map(l=>(0,Kr.jsx)("span",{className:(0,hi.default)(i.actionShortcut,l===8629&&i.actionShortcutFixKerning),children:typeof l=="number"?String.fromCharCode(l):l},l))]}))},Ad=kg;var Po=require("react/jsx-runtime"),Rg="[data-command-palette-item]";function Jt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:r,onChangeSearch:s,onChangeType:i,onChangeOpen:l,selectedType:d,types:a,children:c,isOpen:u,search:p,updateDeps:m=[]}){let[f,h]=(0,at.useState)(),v=(0,at.useRef)(null),w=()=>{r&&r(n),i(void 0),s(""),l(!1)},E=()=>{var _;if(o!==n&&r){r(n);return}if(d&&i){i(void 0),(_=v.current)==null||_.focus();return}if(p.length>0){s("");return}l(!1)},b=()=>{let _=I();_.length!==0&&h(_[0].dataset.itemId)},I=()=>Array.from(document.querySelectorAll(Rg)||[]),N=_=>document.querySelector(`[data-item-id=${_}]`),L=_=>{let U=N(_);U&&h(U.dataset.itemId)},D=_=>{let U=N(_);U&&U.scrollIntoView({behavior:"smooth"})},j=()=>{if(!f)return;let _=I(),U=N(f);if(!U)return;let Ee=_.indexOf(U),ge=_[Ee+1];ge!=null&&ge.dataset.itemId?L(ge.dataset.itemId):b()},oe=()=>{if(!f)return;let _=I(),U=N(f);if(!U)return;let Ee=_.indexOf(U),ge=_[Ee-1];ge!=null&&ge.dataset.itemId?L(ge.dataset.itemId):L(_[_.length-1].dataset.itemId)},be=(0,at.useCallback)(_=>{switch(_.key){case"ArrowDown":{_.preventDefault(),j();break}case"ArrowUp":{_.preventDefault(),oe();break}case"Enter":{if(f){let U=N(f);U==null||U.click()}break}}},[f]);return(0,at.useEffect)(()=>{b()},[p,o,d,u,...m]),(0,at.useEffect)(()=>{f&&D(f)},[f]),(0,Po.jsx)(Pr,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:E,onClose:w,onKeyDown:be,children:(0,Po.jsxs)(Cd,{selected:f,setSelected:h,isOpen:u,onChangeOpen:l,page:o,children:[o===n&&(0,Po.jsx)(Ld,{ref:v,onChange:s,onChangeType:i,placeholder:t,value:p,selectedType:d,types:a,typePlaceholder:e}),c]})})}Jt.Page=fi;Jt.List=ci;Jt.Image=hd;Jt.ListItem=gi;Jt.ListItemActions=Rd;Jt.Button=Ad;var W=Jt;var Md=require("react");function Nd(t,e){(0,Md.useEffect)(()=>{let n=o=>{var r;((r=navigator==null?void 0:navigator.platform)!=null&&r.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var Io=require("react"),Ur=require("react-redux");var Nn=require("@reduxjs/toolkit");var Od={data:null,fetchState:"idle"},Pg=t=>{var e;return(e=t.entities.data)!=null?e:null},Br=(0,Nn.createSelector)([Pg,kn,Rl],(t,e,n)=>{var l;let o=[],{visitorName:r}=n!=null?n:{},{agentName:s,agentNickname:i}=e!=null?e:{};return s&&s!==r&&o.push(s),i&&i!==r&&o.push(i),(l=t==null?void 0:t.filter(d=>!o.includes(d.text)))!=null?l:null}),Be=(0,Nn.createAsyncThunk)("entities/getEntities",(t,e)=>y(void 0,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let r=o.conversationQuery,s=yield r();return s.length===0?Promise.resolve([]):n.getEntities(s)})),Ig=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),Lg=(0,Nn.createSlice)({name:"entities",initialState:Od,reducers:{},extraReducers:t=>{t.addCase(Be.pending,e=>{e.fetchState="loading"}).addCase(Be.rejected,e=>{e.fetchState="error"}).addCase(Be.fulfilled,(e,n)=>{e.fetchState="done",e.data=Ig(e.data?[...e.data,...n.payload]:n.payload)}).addCase(Z,()=>Od)}}),Dd=Lg.reducer;var yi={};re(yi,{enUS:()=>Ag,nlNL:()=>Mg});var Ag={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Mg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var _d={root:"dd-TYTKs",empty:"dd-AU7uT"};var On=require("react/jsx-runtime"),Ng=({onCopy:t})=>{let e=(0,Io.useRef)(null),n=x("EntitiesList",_d),o=(0,Ur.useSelector)(Br),{setSelected:r}=Pt(),s=k(yi),i=(0,Ur.useDispatch)();return(0,Io.useEffect)(()=>{i(Be())},[]),(0,Io.useEffect)(()=>{e.current&&(e.current.focus(),r("entity-0"))},[e]),(0,On.jsxs)("div",{className:n.root,ref:e,tabIndex:-1,children:[o&&o.length>0&&(0,On.jsx)(W.List,{children:o.map((l,d)=>(0,On.jsx)(W.ListItem,{id:`entity-${d}`,closeOnSelect:!0,onClick:()=>t(l),children:l.text},l.text))},"entities"),o&&o.length===0&&(0,On.jsx)("p",{className:n.empty,children:s("noResults")})]})},Fd=Ng;var nn=M(require("react")),nc=require("react-redux");var Dn=require("react"),Hd=require("react-redux");function lt(t,e){let n=(0,Dn.useRef)(t);n.current=t;let[o,r]=(0,Dn.useState)(void 0),[s,i]=(0,Dn.useState)(void 0),[l,d]=(0,Dn.useState)("idle"),a=(0,Hd.useDispatch)();return{error:s,state:l,data:o,call:p=>y(this,null,function*(){d("loading"),yield a(n.current(p)).unwrap().then(m=>{r(m),d("done"),e!=null&&e.onSuccess&&(e==null||e.onSuccess(m))}).catch(m=>{i(m),d("error"),e!=null&&e.onError&&(e==null||e.onError(m))})}),reset:()=>{d("idle"),r(void 0),i(void 0)}}}var Vr=M(require("classnames")),Wd=require("react");var vi=require("react/jsx-runtime"),xi=t=>(0,vi.jsx)("svg",S(g({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,vi.jsx)("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"})}));var Si=require("react/jsx-runtime"),Kd=t=>(0,Si.jsx)("svg",S(g({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Si.jsx)("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 _n(t,e){var r;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(s=>{n.classList.add(s)}),n.addEventListener("animationend",()=>n.remove()),(r=t.parentElement)==null||r.appendChild(n)}var bi={};re(bi,{enUS:()=>Og,nlNL:()=>Dg});var Og={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},Dg={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Vd=require("react-redux");var Bd=require("@reduxjs/toolkit");function Ud(t){return(0,Bd.createAsyncThunk)("analytics/logEvent",(e,n)=>{var s,i,l;let o=(i=(s=n.getState())==null?void 0:s.conversation.current)==null?void 0:i.id,r=(l=n.getState())==null?void 0:l.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,S(g({conversationId:o},r),{data:e.data}))})(t)}function Q(){let t=(0,Vd.useDispatch)();return(e,n)=>y(this,null,function*(){yield t(Ud({name:e,data:n}))})}var zd={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};var wi=require("react-redux");var Fn=t=>e=>{let{passwordlessToken:{token:n},settings:{isEmbedded:o,adminUrl:r}}=e,s=r||window.location.origin;return o&&!n?null:o&&n?`${s}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${s}${t}`};var dt=require("react/jsx-runtime"),_g=({eventName:t,eventData:e,feedbackType:n,feedbackText:o})=>{let r=x("FeedbackThumbs",zd),s=C("enableFeedbackForm"),i=(0,wi.useSelector)(je),l=(0,wi.useSelector)(Fn(`/admin/feedback?conversationId=${i}&type=${n}&text=${o}&data=${JSON.stringify(e)}`)),d=k(bi),a=Q(),[c,u]=(0,Wd.useState)(null),p=f=>{f.stopPropagation(),_n(f.target,r.fadeup),u("up"),a(t,S(g({},e),{rating:"up"}))},m=f=>{f.stopPropagation(),_n(f.target,r.fadedown),u("down"),a(t,S(g({},e),{rating:"down"}))};return(0,dt.jsxs)("div",{className:r.thumbs,children:[(0,dt.jsx)(F.Button,{title:d("thumbsUp"),onClick:p,icon:(0,dt.jsx)(Kd,{}),className:(0,Vr.default)(r.thumbsUp,c==="up"&&r.selected),disabled:!!c}),s&&l?(0,dt.jsx)(F.Button,{as:"a",title:d("thumbsDown"),href:l,target:"_blank",rel:"noreferrer",onClick:m,icon:(0,dt.jsx)(xi,{}),className:(0,Vr.default)(r.thumbsDown,c==="down"&&r.selected),disabled:!!c}):(0,dt.jsx)(F.Button,{title:d("thumbsDown"),onClick:m,icon:(0,dt.jsx)(xi,{}),className:(0,Vr.default)(r.thumbsDown,c==="down"&&r.selected),disabled:!!c})]})},Yt=_g;var Lo=require("react/jsx-runtime"),jd=()=>(0,Lo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Lo.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Lo.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var Ci={};re(Ci,{enUS:()=>Fg,nlNL:()=>Hg});var Fg={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},Hg={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var qd={root:"dd-fxP4c",title:"dd-vDbMh",empty:"dd-sB0lz",status:"dd--oZ1C",form:"dd-t0hnD",input:"dd-i1v3W",submit:"dd-oo2Oa",question:"dd-WvK17",answer:"dd-HAHcU",alignRight:"dd-oxrX3",listItemFeedback:"dd-POUal"};var ec=M(require("dompurify")),pt=require("react");var Ei=M(require("classnames")),Le=require("react");var zr=require("react"),Kg=["bottom","height","left","right","top","width"],Bg=(t={},e={})=>Kg.some(n=>t[n]!==e[n]),ct=new Map,$d,Gd=()=>{let t=[],e=[];ct.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let r=o.getBoundingClientRect();Bg(r,n.rect)&&(n.rect=r,t.push(n))}),e.forEach(n=>{ct.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),$d=window.requestAnimationFrame(Gd)};function Ug(t,e){return{observe(){let n=ct.size===0;if(ct.has(t)){let o=ct.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else ct.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&Gd()},unobserve(){let n=ct.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||ct.delete(t),ct.size||cancelAnimationFrame($d)}}}}function Ti(t){let[e,n]=(0,zr.useState)(null);return(0,zr.useLayoutEffect)(()=>{if(!t.current)return;let o=Ug(t.current,r=>{n(r)});return o.observe(),()=>{o.unobserve()}},[t]),e}var Hn=require("react"),Qd=require("react-dom");var Xd=require("react");function It(t){(0,Xd.useEffect)(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function en(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Zd={root:"dd-r-dgo"};var Jd=({children:t,parentNode:e})=>{let[n,o]=(0,Hn.useState)(null),r=(0,Hn.useContext)(Yn);return(0,Hn.useLayoutEffect)(()=>{let s=document.createElement("div");return en(s),s.classList.add(Zd.root),r!=null&&r.portalRootNode&&s.classList.add(r==null?void 0:r.portalRootNode),(e||document.body).appendChild(s),o(s),()=>{s.isConnected&&s.remove()}},[]),n?(0,Qd.createPortal)(t,n):null};var Xe={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};var Wr=require("react/jsx-runtime"),jr=(t=!1)=>{let[e,n]=(0,Le.useState)(t),o=(0,Le.useCallback)(()=>n(!0),[]),r=(0,Le.useCallback)(()=>n(!1),[]),s=(0,Le.useCallback)(()=>n(l=>!l),[]),i=(0,Le.useRef)(null);return{opened:e,open:o,close:r,toggle:s,triggerRef:i}};function ki(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,r=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:r,height:t.height,width:t.width}}var Kn=a=>{var c=a,{className:t,triggerRef:e,boundaryRef:n=(0,Le.createRef)(),position:o="above",align:r="center",children:s,toStyle:i=ki,parentNode:l}=c,d=A(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let u=Ti(e),p=Ti(n),m=(0,Le.useMemo)(()=>i(u,p,0),[u,p]);return(0,Wr.jsx)(Jd,{parentNode:l,children:(0,Wr.jsx)("div",S(g({className:(0,Ei.default)(Xe.ref,{[Xe.positionAbove]:o==="above",[Xe.positionBelow]:o==="below",[Xe.positionLeft]:o==="left",[Xe.positionRight]:o==="right",[Xe.alignStart]:r==="start",[Xe.alignCenter]:r==="center",[Xe.alignEnd]:r==="end"}),style:m},d),{role:"dialog",children:(0,Wr.jsx)("div",{className:(0,Ei.default)(t,Xe.root),children:s})}))})};var Yd={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};var tc=require("marked"),Ue=require("react/jsx-runtime");function Vg(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 Ri(t){var n,o;let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(r=>r.remove()),(o=(n=e.textContent)==null?void 0:n.trim())!=null?o:""}function zg(t){return t.replace(/\r\n/g,`
4
- `)}var Wg=({content:t,useLabel:e,copyLabel:n,onCopy:o,onUse:r})=>{let s=x("Markdown",Yd),i=(0,pt.useRef)(null),[l,d]=(0,pt.useState)(null),a=(0,pt.useMemo)(()=>{let h=tc.marked.parse(zg(t));return ec.default.sanitize(h.toString()).replaceAll("</code>",`${Vg(s.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[t]),c=h=>{var E;let v=h.target,w=!!((E=i.current)!=null&&E.querySelector("code"));if(["A","BUTTON"].includes(v.tagName)){d(null);return}l||w&&v.tagName!=="CODE"||!w&&v!==i.current||(v.addEventListener("mouseleave",()=>d(null),{once:!0}),d(v))},u=()=>{if(!l)return;d(null);let h=l.querySelector("button");h&&(_n(h,s.fadeup),o==null||o(Ri(l)))},p=h=>{let v=h.target;if(v.tagName==="A"){h.stopPropagation();return}"copyIcon"in v.dataset&&(_n(v,s.fadeup),o==null||o(Ri(v.parentElement)))},m=()=>{!l||!r||(d(null),r(Ri(l)))},f=h=>{if(h===null)return;let v=h.getBoundingClientRect();v.left<0?h.style.transform=`translateX(${-v.left+2}px)`:v.right>window.innerWidth&&(h.style.transform=`translateX(${window.innerWidth-v.right-2}px)`)};return(0,Ue.jsxs)(pt.Fragment,{children:[l&&(o||r)&&(0,Ue.jsxs)(Kn,{triggerRef:{current:l},className:s.popover,parentNode:l,children:[(0,Ue.jsxs)("div",{className:s.options,ref:f,children:[o&&(0,Ue.jsx)("button",{type:"button",className:s.option,onClick:u,children:n}),r&&(0,Ue.jsxs)(pt.Fragment,{children:[(0,Ue.jsx)("div",{className:s.divider}),(0,Ue.jsx)("button",{type:"button",className:s.option,onClick:m,children:e})]})]}),(0,Ue.jsx)("div",{className:s.arrow})]}),(0,Ue.jsx)("div",{ref:i,"data-testid":"widget-markdown-content",className:s.root,dangerouslySetInnerHTML:{__html:a},onMouseOver:c,onClick:p})]})},tn=Wg;var ie=require("react/jsx-runtime"),jg=({threadId:t,onEvaluate:e,onUse:n,onResetQuestion:o,question:r})=>{var v;let[s,i]=nn.default.useState(""),{setSelected:l}=Pt(),d=(0,nn.useRef)(null),a=x("KnowledgeSearchStyles",qd),c=k(Ci),u=Q(),p=(v=(0,nc.useSelector)(So(t!=null?t:-1)))!=null?v:[],m=lt(e,{onSuccess(w){u("knowledge assist question answered",{question:s||r||"",sources:w.answer.sources,answer:w.answer.answer,isFollowUpQuestion:p.length>=1,isAutoInitiated:!s&&!!r}),l(`knowledge-assist-${p.length}`),i("")}}),f=w=>y(void 0,null,function*(){w.preventDefault(),w.stopPropagation(),s!==""&&m.call(s)}),h=(w,E)=>{u("knowledge assist source viewed",{question:E,sourceViewed:w.url||w.name})};return(0,nn.useEffect)(()=>{var w;r&&m.state==="idle"?m.call(r):(w=d.current)==null||w.focus()},[d,m.state]),(0,nn.useEffect)(()=>{d.current&&d.current.scrollIntoView({behavior:"smooth"})},[d,p]),(0,ie.jsxs)("div",{className:a.root,children:[p.length>0&&(0,ie.jsx)("div",{className:a.alignRight,children:(0,ie.jsx)(W.Button,{onClick:o,children:c("reset")})}),p.map(({question:w,answer:E},b)=>(0,ie.jsx)(W.List,{children:(0,ie.jsx)(W.ListItem,{id:`knowledge-assist-${b}`,"data-testid":"knowledge-search-answer",description:(0,ie.jsx)(tn,{content:E.answer}),closeOnSelect:!0,onClick:()=>n(E.answer),onSourceClick:I=>h(I,w),sources:E.sources,styles:{title:a.question,description:a.answer},extra:(0,ie.jsx)("div",{className:a.listItemFeedback,children:(0,ie.jsx)(Yt,{feedbackText:E.answer,feedbackType:"knowledge-assist-answer",eventName:"knowledge assist feedback",eventData:g({question:w,isAgent:r!==w,isFollowUpQuestion:p.length>1},E)})}),children:w})},`${E.answer}_${b}`)),m.state==="loading"&&(0,ie.jsx)("p",{className:a.status,children:c("loading")}),m.state==="error"&&(0,ie.jsx)("p",{className:a.status,children:c("error")}),(0,ie.jsxs)("form",{className:a.form,onSubmit:f,children:[(0,ie.jsx)("input",{ref:d,placeholder:c("anotherQuestion"),className:a.input,type:"text",value:s,onFocus:()=>{l(void 0)},onChange:w=>{l(void 0),i(w.target.value)}}),(0,ie.jsx)("button",{type:"submit",className:a.submit,disabled:m.state==="loading",children:(0,ie.jsx)(jd,{})})]})]})},oc=jg;var Pi=require("react/jsx-runtime"),qr=t=>(0,Pi.jsx)("svg",S(g({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},t),{children:(0,Pi.jsx)("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 Ao={};re(Ao,{enUS:()=>qg,nlNL:()=>$g});var qg={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"}]},$g={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 Ii=require("react-redux");var rc=require("react-redux");var $r={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var on=require("react/jsx-runtime"),Gg=({suggestion:t,source:e,context:n})=>{let o=k(Ao),r=(0,Ii.useSelector)(je),s=(0,rc.useDispatch)(),i=C("enableSuggestionFeedback"),l=`${t.text}`,d=(0,Ii.useSelector)(Fn(`/admin/feedback?conversationId=${r}&type=${e}&text=${l}&data=${JSON.stringify({context:n})}`)),a=()=>{s(ot({name:"suggestion feedback",data:{text:t.text,source:e,context:n},options:{includeConversationData:!0}}))};return!i||!d?null:(0,on.jsxs)(Y,{placement:"top-end",children:[(0,on.jsx)(Y.Trigger,{className:$r.trigger,children:(0,on.jsx)(qr,{"data-testid":"feedback-dropdown-trigger"})}),(0,on.jsx)(Y.Content,{className:$r.content,children:(0,on.jsx)(Y.Button,{className:$r.item,as:"a",onClick:a,target:"_blank",href:d,children:o("giveFeedback")})})]})},Gr=Gg;var Mo={};re(Mo,{enUS:()=>Xg,nlNL:()=>Zg});var Xg={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?"}]},Zg={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?"}]};var mc=require("react"),Qr=require("react-redux");var rn=require("@reduxjs/toolkit");var Qg=["{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}"],Jg=new RegExp(Qg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function sc(t,e){let n=t.split(Jg),o=0,r=[];for(let s=0;s<n.length;s++){let i=n[s];if(r.push(i),s===n.length-1)break;if(e.indexOf(i)===-1)return t;let l=n[s+1],d=s===n.length-2;o+=i.length;let a=o;if(d){let u=l.charAt(0),p=0;do a=u?e.indexOf(u,a+1):-1,p+=1;while(a!==-1&&l.indexOf(e.slice(a))!==0);if(a===-1&&p>2)return t}else a=l&&l!==""?e.indexOf(l,o):-1;let c=a===-1?e.slice(o):e.slice(o,a);r.push(c),o=a}return r.join("")}function ic(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var lc={suggestions:[],fetchState:"idle"},ac={default:lc},dc=t=>e=>{var n,o;return(o=(n=e.textSuggestions[t])==null?void 0:n.suggestions)!=null?o:[]},Xr=t=>t.textSuggestions,cc=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Zr=(0,rn.createAction)("textSuggestions/refresh"),Ve=(0,rn.createAsyncThunk)("textSuggestions/recommendations",(t,e)=>y(void 0,null,function*(){var a,c;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:r}=o.info,{textSuggestionsCount:s,inlineSuggestions:i}=o.settings,l=Cn(o),d=[];if(t==="sticky-messages"){let u=(a=o.profile.data)==null?void 0:a.code;if(!u)throw new Error("No current profile to fetch pinned messages");d=yield n.getPinnedMessages(u)}else{let u=(c=o.conversation.current)==null?void 0:c.id;if(!u)throw new Error("No current conversation to fetch text suggestions");d=yield n.getTextSuggestions(u,ro(o),t)}if(r&&(d=d.map(u=>g(S(g({},u),{text:xe(u.text,r)}),u.title?{title:xe(u.title,r)}:{}))),t==="default"){let u=i?d.filter(cc(l)):d;e.dispatch(Et(u.slice(0,s)))}return d})),No=(0,rn.createAsyncThunk)("textSuggestions/autocompletions",(t,e)=>y(void 0,null,function*(){var c;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=(c=o.conversation.current)==null?void 0:c.id,{platformVariables:s}=o.info,{textSuggestionsCount:i,deanonymize:l,inlineSuggestions:d}=o.settings;if(!r)throw new Error("No current conversation to fetch text suggestions");let a=yield n.getAutocompleteSuggestions(r,S(g({},ro(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return d&&(a=a.filter(cc(t))),s&&(a=a.map(u=>S(g({},u),{text:xe(u.text,s)}))),l&&(a=a.map(u=>S(g({},u),{text:u.source!=="trie-with-typos"?sc(u.text,t):u.text}))),a=ic(a,i),e.dispatch(Et(a)),a})),pc=(0,rn.createSlice)({name:"textSuggestions",initialState:ac,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(Ve.pending,(e,n)=>{let o=n.meta.arg,r=e[o]||lc;return S(g({},e),{[o]:S(g({},r),{fetchState:"loading"})})}).addCase(Ve.rejected,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="error")}).addCase(Ve.fulfilled,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="done",e[o].suggestions=n.payload)}).addCase(No.pending,e=>{e.default.fetchState="loading"}).addCase(No.rejected,e=>{e.default.fetchState="error"}).addCase(No.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(Z,()=>ac)}}),{setTextSuggestions:HC}=pc.actions,uc=pc.reducer;var sn=require("react/jsx-runtime"),Yg=({types:t,commands:e,onClick:n})=>{let o=(0,Qr.useDispatch)(),r=k(Mo),s=(0,Qr.useSelector)(Xr);return(0,mc.useEffect)(()=>{t.forEach(({type:i})=>{(!s[i]||s[i].suggestions.length===0)&&o(Ve(i))})},[]),(0,sn.jsxs)("div",{children:[e.length>0&&(0,sn.jsx)(W.List,{heading:r("commands"),children:e.map((i,l)=>(0,sn.jsx)(W.ListItem,{id:`command-${l}`,closeOnSelect:!1,onClick:i.onClick,children:i.label},i.label))}),t.map(({type:i,title:l})=>{var d;return(0,sn.jsx)(W.List,{heading:l,orientation:"vertical",children:(d=s[i])==null?void 0:d.suggestions.map((a,c)=>(0,sn.jsx)(W.ListItem,{id:`${i}-${c}`,closeOnSelect:!1,description:a.title&&a.text,onClick:()=>n(a.text,a),"data-testid":"search-overlay-suggestion",children:a.title||a.text},`${a.id}-${a.text}`))},i)})]})},gc=Yg;var ee=require("react/jsx-runtime"),tf=200,nf=5,of=4,Li=(t,e,n)=>t.slice(0,n?10:e.toLowerCase()==="image"?of:nf),rf=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),sf=()=>{var va,xa,Sa;let t=(0,Ae.useDispatch)(),e=Se(),n=k(Mo),[o,r]=(0,pe.useState)(!1),[s,i]=(0,pe.useState)(""),[l,d]=(0,pe.useState)(null),a=(0,Ae.useSelector)(Dl),c=(0,Ae.useSelector)(Gt),[u,p]=(0,pe.useState)(),m=(0,Ae.useSelector)(de),f=C("showSearch"),h=C("enableSuggestionFeedback"),v=C("showEntitiesCommand"),w=C("showKnowledgeSearch"),E=C("showImageSearch"),b=C("searchTriggerKey"),I=(0,Ae.useSelector)(Nr),N=(0,Ae.useSelector)(Or),L=(0,Ae.useSelector)(dd),D=(0,Ae.useSelector)(Gs),j=(0,Ae.useSelector)(_l),oe=(0,Ae.useSelector)(Ol),be=((Sa=(xa=(va=c==null?void 0:c.uiConfig)==null?void 0:va.search)==null?void 0:xa.initialTypes)==null?void 0:Sa.filter(({isActive:R})=>R))||[],_=Q(),U=(0,pe.useMemo)(()=>{let R=fe=>Li(D.filter(G=>G.type===fe.toUpperCase()),fe,u),$=(L==null?void 0:L.map(fe=>({value:fe.code.toUpperCase(),label:`${fe.name}s`,list:R(fe.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if($.push({value:"PERSONAL",label:n("personalSuggestions"),list:R("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:R("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:R("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),E&&$.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:R("IMAGE"),listOrientation:"horizontal"}),be.length===0)return $;let Ft=be.map(fe=>$.find(G=>G.value.toLowerCase()===fe.type)).filter(fe=>!!fe),Fs=$.filter(fe=>!Ft.find(G=>G.value===fe.value));return[...Ft,...Fs]},[L,be,E,u]),Ee=[{label:n("entitiesClipboard"),onClick:()=>t(rt("entities")),shouldShow:v&&rf(n("entitiesClipboard"),s)},{label:s?`${n("knowledgeAssist")}: ${s}`:n("knowledgeAssist"),onClick:()=>{t(rt("knowledgeAssist")),_("open knowledge assistant",{via:"search-command"})},shouldShow:w}].filter(R=>R.shouldShow).filter(()=>!u),ge=(0,pe.useCallback)((0,fc.default)((R,$)=>{t(Wt({query:R,type:$,tags:["search-overlay"],size:u?50:20}))},tf),[u]),ya=(0,pe.useCallback)((R,$)=>{switch($.type){case"IMAGE":e.send(Zs,{suggestion:$});break;default:e.send(qe,{text:R,suggestion:$})}t(Re(!1))},[t]),$u=R=>{$e(R.text),t(ot({name:"entity copied",data:{entity:R,type:"copy"}})),t(Re(!1))},Gu=R=>{e.send(qe,{text:R,suggestion:{source:"knowledge-assist",text:R}}),t(ot({name:"answer used",data:{originalText:R},options:{includeConversationData:!0}})),i(""),l&&t(In(l)),t(rt("search")),t(Re(!1))},Xu=R=>{let $={input:R,threadId:l,onNewThreadId:Ft=>d(Ft)};if(N)return qt(g({assistantCode:N},$));if(I)return $t(g({assistantCode:I},$))};function Qo(R){return $=>{o?window.confirm(n("warning"))&&(R($),r(!1)):R($)}}return(0,pe.useEffect)(()=>{s?ge(s,u):t(vr())},[s,u]),(0,pe.useEffect)(()=>{m&&t(bo())},[m]),Nd(b,()=>{t(Re(!0)),_("open search",{via:"ctrl+k"})}),!f||!c?null:(0,ee.jsxs)(W,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:Qo(R=>t(Re(R))),onChangeType:R=>p(R),onChangePage:Qo(R=>t(rt(R))),selectedType:u,search:s,page:a,isOpen:oe,types:U,updateDeps:[D],children:[(0,ee.jsxs)(W.Page,{id:"search",children:[s.length===0&&(0,ee.jsx)(gc,{types:be,commands:Ee,onClick:ya}),s.length>0&&(0,ee.jsxs)(pe.Fragment,{children:[Ee.length>0&&(0,ee.jsx)(W.List,{heading:n("commands"),children:Ee.map((R,$)=>(0,ee.jsx)(W.ListItem,{closeOnSelect:!1,onClick:R.onClick,id:`commands-${$}`,children:R.label},R.label))}),U.map(({value:R,label:$,list:Ft,lineClamp:Fs,listOrientation:fe})=>(0,ee.jsx)(W.List,{heading:$,orientation:fe==="horizontal"?"horizontal":"vertical",onShowAll:()=>p(R),hasMore:!u&&j[R.toLowerCase()]>Li(Ft,R,u).length,children:Li(Ft,R,u).map(G=>(0,ee.jsx)(W.ListItem,{id:`${R}-${G.id}`,closeOnSelect:!1,lineClamp:Fs,onClick:()=>ya(G.text,G),description:R!=="IMAGE"?G.title&&G.text:void 0,tooltip:G.text,extra:h&&(0,ee.jsx)(W.ListItemActions,{children:(0,ee.jsx)(Gr,{context:s,source:"search",suggestion:G})}),children:R==="IMAGE"?(0,ee.jsx)(W.Image,{title:G.title||G.text,src:G.image}):G.title||G.text},`${G.id}-${G.text}`))},R))]})]}),(0,ee.jsx)(W.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Qo(()=>{t(rt("search"))}),children:(0,ee.jsx)(Fd,{onCopy:$u})}),(I!=null?I:N)&&(0,ee.jsx)(W.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Qo(()=>{l&&t(In(l)),t(rt("search"))}),children:(0,ee.jsx)(oc,{threadId:l,onEvaluate:Xu,question:s,onUse:Gu,onResetQuestion:()=>{l&&t(In(l)),i(""),d(null)}})})]})},hc=sf;var Oo=require("react/jsx-runtime"),af=()=>{let t=C("showSearch"),e=C("isEmbedded");return(0,Oo.jsxs)(yc.Fragment,{children:[t&&(0,Oo.jsx)(hc,{}),e&&(0,Oo.jsx)(nd,{})]})},vc=af;var wc=M(require("classnames")),Cc=require("react-redux");var Jr=require("react/jsx-runtime"),xc=({className:t})=>(0,Jr.jsx)("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:(0,Jr.jsx)("g",{children:(0,Jr.jsx)("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
+ `,qt.MISSING_INTL_API,i);var I=n.getPluralRules(e,{type:c.pluralType}).select(p-(c.offset||0));w=c.options[I]||c.options.other}if(!w)throw new oi(c.value,p,Object.keys(c.options),i);a.push.apply(a,yo(w.value,e,n,o,r,p-(c.offset||0)));continue}}return Bm(a)}function Vm(t,e){return e?we(we(we({},t||{}),e||{}),Object.keys(t).reduce(function(n,o){return n[o]=we(we({},t[o]),e[o]||{}),n},{})):t}function zm(t,e){return e?Object.keys(t).reduce(function(n,o){return n[o]=Vm(t[o],e[o]),n},we({},t)):t}function ri(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,n){t[e]=n}}}}}function Wm(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:xr(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,Sr([void 0],n,!1)))},{cache:ri(t.number),strategy:br.variadic}),getDateTimeFormat:xr(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,Sr([void 0],n,!1)))},{cache:ri(t.dateTime),strategy:br.variadic}),getPluralRules:xr(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,Sr([void 0],n,!1)))},{cache:ri(t.pluralRules),strategy:br.variadic})}}var si=function(){function t(e,n,o,r){n===void 0&&(n=t.defaultLocale);var s=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(l){var c=s.formatToParts(l);if(c.length===1)return c[0].value;var u=c.reduce(function(p,m){return!p.length||m.type!==se.literal||typeof p[p.length-1]!="string"?p.push(m.value):p[p.length-1]+=m.value,p},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(l){return yo(s.ast,s.locales,s.formatters,s.formats,l,void 0,s.message)},this.resolvedOptions=function(){var l;return{locale:((l=s.resolvedLocale)===null||l===void 0?void 0:l.toString())||Intl.NumberFormat.supportedLocalesOf(s.locales)[0]}},this.getAst=function(){return s.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=r||{},a=i.formatters,d=Vl(i,["formatters"]);this.ast=t.__parse(e,we(we({},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=zm(t.formats,o),this.formatters=r&&r.formatters||Wm(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=jl,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 qm(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var jm="dummy",ii=(0,kr.createContext)(null);function k(t){var o;let e=(0,kr.useContext)(ii);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(r,s)=>{let i=qm(n,r);return i?new si(i).format(s):(e!==jm&&console.warn(`${r} does not exist in messages of ${e}`),`[${r}]`)}}var Rr=require("react");var Xl={root:"dd-tvkOF",content:"dd-eXA1D"};var ai=require("react/jsx-runtime"),$m=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:r,onKeyDown:s,overlayAriaLabel:i,contentAriaLabel:a})=>{let d=(0,Rr.useRef)(null),l=S("Dialog",Xl),c=p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),r();return}s&&s(p)},u=p=>{p.target===d.current&&t&&o()};return(0,Rr.useEffect)(()=>{var p,m;!d.current||!t||!e||(m=(p=d.current)==null?void 0:p.querySelector("input, textarea"))==null||m.focus()},[t,e,d]),t?(0,ai.jsx)("div",{role:"dialog","data-testid":"dialog",className:l.root,"aria-label":i,ref:d,onKeyDown:c,onMouseDown:u,children:(0,ai.jsx)("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:n})}):null},Pr=$m;var Ql=M(require("classnames"));var Zl={root:"dd-ranhW"};var Jl=require("react/jsx-runtime"),Gm=o=>{var r=o,{className:t,value:e}=r,n=A(r,["className","value"]);let s=S("TextInput",Zl);return(0,Jl.jsx)("input",g({className:(0,Ql.default)(t,s.root),type:"text",value:e},n))},vo=Gm;var li={};re(li,{enUS:()=>Xm,nlNL:()=>Zm});var Xm={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"}]},Zm={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 Yl={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"};var X=require("react/jsx-runtime");var Qm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch(e){return t}},Jm=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:r})=>{let s=k(li),i=S("LoginTokenDialog",Yl),a=(0,Lr.useSelector)(Ya),d=(0,Lr.useDispatch)(),l=C("productName"),[c,u]=(0,_e.useState)(t||""),[p,m]=(0,_e.useState)(0),[h,f]=(0,_e.useState)(""),y=(0,_e.useCallback)(I=>v(void 0,null,function*(){I.preventDefault(),d(tl({email:c})),m(1)}),[n,c]),b=()=>{f(""),m(0)},E=(0,_e.useCallback)(I=>v(void 0,null,function*(){I.preventDefault();let N=Qm(I.target.elements.token.value);if(!N){f(s("verifyCodeError",{login:w}));return}d(no({token:N}))}),[n]),w=(0,_e.useMemo)(()=>I=>(0,X.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:b,children:I},"back-button"),[]);return(0,_e.useEffect)(()=>{a==="error"&&f(s("verifyCodeError",{login:w})),a==="done"&&o()},[a]),(0,X.jsx)(Pr,{autoFocus:!0,isOpen:e,contentAriaLabel:s("promptTitle",{productName:l}),overlayAriaLabel:s("promptTitle",{productName:l}),onClose:r,onBack:r,children:(0,X.jsxs)("div",{className:i.root,children:[(0,X.jsx)("h1",{className:i.title,children:s("promptTitle",{productName:l})}),p===0&&(0,X.jsxs)("form",{onSubmit:y,children:[(0,X.jsx)("h2",{className:i.subtitle,children:s("requestCodeTitle")}),(0,X.jsx)("p",{className:i.text,children:s("requestCodeBody",{productName:l})}),(0,X.jsx)(vo,{className:i.input,name:"email",placeholder:s("requestCodeInputPlaceholder"),value:c,onChange:I=>u(I.target.value)}),(0,X.jsx)("div",{className:i.actions,children:(0,X.jsx)("button",{type:"submit",className:(0,Ir.default)(i.button,i.primaryButton),children:s("requestCodeSubmitLabel")})})]}),p===1&&(0,X.jsxs)("form",{onSubmit:E,children:[(0,X.jsx)("h2",{className:i.subtitle,children:s("verifyCodeTitle")}),(0,X.jsx)("p",{className:i.text,children:s("verifyCodeBody")}),(0,X.jsx)(vo,{className:i.input,name:"token",placeholder:s("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),h&&(0,X.jsx)("div",{className:i.errorMessage,children:h}),(0,X.jsxs)("div",{className:i.actions,children:[(0,X.jsx)("button",{type:"button",className:(0,Ir.default)(i.button),onClick:b,children:s("back")}),(0,X.jsx)("button",{type:"submit",className:(0,Ir.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:s("verifyCodeSubmitLabel")})]})]})]})})},ed=Jm;var nd=require("react/jsx-runtime"),Ym=()=>{let t=(0,di.useSelector)(el),e=(0,di.useSelector)(kn),n=C("adminUrl"),o=xe(),r=()=>o.send(Pn,!1),s=()=>{o.send(Pn,!1),o.send(so)};return(0,nd.jsx)(ed,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:r,onSuccess:s})},td=Ym;var gc=M(require("lodash.debounce")),pe=require("react"),Ae=require("react-redux");var st=require("@reduxjs/toolkit");var So="__summarizerAssistant__",od={cues:[],threads:{},fetchState:"idle"},rd=t=>{var e;return(e=t.assistants)==null?void 0:e.cues};var xo=t=>e=>{var n,o;return(o=(n=e.assistants)==null?void 0:n.threads[t])!=null?o:null},Ar=(0,st.createAction)("assistants/callToAction"),Fe=(0,st.createAsyncThunk)("assistants/evaluateSummaryAssistant",(t,e)=>v(void 0,null,function*(){let o=e.getState().profile.data;if(!o)throw new Error("No Profile is loaded");let{summarizerAssistantNew:r}=o;if(!r)throw new Error("No Summarizer Assistant set in Profile");let s=yield e.dispatch(He(g({assistantCode:r,expectFormat:"text",transcript:"in-memory-transcript",skipState:!0},t)));if(s.error)throw new Error(s.error.message);if(typeof s.payload!="string")throw T.warn("Unexpected summary output",s),new Error("Unexpected summary output");return s.payload})),eg=1,jt=(0,st.createAsyncThunk)("assistants/evaluateKnowledgeAssistantLegacy",(t,e)=>v(void 0,null,function*(){var m,h,f,y;let{threadId:n}=t,{onNewThreadId:o,input:r}=t,{deepdeskAPI:s}=e.extra,i=e.getState(),{platformVariables:a}=i.info;n||(n=eg++,o&&o(n));let d=(m=xo(n)(i))!=null?m:[],l=yield s.getKnowledgeAssistant(t.assistantCode),c=(h=i.conversation.current)==null?void 0:h.externalId,u=(y=(f=i.info)==null?void 0:f.agentInfo)==null?void 0:y.agentId;if(!l)throw new Error("KnowledgeAssistant is not found");let p=yield s.knowledgeAssist({customerInstruction:l.customerInstruction,doNotKnowAnswer:l.doNotKnowAnswer,question:r},d,l.code,{agentId:u,conversationId:c});return a&&(p.answer=Se(p.answer,a)),{threadId:n,question:r,answer:p}})),$t=(0,st.createAsyncThunk)("assistants/evaluateKnowledgeAssistant",(t,e)=>v(void 0,null,function*(){let{threadId:n}=t,{onNewThreadId:o}=t,{deepdeskAPI:r}=e.extra,s=e.getState(),{platformVariables:i}=s.info;n||(n=(yield r.createAssistantThread({assistantCode:t.assistantCode})).id,o&&o(n)),yield r.postMessageToAssistantThread({assistantCode:t.assistantCode,threadId:n,message:t.input});let a=yield e.dispatch(He(x(g({expectFormat:"json-schema:knowledge-assist",skipState:!0},t),{input:{},threadId:n})));if(a.error)throw new Error(a.error.message);let d=a.payload;return{threadId:n,question:t.input,answer:{answer:Se(d.response,i!=null?i:{}),sources:d.sources}}})),He=(0,st.createAsyncThunk)("assistants/evaluate",(t,e)=>v(void 0,null,function*(){var m;let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra,{transcript:r,input:s={},expectFormat:i,threadId:a}=t,d=e.getState(),{platformVariables:l}=d.info,c=(m=d.conversation.current)==null?void 0:m.externalId,u;if(r==="in-memory-transcript"){if(!o.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");u=yield o.conversationQuery()}else Array.isArray(r)&&(u=r);if(t.includeMetadata){if(!d.conversation.current)throw new Error("Can't include metadata, no current conversation");let{metadata:h}=d.conversation.current;Object.assign(s,{metadata:h})}let p=yield n.evaluateAssistant(t.assistantCode,{expectFormat:i,input:s,transcript:u,externalConversationId:c,threadId:a});if(!l)return p;switch(i){case"text":return Se(p,l);case"json-schema:cues":return p.map(h=>x(g({},h),{name:Se(h.name,l),response:Se(h.response,l)}));case"json-schema:knowledge-assist":{let h=p;return x(g({},h),{answer:Se(h.response,l)})}default:return p}})),sd=(0,st.createSlice)({name:"assistants",initialState:od,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]}},extraReducers:t=>{t.addCase(He.pending,(e,n)=>{n.meta.arg.skipState||(e.fetchState="loading")}).addCase(He.rejected,(e,n)=>{var o;T.warn((o=n.error)==null?void 0:o.message),!n.meta.arg.skipState&&(e.fetchState="error")}).addCase(He.fulfilled,(e,n)=>{if(!n.meta.arg.skipState)switch(n.meta.arg.expectFormat){case"json-schema:cues":{let o=n.payload,r=o.map(i=>i.code),s=e.cues.filter(i=>!r.includes(i.code));e.fetchState="done",e.cues=[...s,...o];break}}}).addCase($t.fulfilled,(e,n)=>{let s=n.payload,{threadId:o}=s,r=A(s,["threadId"]);e.threads[o]=[...e.threads[o]||[],r]}).addCase(jt.fulfilled,(e,n)=>{let s=n.payload,{threadId:o}=s,r=A(s,["threadId"]);e.threads[o]=[...e.threads[o]||[],r]}).addCase(Fe.pending,e=>{let n={code:So,name:"Summary",response:"",isLoading:!0},o=e.cues.filter(r=>r.code!==So);e.cues=[...o,n]}).addCase(Fe.rejected,e=>{let n=e.cues.filter(o=>o.code!==So);e.cues=n}).addCase(Fe.fulfilled,(e,n)=>{let o={code:So,name:"Summary",response:n.payload,specialType:"summary"},r=e.cues.filter(s=>s.code!==So);e.cues=[...r,o]}).addCase(Z,()=>od)}}),{removeCueByCode:id,resetCues:Hx,removeThreadById:In}=sd.actions,ad=sd.reducer;var Mr=require("@reduxjs/toolkit");var tg={data:null,fetchState:"idle"},ld=t=>t.contentTypes.data,bo=(0,Mr.createAsyncThunk)("contentTypes/getContentTypes",(t,e)=>v(void 0,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),ng=(0,Mr.createSlice)({name:"contentTypes",initialState:tg,reducers:{},extraReducers:t=>{t.addCase(bo.pending,e=>{e.fetchState="loading"}).addCase(bo.rejected,e=>{e.fetchState="error"}).addCase(bo.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),dd=ng.reducer;var Ln=require("@reduxjs/toolkit");var og={data:null,fetchState:"idle"},rg=[],Gt=t=>t.profile.data,sg=t=>t.profile.data?t.profile.data.uiConfig.widget.types:rg,Co=(0,Ln.createSelector)([sg],t=>t.filter(e=>e.isActive)),cd=t=>{var e;return(e=t.profile.data)==null?void 0:e.summarizerAssistantNew},pd=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},ci=t=>e=>Co(e).find(n=>n.type===t),ud=t=>t.profile.data?!!t.profile.data.uiConfig.widget.types.find(e=>e.type==="custom-data"):!1,Nr=t=>{var e;return(e=t.profile.data)==null?void 0:e.knowledgeAssistantNew},Or=t=>{var e;return(e=t.profile.data)==null?void 0:e.knowledgeAssistant},wo=(0,Ln.createAsyncThunk)("profile/getProfile",(t,e)=>v(void 0,null,function*(){var s;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=o.conversation.current;if(!r||!r.profileCode)throw new Error("No conversation of conversation profileCode found");return((s=o.profile.data)==null?void 0:s.code)===r.profileCode?o.profile.data:n.getProfile(r.profileCode)})),ig=(0,Ln.createSlice)({name:"profile",initialState:og,reducers:{},extraReducers:t=>{t.addCase(wo.pending,e=>{e.fetchState="loading"}).addCase(wo.rejected,e=>{e.fetchState="error"}).addCase(wo.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),md=ig.reducer;function $e(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()}var at=require("react");var gd=require("react"),Dr=M(require("classnames"));var Ce={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 it={};re(it,{enUS:()=>ag,nlNL:()=>lg});var ag={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"}]},lg={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"}]};var Rt=require("react/jsx-runtime"),dg=({src:t,title:e})=>{let n=S("CommandPalette",Ce),[o,r]=(0,gd.useState)("loading"),s=k(it);return(0,Rt.jsxs)("div",{className:n.image,children:[(0,Rt.jsx)("img",{src:t,alt:e,onLoad:()=>r("done"),onError:()=>r("error"),className:(0,Dr.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&(0,Rt.jsx)("span",{className:(0,Dr.default)(n.imageSrc,n.imageSrcStatus),children:s("loading")}),o==="error"&&(0,Rt.jsx)("span",{className:(0,Dr.default)(n.imageSrc,n.imageSrcStatus),children:(0,Rt.jsx)(er,{})}),e&&(0,Rt.jsx)("span",{className:n.imageTitle,children:e})]})},fd=dg;var hd=M(require("react")),yd=M(require("classnames"));var Xt=require("react/jsx-runtime");function pi({children:t,heading:e,orientation:n,hasMore:o,onShowAll:r}){let s=k(it),i=S("CommandPalette",Ce);return hd.default.Children.count(t)===0?null:(0,Xt.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||o)&&(0,Xt.jsxs)("div",{className:i.listHeader,children:[e&&(0,Xt.jsx)("h4",{className:i.listHeading,children:e}),o&&r&&(0,Xt.jsx)("button",{onClick:r,className:i.listMoreButton,type:"button",children:s("showAll")})]}),(0,Xt.jsx)("div",{className:(0,yd.default)(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}var To=M(require("classnames")),gi=require("interweave"),Eo=require("react");var cg=/[.*+?^${}()|[\]\\]/g,pg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function ug(t){return t.replace(cg,"\\$&")}function mg(t,e){let n=t.split("").findIndex((o,r)=>o!==e[r]);return n>-1?n:Math.min(t.length,e.length)}function gg(t){return t.search(pg)}function vd(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let r=new RegExp(`\\b(${ug(o)})\\b`,"gi");n=n.replace(r,"<strong>$1</strong>")}),n}function Sd(t){return t.replace(sr,'<mark data-type="placeholder">$1</mark>')}function An(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function fg(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 ui(t,e,n={}){if(e){let o=mg(e.toLowerCase(),t.toLowerCase()),r=An(t.substring(o,t.length));if(n.stripAgentPart){let d=t.substring(0,o),l=gg(d);return`<span style="opacity: 0.5">${d.substring(l+1)}</span>${r}`}let i=e.split(qa).length>3||e.length>30?fg(e.trim(),o):0;return`${`${i>0?"\u2026":""}${An(t.substring(i,o))}`}<strong>${r}</strong>`}return t}var hg=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function _r(t){return hg.test(t)}function xd(t){var n;let e=document.createElement("template");return e.innerHTML=t,(n=e.content.textContent)!=null?n:""}var Fr=M(require("react")),Cd=require("react/jsx-runtime"),bd=Fr.default.createContext(void 0);function Pt(){let t=Fr.default.useContext(bd);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var wd=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:r,setSelected:s})=>{let i=Fr.default.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:r,setSelected:s}),[n,e,r]);return(0,Cd.jsx)(bd.Provider,{value:i,children:t})};var Ge=M(require("react")),H=require("@floating-ui/react");var Hr={tooltip:"dd-XpCXd",tooltipTrigger:"dd-8TKeF",arrow:"dd-ZEu2Y"};var Ie=require("react/jsx-runtime");function yg({initialOpen:t=!1,placement:e="bottom",modal:n,tooltip:o,open:r,onOpenChange:s}={}){let[i,a]=Ge.useState(t),d=r!=null?r:i,l=s!=null?s:a,c=(0,H.useFloating)({placement:e,open:d,onOpenChange:l,whileElementsMounted:H.autoUpdate,middleware:[(0,H.offset)(5),(0,H.flip)({crossAxis:e.includes("-"),fallbackAxisSideDirection:"end",padding:5}),(0,H.shift)({padding:10})]}),u=c.context,p=(0,H.useClick)(u,{enabled:r==null}),m=(0,H.useDismiss)(u),h=(0,H.useRole)(u),f=(0,H.useHover)(u,{enabled:o!=null?o:!1,handleClose:(0,H.safePolygon)()}),y=(0,H.useInteractions)([p,m,h,f]);return Ge.useMemo(()=>x(g(g({open:d,setOpen:l},y),c),{modal:n}),[d,l,y,c,n])}var Td=Ge.createContext(null),mi=()=>{let t=Ge.useContext(Td);if(t==null)throw new Error("Popover components must be wrapped in <Popover />");return t},Zt=o=>{var r=o,{children:t,modal:e=!1}=r,n=A(r,["children","modal"]);let s=yg(g({modal:e},n));return(0,Ie.jsx)(Td.Provider,{value:s,children:t})};function vg(o){var r=o,{as:t,children:e}=r,n=A(r,["as","children"]);let s=mi(),i=t||"button",a=e.ref,d=(0,H.useMergeRefs)([s.refs.setReference,a]);return(0,Ie.jsx)(i,x(g({ref:d,type:"button"},s.getReferenceProps(n)),{children:e}))}var Sg=Ge.forwardRef(function(r,o){var s=r,{style:e}=s,n=A(s,["style"]);let l=mi(),{context:i}=l,a=A(l,["context"]),d=(0,H.useMergeRefs)([a.refs.setFloating,o]);return i.open?(0,Ie.jsx)(H.FloatingPortal,{children:(0,Ie.jsx)(H.FloatingFocusManager,{context:i,modal:a.modal,children:(0,Ie.jsx)("div",x(g({ref:d,style:g(x(g({},a.floatingStyles),{zIndex:1e7}),e)},a.getFloatingProps(n)),{children:n.children}))})}):null});function xg(r){var s=r,{as:t,children:e,onClick:n}=s,o=A(s,["as","children","onClick"]);let{setOpen:i}=mi();return(0,Ie.jsx)(t||"button",x(g({type:"button",onClick:l=>{n(l),i(!1),l.stopPropagation()}},o),{children:e}))}function Ed({trigger:t,children:e,placement:n="top"}){return(0,Ie.jsxs)(Zt,{tooltip:!0,placement:n,children:[(0,Ie.jsxs)(Zt.Content,{className:Hr.tooltip,children:[e,(0,Ie.jsx)("div",{className:Hr.arrow})]}),(0,Ie.jsx)(Zt.Trigger,{className:Hr.tooltipTrigger,children:t})]})}Zt.Trigger=vg;Zt.Content=Sg;Zt.Button=xg;var ee=Zt;var ce=require("react/jsx-runtime"),bg=3,wg=90,kd=({children:t})=>{let e=S("CommandPalette",Ce);return(0,ce.jsx)("div",{className:e.listItemActions,children:t})};function fi(m){var h=m,{closeOnSelect:t=!0,lineClamp:e,tooltip:n,children:o,onClick:r,extra:s,onSourceClick:i,description:a,sources:d,id:l,styles:c,defaultSourcesAmount:u=bg}=h,p=A(h,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var q;let f=k(it),[y,b]=(0,Eo.useState)(!1),{selected:E,onChangeOpen:w}=Pt(),[I,N]=(0,Eo.useState)(!1),L=S("CommandPalette",Ce);function D(oe){r(oe),t&&w(!1)}return(0,Eo.useEffect)(()=>{N(E===l)},[E]),(0,ce.jsxs)("div",{className:(0,To.default)(L.listItem,l===E&&L.listItemSelected),children:[(0,ce.jsxs)(ee,{placement:"right-start",tooltip:!0,onOpenChange:N,open:I,children:[(0,ce.jsx)(ee.Trigger,x(g({className:L.listItemAction,"aria-disabled":(q=p.disabled)!=null?q:!1,onClick:D,"data-command-palette-item":!0,"data-item-id":l},p),{children:(0,ce.jsxs)("div",{className:L.listItemContent,children:[typeof o=="string"?(0,ce.jsx)("p",{className:(0,To.default)(L.listItemText,L.truncate,c==null?void 0:c.title),children:o}):o,a&&typeof a=="string"?(0,ce.jsx)(gi.Interweave,{tagName:"p",allowList:[],content:_r(a)?xd(a):a,className:(0,To.default)(L.listItemDescription,c==null?void 0:c.description,e?L.lineClamp:L.truncate)}):a]})})),n&&n.toString().length>wg&&(0,ce.jsx)(ee.Content,{className:L.listItemTooltip,children:(0,ce.jsx)(gi.Interweave,{className:L.listItemTooltipContent,allowList:["h1","h2","h3","h4","h5","h6","a","p"],tagName:"div",content:n})})]}),l===E&&s,d&&d.length>0&&(0,ce.jsxs)("div",{className:L.sources,children:[(0,ce.jsx)("span",{className:L.sourcesTitle,children:f("sources")}),d.slice(0,y?d.length:u).map(oe=>(0,ce.jsx)("a",{className:L.source,href:oe.url,target:"_blank",title:oe.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i==null?void 0:i(oe),children:oe.name},oe.url)),!y&&d.length>u&&(0,ce.jsx)("button",{className:(0,To.default)(L.source,L.sourceShowMore),type:"button",onClick:()=>b(!0),children:f("showMore",{amount:d.length-u})})]})]})}var ko=require("react/jsx-runtime"),Rd=()=>(0,ko.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,ko.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,ko.jsx)("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"})]});var Qt=require("react/jsx-runtime");function hi({children:t,title:e,id:n,onDismiss:o}){let r=k(it),s=S("CommandPalette",Ce),{page:i}=Pt();return i!==n?null:(0,Qt.jsxs)("div",{className:s.page,id:`page_${n}`,tabIndex:-1,children:[o&&(0,Qt.jsxs)("div",{className:s.pageNav,children:[(0,Qt.jsxs)("button",{className:s.pageBackButton,type:"button",onClick:o,children:[(0,Qt.jsx)(Rd,{}),r("back")]}),e&&(0,Qt.jsx)("h3",{className:s.pageTitle,children:e})]}),t]})}var Pd=require("react");var Ro=require("react/jsx-runtime"),Mn=()=>(0,Ro.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Ro.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Ro.jsx)("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"})]});var Ke=require("react/jsx-runtime");function Cg({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:r,value:s,selectedType:i},a){let d=S("CommandPalette",Ce);return(0,Ke.jsxs)("div",{className:d.search,children:[(0,Ke.jsx)("div",{className:d.searchIcon,children:(0,Ke.jsx)(Mn,{})}),(0,Ke.jsxs)("div",{className:d.searchInputWrapper,children:[(0,Ke.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:l=>{t(l.currentTarget.value)},onFocus:l=>{l.currentTarget.select()},className:d.searchInput,placeholder:n,value:s,type:"text",id:"command-palette-search-input",autoFocus:!0}),r&&r.length>0&&(0,Ke.jsx)("div",{className:d.selectWrapper,children:(0,Ke.jsxs)("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&&(0,Ke.jsx)("option",{children:o}),r.map(l=>(0,Ke.jsx)("option",{value:l.value,children:l.label},l.value))]})})]})]})}var Id=(0,Pd.forwardRef)(Cg);var yi=M(require("classnames"));var Kr=require("react/jsx-runtime"),Tg=r=>{var s=r,{onClick:t,shortKeys:e,children:n}=s,o=A(s,["onClick","shortKeys","children"]);let i=S("CommandPalette",Ce);return(0,Kr.jsxs)("button",x(g({type:"button"},o),{onClick:t,className:(0,yi.default)(i.actionButton,o.className,{[i.hasShortKeys]:e&&e.length>0}),children:[n,e==null?void 0:e.map(a=>(0,Kr.jsx)("span",{className:(0,yi.default)(i.actionShortcut,a===8629&&i.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},Ld=Tg;var Po=require("react/jsx-runtime"),Eg="[data-command-palette-item]";function Jt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:r,onChangeSearch:s,onChangeType:i,onChangeOpen:a,selectedType:d,types:l,children:c,isOpen:u,search:p,updateDeps:m=[]}){let[h,f]=(0,at.useState)(),y=(0,at.useRef)(null),b=()=>{r&&r(n),i(void 0),s(""),a(!1)},E=()=>{var _;if(o!==n&&r){r(n);return}if(d&&i){i(void 0),(_=y.current)==null||_.focus();return}if(p.length>0){s("");return}a(!1)},w=()=>{let _=I();_.length!==0&&f(_[0].dataset.itemId)},I=()=>Array.from(document.querySelectorAll(Eg)||[]),N=_=>document.querySelector(`[data-item-id=${_}]`),L=_=>{let U=N(_);U&&f(U.dataset.itemId)},D=_=>{let U=N(_);U&&U.scrollIntoView({behavior:"smooth"})},q=()=>{if(!h)return;let _=I(),U=N(h);if(!U)return;let Ee=_.indexOf(U),ge=_[Ee+1];ge!=null&&ge.dataset.itemId?L(ge.dataset.itemId):w()},oe=()=>{if(!h)return;let _=I(),U=N(h);if(!U)return;let Ee=_.indexOf(U),ge=_[Ee-1];ge!=null&&ge.dataset.itemId?L(ge.dataset.itemId):L(_[_.length-1].dataset.itemId)},be=(0,at.useCallback)(_=>{switch(_.key){case"ArrowDown":{_.preventDefault(),q();break}case"ArrowUp":{_.preventDefault(),oe();break}case"Enter":{if(h){let U=N(h);U==null||U.click()}break}}},[h]);return(0,at.useEffect)(()=>{w()},[p,o,d,u,...m]),(0,at.useEffect)(()=>{h&&D(h)},[h]),(0,Po.jsx)(Pr,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:E,onClose:b,onKeyDown:be,children:(0,Po.jsxs)(wd,{selected:h,setSelected:f,isOpen:u,onChangeOpen:a,page:o,children:[o===n&&(0,Po.jsx)(Id,{ref:y,onChange:s,onChangeType:i,placeholder:t,value:p,selectedType:d,types:l,typePlaceholder:e}),c]})})}Jt.Page=hi;Jt.List=pi;Jt.Image=fd;Jt.ListItem=fi;Jt.ListItemActions=kd;Jt.Button=Ld;var W=Jt;var Ad=require("react");function Md(t,e){(0,Ad.useEffect)(()=>{let n=o=>{var r;((r=navigator==null?void 0:navigator.platform)!=null&&r.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var Io=require("react"),Ur=require("react-redux");var Nn=require("@reduxjs/toolkit");var Nd={data:null,fetchState:"idle"},kg=t=>{var e;return(e=t.entities.data)!=null?e:null},Br=(0,Nn.createSelector)([kg,kn,kl],(t,e,n)=>{var a;let o=[],{visitorName:r}=n!=null?n:{},{agentName:s,agentNickname:i}=e!=null?e:{};return s&&s!==r&&o.push(s),i&&i!==r&&o.push(i),(a=t==null?void 0:t.filter(d=>!o.includes(d.text)))!=null?a:null}),Be=(0,Nn.createAsyncThunk)("entities/getEntities",(t,e)=>v(void 0,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let r=o.conversationQuery,s=yield r();return s.length===0?Promise.resolve([]):n.getEntities(s)})),Rg=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),Pg=(0,Nn.createSlice)({name:"entities",initialState:Nd,reducers:{},extraReducers:t=>{t.addCase(Be.pending,e=>{e.fetchState="loading"}).addCase(Be.rejected,e=>{e.fetchState="error"}).addCase(Be.fulfilled,(e,n)=>{e.fetchState="done",e.data=Rg(e.data?[...e.data,...n.payload]:n.payload)}).addCase(Z,()=>Nd)}}),Od=Pg.reducer;var vi={};re(vi,{enUS:()=>Ig,nlNL:()=>Lg});var Ig={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Lg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Dd={root:"dd-TYTKs",empty:"dd-AU7uT"};var On=require("react/jsx-runtime"),Ag=({onCopy:t})=>{let e=(0,Io.useRef)(null),n=S("EntitiesList",Dd),o=(0,Ur.useSelector)(Br),{setSelected:r}=Pt(),s=k(vi),i=(0,Ur.useDispatch)();return(0,Io.useEffect)(()=>{i(Be())},[]),(0,Io.useEffect)(()=>{e.current&&(e.current.focus(),r("entity-0"))},[e]),(0,On.jsxs)("div",{className:n.root,ref:e,tabIndex:-1,children:[o&&o.length>0&&(0,On.jsx)(W.List,{children:o.map((a,d)=>(0,On.jsx)(W.ListItem,{id:`entity-${d}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),o&&o.length===0&&(0,On.jsx)("p",{className:n.empty,children:s("noResults")})]})},_d=Ag;var nn=M(require("react")),tc=require("react-redux");var Dn=require("react"),Fd=require("react-redux");function lt(t,e){let n=(0,Dn.useRef)(t);n.current=t;let[o,r]=(0,Dn.useState)(void 0),[s,i]=(0,Dn.useState)(void 0),[a,d]=(0,Dn.useState)("idle"),l=(0,Fd.useDispatch)();return{error:s,state:a,data:o,call:p=>v(this,null,function*(){d("loading"),yield l(n.current(p)).unwrap().then(m=>{r(m),d("done"),e!=null&&e.onSuccess&&(e==null||e.onSuccess(m))}).catch(m=>{i(m),d("error"),e!=null&&e.onError&&(e==null||e.onError(m))})}),reset:()=>{d("idle"),r(void 0),i(void 0)}}}var Vr=M(require("classnames")),zd=require("react");var Si=require("react/jsx-runtime"),xi=t=>(0,Si.jsx)("svg",x(g({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Si.jsx)("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"})}));var bi=require("react/jsx-runtime"),Hd=t=>(0,bi.jsx)("svg",x(g({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,bi.jsx)("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 _n(t,e){var r;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(s=>{n.classList.add(s)}),n.addEventListener("animationend",()=>n.remove()),(r=t.parentElement)==null||r.appendChild(n)}var wi={};re(wi,{enUS:()=>Mg,nlNL:()=>Ng});var Mg={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},Ng={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Ud=require("react-redux");var Kd=require("@reduxjs/toolkit");function Bd(t){return(0,Kd.createAsyncThunk)("analytics/logEvent",(e,n)=>{var s,i,a;let o=(i=(s=n.getState())==null?void 0:s.conversation.current)==null?void 0:i.id,r=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,x(g({conversationId:o},r),{data:e.data}))})(t)}function Q(){let t=(0,Ud.useDispatch)();return(e,n)=>v(this,null,function*(){yield t(Bd({name:e,data:n}))})}var Vd={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};var Ci=require("react-redux");var Fn=t=>e=>{let{passwordlessToken:{token:n},settings:{isEmbedded:o,adminUrl:r}}=e,s=r||window.location.origin;return o&&!n?null:o&&n?`${s}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${s}${t}`};var dt=require("react/jsx-runtime"),Og=({eventName:t,eventData:e,feedbackType:n,feedbackText:o})=>{let r=S("FeedbackThumbs",Vd),s=C("enableFeedbackForm"),i=(0,Ci.useSelector)(qe),a=(0,Ci.useSelector)(Fn(`/admin/feedback?conversationId=${i}&type=${n}&text=${o}&data=${JSON.stringify(e)}`)),d=k(wi),l=Q(),[c,u]=(0,zd.useState)(null),p=h=>{h.stopPropagation(),_n(h.target,r.fadeup),u("up"),l(t,x(g({},e),{rating:"up"}))},m=h=>{h.stopPropagation(),_n(h.target,r.fadedown),u("down"),l(t,x(g({},e),{rating:"down"}))};return(0,dt.jsxs)("div",{className:r.thumbs,children:[(0,dt.jsx)(F.Button,{title:d("thumbsUp"),onClick:p,icon:(0,dt.jsx)(Hd,{}),className:(0,Vr.default)(r.thumbsUp,c==="up"&&r.selected),disabled:!!c}),s&&a?(0,dt.jsx)(F.Button,{as:"a",title:d("thumbsDown"),href:a,target:"_blank",rel:"noreferrer",onClick:m,icon:(0,dt.jsx)(xi,{}),className:(0,Vr.default)(r.thumbsDown,c==="down"&&r.selected),disabled:!!c}):(0,dt.jsx)(F.Button,{title:d("thumbsDown"),onClick:m,icon:(0,dt.jsx)(xi,{}),className:(0,Vr.default)(r.thumbsDown,c==="down"&&r.selected),disabled:!!c})]})},Yt=Og;var Lo=require("react/jsx-runtime"),Wd=()=>(0,Lo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Lo.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Lo.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var Ti={};re(Ti,{enUS:()=>Dg,nlNL:()=>_g});var Dg={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},_g={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var qd={root:"dd-fxP4c",title:"dd-vDbMh",empty:"dd-sB0lz",status:"dd--oZ1C",form:"dd-t0hnD",input:"dd-i1v3W",submit:"dd-oo2Oa",question:"dd-WvK17",answer:"dd-HAHcU",alignRight:"dd-oxrX3",listItemFeedback:"dd-POUal"};var Yd=M(require("dompurify")),pt=require("react");var ki=M(require("classnames")),Le=require("react");var zr=require("react"),Fg=["bottom","height","left","right","top","width"],Hg=(t={},e={})=>Fg.some(n=>t[n]!==e[n]),ct=new Map,jd,$d=()=>{let t=[],e=[];ct.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let r=o.getBoundingClientRect();Hg(r,n.rect)&&(n.rect=r,t.push(n))}),e.forEach(n=>{ct.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),jd=window.requestAnimationFrame($d)};function Kg(t,e){return{observe(){let n=ct.size===0;if(ct.has(t)){let o=ct.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else ct.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&$d()},unobserve(){let n=ct.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||ct.delete(t),ct.size||cancelAnimationFrame(jd)}}}}function Ei(t){let[e,n]=(0,zr.useState)(null);return(0,zr.useLayoutEffect)(()=>{if(!t.current)return;let o=Kg(t.current,r=>{n(r)});return o.observe(),()=>{o.unobserve()}},[t]),e}var Hn=require("react"),Zd=require("react-dom");var Gd=require("react");function It(t){(0,Gd.useEffect)(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function en(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Xd={root:"dd-r-dgo"};var Qd=({children:t,parentNode:e})=>{let[n,o]=(0,Hn.useState)(null),r=(0,Hn.useContext)(Yn);return(0,Hn.useLayoutEffect)(()=>{let s=document.createElement("div");return en(s),s.classList.add(Xd.root),r!=null&&r.portalRootNode&&s.classList.add(r==null?void 0:r.portalRootNode),(e||document.body).appendChild(s),o(s),()=>{s.isConnected&&s.remove()}},[]),n?(0,Zd.createPortal)(t,n):null};var Xe={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};var Wr=require("react/jsx-runtime"),qr=(t=!1)=>{let[e,n]=(0,Le.useState)(t),o=(0,Le.useCallback)(()=>n(!0),[]),r=(0,Le.useCallback)(()=>n(!1),[]),s=(0,Le.useCallback)(()=>n(a=>!a),[]),i=(0,Le.useRef)(null);return{opened:e,open:o,close:r,toggle:s,triggerRef:i}};function Ri(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,r=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:r,height:t.height,width:t.width}}var Kn=l=>{var c=l,{className:t,triggerRef:e,boundaryRef:n=(0,Le.createRef)(),position:o="above",align:r="center",children:s,toStyle:i=Ri,parentNode:a}=c,d=A(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let u=Ei(e),p=Ei(n),m=(0,Le.useMemo)(()=>i(u,p,0),[u,p]);return(0,Wr.jsx)(Qd,{parentNode:a,children:(0,Wr.jsx)("div",x(g({className:(0,ki.default)(Xe.ref,{[Xe.positionAbove]:o==="above",[Xe.positionBelow]:o==="below",[Xe.positionLeft]:o==="left",[Xe.positionRight]:o==="right",[Xe.alignStart]:r==="start",[Xe.alignCenter]:r==="center",[Xe.alignEnd]:r==="end"}),style:m},d),{role:"dialog",children:(0,Wr.jsx)("div",{className:(0,ki.default)(t,Xe.root),children:s})}))})};var Jd={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};var ec=require("marked"),Ue=require("react/jsx-runtime");function Bg(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 Pi(t){var n,o;let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(r=>r.remove()),(o=(n=e.textContent)==null?void 0:n.trim())!=null?o:""}function Ug(t){return t.replace(/\r\n/g,`
4
+ `)}var Vg=({content:t,useLabel:e,copyLabel:n,onCopy:o,onUse:r})=>{let s=S("Markdown",Jd),i=(0,pt.useRef)(null),[a,d]=(0,pt.useState)(null),l=(0,pt.useMemo)(()=>{let f=ec.marked.parse(Ug(t));return Yd.default.sanitize(f.toString()).replaceAll("</code>",`${Bg(s.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[t]),c=f=>{var E;let y=f.target,b=!!((E=i.current)!=null&&E.querySelector("code"));if(["A","BUTTON"].includes(y.tagName)){d(null);return}a||b&&y.tagName!=="CODE"||!b&&y!==i.current||(y.addEventListener("mouseleave",()=>d(null),{once:!0}),d(y))},u=()=>{if(!a)return;d(null);let f=a.querySelector("button");f&&(_n(f,s.fadeup),o==null||o(Pi(a)))},p=f=>{let y=f.target;if(y.tagName==="A"){f.stopPropagation();return}"copyIcon"in y.dataset&&(_n(y,s.fadeup),o==null||o(Pi(y.parentElement)))},m=()=>{!a||!r||(d(null),r(Pi(a)))},h=f=>{if(f===null)return;let y=f.getBoundingClientRect();y.left<0?f.style.transform=`translateX(${-y.left+2}px)`:y.right>window.innerWidth&&(f.style.transform=`translateX(${window.innerWidth-y.right-2}px)`)};return(0,Ue.jsxs)(pt.Fragment,{children:[a&&(o||r)&&(0,Ue.jsxs)(Kn,{triggerRef:{current:a},className:s.popover,parentNode:a,children:[(0,Ue.jsxs)("div",{className:s.options,ref:h,children:[o&&(0,Ue.jsx)("button",{type:"button",className:s.option,onClick:u,children:n}),r&&(0,Ue.jsxs)(pt.Fragment,{children:[(0,Ue.jsx)("div",{className:s.divider}),(0,Ue.jsx)("button",{type:"button",className:s.option,onClick:m,children:e})]})]}),(0,Ue.jsx)("div",{className:s.arrow})]}),(0,Ue.jsx)("div",{ref:i,"data-testid":"widget-markdown-content",className:s.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:c,onClick:p})]})},tn=Vg;var ie=require("react/jsx-runtime"),zg=({threadId:t,onEvaluate:e,onUse:n,onResetQuestion:o,question:r})=>{var y;let[s,i]=nn.default.useState(""),{setSelected:a}=Pt(),d=(0,nn.useRef)(null),l=S("KnowledgeSearchStyles",qd),c=k(Ti),u=Q(),p=(y=(0,tc.useSelector)(xo(t!=null?t:-1)))!=null?y:[],m=lt(e,{onSuccess(b){u("knowledge assist question answered",{question:s||r||"",sources:b.answer.sources,answer:b.answer.answer,isFollowUpQuestion:p.length>=1,isAutoInitiated:!s&&!!r}),a(`knowledge-assist-${p.length}`),i("")}}),h=b=>v(void 0,null,function*(){b.preventDefault(),b.stopPropagation(),s!==""&&m.call(s)}),f=(b,E)=>{u("knowledge assist source viewed",{question:E,sourceViewed:b.url||b.name})};return(0,nn.useEffect)(()=>{var b;r&&m.state==="idle"?m.call(r):(b=d.current)==null||b.focus()},[d,m.state]),(0,nn.useEffect)(()=>{d.current&&d.current.scrollIntoView({behavior:"smooth"})},[d,p]),(0,ie.jsxs)("div",{className:l.root,children:[p.length>0&&(0,ie.jsx)("div",{className:l.alignRight,children:(0,ie.jsx)(W.Button,{onClick:o,children:c("reset")})}),p.map(({question:b,answer:E},w)=>(0,ie.jsx)(W.List,{children:(0,ie.jsx)(W.ListItem,{id:`knowledge-assist-${w}`,"data-testid":"knowledge-search-answer",description:(0,ie.jsx)(tn,{content:E.answer}),closeOnSelect:!0,onClick:()=>n(E.answer),onSourceClick:I=>f(I,b),sources:E.sources,styles:{title:l.question,description:l.answer},extra:(0,ie.jsx)("div",{className:l.listItemFeedback,children:(0,ie.jsx)(Yt,{feedbackText:E.answer,feedbackType:"knowledge-assist-answer",eventName:"knowledge assist feedback",eventData:g({question:b,isAgent:r!==b,isFollowUpQuestion:p.length>1},E)})}),children:b})},`${E.answer}_${w}`)),m.state==="loading"&&(0,ie.jsx)("p",{className:l.status,children:c("loading")}),m.state==="error"&&(0,ie.jsx)("p",{className:l.status,children:c("error")}),(0,ie.jsxs)("form",{className:l.form,onSubmit:h,children:[(0,ie.jsx)("input",{ref:d,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{a(void 0)},onChange:b=>{a(void 0),i(b.target.value)}}),(0,ie.jsx)("button",{type:"submit",className:l.submit,disabled:m.state==="loading",children:(0,ie.jsx)(Wd,{})})]})]})},nc=zg;var Ii=require("react/jsx-runtime"),jr=t=>(0,Ii.jsx)("svg",x(g({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},t),{children:(0,Ii.jsx)("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 Ao={};re(Ao,{enUS:()=>Wg,nlNL:()=>qg});var Wg={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"}]},qg={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 Li=require("react-redux");var oc=require("react-redux");var $r={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var on=require("react/jsx-runtime"),jg=({suggestion:t,source:e,context:n})=>{let o=k(Ao),r=(0,Li.useSelector)(qe),s=(0,oc.useDispatch)(),i=C("enableSuggestionFeedback"),a=`${t.text}`,d=(0,Li.useSelector)(Fn(`/admin/feedback?conversationId=${r}&type=${e}&text=${a}&data=${JSON.stringify({context:n})}`)),l=()=>{s(ot({name:"suggestion feedback",data:{text:t.text,source:e,context:n},options:{includeConversationData:!0}}))};return!i||!d?null:(0,on.jsxs)(ee,{placement:"top-end",children:[(0,on.jsx)(ee.Trigger,{className:$r.trigger,children:(0,on.jsx)(jr,{"data-testid":"feedback-dropdown-trigger"})}),(0,on.jsx)(ee.Content,{className:$r.content,children:(0,on.jsx)(ee.Button,{className:$r.item,as:"a",onClick:l,target:"_blank",href:d,children:o("giveFeedback")})})]})},Gr=jg;var Mo={};re(Mo,{enUS:()=>$g,nlNL:()=>Gg});var $g={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?"}]},Gg={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?"}]};var uc=require("react"),Qr=require("react-redux");var rn=require("@reduxjs/toolkit");var Xg=["{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}"],Zg=new RegExp(Xg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function rc(t,e){let n=t.split(Zg),o=0,r=[];for(let s=0;s<n.length;s++){let i=n[s];if(r.push(i),s===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[s+1],d=s===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);r.push(c),o=l}return r.join("")}function sc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var ac={suggestions:[],fetchState:"idle"},ic={default:ac},lc=t=>e=>{var n,o;return(o=(n=e.textSuggestions[t])==null?void 0:n.suggestions)!=null?o:[]},Xr=t=>t.textSuggestions,dc=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Zr=(0,rn.createAction)("textSuggestions/refresh"),Ve=(0,rn.createAsyncThunk)("textSuggestions/recommendations",(t,e)=>v(void 0,null,function*(){var l,c;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:r}=o.info,{textSuggestionsCount:s,inlineSuggestions:i}=o.settings,a=Cn(o),d=[];if(t==="sticky-messages"){let u=(l=o.profile.data)==null?void 0:l.code;if(!u)throw new Error("No current profile to fetch pinned messages");d=yield n.getPinnedMessages(u)}else{let u=(c=o.conversation.current)==null?void 0:c.id;if(!u)throw new Error("No current conversation to fetch text suggestions");d=yield n.getTextSuggestions(u,ro(o),t)}if(r&&(d=d.map(u=>g(x(g({},u),{text:Se(u.text,r)}),u.title?{title:Se(u.title,r)}:{}))),t==="default"){let u=i?d.filter(dc(a)):d;e.dispatch(Et(u.slice(0,s)))}return d})),No=(0,rn.createAsyncThunk)("textSuggestions/autocompletions",(t,e)=>v(void 0,null,function*(){var c;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=(c=o.conversation.current)==null?void 0:c.id,{platformVariables:s}=o.info,{textSuggestionsCount:i,deanonymize:a,inlineSuggestions:d}=o.settings;if(!r)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(r,x(g({},ro(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return d&&(l=l.filter(dc(t))),s&&(l=l.map(u=>x(g({},u),{text:Se(u.text,s)}))),a&&(l=l.map(u=>x(g({},u),{text:u.source!=="trie-with-typos"?rc(u.text,t):u.text}))),l=sc(l,i),e.dispatch(Et(l)),l})),cc=(0,rn.createSlice)({name:"textSuggestions",initialState:ic,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(Ve.pending,(e,n)=>{let o=n.meta.arg,r=e[o]||ac;return x(g({},e),{[o]:x(g({},r),{fetchState:"loading"})})}).addCase(Ve.rejected,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="error")}).addCase(Ve.fulfilled,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="done",e[o].suggestions=n.payload)}).addCase(No.pending,e=>{e.default.fetchState="loading"}).addCase(No.rejected,e=>{e.default.fetchState="error"}).addCase(No.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(Z,()=>ic)}}),{setTextSuggestions:_C}=cc.actions,pc=cc.reducer;var sn=require("react/jsx-runtime"),Qg=({types:t,commands:e,onClick:n})=>{let o=(0,Qr.useDispatch)(),r=k(Mo),s=(0,Qr.useSelector)(Xr);return(0,uc.useEffect)(()=>{t.forEach(({type:i})=>{(!s[i]||s[i].suggestions.length===0)&&o(Ve(i))})},[]),(0,sn.jsxs)("div",{children:[e.length>0&&(0,sn.jsx)(W.List,{heading:r("commands"),children:e.map((i,a)=>(0,sn.jsx)(W.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:i.onClick,children:i.label},i.label))}),t.map(({type:i,title:a})=>{var d;return(0,sn.jsx)(W.List,{heading:a,orientation:"vertical",children:(d=s[i])==null?void 0:d.suggestions.map((l,c)=>(0,sn.jsx)(W.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)})]})},mc=Qg;var te=require("react/jsx-runtime"),Yg=200,ef=5,tf=4,Ai=(t,e,n)=>t.slice(0,n?10:e.toLowerCase()==="image"?tf:ef),nf=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),of=()=>{var ya,va,Sa;let t=(0,Ae.useDispatch)(),e=xe(),n=k(Mo),[o,r]=(0,pe.useState)(!1),[s,i]=(0,pe.useState)(""),[a,d]=(0,pe.useState)(null),l=(0,Ae.useSelector)(Ol),c=(0,Ae.useSelector)(Gt),[u,p]=(0,pe.useState)(),m=(0,Ae.useSelector)(de),h=C("showSearch"),f=C("enableSuggestionFeedback"),y=C("showEntitiesCommand"),b=C("showKnowledgeSearch"),E=C("showImageSearch"),w=C("searchTriggerKey"),I=(0,Ae.useSelector)(Nr),N=(0,Ae.useSelector)(Or),L=(0,Ae.useSelector)(ld),D=(0,Ae.useSelector)(Xs),q=(0,Ae.useSelector)(Dl),oe=(0,Ae.useSelector)(Nl),be=((Sa=(va=(ya=c==null?void 0:c.uiConfig)==null?void 0:ya.search)==null?void 0:va.initialTypes)==null?void 0:Sa.filter(({isActive:R})=>R))||[],_=Q(),U=(0,pe.useMemo)(()=>{let R=fe=>Ai(D.filter(G=>G.type===fe.toUpperCase()),fe,u),$=(L==null?void 0:L.map(fe=>({value:fe.code.toUpperCase(),label:`${fe.name}s`,list:R(fe.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if($.push({value:"PERSONAL",label:n("personalSuggestions"),list:R("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:R("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:R("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),E&&$.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:R("IMAGE"),listOrientation:"horizontal"}),be.length===0)return $;let Ft=be.map(fe=>$.find(G=>G.value.toLowerCase()===fe.type)).filter(fe=>!!fe),Hs=$.filter(fe=>!Ft.find(G=>G.value===fe.value));return[...Ft,...Hs]},[L,be,E,u]),Ee=[{label:n("entitiesClipboard"),onClick:()=>t(rt("entities")),shouldShow:y&&nf(n("entitiesClipboard"),s)},{label:s?`${n("knowledgeAssist")}: ${s}`:n("knowledgeAssist"),onClick:()=>{t(rt("knowledgeAssist")),_("open knowledge assistant",{via:"search-command"})},shouldShow:b}].filter(R=>R.shouldShow).filter(()=>!u),ge=(0,pe.useCallback)((0,gc.default)((R,$)=>{t(Wt({query:R,type:$,tags:["search-overlay"],size:u?50:20}))},Yg),[u]),ha=(0,pe.useCallback)((R,$)=>{switch($.type){case"IMAGE":e.send(Qs,{suggestion:$});break;default:e.send(je,{text:R,suggestion:$})}t(Re(!1))},[t]),qu=R=>{$e(R.text),t(ot({name:"entity copied",data:{entity:R,type:"copy"}})),t(Re(!1))},ju=R=>{e.send(je,{text:R,suggestion:{source:"knowledge-assist",text:R}}),t(ot({name:"answer used",data:{originalText:R},options:{includeConversationData:!0}})),i(""),a&&t(In(a)),t(rt("search")),t(Re(!1))},$u=R=>{let $={input:R,threadId:a,onNewThreadId:Ft=>d(Ft)};if(N)return jt(g({assistantCode:N},$));if(I)return $t(g({assistantCode:I},$))};function Qo(R){return $=>{o?window.confirm(n("warning"))&&(R($),r(!1)):R($)}}return(0,pe.useEffect)(()=>{s?ge(s,u):t(vr())},[s,u]),(0,pe.useEffect)(()=>{m&&t(bo())},[m]),Md(w,()=>{t(Re(!0)),_("open search",{via:"ctrl+k"})}),!h||!c?null:(0,te.jsxs)(W,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:Qo(R=>t(Re(R))),onChangeType:R=>p(R),onChangePage:Qo(R=>t(rt(R))),selectedType:u,search:s,page:l,isOpen:oe,types:U,updateDeps:[D],children:[(0,te.jsxs)(W.Page,{id:"search",children:[s.length===0&&(0,te.jsx)(mc,{types:be,commands:Ee,onClick:ha}),s.length>0&&(0,te.jsxs)(pe.Fragment,{children:[Ee.length>0&&(0,te.jsx)(W.List,{heading:n("commands"),children:Ee.map((R,$)=>(0,te.jsx)(W.ListItem,{closeOnSelect:!1,onClick:R.onClick,id:`commands-${$}`,children:R.label},R.label))}),U.map(({value:R,label:$,list:Ft,lineClamp:Hs,listOrientation:fe})=>(0,te.jsx)(W.List,{heading:$,orientation:fe==="horizontal"?"horizontal":"vertical",onShowAll:()=>p(R),hasMore:!u&&q[R.toLowerCase()]>Ai(Ft,R,u).length,children:Ai(Ft,R,u).map(G=>(0,te.jsx)(W.ListItem,{id:`${R}-${G.id}`,closeOnSelect:!1,lineClamp:Hs,onClick:()=>ha(G.text,G),description:R!=="IMAGE"?G.title&&G.text:void 0,tooltip:G.text,extra:f&&(0,te.jsx)(W.ListItemActions,{children:(0,te.jsx)(Gr,{context:s,source:"search",suggestion:G})}),children:R==="IMAGE"?(0,te.jsx)(W.Image,{title:G.title||G.text,src:G.image}):G.title||G.text},`${G.id}-${G.text}`))},R))]})]}),(0,te.jsx)(W.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Qo(()=>{t(rt("search"))}),children:(0,te.jsx)(_d,{onCopy:qu})}),(I!=null?I:N)&&(0,te.jsx)(W.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Qo(()=>{a&&t(In(a)),t(rt("search"))}),children:(0,te.jsx)(nc,{threadId:a,onEvaluate:$u,question:s,onUse:ju,onResetQuestion:()=>{a&&t(In(a)),i(""),d(null)}})})]})},fc=of;var Oo=require("react/jsx-runtime"),rf=()=>{let t=C("showSearch"),e=C("isEmbedded");return(0,Oo.jsxs)(hc.Fragment,{children:[t&&(0,Oo.jsx)(fc,{}),e&&(0,Oo.jsx)(td,{})]})},yc=rf;var bc=M(require("classnames")),wc=require("react-redux");var Jr=require("react/jsx-runtime"),vc=({className:t})=>(0,Jr.jsx)("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:(0,Jr.jsx)("g",{children:(0,Jr.jsx)("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
5
5
  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
6
6
  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
7
7
  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
8
- c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Ai=require("react/jsx-runtime"),lf={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Sc=({className:t,color:e})=>(0,Ai.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ai.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:lf[e||"pink"]})});var bc={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var Mi={};re(Mi,{enUS:()=>df,nlNL:()=>cf});var df={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},cf={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Tc=require("react-redux"),an=require("react/jsx-runtime"),Ec=({onLogIn:t})=>{let e=k(Mi),n=C("floatingMenu"),o=C("productName"),r=(0,Tc.useDispatch)(),s=(0,Cc.useSelector)(de),i=x("FloatingMenu",bc);if(s===null||n===!1)return null;let l=()=>{s===!0?r(Re(!0)):t()};return(0,an.jsxs)("button",{type:"button",className:(0,wc.default)(i.root,{[i.isLoggedIn]:s,[i.isLoggedOut]:!s}),onClick:l,children:[(0,an.jsx)("div",{className:i.text,children:e(s?"search":"signin",{productName:o})}),(0,an.jsxs)("div",{className:i.icon,children:[(0,an.jsx)(Sc,{className:i.logo,color:"pink"}),s===!1&&(0,an.jsx)(xc,{className:i.lock})]})]})};var ns=require("react"),ut=require("react-redux");function Ze(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:r,selection:s}=t.input;return s.start!==s.end?!1:s.end>=r.length?!0:e?n&&new RegExp(n).test(r.substring(s.end))||o&&new RegExp(o).test(r.substring(0,s.end))?!0:n===!1&&o===!1:!1}var kc=require("@reduxjs/toolkit"),pf={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Yr=({ui:t})=>t.overlayCollapsed,Rc=(0,kc.createSlice)({name:"ui",initialState:pf,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:Do,setInputFocus:es,setOverlayCollapsed:Lt,setOpenOverlayWhenTyping:Pc,setOverlayCollapsedUserOverwrite:Ic}=Rc.actions,Lc=Rc.reducer;var _c=require("react");var Oc=require("interweave"),At=require("react"),_o=require("react-redux");var Ac=require("react");function Mc(t,e,n){(0,Ac.useEffect)(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var Nc={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var ln=require("react/jsx-runtime"),mf=["search","personal-collection-search","search-autocomplete"];function gf(t,e,n,o={}){var s;let r="";return mf.includes(e)?r=xd(pi(t,n,{stripAgentPart:!0}),(s=o.searchKeywords)!=null?s:[n]):r=pi(t,n,o),o.placeholders===!0&&(r=Sd(r)),r}var ff=()=>{},hf=({selected:t,suggestion:e})=>{let n=C("inlineSuggestions"),o=(0,_o.useSelector)(Cn),[r,s]=(0,At.useState)(!1),i=C("enableSuggestionFeedback"),l=(0,_o.useSelector)(p=>p.input.text),d=(0,_o.useDispatch)(),a=x("TextSuggestion",Nc),c=(0,At.useRef)(null);(0,At.useEffect)(()=>{let p=setTimeout(()=>{d(hl({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(p)}},[e]),Mc(c,"click",()=>{d(De({suggestion:e,text:e.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,At.useMemo)(()=>gf(e.text,e.source,o,{stripAgentPart:n,placeholders:!0,searchKeywords:e.searchKeywords}),[n,e.text,e.source,o,e.searchKeywords]);return e.source==="gpt"&&!n?null:(0,ln.jsxs)("div",{className:a.root,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[(0,ln.jsx)(F,{ref:c,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:ff,children:(0,ln.jsx)(Oc.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),i&&r&&(0,ln.jsx)("div",{className:a.actions,children:(0,ln.jsx)(Gr,{source:"overlay",context:l,suggestion:e})})]})},Dc=hf;var Fc=require("react/jsx-runtime"),yf=({suggestions:t,selectedIndex:e,reverse:n})=>(0,_c.useMemo)(()=>{let r=t.map((s,i)=>(0,Fc.jsx)(Dc,{index:i,selected:i===e,suggestion:s},`${s.text}-${s.source}`));return n?r.reverse():r},[t,e,n]),ts=yf;var Hc={root:"dd-PfvRI",paper:"dd-HYlyY"};var Fo=require("react/jsx-runtime"),vf=({textSuggestions:t,selectedIndex:e})=>{let n=(0,ns.useRef)(null),o=x("InlineSuggestionsOverlay",Hc),r=(0,ut.useSelector)(Ze),s=(0,ut.useDispatch)(),i=(0,ut.useSelector)(de),l=(0,ut.useSelector)(wn),d=(0,ut.useSelector)(Yr),a=C("showTextSuggestions");return It(()=>{setTimeout(()=>{s(Lt({collapse:!0,skipWhenInputFocus:!0}))})}),(0,ns.useEffect)(()=>{let c=n.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`}),d||!r||!a||t.length===0||i!==!0||l===!1?null:(0,Fo.jsx)("div",{className:o.root,"data-variant":"inline",children:(0,Fo.jsx)("div",{ref:n,className:o.paper,children:(0,Fo.jsx)(ve,{children:(0,Fo.jsx)(ts,{suggestions:t,selectedIndex:e})})})})},xf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Kc=(0,ut.connect)(xf)(vf);var Bc=require("react-redux");var Ho=require("react/jsx-runtime"),Sf=({children:t})=>{let n=C("locale").replace("-","");return(0,Ho.jsx)(si.Provider,{value:n,children:t})},bf=({store:t,customStyles:e={},children:n})=>(0,Ho.jsx)(Bc.Provider,{store:t,children:(0,Ho.jsx)(Sf,{children:(0,Ho.jsx)(Yn.Provider,{value:e,children:n})})}),Mt=bf;var rs=M(require("classnames")),Bn=require("react"),gt=require("react-redux");var Uc=require("react");function Vc(t,e){let[n,o]=(0,Uc.useState)(()=>{if(typeof window=="undefined")return e;try{let s=window.localStorage.getItem(t);return s?JSON.parse(s):e}catch(s){return T.error(s),e}});return[n,s=>{try{let i=s instanceof Function?s(n):s;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){T.error(i)}}]}var zc=()=>/Mac/i.test(navigator.platform);var jc=M(require("classnames")),mt=require("react");var Ni={};re(Ni,{enUS:()=>wf,nlNL:()=>Cf});var wf={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"}]}]},Cf={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 Wc={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var Nt=require("react/jsx-runtime"),Oi=(t,e,n)=>o=>(0,Nt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),Tf=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o,onLogIn:r})=>{let s=k(Ni),i=Se(),l=x("Login",Wc),d=C("productName"),a=(0,mt.useCallback)(v=>{v.preventDefault(),o&&o(Number.parseInt(v.target.value,10))},[]),c=(0,mt.useCallback)(v=>{v.preventDefault(),i.send(Pn,!0)},[e]),u=(0,mt.useMemo)(()=>v=>(0,Nt.jsx)("a",{onClick:E=>{E.preventDefault(),r()},href:e,className:l.anchor,target:"_blank",rel:"noreferrer",children:v},"login"),[e]),p=(0,mt.useCallback)(v=>(0,Nt.jsx)("button",{type:"button",className:l.anchorButton,onClick:c,children:v},"prompt"),[c]),{min:m,hour:f,day:h}=(0,mt.useMemo)(()=>({min:Oi(l,60*10,a),hour:Oi(l,60*60,a),day:Oi(l,60*60*12,a)}),[]);return(0,Nt.jsxs)("div",{className:(0,jc.default)(t,l.root),children:[s("loginPlease",{login:n?p:u,productName:d}),o&&(0,Nt.jsxs)(mt.Fragment,{children:[(0,Nt.jsx)("br",{}),s("snooze",{min:m,hour:f,day:h})]})]})},os=Tf;var $c=require("react-redux");var qc={root:"dd-DoQhb",text:"dd-Jwnev"};var Ko=require("react/jsx-runtime"),Ef=({title:t})=>{let e=x("SearchTrigger",qc),n=(0,$c.useDispatch)(),o=Q();return(0,Ko.jsxs)("button",{type:"button",className:e.root,onClick:()=>{n(Re(!0)),o("open search",{via:"autocomplete-overlay"})},children:[(0,Ko.jsx)(Mn,{}),(0,Ko.jsx)("span",{className:e.text,children:t})]})},Gc=Ef;var Di={};re(Di,{enUS:()=>kf,nlNL:()=>Rf});var kf={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"}]},Rf={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}]};var Xc={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2"};var V=require("react/jsx-runtime"),Pf=({textSuggestions:t,selectedIndex:e,onLogIn:n})=>{let o=x("SuggestionsOverlay",Xc),r=k(Di),s=(0,gt.useSelector)(Ze),i=fl(),l=(0,gt.useDispatch)(),d=(0,Bn.useRef)(null),a=C("searchTriggerKey"),c=C("productName"),u=(0,gt.useSelector)(Yr),p=(0,gt.useSelector)(de),m=(0,gt.useSelector)(wn),[f,h]=(0,Bn.useState)(null),v=C("showSearch"),w=C("showTextSuggestions"),E=C("adminUrl"),b=C("isEmbedded"),[I,N]=Vc("dd-snooze-until-ms",0),L=u||I>Date.now(),D=t.filter(be=>be.source!=="gpt").length,j=()=>{L&&N(0),l(Ic(!L))},oe=be=>{let _=Date.now()+be*1e3;N(_),T.info(`Snooze until: ${new Date(_)}`),l(Lt({collapse:!0}))};return(0,Bn.useEffect)(()=>{D===0&&h(null)},[t,D]),It(()=>{l(Lt({collapse:!0,skipWhenInputFocus:!0}))}),p===null||m===!1?null:p===!1?(0,V.jsxs)("div",{ref:d,className:(0,rs.default)(o.root,{[o.isCollapsed]:L}),children:[!L&&(0,V.jsxs)("div",{className:o.triggers,children:[(0,V.jsx)("div",{style:{flex:1}}),(0,V.jsx)("div",{className:o.triggersRight,children:(0,V.jsx)(Bt,{className:o.toggleButton,title:r("collapse"),onClick:j,isCollapsed:!1})})]}),(0,V.jsx)("div",{className:o.toggleButtonWrapper,children:(0,V.jsx)(Bt,{className:o.toggleButton,title:r("open",{productName:c}),onClick:j,isCollapsed:!0})}),(0,V.jsx)("div",{className:o.collapsible,children:(0,V.jsx)(os,{loginUrl:E,isEmbedded:b,onLogIn:n,onSnooze:oe})})]}):!i||!s?null:(0,V.jsxs)("div",{ref:d,className:(0,rs.default)(o.root,{[o.isCollapsed]:L}),children:[!L&&(0,V.jsxs)("div",{className:o.triggers,children:[(0,V.jsx)("div",{style:{flex:1},children:v&&(0,V.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>h(r(zc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:a.toUpperCase()})),onMouseLeave:()=>h(null),children:(0,V.jsx)(Gc,{title:r("search")})})}),(0,V.jsxs)("div",{className:o.triggersRight,onFocus:()=>{},children:[(0,V.jsx)("div",{className:(0,rs.default)(!f&&o.hintsHidden,o.hints),children:f}),(0,V.jsx)(Bt,{className:o.toggleButton,title:r("collapse"),onClick:j,isCollapsed:!1})]})]}),(0,V.jsx)("div",{className:o.toggleButtonWrapper,children:(0,V.jsx)(Bt,{className:o.toggleButton,title:r("open",{productName:c}),onClick:j,isCollapsed:!0})}),D>0&&w&&(0,V.jsx)("div",{className:o.collapsible,onFocus:()=>{},children:(0,V.jsx)(ve,{children:(0,V.jsx)(ts,{suggestions:t,selectedIndex:e,reverse:!0})})})]})},If=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Zc=(0,gt.connect)(If)(Pf);var hs=M(require("classnames")),hp=require("interweave"),yt=require("react"),yp=require("react-redux");var Un=require("react");function ss(t){return t.contentEditable==="true"}function Lf(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let r=o.getRangeAt(0),s=r.cloneRange();s.selectNodeContents(t),s.setEnd(r.endContainer,r.endOffset),n=s.toString().length,s.selectNodeContents(t),s.setEnd(r.startContainer,r.startOffset),e=s.toString().length}return{selectionStart:e,selectionEnd:n}}function Qc(t){let{selectionStart:e,selectionEnd:n}=ss(t)?Lf(t):t;return[e,n]}function Jc(t){let[,e]=(0,Un.useState)(),n=(0,Un.useRef)(null);return n.current=Qc(t),(0,Un.useEffect)(()=>{let o=()=>{var l;let[r,s]=(l=n.current)!=null?l:[],i=Qc(t);(!i||r!==i[0]||s!==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 Yc(t,e){if(!e)return;let n=t,{value:o}=n,[r,s]=e,i=o.match(sr);if(!i||i.length===0)return;let l=0;i.find(d=>{let a=o.indexOf(d,l);return r>a&&s<a+d.length?(n.selectionStart=a,n.selectionEnd=a+d.length,!0):(l=a+d.length,!1)})}var ep=require("react"),Af=["div","span","mark","strong","b","i","u","em"];function _i(t,e,n=0){var s;let o=t[t.length-1],r=typeof o=="object"&&o!==null?(s=o.props)==null?void 0:s.tagName:void 0;if(r==="br")return t.pop(),[...t,...e,o];if(Af.includes(r)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),(0,ep.cloneElement)(o,{children:_i(i,e,n+1)})]}return[...t,...e]}function dn(t){return t.tagName.toLowerCase()==="textarea"}var tp={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var ip=M(require("classnames")),ap=require("interweave"),ps=require("react");var Vn=require("react");function np(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let r=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...r)})},()=>window.cancelAnimationFrame(n)]}function is(t){let e=(0,Vn.useRef)(null),[n,o]=(0,Vn.useState)(!1);return(0,Vn.useEffect)(()=>{var c;let r=!1,s=Number.parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[i,l]=np((u,p)=>{let m=e.current;if(!m)return;let f=u/s,h=p/s,v=m.getBoundingClientRect(),w=f>v.x&&f<v.x+v.width&&h>v.y&&h<v.y+v.height;w&&!r?(r=!0,o(!0)):!w&&r&&(r=!1,o(!1))},({clientX:u,clientY:p})=>[u,p]),[d,a]=np(()=>{r=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",d),()=>{l(),a(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",d)}},[e]),[e,n]}function op(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function as(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function rp(t){return t!=null}var sp=M(require("classnames")),ls=require("react");var ft={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var Fi=require("react/jsx-runtime"),ds=(0,ls.forwardRef)((r,o)=>{var s=r,{className:t,children:e}=s,n=A(s,["className","children"]);let i=(0,ls.useRef)(null),l=x("TabCompletion",ft);return(0,Fi.jsx)("div",S(g({ref:as([i,o]),className:(0,sp.default)(t,l.popoverContentContainer)},n),{children:(0,Fi.jsx)("div",{className:l.popoverContent,children:e})}))});var Ot=require("react/jsx-runtime"),Mf=t=>e=>{let n=ki(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},Nf=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:r})=>{let s=x("TabCompletion",ft),i=jr(),l=(0,ps.useMemo)(()=>Mf(t.getBoundingClientRect()),[t]),[d,a]=is(t);return(0,ps.useEffect)(()=>{a?i.open():i.close()},[a]),(0,Ot.jsxs)("span",{children:[(0,Ot.jsx)("mark",{ref:as([d,i.triggerRef]),className:(0,ip.default)(s.matchKeyword,{[s.hover]:a}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&(0,Ot.jsx)(Kn,{className:s.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:l,children:(0,Ot.jsx)(ds,{style:n,children:(0,Ot.jsx)("div",{className:s.hintText,children:r})})})]})},cs=class extends ap.Matcher{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(r=>S(g({},r),{keywordRegex:new RegExp(`\\b${op(r.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let i=n.match(s.keywordRegex);if(!i)return null;let l=n.charAt(i.index-1),d=n.charAt(i.index+s.keyword.length);return l==="{"&&d==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(rp);if(o.length===0)return null;let r=o.reduce((s,i)=>i.index<s.index?i:s);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(n,o){return(0,Ot.jsx)(Nf,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:n},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var lp=require("interweave"),dp=M(require("classnames"));var Hi=require("react/jsx-runtime"),Of=({inputElement:t,children:e})=>{let n=x("TabCompletion",ft),[o,r]=is(t);return(0,Hi.jsx)("mark",{ref:o,className:(0,dp.default)(n.matchPlaceholder,{[n.hover]:r}),children:e})},us=class extends lp.Matcher{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(0,Hi.jsx)(Of,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var gs=M(require("classnames")),gp=require("interweave"),me=require("react"),fp=require("react-redux");var Ki=require("react/jsx-runtime"),cp=()=>(0,Ki.jsx)("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:(0,Ki.jsx)("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});var Qe=require("react"),Bo=require("react-redux"),up=M(require("lodash.debounce"));var pp={root:"dd-ky-Bv",content:"dd-kV5e1"};function ms(t,e,n){var r;let o=((r=t.imageSizes)==null?void 0:r[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(s){return null}}function Bi(t){return t.replace("https://www.","").replace("https://","")}var Me=require("react/jsx-runtime"),Df=3,_f=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Ff=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:r=Df})=>{let s=x("LinkSearch",pp),[i,l]=(0,Qe.useState)(""),d=(0,Bo.useDispatch)(),a=(0,Bo.useSelector)(dc("url")),c=(0,Bo.useSelector)(Fl("URL")),u=(0,Qe.useMemo)(()=>c.map(_f),[c]),[p,m]=(0,Qe.useState)(u.length-1),f=C("fallbackImage"),h=b=>{let I=b.target;l(I.value)},v=(b,I)=>{b.stopPropagation(),b.preventDefault(),window.open(I,"_blank")},w=b=>{var L;let I=p-1<0?u.length-1:p-1,N=p+1===u.length?0:p+1;b.code==="Escape"&&(l(""),e()),b.code==="ArrowUp"&&m(I),b.code==="ArrowDown"&&m(N),b.code==="Enter"&&t(((L=u[p])==null?void 0:L.text)||i)},E=(0,Qe.useCallback)((0,up.default)(b=>{d(Wt({query:b,type:"URL",tags:["link-search"]}))},300),[]);return(0,Qe.useEffect)(()=>{i&&E(i)},[i]),(0,Qe.useEffect)(()=>()=>{d(vr())},[]),(0,Me.jsxs)("div",{className:s.root,children:[(0,Me.jsx)(ve,{withDivider:!0,children:(i?u:a).slice(0,r).map((b,I)=>(0,Me.jsx)(F,{selected:p===I,onClick:()=>t(b.text),"data-testid":"linksearch-suggestion",children:(0,Me.jsxs)(K,{children:[(0,Me.jsx)(K.Image,{src:ms(b,"small",f||void 0),title:b.title||b.text}),(0,Me.jsxs)(K.Content,{className:s.content,cropText:!0,children:[(0,Me.jsx)(K.Title,{children:b.title||Bi(b.text)}),b.title&&Bi(b.text)]}),(0,Me.jsx)(F.Actions,{children:(0,Me.jsx)(F.ActionButton,{label:o,onClick:N=>v(N,b.text)})})]})},b.text))}),(0,Me.jsx)(vo,{value:i,onChange:h,autoFocus:!0,placeholder:n,onKeyUp:w})]})},mp=Ff;var Ui={};re(Ui,{enUS:()=>Hf,nlNL:()=>Kf});var Hf={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Kf={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var ue=require("react/jsx-runtime"),Bf=(0,me.forwardRef)((t,e)=>{let n=x("TabCompletion",ft);return(0,ue.jsx)("mark",{ref:e,className:(0,gs.default)(n.matchSelection)},"selection-start")}),Uf=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:r})=>{let s=k(Ui),i=x("TabCompletion",ft),l=(0,me.useRef)(null),d=(0,me.useRef)(null),[a,c]=(0,me.useState)(null),u=(0,fp.useDispatch)(),p=jr(document.activeElement===o),[m]=(0,me.useState)(()=>document.createRange());p.triggerRef.current=m,(0,me.useEffect)(()=>()=>m.detach(),[]),(0,me.useEffect)(()=>{let h=t.current,v=l.current;!h||!v||(m.setStart(h,0),m.setEnd(v,0))},[t.current,l.current]),It(()=>{p.close()});let f=(0,me.useCallback)(h=>{let v=m.toString(),w=/^http(s?):\/\//.test(h)?h:`https://${h}`;u(ur({text:`[${v}](${w})`,replace:"selection"}))},[]);return(0,ue.jsxs)("span",{children:[(0,ue.jsx)("mark",{ref:l,className:(0,gs.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":p.opened?"true":"false",children:r}),p.opened&&(0,ue.jsx)(Kn,{className:i.popoverRoot,triggerRef:p.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,ue.jsxs)(ds,{style:n,ref:d,children:[(0,ue.jsx)("div",{className:(0,gs.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:a!==null}),children:(0,ue.jsxs)("button",{type:"button",tabIndex:a===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,ue.jsx)(cp,{}),(0,ue.jsx)("span",{children:"\xA0"}),(0,ue.jsx)("span",{children:s("insertLink")})]})}),a==="insertLink"&&(0,ue.jsx)(mp,{placeholder:s("linkInputPlaceholder"),visitUrlText:s("visitUrl"),onSelectLink:f,onDismiss:()=>{c(null),p.close()}})]})})]},"selection-end")},fs=class extends gp.Matcher{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,o){return this.props=o,this.charCount=0,this.startRef=(0,me.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,r]=this.props.selection;if(o===r)return null;let s=this.foundIndex===0?o:r,i=s>=this.charCount&&s<=this.charCount+n.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let l=this.foundIndex===1;return i&&l?this.charCount+=s-this.charCount:this.charCount+=n.length,i?g({isStart:l},i):null}replaceWith(n,o){return o.isStart?(0,ue.jsx)(Bf,{ref:this.startRef}):(0,ue.jsx)(Uf,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var vp=require("react-redux");var ht=require("react/jsx-runtime"),Vf=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:r,showStyleSuggestions:s,keywordMatches:i,inputElement:l,source:d})=>{let a=x("TabCompletion",tp),c=C("insertLink"),u=C("showMidSentenceSuggestions"),p=C("inlineSuggestions"),m=Jc(l),f=(0,yt.useRef)(null),h=(0,vp.useSelector)(de);(0,yt.useEffect)(()=>{dn(l)&&m&&Yc(l,m)},[m]);let v=(0,yt.useCallback)(b=>{if(!r||!n)return b;let I=[(0,ht.jsx)("span",{className:a.resetIndent,children:"\u200B"},"u200B"),(0,ht.jsx)("span",{"data-testid":"tab-completion",className:(0,hs.default)(a.tabText,a.resetIndent),"data-source":d,children:n},"tabText")];return o&&I.push((0,ht.jsx)("span",{className:(0,hs.default)(a.hint,a.resetIndent),children:(0,ht.jsx)(or,{keyCode:"tab"},"tabHint")})),_i(b,I)},[r,n,o]),w=(0,yt.useMemo)(()=>{let b=[];return c&&b.push(new fs("selection")),b.push(new us("placeholders")),s&&b.push(new cs("keywords")),b},[p,c,s]),E=(0,yt.useMemo)(()=>{let b=window.getComputedStyle(l);return{"--dd-color":b.color,"--dd-font-size":b.fontSize,"--dd-font-family":b.fontFamily,"--dd-font-variant":b.fontVariant}},[]);return!t||!h?null:(0,ht.jsxs)("div",{ref:b=>{b!=null&&b.parentElement&&(f.current=b==null?void 0:b.parentElement)},className:a.root,style:E,children:[(0,ht.jsx)(hp.Interweave,{tagName:"span",containerTagName:"div",className:(0,hs.default)(a.container,a.agentText),disableLineBreaks:dn(l),content:e||"\u200B",onAfterParse:v,matchers:w,selection:m,keywordMatches:i,inputElement:l,inputStyle:E,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!u}),(0,ht.jsx)("br",{})]})},zf=t=>{var v,w,E;let{input:e,ui:n,settings:o,styleSuggestions:r,conversation:s}=t,i=Tn({input:e}),l=(i==null?void 0:i.text)||"",d=(i==null?void 0:i.source)||"",a=(v=e.html)!=null?v:An(e.text),c=l.indexOf(e.text)===0?l.slice(e.text.length):"",{showTabHint:u}=n,{isSupported:p}=s,{showTabCompletion:m,visible:f,showStyleSuggestions:h}=o;return{showTabHint:u,showStyleSuggestions:h,showTabCompletion:m&&Ze(t),content:a,tabText:c,source:d,keywordMatches:(E=(w=r.list)==null?void 0:w.keywordMatches)!=null?E:[],enabled:f&&p!==!1}},xp=(0,yp.connect)(zf)(Vf);var qn=require("react"),q=require("react-redux");var Uo=require("@reduxjs/toolkit");var Wf={token:null,interval:null},Vi=(0,Uo.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>y(void 0,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),zi=(0,Uo.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(Vi()),setInterval(()=>o(Vi()),n)}),Sp=(0,Uo.createSlice)({name:"passwordlessToken",initialState:Wf,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Vi.fulfilled,(e,n)=>{e.token=n.payload.token}),t.addCase(zi.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollPasswordlessToken:bp}=Sp.actions,wp=Sp.reducer;var Cp=require("@reduxjs/toolkit");function jf(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}var Tp=(0,Cp.createSelector)([sd],t=>t.map(n=>({text:n.response,title:n.name,callToAction:n.callToAction,isLoading:n.isLoading,specialType:n.specialType,rule:{id:jf(n.code),label:n.code,name:n.name,description:n.name}})));var ys=require("react"),kp=require("react-redux"),ji=M(require("classnames"));var Wi=require("react/jsx-runtime"),Vo=()=>(0,Wi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,Wi.jsx)("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var Ep={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var Je=require("react/jsx-runtime"),qf=({entities:t})=>{let e=x("EntitiesWidgetList",Ep),[n,o]=(0,ys.useState)(void 0),r=(0,kp.useDispatch)(),s=()=>{o(void 0)},i=l=>{t&&(o(t.indexOf(l)),$e(l.text),r(ot({name:"entity copied",data:{entity:l,type:"copy"}})))};return(0,ys.useEffect)(()=>{let l=setTimeout(s,500);return()=>{clearTimeout(l)}},[n]),!t||t.length===0?null:(0,Je.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((l,d)=>(0,Je.jsxs)("button",{title:l.text,className:e.entity,type:"button",onClick:()=>i(l),children:[(0,Je.jsx)("span",{className:e.entityText,children:l.text}),(0,Je.jsxs)("span",{className:e.iconWrapper,children:[(0,Je.jsx)("span",{className:(0,ji.default)(e.icon),children:(0,Je.jsx)(Vo,{})}),(0,Je.jsx)("span",{className:(0,ji.default)(e.icon,n===d&&e.iconClicked),children:(0,Je.jsx)(Vo,{})})]})]},l.text))})},Rp=qf;var qi=require("react/jsx-runtime"),Pp=()=>(0,qi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,qi.jsx)("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});var $i=require("react/jsx-runtime"),Ip=()=>(0,$i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,$i.jsx)("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});var Gi=require("react/jsx-runtime"),Lp=()=>(0,Gi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Gi.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var Qi=require("react-redux");var Ap={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var Mp={root:"dd-nazq3",rotation:"dd-3EHTv"};var Op=require("react/jsx-runtime"),$f=({size:t=12})=>{let e=x("LoadingSpinner",Mp);return(0,Op.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},Np=$f;var Xi=require("react/jsx-runtime"),Dp=()=>(0,Xi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Xi.jsx)("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"})});var zo=require("react/jsx-runtime"),_p=t=>(0,zo.jsxs)("svg",S(g({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},t),{children:[(0,zo.jsx)("title",{id:"checkTitle",children:"Check"}),(0,zo.jsx)("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 Zi={};re(Zi,{enUS:()=>Gf,nlNL:()=>Xf});var Gf={error:[{type:0,value:"Something went wrong"}]},Xf={error:[{type:0,value:"Er ging iets fout"}]};var Te=require("react/jsx-runtime"),Fp,Zf=3e3,Qf=()=>{let t=x("OnDemandAssistants",Ap),e=k(Zi),n=lt(He),o=lt(Fe),r=(0,Qi.useSelector)(pd),s=(0,Qi.useSelector)(ud),i=Q(),l=s.filter(c=>c.isPinned),d=s.filter(c=>!c.isPinned),a=c=>y(void 0,null,function*(){if(clearTimeout(Fp),i("trigger on demand assistant",{assistantCode:c}),c===r){o.call({transcript:"in-memory-transcript"});return}n.call({assistantCode:c,expectFormat:"json-schema:cues",transcript:"in-memory-transcript"}),Fp=setTimeout(()=>n.reset(),Zf)});return s.length===0?null:(0,Te.jsxs)("div",{className:t.root,children:[l.map(({assistant:c,assistantName:u})=>(0,Te.jsx)("button",{type:"button",className:t.button,disabled:n.state==="loading",onClick:()=>a(c),children:u},c)),n.state==="loading"&&(0,Te.jsx)(Np,{}),n.state==="done"&&(0,Te.jsx)(_p,{"data-testid":"trigger-done"}),n.state==="error"&&(0,Te.jsx)(kd,{trigger:(0,Te.jsx)(Dp,{}),children:e("error")}),d.length>0&&n.state==="idle"&&(0,Te.jsxs)(Y,{placement:"top-end",children:[(0,Te.jsx)(Y.Trigger,{className:t.trigger,children:(0,Te.jsx)(qr,{"data-testid":"trigger"})}),(0,Te.jsx)(Y.Content,{className:t.nav,"data-testid":"popover",children:d.map(({assistant:c,assistantName:u})=>(0,Te.jsx)(Y.Button,{className:t.item,disabled:n.state==="loading",onClick:()=>a(c),children:u},c))})]})]})},Hp=Qf;var zp=require("react-redux");var Up=require("react");var Kp={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var Bp=require("react/jsx-runtime"),Jf=({width:t})=>{let e=x("LoadingProgressBar",Kp);return(0,Bp.jsx)("div",{className:e.loadingBar,style:{width:t}})},vs=Jf;var vt=require("react/jsx-runtime"),xs=({title:t})=>{let e=(0,Up.useRef)(null);return _a(e),(0,vt.jsx)(F,{ref:e,children:(0,vt.jsx)(K,{children:(0,vt.jsxs)(K.Content,{children:[(0,vt.jsx)(K.Title,{children:t}),(0,vt.jsx)(vs,{width:"60%"}),(0,vt.jsx)(vs,{width:"90%"}),(0,vt.jsx)(vs,{width:"50%"})]})})})};var Wo={};re(Wo,{enUS:()=>Yf,nlNL:()=>eh});var Yf={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"}]},eh={useCue:[{type:0,value:"Voeg toe aan bericht"}],__summarizerAssistant__:[{type:0,value:"Samenvatting"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var cn=require("react");var Ji={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"};var ae=require("react/jsx-runtime"),th=500,nh=100,oh=({content:t,onChange:e,onCopy:n})=>{let o=(0,cn.useRef)(null),r=x("WidgetCue",Ji);return(0,cn.useEffect)(()=>{let s=o.current;if(!s)return;s.style.setProperty("height","0px");let i=Math.min(Math.max(s.scrollHeight,nh),th);s.style.setProperty("height",`${i}px`)},[t]),(0,ae.jsx)("textarea",{ref:o,className:r.editableCue,onCopy:n,onChange:e,value:t})},rh=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:r})=>{var h;let s=x("WidgetCue",Ji),i=k(Wo),l=Q(),d=C("hasKeyboardInput"),[a,c]=(0,cn.useState)(t.text),u=()=>{e&&e(t),n(t)},p=v=>{o&&o(v,t)},m=v=>{r&&r(v,t)},f=v=>{v.preventDefault(),v.stopPropagation(),n(t)};return(0,cn.useEffect)(()=>{l("Assistant response displayed",{name:t.rule.name,description:t.rule.description,group:t.rule.label,cueText:t.text})},[]),(0,ae.jsxs)(F,{"data-testid":"cue",children:[(0,ae.jsx)(K,{children:(0,ae.jsxs)(K.Content,{children:[t.title&&(0,ae.jsx)(K.Title,{className:s.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?i(t.rule.label):t.title}),t.specialType==="summary"?(0,ae.jsx)(oh,{content:a,onCopy:()=>{let v=document.getSelection();v&&p(v.toString())},onChange:v=>{var w;return c((w=v.target.value)!=null?w:"")}}):(0,ae.jsx)(tn,{content:t.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:p,onUse:d?m:void 0})]})}),(0,ae.jsxs)(F.ButtonsContainer,{children:[(0,ae.jsxs)("div",{className:s.actions,children:[t.specialType==="summary"&&(0,ae.jsx)(F.Button,{onClick:()=>p(a),children:i("copyCue")}),t.callToAction&&(0,ae.jsx)(F.Button,{onClick:u,children:t.callToAction.label}),(0,ae.jsx)(F.Button,{onClick:f,children:i("removeCue")})]}),t.specialType==="summary"?(0,ae.jsx)(Yt,{eventName:"summary feedback",feedbackText:(h=t.text)!=null?h:"",feedbackType:"summary",eventData:{summary:t.text}}):(0,ae.jsx)(Yt,{eventName:"Assistant response feedback",eventData:{name:t.rule.name,group:t.rule.label,description:t.rule.description,cueText:t.text},feedbackText:t.text,feedbackType:"assistant"})]})]})},Vp=rh;var zn=require("react/jsx-runtime"),sh=({cues:t})=>{let e=(0,zp.useDispatch)(),n=Se(),o=k(Wo),r=Q(),s=a=>{e(ad({code:a.rule.label})),r("Assistant response closed",{name:a.rule.name,group:a.rule.label,description:a.rule.description,cueText:a.text})},i=(a,c)=>{switch($e(a),c.specialType){case"summary":r("summary copied to clipboard",{originalText:c.text,finalText:a,assistant:c.rule.label});break;default:r("Assistant response copied",{name:c.rule.name,group:c.rule.label,description:c.rule.description,copiedText:a})}},l=a=>{a.callToAction&&(e(Ar(a)),r("Assistant call to action",{name:a.rule.name,group:a.rule.label,description:a.rule.description,eventName:a.callToAction.event,value:a.callToAction.value}))},d=(a,c)=>{n.send(qe,{text:a,suggestion:{source:"cue",sourceText:a}}),r("Assistant response used",{name:c.rule.name,group:c.rule.label,description:c.rule.description,usedText:a})};return(0,zn.jsx)(zn.Fragment,{children:t.map(a=>a.isLoading?(0,zn.jsx)(xs,{title:a.rule.label.startsWith("__")?o(a.rule.label):a.title},a.rule.id):(0,zn.jsx)(Vp,{cue:a,onCallToAction:l,onRemove:s,onCopy:i,onUse:d},a.rule.id))})},Wp=sh;var Ss=require("react");var jp={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var ze=require("react/jsx-runtime");function ih(t,e){return e.split(".").reduce((n,o)=>!n||typeof n!="object"||!(o in n)?null:n[o],t)}var qp=({data:t,schema:e})=>{let n=x("WidgetCustomData",jp),o=r=>{$e(r)};return(0,Ss.useEffect)(()=>{T.info("Custom data",t,e)},[t]),(0,ze.jsx)("dl",{className:n.root,children:e.map(r=>{let s=ih(t,r.path);return(0,ze.jsxs)(Ss.Fragment,{children:[(0,ze.jsx)("dt",{className:n.label,children:r.label}),(0,ze.jsx)("dd",{className:n.value,children:r.type==="boolean"&&s?(0,ze.jsx)("span",{className:n.isTrue,children:r.trueValue}):r.type==="boolean"&&!s?(0,ze.jsx)("span",{className:n.isFalse,children:r.falseValue}):s?(0,ze.jsxs)("button",{type:"button",onClick:()=>o(s),className:n.copyButton,children:[(0,ze.jsx)("span",{className:n.copyButtonText,children:s}),(0,ze.jsx)(Vo,{})]}):"-"})]},r.label)})})};var te=require("react"),bs=require("react-redux");var Yi=require("react/jsx-runtime"),$p=()=>(0,Yi.jsx)("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"ReplayIcon",children:(0,Yi.jsx)("path",{d:"M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8"})});var Wn={};re(Wn,{enUS:()=>ah,nlNL:()=>lh});var ah={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"What is your question?"}],useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Submit"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},lh={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"Wat is je vraag?"}],useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Verzend"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var ea={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",sources:"dd-xf9c6",source:"dd-a-vyX",tooltip:"dd-EsgcZ",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};var O=require("react/jsx-runtime"),dh=3,ch=({sources:t,onClick:e})=>{let n=k(Wn),o=x("WidgetKnowledgeAssistant",ea),[r,s]=(0,te.useState)(!1),i=r?t:t.slice(0,dh);return i.length===0?null:(0,O.jsxs)("ul",{className:o.sources,children:[i.map(l=>(0,O.jsx)("li",{className:o.source,"data-testid":"knowledge-assist-source",children:(0,O.jsxs)(Y,{tooltip:!0,placement:"top-start",children:[(0,O.jsx)(Y.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:l.url,onClick:d=>{d.stopPropagation(),e(l)},children:(0,O.jsx)("span",{className:o.linkContent,children:l.name})}),l.url&&(0,O.jsx)(Y.Content,{className:o.tooltip,children:decodeURIComponent(l.url)})]})},l.name)),i<t&&(0,O.jsx)("button",{type:"button",className:o.showMoreSources,onClick:()=>s(!0),children:n("showMore",{amount:t.length-i.length})})]})},ph=({title:t,description:e})=>(0,O.jsx)(F,{"data-testid":"knowledge-assist-empty-state",children:(0,O.jsx)(K,{children:(0,O.jsxs)(K.Content,{children:[(0,O.jsx)(K.Title,{children:t}),(0,O.jsx)(tn,{content:e})]})})}),uh=({innerRef:t,item:e,index:n,hasKeyboardInput:o,onCopy:r,onUse:s,onSourceClick:i})=>{var d;let l=k(Wn);return(0,O.jsxs)(F,{"data-testid":"knowledge-assist-answer",ref:t,children:[(0,O.jsx)(K,{children:(0,O.jsxs)(K.Content,{children:[(0,O.jsx)(K.Title,{children:e.question}),(0,O.jsx)(tn,{content:e.answer.answer,useLabel:l("useCue"),copyLabel:l("copyCue"),onCopy:r,onUse:o?s:void 0}),(0,O.jsx)(ch,{sources:(d=e.answer.sources)!=null?d:[],onClick:a=>i(a,e.question)})]})}),(0,O.jsxs)(F.ButtonsContainer,{children:[(0,O.jsx)("div",{}),(0,O.jsx)(Yt,{eventName:"knowledge assist feedback",eventData:{question:e.question,isFollowUpQuestion:n>0,isAgent:!0,answer:e.answer.answer},feedbackText:e.answer.answer,feedbackType:"assistant"})]})]})},ta=(0,te.createContext)(null),ws=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,children:o})=>{let[r,s]=(0,te.useState)(null),[i,l]=(0,te.useState)(!1),[d,a]=(0,te.useState)(!!n),[c,u]=(0,te.useState)(null),p=(0,bs.useDispatch)(),m=Q(),f=lt(w=>{if(!t)throw new Error("No knowledge assistant was defined");return e({assistantCode:t,input:w,threadId:r,onNewThreadId(E){s(E)}})},{onSuccess(w){var E;m("knowledge assist question answered",{question:w.question,answer:w.answer.answer,sources:(E=w.answer.sources)!=null?E:[],isFollowUpQuestion:w.threadId===r,isAutoInitiated:d}),a(!1)}}),h=w=>y(void 0,null,function*(){l(!0),u(w),yield f.call(w),l(!1),u(null)}),v={isEnabled:!!t,isSubmitting:i,threadId:r,pendingInput:c,onSubmit:h,onReset(){r&&p(In(r)),s(null)}};return(0,te.useEffect)(()=>{n&&h(n)},[n]),(0,O.jsx)(ta.Provider,{value:v,children:o})},Cs=()=>{let t=k(Wn),e=x("WidgetKnowledgeAssistant",ea),n=(0,te.useContext)(ta),o=(0,te.useRef)(null),[r,s]=(0,te.useState)(""),i=a=>{s(a.target.value)},l=a=>{a.preventDefault(),n.onSubmit(r).then(()=>{var c;o.current&&((c=o.current)==null||c.focus(),s(""))})},d=a=>{a.preventDefault(),n.onReset()};return n.isEnabled?(0,O.jsxs)("form",{className:e.form,onSubmit:l,children:[(0,O.jsx)("input",{ref:o,className:e.formInput,placeholder:t("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:r,onChange:i}),(0,O.jsx)("button",{type:"submit",disabled:n.isSubmitting||r==="",className:e.formSubmit,children:t("submitLabel")}),(0,O.jsx)("button",{type:"button",title:t("resetLabel"),disabled:n.threadId===null||n.isSubmitting,onClick:d,className:e.actionButton,children:(0,O.jsx)($p,{})})]}):null},Ts=({emptyState:t})=>{var u,p;let e=k(Wn),n=Q(),o=(0,te.useRef)(null),r=(0,te.useContext)(ta),s=(p=(0,bs.useSelector)(So((u=r.threadId)!=null?u:-1)))!=null?p:[],i=C("hasKeyboardInput"),l=Se(),d=m=>{$e(m),n("Assistant response copied",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",copiedText:m})},a=(m,f)=>{n("knowledge assist source viewed",{question:f,sourceViewed:m.url||m.name})},c=m=>{l.send(qe,{text:m,suggestion:{source:"cue",sourceText:m}}),n("Assistant response used",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",usedText:m})};return!r.isEnabled||(s==null?void 0:s.length)===0&&!r.isSubmitting&&!t?null:(0,O.jsx)(We,{type:"knowledge",title:e("titleKnowledgeAssistant"),"data-testid":"knowledge",children:(0,O.jsxs)(ve,{withDivider:!0,children:[t&&s.length===0&&!r.pendingInput&&(0,O.jsx)(ph,g({},t)),s.map((m,f)=>(0,O.jsx)(uh,{innerRef:f===s.length-1?o:void 0,item:m,index:f,hasKeyboardInput:i,onCopy:d,onUse:c,onSourceClick:a},`${m.question}_${m.answer}_${f}`)),r.pendingInput&&(0,O.jsx)(xs,{title:r.pendingInput})]})})};var Zp=require("react");var mh=/(https?:\/\/[^\s]+)/,Xp=t=>t.split(" ").find(e=>mh.test(e));var Ne=require("react/jsx-runtime"),gh=({suggestion:t,lines:e,onUse:n})=>{var u;let o=t.text||t.url||t.message,r=Xp(o),s=k(Ao),i=C("showImages"),l=C("fallbackImage"),d=C("hasKeyboardInput"),a=p=>{p.preventDefault(),p.stopPropagation(),d&&n(o)},c=(0,Zp.useCallback)(p=>{window.open(r,"_blank"),p.stopPropagation(),p.preventDefault()},[r]);return(0,Ne.jsxs)(F,{onClick:d?a:void 0,"data-testid":"edit-suggestion",children:[(0,Ne.jsxs)(K,{children:[i&&t.image&&(0,Ne.jsx)(K.Image,{src:ms(t,"small",l||void 0),title:t.title}),(0,Ne.jsxs)(K.Content,{children:[t.title&&(0,Ne.jsx)(K.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,Ne.jsx)(F.Labels,{labels:t.searchKeywords}),(0,Ne.jsx)(K.Content,{cropText:e==="single",lineClamp:e==="multiple",children:o})]})]}),(0,Ne.jsxs)(F.Actions,{children:[r&&(0,Ne.jsx)(F.ActionButton,{onClick:c,label:s("visitUrl")}),d&&(0,Ne.jsx)(F.ActionButton,{primary:!0,onClick:a,label:s("useSuggestion")})]})]})},Qp=gh;var jo=require("react/jsx-runtime"),fh=({lines:t,suggestions:e})=>{let n=Se(),o=(r,s)=>{n.send(qe,{text:r,suggestion:S(g({},s),{source:s.source,sourceText:s.text})})};return(0,jo.jsx)(jo.Fragment,{children:e.map(r=>(0,jo.jsx)(Qp,{suggestion:r,lines:t,onUse:s=>o(s,r)},r.text||r.url||r.message))})},Jp=fh;var Es={};re(Es,{enUS:()=>hh,nlNL:()=>yh});var hh={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},yh={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var jn={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};var P=require("react/jsx-runtime"),eu=(t,e)=>{let n=(0,q.useSelector)(de);(0,qn.useEffect)(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},vh=({onLogIn:t})=>{let e=x("Widget",jn),n=C("isEmbedded"),o=C("adminUrl");return(0,P.jsx)("div",{className:e.loginText,children:(0,P.jsx)("div",{children:(0,P.jsx)(os,{isEmbedded:n,loginUrl:o,onLogIn:t})})},"login")},Yp=({text:t})=>{let e=x("Widget",jn);return(0,P.jsx)("div",{className:e.stateText,children:(0,P.jsx)("div",{children:(0,P.jsx)("p",{children:t})})},"notification")},xh=()=>{let t=k(Es),e=(0,q.useDispatch)(),n=x("Widget",jn),o=C("showSearch"),r=C("showSummaryCommand"),s=C("showKnowledgeSearch"),i=(0,q.useSelector)(di("knowledge-assist")),l=C("isEmbedded"),d=(0,q.useSelector)(Fn("/admin/")),a=Se(),c=C("productName"),u=C("hasKeyboardInput"),p=lt(()=>Fe({})),m=Q(),f=o||r||s||d;return eu(()=>{if(l)return e(zi()),()=>{e(bp())}},[e,l]),!f||!u?null:(0,P.jsx)(We,{title:t("actions"),type:"shortcuts",children:(0,P.jsxs)("div",{className:n.shortcutList,children:[o&&(0,P.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":t("linkSearch"),onClick:()=>{a.send("ShowCommandPalette",{isOpen:!0}),m("open search",{via:"widget-shortcut"})},children:[(0,P.jsx)(Mn,{}),t("linkSearch")]}),r&&!i&&(0,P.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":t("linkSummary"),disabled:p.state==="loading",onClick:()=>p.call(),children:[(0,P.jsx)(Lp,{}),t("linkSummary")]}),s&&!i&&(0,P.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":t("linkKnowledgeSearch"),onClick:()=>{a.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),m("open knowledge assistant",{via:"widget-shortcut"})},children:[(0,P.jsx)(Ip,{}),t("linkKnowledgeSearch")]}),d&&(0,P.jsxs)("a",{className:n.shortcut,target:"_blank",href:d,"data-testid":"shortcut-studio-login","aria-label":t("linkStudioLogin",{productName:c}),rel:"noreferrer",onClick:()=>{m("open my deepdesk",{via:"widget-shortcut"})},children:[(0,P.jsx)(Pp,{}),t("linkStudioLogin",{productName:c})]})]})})},Sh=()=>{let t=(0,q.useDispatch)(),e=(0,q.useSelector)(Co),n=(0,q.useSelector)(md),o=(0,q.useSelector)(Tp),r=(0,q.useSelector)(Pl),s=(0,q.useSelector)(Br),i=(0,q.useSelector)(Xr),l=(0,q.useSelector)(Gt),d=(0,q.useSelector)(je);return(0,qn.useEffect)(()=>{!!r&&!n&&T.warn("Custom data provided, but no schema.")},[r,n]),eu(()=>{e.forEach(({type:a})=>{a==="entities"?t(Be()):ir.includes(a)||t(Ve(a))})},[t,d,l]),(0,qn.useEffect)(()=>{o.length>0&&!e.some(a=>a.type==="cues")&&T.warn("Received cues, but cues are not configured in widget.")},[e,o]),(0,P.jsx)(qn.Fragment,{children:e.map(({type:a,title:c,amount:u,lines:p,schema:m})=>{var f,h;switch(a){case"entities":return s&&s.length>0&&(0,P.jsx)(We,{type:a,title:c,"data-testid":`type-${a}`,children:(0,P.jsx)(Rp,{entities:s})},a);case"cues":return o&&o.length>0&&(0,P.jsx)(We,{type:a,title:c,"data-testid":`type-${a}`,children:(0,P.jsx)(ve,{withDivider:!0,children:(0,P.jsx)(Wp,{cues:o})})},a);case"custom-data":return r&&m&&(0,P.jsx)(We,{type:a,title:c,"data-testid":`type-${a}`,children:(0,P.jsx)(ve,{withDivider:!0,children:(0,P.jsx)(qp,{data:r,schema:m})})},a);default:return((h=(f=i[a])==null?void 0:f.suggestions)==null?void 0:h.length)>0&&(0,P.jsx)(We,{type:a,title:c,"data-testid":`type-${a}`,children:(0,P.jsx)(ve,{withDivider:!0,children:(0,P.jsx)(Jp,{lines:p,contentType:a,suggestions:i[a].suggestions.slice(0,u)||[]})})},a)}})})},na=({children:t})=>{let e=x("Widget",jn);return(0,P.jsx)("div",{className:e.footer,children:t})},oa=({children:t})=>{let e=x("Widget",jn);return(0,P.jsx)("div",{className:e.root,"data-testid":"widget",children:t})},bh=({onLogIn:t,knowledgeAssistOptions:e={}})=>{let n=k(Es),o=(0,q.useSelector)(wn),r=(0,q.useSelector)(de),s=(0,q.useSelector)(cl),i=(0,q.useSelector)(Gt),l=(0,q.useSelector)(di("knowledge-assist")),d=(0,q.useSelector)(Nr),a=(0,q.useSelector)(Or);return o===!1?(0,P.jsx)(Yp,{text:n("notSupported")}):r===!1?(0,P.jsx)(vh,{onLogIn:t}):!i||!s||r===null?(0,P.jsx)(Yp,{text:n("waiting")}):(0,P.jsx)(oa,{children:(0,P.jsxs)(ws,{initialQuestion:e.initialQuestion,assistantCode:d!=null?d:a,evaluateKnowledgeAssistFn:a?qt:$t,children:[(0,P.jsxs)(yn,{children:[(0,P.jsx)(xh,{}),(0,P.jsx)(Sh,{}),l&&(0,P.jsx)(Ts,{emptyState:e.emptyState})]}),(0,P.jsxs)(na,{children:[l&&(0,P.jsx)(Cs,{}),(0,P.jsx)(Hp,{})]})]})})},tu=bh;function $n(t){let e=new Range;return e.selectNodeContents(t),e}function nu(t,e,n){try{return Dt(t,e,n),!0}catch(o){return!1}}function ks(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Rs(t){return"tagName"in t&&t.tagName==="BR"}var qo=/[\u200B-\u200D\uFEFF]/g;function Dt(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let r=0,s=!1;function i(d,a){let c=-1,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(d))return a;for(let p=0;p<=d.length;p++)if(u.test(d[p])||c++,c===a)return p;throw new Error("Offset out of range")}function l(d){switch(d.nodeType){case Node.TEXT_NODE:{let a=d.textContent,c=a.replace(qo,""),u=r+c.length,p=e>=r&&e<=u,m=n>=r&&n<=u;if(p){let f=i(a,e-r);f===0&&!m?o.setStartBefore(d):o.setStart(d,f)}m&&(o.setEnd(d,i(a,n-r)),s=!0),r=u;break}case Node.ELEMENT_NODE:{if(Rs(d)&&(r===e&&o.setStartBefore(d),r++,r===n)){o.setEndAfter(d),s=!0;return}for(let c=0;c<d.childNodes.length&&(l(d.childNodes[c]),!s);c++);let a=d.lastChild;ks(d)&&a&&!ks(a)&&!Rs(a)&&r++;break}default:break}}if(l(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function $o(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:r,endOffset:s,collapsed:i}=e,l,d,a=0;function c(u){let p=u===t,m=u===n,f=u===r;switch(u.nodeType){case Node.TEXT_NODE:{let h=u.textContent;m&&(l=a+h.substring(0,o).replace(qo,"").length),f&&(d=a+h.substring(0,s).replace(qo,"").length),a+=h.replace(qo,"").length;break}case Node.ELEMENT_NODE:{if(Rs(u)&&u.nextSibling){a++;break}!p&&ks(u)&&u.previousSibling&&a++;for(let h=0;h<u.childNodes.length;h++){let v=m&&h===o,w=f&&h===s;if(v&&(l=a),w&&(d=a),d!==void 0||((!v||!i)&&c(u.childNodes[h]),f&&h===s-1&&(d=a),d!==void 0))break}f&&(d=a);break}default:break}}if(c(t),d===void 0)throw new Error("Could not determine start and end");return{start:l!=null?l:d,end:d}}function Go(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:r,endOffset:s,collapsed:i}=e,l=0,d="";function a(c){let u=c===t,p=c===n,m=c===r;switch(p&&(l=1),c.nodeType){case Node.TEXT_NODE:{if(l!==1)return;let f=p?o:0,h=m?s:void 0;d+=c.textContent.replace(qo,"").substring(f,h);break}case Node.ELEMENT_NODE:{if(!i&&l===1&&Rs(c)&&c.nextSibling){d+=`
9
- `;break}!u&&!i&&l===1&&ks(c)&&c.previousSibling&&(d+=`
10
- `);let f=p?o:0,h=m?Math.min(s,c.childNodes.length):c.childNodes.length;for(let v=f;v<h&&(a(c.childNodes[v]),l!==2);v++);break}default:break}m&&(l=2)}return a(t),d}var ou=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(ou||{}),xt=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=r=>{n(r)};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(),r=this.cachedCaretPosition===null;if(!this.isActive||(e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),e!==this.cachedText?(this.cachedText=e,this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,r=!0,this.emit("selection",o)),!r))return;let s=this.getCaretPosition();Tt(s,this.cachedCaretPosition)||(this.cachedCaretPosition=s,this.emit("caretposition",s))}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:r}=e;this.isPossibleClearInputAction=Object.values(ou).includes(n)||n.toLowerCase()==="z"&&(o||r),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,r;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((r=e.clipboardData)==null?void 0:r.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 ru(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var pn=class extends xt{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Go(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var i;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 r="getComposedRanges"in o&&n instanceof ShadowRoot?(i=o.getComposedRanges(n))==null?void 0:i[0]:o.rangeCount>0?o.getRangeAt(0):null;if(!r)return null;let s=this.element.ownerDocument.createRange();return s.setStart(r==null?void 0:r.startContainer,r==null?void 0:r.startOffset),s.setEnd(r==null?void 0:r.endContainer,r==null?void 0:r.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let o=n.getBoundingClientRect();return!ru(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!ru(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let n=this.getRange();if(n)return $o(this.element,n);let o=this.lastKnownSelection;if(o&&nu(this.element,o.start,o.end))return o;let r=$n(this.element);return r.collapse(!1),$o(this.element,r)}getSelectedText(){let{start:n,end:o}=this.getSelection();return Go(this.element,Dt(this.element,n,o))}listen(){super.listen();let n=new MutationObserver(s=>{var i,l;s.length===2&&s[0].addedNodes.length===1&&((i=s[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((l=s[1].removedNodes[0])==null?void 0:l.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,r=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>r.disconnect())}};var wh=["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 su(t,e){let n="mozInnerScreenX"in window,o=document.createElement("div");o.id="input-textarea-caret-position-mirror-div";let r=o.style,s=window.getComputedStyle(t),i=t.ownerDocument.body;r.whiteSpace="pre-wrap",r.wordWrap="break-word",r.position="absolute",r.visibility="hidden",wh.forEach(c=>{r[c]=s[c]}),n?t.scrollHeight>Number.parseInt(s.height)&&(r.overflowY="scroll"):r.overflow="hidden",o.textContent=t.value.substring(0,e);let l=document.createElement("span");l.textContent=t.value.substring(e)||".",o.appendChild(l),i.appendChild(o);let d=t.getBoundingClientRect(),a={top:d.top-t.scrollTop+l.offsetTop+Number.parseInt(s.borderTopWidth)+l.offsetHeight,left:d.left-t.scrollLeft+l.offsetLeft+Number.parseInt(s.borderLeftWidth)};return i.removeChild(o),a}var un=class extends xt{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 su(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 s;return(s=n==null?void 0:n.get)==null?void 0:s.call(this.element)},set:s=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,s),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let o=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};function iu(t,e,n){let o=`deepdesk-iframe-${t}`,r=document.getElementById(o);if(r)return r;let s=document.createElement("iframe"),i=new URL(e);return Object.entries(n).forEach(([l,d])=>{i.searchParams.append(l,d)}),s.style.position="absolute",s.style.left="-999em",s.style.width="0px",s.style.height="0px",s.tabIndex=-1,s.id=o,s.title=`iframe-${t}`,s.src=i.toString(),window.document.body.appendChild(s),s}function Ch(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch(e){return t}}var ra=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()}},sa=class{constructor(e,n,o){this.name=e;this.targetOrigin=n;this.options=o;this.disposeHandlers=[];this.iframe=iu(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()}},ia=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(),T.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 sa(e,this.deepdeskUrl,{debug:!0}):new ra(e),o=r=>{var i,l;if(r.origin!==this.deepdeskUrl)return;let s=Ch(r.data);typeof s!="object"||s.type!=="event"||s.channel!==e||(T.info("Received broadcast event",this.externalId,r),(l=(i=this.eventMap)[s.name])==null||l.call(i,s.payload))};return n.onMessage(o),n}send(e,n,o){var i,l;T.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let r={type:"event",name:e,payload:n};o!==!1&&((l=(i=this.eventMap)[e])==null||l.call(i,n));let s=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage(S(g({},r),{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)}},au=ia;function Th(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function z(t){return Array.isArray(t)?t.map(z):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>S(g({},e),{[Th(n)]:z(t[n])}),{}):t}function Eh(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function ne(t){return Array.isArray(t)?t.map(ne):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>S(g({},e),{[Eh(n)]:ne(t[n])}),{}):t}var Gn=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var aa=t=>new Promise(e=>{setTimeout(e,t)});var Xn=class extends Gn{constructor(){super(...arguments);this.name="ClientError"}},da=class extends Gn{constructor(){super(...arguments);this.name="ServerError"}},la=new Map;function kh(t){return y(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:(T.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var _t=class _t{constructor(e="",n={}){this.baseUrl=e;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,n={}){return new Promise((o,r)=>{let s={isAborted:!1,reject:r},i=`${this.baseUrl}${e}`,l=this.fetch,d=n.method===void 0||n.method.toLowerCase()==="get",L=n,{useCache:a=!1,abortLatest:c=!1,attempts:u=1,retryDelay:p=500,refreshTokenOn401:m=!0,retryOnError:f=D=>D instanceof TypeError,retryOnResponse:h=D=>D.status>=500,version:v=null}=L,w=A(L,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(a){if(!d)throw new Error(`Can't use 'useCache' for ${n.method}`);if(la.has(i)){o(la.get(i));return}}let E=S(g({credentials:"include"},w),{headers:g({Accept:"application/json","Content-Type":"application/json"},w.headers)});!d&&this.csrfToken&&(E.headers=S(g({},E.headers),{"X-CSRFToken":this.csrfToken})),typeof v=="string"&&(E.headers=S(g({},E.headers),{"X-Deepdesk-API-Version":v}));let b=u,I=!1;if(!l)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]=s;let N=()=>y(this,null,function*(){return b--,l(i,E).then(D=>y(this,null,function*(){return h(D)&&!s.isAborted&&b>0?(yield aa(p),N()):D.status===401&&m===!0&&I===!1?(I=!0,yield this.refreshToken(),N()):D})).catch(D=>y(this,null,function*(){if(f(D)&&!s.isAborted&&b>0)return yield aa(p),N();throw D}))});N().then(D=>y(this,null,function*(){let j=yield kh(D);if(delete this.latestRequestByUrl[i],D.status>=500){r(new da("Server Error",j));return}if(D.status===401){r(new Xn("Unauthorized",j));return}if(D.status===403){r(new Xn("Forbidden",j));return}if(D.status===404){r(new Xn("Not Found",j));return}if(D.status>=400){r(new Xn("Bad Request",j));return}a&&la.set(i,j),o(j)})).catch(D=>{r(D)})})}validateToken(){return y(this,null,function*(){let{has_valid_access_token:e}=yield this.get("/auth/validate");if(!e)try{yield this.refreshToken()}catch(o){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/");return!!n})}refreshToken(){return _t.refreshingToken||(_t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{_t.refreshingToken=null},1e3*60)})),_t.refreshingToken}get(e,n){return this.request(e,n)}post(e,n,o){return this.request(e,g({method:"POST",body:JSON.stringify(n)},o))}patch(e,n,o){return this.request(e,g({method:"PATCH",body:JSON.stringify(n)},o))}put(e,n,o){return this.request(e,g({method:"PUT",body:JSON.stringify(n)},o))}delete(e,n){return this.request(e,g({method:"DELETE"},n))}};_t.refreshingToken=null;var mn=_t;var lu;(e=>{let t;(i=>(i.SEND_MESSAGE="Send Message",i.HANDLING_TIME="Handling Time",i.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",i.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(t=e.EventType||(e.EventType={}))})(lu||(lu={}));function Ps(t){return S(g({},z(t)),{metadata:t.metadata})}var gn=class gn{constructor(e,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new mn(e,{fetch:n.fetch}),this.client.patchFetch(o=>(r,s)=>y(this,null,function*(){let i=yield o(r,s);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return y(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=yield this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(gn.exchangeTokenPromise||(gn.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),gn.exchangeTokenPromise):Promise.resolve()})}createConversation(e){return y(this,null,function*(){var o;yield this.preflight(),T.info(`Creating conversation for session ${e.externalId} and agent ${e.agentId}`);let n=yield this.client.post("/api/v2/conversations",S(g({chat_start_time:new Date().toISOString()},ne(e)),{metadata:(o=e.metadata)!=null?o:{}}));return Ps(n)})}getMe(){return y(this,null,function*(){let e=yield this.client.get("/apis/admin/session/me/");return z(e)})}postIdentity(e){return y(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",ne(e))})}patchMe(e){return y(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",ne(e));return z(n)})}getProfile(e){return y(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${e}/`,{useCache:!0});return z(n)})}getKnowledgeAssistant(e){return y(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{useCache:!0});return z(n)})}getContentTypes(){return y(this,null,function*(){let e=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return z(e)})}getAccount(){return y(this,null,function*(){let e=yield this.client.get("/apis/admin/account/",{useCache:!0});return z(e)})}getPlatformConfig(e){return y(this,null,function*(){let n=e!==void 0?`/platform/config/${e}/`:"/platform/config/",{config:o}=yield this.client.get(n,{useCache:!0});return z(o)})}checkUserExists(e){return y(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${e}`,{version:"v1"});return n})}getConversationByExternalId(o){return y(this,arguments,function*(e,n={}){yield this.preflight(),T.info(`Getting conversation for session ${e}`);let{attempts:r=1,retryDelay:s=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:r,retryDelay:s,retryOnResponse:l=>l.status===404||l.status>=500,version:"v2"});return T.info(`Successfully retrieved conversation ${i.id} for session ${e}`),Ps(i)})}isConversationSupported(o){return y(this,arguments,function*(e,n={}){T.info(`Check if conversation for session ${e} is supported`);let{attempts:r=1,retryDelay:s=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:r,retryDelay:s,retryOnResponse:l=>l.status===404||l.status>=500})).has_active_profile})}updateConversation(e,n){return y(this,null,function*(){var s;yield this.preflight();let o=ne(n);n.metadata&&(o.metadata=(s=n.metadata)!=null?s:{});let r=yield this.client.put(`/api/v2/conversations/${e}`,o);return Ps(r)})}postMessages(e,n){return y(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${e}/messages`,n.map(r=>S(g({},ne(r)),{metadata:r.metadata})))).map(r=>Ps(r))})}sendEvent(e,n){return y(this,null,function*(){yield this.preflight();let i=n,{data:o}=i,r=A(i,["data"]),s=Object.entries(this.latestReceivedDeepdeskVersions).reduce((l,[d,a])=>S(g({},l),{[d]:a}),{});return this.client.post("/api/events",ne(S(g(g({},s),r),{data:o,name:e})),{version:"v2"})})}sendEventV1(e,n){return y(this,null,function*(){yield this.preflight();let o=Object.entries(this.latestReceivedDeepdeskVersions).reduce((r,[s,i])=>S(g({},r),{[s]:i}),{});return this.client.post("/api/events",{event:e,data:ne(g(g({},n),o))},{version:"v1"})})}getEntities(e){return y(this,null,function*(){return yield this.preflight(),(yield this.client.post("/api/entities",{messages:e.filter(o=>o.text)},{version:"v1"})).entities})}getTemporaryExchangeToken(){return y(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(e){return y(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:e}).catch(n=>{throw T.warn(`Invalid token '${e}'`),n})})}authenticateWithKey(e,n){return y(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",ne(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(r){return y(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}`,ne(n),{abortLatest:!0})).map(i=>S(g({},z(i)),{text:i.text||i.url||i.message,source:o,type:o})).filter((i,l,d)=>l===d.findIndex(a=>a.text===i.text))})}isLoggedIn(){return y(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(e,n){return y(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${e}/autocomplete`,ne(n),{abortLatest:!0})).map(r=>({score:1,source:r.source,sourceText:r.source_text,text:r.label,trainingJobs:r.training_jobs,searchKeywords:r.search_keywords,type:r.source})).filter((r,s,i)=>s===i.findIndex(l=>l.text===r.text))})}getPinnedMessages(e){return y(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return z(n).map(o=>S(g({},o),{text:o.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(e){return y(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",ne(e),{abortLatest:!0,version:"v1"});return z(n)})}search(e){return y(this,null,function*(){let n=yield this.client.post(`/api/profiles/${e.profile}/search`,ne(e),{version:"v2"});return z(n)})}knowledgeAssist(s,i,l){return y(this,arguments,function*(e,n,o,r={}){yield this.preflight();let d=yield this.client.post(`/api/knowledge-assist/assistants/${o}/search`,ne({question:e.question,doNotKnowAnswer:e.doNotKnowAnswer,customerInstruction:e.customerInstruction,chatHistory:n.map(a=>({question:a.question,answer:a.answer.answer})),agentId:r.agentId,conversationId:r.conversationId}),{version:"v2"});return z(d)})}requestLoginByEmail(e){return y(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:e});return z(n)})}requestPasswordlessToken(){return y(this,null,function*(){let e=yield this.client.get("/apis/admin/session/passwordless/request/");return z(e.token)})}getCsrfToken(){return y(this,null,function*(){let{token:e}=yield this.client.get("/apis/admin/session/csrf/");return e})}verifyLoginToken(e){return y(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:e});return z(n)})}getSummary(o){return y(this,arguments,function*(e,n={}){yield this.preflight();let r=yield this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model},{version:"v1"});return z(r)})}evaluateAssistant(e,n){return y(this,null,function*(){var l;yield this.preflight();let o=new URLSearchParams,{expectFormat:r="text"}=n||{};if(r.startsWith("json-schema:")){let d=r.replace("json-schema:","");o.append("expect_response_format","json-schema"),o.append("expect_response_format_schema",d)}else o.append("expect_response_format",r);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()}`,i=yield this.client.post(s,{input:(l=n==null?void 0:n.input)!=null?l:{},conversation:n==null?void 0:n.transcript});return z(i.output)})}createAssistantThread(e){return y(this,null,function*(){yield this.preflight();let{assistantCode:n}=e,o=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return z(o)})}postMessageToAssistantThread(e){return y(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:r}=e,s=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:r,role:"user"});return z(s)})}translateMessages(e){return y(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/translate",ne(e),{version:"v2"});return z(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let r=o.toLowerCase(),s=r.match($a);if(!n||!s)return;let i=s[1].replace("-","_"),l=this.latestReceivedDeepdeskVersions[i];l&&n&&l!==n&&T.warn(`Overwritten Version header ${r}: ${JSON.stringify(l)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};gn.exchangeTokenPromise=null;var St=gn;var Ms=require("@reduxjs/toolkit");var cu=require("@reduxjs/toolkit");var du={startTime:null,stopTime:null},pu=t=>t.handlingTime,uu=(0,cu.createSlice)({name:"handlingTime",initialState:du,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(Z,()=>du)}}),{handlingTimeStart:mu,handlingTimeStop:Is,handlingTimeReset:gu}=uu.actions,fu=uu.reducer;var hu=(t={})=>{let e=g({onAuthError:bn(!1)},t);return n=>o=>r=>("error"in r&&r.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(r))};var As=require("@reduxjs/toolkit");var Ls={list:{keywordMatches:[]},fetchState:"idle"};var fn=(0,As.createAsyncThunk)("styleSuggestions/getAll",(n,o)=>y(void 0,[n,o],function*({text:t},e){var d;let{deepdeskAPI:r}=e.extra,s=e.getState(),{showStyleSuggestions:i}=s.settings,l=(d=s.conversation.current)==null?void 0:d.profileCode;if(!i)return Ls.list;if(!l)throw new Error("No current conversation to fetch pinned messages");return r.getStyleSuggestions({profileCode:l,message:t})})),Rh=(0,As.createSlice)({name:"styleSuggestions",initialState:Ls,reducers:{},extraReducers:t=>{t.addCase(fn.pending,e=>{e.fetchState="loading"}).addCase(fn.rejected,e=>{e.fetchState="error"}).addCase(fn.fulfilled,(e,n)=>{e.fetchState="done",Tt(e.list,n.payload)||(e.list=n.payload)}).addCase(zt,e=>{e.list=Ls.list}).addCase(Z,()=>Ls)}}),yu=Rh.reducer;var vu=(t={})=>{let e,n=!0,o=g({getStyleSuggestions:fn,debounce:500},t);return r=>s=>i=>{var m;let l=r.getState().input.text,d=s(i),a=r.getState();if(a.auth.isLoggedIn!==!0)return d;let{showStyleSuggestions:c}=a.settings;if(!((m=a.conversation.current)==null?void 0:m.id)||!c)return d;let{text:p}=a.input;return p===l&&!n||(clearTimeout(e),p==="")||(e=setTimeout(()=>{n=!1,r.dispatch(o.getStyleSuggestions({text:p}))},t.debounce)),d}};function Ph(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var xu=(t={})=>{let e=g({getTextSuggestions:Ve,getAutocompleteSuggestions:No,debounce:200,check:Ze},t),n;return o=>r=>s=>{var h;let{input:i}=o.getState(),l=r(s),d=o.getState();if(d.auth.isLoggedIn!==!0)return l;let{recommendTextSuggestions:a,showTabCompletion:c}=d.settings,u=(h=d.conversation.current)==null?void 0:h.id,p=s.type===Zr.toString();if(!u||!a&&!c)return l;let{input:m}=d;return Ph(m,i)&&!p||(clearTimeout(n),!e.check(d))||(n=setTimeout(()=>{let v=Cn(d);v===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(v))},p?0:e.debounce)),l}};var Su=fn.fulfilled.toString();function Ih(t,e){let n=new Set([...e.keywordMatches.map(r=>r.keyword)]),o=[];return n.forEach(r=>{let s=t.keywordMatches.filter(d=>d.keyword===r),i=e.keywordMatches.filter(d=>d.keyword===r),l=i.length-s.length;l<=0||o.push(...i.slice(0,l))}),o}var bu=t=>e=>n=>o=>{var a;if(o.type!==Su){n(o);return}let r=e.getState().styleSuggestions.list;n(o);let s=e.getState(),i=s.styleSuggestions.list,l=(a=s.conversation)==null?void 0:a.current;if(r===i)return;let d=Ih(r,i);o.type===Su&&d.length>0&&t.sendEvent("style suggested",{conversationId:l==null?void 0:l.id,data:{keywordMatches:d}})};var Lh=(0,Ms.combineReducers)({assistants:ld,auth:sl,conversation:pl,contentTypes:cd,passwordlessToken:wp,entities:Dd,handlingTime:fu,info:Nl,input:El,settings:Ja,profile:gd,search:Kl,styleSuggestions:yu,ui:Lc,textSuggestions:uc});function wu(t){return(0,Ms.configureStore)({reducer:Lh,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}),hu(),xu({debounce:200}),vu({debounce:500}),bu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Ah=t=>{var e,n;return(n=(e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())!=null?n:"unknown"},Mh=t=>e=>n=>o=>{var l,d,a,c,u,p;let r=e.getState(),s=to("inlineSuggestions")(r);switch(o.type){case bn.toString():{!o.payload&&t.emit("logout",void 0);break}case Be.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:(l=r.conversation.current)==null?void 0:l.id,data:{entities:o.payload}});break;case ot.toString():t.sendEvent(o.payload.name,{conversationId:((d=o.payload.options)==null?void 0:d.includeConversationData)&&((a=r.conversation.current)==null?void 0:a.id),data:o.payload.data});break;case zt.toString():t.logSendMessage(o.payload);break;case Ar.toString():t.emit("call-to-action",{cue:o.payload});break;case He.fulfilled.toString():o.isBroadcasted||t.broadcast(Xs,o,!1);break;default:break}let i=n(o);switch(o.type){case zt.toString():t.handleAfterSendMessage(o.payload);break;case Do.toString():t.onUpdateShowTabHint(o.payload);break;case Is.toString():t.logHandlingTime();break;case"analytics/logEvent/fulfilled":{t.emit("event",o.meta.arg);break}case ur.toString():{let{start:m,end:f}=r.input.selection;t.emit("replace",S(g({},o.payload),{replace:o.payload.replace==="selection"?{start:m,end:f}:{start:0,end:f}}));break}case De.toString():{let{start:m,end:f}=r.input.selection;t.emit("select-suggestion",S(g({type:Ah(o.payload.suggestion)},o.payload),{replace:o.payload.replace==="selection"?{start:m,end:f}:{start:0,end:f}})),s&&e.dispatch(Et([]));break}case mr.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(c=r.conversation.current)==null?void 0:c.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Et.toString():{s&&o.payload.length>0&&e.dispatch(gr(0));break}case Fe.fulfilled.toString():{t.sendEvent("conversation summarized",{conversationId:(u=r.conversation.current)==null?void 0:u.id,data:{summary:o.payload,assistant:(p=e.getState().profile.data)==null?void 0:p.summarizerAssistantNew}}),t.emit("summary-generated",{summary:o.payload});break}default:break}return i},Cu=Mh;var Tu=require("@reduxjs/toolkit");function ca(t){return t.toISOString().replace("T"," ").replace("Z","")}var Nh=(t,e)=>e.version,Eu=(0,Tu.createSelector)([kn,je,pu,Nh],(t,e,n,o)=>{if(!e)return T.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:s}=n;return!r||!s?(T.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:ca(r),timeStop:ca(s)}});function ku(t,e,n){var j,oe,be,_;let o=(j=e.conversation.current)==null?void 0:j.id;if(!o)return T.warn("No conversationId for send message metrics"),null;let{text:r,metrics:{numCharsTyped:s,numCharsPasted:i,numCharsCut:l,numCharsDeleted:d,numPaste:a,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:u,pastes:p,cuts:m,deletions:f,textSuggestions:h,offeredTextSuggestions:v}}=e[t],w=r.length,b=h.reduce((U,{text:Ee,searchTerm:ge})=>U+Ee.length-(ge?ge.length:0),0),I=c!=null?c:Date.now(),N=(Date.now()-I)/1e3+(u||0),L=s/N,D=h.reduce((U,{searchTerm:Ee})=>U+(Ee?Ee.length:0),0);return{conversationId:o,source:"agent",text:r,clientVersion:n.version,pastes:p,cuts:m,deletions:f,lenTextTyped:s+D,lenTextTotal:w,lenTextAssisted:b,lenTextPasted:i,lenTextCut:l,lenTextDeleted:d,timeTotalSeconds:N,charsPerSecond:L,numPastes:a,textSuggestionsV2:h,suggestionsCounters:[{source:"gpt",countOffered:v.filter(U=>U.source==="gpt").length}],agentId:(oe=e.info.agentInfo)==null?void 0:oe.agentId,agentName:(be=e.info.agentInfo)==null?void 0:be.agentName,agentEmail:(_=e.info.agentInfo)==null?void 0:_.agentEmail}}function pa(t,e){var s;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return pa(o,e);let r=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;return r?pa(r,e):null}function ua(t,e){return pa(t,e)}function Ru(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Oh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Ns(t){return Oh(t)&&(dn(t)||ss(t))}var Iu,Ye=new Map,Dh=["bottom","height","left","right","top","width"],Pu=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:Dh.some(n=>t[n]!==e[n]);function Lu(t){var n,o,r;if(t.ownerDocument===document)return[];let e=(r=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?r:null;return e?[e,...Lu(e)]:[]}function Au(t,e){return!t||!e?null:S(g({},t),{top:t.top+e.top,left:t.left+e.left})}var Os=!1,Mu=()=>{Os=!0;let t=[];if(Ye.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),Ye.delete(n);return}let o=n.getBoundingClientRect();Pu(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{let n=e.parentRects?e.parentRects.reduce(Au,e.rect):e.rect;Pu(n,e.totalRect)&&e.callbacks.forEach(o=>o(n)),e.totalRect=n}),Ye.size===0){Os=!1;return}Iu=window.requestAnimationFrame(Mu)};function ma(t,e){let n=Lu(t),o=[],r=n.map((s,i)=>ma(s,l=>{o[i]=l;let d=Ye.get(t);if(!d)return;let a=o.reduce(Au,d.rect);d.callbacks.forEach(c=>c(a))}));return{observe(s=!0){if(r.forEach(i=>i.observe(!1)),Ye.has(t)){let i=Ye.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Ye.set(t,{rect:void 0,callbacks:[e],parentRects:o});s&&!Os&&Mu()},unobserve(){r.forEach(i=>i.unobserve());let s=Ye.get(t);if(s){let i=s.callbacks.indexOf(e);i>=0&&s.callbacks.splice(i,1),s.callbacks.length||Ye.delete(t),Ye.size||(cancelAnimationFrame(Iu),Os=!1)}}}}var Nu,et=new Map,Ou=()=>{et.forEach((t,e)=>{if(!e.isConnected){et.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,r=o>n;t.visible!==r&&(t.visible=r,t.callbacks.forEach(s=>s(t.visible)))}),et.size!==0&&(Nu=window.requestAnimationFrame(Ou))};function Du(t,e){return{observe(){let n=et.size===0;et.has(t)?et.get(t).callbacks.push(e):et.set(t,{visible:void 0,callbacks:[e]}),n&&Ou()},unobserve(){let n=et.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||et.delete(t),et.size||cancelAnimationFrame(Nu)}}}}var ga=["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 fa(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function Zn(t){return Number.parseFloat(t)}function Ds(t){return Math.round(t*1e6)}function _u(t){return t/1e6}function ha(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,r=Zn(t.width),s=Zn(t.borderLeftWidth),i=Zn(t.borderRightWidth),l=Zn(t.paddingRight),d=_u(Ds(r)-Ds(s)-Ds(i)),a=_u(Ds(o));if(d-a>2){let c=d-a;n.style.paddingRight=`${l+c}px`}}function Xo(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",en(n);let o=window.getComputedStyle(t),r=!0,s=()=>{n.scrollTop=t.scrollTop};fa(o,n,ga),ha(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",s));let i=Du(t,()=>{fa(o,n,ga),ha(o,t,n),s(),setTimeout(s,0)}),l,d=!0,a=ma(t,p=>{if(p===null){e.onRemove&&e.onRemove(),n.remove();return}if(!d&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),d=!0),clearTimeout(l),l=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),d=!1},200),p.height===0&&p.width===0){if(r===!0)return;e.onHide&&e.onHide(),n.style.display="none",r=!0;return}if(fa(o,n,ga),ha(o,t,n),s(),n.style.top=`${p.top}px`,n.style.left=`${p.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let m=e.closestScrollElement.getBoundingClientRect(),f=window.getComputedStyle(e.closestScrollElement),h=Zn(f.borderTopWidth),v=Zn(f.borderBottomWidth),w=m.top+h-p.top,E=p.top+p.height+-(m.top+m.height-v);n.style.clipPath=`inset(${w}px 0px ${E}px 0px)`}r&&(n.style.display="block",e.onShow&&e.onShow(),r=!1)});return e.appendTo?e.appendTo.appendChild(n):(u=t.parentElement)==null||u.appendChild(n),a.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",s),a.unobserve(),i.unobserve()}]}var Fu=(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){T.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function _h(t){return t.offsetParent!==null}function Hu(t){if(!_h(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 _s(t,e,n=100){let o=Hu(t);e({isVisible:o});let r=setInterval(()=>{let s=Hu(t);s!==o&&(o=s,e({isVisible:o}))},n);return()=>{clearTimeout(r)}}var B=require("react/jsx-runtime");var Ku=Fu("showTabHint",!0),Qn=class Qn{constructor({deepdeskUrl:e,version:n=Qn.version||"unknown",locale:o="en-US",token:r,fetch:s,productName:i,createCustomChannel:l}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.floatingMenu=null;this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let d=e.replace(/\/api$/,"");this.deepdeskApi=new St(d,{token:r,fetch:s}),this.version=n,this.instanceId=Qn.count++;let a={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Cu({broadcast:(c,u,p)=>{this.broadcastEvents.send(c,u,p)},emit:(c,u)=>this.emit(c,u),handleAfterSendMessage:c=>this.handleAfterSendMessage(c),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:c=>this.logSendMessage(c),onUpdateShowTabHint:c=>Ku.update(c),sendEvent:(c,u)=>this.deepdeskApi.sendEvent(c,u)})]};this.store=wu(a),this.broadcastEvents=new au({debug:!0,deepdeskUrl:d,eventMap:Bl(this.store),createCustomChannel:l}),this.store.dispatch(Do(Ku.value())),this.store.dispatch(ar({locale:o,adminUrl:d,productName:i}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var e;return(e=this.state.input.textSuggestions[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?(T.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(T.warn("Profile has not been loaded (yet)"),!0):(T.warn("No conversation loaded (yet)"),!0)}login(){this.store.dispatch(bn(null)),this.store.dispatch(nt());let e=n=>de(n)&&Ya(n)!=="loading";return new Promise(n=>{let o=this.subscribe(e,r=>{r&&(o(),n())});this.unmountHandlers.push(()=>{o()})})}isLoggedIn(){return y(this,null,function*(){return(yield this.store.dispatch(nt())).payload})}isConversationSupported(e,n){return y(this,null,function*(){return(yield this.store.dispatch(zs({externalId:e,options:n}))).payload})}createConversation(e){return y(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(lr(S(g({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}getConversationByExternalId(e,n){return y(this,null,function*(){return this.hasConversation()&&this.externalId()!==e&&this.resetConversation(),(yield this.store.dispatch(dr({externalId:e,options:n}))).payload})}upsertConversation(e){return y(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Ws(S(g({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return y(this,null,function*(){return(yield this.store.dispatch(pr(e))).payload})}updateConversation(e){return y(this,null,function*(){return(yield this.store.dispatch(cr(e))).payload})}resetConversation(){this.store.dispatch(Z()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(ar(e))}setVisitorInfo(e){this.store.dispatch(Ll(e))}setCustomData(e){this.store.dispatch(Al(e))}setAgentInfo(e,n){return y(this,null,function*(){yield this.store.dispatch(oo(g(g({},e),n)))})}setAgentSettings(e){return y(this,null,function*(){yield this.store.dispatch(qs(e))})}getAgentSettings(){return y(this,null,function*(){return(yield this.store.dispatch($s())).payload})}refresh(){return y(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(fr({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let e=[];return this.store.dispatch(Zr()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})})}notifyExternalSuggestion(e){this.store.dispatch(De(e))}evaluateAssistant(e,n){return y(this,null,function*(){let c=n||{},{input:o={},transcript:r,showCuesInWidget:s=!0,includeMetadata:i,expectFormat:l}=c,d=A(c,["input","transcript","showCuesInWidget","includeMetadata","expectFormat"]);Object.assign(o,d);let a=yield this.store.dispatch(He({assistantCode:e,expectFormat:l||"json-schema:cues",transcript:r,includeMetadata:i,input:o,skipState:!s}));if(a.error)throw new Error(a.error.message);return a.payload})}evaluateConversationAssistant(e,n){return y(this,null,function*(){yield this.loadProfileConfig();let o=this.state.profile.data;if(!o){T.warn("Can't evaluate assistant when profile is not loaded yet.");return}let s=o[{accepted:"conversationAcceptedAssistant","new-message":"conversationNewMessageAssistant",ended:"conversationEndedAssistant"}[e]];if(!s){T.warn(`No assistant set in profile for conversation event "${e}"`);return}yield this.evaluateAssistant(s,g({transcript:"stored-transcript",includeMetadata:!0},n))})}getSummary(){return y(this,null,function*(){var n;if(!this.hasConversation())return T.warn("No conversation to create summary for."),null;(n=this.state.profile.data)!=null&&n.summarizerAssistantNew||T.warn("No profile loaded yet, or no summarizer assistant set in profile");let e=yield this.store.dispatch(Fe({}));if(e.error)throw new Error(e.error.message);return e.payload})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:s,selection:i}=this.state.input,{inlineSuggestions:l,showTextSuggestions:d}=this.settings,a=l?"below":"above",c=r.length>0;if(this.store.dispatch(vl(js(e))),!Ze(this.state)||e.key!=="Tab"&&!d)return;let u=()=>{n||!c||i&&(e.shiftKey||(this.store.dispatch(bl()),e.preventDefault()))},p=()=>{n||!c||l&&s<=0||i&&(e.shiftKey||(this.store.dispatch(wl()),e.preventDefault()))};switch(e.key){case"ArrowUp":a==="below"?p():u();break;case"ArrowDown":{a==="below"?u():p();break}case"Escape":{n||(this.store.dispatch(gr(-1)),this.store.dispatch(Lt({collapse:!0})),this.store.dispatch(Pc(!0)),e.preventDefault());break}case"Tab":{e.preventDefault();let m=Tn(this.state);if(!m)return;this.store.dispatch(Do(!1)),this.store.dispatch(De({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=Tn(this.state);if(!m)return;this.store.dispatch(De({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=Tn(this.state);if(!m)return;this.store.dispatch(De({text:m.text,suggestion:m,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),e.preventDefault();break}default:}n&&o&&this.store.dispatch(Lt({collapse:!1}))}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Et([]))}handlingTimeStart(){this.state.handlingTime.startTime||(T.info("Start handling time"),this.store.dispatch(mu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(T.info("Stop handling time"),this.store.dispatch(Is()))}logSendMessage(e){let n=ku("input",this.state,{version:this.version});n&&(e&&(Object.assign(n,{text:e}),Object.assign(n,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let e=Eu(this.state,{version:this.version});e&&(this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(gu()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch(zt((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(Tl()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(r=>{try{r(n)}catch(s){T.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),T.error(s)}})}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(Ml(e))}whenConversationLoaded(e){let n=r=>{var s;return(s=r.conversation.current)==null?void 0:s.id},o=()=>this.loadProfileConfig().then(()=>e());n(this.state)&&o(),this.subscribe(n,r=>{r&&o()})}overlayContainerFactory(e,n,o,r){let[s,i]=Xo(n,o);return s.setAttribute("translate","no"),s.dataset.testid=e,r&&s.classList.add(r),this.unmountHandlers.push(()=>{(0,J.unmountComponentAtNode)(s),i(),s.remove()}),s}createInlineContainer(e,n){var l;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 r=document.createElement("div");r.style.display="none",r.style.position="absolute",r.style.height="0px",r.style.width="0px",r.style.backgroundColor="red",o.appendChild(r);let s=(l=e.ownerDocument.defaultView)==null?void 0:l.frameElement,i=s?s.ownerDocument.defaultView:null;if(s&&(i===window||(i==null?void 0:i.parent)===window)){let[d,a]=Xo(s,{appendTo:document.body,onMoveStart:()=>{r.style.display="none"}});d.dataset.testid=n,d.style.zIndex="2",d.appendChild(o),this.unmountHandlers.push(()=>{(0,J.unmountComponentAtNode)(r),a()})}else document.body.appendChild(o);return r}createContainer(e,n=document.body){let o=window.getComputedStyle(n),r=document.createElement("div");return en(r),r.dataset.testid=e,r.style.color=o.color,r.style.fontSize=o.fontSize,r.style.fontFamily=o.fontFamily,r.style.fontVariant=o.fontVariant,r.setAttribute("translate","no"),n.appendChild(r),this.unmountHandlers.push(()=>{(0,J.unmountComponentAtNode)(r),r.remove()}),r}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),T.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()?(T.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Cl(o.metrics))):T.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(!Ns(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let p=n,{customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i,inputMediator:l}=p,d=A(p,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),a={customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i};this.configure(d),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),en(e),this.inputMediator=l||(dn(e)?new un(e):new pn(e)),this.inputMediator.on("change",({plainText:m,rawHTML:f})=>{this.store.dispatch(fr({text:m,html:f}))}),this.inputMediator.on("keyup",m=>{this.store.dispatch(xl(js(m)))}),this.inputMediator.on("keydown",m=>{this.handleKeyDown(m)}),this.inputMediator.on("paste",({pastedText:m,selectionText:f})=>{this.store.dispatch(Sl({text:m,selectionText:f}))}),this.inputMediator.on("cut",({selectionText:m})=>{this.store.dispatch(yl(m))});let c;this.inputMediator.on("selection",m=>{clearTimeout(c),m===null?c=setTimeout(()=>{m!==null&&this.store.dispatch(hr(m))},500):this.store.dispatch(hr(m))}),this.inputMediator.on("disabled",()=>{var m;(m=this.inputMediator)==null||m.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(es(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(es(!0))}),this.renderSuggestions(e,a),this.subscribe(to("inlineSuggestions"),()=>{this.renderSuggestions(e,a)});let u=this.renderOverlays(n);this.unmountHandlers.push(()=>{u.unmount()}),this.store.dispatch(fr({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(hr(this.inputMediator.getSelection())),this.store.dispatch(es(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var m;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setExternalId((m=this.state.conversation.current)==null?void 0:m.externalId)}),this.isMounted=!0}subscribe(e,n){let o=e(this.store.getState());return this.store.subscribe(()=>{let r=e(this.store.getState());r!==o&&(o=r,n(o))})}unmount(){var e,n,o,r;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.floatingMenu)==null||o.unmount(),this.unmountHandlers.forEach(s=>s()),this.unmountHandlers=[],(r=this.inputMediator)==null||r.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderSuggestions(e,n){var o,r,s;(o=this.floatingMenu)==null||o.unmount(),(r=this.inlineSuggestions)==null||r.unmount(),(s=this.aboveSuggestions)==null||s.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(e,n)),this.settings.inlineSuggestions?this.inlineSuggestions=this.renderInlineSuggestions(e,n):this.aboveSuggestions=this.renderAboveSuggestions(e,n)}renderInlineSuggestions(e,n){let{customStyles:o}=n,r=this.createInlineContainer(e,"deepdesk-caret");(0,J.render)((0,B.jsx)(Mt,{store:this.store,customStyles:o,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(Kc,{})})}),r);let s=i=>{i?(r.style.display="block",r.style.top=`${i.top}px`,r.style.left=`${i.left}px`):r.style.display="none"};return this.inputMediator.on("caretposition",s),{unmount:()=>{var i;(0,J.unmountComponentAtNode)(r),(i=this.inputMediator)==null||i.off("caretposition",s),r.remove()}}}renderAboveSuggestions(e,n){let{customStyles:o,closestScrollSelector:r,appendOverlayTo:s}=n,i=r&&ua(e,r)||void 0,l=this.overlayContainerFactory("deepdesk-tab-completion",i||e,{appendTo:s,closestScrollElement:i,mirrorOverflow:!0,onRemove:()=>this.unmount()},o==null?void 0:o.rootNode),d=this.overlayContainerFactory("deepdesk-suggestions-overlay",i||e,{appendTo:s},o==null?void 0:o.suggestionsRootNode);return(0,J.render)((0,B.jsx)(Mt,{store:this.store,customStyles:o,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(xp,{inputElement:e})})}),l),(0,J.render)((0,B.jsx)(Mt,{store:this.store,customStyles:o,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(Zc,{onLogIn:()=>this.loginViaPopup().catch(a=>T.warn(a.message))})})}),d),{unmount(){(0,J.unmountComponentAtNode)(l),(0,J.unmountComponentAtNode)(d),l.remove(),d.remove()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:r,appendOverlayTo:s,floatingMenuParent:i}=n,l=r&&ua(e,r)||void 0,d=this.overlayContainerFactory("floating-menu",l||e,{appendTo:i!=null?i:s},o==null?void 0:o.floatingMenuParent);return(0,J.render)((0,B.jsx)(Mt,{store:this.store,customStyles:o,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(Ec,{onLogIn:()=>this.loginViaPopup().catch(a=>T.warn(a.message))})})}),d),{unmount(){(0,J.unmountComponentAtNode)(d),d.remove()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays");return(0,J.render)((0,B.jsx)(Mt,{store:this.store,customStyles:n,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(vc,{})})}),o),{unmount(){(0,J.unmountComponentAtNode)(o),o.remove()}}}renderWidget(e,n={}){if(this.widgetRoot&&T.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:r,isEmbedded:s}=n;this.widgetRoot=e,this.configure({showImages:r,isEmbedded:s}),(0,J.render)((0,B.jsx)(Mt,{store:this.store,customStyles:o,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(tu,{knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(i=>T.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setExternalId((i=this.state.conversation.current)==null?void 0:i.externalId)})}unmountWidget(){this.widgetRoot&&(0,J.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}renderKnowledgeAssistantWidget(e,n,o={}){let{customStyles:r,initialQuestion:s}=o;return(0,J.render)((0,B.jsx)(Mt,{store:this.store,customStyles:r,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(oa,{children:(0,B.jsxs)(ws,{assistantCode:e,initialQuestion:s,evaluateKnowledgeAssistFn:o.isLegacyKnowledgeAssist?qt:$t,children:[(0,B.jsx)(yn,{children:(0,B.jsx)(Ts,{emptyState:o.emptyState})}),(0,B.jsx)(na,{children:(0,B.jsx)(Cs,{})})]})})})}),n),{unmount(){(0,J.unmountComponentAtNode)(n),n.remove()}}}setupHandlingTime(e){let n=_s(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Ru(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>y(this,null,function*(){yield this.store.dispatch(wo());let e=Gt(this.state);e&&this.store.dispatch(ar({showSearch:e.search,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:!!e.summarizerAssistantNew||e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistantNew||!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions}))})),this.loadProfileConfigPromise)}loginViaPopup(e){return y(this,null,function*(){return new Promise((n,o)=>{let r=new MessageChannel,s=r.port1,i=this.settings.adminUrl,l=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);l.searchParams.append("redirect","/sdk/popup/close.html");let d=!1,a=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",u),clearInterval(p)};s.onmessage=m=>y(this,null,function*(){var f,h;if((f=m.data)!=null&&f.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((h=m.data)==null?void 0:h.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(so),d=!0,r.port1.close(),n()}catch(v){console.error(v),o(v)}finally{d=!0,a()}});let c=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&o(new Error("Popup blocked by browser"));let u=m=>y(this,null,function*(){var f;if(m.origin===l.origin)switch((f=m.data)==null?void 0:f.type){case"deepdesk-popup-loaded":{try{let h=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(h,l.origin,[r.port2])}catch(h){T.error("Error posting message to popup",h),o(h)}break}case"deepdesk-popup-error":{a(),m.data.message==="Timeout"&&T.warn("Popup timed out. Check if the account's platform url is configured correctly."),o(new Error(m.data.message));break}}});window.addEventListener("message",u);let p=setInterval(()=>{c&&!c.closed||(a(),d||o(new Error("Popup closed by user")))},200);this.unmountHandlers.push(a)})})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}checkForTrialMode(e){return y(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(T.info("Trial is active"),!(yield this.deepdeskApi.checkUserExists(e)))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:o}=n;T.info(o),this.shouldRender=!1}})}refreshWidgetSuggestions(){return y(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=Co(this.state);try{n.forEach(({type:o})=>{o==="entities"?this.store.dispatch(Be()):ir.includes(o)||this.store.dispatch(Ve(o))})}catch(o){this.handleError(o)}})}};Qn.version="17.0.0-rc.4",Qn.count=0;var Zo=Qn;function Fh(t){return y(this,null,function*(){var r,s,i;let n=yield((r=t.fetch)!=null?r:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(s=t.mimeType)!=null?s:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function Bu(t,e){return y(this,null,function*(){let n=yield Fh(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 Uu(t,e,n){return y(this,null,function*(){yield new St(t).authenticateWithKey(e,n)})}function Vu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function zu(o,r){return y(this,arguments,function*(t,e,n={}){var u,p;let{value:s}=t,{start:i,end:l}=(u=n.replace)!=null?u:{start:0,end:s.length},d=`${s.slice(0,i)}${e}${s.slice(l)}`,a=(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=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})})}function Wu(o,r){return y(this,arguments,function*(t,e,n={}){let s=n.replace?Dt(t,n.replace.start,n.replace.end):$n(t),i,l=()=>{if(n.setRange)return n.setRange(s.cloneRange());s.deleteContents(),i=document.createElement("span"),s.insertNode(i),n.insertBRs!==!1?e.split(`
11
- `).reverse().forEach((d,a)=>{a>0&&s.insertNode(document.createElement("br")),s.insertNode(document.createTextNode(d))}):s.insertNode(document.createTextNode(e))};return Promise.resolve(l()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let d=n.selectionAfter?Dt(t,n.selectionAfter.start,n.selectionAfter.end):(s.collapse(!1),s),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(d)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function Hh(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 Kh(t){let e=document.createDocumentFragment();return t.split(`
12
- `).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let r={index:0},s=0;for(;r=n.slice(s).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=r[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(r[2])),e.appendChild(document.createTextNode(n.slice(s,s+r.index))),e.appendChild(i),s=s+r.index+r[0].length}e.appendChild(document.createTextNode(n.slice(s)))}),e}function ju(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):ju(n,e)}function qu(r,s){return y(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 l=()=>{var p;let d=(p=t.ownerDocument.defaultView)!=null?p:window,a=d.getSelection();if((!a||a.rangeCount===0)&&(t.focus(),a=d.getSelection()),!a||a.rangeCount===0)return;let c=a.getRangeAt(0);if(!c)return;i=document.createElement("span"),c.insertNode(i);let u=o?Hh(e):Kh(e);n?ju(c.startContainer,u):(c.insertNode(u),c.collapse(!1))};return Promise.resolve(l()).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()}})})}0&&(module.exports={Card,ContentEditableInput,DeepdeskAPI,DeepdeskSDK,HTTPClient,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createFullRange,createOverlayContainer,createRangeFromOffsets,escapeHTML,formatTextMarkup,getRangeOffsets,getRangeText,insertCKEditor,isHTML,isSupportedInputElement,updateContentEditable,updateTextArea,useClickOutsideRoot,useStyles,waitForElementVisibilityChange});
8
+ c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Mi=require("react/jsx-runtime"),sf={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Sc=({className:t,color:e})=>(0,Mi.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Mi.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:sf[e||"pink"]})});var xc={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var Ni={};re(Ni,{enUS:()=>af,nlNL:()=>lf});var af={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},lf={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Cc=require("react-redux"),an=require("react/jsx-runtime"),Tc=({onLogIn:t})=>{let e=k(Ni),n=C("floatingMenu"),o=C("productName"),r=(0,Cc.useDispatch)(),s=(0,wc.useSelector)(de),i=S("FloatingMenu",xc);if(s===null||n===!1)return null;let a=()=>{s===!0?r(Re(!0)):t()};return(0,an.jsxs)("button",{type:"button",className:(0,bc.default)(i.root,{[i.isLoggedIn]:s,[i.isLoggedOut]:!s}),onClick:a,children:[(0,an.jsx)("div",{className:i.text,children:e(s?"search":"signin",{productName:o})}),(0,an.jsxs)("div",{className:i.icon,children:[(0,an.jsx)(Sc,{className:i.logo,color:"pink"}),s===!1&&(0,an.jsx)(vc,{className:i.lock})]})]})};var ns=require("react"),ut=require("react-redux");function Ze(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:r,selection:s}=t.input;return s.start!==s.end?!1:s.end>=r.length?!0:e?n&&new RegExp(n).test(r.substring(s.end))||o&&new RegExp(o).test(r.substring(0,s.end))?!0:n===!1&&o===!1:!1}var Ec=require("@reduxjs/toolkit"),df={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Yr=({ui:t})=>t.overlayCollapsed,kc=(0,Ec.createSlice)({name:"ui",initialState:df,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:Do,setInputFocus:es,setOverlayCollapsed:Lt,setOpenOverlayWhenTyping:Rc,setOverlayCollapsedUserOverwrite:Pc}=kc.actions,Ic=kc.reducer;var Dc=require("react");var Nc=require("interweave"),At=require("react"),_o=require("react-redux");var Lc=require("react");function Ac(t,e,n){(0,Lc.useEffect)(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var Mc={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var ln=require("react/jsx-runtime"),pf=["search","personal-collection-search","search-autocomplete"];function uf(t,e,n,o={}){var s;let r="";return pf.includes(e)?r=vd(ui(t,n,{stripAgentPart:!0}),(s=o.searchKeywords)!=null?s:[n]):r=ui(t,n,o),o.placeholders===!0&&(r=Sd(r)),r}var mf=()=>{},gf=({selected:t,suggestion:e})=>{let n=C("inlineSuggestions"),o=(0,_o.useSelector)(Cn),[r,s]=(0,At.useState)(!1),i=C("enableSuggestionFeedback"),a=(0,_o.useSelector)(p=>p.input.text),d=(0,_o.useDispatch)(),l=S("TextSuggestion",Mc),c=(0,At.useRef)(null);(0,At.useEffect)(()=>{let p=setTimeout(()=>{d(fl({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(p)}},[e]),Ac(c,"click",()=>{d(De({suggestion:e,text:e.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,At.useMemo)(()=>uf(e.text,e.source,o,{stripAgentPart:n,placeholders:!0,searchKeywords:e.searchKeywords}),[n,e.text,e.source,o,e.searchKeywords]);return e.source==="gpt"&&!n?null:(0,ln.jsxs)("div",{className:l.root,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[(0,ln.jsx)(F,{ref:c,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:mf,children:(0,ln.jsx)(Nc.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:l.formattedText,content:u})}),i&&r&&(0,ln.jsx)("div",{className:l.actions,children:(0,ln.jsx)(Gr,{source:"overlay",context:a,suggestion:e})})]})},Oc=gf;var _c=require("react/jsx-runtime"),ff=({suggestions:t,selectedIndex:e,reverse:n})=>(0,Dc.useMemo)(()=>{let r=t.map((s,i)=>(0,_c.jsx)(Oc,{index:i,selected:i===e,suggestion:s},`${s.text}-${s.source}`));return n?r.reverse():r},[t,e,n]),ts=ff;var Fc={root:"dd-PfvRI",paper:"dd-HYlyY"};var Fo=require("react/jsx-runtime"),hf=({textSuggestions:t,selectedIndex:e})=>{let n=(0,ns.useRef)(null),o=S("InlineSuggestionsOverlay",Fc),r=(0,ut.useSelector)(Ze),s=(0,ut.useDispatch)(),i=(0,ut.useSelector)(de),a=(0,ut.useSelector)(wn),d=(0,ut.useSelector)(Yr),l=C("showTextSuggestions");return It(()=>{setTimeout(()=>{s(Lt({collapse:!0,skipWhenInputFocus:!0}))})}),(0,ns.useEffect)(()=>{let c=n.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`}),d||!r||!l||t.length===0||i!==!0||a===!1?null:(0,Fo.jsx)("div",{className:o.root,"data-variant":"inline",children:(0,Fo.jsx)("div",{ref:n,className:o.paper,children:(0,Fo.jsx)(ve,{children:(0,Fo.jsx)(ts,{suggestions:t,selectedIndex:e})})})})},yf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Hc=(0,ut.connect)(yf)(hf);var Kc=require("react-redux");var Ho=require("react/jsx-runtime"),vf=({children:t})=>{let n=C("locale").replace("-","");return(0,Ho.jsx)(ii.Provider,{value:n,children:t})},Sf=({store:t,customStyles:e={},children:n})=>(0,Ho.jsx)(Kc.Provider,{store:t,children:(0,Ho.jsx)(vf,{children:(0,Ho.jsx)(Yn.Provider,{value:e,children:n})})}),Mt=Sf;var rs=M(require("classnames")),Bn=require("react"),gt=require("react-redux");var Bc=require("react");function Uc(t,e){let[n,o]=(0,Bc.useState)(()=>{if(typeof window=="undefined")return e;try{let s=window.localStorage.getItem(t);return s?JSON.parse(s):e}catch(s){return T.error(s),e}});return[n,s=>{try{let i=s instanceof Function?s(n):s;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){T.error(i)}}]}var Vc=()=>/Mac/i.test(navigator.platform);var Wc=M(require("classnames")),mt=require("react");var Oi={};re(Oi,{enUS:()=>xf,nlNL:()=>bf});var xf={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"}]}]},bf={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 zc={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var Nt=require("react/jsx-runtime"),Di=(t,e,n)=>o=>(0,Nt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),wf=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o,onLogIn:r})=>{let s=k(Oi),i=xe(),a=S("Login",zc),d=C("productName"),l=(0,mt.useCallback)(y=>{y.preventDefault(),o&&o(Number.parseInt(y.target.value,10))},[]),c=(0,mt.useCallback)(y=>{y.preventDefault(),i.send(Pn,!0)},[e]),u=(0,mt.useMemo)(()=>y=>(0,Nt.jsx)("a",{onClick:E=>{E.preventDefault(),r()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:y},"login"),[e]),p=(0,mt.useCallback)(y=>(0,Nt.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:y},"prompt"),[c]),{min:m,hour:h,day:f}=(0,mt.useMemo)(()=>({min:Di(a,60*10,l),hour:Di(a,60*60,l),day:Di(a,60*60*12,l)}),[]);return(0,Nt.jsxs)("div",{className:(0,Wc.default)(t,a.root),children:[s("loginPlease",{login:n?p:u,productName:d}),o&&(0,Nt.jsxs)(mt.Fragment,{children:[(0,Nt.jsx)("br",{}),s("snooze",{min:m,hour:h,day:f})]})]})},os=wf;var jc=require("react-redux");var qc={root:"dd-DoQhb",text:"dd-Jwnev"};var Ko=require("react/jsx-runtime"),Cf=({title:t})=>{let e=S("SearchTrigger",qc),n=(0,jc.useDispatch)(),o=Q();return(0,Ko.jsxs)("button",{type:"button",className:e.root,onClick:()=>{n(Re(!0)),o("open search",{via:"autocomplete-overlay"})},children:[(0,Ko.jsx)(Mn,{}),(0,Ko.jsx)("span",{className:e.text,children:t})]})},$c=Cf;var _i={};re(_i,{enUS:()=>Tf,nlNL:()=>Ef});var Tf={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"}]},Ef={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}]};var Gc={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2"};var V=require("react/jsx-runtime"),kf=({textSuggestions:t,selectedIndex:e,onLogIn:n})=>{let o=S("SuggestionsOverlay",Gc),r=k(_i),s=(0,gt.useSelector)(Ze),i=gl(),a=(0,gt.useDispatch)(),d=(0,Bn.useRef)(null),l=C("searchTriggerKey"),c=C("productName"),u=(0,gt.useSelector)(Yr),p=(0,gt.useSelector)(de),m=(0,gt.useSelector)(wn),[h,f]=(0,Bn.useState)(null),y=C("showSearch"),b=C("showTextSuggestions"),E=C("adminUrl"),w=C("isEmbedded"),[I,N]=Uc("dd-snooze-until-ms",0),L=u||I>Date.now(),D=t.filter(be=>be.source!=="gpt").length,q=()=>{L&&N(0),a(Pc(!L))},oe=be=>{let _=Date.now()+be*1e3;N(_),T.info(`Snooze until: ${new Date(_)}`),a(Lt({collapse:!0}))};return(0,Bn.useEffect)(()=>{D===0&&f(null)},[t,D]),It(()=>{a(Lt({collapse:!0,skipWhenInputFocus:!0}))}),p===null||m===!1?null:p===!1?(0,V.jsxs)("div",{ref:d,className:(0,rs.default)(o.root,{[o.isCollapsed]:L}),children:[!L&&(0,V.jsxs)("div",{className:o.triggers,children:[(0,V.jsx)("div",{style:{flex:1}}),(0,V.jsx)("div",{className:o.triggersRight,children:(0,V.jsx)(Bt,{className:o.toggleButton,title:r("collapse"),onClick:q,isCollapsed:!1})})]}),(0,V.jsx)("div",{className:o.toggleButtonWrapper,children:(0,V.jsx)(Bt,{className:o.toggleButton,title:r("open",{productName:c}),onClick:q,isCollapsed:!0})}),(0,V.jsx)("div",{className:o.collapsible,children:(0,V.jsx)(os,{loginUrl:E,isEmbedded:w,onLogIn:n,onSnooze:oe})})]}):!i||!s?null:(0,V.jsxs)("div",{ref:d,className:(0,rs.default)(o.root,{[o.isCollapsed]:L}),children:[!L&&(0,V.jsxs)("div",{className:o.triggers,children:[(0,V.jsx)("div",{style:{flex:1},children:y&&(0,V.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(r(Vc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,V.jsx)($c,{title:r("search")})})}),(0,V.jsxs)("div",{className:o.triggersRight,onFocus:()=>{},children:[(0,V.jsx)("div",{className:(0,rs.default)(!h&&o.hintsHidden,o.hints),children:h}),(0,V.jsx)(Bt,{className:o.toggleButton,title:r("collapse"),onClick:q,isCollapsed:!1})]})]}),(0,V.jsx)("div",{className:o.toggleButtonWrapper,children:(0,V.jsx)(Bt,{className:o.toggleButton,title:r("open",{productName:c}),onClick:q,isCollapsed:!0})}),D>0&&b&&(0,V.jsx)("div",{className:o.collapsible,onFocus:()=>{},children:(0,V.jsx)(ve,{children:(0,V.jsx)(ts,{suggestions:t,selectedIndex:e,reverse:!0})})})]})},Rf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Xc=(0,gt.connect)(Rf)(kf);var hs=M(require("classnames")),fp=require("interweave"),yt=require("react"),hp=require("react-redux");var Un=require("react");function ss(t){return t.contentEditable==="true"}function Pf(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let r=o.getRangeAt(0),s=r.cloneRange();s.selectNodeContents(t),s.setEnd(r.endContainer,r.endOffset),n=s.toString().length,s.selectNodeContents(t),s.setEnd(r.startContainer,r.startOffset),e=s.toString().length}return{selectionStart:e,selectionEnd:n}}function Zc(t){let{selectionStart:e,selectionEnd:n}=ss(t)?Pf(t):t;return[e,n]}function Qc(t){let[,e]=(0,Un.useState)(),n=(0,Un.useRef)(null);return n.current=Zc(t),(0,Un.useEffect)(()=>{let o=()=>{var a;let[r,s]=(a=n.current)!=null?a:[],i=Zc(t);(!i||r!==i[0]||s!==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 Jc(t,e){if(!e)return;let n=t,{value:o}=n,[r,s]=e,i=o.match(sr);if(!i||i.length===0)return;let a=0;i.find(d=>{let l=o.indexOf(d,a);return r>l&&s<l+d.length?(n.selectionStart=l,n.selectionEnd=l+d.length,!0):(a=l+d.length,!1)})}var Yc=require("react"),If=["div","span","mark","strong","b","i","u","em"];function Fi(t,e,n=0){var s;let o=t[t.length-1],r=typeof o=="object"&&o!==null?(s=o.props)==null?void 0:s.tagName:void 0;if(r==="br")return t.pop(),[...t,...e,o];if(If.includes(r)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),(0,Yc.cloneElement)(o,{children:Fi(i,e,n+1)})]}return[...t,...e]}function dn(t){return t.tagName.toLowerCase()==="textarea"}var ep={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var sp=M(require("classnames")),ip=require("interweave"),ps=require("react");var Vn=require("react");function tp(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let r=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...r)})},()=>window.cancelAnimationFrame(n)]}function is(t){let e=(0,Vn.useRef)(null),[n,o]=(0,Vn.useState)(!1);return(0,Vn.useEffect)(()=>{var c;let r=!1,s=Number.parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[i,a]=tp((u,p)=>{let m=e.current;if(!m)return;let h=u/s,f=p/s,y=m.getBoundingClientRect(),b=h>y.x&&h<y.x+y.width&&f>y.y&&f<y.y+y.height;b&&!r?(r=!0,o(!0)):!b&&r&&(r=!1,o(!1))},({clientX:u,clientY:p})=>[u,p]),[d,l]=tp(()=>{r=!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 np(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function as(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function op(t){return t!=null}var rp=M(require("classnames")),ls=require("react");var ft={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var Hi=require("react/jsx-runtime"),ds=(0,ls.forwardRef)((r,o)=>{var s=r,{className:t,children:e}=s,n=A(s,["className","children"]);let i=(0,ls.useRef)(null),a=S("TabCompletion",ft);return(0,Hi.jsx)("div",x(g({ref:as([i,o]),className:(0,rp.default)(t,a.popoverContentContainer)},n),{children:(0,Hi.jsx)("div",{className:a.popoverContent,children:e})}))});var Ot=require("react/jsx-runtime"),Lf=t=>e=>{let n=Ri(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},Af=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:r})=>{let s=S("TabCompletion",ft),i=qr(),a=(0,ps.useMemo)(()=>Lf(t.getBoundingClientRect()),[t]),[d,l]=is(t);return(0,ps.useEffect)(()=>{l?i.open():i.close()},[l]),(0,Ot.jsxs)("span",{children:[(0,Ot.jsx)("mark",{ref:as([d,i.triggerRef]),className:(0,sp.default)(s.matchKeyword,{[s.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&(0,Ot.jsx)(Kn,{className:s.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,Ot.jsx)(ds,{style:n,children:(0,Ot.jsx)("div",{className:s.hintText,children:r})})})]})},cs=class extends ip.Matcher{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(r=>x(g({},r),{keywordRegex:new RegExp(`\\b${np(r.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let i=n.match(s.keywordRegex);if(!i)return null;let a=n.charAt(i.index-1),d=n.charAt(i.index+s.keyword.length);return a==="{"&&d==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(op);if(o.length===0)return null;let r=o.reduce((s,i)=>i.index<s.index?i:s);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(n,o){return(0,Ot.jsx)(Af,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:n},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var ap=require("interweave"),lp=M(require("classnames"));var Ki=require("react/jsx-runtime"),Mf=({inputElement:t,children:e})=>{let n=S("TabCompletion",ft),[o,r]=is(t);return(0,Ki.jsx)("mark",{ref:o,className:(0,lp.default)(n.matchPlaceholder,{[n.hover]:r}),children:e})},us=class extends ap.Matcher{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(0,Ki.jsx)(Mf,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var gs=M(require("classnames")),mp=require("interweave"),me=require("react"),gp=require("react-redux");var Bi=require("react/jsx-runtime"),dp=()=>(0,Bi.jsx)("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:(0,Bi.jsx)("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});var Qe=require("react"),Bo=require("react-redux"),pp=M(require("lodash.debounce"));var cp={root:"dd-ky-Bv",content:"dd-kV5e1"};function ms(t,e,n){var r;let o=((r=t.imageSizes)==null?void 0:r[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(s){return null}}function Ui(t){return t.replace("https://www.","").replace("https://","")}var Me=require("react/jsx-runtime"),Nf=3,Of=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Df=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:r=Nf})=>{let s=S("LinkSearch",cp),[i,a]=(0,Qe.useState)(""),d=(0,Bo.useDispatch)(),l=(0,Bo.useSelector)(lc("url")),c=(0,Bo.useSelector)(_l("URL")),u=(0,Qe.useMemo)(()=>c.map(Of),[c]),[p,m]=(0,Qe.useState)(u.length-1),h=C("fallbackImage"),f=w=>{let I=w.target;a(I.value)},y=(w,I)=>{w.stopPropagation(),w.preventDefault(),window.open(I,"_blank")},b=w=>{var L;let I=p-1<0?u.length-1:p-1,N=p+1===u.length?0:p+1;w.code==="Escape"&&(a(""),e()),w.code==="ArrowUp"&&m(I),w.code==="ArrowDown"&&m(N),w.code==="Enter"&&t(((L=u[p])==null?void 0:L.text)||i)},E=(0,Qe.useCallback)((0,pp.default)(w=>{d(Wt({query:w,type:"URL",tags:["link-search"]}))},300),[]);return(0,Qe.useEffect)(()=>{i&&E(i)},[i]),(0,Qe.useEffect)(()=>()=>{d(vr())},[]),(0,Me.jsxs)("div",{className:s.root,children:[(0,Me.jsx)(ve,{withDivider:!0,children:(i?u:l).slice(0,r).map((w,I)=>(0,Me.jsx)(F,{selected:p===I,onClick:()=>t(w.text),"data-testid":"linksearch-suggestion",children:(0,Me.jsxs)(K,{children:[(0,Me.jsx)(K.Image,{src:ms(w,"small",h||void 0),title:w.title||w.text}),(0,Me.jsxs)(K.Content,{className:s.content,cropText:!0,children:[(0,Me.jsx)(K.Title,{children:w.title||Ui(w.text)}),w.title&&Ui(w.text)]}),(0,Me.jsx)(F.Actions,{children:(0,Me.jsx)(F.ActionButton,{label:o,onClick:N=>y(N,w.text)})})]})},w.text))}),(0,Me.jsx)(vo,{value:i,onChange:f,autoFocus:!0,placeholder:n,onKeyUp:b})]})},up=Df;var Vi={};re(Vi,{enUS:()=>_f,nlNL:()=>Ff});var _f={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Ff={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var ue=require("react/jsx-runtime"),Hf=(0,me.forwardRef)((t,e)=>{let n=S("TabCompletion",ft);return(0,ue.jsx)("mark",{ref:e,className:(0,gs.default)(n.matchSelection)},"selection-start")}),Kf=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:r})=>{let s=k(Vi),i=S("TabCompletion",ft),a=(0,me.useRef)(null),d=(0,me.useRef)(null),[l,c]=(0,me.useState)(null),u=(0,gp.useDispatch)(),p=qr(document.activeElement===o),[m]=(0,me.useState)(()=>document.createRange());p.triggerRef.current=m,(0,me.useEffect)(()=>()=>m.detach(),[]),(0,me.useEffect)(()=>{let f=t.current,y=a.current;!f||!y||(m.setStart(f,0),m.setEnd(y,0))},[t.current,a.current]),It(()=>{p.close()});let h=(0,me.useCallback)(f=>{let y=m.toString(),b=/^http(s?):\/\//.test(f)?f:`https://${f}`;u(ur({text:`[${y}](${b})`,replace:"selection"}))},[]);return(0,ue.jsxs)("span",{children:[(0,ue.jsx)("mark",{ref:a,className:(0,gs.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":p.opened?"true":"false",children:r}),p.opened&&(0,ue.jsx)(Kn,{className:i.popoverRoot,triggerRef:p.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,ue.jsxs)(ds,{style:n,ref:d,children:[(0,ue.jsx)("div",{className:(0,gs.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:l!==null}),children:(0,ue.jsxs)("button",{type:"button",tabIndex:l===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,ue.jsx)(dp,{}),(0,ue.jsx)("span",{children:"\xA0"}),(0,ue.jsx)("span",{children:s("insertLink")})]})}),l==="insertLink"&&(0,ue.jsx)(up,{placeholder:s("linkInputPlaceholder"),visitUrlText:s("visitUrl"),onSelectLink:h,onDismiss:()=>{c(null),p.close()}})]})})]},"selection-end")},fs=class extends mp.Matcher{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,o){return this.props=o,this.charCount=0,this.startRef=(0,me.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,r]=this.props.selection;if(o===r)return null;let s=this.foundIndex===0?o:r,i=s>=this.charCount&&s<=this.charCount+n.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let a=this.foundIndex===1;return i&&a?this.charCount+=s-this.charCount:this.charCount+=n.length,i?g({isStart:a},i):null}replaceWith(n,o){return o.isStart?(0,ue.jsx)(Hf,{ref:this.startRef}):(0,ue.jsx)(Kf,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var yp=require("react-redux");var ht=require("react/jsx-runtime"),Bf=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:r,showStyleSuggestions:s,keywordMatches:i,inputElement:a,source:d})=>{let l=S("TabCompletion",ep),c=C("insertLink"),u=C("showMidSentenceSuggestions"),p=C("inlineSuggestions"),m=Qc(a),h=(0,yt.useRef)(null),f=(0,yp.useSelector)(de);(0,yt.useEffect)(()=>{dn(a)&&m&&Jc(a,m)},[m]);let y=(0,yt.useCallback)(w=>{if(!r||!n)return w;let I=[(0,ht.jsx)("span",{className:l.resetIndent,children:"\u200B"},"u200B"),(0,ht.jsx)("span",{"data-testid":"tab-completion",className:(0,hs.default)(l.tabText,l.resetIndent),"data-source":d,children:n},"tabText")];return o&&I.push((0,ht.jsx)("span",{className:(0,hs.default)(l.hint,l.resetIndent),children:(0,ht.jsx)(or,{keyCode:"tab"},"tabHint")})),Fi(w,I)},[r,n,o]),b=(0,yt.useMemo)(()=>{let w=[];return c&&w.push(new fs("selection")),w.push(new us("placeholders")),s&&w.push(new cs("keywords")),w},[p,c,s]),E=(0,yt.useMemo)(()=>{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||!f?null:(0,ht.jsxs)("div",{ref:w=>{w!=null&&w.parentElement&&(h.current=w==null?void 0:w.parentElement)},className:l.root,style:E,children:[(0,ht.jsx)(fp.Interweave,{tagName:"span",containerTagName:"div",className:(0,hs.default)(l.container,l.agentText),disableLineBreaks:dn(a),content:e||"\u200B",onAfterParse:y,matchers:b,selection:m,keywordMatches:i,inputElement:a,inputStyle:E,boundaryRef:h,inlineSuggestionsOnlyAtEnd:!u}),(0,ht.jsx)("br",{})]})},Uf=t=>{var y,b,E;let{input:e,ui:n,settings:o,styleSuggestions:r,conversation:s}=t,i=Tn({input:e}),a=(i==null?void 0:i.text)||"",d=(i==null?void 0:i.source)||"",l=(y=e.html)!=null?y:An(e.text),c=a.indexOf(e.text)===0?a.slice(e.text.length):"",{showTabHint:u}=n,{isSupported:p}=s,{showTabCompletion:m,visible:h,showStyleSuggestions:f}=o;return{showTabHint:u,showStyleSuggestions:f,showTabCompletion:m&&Ze(t),content:l,tabText:c,source:d,keywordMatches:(E=(b=r.list)==null?void 0:b.keywordMatches)!=null?E:[],enabled:h&&p!==!1}},vp=(0,hp.connect)(Uf)(Bf);var jn=require("react"),j=require("react-redux");var Uo=require("@reduxjs/toolkit");var Vf={token:null,interval:null},zi=(0,Uo.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>v(void 0,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),Wi=(0,Uo.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(zi()),setInterval(()=>o(zi()),n)}),Sp=(0,Uo.createSlice)({name:"passwordlessToken",initialState:Vf,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(zi.fulfilled,(e,n)=>{e.token=n.payload.token}),t.addCase(Wi.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollPasswordlessToken:xp}=Sp.actions,bp=Sp.reducer;var wp=require("@reduxjs/toolkit");function zf(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}var Cp=(0,wp.createSelector)([rd],t=>t.map(n=>({text:n.response,title:n.name,callToAction:n.callToAction,isLoading:n.isLoading,specialType:n.specialType,rule:{id:zf(n.code),label:n.code,name:n.name,description:n.name}})));var ys=require("react"),Ep=require("react-redux"),ji=M(require("classnames"));var qi=require("react/jsx-runtime"),Vo=()=>(0,qi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,qi.jsx)("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var Tp={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var Je=require("react/jsx-runtime"),Wf=({entities:t})=>{let e=S("EntitiesWidgetList",Tp),[n,o]=(0,ys.useState)(void 0),r=(0,Ep.useDispatch)(),s=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),$e(a.text),r(ot({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,ys.useEffect)(()=>{let a=setTimeout(s,500);return()=>{clearTimeout(a)}},[n]),!t||t.length===0?null:(0,Je.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,d)=>(0,Je.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Je.jsx)("span",{className:e.entityText,children:a.text}),(0,Je.jsxs)("span",{className:e.iconWrapper,children:[(0,Je.jsx)("span",{className:(0,ji.default)(e.icon),children:(0,Je.jsx)(Vo,{})}),(0,Je.jsx)("span",{className:(0,ji.default)(e.icon,n===d&&e.iconClicked),children:(0,Je.jsx)(Vo,{})})]})]},a.text))})},kp=Wf;var $i=require("react/jsx-runtime"),Rp=()=>(0,$i.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,$i.jsx)("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});var Gi=require("react/jsx-runtime"),Pp=()=>(0,Gi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Gi.jsx)("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});var Xi=require("react/jsx-runtime"),Ip=()=>(0,Xi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Xi.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var Ji=require("react-redux");var Lp={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var Ap={root:"dd-nazq3",rotation:"dd-3EHTv"};var Np=require("react/jsx-runtime"),qf=({size:t=12})=>{let e=S("LoadingSpinner",Ap);return(0,Np.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},Mp=qf;var Zi=require("react/jsx-runtime"),Op=()=>(0,Zi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Zi.jsx)("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"})});var zo=require("react/jsx-runtime"),Dp=t=>(0,zo.jsxs)("svg",x(g({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},t),{children:[(0,zo.jsx)("title",{id:"checkTitle",children:"Check"}),(0,zo.jsx)("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 Qi={};re(Qi,{enUS:()=>jf,nlNL:()=>$f});var jf={error:[{type:0,value:"Something went wrong"}]},$f={error:[{type:0,value:"Er ging iets fout"}]};var Te=require("react/jsx-runtime"),_p,Gf=3e3,Xf=({assistantOptions:t})=>{let e=S("OnDemandAssistants",Lp),n=k(Qi),o=lt(He),r=lt(Fe),s=(0,Ji.useSelector)(cd),i=(0,Ji.useSelector)(pd),a=Q(),d=i.filter(u=>u.isPinned),l=i.filter(u=>!u.isPinned),c=u=>v(void 0,null,function*(){if(clearTimeout(_p),a("trigger on demand assistant",{assistantCode:u}),u===s){r.call({transcript:t.transcript});return}o.call(x(g({},t),{assistantCode:u})),_p=setTimeout(()=>o.reset(),Gf)});return i.length===0?null:(0,Te.jsxs)("div",{className:e.root,children:[d.map(({assistant:u,assistantName:p})=>(0,Te.jsx)("button",{type:"button",className:e.button,disabled:o.state==="loading",onClick:()=>c(u),children:p},u)),o.state==="loading"&&(0,Te.jsx)(Mp,{}),o.state==="done"&&(0,Te.jsx)(Dp,{"data-testid":"trigger-done"}),o.state==="error"&&(0,Te.jsx)(Ed,{trigger:(0,Te.jsx)(Op,{}),children:n("error")}),l.length>0&&o.state==="idle"&&(0,Te.jsxs)(ee,{placement:"top-end",children:[(0,Te.jsx)(ee.Trigger,{className:e.trigger,children:(0,Te.jsx)(jr,{"data-testid":"trigger"})}),(0,Te.jsx)(ee.Content,{className:e.nav,"data-testid":"popover",children:l.map(({assistant:u,assistantName:p})=>(0,Te.jsx)(ee.Button,{className:e.item,disabled:o.state==="loading",onClick:()=>c(u),children:p},u))})]})]})},Fp=Xf;var Vp=require("react-redux");var Bp=require("react");var Hp={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var Kp=require("react/jsx-runtime"),Zf=({width:t})=>{let e=S("LoadingProgressBar",Hp);return(0,Kp.jsx)("div",{className:e.loadingBar,style:{width:t}})},vs=Zf;var vt=require("react/jsx-runtime"),Ss=({title:t})=>{let e=(0,Bp.useRef)(null);return Da(e),(0,vt.jsx)(F,{ref:e,children:(0,vt.jsx)(K,{children:(0,vt.jsxs)(K.Content,{children:[(0,vt.jsx)(K.Title,{children:t}),(0,vt.jsx)(vs,{width:"60%"}),(0,vt.jsx)(vs,{width:"90%"}),(0,vt.jsx)(vs,{width:"50%"})]})})})};var Wo={};re(Wo,{enUS:()=>Qf,nlNL:()=>Jf});var Qf={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"}]},Jf={useCue:[{type:0,value:"Voeg toe aan bericht"}],__summarizerAssistant__:[{type:0,value:"Samenvatting"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var cn=require("react");var Yi={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"};var ae=require("react/jsx-runtime"),Yf=500,eh=100,th=({content:t,onChange:e,onCopy:n})=>{let o=(0,cn.useRef)(null),r=S("WidgetCue",Yi);return(0,cn.useEffect)(()=>{let s=o.current;if(!s)return;s.style.setProperty("height","0px");let i=Math.min(Math.max(s.scrollHeight,eh),Yf);s.style.setProperty("height",`${i}px`)},[t]),(0,ae.jsx)("textarea",{ref:o,className:r.editableCue,onCopy:n,onChange:e,value:t})},nh=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:r})=>{var f;let s=S("WidgetCue",Yi),i=k(Wo),a=Q(),d=C("hasKeyboardInput"),[l,c]=(0,cn.useState)(t.text),u=()=>{e&&e(t),n(t)},p=y=>{o&&o(y,t)},m=y=>{r&&r(y,t)},h=y=>{y.preventDefault(),y.stopPropagation(),n(t)};return(0,cn.useEffect)(()=>{a("Assistant response displayed",{name:t.rule.name,description:t.rule.description,group:t.rule.label,cueText:t.text})},[]),(0,ae.jsxs)(F,{"data-testid":"cue",children:[(0,ae.jsx)(K,{children:(0,ae.jsxs)(K.Content,{children:[t.title&&(0,ae.jsx)(K.Title,{className:s.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?i(t.rule.label):t.title}),t.specialType==="summary"?(0,ae.jsx)(th,{content:l,onCopy:()=>{let y=document.getSelection();y&&p(y.toString())},onChange:y=>{var b;return c((b=y.target.value)!=null?b:"")}}):(0,ae.jsx)(tn,{content:t.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:p,onUse:d?m:void 0})]})}),(0,ae.jsxs)(F.ButtonsContainer,{children:[(0,ae.jsxs)("div",{className:s.actions,children:[t.specialType==="summary"&&(0,ae.jsx)(F.Button,{onClick:()=>p(l),children:i("copyCue")}),t.callToAction&&(0,ae.jsx)(F.Button,{onClick:u,children:t.callToAction.label}),(0,ae.jsx)(F.Button,{onClick:h,children:i("removeCue")})]}),t.specialType==="summary"?(0,ae.jsx)(Yt,{eventName:"summary feedback",feedbackText:(f=t.text)!=null?f:"",feedbackType:"summary",eventData:{summary:t.text}}):(0,ae.jsx)(Yt,{eventName:"Assistant response feedback",eventData:{name:t.rule.name,group:t.rule.label,description:t.rule.description,cueText:t.text},feedbackText:t.text,feedbackType:"assistant"})]})]})},Up=nh;var zn=require("react/jsx-runtime"),oh=({cues:t})=>{let e=(0,Vp.useDispatch)(),n=xe(),o=k(Wo),r=Q(),s=l=>{e(id({code:l.rule.label})),r("Assistant response closed",{name:l.rule.name,group:l.rule.label,description:l.rule.description,cueText:l.text})},i=(l,c)=>{switch($e(l),c.specialType){case"summary":r("summary copied to clipboard",{originalText:c.text,finalText:l,assistant:c.rule.label});break;default:r("Assistant response copied",{name:c.rule.name,group:c.rule.label,description:c.rule.description,copiedText:l})}},a=l=>{l.callToAction&&(e(Ar(l)),r("Assistant call to action",{name:l.rule.name,group:l.rule.label,description:l.rule.description,eventName:l.callToAction.event,value:l.callToAction.value}))},d=(l,c)=>{n.send(je,{text:l,suggestion:{source:"cue",sourceText:l}}),r("Assistant response used",{name:c.rule.name,group:c.rule.label,description:c.rule.description,usedText:l})};return(0,zn.jsx)(zn.Fragment,{children:t.map(l=>l.isLoading?(0,zn.jsx)(Ss,{title:l.rule.label.startsWith("__")?o(l.rule.label):l.title},l.rule.id):(0,zn.jsx)(Up,{cue:l,onCallToAction:a,onRemove:s,onCopy:i,onUse:d},l.rule.id))})},zp=oh;var xs=require("react");var Wp={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var ze=require("react/jsx-runtime");function rh(t,e){return e.split(".").reduce((n,o)=>!n||typeof n!="object"||!(o in n)?null:n[o],t)}var qp=({data:t,schema:e})=>{let n=S("WidgetCustomData",Wp),o=r=>{$e(r)};return(0,xs.useEffect)(()=>{T.info("Custom data",t,e)},[t]),(0,ze.jsx)("dl",{className:n.root,children:e.map(r=>{let s=rh(t,r.path);return(0,ze.jsxs)(xs.Fragment,{children:[(0,ze.jsx)("dt",{className:n.label,children:r.label}),(0,ze.jsx)("dd",{className:n.value,children:r.type==="boolean"&&s?(0,ze.jsx)("span",{className:n.isTrue,children:r.trueValue}):r.type==="boolean"&&!s?(0,ze.jsx)("span",{className:n.isFalse,children:r.falseValue}):s?(0,ze.jsxs)("button",{type:"button",onClick:()=>o(s),className:n.copyButton,children:[(0,ze.jsx)("span",{className:n.copyButtonText,children:s}),(0,ze.jsx)(Vo,{})]}):"-"})]},r.label)})})};var J=require("react"),ws=require("react-redux");var Wn={};re(Wn,{enUS:()=>sh,nlNL:()=>ih});var sh={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"}]},ih={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 bs={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-"};var O=require("react/jsx-runtime"),ah=3,lh=({sources:t,onClick:e})=>{let n=k(Wn),o=S("WidgetKnowledgeAssistant",bs),[r,s]=(0,J.useState)(!1),i=r?t:t.slice(0,ah);return i.length===0?null:(0,O.jsxs)("ul",{className:o.sources,children:[i.map(a=>(0,O.jsx)("li",{className:o.source,"data-testid":"knowledge-assist-source",children:(0,O.jsxs)(ee,{tooltip:!0,placement:"top-start",children:[(0,O.jsx)(ee.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:d=>{d.stopPropagation(),e(a)},children:(0,O.jsx)("span",{className:o.linkContent,children:a.name})}),a.url&&(0,O.jsx)(ee.Content,{className:o.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),i<t&&(0,O.jsx)("button",{type:"button",className:o.showMoreSources,onClick:()=>s(!0),children:n("showMore",{amount:t.length-i.length})})]})},dh=({title:t,description:e})=>(0,O.jsx)(F,{"data-testid":"knowledge-assist-empty-state",children:(0,O.jsx)(K,{children:(0,O.jsxs)(K.Content,{children:[(0,O.jsx)(K.Title,{children:t}),(0,O.jsx)(tn,{content:e})]})})}),ch=({innerRef:t,item:e,index:n,hasKeyboardInput:o,onCopy:r,onUse:s,onSourceClick:i})=>{var d;let a=k(Wn);return(0,O.jsxs)(F,{"data-testid":"knowledge-assist-answer",ref:t,children:[(0,O.jsx)(K,{children:(0,O.jsxs)(K.Content,{children:[(0,O.jsx)(K.Title,{children:e.question}),(0,O.jsx)(tn,{content:e.answer.answer,useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:r,onUse:o?s:void 0}),(0,O.jsx)(lh,{sources:(d=e.answer.sources)!=null?d:[],onClick:l=>i(l,e.question)})]})}),(0,O.jsxs)(F.ButtonsContainer,{children:[(0,O.jsx)("div",{}),(0,O.jsx)(Yt,{eventName:"knowledge assist feedback",eventData:{question:e.question,isFollowUpQuestion:n>0,isAgent:!0,answer:e.answer.answer},feedbackText:e.answer.answer,feedbackType:"assistant"})]})]})},ea=(0,J.createContext)(null),Cs=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,children:o})=>{let[r,s]=(0,J.useState)(null),[i,a]=(0,J.useState)(!1),[d,l]=(0,J.useState)(!!n),[c,u]=(0,J.useState)(null),p=(0,ws.useDispatch)(),m=Q(),h=lt(b=>{if(!t)throw new Error("No knowledge assistant was defined");return e({assistantCode:t,input:b,threadId:r,onNewThreadId(E){s(E)}})},{onSuccess(b){var E;m("knowledge assist question answered",{question:b.question,answer:b.answer.answer,sources:(E=b.answer.sources)!=null?E:[],isFollowUpQuestion:b.threadId===r,isAutoInitiated:d}),l(!1)}}),f=b=>v(void 0,null,function*(){a(!0),u(b),yield h.call(b),a(!1),u(null)}),y={isEnabled:!!t,isSubmitting:i,threadId:r,pendingInput:c,onSubmit:f,onReset(){r&&p(In(r)),s(null)}};return(0,J.useEffect)(()=>{n&&f(n)},[n]),(0,O.jsx)(ea.Provider,{value:y,children:o})},Ts=()=>{let t=k(Wn),e=S("WidgetKnowledgeAssistant",bs),n=(0,J.useContext)(ea),o=(0,J.useRef)(null),[r,s]=(0,J.useState)(""),i=d=>{s(d.target.value)},a=d=>{d.preventDefault(),n.onSubmit(r).then(()=>{var l;o.current&&((l=o.current)==null||l.focus(),s(""))})};return n.isEnabled?(0,O.jsxs)("form",{className:e.form,onSubmit:a,children:[(0,O.jsx)("input",{ref:o,className:e.formInput,placeholder:t("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:r,onChange:i}),(0,O.jsx)("button",{type:"submit",disabled:n.isSubmitting||r==="",className:e.formSubmit,children:t("submitLabel")})]}):null},Es=({title:t,emptyState:e})=>{var h,f;let n=k(Wn),o=Q(),r=S("WidgetKnowledgeAssistant",bs),s=(0,J.useRef)(null),i=(0,J.useContext)(ea),a=(f=(0,ws.useSelector)(xo((h=i.threadId)!=null?h:-1)))!=null?f:[],d=C("hasKeyboardInput"),l=xe(),c=y=>{$e(y),o("Assistant response copied",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",copiedText:y})},u=(y,b)=>{o("knowledge assist source viewed",{question:b,sourceViewed:y.url||y.name})},p=y=>{var b;y.preventDefault(),i.onReset(),o("knowledge assist reset",{threadId:(b=i.threadId)!=null?b:void 0})},m=y=>{l.send(je,{text:y,suggestion:{source:"cue",sourceText:y}}),o("Assistant response used",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",usedText:y})};return!i.isEnabled||(a==null?void 0:a.length)===0&&!i.isSubmitting&&!e?null:(0,O.jsxs)(J.Fragment,{children:[(0,O.jsx)(We,{type:"knowledge",title:t,"data-testid":"knowledge",children:(0,O.jsxs)(ve,{withDivider:!0,children:[e&&a.length===0&&!i.pendingInput&&(0,O.jsx)(dh,g({},e)),a.map((y,b)=>(0,O.jsx)(ch,{innerRef:b===a.length-1?s:void 0,item:y,index:b,hasKeyboardInput:d,onCopy:c,onUse:m,onSourceClick:u},`${y.question}_${y.answer}_${b}`)),i.pendingInput&&(0,O.jsx)(Ss,{title:i.pendingInput})]})}),a.length>0&&(0,O.jsx)("div",{className:r.resetContainer,children:(0,O.jsx)(F.Button,{disabled:i.threadId===null||i.isSubmitting,onClick:p,children:n("resetLabel")})})]})};var Gp=require("react");var ph=/(https?:\/\/[^\s]+)/,$p=t=>t.split(" ").find(e=>ph.test(e));var Ne=require("react/jsx-runtime"),uh=({suggestion:t,lines:e,onUse:n})=>{var u;let o=t.text||t.url||t.message,r=$p(o),s=k(Ao),i=C("showImages"),a=C("fallbackImage"),d=C("hasKeyboardInput"),l=p=>{p.preventDefault(),p.stopPropagation(),d&&n(o)},c=(0,Gp.useCallback)(p=>{window.open(r,"_blank"),p.stopPropagation(),p.preventDefault()},[r]);return(0,Ne.jsxs)(F,{onClick:d?l:void 0,"data-testid":"edit-suggestion",children:[(0,Ne.jsxs)(K,{children:[i&&t.image&&(0,Ne.jsx)(K.Image,{src:ms(t,"small",a||void 0),title:t.title}),(0,Ne.jsxs)(K.Content,{children:[t.title&&(0,Ne.jsx)(K.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,Ne.jsx)(F.Labels,{labels:t.searchKeywords}),(0,Ne.jsx)(K.Content,{cropText:e==="single",lineClamp:e==="multiple",children:o})]})]}),(0,Ne.jsxs)(F.Actions,{children:[r&&(0,Ne.jsx)(F.ActionButton,{onClick:c,label:s("visitUrl")}),d&&(0,Ne.jsx)(F.ActionButton,{primary:!0,onClick:l,label:s("useSuggestion")})]})]})},Xp=uh;var qo=require("react/jsx-runtime"),mh=({lines:t,suggestions:e})=>{let n=xe(),o=(r,s)=>{n.send(je,{text:r,suggestion:x(g({},s),{source:s.source,sourceText:s.text})})};return(0,qo.jsx)(qo.Fragment,{children:e.map(r=>(0,qo.jsx)(Xp,{suggestion:r,lines:t,onUse:s=>o(s,r)},r.text||r.url||r.message))})},Zp=mh;var ks={};re(ks,{enUS:()=>gh,nlNL:()=>fh});var gh={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},fh={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var qn={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};var P=require("react/jsx-runtime"),Jp=(t,e)=>{let n=(0,j.useSelector)(de);(0,jn.useEffect)(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},hh=({onLogIn:t})=>{let e=S("Widget",qn),n=C("isEmbedded"),o=C("adminUrl");return(0,P.jsx)("div",{className:e.loginText,children:(0,P.jsx)("div",{children:(0,P.jsx)(os,{isEmbedded:n,loginUrl:o,onLogIn:t})})},"login")},Qp=({text:t})=>{let e=S("Widget",qn);return(0,P.jsx)("div",{className:e.stateText,children:(0,P.jsx)("div",{children:(0,P.jsx)("p",{children:t})})},"notification")},yh=()=>{let t=k(ks),e=(0,j.useDispatch)(),n=S("Widget",qn),o=C("showSearch"),r=C("showSummaryCommand"),s=C("showKnowledgeSearch"),i=(0,j.useSelector)(ci("knowledge-assist")),a=C("isEmbedded"),d=(0,j.useSelector)(Fn("/admin/")),l=xe(),c=C("productName"),u=C("hasKeyboardInput"),p=lt(()=>Fe({})),m=Q(),h=o||r||s||d;return Jp(()=>{if(a)return e(Wi()),()=>{e(xp())}},[e,a]),!h||!u?null:(0,P.jsx)(We,{title:t("actions"),type:"shortcuts",children:(0,P.jsxs)("div",{className:n.shortcutList,children:[o&&(0,P.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":t("linkSearch"),onClick:()=>{l.send("ShowCommandPalette",{isOpen:!0}),m("open search",{via:"widget-shortcut"})},children:[(0,P.jsx)(Mn,{}),t("linkSearch")]}),r&&!i&&(0,P.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":t("linkSummary"),disabled:p.state==="loading",onClick:()=>p.call(),children:[(0,P.jsx)(Ip,{}),t("linkSummary")]}),s&&!i&&(0,P.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":t("linkKnowledgeSearch"),onClick:()=>{l.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),m("open knowledge assistant",{via:"widget-shortcut"})},children:[(0,P.jsx)(Pp,{}),t("linkKnowledgeSearch")]}),d&&(0,P.jsxs)("a",{className:n.shortcut,target:"_blank",href:d,"data-testid":"shortcut-studio-login","aria-label":t("linkStudioLogin",{productName:c}),rel:"noreferrer",onClick:()=>{m("open my deepdesk",{via:"widget-shortcut"})},children:[(0,P.jsx)(Rp,{}),t("linkStudioLogin",{productName:c})]})]})})},vh=()=>{let t=(0,j.useDispatch)(),e=(0,j.useSelector)(Co),n=(0,j.useSelector)(ud),o=(0,j.useSelector)(Cp),r=(0,j.useSelector)(Rl),s=(0,j.useSelector)(Br),i=(0,j.useSelector)(Xr),a=(0,j.useSelector)(Gt),d=(0,j.useSelector)(qe);return(0,jn.useEffect)(()=>{!!r&&!n&&T.warn("Custom data provided, but no schema.")},[r,n]),Jp(()=>{e.forEach(({type:l})=>{l==="entities"?t(Be()):ir.includes(l)||t(Ve(l))})},[t,d,a]),(0,jn.useEffect)(()=>{o.length>0&&!e.some(l=>l.type==="cues")&&T.warn("Received cues, but cues are not configured in widget.")},[e,o]),(0,P.jsx)(jn.Fragment,{children:e.map(({type:l,title:c,amount:u,lines:p,schema:m})=>{var h,f;switch(l){case"entities":return s&&s.length>0&&(0,P.jsx)(We,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(kp,{entities:s})},l);case"cues":return o&&o.length>0&&(0,P.jsx)(We,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ve,{withDivider:!0,children:(0,P.jsx)(zp,{cues:o})})},l);case"custom-data":return r&&m&&(0,P.jsx)(We,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ve,{withDivider:!0,children:(0,P.jsx)(qp,{data:r,schema:m})})},l);default:return((f=(h=i[l])==null?void 0:h.suggestions)==null?void 0:f.length)>0&&(0,P.jsx)(We,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ve,{withDivider:!0,children:(0,P.jsx)(Zp,{lines:p,contentType:l,suggestions:i[l].suggestions.slice(0,u)||[]})})},l)}})})},ta=({children:t})=>{let e=S("Widget",qn);return(0,P.jsx)("div",{className:e.footer,children:t})},na=({children:t})=>{let e=S("Widget",qn);return(0,P.jsx)("div",{className:e.root,"data-testid":"widget",children:t})},Sh=({onLogIn:t,knowledgeAssistOptions:e={},assistantOptions:n={transcript:"in-memory-transcript",expectFormat:"json-schema:cues"}})=>{let o=k(ks),r=(0,j.useSelector)(wn),s=(0,j.useSelector)(de),i=(0,j.useSelector)(dl),a=(0,j.useSelector)(Gt),d=(0,j.useSelector)(ci("knowledge-assist")),l=(0,j.useSelector)(Nr),c=(0,j.useSelector)(Or);return r===!1?(0,P.jsx)(Qp,{text:o("notSupported")}):s===!1?(0,P.jsx)(hh,{onLogIn:t}):!a||!i||s===null?(0,P.jsx)(Qp,{text:o("waiting")}):(0,P.jsx)(na,{children:(0,P.jsxs)(Cs,{initialQuestion:e.initialQuestion,assistantCode:l!=null?l:c,evaluateKnowledgeAssistFn:c?jt:$t,children:[(0,P.jsxs)(yn,{children:[(0,P.jsx)(yh,{}),(0,P.jsx)(vh,{}),d&&(0,P.jsx)(Es,{title:d.title,emptyState:e.emptyState})]}),(0,P.jsxs)(ta,{children:[d&&(0,P.jsx)(Ts,{}),(0,P.jsx)(Fp,{assistantOptions:n})]})]})})},Yp=Sh;function $n(t){let e=new Range;return e.selectNodeContents(t),e}function eu(t,e,n){try{return Dt(t,e,n),!0}catch(o){return!1}}function Rs(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Ps(t){return"tagName"in t&&t.tagName==="BR"}var jo=/[\u200B-\u200D\uFEFF]/g;function Dt(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let r=0,s=!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(jo,""),u=r+c.length,p=e>=r&&e<=u,m=n>=r&&n<=u;if(p){let h=i(l,e-r);h===0&&!m?o.setStartBefore(d):o.setStart(d,h)}m&&(o.setEnd(d,i(l,n-r)),s=!0),r=u;break}case Node.ELEMENT_NODE:{if(Ps(d)&&(r===e&&o.setStartBefore(d),r++,r===n)){o.setEndAfter(d),s=!0;return}for(let c=0;c<d.childNodes.length&&(a(d.childNodes[c]),!s);c++);let l=d.lastChild;Rs(d)&&l&&!Rs(l)&&!Ps(l)&&r++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function $o(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:r,endOffset:s,collapsed:i}=e,a,d,l=0;function c(u){let p=u===t,m=u===n,h=u===r;switch(u.nodeType){case Node.TEXT_NODE:{let f=u.textContent;m&&(a=l+f.substring(0,o).replace(jo,"").length),h&&(d=l+f.substring(0,s).replace(jo,"").length),l+=f.replace(jo,"").length;break}case Node.ELEMENT_NODE:{if(Ps(u)&&u.nextSibling){l++;break}!p&&Rs(u)&&u.previousSibling&&l++;for(let f=0;f<u.childNodes.length;f++){let y=m&&f===o,b=h&&f===s;if(y&&(a=l),b&&(d=l),d!==void 0||((!y||!i)&&c(u.childNodes[f]),h&&f===s-1&&(d=l),d!==void 0))break}h&&(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 Go(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:r,endOffset:s,collapsed:i}=e,a=0,d="";function l(c){let u=c===t,p=c===n,m=c===r;switch(p&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let h=p?o:0,f=m?s:void 0;d+=c.textContent.replace(jo,"").substring(h,f);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&Ps(c)&&c.nextSibling){d+=`
9
+ `;break}!u&&!i&&a===1&&Rs(c)&&c.previousSibling&&(d+=`
10
+ `);let h=p?o:0,f=m?Math.min(s,c.childNodes.length):c.childNodes.length;for(let y=h;y<f&&(l(c.childNodes[y]),a!==2);y++);break}default:break}m&&(a=2)}return l(t),d}var tu=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(tu||{}),St=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=r=>{n(r)};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(),r=this.cachedCaretPosition===null;if(!this.isActive||(e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),e!==this.cachedText?(this.cachedText=e,this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,r=!0,this.emit("selection",o)),!r))return;let s=this.getCaretPosition();Tt(s,this.cachedCaretPosition)||(this.cachedCaretPosition=s,this.emit("caretposition",s))}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:r}=e;this.isPossibleClearInputAction=Object.values(tu).includes(n)||n.toLowerCase()==="z"&&(o||r),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,r;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((r=e.clipboardData)==null?void 0:r.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 nu(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var pn=class extends St{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Go(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var i;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 r="getComposedRanges"in o&&n instanceof ShadowRoot?(i=o.getComposedRanges(n))==null?void 0:i[0]:o.rangeCount>0?o.getRangeAt(0):null;if(!r)return null;let s=this.element.ownerDocument.createRange();return s.setStart(r==null?void 0:r.startContainer,r==null?void 0:r.startOffset),s.setEnd(r==null?void 0:r.endContainer,r==null?void 0:r.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let o=n.getBoundingClientRect();return!nu(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!nu(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let n=this.getRange();if(n)return $o(this.element,n);let o=this.lastKnownSelection;if(o&&eu(this.element,o.start,o.end))return o;let r=$n(this.element);return r.collapse(!1),$o(this.element,r)}getSelectedText(){let{start:n,end:o}=this.getSelection();return Go(this.element,Dt(this.element,n,o))}listen(){super.listen();let n=new MutationObserver(s=>{var i,a;s.length===2&&s[0].addedNodes.length===1&&((i=s[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=s[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,r=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>r.disconnect())}};var xh=["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 ou(t,e){let n="mozInnerScreenX"in window,o=document.createElement("div");o.id="input-textarea-caret-position-mirror-div";let r=o.style,s=window.getComputedStyle(t),i=t.ownerDocument.body;r.whiteSpace="pre-wrap",r.wordWrap="break-word",r.position="absolute",r.visibility="hidden",xh.forEach(c=>{r[c]=s[c]}),n?t.scrollHeight>Number.parseInt(s.height)&&(r.overflowY="scroll"):r.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(s.borderTopWidth)+a.offsetHeight,left:d.left-t.scrollLeft+a.offsetLeft+Number.parseInt(s.borderLeftWidth)};return i.removeChild(o),l}var un=class extends St{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 ou(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 s;return(s=n==null?void 0:n.get)==null?void 0:s.call(this.element)},set:s=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,s),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let o=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};function ru(t,e,n){let o=`deepdesk-iframe-${t}`,r=document.getElementById(o);if(r)return r;let s=document.createElement("iframe"),i=new URL(e);return Object.entries(n).forEach(([a,d])=>{i.searchParams.append(a,d)}),s.style.position="absolute",s.style.left="-999em",s.style.width="0px",s.style.height="0px",s.tabIndex=-1,s.id=o,s.title=`iframe-${t}`,s.src=i.toString(),window.document.body.appendChild(s),s}function bh(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch(e){return t}}var oa=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()}},ra=class{constructor(e,n,o){this.name=e;this.targetOrigin=n;this.options=o;this.disposeHandlers=[];this.iframe=ru(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()}},sa=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(),T.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 ra(e,this.deepdeskUrl,{debug:!0}):new oa(e),o=r=>{var i,a;if(r.origin!==this.deepdeskUrl)return;let s=bh(r.data);typeof s!="object"||s.type!=="event"||s.channel!==e||(T.info("Received broadcast event",this.externalId,r),(a=(i=this.eventMap)[s.name])==null||a.call(i,s.payload))};return n.onMessage(o),n}send(e,n,o){var i,a;T.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let r={type:"event",name:e,payload:n};o!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,n));let s=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage(x(g({},r),{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)}},su=sa;function wh(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function z(t){return Array.isArray(t)?t.map(z):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>x(g({},e),{[wh(n)]:z(t[n])}),{}):t}function Ch(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function ne(t){return Array.isArray(t)?t.map(ne):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>x(g({},e),{[Ch(n)]:ne(t[n])}),{}):t}var Gn=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var ia=t=>new Promise(e=>{setTimeout(e,t)});var Xn=class extends Gn{constructor(){super(...arguments);this.name="ClientError"}},la=class extends Gn{constructor(){super(...arguments);this.name="ServerError"}},aa=new Map;function Th(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:(T.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var _t=class _t{constructor(e="",n={}){this.baseUrl=e;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,n={}){return new Promise((o,r)=>{let s={isAborted:!1,reject:r},i=`${this.baseUrl}${e}`,a=this.fetch,d=n.method===void 0||n.method.toLowerCase()==="get",L=n,{useCache:l=!1,abortLatest:c=!1,attempts:u=1,retryDelay:p=500,refreshTokenOn401:m=!0,retryOnError:h=D=>D instanceof TypeError,retryOnResponse:f=D=>D.status>=500,version:y=null}=L,b=A(L,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(l){if(!d)throw new Error(`Can't use 'useCache' for ${n.method}`);if(aa.has(i)){o(aa.get(i));return}}let E=x(g({credentials:"include"},b),{headers:g({Accept:"application/json","Content-Type":"application/json"},b.headers)});!d&&this.csrfToken&&(E.headers=x(g({},E.headers),{"X-CSRFToken":this.csrfToken})),typeof y=="string"&&(E.headers=x(g({},E.headers),{"X-Deepdesk-API-Version":y}));let w=u,I=!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]=s;let N=()=>v(this,null,function*(){return w--,a(i,E).then(D=>v(this,null,function*(){return f(D)&&!s.isAborted&&w>0?(yield ia(p),N()):D.status===401&&m===!0&&I===!1?(I=!0,yield this.refreshToken(),N()):D})).catch(D=>v(this,null,function*(){if(h(D)&&!s.isAborted&&w>0)return yield ia(p),N();throw D}))});N().then(D=>v(this,null,function*(){let q=yield Th(D);if(delete this.latestRequestByUrl[i],D.status>=500){r(new la("Server Error",q));return}if(D.status===401){r(new Xn("Unauthorized",q));return}if(D.status===403){r(new Xn("Forbidden",q));return}if(D.status===404){r(new Xn("Not Found",q));return}if(D.status>=400){r(new Xn("Bad Request",q));return}l&&aa.set(i,q),o(q)})).catch(D=>{r(D)})})}validateToken(){return v(this,null,function*(){let{has_valid_access_token:e}=yield this.get("/auth/validate");if(!e)try{yield this.refreshToken()}catch(o){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/");return!!n})}refreshToken(){return _t.refreshingToken||(_t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{_t.refreshingToken=null},1e3*60)})),_t.refreshingToken}get(e,n){return this.request(e,n)}post(e,n,o){return this.request(e,g({method:"POST",body:JSON.stringify(n)},o))}patch(e,n,o){return this.request(e,g({method:"PATCH",body:JSON.stringify(n)},o))}put(e,n,o){return this.request(e,g({method:"PUT",body:JSON.stringify(n)},o))}delete(e,n){return this.request(e,g({method:"DELETE"},n))}};_t.refreshingToken=null;var mn=_t;var iu;(e=>{let t;(i=>(i.SEND_MESSAGE="Send Message",i.HANDLING_TIME="Handling Time",i.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",i.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(t=e.EventType||(e.EventType={}))})(iu||(iu={}));function Is(t){return x(g({},z(t)),{metadata:t.metadata})}var gn=class gn{constructor(e,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new mn(e,{fetch:n.fetch}),this.client.patchFetch(o=>(r,s)=>v(this,null,function*(){let i=yield o(r,s);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?(gn.exchangeTokenPromise||(gn.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),gn.exchangeTokenPromise):Promise.resolve()})}createConversation(e){return v(this,null,function*(){var o;yield this.preflight(),T.info(`Creating conversation for session ${e.externalId} and agent ${e.agentId}`);let n=yield this.client.post("/api/v2/conversations",x(g({chat_start_time:new Date().toISOString()},ne(e)),{metadata:(o=e.metadata)!=null?o:{}}));return Is(n)})}getMe(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/session/me/");return z(e)})}postIdentity(e){return v(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",ne(e))})}patchMe(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",ne(e));return z(n)})}getProfile(e){return v(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${e}/`,{useCache:!0});return z(n)})}getKnowledgeAssistant(e){return v(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{useCache:!0});return z(n)})}getContentTypes(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return z(e)})}getAccount(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/account/",{useCache:!0});return z(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 z(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(),T.info(`Getting conversation for session ${e}`);let{attempts:r=1,retryDelay:s=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:r,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return T.info(`Successfully retrieved conversation ${i.id} for session ${e}`),Is(i)})}isConversationSupported(o){return v(this,arguments,function*(e,n={}){T.info(`Check if conversation for session ${e} is supported`);let{attempts:r=1,retryDelay:s=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:r,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(e,n){return v(this,null,function*(){var s;yield this.preflight();let o=ne(n);n.metadata&&(o.metadata=(s=n.metadata)!=null?s:{});let r=yield this.client.put(`/api/v2/conversations/${e}`,o);return Is(r)})}postMessages(e,n){return v(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${e}/messages`,n.map(r=>x(g({},ne(r)),{metadata:r.metadata})))).map(r=>Is(r))})}sendEvent(e,n){return v(this,null,function*(){yield this.preflight();let i=n,{data:o}=i,r=A(i,["data"]),s=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[d,l])=>x(g({},a),{[d]:l}),{});return this.client.post("/api/events",ne(x(g(g({},s),r),{data:o,name:e})),{version:"v2"})})}sendEventV1(e,n){return v(this,null,function*(){yield this.preflight();let o=Object.entries(this.latestReceivedDeepdeskVersions).reduce((r,[s,i])=>x(g({},r),{[s]:i}),{});return this.client.post("/api/events",{event:e,data:ne(g(g({},n),o))},{version:"v1"})})}getEntities(e){return v(this,null,function*(){return yield this.preflight(),(yield this.client.post("/api/entities",{messages:e.filter(o=>o.text)},{version:"v1"})).entities})}getTemporaryExchangeToken(){return v(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(e){return v(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:e}).catch(n=>{throw T.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/",ne(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(r){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}`,ne(n),{abortLatest:!0})).map(i=>x(g({},z(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`,ne(n),{abortLatest:!0})).map(r=>({score:1,source:r.source,sourceText:r.source_text,text:r.label,trainingJobs:r.training_jobs,searchKeywords:r.search_keywords,type:r.source})).filter((r,s,i)=>s===i.findIndex(a=>a.text===r.text))})}getPinnedMessages(e){return v(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return z(n).map(o=>x(g({},o),{text:o.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(e){return v(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",ne(e),{abortLatest:!0,version:"v1"});return z(n)})}search(e){return v(this,null,function*(){let n=yield this.client.post(`/api/profiles/${e.profile}/search`,ne(e),{version:"v2"});return z(n)})}knowledgeAssist(s,i,a){return v(this,arguments,function*(e,n,o,r={}){yield this.preflight();let d=yield this.client.post(`/api/knowledge-assist/assistants/${o}/search`,ne({question:e.question,doNotKnowAnswer:e.doNotKnowAnswer,customerInstruction:e.customerInstruction,chatHistory:n.map(l=>({question:l.question,answer:l.answer.answer})),agentId:r.agentId,conversationId:r.conversationId}),{version:"v2"});return z(d)})}requestLoginByEmail(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:e});return z(n)})}requestPasswordlessToken(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/session/passwordless/request/");return z(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 z(n)})}getSummary(o){return v(this,arguments,function*(e,n={}){yield this.preflight();let r=yield this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model},{version:"v1"});return z(r)})}evaluateAssistant(e,n){return v(this,null,function*(){var a;yield this.preflight();let o=new URLSearchParams,{expectFormat:r="text"}=n||{};if(r.startsWith("json-schema:")){let d=r.replace("json-schema:","");o.append("expect_response_format","json-schema"),o.append("expect_response_format_schema",d)}else o.append("expect_response_format",r);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()}`,i=yield this.client.post(s,{input:(a=n==null?void 0:n.input)!=null?a:{},conversation:n==null?void 0:n.transcript});return z(i.output)})}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 z(o)})}postMessageToAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:r}=e,s=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:r,role:"user"});return z(s)})}translateMessages(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/translate",ne(e),{version:"v2"});return z(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let r=o.toLowerCase(),s=r.match(ja);if(!n||!s)return;let i=s[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&T.warn(`Overwritten Version header ${r}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};gn.exchangeTokenPromise=null;var xt=gn;var Ns=require("@reduxjs/toolkit");var lu=require("@reduxjs/toolkit");var au={startTime:null,stopTime:null},du=t=>t.handlingTime,cu=(0,lu.createSlice)({name:"handlingTime",initialState:au,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(Z,()=>au)}}),{handlingTimeStart:pu,handlingTimeStop:Ls,handlingTimeReset:uu}=cu.actions,mu=cu.reducer;var gu=(t={})=>{let e=g({onAuthError:bn(!1)},t);return n=>o=>r=>("error"in r&&r.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(r))};var Ms=require("@reduxjs/toolkit");var As={list:{keywordMatches:[]},fetchState:"idle"};var fn=(0,Ms.createAsyncThunk)("styleSuggestions/getAll",(n,o)=>v(void 0,[n,o],function*({text:t},e){var d;let{deepdeskAPI:r}=e.extra,s=e.getState(),{showStyleSuggestions:i}=s.settings,a=(d=s.conversation.current)==null?void 0:d.profileCode;if(!i)return As.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return r.getStyleSuggestions({profileCode:a,message:t})})),Eh=(0,Ms.createSlice)({name:"styleSuggestions",initialState:As,reducers:{},extraReducers:t=>{t.addCase(fn.pending,e=>{e.fetchState="loading"}).addCase(fn.rejected,e=>{e.fetchState="error"}).addCase(fn.fulfilled,(e,n)=>{e.fetchState="done",Tt(e.list,n.payload)||(e.list=n.payload)}).addCase(zt,e=>{e.list=As.list}).addCase(Z,()=>As)}}),fu=Eh.reducer;var hu=(t={})=>{let e,n=!0,o=g({getStyleSuggestions:fn,debounce:500},t);return r=>s=>i=>{var m;let a=r.getState().input.text,d=s(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return d;let{showStyleSuggestions:c}=l.settings;if(!((m=l.conversation.current)==null?void 0:m.id)||!c)return d;let{text:p}=l.input;return p===a&&!n||(clearTimeout(e),p==="")||(e=setTimeout(()=>{n=!1,r.dispatch(o.getStyleSuggestions({text:p}))},t.debounce)),d}};function kh(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var yu=(t={})=>{let e=g({getTextSuggestions:Ve,getAutocompleteSuggestions:No,debounce:200,check:Ze},t),n;return o=>r=>s=>{var f;let{input:i}=o.getState(),a=r(s),d=o.getState();if(d.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:c}=d.settings,u=(f=d.conversation.current)==null?void 0:f.id,p=s.type===Zr.toString();if(!u||!l&&!c)return a;let{input:m}=d;return kh(m,i)&&!p||(clearTimeout(n),!e.check(d))||(n=setTimeout(()=>{let y=Cn(d);y===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(y))},p?0:e.debounce)),a}};var vu=fn.fulfilled.toString();function Rh(t,e){let n=new Set([...e.keywordMatches.map(r=>r.keyword)]),o=[];return n.forEach(r=>{let s=t.keywordMatches.filter(d=>d.keyword===r),i=e.keywordMatches.filter(d=>d.keyword===r),a=i.length-s.length;a<=0||o.push(...i.slice(0,a))}),o}var Su=t=>e=>n=>o=>{var l;if(o.type!==vu){n(o);return}let r=e.getState().styleSuggestions.list;n(o);let s=e.getState(),i=s.styleSuggestions.list,a=(l=s.conversation)==null?void 0:l.current;if(r===i)return;let d=Rh(r,i);o.type===vu&&d.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:d}})};var Ph=(0,Ns.combineReducers)({assistants:ad,auth:rl,conversation:cl,contentTypes:dd,passwordlessToken:bp,entities:Od,handlingTime:mu,info:Ml,input:Tl,settings:Qa,profile:md,search:Hl,styleSuggestions:fu,ui:Ic,textSuggestions:pc});function xu(t){return(0,Ns.configureStore)({reducer:Ph,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}),gu(),yu({debounce:200}),hu({debounce:500}),Su(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Ih=t=>{var e,n;return(n=(e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())!=null?n:"unknown"},Lh=t=>e=>n=>o=>{var a,d,l,c,u,p;let r=e.getState(),s=to("inlineSuggestions")(r);switch(o.type){case bn.toString():{!o.payload&&t.emit("logout",void 0);break}case Be.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:(a=r.conversation.current)==null?void 0:a.id,data:{entities:o.payload}});break;case ot.toString():t.sendEvent(o.payload.name,{conversationId:((d=o.payload.options)==null?void 0:d.includeConversationData)&&((l=r.conversation.current)==null?void 0:l.id),data:o.payload.data});break;case zt.toString():t.logSendMessage(o.payload);break;case Ar.toString():t.emit("call-to-action",{cue:o.payload});break;case He.fulfilled.toString():o.isBroadcasted||t.broadcast(Zs,o,!1);break;default:break}let i=n(o);switch(o.type){case zt.toString():t.handleAfterSendMessage(o.payload);break;case Do.toString():t.onUpdateShowTabHint(o.payload);break;case Ls.toString():t.logHandlingTime();break;case"analytics/logEvent/fulfilled":{t.emit("event",o.meta.arg);break}case ur.toString():{let{start:m,end:h}=r.input.selection;t.emit("replace",x(g({},o.payload),{replace:o.payload.replace==="selection"?{start:m,end:h}:{start:0,end:h}}));break}case De.toString():{let{start:m,end:h}=r.input.selection;t.emit("select-suggestion",x(g({type:Ih(o.payload.suggestion)},o.payload),{replace:o.payload.replace==="selection"?{start:m,end:h}:{start:0,end:h}})),s&&e.dispatch(Et([]));break}case mr.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(c=r.conversation.current)==null?void 0:c.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Et.toString():{s&&o.payload.length>0&&e.dispatch(gr(0));break}case Fe.fulfilled.toString():{t.sendEvent("conversation summarized",{conversationId:(u=r.conversation.current)==null?void 0:u.id,data:{summary:o.payload,assistant:(p=e.getState().profile.data)==null?void 0:p.summarizerAssistantNew}}),t.emit("summary-generated",{summary:o.payload});break}default:break}return i},bu=Lh;var wu=require("@reduxjs/toolkit");function da(t){return t.toISOString().replace("T"," ").replace("Z","")}var Ah=(t,e)=>e.version,Cu=(0,wu.createSelector)([kn,qe,du,Ah],(t,e,n,o)=>{if(!e)return T.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:s}=n;return!r||!s?(T.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:da(r),timeStop:da(s)}});function Tu(t,e,n){var q,oe,be,_;let o=(q=e.conversation.current)==null?void 0:q.id;if(!o)return T.warn("No conversationId for send message metrics"),null;let{text:r,metrics:{numCharsTyped:s,numCharsPasted:i,numCharsCut:a,numCharsDeleted:d,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:u,pastes:p,cuts:m,deletions:h,textSuggestions:f,offeredTextSuggestions:y}}=e[t],b=r.length,w=f.reduce((U,{text:Ee,searchTerm:ge})=>U+Ee.length-(ge?ge.length:0),0),I=c!=null?c:Date.now(),N=(Date.now()-I)/1e3+(u||0),L=s/N,D=f.reduce((U,{searchTerm:Ee})=>U+(Ee?Ee.length:0),0);return{conversationId:o,source:"agent",text:r,clientVersion:n.version,pastes:p,cuts:m,deletions:h,lenTextTyped:s+D,lenTextTotal:b,lenTextAssisted:w,lenTextPasted:i,lenTextCut:a,lenTextDeleted:d,timeTotalSeconds:N,charsPerSecond:L,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:y.filter(U=>U.source==="gpt").length}],agentId:(oe=e.info.agentInfo)==null?void 0:oe.agentId,agentName:(be=e.info.agentInfo)==null?void 0:be.agentName,agentEmail:(_=e.info.agentInfo)==null?void 0:_.agentEmail}}function ca(t,e){var s;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return ca(o,e);let r=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;return r?ca(r,e):null}function pa(t,e){return ca(t,e)}function Eu(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Mh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Os(t){return Mh(t)&&(dn(t)||ss(t))}var Ru,Ye=new Map,Nh=["bottom","height","left","right","top","width"],ku=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:Nh.some(n=>t[n]!==e[n]);function Pu(t){var n,o,r;if(t.ownerDocument===document)return[];let e=(r=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?r:null;return e?[e,...Pu(e)]:[]}function Iu(t,e){return!t||!e?null:x(g({},t),{top:t.top+e.top,left:t.left+e.left})}var Ds=!1,Lu=()=>{Ds=!0;let t=[];if(Ye.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),Ye.delete(n);return}let o=n.getBoundingClientRect();ku(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{let n=e.parentRects?e.parentRects.reduce(Iu,e.rect):e.rect;ku(n,e.totalRect)&&e.callbacks.forEach(o=>o(n)),e.totalRect=n}),Ye.size===0){Ds=!1;return}Ru=window.requestAnimationFrame(Lu)};function ua(t,e){let n=Pu(t),o=[],r=n.map((s,i)=>ua(s,a=>{o[i]=a;let d=Ye.get(t);if(!d)return;let l=o.reduce(Iu,d.rect);d.callbacks.forEach(c=>c(l))}));return{observe(s=!0){if(r.forEach(i=>i.observe(!1)),Ye.has(t)){let i=Ye.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Ye.set(t,{rect:void 0,callbacks:[e],parentRects:o});s&&!Ds&&Lu()},unobserve(){r.forEach(i=>i.unobserve());let s=Ye.get(t);if(s){let i=s.callbacks.indexOf(e);i>=0&&s.callbacks.splice(i,1),s.callbacks.length||Ye.delete(t),Ye.size||(cancelAnimationFrame(Ru),Ds=!1)}}}}var Au,et=new Map,Mu=()=>{et.forEach((t,e)=>{if(!e.isConnected){et.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,r=o>n;t.visible!==r&&(t.visible=r,t.callbacks.forEach(s=>s(t.visible)))}),et.size!==0&&(Au=window.requestAnimationFrame(Mu))};function Nu(t,e){return{observe(){let n=et.size===0;et.has(t)?et.get(t).callbacks.push(e):et.set(t,{visible:void 0,callbacks:[e]}),n&&Mu()},unobserve(){let n=et.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||et.delete(t),et.size||cancelAnimationFrame(Au)}}}}var ma=["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 ga(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function Zn(t){return Number.parseFloat(t)}function _s(t){return Math.round(t*1e6)}function Ou(t){return t/1e6}function fa(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,r=Zn(t.width),s=Zn(t.borderLeftWidth),i=Zn(t.borderRightWidth),a=Zn(t.paddingRight),d=Ou(_s(r)-_s(s)-_s(i)),l=Ou(_s(o));if(d-l>2){let c=d-l;n.style.paddingRight=`${a+c}px`}}function Xo(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",en(n);let o=window.getComputedStyle(t),r=!0,s=()=>{n.scrollTop=t.scrollTop};ga(o,n,ma),fa(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",s));let i=Nu(t,()=>{ga(o,n,ma),fa(o,t,n),s(),setTimeout(s,0)}),a,d=!0,l=ua(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(r===!0)return;e.onHide&&e.onHide(),n.style.display="none",r=!0;return}if(ga(o,n,ma),fa(o,t,n),s(),n.style.top=`${p.top}px`,n.style.left=`${p.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let m=e.closestScrollElement.getBoundingClientRect(),h=window.getComputedStyle(e.closestScrollElement),f=Zn(h.borderTopWidth),y=Zn(h.borderBottomWidth),b=m.top+f-p.top,E=p.top+p.height+-(m.top+m.height-y);n.style.clipPath=`inset(${b}px 0px ${E}px 0px)`}r&&(n.style.display="block",e.onShow&&e.onShow(),r=!1)});return e.appendTo?e.appendTo.appendChild(n):(u=t.parentElement)==null||u.appendChild(n),l.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",s),l.unobserve(),i.unobserve()}]}var Du=(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){T.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Oh(t){return t.offsetParent!==null}function _u(t){if(!Oh(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 Fs(t,e,n=100){let o=_u(t);e({isVisible:o});let r=setInterval(()=>{let s=_u(t);s!==o&&(o=s,e({isVisible:o}))},n);return()=>{clearTimeout(r)}}var B=require("react/jsx-runtime");var Fu=Du("showTabHint",!0),Qn=class Qn{constructor({deepdeskUrl:e,version:n=Qn.version||"unknown",locale:o="en-US",token:r,fetch:s,productName:i,createCustomChannel:a}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.floatingMenu=null;this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let d=e.replace(/\/api$/,"");this.deepdeskApi=new xt(d,{token:r,fetch:s}),this.version=n,this.instanceId=Qn.count++;let l={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[bu({broadcast:(c,u,p)=>{this.broadcastEvents.send(c,u,p)},emit:(c,u)=>this.emit(c,u),handleAfterSendMessage:c=>this.handleAfterSendMessage(c),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:c=>this.logSendMessage(c),onUpdateShowTabHint:c=>Fu.update(c),sendEvent:(c,u)=>this.deepdeskApi.sendEvent(c,u)})]};this.store=xu(l),this.broadcastEvents=new su({debug:!0,deepdeskUrl:d,eventMap:Kl(this.store),createCustomChannel:a}),this.store.dispatch(Do(Fu.value())),this.store.dispatch(ar({locale:o,adminUrl:d,productName:i}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var e;return(e=this.state.input.textSuggestions[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?(T.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(T.warn("Profile has not been loaded (yet)"),!0):(T.warn("No conversation loaded (yet)"),!0)}login(){this.store.dispatch(bn(null)),this.store.dispatch(nt());let e=n=>de(n)&&Ja(n)!=="loading";return new Promise(n=>{let o=this.subscribe(e,r=>{r&&(o(),n())});this.unmountHandlers.push(()=>{o()})})}isLoggedIn(){return v(this,null,function*(){return(yield this.store.dispatch(nt())).payload})}isConversationSupported(e,n){return v(this,null,function*(){return(yield this.store.dispatch(Ws({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(lr(x(g({},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(dr({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(qs(x(g({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return v(this,null,function*(){return(yield this.store.dispatch(pr(e))).payload})}updateConversation(e){return v(this,null,function*(){return(yield this.store.dispatch(cr(e))).payload})}resetConversation(){this.store.dispatch(Z()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(ar(e))}setVisitorInfo(e){this.store.dispatch(Il(e))}setCustomData(e){this.store.dispatch(Ll(e))}setAgentInfo(e,n){return v(this,null,function*(){yield this.store.dispatch(oo(g(g({},e),n)))})}setAgentSettings(e){return v(this,null,function*(){yield this.store.dispatch($s(e))})}getAgentSettings(){return v(this,null,function*(){return(yield this.store.dispatch(Gs())).payload})}refresh(){return v(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(fr({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let e=[];return this.store.dispatch(Zr()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})})}notifyExternalSuggestion(e){this.store.dispatch(De(e))}evaluateAssistant(e,n){return v(this,null,function*(){let c=n||{},{input:o={},transcript:r,showCuesInWidget:s=!0,includeMetadata:i,expectFormat:a}=c,d=A(c,["input","transcript","showCuesInWidget","includeMetadata","expectFormat"]);Object.assign(o,d);let l=yield this.store.dispatch(He({assistantCode:e,expectFormat:a||"json-schema:cues",transcript:r,includeMetadata:i,input:o,skipState:!s}));if(l.error)throw new Error(l.error.message);return l.payload})}evaluateConversationAssistant(e,n){return v(this,null,function*(){yield this.loadProfileConfig();let o=this.state.profile.data;if(!o){T.warn("Can't evaluate assistant when profile is not loaded yet.");return}let s=o[{accepted:"conversationAcceptedAssistant","new-message":"conversationNewMessageAssistant",ended:"conversationEndedAssistant"}[e]];if(!s){T.warn(`No assistant set in profile for conversation event "${e}"`);return}yield this.evaluateAssistant(s,g({includeMetadata:!0},n))})}getSummary(){return v(this,arguments,function*(e={}){var o;if(!this.hasConversation())return T.warn("No conversation to create summary for."),null;(o=this.state.profile.data)!=null&&o.summarizerAssistantNew||T.warn("No profile loaded yet, or no summarizer assistant set in profile");let n=yield this.store.dispatch(Fe(e));if(n.error)throw new Error(n.error.message);return n.payload})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:s,selection:i}=this.state.input,{inlineSuggestions:a,showTextSuggestions:d}=this.settings,l=a?"below":"above",c=r.length>0;if(this.store.dispatch(yl(js(e))),!Ze(this.state)||e.key!=="Tab"&&!d)return;let u=()=>{n||!c||i&&(e.shiftKey||(this.store.dispatch(xl()),e.preventDefault()))},p=()=>{n||!c||a&&s<=0||i&&(e.shiftKey||(this.store.dispatch(bl()),e.preventDefault()))};switch(e.key){case"ArrowUp":l==="below"?p():u();break;case"ArrowDown":{l==="below"?u():p();break}case"Escape":{n||(this.store.dispatch(gr(-1)),this.store.dispatch(Lt({collapse:!0})),this.store.dispatch(Rc(!0)),e.preventDefault());break}case"Tab":{e.preventDefault();let m=Tn(this.state);if(!m)return;this.store.dispatch(Do(!1)),this.store.dispatch(De({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=Tn(this.state);if(!m)return;this.store.dispatch(De({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=Tn(this.state);if(!m)return;this.store.dispatch(De({text:m.text,suggestion:m,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),e.preventDefault();break}default:}n&&o&&this.store.dispatch(Lt({collapse:!1}))}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Et([]))}handlingTimeStart(){this.state.handlingTime.startTime||(T.info("Start handling time"),this.store.dispatch(pu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(T.info("Stop handling time"),this.store.dispatch(Ls()))}logSendMessage(e){let n=Tu("input",this.state,{version:this.version});n&&(e&&(Object.assign(n,{text:e}),Object.assign(n,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let e=Cu(this.state,{version:this.version});e&&(this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(uu()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch(zt((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(Cl()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(r=>{try{r(n)}catch(s){T.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),T.error(s)}})}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(Al(e))}whenConversationLoaded(e){let n=r=>{var s;return(s=r.conversation.current)==null?void 0:s.id},o=()=>this.loadProfileConfig().then(()=>e());n(this.state)&&o(),this.subscribe(n,r=>{r&&o()})}overlayContainerFactory(e,n,o,r){let[s,i]=Xo(n,o);return s.setAttribute("translate","no"),s.dataset.testid=e,r&&s.classList.add(r),this.unmountHandlers.push(()=>{(0,Y.unmountComponentAtNode)(s),i(),s.remove()}),s}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 r=document.createElement("div");r.style.display="none",r.style.position="absolute",r.style.height="0px",r.style.width="0px",r.style.backgroundColor="red",o.appendChild(r);let s=(a=e.ownerDocument.defaultView)==null?void 0:a.frameElement,i=s?s.ownerDocument.defaultView:null;if(s&&(i===window||(i==null?void 0:i.parent)===window)){let[d,l]=Xo(s,{appendTo:document.body,onMoveStart:()=>{r.style.display="none"}});d.dataset.testid=n,d.style.zIndex="2",d.appendChild(o),this.unmountHandlers.push(()=>{(0,Y.unmountComponentAtNode)(r),l()})}else document.body.appendChild(o);return r}createContainer(e,n=document.body){let o=window.getComputedStyle(n),r=document.createElement("div");return en(r),r.dataset.testid=e,r.style.color=o.color,r.style.fontSize=o.fontSize,r.style.fontFamily=o.fontFamily,r.style.fontVariant=o.fontVariant,r.setAttribute("translate","no"),n.appendChild(r),this.unmountHandlers.push(()=>{(0,Y.unmountComponentAtNode)(r),r.remove()}),r}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),T.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()?(T.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(wl(o.metrics))):T.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(!Os(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let p=n,{customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i,inputMediator:a}=p,d=A(p,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i};this.configure(d),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),en(e),this.inputMediator=a||(dn(e)?new un(e):new pn(e)),this.inputMediator.on("change",({plainText:m,rawHTML:h})=>{this.store.dispatch(fr({text:m,html:h}))}),this.inputMediator.on("keyup",m=>{this.store.dispatch(vl(js(m)))}),this.inputMediator.on("keydown",m=>{this.handleKeyDown(m)}),this.inputMediator.on("paste",({pastedText:m,selectionText:h})=>{this.store.dispatch(Sl({text:m,selectionText:h}))}),this.inputMediator.on("cut",({selectionText:m})=>{this.store.dispatch(hl(m))});let c;this.inputMediator.on("selection",m=>{clearTimeout(c),m===null?c=setTimeout(()=>{m!==null&&this.store.dispatch(hr(m))},500):this.store.dispatch(hr(m))}),this.inputMediator.on("disabled",()=>{var m;(m=this.inputMediator)==null||m.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(es(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(es(!0))}),this.renderSuggestions(e,l),this.subscribe(to("inlineSuggestions"),()=>{this.renderSuggestions(e,l)});let u=this.renderOverlays(n);this.unmountHandlers.push(()=>{u.unmount()}),this.store.dispatch(fr({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(hr(this.inputMediator.getSelection())),this.store.dispatch(es(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var m;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setExternalId((m=this.state.conversation.current)==null?void 0:m.externalId)}),this.isMounted=!0}subscribe(e,n){let o=e(this.store.getState());return this.store.subscribe(()=>{let r=e(this.store.getState());r!==o&&(o=r,n(o))})}unmount(){var e,n,o,r;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.floatingMenu)==null||o.unmount(),this.unmountHandlers.forEach(s=>s()),this.unmountHandlers=[],(r=this.inputMediator)==null||r.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderSuggestions(e,n){var o,r,s;(o=this.floatingMenu)==null||o.unmount(),(r=this.inlineSuggestions)==null||r.unmount(),(s=this.aboveSuggestions)==null||s.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(e,n)),this.settings.inlineSuggestions?this.inlineSuggestions=this.renderInlineSuggestions(e,n):this.aboveSuggestions=this.renderAboveSuggestions(e,n)}renderInlineSuggestions(e,n){let{customStyles:o}=n,r=this.createInlineContainer(e,"deepdesk-caret");(0,Y.render)((0,B.jsx)(Mt,{store:this.store,customStyles:o,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(Hc,{})})}),r);let s=i=>{i?(r.style.display="block",r.style.top=`${i.top}px`,r.style.left=`${i.left}px`):r.style.display="none"};return this.inputMediator.on("caretposition",s),{unmount:()=>{var i;(0,Y.unmountComponentAtNode)(r),(i=this.inputMediator)==null||i.off("caretposition",s),r.remove()}}}renderAboveSuggestions(e,n){let{customStyles:o,closestScrollSelector:r,appendOverlayTo:s}=n,i=r&&pa(e,r)||void 0,a=this.overlayContainerFactory("deepdesk-tab-completion",i||e,{appendTo:s,closestScrollElement:i,mirrorOverflow:!0,onRemove:()=>this.unmount()},o==null?void 0:o.rootNode),d=this.overlayContainerFactory("deepdesk-suggestions-overlay",i||e,{appendTo:s},o==null?void 0:o.suggestionsRootNode);return(0,Y.render)((0,B.jsx)(Mt,{store:this.store,customStyles:o,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(vp,{inputElement:e})})}),a),(0,Y.render)((0,B.jsx)(Mt,{store:this.store,customStyles:o,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(Xc,{onLogIn:()=>this.loginViaPopup().catch(l=>T.warn(l.message))})})}),d),{unmount(){(0,Y.unmountComponentAtNode)(a),(0,Y.unmountComponentAtNode)(d),a.remove(),d.remove()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:r,appendOverlayTo:s,floatingMenuParent:i}=n,a=r&&pa(e,r)||void 0,d=this.overlayContainerFactory("floating-menu",a||e,{appendTo:i!=null?i:s},o==null?void 0:o.floatingMenuParent);return(0,Y.render)((0,B.jsx)(Mt,{store:this.store,customStyles:o,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(Tc,{onLogIn:()=>this.loginViaPopup().catch(l=>T.warn(l.message))})})}),d),{unmount(){(0,Y.unmountComponentAtNode)(d),d.remove()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays");return(0,Y.render)((0,B.jsx)(Mt,{store:this.store,customStyles:n,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(yc,{})})}),o),{unmount(){(0,Y.unmountComponentAtNode)(o),o.remove()}}}renderWidget(e,n={}){if(this.widgetRoot&&T.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:r,isEmbedded:s}=n;this.widgetRoot=e,this.configure({showImages:r,isEmbedded:s}),(0,Y.render)((0,B.jsx)(Mt,{store:this.store,customStyles:o,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(Yp,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(i=>T.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setExternalId((i=this.state.conversation.current)==null?void 0:i.externalId)})}unmountWidget(){this.widgetRoot&&(0,Y.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}renderKnowledgeAssistantWidget(e,n,o={}){let{customStyles:r,initialQuestion:s}=o;return(0,Y.render)((0,B.jsx)(Mt,{store:this.store,customStyles:r,children:(0,B.jsx)(kt,{broadcastEvents:this.broadcastEvents,children:(0,B.jsx)(na,{children:(0,B.jsxs)(Cs,{assistantCode:e,initialQuestion:s,evaluateKnowledgeAssistFn:o.isLegacyKnowledgeAssist?jt:$t,children:[(0,B.jsx)(yn,{children:(0,B.jsx)(Es,{emptyState:o.emptyState})}),(0,B.jsx)(ta,{children:(0,B.jsx)(Ts,{})})]})})})}),n),{unmount(){(0,Y.unmountComponentAtNode)(n),n.remove()}}}setupHandlingTime(e){let n=Fs(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Eu(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(wo());let e=Gt(this.state);e&&this.store.dispatch(ar({showSearch:e.search,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:!!e.summarizerAssistantNew||e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistantNew||!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions}))})),this.loadProfileConfigPromise)}loginViaPopup(e){return v(this,null,function*(){return new Promise((n,o)=>{let r=new MessageChannel,s=r.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)};s.onmessage=m=>v(this,null,function*(){var h,f;if((h=m.data)!=null&&h.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((f=m.data)==null?void 0:f.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(so),d=!0,r.port1.close(),n()}catch(y){console.error(y),o(y)}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=m=>v(this,null,function*(){var h;if(m.origin===a.origin)switch((h=m.data)==null?void 0:h.type){case"deepdesk-popup-loaded":{try{let f=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(f,a.origin,[r.port2])}catch(f){T.error("Error posting message to popup",f),o(f)}break}case"deepdesk-popup-error":{l(),m.data.message==="Timeout"&&T.warn("Popup timed out. Check if the account's platform url is configured correctly."),o(new Error(m.data.message));break}}});window.addEventListener("message",u);let p=setInterval(()=>{c&&!c.closed||(l(),d||o(new Error("Popup closed by user")))},200);this.unmountHandlers.push(l)})})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}checkForTrialMode(e){return v(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(T.info("Trial is active"),!(yield this.deepdeskApi.checkUserExists(e)))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:o}=n;T.info(o),this.shouldRender=!1}})}refreshWidgetSuggestions(){return v(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=Co(this.state);try{n.forEach(({type:o})=>{o==="entities"?this.store.dispatch(Be()):ir.includes(o)||this.store.dispatch(Ve(o))})}catch(o){this.handleError(o)}})}};Qn.version="17.0.0-rc.6",Qn.count=0;var Zo=Qn;function Dh(t){return v(this,null,function*(){var r,s,i;let n=yield((r=t.fetch)!=null?r:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(s=t.mimeType)!=null?s:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function Hu(t,e){return v(this,null,function*(){let n=yield Dh(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 Ku(t,e,n){return v(this,null,function*(){yield new xt(t).authenticateWithKey(e,n)})}function Bu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Uu(o,r){return v(this,arguments,function*(t,e,n={}){var u,p;let{value:s}=t,{start:i,end:a}=(u=n.replace)!=null?u:{start:0,end:s.length},d=`${s.slice(0,i)}${e}${s.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 Vu(o,r){return v(this,arguments,function*(t,e,n={}){let s=n.replace?Dt(t,n.replace.start,n.replace.end):$n(t),i,a=()=>{if(n.setRange)return n.setRange(s.cloneRange());s.deleteContents(),i=document.createElement("span"),s.insertNode(i),n.insertBRs!==!1?e.split(`
11
+ `).reverse().forEach((d,l)=>{l>0&&s.insertNode(document.createElement("br")),s.insertNode(document.createTextNode(d))}):s.insertNode(document.createTextNode(e))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let d=n.selectionAfter?Dt(t,n.selectionAfter.start,n.selectionAfter.end):(s.collapse(!1),s),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 _h(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 Fh(t){let e=document.createDocumentFragment();return t.split(`
12
+ `).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let r={index:0},s=0;for(;r=n.slice(s).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=r[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(r[2])),e.appendChild(document.createTextNode(n.slice(s,s+r.index))),e.appendChild(i),s=s+r.index+r[0].length}e.appendChild(document.createTextNode(n.slice(s)))}),e}function zu(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):zu(n,e)}function Wu(r,s){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?_h(e):Fh(e);n?zu(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()}})})}0&&(module.exports={Card,ContentEditableInput,DeepdeskAPI,DeepdeskSDK,HTTPClient,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createFullRange,createOverlayContainer,createRangeFromOffsets,escapeHTML,formatTextMarkup,getRangeOffsets,getRangeText,insertCKEditor,isHTML,isSupportedInputElement,updateContentEditable,updateTextArea,useClickOutsideRoot,useStyles,waitForElementVisibilityChange});