@deepdesk/deepdesk-sdk 19.1.1-beta.1 → 19.1.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +8 -8
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +8 -8
- package/dist/index.iife.js +25 -25
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var Qu=Object.create;var Zn=Object.defineProperty,Zu=Object.defineProperties,Yu=Object.getOwnPropertyDescriptor,eg=Object.getOwnPropertyDescriptors,tg=Object.getOwnPropertyNames,Zo=Object.getOwnPropertySymbols,ng=Object.getPrototypeOf,Wr=Object.prototype.hasOwnProperty,Ea=Object.prototype.propertyIsEnumerable;var wa=(t,e,n)=>e in t?Zn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))Wr.call(e,n)&&wa(t,n,e[n]);if(Zo)for(var n of Zo(e))Ea.call(e,n)&&wa(t,n,e[n]);return t},S=(t,e)=>Zu(t,eg(e));var M=(t,e)=>{var n={};for(var o in t)Wr.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&Zo)for(var o of Zo(t))e.indexOf(o)<0&&Ea.call(t,o)&&(n[o]=t[o]);return n};var Y=(t,e)=>{for(var n in e)Zn(t,n,{get:e[n],enumerable:!0})},ka=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of tg(e))!Wr.call(t,s)&&s!==n&&Zn(t,s,{get:()=>e[s],enumerable:!(o=Yu(e,s))||o.enumerable});return t};var O=(t,e,n)=>(n=t!=null?Qu(ng(t)):{},ka(e||!t||!t.__esModule?Zn(n,"default",{value:t,enumerable:!0}):n,t)),og=t=>ka(Zn({},"__esModule",{value:!0}),t);var v=(t,e,n)=>new Promise((o,s)=>{var r=d=>{try{a(n.next(d))}catch(l){s(l)}},i=d=>{try{a(n.throw(d))}catch(l){s(l)}},a=d=>d.done?o(d.value):Promise.resolve(d.value).then(r,i);a((n=n.apply(t,e)).next())});var qh={};Y(qh,{Card:()=>F,ContentEditableInput:()=>cn,DeepdeskAPI:()=>yt,DeepdeskSDK:()=>Qo,HTTPClient:()=>un,InputMediator:()=>ht,InputType:()=>Kt,KeyboardHint:()=>os,Label:()=>Oa,Locale:()=>eo,Section:()=>Ke,SectionList:()=>hn,Sources:()=>et,Suggestion:()=>I,SuggestionList:()=>ie,TextAreaInput:()=>pn,ToggleButton:()=>Ut,attachFile:()=>Vu,authenticateWithKey:()=>ju,createFullRange:()=>$n,createOverlayContainer:()=>Xo,createRangeFromOffsets:()=>Dt,escapeHTML:()=>An,formatTextMarkup:()=>$u,getRangeOffsets:()=>Go,getRangeText:()=>qo,insertCKEditor:()=>Ju,isHTML:()=>Co,isSupportedInputElement:()=>_r,logEvent:()=>Ks,updateContentEditable:()=>qu,updateTextArea:()=>Gu,useClickOutsideRoot:()=>Rt,useStyles:()=>x,waitForElementVisibilityChange:()=>Br});module.exports=og(qh);var jr=O(require("classnames")),we=O(require("react"));var Yo=O(require("react")),Ra=O(require("classnames"));var Yn=Yo.default.createContext({});function x(t,e){let r=(0,Yo.useContext)(Yn),{debug:n}=r,s=M(r,["debug"])[t];return Object.entries(e).reduce((i,[a,d])=>{let l=s==null?void 0:s[a];return S(y({},i),{[a]:(0,Ra.default)(d,l,n?`${t}__${a}`:!1)})},{})}var Pa={root:"dd-4s9wq"};var Ht=require("react/jsx-runtime"),es=()=>(0,Ht.jsxs)("svg",{className:Pa.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 Vr={root:"dd-c9KvZ",imageWrapper:"dd-sE7D9",image:"dd-bEGMz",content:"dd-oFIQa",title:"dd-mSgoo",contentIsCropped:"dd-Uvjv4",lineClamp:"dd-ApQo-"};var Bt=require("react/jsx-runtime"),ts=(0,we.createContext)(Vr),sg=({title:t,src:e})=>{let n=(0,we.useContext)(ts),[o,s]=(0,we.useState)(!1);return(0,we.useEffect)(()=>{s(!1)},[e]),(0,Bt.jsx)("div",{className:n.imageWrapper,children:e&&!o?(0,Bt.jsx)("img",{className:n.image,alt:t,src:e,onError:()=>s(!0)}):(0,Bt.jsx)(es,{})})},rg=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let s=(0,we.useContext)(ts);return(0,Bt.jsx)("div",{className:(0,jr.default)(s.content,t,{[s.contentIsCropped]:n,[s.lineClamp]:e}),children:o})},ig=r=>{var i=r,{as:t="h1",cropText:e=!1,className:n,children:o}=i,s=M(i,["as","cropText","className","children"]);let a=(0,we.useContext)(ts);return we.default.createElement(t,y({className:(0,jr.default)(a.title,n,{[a.contentIsCropped]:e})},s),o)},ns=({children:t})=>{let e=x("Card",Vr);return(0,Bt.jsx)("div",{className:e.root,children:(0,Bt.jsx)(ts.Provider,{value:e,children:t})})};ns.Image=sg;ns.Content=rg;ns.Title=ig;var F=ns;var La=O(require("classnames"));var Ia={root:"dd-llBx9"};var Aa=require("react/jsx-runtime");var ag={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},lg=o=>{var s=o,{className:t,keyCode:e}=s,n=M(s,["className","keyCode"]);let r=x("KeyboardHint",Ia);return(0,Aa.jsx)("span",y({"data-key":ag[e],className:(0,La.default)(t,r.root)},n))},os=lg;var Na=O(require("classnames"));var Ma={root:"dd-e6HXZ"};var Da=require("react/jsx-runtime"),dg=o=>{var s=o,{className:t,children:e}=s,n=M(s,["className","children"]);let r=x("Label",Ma);return(0,Da.jsx)("span",S(y({},n),{className:(0,Na.default)(t,r.root),children:e}))},Oa=dg;var _a={root:"dd-FiMI7",subTitleContainer:"dd-98jc7",subtitle:"dd-3MnW8",suggestions:"dd-0SGL8"};var fn=require("react/jsx-runtime"),cg=s=>{var r=s,{title:t,children:e,type:n}=r,o=M(r,["title","children","type"]);let i=x("Section",_a);return(0,fn.jsxs)("section",S(y({},o),{className:i.root,"data-section-type":n,children:[t&&(0,fn.jsx)("div",{className:i.subTitleContainer,children:(0,fn.jsx)("span",{className:i.subtitle,children:t})}),(0,fn.jsx)("div",{className:i.suggestions,children:e})]}))},Ke=cg;var Ka=O(require("classnames")),za=require("react");var xt=require("react"),Ba=require("react/jsx-runtime"),Fa=(0,xt.createContext)(null),Ha=({scrollContainerRef:t,children:e})=>{let n=(0,xt.useCallback)(o=>{let s=t.current;if(!s||s.scrollHeight<=s.clientHeight)return;let{top:r}=s.getBoundingClientRect(),{top:i}=o.getBoundingClientRect();"scrollTo"in s?s.scrollTo({top:i-r}):s.scrollTop=i-r},[]);return(0,Ba.jsx)(Fa.Provider,{value:n,children:e})},ss=t=>{let e=(0,xt.useContext)(Fa);(0,xt.useEffect)(()=>{let n=t.current;n&&e(n)},[])};var Ua={root:"dd-uoTXh"};var $r=require("react/jsx-runtime"),pg=({className:t,children:e})=>{let n=x("SectionList",Ua),o=(0,za.useRef)(null);return(0,$r.jsx)(Ha,{scrollContainerRef:o,children:(0,$r.jsx)("div",{ref:o,className:(0,Ka.default)(n.root,t),children:e})})},hn=pg;var yn=O(require("classnames")),ge=O(require("react"));var Gr={root:"dd-1g-A9",fadein:"dd-McXxq",isClickable:"dd-CTG8E",isSelected:"dd-yhg27",actions:"dd-Nlm6p",actionsIsFixed:"dd-OK-kw",actionButton:"dd-zbXsQ",dropdownList:"dd-AvwWP",dropdownButton:"dd-piaJi",dropdownItem:"dd-qgkTO",dropdownItemButton:"dd-sTE2D",actionButtonIsPrimary:"dd-mhkWS",actionButtonIsDisabled:"dd-0eKLQ",labels:"dd-QKJu6",label:"dd-aMplE",buttonsContainer:"dd-uRYN4",button:"dd-9UE-x",buttonPrimary:"dd-aYDCB",buttonSecondary:"dd--cpPL",buttonWithIcon:"dd-MQVt5",icon:"dd-Jr-ww",buttonDisabled:"dd-agTuH"};var re=require("react/jsx-runtime"),St=(0,ge.createContext)(Gr),ug=o=>{var s=o,{fixed:t,children:e}=s,n=M(s,["fixed","children"]);let r=(0,ge.useContext)(St);return(0,re.jsx)("div",S(y({},n),{className:(0,yn.default)(r.actions,{[r.actionsIsFixed]:t}),children:e}))};function gg(d){var l=d,{as:t,className:e,icon:n,title:o,children:s,disabled:r,variant:i}=l,a=M(l,["as","className","icon","title","children","disabled","variant"]);let c=(0,ge.useContext)(St);return(0,re.jsxs)(t||"button",S(y({type:"button",className:(0,yn.default)(c.button,{[c.buttonWithIcon]:n,[c.buttonDisabled]:r,[c.buttonPrimary]:i==="primary",[c.buttonSecondary]:i==="secondary"},e),title:o,"aria-label":o},a),{children:[n&&(0,re.jsx)("span",{className:c.icon,children:n}),s]}))}var mg=({children:t})=>{let e=(0,ge.useContext)(St);return(0,re.jsx)("div",{className:e.buttonsContainer,children:t})},fg=({className:t,primary:e,disabled:n,label:o,children:s})=>{let r=(0,ge.useContext)(St);return(0,re.jsxs)("div",{className:(0,yn.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,(0,re.jsx)("ul",{className:r.dropdownList,children:s})]})},hg=({index:t,label:e,onClick:n})=>{let o=(0,ge.useContext)(St);return(0,re.jsx)("li",{className:o.dropdownItem,children:(0,re.jsx)("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},yg=({className:t,primary:e,disabled:n,onClick:o,label:s})=>{let r=(0,ge.useContext)(St);return(0,re.jsx)("button",{type:"button",className:(0,yn.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onClick:o!=null?o:(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:s})},vg=({labels:t})=>{let e=(0,ge.useContext)(St);return(0,re.jsx)("div",{className:e.labels,children:t.map(n=>(0,re.jsx)("span",{className:e.label,children:n},n))})},bt=ge.default.forwardRef((a,i)=>{var d=a,{className:t,selected:e,onClick:n,children:o,as:s="div"}=d,r=M(d,["className","selected","onClick","children","as"]);let l=x("Suggestion",Gr),c=(0,ge.useCallback)(u=>{u.preventDefault(),n&&n(u)},[n]);return(0,re.jsx)(s,S(y({},r),{ref:i,className:(0,yn.default)(t,l.root,{[l.isSelected]:e,[l.isClickable]:!!n}),onClick:c,children:(0,re.jsx)(St.Provider,{value:l,children:o})}))});bt.Labels=vg;bt.Actions=ug;bt.ActionButton=yg;bt.DropdownButton=fg;bt.DropdownItem=hg;bt.ButtonsContainer=mg;bt.Button=gg;var I=bt;var Va=O(require("classnames"));var Wa={root:"dd-W35K-",isWithDivider:"dd-sscOy"};var ja=require("react/jsx-runtime"),xg=({withDivider:t,children:e})=>{let n=x("SuggestionList",Wa);return(0,ja.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Va.default)(n.root,{[n.isWithDivider]:t}),children:e})},ie=xg;var Ga=O(require("classnames"));var $a={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};var rs=require("react/jsx-runtime"),Sg=({className:t,isCollapsed:e,title:n,onClick:o})=>{let s=x("ToggleButton",$a);return(0,rs.jsx)("button",{type:"button",className:(0,Ga.default)(s.root,t,{[s.isCollapsed]:e}),onClick:o,title:n,children:(0,rs.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,rs.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Ut=Sg;var qa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,is=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Xa=/x-deepdesk-(([a-z0-9\-_])+-version)/,as=["cues","custom-data","custom-data-banner","knowledge-assist"],Ja=Intl.DateTimeFormat().resolvedOptions().timeZone,et=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(et||{}),Kt=(i=>(i.ENTER="enter",i.TAB="tab",i.ARROW="arrow",i.HOTKEY="hotkey",i.MOUSE="mouse",i.SPACE="space",i))(Kt||{});var vt=require("react-dom/client");var Jd=require("react");var Qa=require("@reduxjs/toolkit"),Za=require("react-redux");var eo=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(eo||{});var bg={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,addToPersonalCollection:!1,inlineSuggestions:!1,suggestionsPlacement:"above",floatingMenu:!1,detectSubmit:!1,automaticHandlingTime:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!0,adminUrl:void 0,productName:"Deepdesk",hasKeyboardInput:!0},Ya=(0,Qa.createSlice)({name:"settings",initialState:bg,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,s]=n;typeof s!="undefined"&&(t[o]=s)})}}}),{set:ls}=Ya.actions,vn=t=>e=>e.settings[t],E=t=>(0,Za.useSelector)(vn(t)),el=Ya.reducer;var fi=require("react-redux");var xn=require("@reduxjs/toolkit");var Cg={isLoggedIn:null,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1,loginError:null},ne=t=>t.auth.isLoggedIn;var tl=t=>t.auth.verifyFetchState,nl=t=>t.auth.showLoginOverlay,ol=t=>t.auth.loginError,tt=(0,xn.createAsyncThunk)("auth/validate",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.isLoggedIn()})),sl=(0,xn.createAsyncThunk)("auth/requestLogin",(n,o)=>v(null,[n,o],function*({email:t},e){let{deepdeskAPI:s}=e.extra;return s.requestLoginByEmail(t)})),to=(0,xn.createAsyncThunk)("auth/verifyLoginToken",(n,o)=>v(null,[n,o],function*({token:t},e){let{deepdeskAPI:s}=e.extra;return s.verifyLoginToken(t)})),rl=(0,xn.createSlice)({name:"auth",initialState:Cg,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload},setLoginError(t,e){t.loginError=e.payload},clearLoginError(t){t.loginError=null}},extraReducers:t=>{t.addCase(tt.pending,e=>{e.loginFetchState="loading"}),t.addCase(tt.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(tt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(to.pending,e=>{e.verifyFetchState="loading"}),t.addCase(to.rejected,e=>{e.verifyFetchState="error"}),t.addCase(to.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Sn,setShowLoginOverlay:il,setLoginError:qr,clearLoginError:ds}=rl.actions,al=rl.reducer;var Wt=require("@reduxjs/toolkit"),ml=require("diff");function ll(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Ct(t,e,n=10){let o=typeof t,s=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==s?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>Ct(r,e[i],n-1)):ll(t)&&ll(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Ct(t[i],e[i],n-1)):!1}function Tg(t){return Math.max(...t.map(e=>e.length))}function wg(t,e){let n=t.reduce((o,s)=>{if(s){let r=o[s]?o[s]+1:1;return S(y({},o),{[s]:r})}return o},{});return Object.keys(n).reduce((o,s)=>(n[s]<e&&o.push(s),o),[])}function dl(t,e){let o=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Tg(o);s++){let r=wg(o.map(a=>a[s]),e),i=o.filter(a=>!r.includes(a[s]));if(i.length>=e)o=i;else return{text:o[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Eg=2;function cl(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=dl(t,Eg);return n&&n.text!==e?n:t[0]}var Me=require("@reduxjs/toolkit");var kg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=kg;var pl={current:null,isSupported:null},J=(0,Me.createAction)("resetConversation"),ul=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.externalId)||null},ze=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},bn=t=>t.conversation.isSupported,Xr=(0,Me.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),cs=(0,Me.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),ps=(0,Me.createAsyncThunk)("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),us=(0,Me.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=ze(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),Jr=(0,Me.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:s,agentName:r,agentEmail:i,agentNickname:a,metadata:d}=t;return n.updateConversation(o.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,metadata:d})})}),Qr=(0,Me.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=ze(e.getState());if(!o)throw new Error("No current conversation to update messages");return n.postMessages(o,t.map(s=>y({},s)))}),Rg=[cs.rejected,ps.rejected,us.rejected,Qr.rejected].map(t=>t==null?void 0:t.toString());function Pg(t){return Rg.includes(t.type)}var Ig=(0,Me.createSlice)({name:"conversation",initialState:pl,reducers:{},extraReducers:t=>{t.addCase(Xr.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(cs.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(ps.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Jr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(us.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(J,()=>pl).addMatcher(Pg,(e,n)=>{var o;throw k.info("Conversation action rejected",n.type,((o=n.error)==null?void 0:o.message)||"No message"),new Error(n.error.message)})}}),gl=Ig.reducer;var zt={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],pinnedSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Zr(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}}var gs=(0,Wt.createAction)("input/applyImageSuggestion"),fl=(0,Wt.createSlice)({name:"input",initialState:zt,reducers:{setInput(t,e){var r,i;let{beforeInputChange:n}=t,{text:o,html:s}=e.payload;if(t.text=o,t.html=s!=null?s:null,o==="")t.metrics=zt.metrics,t.textSuggestions=[],t.mixedSuggestion=null;else if(n!==null&&t.text!==n.text){let{key:a,shiftKey:d,ctrlKey:l,metaKey:c,altKey:u}=n.keyDown;switch(a){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:p}=t,f=(0,ml.diffChars)(n.text,p);n.text.length-p.length>1&&t.metrics.deletions.push(...f.filter(m=>m.removed).map(m=>m.value)),t.metrics.numCharsDeleted+=n.text.length-p.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(l||c)break;default:if(!l&&!c&&!u){t.metrics.numCharsTyped+=1;let p=((r=n.selection)==null?void 0:r.start)!==void 0&&((i=n.selection)==null?void 0:i.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;p&&p.length>0&&(t.metrics.numCharsDeleted+=p.length,t.metrics.deletions.push(p))}}t.metrics.agentStartedTypingTimestamp||(t.metrics.agentStartedTypingTimestamp=Date.now())}t.beforeInputChange=null},sendMessage(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(n=>!t.metrics.textSuggestions.some(o=>o.text===n.text&&o.source===n.source))},setSelection(t,e){e.payload!==null&&(Ct(t.selection,e.payload)||(t.selection=e.payload))},commitSuggestion(t,e){let n=e.payload,{text:o,suggestion:{source:s,abVariant:r,abTestName:i,trainingJobs:a,sourceText:d,searchTerm:l,assistantCode:c,text:u},eventMetrics:{inputType:p},replace:f}=n,m=s==="search"||s==="personal-collection-search",g=o.slice(t.text.substring(0,t.selection.start).length);(m||f==="selection")&&(g=o),n.suggestion.source==="search-overlay"&&(g=u),t.metrics.textSuggestions.push({text:g,source:s,assistantCode:c,abVariant:r,abTestName:i,inputType:p,sourceText:d,trainingJobs:a||[],searchTerm:m?t.text:l}),t.textSuggestions=[],t.selectedSuggestionIndex=-1},offeredTextSuggestion(t,e){let{text:n,suggestion:{source:o}}=e.payload;t.metrics.offeredTextSuggestions.find(r=>r.text===n)||t.metrics.offeredTextSuggestions.push({text:n,source:o})},registerKeyDown(t,e){let{key:n}=e.payload;["Control","Meta","Shift","Alt"].includes(n)||(t.beforeInputChange={text:t.text,selection:t.selection,keyDown:e.payload})},registerKeyUp(t,e){},registerCut(t,e){let{metrics:n}=t,o=e.payload;t.metrics=S(y({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:s}=e.payload,r=n.numCharsDeleted+(s!=null&&s.length?s.length:0),i=s!=null&&s.length?[...n.deletions,s]:n.deletions;t.metrics=S(y({},t.metrics),{numCharsDeleted:r,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},selectPreviousTextSuggestion(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},selectTextSuggestionByIndex(t,e){t.selectedSuggestionIndex=e.payload},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0){t.mixedSuggestion=null;return}let n=t.text.substring(0,t.selection.end),o=cl(e.payload,n);t.mixedSuggestion=o!=null&&o.text.includes(n)?o:null},setPinnedSuggestions(t,e){t.pinnedSuggestions=e.payload},removePinnedSuggestions(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(o=>o.source!==e.payload.source||e.payload.assistantCode&&o.assistantCode!==e.payload.assistantCode?!0:e.payload.text?o.text!==e.payload.text:!1);let n=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex>n-1&&(t.selectedSuggestionIndex=-1)},setMetrics(t,{payload:e}){t.metrics=e},resetMetrics(t){t.metrics=zt.metrics}},extraReducers:t=>{t.addCase(J,e=>{e.mixedSuggestion=zt.mixedSuggestion,e.textSuggestions=zt.textSuggestions,e.selectedSuggestionIndex=zt.selectedSuggestionIndex,e.metrics=zt.metrics})}}),Cn=t=>t.input.text.substring(0,t.input.selection.end),Lg=t=>t.input.mixedSuggestion,Ag=t=>t.input.pinnedSuggestions,Mg=t=>t.input.textSuggestions,no=t=>t.input.selectedSuggestionIndex,Vt=(0,Wt.createSelector)([Mg,Ag],(t,e)=>[...t,...e]),Tn=(0,Wt.createSelector)([Vt,Lg,no],(t,e,n)=>n>-1?t[n]:e),hl=t=>t.input.selection,{commitSuggestion:ye,offeredTextSuggestion:yl,registerCut:vl,registerKeyDown:xl,registerKeyUp:Sl,registerPaste:bl,selectNextTextSuggestion:Cl,selectPreviousTextSuggestion:Tl,selectTextSuggestionByIndex:ms,setInput:fs,setMetrics:wl,setPinnedSuggestions:wn,removePinnedSuggestions:jt,setSelection:hs,setTextSuggestions:Tt,resetMetrics:El,sendMessage:$t}=fl.actions,kl=fl.reducer;var kn=require("@reduxjs/toolkit");var Gt=require("@reduxjs/toolkit");function Rl(t){try{return Intl.DateTimeFormat(void 0,{timeZone:t}),!0}catch(e){return!1}}var Ng={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle",showNicknameDialog:!1},En=t=>{var e;return(e=t.info.agentInfo)!=null?e:null},Pl=t=>{var e;return(e=t.info.visitorInfo)!=null?e:null},Il=t=>{var e;return(e=t.info.customData)!=null?e:null},so=({info:{visitorInfo:t,agentInfo:e}})=>{var n,o;return{timezone:t!=null&&t.visitorTimeZone&&Rl(t.visitorTimeZone)?t.visitorTimeZone:Ja,agentName:(n=e==null?void 0:e.agentNickname)!=null?n:"",visitorName:(o=t==null?void 0:t.visitorName)!=null?o:""}},Og=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],Ll=(0,Gt.createAsyncThunk)("info/setAgentNickname",(n,o)=>v(null,[n,o],function*({agentNickname:t},e){var i;let{deepdeskAPI:s}=e.extra,r=yield s.patchMe({nickname:t});return{agentNickname:(i=r==null?void 0:r.nickname)!=null?i:t}})),oo=(0,Gt.createAsyncThunk)("info/setAgentInfo",(t,e)=>v(null,null,function*(){var r,i,a;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=[];if(t.agentId&&t.skipSync!==!0&&s.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let d=Og.reduce((l,[c,u])=>!o[u]&&c in t?S(y({},l),{[u]:t[c]}):l,{});Object.keys(d).length>0&&s.push(n.patchMe(d).then(l=>o=l))}return s.length>0&&(yield Promise.all(s)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(r=o.nickname)!=null?r:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(a=o.defaultLocale)!=null?a:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),Yr=(0,Gt.createAsyncThunk)("info/setAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=y(y({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:s}),s})),ei=(0,Gt.createAsyncThunk)("info/getAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),Al=(0,Gt.createSlice)({name:"info",initialState:Ng,reducers:{setVisitorInfo(t,e){t.visitorInfo=y(y({},t.visitorInfo),e.payload)},setCustomData(t,e){t.customData=e.payload},setPlatformVariables(t,e){t.platformVariables=e.payload},setShowNicknameDialog(t,e){t.showNicknameDialog=e.payload}},extraReducers:t=>{t.addCase(oo.pending,(e,n)=>{e.fetchState="loading",e.agentInfo=y(y({},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(Yr.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(ei.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(J,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Ml,setCustomData:Nl,setPlatformVariables:Ol,setShowNicknameDialog:Dl}=Al.actions,_l=Al.reducer;function Ne(t,e){return e?Object.entries(e).reduce((n,[o,s])=>n.replaceAll(o,s),t):t}var ys={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},Fl=t=>t.search.isOpen,Hl=t=>t.search.page,ti=t=>t.search.list,Bl=t=>t.search.aggregates,Dg=(0,kn.createSelector)([ti,(t,e)=>e],(t,e)=>t.filter(n=>n.type===e)),Ul=t=>e=>Dg(e,t),qt=(0,kn.createAsyncThunk)("search/getAll",(t,e)=>v(null,null,function*(){var d;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(d=o.conversation.current)==null?void 0:d.profileCode,{platformVariables:r}=o.info;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:so(o)});return{results:i.map(l=>S(y(y({},l),l.title&&r?{title:Ne(l.title,r)}:{}),{text:Ne(l.text,r!=null?r:{}),source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:a}})),Kl=(0,kn.createSlice)({name:"search",initialState:ys,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ys.fetchState,t.list=ys.list}},extraReducers:t=>{t.addCase(qt.pending,e=>{e.fetchState="loading"}).addCase(qt.rejected,(e,n)=>{e.fetchState="error",k.error(n.error)}).addCase(qt.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload.results,e.aggregates=n.payload.aggregates||{}}).addCase(J,()=>ys)}}),{resetSearch:vs,setIsOpen:Oe,setPage:Rn}=Kl.actions,zl=Kl.reducer;var ni="SetOutputs",Pn="ShowLoginOverlay",ro="UserLoggedIn",_g="UserLoggedOut",nt="ApplySuggestion",oi="ApplyImageSuggestion",Fg="ShowCommandPalette",xs="ShowNicknameDialog",Ss="ReduxAction",Hg="RemovePinnedSuggestion",Bg=t=>({[ni]:e=>{t.dispatch(S(y({},e),{isBroadcasted:!0}))},[Ss]:e=>{e.isBroadcasted||t.dispatch(S(y({},e),{isBroadcasted:!0}))},[Hg]:e=>{t.dispatch(jt(e))},[Fg]:e=>{t.dispatch(Oe(e.isOpen)),e.page&&t.dispatch(Rn(e.page))},[xs]:e=>{t.dispatch(Dl(e.showNicknameDialog))},[Pn]:e=>{t.dispatch(il(e))},[ro]:()=>{t.dispatch(tt())},[_g]:()=>{t.dispatch(tt())},[oi]:e=>{t.dispatch(gs({suggestion:e.suggestion}))},[nt]:e=>{t.dispatch(ye(S(y({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),Wl=Bg;var io=O(require("react")),jl=require("react/jsx-runtime"),Vl=io.default.createContext(null),ot=({broadcastEvents:t,children:e})=>{let n=io.default.useMemo(()=>t,[]);return(0,jl.jsx)(Vl.Provider,{value:n,children:e})},me=()=>{let t=(0,io.useContext)(Vl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var Ls=O(require("classnames")),De=require("react"),As=require("react-redux");var Ps=require("react");var si=function(t,e){return si=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},si(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");si(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var ve=function(){return ve=Object.assign||function(e){for(var n,o=1,s=arguments.length;o<s;o++){n=arguments[o];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ve.apply(this,arguments)};function $l(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(n[o[s]]=t[o[s]]);return n}function bs(t,e,n){if(n||arguments.length===2)for(var o=0,s=e.length,r;o<s;o++)(r||!(o in e))&&(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}function Cs(t,e){var n=e&&e.cache?e.cache:$g,o=e&&e.serializer?e.serializer:Vg,s=e&&e.strategy?e.strategy:Kg;return s(t,{cache:n,serializer:o})}function Ug(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Gl(t,e,n,o){var s=Ug(o)?o:n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.call(this,o),e.set(s,r)),r}function ql(t,e,n){var o=Array.prototype.slice.call(arguments,3),s=n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.apply(this,o),e.set(s,r)),r}function ri(t,e,n,o,s){return n.bind(e,t,o,s)}function Kg(t,e){var n=t.length===1?Gl:ql;return ri(t,this,n,e.cache.create(),e.serializer)}function zg(t,e){return ri(t,this,ql,e.cache.create(),e.serializer)}function Wg(t,e){return ri(t,this,Gl,e.cache.create(),e.serializer)}var Vg=function(){return JSON.stringify(arguments)},jg=(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})(),$g={create:function(){return new jg}},Ts={variadic:zg,monadic:Wg};var ws;(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"})(ws||(ws={}));var Es=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Ee;(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"})(Ee||(Ee={}));var ks;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(ks||(ks={}));function ii(t){return t.type===Ee.literal}function ai(t){return t.type===Ee.argument}function lo(t){return t.type===Ee.number}function co(t){return t.type===Ee.date}function po(t){return t.type===Ee.time}function uo(t){return t.type===Ee.select}function go(t){return t.type===Ee.plural}function Xl(t){return t.type===Ee.pound}function mo(t){return t.type===Ee.tag}function Rs(t){return!!(t&&typeof t=="object"&&t.type===ks.number)}function fo(t){return!!(t&&typeof t=="object"&&t.type===ks.dateTime)}function li(t){t.forEach(function(e){if(delete e.location,uo(e)||go(e))for(var n in e.options)delete e.options[n].location,li(e.options[n].value);else lo(e)&&Rs(e.style)||(co(e)||po(e))&&fo(e.style)?delete e.style.location:mo(e)&&li(e.children)})}function Jl(t,e){e===void 0&&(e={}),e=ve({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new Es(t,e).parse();if(n.err){var o=SyntaxError(ws[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||li(n.val),n.val}var Xt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Xt||(Xt={}));var ho=(function(t){ao(e,t);function e(n,o,s){var r=t.call(this,n)||this;return r.code=o,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e})(Error);var di=(function(t){ao(e,t);function e(n,o,s,r){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(s).join('", "'),'"'),Xt.INVALID_VALUE,r)||this}return e})(ho);var Ql=(function(t){ao(e,t);function e(n,o,s){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),Xt.INVALID_VALUE,s)||this}return e})(ho);var Zl=(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,'"'),Xt.MISSING_VALUE,o)||this}return e})(ho);var se;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(se||(se={}));function Gg(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 qg(t){return typeof t=="function"}function yo(t,e,n,o,s,r,i){if(t.length===1&&ii(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(ii(c)){a.push({type:se.literal,value:c.value});continue}if(Xl(c)){typeof r=="number"&&a.push({type:se.literal,value:n.getNumberFormat(e).format(r)});continue}var u=c.value;if(!(s&&u in s))throw new Zl(u,i);var p=s[u];if(ai(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 f=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,f).format(p)});continue}if(po(c)){var f=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,f).format(p)});continue}if(lo(c)){var f=typeof c.style=="string"?o.number[c.style]:Rs(c.style)?c.style.parsedOptions:void 0;f&&f.scale&&(p=p*(f.scale||1)),a.push({type:se.literal,value:n.getNumberFormat(e,f).format(p)});continue}if(mo(c)){var m=c.children,g=c.value,h=s[g];if(!qg(h))throw new Ql(g,"function",i);var b=yo(m,e,n,o,s,r),T=h(b.map(function(L){return L.value}));Array.isArray(T)||(T=[T]),a.push.apply(a,T.map(function(L){return{type:typeof L=="string"?se.literal:se.object,value:L}}))}if(uo(c)){var C=c.options[p]||c.options.other;if(!C)throw new di(c.value,p,Object.keys(c.options),i);a.push.apply(a,yo(C.value,e,n,o,s));continue}if(go(c)){var C=c.options["=".concat(p)];if(!C){if(!Intl.PluralRules)throw new ho(`Intl.PluralRules is not available in this environment.
|
|
1
|
+
"use strict";var Ju=Object.create;var Qn=Object.defineProperty,Qu=Object.defineProperties,Zu=Object.getOwnPropertyDescriptor,Yu=Object.getOwnPropertyDescriptors,eg=Object.getOwnPropertyNames,Qo=Object.getOwnPropertySymbols,tg=Object.getPrototypeOf,zr=Object.prototype.hasOwnProperty,wa=Object.prototype.propertyIsEnumerable;var Ta=(t,e,n)=>e in t?Qn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))zr.call(e,n)&&Ta(t,n,e[n]);if(Qo)for(var n of Qo(e))wa.call(e,n)&&Ta(t,n,e[n]);return t},S=(t,e)=>Qu(t,Yu(e));var M=(t,e)=>{var n={};for(var o in t)zr.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&Qo)for(var o of Qo(t))e.indexOf(o)<0&&wa.call(t,o)&&(n[o]=t[o]);return n};var Y=(t,e)=>{for(var n in e)Qn(t,n,{get:e[n],enumerable:!0})},Ea=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of eg(e))!zr.call(t,s)&&s!==n&&Qn(t,s,{get:()=>e[s],enumerable:!(o=Zu(e,s))||o.enumerable});return t};var O=(t,e,n)=>(n=t!=null?Ju(tg(t)):{},Ea(e||!t||!t.__esModule?Qn(n,"default",{value:t,enumerable:!0}):n,t)),ng=t=>Ea(Qn({},"__esModule",{value:!0}),t);var v=(t,e,n)=>new Promise((o,s)=>{var r=d=>{try{a(n.next(d))}catch(l){s(l)}},i=d=>{try{a(n.throw(d))}catch(l){s(l)}},a=d=>d.done?o(d.value):Promise.resolve(d.value).then(r,i);a((n=n.apply(t,e)).next())});var Gh={};Y(Gh,{Card:()=>F,ContentEditableInput:()=>dn,DeepdeskAPI:()=>yt,DeepdeskSDK:()=>Jo,HTTPClient:()=>un,InputMediator:()=>ht,InputType:()=>Ut,KeyboardHint:()=>ns,Label:()=>Na,Locale:()=>Yn,Section:()=>Ke,SectionList:()=>hn,Sources:()=>et,Suggestion:()=>I,SuggestionList:()=>ie,TextAreaInput:()=>cn,ToggleButton:()=>Bt,attachFile:()=>Wu,authenticateWithKey:()=>Vu,createFullRange:()=>$n,createOverlayContainer:()=>qo,createRangeFromOffsets:()=>Dt,escapeHTML:()=>An,formatTextMarkup:()=>ju,getRangeOffsets:()=>$o,getRangeText:()=>Go,insertCKEditor:()=>Xu,isHTML:()=>bo,isSupportedInputElement:()=>Dr,logEvent:()=>Us,updateContentEditable:()=>Gu,updateTextArea:()=>$u,useClickOutsideRoot:()=>Rt,useStyles:()=>x,waitForElementVisibilityChange:()=>Hr});module.exports=ng(Gh);var Vr=O(require("classnames")),we=O(require("react"));var Zo=O(require("react")),ka=O(require("classnames"));var Zn=Zo.default.createContext({});function x(t,e){let r=(0,Zo.useContext)(Zn),{debug:n}=r,s=M(r,["debug"])[t];return Object.entries(e).reduce((i,[a,d])=>{let l=s==null?void 0:s[a];return S(y({},i),{[a]:(0,ka.default)(d,l,n?`${t}__${a}`:!1)})},{})}var Ra={root:"dd-4s9wq"};var Ft=require("react/jsx-runtime"),Yo=()=>(0,Ft.jsxs)("svg",{className:Ra.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Ft.jsx)("defs",{children:(0,Ft.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Ft.jsx)("title",{children:"Failed loading image"}),(0,Ft.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 Wr={root:"dd-c9KvZ",imageWrapper:"dd-sE7D9",image:"dd-bEGMz",content:"dd-oFIQa",title:"dd-mSgoo",contentIsCropped:"dd-Uvjv4",lineClamp:"dd-ApQo-"};var Ht=require("react/jsx-runtime"),es=(0,we.createContext)(Wr),og=({title:t,src:e})=>{let n=(0,we.useContext)(es),[o,s]=(0,we.useState)(!1);return(0,we.useEffect)(()=>{s(!1)},[e]),(0,Ht.jsx)("div",{className:n.imageWrapper,children:e&&!o?(0,Ht.jsx)("img",{className:n.image,alt:t,src:e,onError:()=>s(!0)}):(0,Ht.jsx)(Yo,{})})},sg=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let s=(0,we.useContext)(es);return(0,Ht.jsx)("div",{className:(0,Vr.default)(s.content,t,{[s.contentIsCropped]:n,[s.lineClamp]:e}),children:o})},rg=r=>{var i=r,{as:t="h1",cropText:e=!1,className:n,children:o}=i,s=M(i,["as","cropText","className","children"]);let a=(0,we.useContext)(es);return we.default.createElement(t,y({className:(0,Vr.default)(a.title,n,{[a.contentIsCropped]:e})},s),o)},ts=({children:t})=>{let e=x("Card",Wr);return(0,Ht.jsx)("div",{className:e.root,children:(0,Ht.jsx)(es.Provider,{value:e,children:t})})};ts.Image=og;ts.Content=sg;ts.Title=rg;var F=ts;var Ia=O(require("classnames"));var Pa={root:"dd-llBx9"};var La=require("react/jsx-runtime");var ig={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},ag=o=>{var s=o,{className:t,keyCode:e}=s,n=M(s,["className","keyCode"]);let r=x("KeyboardHint",Pa);return(0,La.jsx)("span",y({"data-key":ig[e],className:(0,Ia.default)(t,r.root)},n))},ns=ag;var Ma=O(require("classnames"));var Aa={root:"dd-e6HXZ"};var Oa=require("react/jsx-runtime"),lg=o=>{var s=o,{className:t,children:e}=s,n=M(s,["className","children"]);let r=x("Label",Aa);return(0,Oa.jsx)("span",S(y({},n),{className:(0,Ma.default)(t,r.root),children:e}))},Na=lg;var Da={root:"dd-FiMI7",subTitleContainer:"dd-98jc7",subtitle:"dd-3MnW8",suggestions:"dd-0SGL8"};var fn=require("react/jsx-runtime"),dg=s=>{var r=s,{title:t,children:e,type:n}=r,o=M(r,["title","children","type"]);let i=x("Section",Da);return(0,fn.jsxs)("section",S(y({},o),{className:i.root,"data-section-type":n,children:[t&&(0,fn.jsx)("div",{className:i.subTitleContainer,children:(0,fn.jsx)("span",{className:i.subtitle,children:t})}),(0,fn.jsx)("div",{className:i.suggestions,children:e})]}))},Ke=dg;var Ua=O(require("classnames")),Ka=require("react");var xt=require("react"),Ha=require("react/jsx-runtime"),_a=(0,xt.createContext)(null),Fa=({scrollContainerRef:t,children:e})=>{let n=(0,xt.useCallback)(o=>{let s=t.current;if(!s||s.scrollHeight<=s.clientHeight)return;let{top:r}=s.getBoundingClientRect(),{top:i}=o.getBoundingClientRect();"scrollTo"in s?s.scrollTo({top:i-r}):s.scrollTop=i-r},[]);return(0,Ha.jsx)(_a.Provider,{value:n,children:e})},os=t=>{let e=(0,xt.useContext)(_a);(0,xt.useEffect)(()=>{let n=t.current;n&&e(n)},[])};var Ba={root:"dd-uoTXh"};var jr=require("react/jsx-runtime"),cg=({className:t,children:e})=>{let n=x("SectionList",Ba),o=(0,Ka.useRef)(null);return(0,jr.jsx)(Fa,{scrollContainerRef:o,children:(0,jr.jsx)("div",{ref:o,className:(0,Ua.default)(n.root,t),children:e})})},hn=cg;var yn=O(require("classnames")),ge=O(require("react"));var $r={root:"dd-1g-A9",fadein:"dd-McXxq",isClickable:"dd-CTG8E",isSelected:"dd-yhg27",actions:"dd-Nlm6p",actionsIsFixed:"dd-OK-kw",actionButton:"dd-zbXsQ",dropdownList:"dd-AvwWP",dropdownButton:"dd-piaJi",dropdownItem:"dd-qgkTO",dropdownItemButton:"dd-sTE2D",actionButtonIsPrimary:"dd-mhkWS",actionButtonIsDisabled:"dd-0eKLQ",labels:"dd-QKJu6",label:"dd-aMplE",buttonsContainer:"dd-uRYN4",button:"dd-9UE-x",buttonPrimary:"dd-aYDCB",buttonSecondary:"dd--cpPL",buttonWithIcon:"dd-MQVt5",icon:"dd-Jr-ww",buttonDisabled:"dd-agTuH"};var re=require("react/jsx-runtime"),St=(0,ge.createContext)($r),pg=o=>{var s=o,{fixed:t,children:e}=s,n=M(s,["fixed","children"]);let r=(0,ge.useContext)(St);return(0,re.jsx)("div",S(y({},n),{className:(0,yn.default)(r.actions,{[r.actionsIsFixed]:t}),children:e}))};function ug(d){var l=d,{as:t,className:e,icon:n,title:o,children:s,disabled:r,variant:i}=l,a=M(l,["as","className","icon","title","children","disabled","variant"]);let c=(0,ge.useContext)(St);return(0,re.jsxs)(t||"button",S(y({type:"button",className:(0,yn.default)(c.button,{[c.buttonWithIcon]:n,[c.buttonDisabled]:r,[c.buttonPrimary]:i==="primary",[c.buttonSecondary]:i==="secondary"},e),title:o,"aria-label":o},a),{children:[n&&(0,re.jsx)("span",{className:c.icon,children:n}),s]}))}var gg=({children:t})=>{let e=(0,ge.useContext)(St);return(0,re.jsx)("div",{className:e.buttonsContainer,children:t})},mg=({className:t,primary:e,disabled:n,label:o,children:s})=>{let r=(0,ge.useContext)(St);return(0,re.jsxs)("div",{className:(0,yn.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,(0,re.jsx)("ul",{className:r.dropdownList,children:s})]})},fg=({index:t,label:e,onClick:n})=>{let o=(0,ge.useContext)(St);return(0,re.jsx)("li",{className:o.dropdownItem,children:(0,re.jsx)("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},hg=({className:t,primary:e,disabled:n,onClick:o,label:s})=>{let r=(0,ge.useContext)(St);return(0,re.jsx)("button",{type:"button",className:(0,yn.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onClick:o!=null?o:(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:s})},yg=({labels:t})=>{let e=(0,ge.useContext)(St);return(0,re.jsx)("div",{className:e.labels,children:t.map(n=>(0,re.jsx)("span",{className:e.label,children:n},n))})},bt=ge.default.forwardRef((a,i)=>{var d=a,{className:t,selected:e,onClick:n,children:o,as:s="div"}=d,r=M(d,["className","selected","onClick","children","as"]);let l=x("Suggestion",$r),c=(0,ge.useCallback)(u=>{u.preventDefault(),n&&n(u)},[n]);return(0,re.jsx)(s,S(y({},r),{ref:i,className:(0,yn.default)(t,l.root,{[l.isSelected]:e,[l.isClickable]:!!n}),onClick:c,children:(0,re.jsx)(St.Provider,{value:l,children:o})}))});bt.Labels=yg;bt.Actions=pg;bt.ActionButton=hg;bt.DropdownButton=mg;bt.DropdownItem=fg;bt.ButtonsContainer=gg;bt.Button=ug;var I=bt;var Wa=O(require("classnames"));var za={root:"dd-W35K-",isWithDivider:"dd-sscOy"};var Va=require("react/jsx-runtime"),vg=({withDivider:t,children:e})=>{let n=x("SuggestionList",za);return(0,Va.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Wa.default)(n.root,{[n.isWithDivider]:t}),children:e})},ie=vg;var $a=O(require("classnames"));var ja={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};var ss=require("react/jsx-runtime"),xg=({className:t,isCollapsed:e,title:n,onClick:o})=>{let s=x("ToggleButton",ja);return(0,ss.jsx)("button",{type:"button",className:(0,$a.default)(s.root,t,{[s.isCollapsed]:e}),onClick:o,title:n,children:(0,ss.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,ss.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Bt=xg;var Ga=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,rs=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var qa=/x-deepdesk-(([a-z0-9\-_])+-version)/,is=["cues","custom-data","custom-data-banner","knowledge-assist"],Xa=Intl.DateTimeFormat().resolvedOptions().timeZone,et=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(et||{}),Ut=(i=>(i.ENTER="enter",i.TAB="tab",i.ARROW="arrow",i.HOTKEY="hotkey",i.MOUSE="mouse",i.SPACE="space",i))(Ut||{});var vt=require("react-dom/client");var Xd=require("react");var Ja=require("@reduxjs/toolkit"),Qa=require("react-redux");var Yn=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(Yn||{});var Sg={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,addToPersonalCollection:!1,inlineSuggestions:!1,suggestionsPlacement:"above",floatingMenu:!1,detectSubmit:!1,automaticHandlingTime:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!0,adminUrl:void 0,productName:"Deepdesk",hasKeyboardInput:!0},Za=(0,Ja.createSlice)({name:"settings",initialState:Sg,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,s]=n;typeof s!="undefined"&&(t[o]=s)})}}}),{set:as}=Za.actions,vn=t=>e=>e.settings[t],E=t=>(0,Qa.useSelector)(vn(t)),Ya=Za.reducer;var mi=require("react-redux");var xn=require("@reduxjs/toolkit");var bg={isLoggedIn:null,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1,loginError:null},ne=t=>t.auth.isLoggedIn;var el=t=>t.auth.verifyFetchState,tl=t=>t.auth.showLoginOverlay,nl=t=>t.auth.loginError,tt=(0,xn.createAsyncThunk)("auth/validate",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.isLoggedIn()})),ol=(0,xn.createAsyncThunk)("auth/requestLogin",(n,o)=>v(null,[n,o],function*({email:t},e){let{deepdeskAPI:s}=e.extra;return s.requestLoginByEmail(t)})),eo=(0,xn.createAsyncThunk)("auth/verifyLoginToken",(n,o)=>v(null,[n,o],function*({token:t},e){let{deepdeskAPI:s}=e.extra;return s.verifyLoginToken(t)})),sl=(0,xn.createSlice)({name:"auth",initialState:bg,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload},setLoginError(t,e){t.loginError=e.payload},clearLoginError(t){t.loginError=null}},extraReducers:t=>{t.addCase(tt.pending,e=>{e.loginFetchState="loading"}),t.addCase(tt.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(tt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(eo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(eo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(eo.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Sn,setShowLoginOverlay:rl,setLoginError:Gr,clearLoginError:ls}=sl.actions,il=sl.reducer;var zt=require("@reduxjs/toolkit"),gl=require("diff");function al(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Ct(t,e,n=10){let o=typeof t,s=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==s?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>Ct(r,e[i],n-1)):al(t)&&al(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Ct(t[i],e[i],n-1)):!1}function Cg(t){return Math.max(...t.map(e=>e.length))}function Tg(t,e){let n=t.reduce((o,s)=>{if(s){let r=o[s]?o[s]+1:1;return S(y({},o),{[s]:r})}return o},{});return Object.keys(n).reduce((o,s)=>(n[s]<e&&o.push(s),o),[])}function ll(t,e){let o=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Cg(o);s++){let r=Tg(o.map(a=>a[s]),e),i=o.filter(a=>!r.includes(a[s]));if(i.length>=e)o=i;else return{text:o[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var wg=2;function dl(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=ll(t,wg);return n&&n.text!==e?n:t[0]}var Me=require("@reduxjs/toolkit");var Eg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=Eg;var cl={current:null,isSupported:null},J=(0,Me.createAction)("resetConversation"),pl=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.externalId)||null},ze=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},bn=t=>t.conversation.isSupported,qr=(0,Me.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),ds=(0,Me.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),cs=(0,Me.createAsyncThunk)("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),ps=(0,Me.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=ze(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),Xr=(0,Me.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:s,agentName:r,agentEmail:i,agentNickname:a,metadata:d}=t;return n.updateConversation(o.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,metadata:d})})}),Jr=(0,Me.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=ze(e.getState());if(!o)throw new Error("No current conversation to update messages");return n.postMessages(o,t.map(s=>y({},s)))}),kg=[ds.rejected,cs.rejected,ps.rejected,Jr.rejected].map(t=>t==null?void 0:t.toString());function Rg(t){return kg.includes(t.type)}var Pg=(0,Me.createSlice)({name:"conversation",initialState:cl,reducers:{},extraReducers:t=>{t.addCase(qr.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(ds.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(cs.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Xr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(ps.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(J,()=>cl).addMatcher(Rg,(e,n)=>{var o;throw k.info("Conversation action rejected",n.type,((o=n.error)==null?void 0:o.message)||"No message"),new Error(n.error.message)})}}),ul=Pg.reducer;var Kt={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],pinnedSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Qr(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}}var us=(0,zt.createAction)("input/applyImageSuggestion"),ml=(0,zt.createSlice)({name:"input",initialState:Kt,reducers:{setInput(t,e){var r,i;let{beforeInputChange:n}=t,{text:o,html:s}=e.payload;if(t.text=o,t.html=s!=null?s:null,o==="")t.metrics=Kt.metrics,t.textSuggestions=[],t.mixedSuggestion=null;else if(n!==null&&t.text!==n.text){let{key:a,shiftKey:d,ctrlKey:l,metaKey:c,altKey:u}=n.keyDown;switch(a){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:p}=t,f=(0,gl.diffChars)(n.text,p);n.text.length-p.length>1&&t.metrics.deletions.push(...f.filter(m=>m.removed).map(m=>m.value)),t.metrics.numCharsDeleted+=n.text.length-p.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(l||c)break;default:if(!l&&!c&&!u){t.metrics.numCharsTyped+=1;let p=((r=n.selection)==null?void 0:r.start)!==void 0&&((i=n.selection)==null?void 0:i.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;p&&p.length>0&&(t.metrics.numCharsDeleted+=p.length,t.metrics.deletions.push(p))}}t.metrics.agentStartedTypingTimestamp||(t.metrics.agentStartedTypingTimestamp=Date.now())}t.beforeInputChange=null},sendMessage(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(n=>!t.metrics.textSuggestions.some(o=>o.text===n.text&&o.source===n.source))},setSelection(t,e){e.payload!==null&&(Ct(t.selection,e.payload)||(t.selection=e.payload))},commitSuggestion(t,e){let n=e.payload,{text:o,suggestion:{source:s,abVariant:r,abTestName:i,trainingJobs:a,sourceText:d,searchTerm:l,assistantCode:c,text:u},eventMetrics:{inputType:p},replace:f}=n,m=s==="search"||s==="personal-collection-search",g=o.slice(t.text.substring(0,t.selection.start).length);(m||f==="selection")&&(g=o),n.suggestion.source==="search-overlay"&&(g=u),t.metrics.textSuggestions.push({text:g,source:s,assistantCode:c,abVariant:r,abTestName:i,inputType:p,sourceText:d,trainingJobs:a||[],searchTerm:m?t.text:l}),t.textSuggestions=[],t.selectedSuggestionIndex=-1},offeredTextSuggestion(t,e){let{text:n,suggestion:{source:o}}=e.payload;t.metrics.offeredTextSuggestions.find(r=>r.text===n)||t.metrics.offeredTextSuggestions.push({text:n,source:o})},registerKeyDown(t,e){let{key:n}=e.payload;["Control","Meta","Shift","Alt"].includes(n)||(t.beforeInputChange={text:t.text,selection:t.selection,keyDown:e.payload})},registerKeyUp(t,e){},registerCut(t,e){let{metrics:n}=t,o=e.payload;t.metrics=S(y({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:s}=e.payload,r=n.numCharsDeleted+(s!=null&&s.length?s.length:0),i=s!=null&&s.length?[...n.deletions,s]:n.deletions;t.metrics=S(y({},t.metrics),{numCharsDeleted:r,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},selectPreviousTextSuggestion(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},selectTextSuggestionByIndex(t,e){t.selectedSuggestionIndex=e.payload},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0){t.mixedSuggestion=null;return}let n=t.text.substring(0,t.selection.end),o=dl(e.payload,n);t.mixedSuggestion=o!=null&&o.text.includes(n)?o:null},setPinnedSuggestions(t,e){t.pinnedSuggestions=e.payload},removePinnedSuggestions(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(o=>o.source!==e.payload.source||e.payload.assistantCode&&o.assistantCode!==e.payload.assistantCode?!0:e.payload.text?o.text!==e.payload.text:!1);let n=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex>n-1&&(t.selectedSuggestionIndex=-1)},setMetrics(t,{payload:e}){t.metrics=e},resetMetrics(t){t.metrics=Kt.metrics}},extraReducers:t=>{t.addCase(J,e=>{e.mixedSuggestion=Kt.mixedSuggestion,e.textSuggestions=Kt.textSuggestions,e.selectedSuggestionIndex=Kt.selectedSuggestionIndex,e.metrics=Kt.metrics})}}),Cn=t=>t.input.text.substring(0,t.input.selection.end),Ig=t=>t.input.mixedSuggestion,Lg=t=>t.input.pinnedSuggestions,Ag=t=>t.input.textSuggestions,to=t=>t.input.selectedSuggestionIndex,Wt=(0,zt.createSelector)([Ag,Lg],(t,e)=>[...t,...e]),Tn=(0,zt.createSelector)([Wt,Ig,to],(t,e,n)=>n>-1?t[n]:e),fl=t=>t.input.selection,{commitSuggestion:ye,offeredTextSuggestion:hl,registerCut:yl,registerKeyDown:vl,registerKeyUp:xl,registerPaste:Sl,selectNextTextSuggestion:bl,selectPreviousTextSuggestion:Cl,selectTextSuggestionByIndex:gs,setInput:ms,setMetrics:Tl,setPinnedSuggestions:wn,removePinnedSuggestions:Vt,setSelection:fs,setTextSuggestions:Tt,resetMetrics:wl,sendMessage:jt}=ml.actions,El=ml.reducer;var kn=require("@reduxjs/toolkit");var $t=require("@reduxjs/toolkit");function kl(t){try{return Intl.DateTimeFormat(void 0,{timeZone:t}),!0}catch(e){return!1}}var Mg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle",showNicknameDialog:!1},En=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},oo=({info:{visitorInfo:t,agentInfo:e}})=>{var n,o;return{timezone:t!=null&&t.visitorTimeZone&&kl(t.visitorTimeZone)?t.visitorTimeZone:Xa,agentName:(n=e==null?void 0:e.agentNickname)!=null?n:"",visitorName:(o=t==null?void 0:t.visitorName)!=null?o:""}},Ng=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],Il=(0,$t.createAsyncThunk)("info/setAgentNickname",(n,o)=>v(null,[n,o],function*({agentNickname:t},e){var i;let{deepdeskAPI:s}=e.extra,r=yield s.patchMe({nickname:t});return{agentNickname:(i=r==null?void 0:r.nickname)!=null?i:t}})),no=(0,$t.createAsyncThunk)("info/setAgentInfo",(t,e)=>v(null,null,function*(){var r,i,a;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=[];if(t.agentId&&t.skipSync!==!0&&s.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let d=Ng.reduce((l,[c,u])=>!o[u]&&c in t?S(y({},l),{[u]:t[c]}):l,{});Object.keys(d).length>0&&s.push(n.patchMe(d).then(l=>o=l))}return s.length>0&&(yield Promise.all(s)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(r=o.nickname)!=null?r:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(a=o.defaultLocale)!=null?a:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),Zr=(0,$t.createAsyncThunk)("info/setAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=y(y({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:s}),s})),Yr=(0,$t.createAsyncThunk)("info/getAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),Ll=(0,$t.createSlice)({name:"info",initialState:Mg,reducers:{setVisitorInfo(t,e){t.visitorInfo=y(y({},t.visitorInfo),e.payload)},setCustomData(t,e){t.customData=e.payload},setPlatformVariables(t,e){t.platformVariables=e.payload},setShowNicknameDialog(t,e){t.showNicknameDialog=e.payload}},extraReducers:t=>{t.addCase(no.pending,(e,n)=>{e.fetchState="loading",e.agentInfo=y(y({},e.agentInfo),n.meta.arg)}).addCase(no.rejected,e=>{e.fetchState="error"}).addCase(no.fulfilled,(e,n)=>{e.fetchState="done",e.agentInfo=n.payload}).addCase(Zr.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(Yr.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(J,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Al,setCustomData:Ml,setPlatformVariables:Nl,setShowNicknameDialog:Ol}=Ll.actions,Dl=Ll.reducer;function Ne(t,e){return e?Object.entries(e).reduce((n,[o,s])=>n.replaceAll(o,s),t):t}var hs={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},_l=t=>t.search.isOpen,Fl=t=>t.search.page,ei=t=>t.search.list,Hl=t=>t.search.aggregates,Og=(0,kn.createSelector)([ei,(t,e)=>e],(t,e)=>t.filter(n=>n.type===e)),Bl=t=>e=>Og(e,t),Gt=(0,kn.createAsyncThunk)("search/getAll",(t,e)=>v(null,null,function*(){var d;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(d=o.conversation.current)==null?void 0:d.profileCode,{platformVariables:r}=o.info;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:oo(o)});return{results:i.map(l=>S(y(y({},l),l.title&&r?{title:Ne(l.title,r)}:{}),{text:Ne(l.text,r!=null?r:{}),source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:a}})),Ul=(0,kn.createSlice)({name:"search",initialState:hs,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=hs.fetchState,t.list=hs.list}},extraReducers:t=>{t.addCase(Gt.pending,e=>{e.fetchState="loading"}).addCase(Gt.rejected,(e,n)=>{e.fetchState="error",k.error(n.error)}).addCase(Gt.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload.results,e.aggregates=n.payload.aggregates||{}}).addCase(J,()=>hs)}}),{resetSearch:ys,setIsOpen:Oe,setPage:Rn}=Ul.actions,Kl=Ul.reducer;var ti="SetOutputs",Pn="ShowLoginOverlay",so="UserLoggedIn",Dg="UserLoggedOut",nt="ApplySuggestion",ni="ApplyImageSuggestion",_g="ShowCommandPalette",vs="ShowNicknameDialog",xs="ReduxAction",Fg="RemovePinnedSuggestion",Hg=t=>({[ti]:e=>{t.dispatch(S(y({},e),{isBroadcasted:!0}))},[xs]:e=>{e.isBroadcasted||t.dispatch(S(y({},e),{isBroadcasted:!0}))},[Fg]:e=>{t.dispatch(Vt(e))},[_g]:e=>{t.dispatch(Oe(e.isOpen)),e.page&&t.dispatch(Rn(e.page))},[vs]:e=>{t.dispatch(Ol(e.showNicknameDialog))},[Pn]:e=>{t.dispatch(rl(e))},[so]:()=>{t.dispatch(tt())},[Dg]:()=>{t.dispatch(tt())},[ni]:e=>{t.dispatch(us({suggestion:e.suggestion}))},[nt]:e=>{t.dispatch(ye(S(y({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),zl=Hg;var ro=O(require("react")),Vl=require("react/jsx-runtime"),Wl=ro.default.createContext(null),ot=({broadcastEvents:t,children:e})=>{let n=ro.default.useMemo(()=>t,[]);return(0,Vl.jsx)(Wl.Provider,{value:n,children:e})},me=()=>{let t=(0,ro.useContext)(Wl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var Is=O(require("classnames")),De=require("react"),Ls=require("react-redux");var Rs=require("react");var oi=function(t,e){return oi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},oi(t,e)};function io(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");oi(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var ve=function(){return ve=Object.assign||function(e){for(var n,o=1,s=arguments.length;o<s;o++){n=arguments[o];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ve.apply(this,arguments)};function jl(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(n[o[s]]=t[o[s]]);return n}function Ss(t,e,n){if(n||arguments.length===2)for(var o=0,s=e.length,r;o<s;o++)(r||!(o in e))&&(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}function bs(t,e){var n=e&&e.cache?e.cache:jg,o=e&&e.serializer?e.serializer:Wg,s=e&&e.strategy?e.strategy:Ug;return s(t,{cache:n,serializer:o})}function Bg(t){return t==null||typeof t=="number"||typeof t=="boolean"}function $l(t,e,n,o){var s=Bg(o)?o:n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.call(this,o),e.set(s,r)),r}function Gl(t,e,n){var o=Array.prototype.slice.call(arguments,3),s=n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.apply(this,o),e.set(s,r)),r}function si(t,e,n,o,s){return n.bind(e,t,o,s)}function Ug(t,e){var n=t.length===1?$l:Gl;return si(t,this,n,e.cache.create(),e.serializer)}function Kg(t,e){return si(t,this,Gl,e.cache.create(),e.serializer)}function zg(t,e){return si(t,this,$l,e.cache.create(),e.serializer)}var Wg=function(){return JSON.stringify(arguments)},Vg=(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})(),jg={create:function(){return new Vg}},Cs={variadic:Kg,monadic:zg};var Ts;(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"})(Ts||(Ts={}));var ws=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Ee;(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"})(Ee||(Ee={}));var Es;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Es||(Es={}));function ri(t){return t.type===Ee.literal}function ii(t){return t.type===Ee.argument}function ao(t){return t.type===Ee.number}function lo(t){return t.type===Ee.date}function co(t){return t.type===Ee.time}function po(t){return t.type===Ee.select}function uo(t){return t.type===Ee.plural}function ql(t){return t.type===Ee.pound}function go(t){return t.type===Ee.tag}function ks(t){return!!(t&&typeof t=="object"&&t.type===Es.number)}function mo(t){return!!(t&&typeof t=="object"&&t.type===Es.dateTime)}function ai(t){t.forEach(function(e){if(delete e.location,po(e)||uo(e))for(var n in e.options)delete e.options[n].location,ai(e.options[n].value);else ao(e)&&ks(e.style)||(lo(e)||co(e))&&mo(e.style)?delete e.style.location:go(e)&&ai(e.children)})}function Xl(t,e){e===void 0&&(e={}),e=ve({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new ws(t,e).parse();if(n.err){var o=SyntaxError(Ts[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||ai(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 fo=(function(t){io(e,t);function e(n,o,s){var r=t.call(this,n)||this;return r.code=o,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e})(Error);var li=(function(t){io(e,t);function e(n,o,s,r){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(s).join('", "'),'"'),qt.INVALID_VALUE,r)||this}return e})(fo);var Jl=(function(t){io(e,t);function e(n,o,s){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),qt.INVALID_VALUE,s)||this}return e})(fo);var Ql=(function(t){io(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})(fo);var se;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(se||(se={}));function $g(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 Gg(t){return typeof t=="function"}function ho(t,e,n,o,s,r,i){if(t.length===1&&ri(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(ri(c)){a.push({type:se.literal,value:c.value});continue}if(ql(c)){typeof r=="number"&&a.push({type:se.literal,value:n.getNumberFormat(e).format(r)});continue}var u=c.value;if(!(s&&u in s))throw new Ql(u,i);var p=s[u];if(ii(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(lo(c)){var f=typeof c.style=="string"?o.date[c.style]:mo(c.style)?c.style.parsedOptions:void 0;a.push({type:se.literal,value:n.getDateTimeFormat(e,f).format(p)});continue}if(co(c)){var f=typeof c.style=="string"?o.time[c.style]:mo(c.style)?c.style.parsedOptions:o.time.medium;a.push({type:se.literal,value:n.getDateTimeFormat(e,f).format(p)});continue}if(ao(c)){var f=typeof c.style=="string"?o.number[c.style]:ks(c.style)?c.style.parsedOptions:void 0;f&&f.scale&&(p=p*(f.scale||1)),a.push({type:se.literal,value:n.getNumberFormat(e,f).format(p)});continue}if(go(c)){var m=c.children,g=c.value,h=s[g];if(!Gg(h))throw new Jl(g,"function",i);var b=ho(m,e,n,o,s,r),T=h(b.map(function(L){return L.value}));Array.isArray(T)||(T=[T]),a.push.apply(a,T.map(function(L){return{type:typeof L=="string"?se.literal:se.object,value:L}}))}if(po(c)){var C=c.options[p]||c.options.other;if(!C)throw new li(c.value,p,Object.keys(c.options),i);a.push.apply(a,ho(C.value,e,n,o,s));continue}if(uo(c)){var C=c.options["=".concat(p)];if(!C){if(!Intl.PluralRules)throw new fo(`Intl.PluralRules is not available in this environment.
|
|
2
2
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
3
|
-
`,Xt.MISSING_INTL_API,i);var w=n.getPluralRules(e,{type:c.pluralType}).select(p-(c.offset||0));C=c.options[w]||c.options.other}if(!C)throw new di(c.value,p,Object.keys(c.options),i);a.push.apply(a,yo(C.value,e,n,o,s,p-(c.offset||0)));continue}}return Gg(a)}function Xg(t,e){return e?ve(ve(ve({},t||{}),e||{}),Object.keys(t).reduce(function(n,o){return n[o]=ve(ve({},t[o]),e[o]||{}),n},{})):t}function Jg(t,e){return e?Object.keys(t).reduce(function(n,o){return n[o]=Xg(t[o],e[o]),n},ve({},t)):t}function ci(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,n){t[e]=n}}}}}function Qg(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Cs(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,bs([void 0],n,!1)))},{cache:ci(t.number),strategy:Ts.variadic}),getDateTimeFormat:Cs(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,bs([void 0],n,!1)))},{cache:ci(t.dateTime),strategy:Ts.variadic}),getPluralRules:Cs(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,bs([void 0],n,!1)))},{cache:ci(t.pluralRules),strategy:Ts.variadic})}}var pi=(function(){function t(e,n,o,s){n===void 0&&(n=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(l){var c=r.formatToParts(l);if(c.length===1)return c[0].value;var u=c.reduce(function(p,f){return!p.length||f.type!==se.literal||typeof p[p.length-1]!="string"?p.push(f.value):p[p.length-1]+=f.value,p},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(l){return yo(r.ast,r.locales,r.formatters,r.formats,l,void 0,r.message)},this.resolvedOptions=function(){var l;return{locale:((l=r.resolvedLocale)===null||l===void 0?void 0:l.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=n,this.resolvedLocale=t.resolveLocale(n),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,d=$l(i,["formatters"]);this.ast=t.__parse(e,ve(ve({},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=Jg(t.formats,o),this.formatters=s&&s.formatters||Qg(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 Zg(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var Yg="dummy",ui=(0,Ps.createContext)(null);function R(t){var o;let e=(0,Ps.useContext)(ui);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=(o=t[e])!=null?o:{};return(s,r)=>{let i=Zg(n,s);return i?new pi(i).format(r):(e!==Yg&&console.warn(`${s} does not exist in messages of ${e}`),`[${s}]`)}}var Is=require("react");var Yl={root:"dd-tvkOF",content:"dd-eXA1D"};var gi=require("react/jsx-runtime"),em=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:s,onKeyDown:r,overlayAriaLabel:i,contentAriaLabel:a})=>{let d=(0,Is.useRef)(null),l=x("Dialog",Yl),c=p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),s();return}r&&r(p)},u=p=>{p.target===d.current&&t&&o()};return(0,Is.useEffect)(()=>{var p,f;!d.current||!t||!e||(f=(p=d.current)==null?void 0:p.querySelector("input, textarea"))==null||f.focus()},[t,e,d]),t?(0,gi.jsx)("div",{role:"dialog","data-testid":"dialog",className:l.root,"aria-label":i,ref:d,onKeyDown:c,onMouseDown:u,children:(0,gi.jsx)("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:n})}):null},In=em;var td=O(require("classnames"));var ed={root:"dd-ranhW"};var nd=require("react/jsx-runtime"),tm=o=>{var s=o,{className:t,value:e}=s,n=M(s,["className","value"]);let r=x("TextInput",ed);return(0,nd.jsx)("input",y({className:(0,td.default)(t,r.root),type:"text",value:e},n))},vo=tm;var mi={};Y(mi,{enUS:()=>nm,nlNL:()=>om});var nm={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"}]},om={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 od={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 G=require("react/jsx-runtime");var sm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch(e){return t}},rm=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:s})=>{let r=R(mi),i=x("LoginTokenDialog",od),a=(0,As.useSelector)(tl),d=(0,As.useDispatch)(),l=E("productName"),[c,u]=(0,De.useState)(t||""),[p,f]=(0,De.useState)(0),[m,g]=(0,De.useState)(""),h=(0,De.useCallback)(w=>v(null,null,function*(){w.preventDefault(),d(sl({email:c})),f(1)}),[n,c]),b=()=>{g(""),f(0)},T=(0,De.useCallback)(w=>v(null,null,function*(){w.preventDefault();let L=sm(w.target.elements.token.value);if(!L){g(r("verifyCodeError",{login:C}));return}d(to({token:L}))}),[n]),C=(0,De.useMemo)(()=>w=>(0,G.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:b,children:w},"back-button"),[]);return(0,De.useEffect)(()=>{a==="error"&&g(r("verifyCodeError",{login:C})),a==="done"&&o()},[a]),(0,G.jsx)(In,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:l}),overlayAriaLabel:r("promptTitle",{productName:l}),onClose:s,onBack:s,children:(0,G.jsxs)("div",{className:i.root,children:[(0,G.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:l})}),p===0&&(0,G.jsxs)("form",{onSubmit:h,children:[(0,G.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,G.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:l})}),(0,G.jsx)(vo,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:c,onChange:w=>u(w.target.value)}),(0,G.jsx)("div",{className:i.actions,children:(0,G.jsx)("button",{type:"submit",className:(0,Ls.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),p===1&&(0,G.jsxs)("form",{onSubmit:T,children:[(0,G.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,G.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,G.jsx)(vo,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&(0,G.jsx)("div",{className:i.errorMessage,children:m}),(0,G.jsxs)("div",{className:i.actions,children:[(0,G.jsx)("button",{type:"button",className:(0,Ls.default)(i.button),onClick:b,children:r("back")}),(0,G.jsx)("button",{type:"submit",className:(0,Ls.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},sd=rm;var id=require("react/jsx-runtime"),im=()=>{let t=(0,fi.useSelector)(nl),e=(0,fi.useSelector)(En),n=E("adminUrl"),o=me(),s=()=>o.send(Pn,!1),r=()=>{o.send(Pn,!1),o.send(ro)};return(0,id.jsx)(sd,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:s,onSuccess:r})},rd=im;var qd=O(require("lodash.debounce")),fe=require("react"),je=require("react-redux");var Ms=require("@reduxjs/toolkit");var am={data:null,fetchState:"idle"},ad=t=>t.contentTypes.data,xo=(0,Ms.createAsyncThunk)("contentTypes/getContentTypes",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),lm=(0,Ms.createSlice)({name:"contentTypes",initialState:am,reducers:{},extraReducers:t=>{t.addCase(xo.pending,e=>{e.fetchState="loading"}).addCase(xo.rejected,e=>{e.fetchState="error"}).addCase(xo.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),ld=lm.reducer;var Ln=require("@reduxjs/toolkit");var dm={data:null,fetchState:"idle"},cm=[],Jt=t=>t.profile.data,pm=t=>t.profile.data?t.profile.data.uiConfig.widget.types:cm,bo=(0,Ln.createSelector)([pm],t=>t.filter(e=>e.isActive)),dd=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},cd=t=>e=>bo(e).find(n=>n.type===t),pd=t=>t.profile.data?!!t.profile.data.uiConfig.widget.types.find(e=>e.type==="custom-data"):!1,ud=t=>{var e,n;return(n=(e=t.profile.data)==null?void 0:e.knowledgeAssistantNew)!=null?n:null},So=(0,Ln.createAsyncThunk)("profile/getProfile",(t,e)=>v(null,null,function*(){var r;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=o.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=o.profile.data)==null?void 0:r.code)===s.profileCode?o.profile.data:n.getProfile(s.profileCode)})),um=(0,Ln.createSlice)({name:"profile",initialState:dm,reducers:{},extraReducers:t=>{t.addCase(So.pending,e=>{e.fetchState="loading"}).addCase(So.rejected,e=>{e.fetchState="error"}).addCase(So.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),gd=um.reducer;function We(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 rt=require("react");var md=require("react"),Ns=O(require("classnames"));var xe={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 st={};Y(st,{enUS:()=>gm,nlNL:()=>mm});var gm={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}],sources:[{type:0,value:"Sources"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},mm={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 wt=require("react/jsx-runtime"),fm=({src:t,title:e})=>{let n=x("CommandPalette",xe),[o,s]=(0,md.useState)("loading"),r=R(st);return(0,wt.jsxs)("div",{className:n.image,children:[(0,wt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,Ns.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&(0,wt.jsx)("span",{className:(0,Ns.default)(n.imageSrc,n.imageSrcStatus),children:r("loading")}),o==="error"&&(0,wt.jsx)("span",{className:(0,Ns.default)(n.imageSrc,n.imageSrcStatus),children:(0,wt.jsx)(es,{})}),e&&(0,wt.jsx)("span",{className:n.imageTitle,children:e})]})},fd=fm;var hd=O(require("react")),yd=O(require("classnames"));var Qt=require("react/jsx-runtime");function hi({children:t,heading:e,orientation:n,hasMore:o,onShowAll:s}){let r=R(st),i=x("CommandPalette",xe);return hd.default.Children.count(t)===0?null:(0,Qt.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||o)&&(0,Qt.jsxs)("div",{className:i.listHeader,children:[e&&(0,Qt.jsx)("h4",{className:i.listHeading,children:e}),o&&s&&(0,Qt.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,Qt.jsx)("div",{className:(0,yd.default)(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}var To=O(require("classnames")),Si=require("interweave"),Et=require("react");var hm=/[.*+?^${}()|[\]\\]/g,ym=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function vm(t){return t.replace(hm,"\\$&")}function xm(t,e){let n=t.split("").findIndex((o,s)=>o!==e[s]);return n>-1?n:Math.min(t.length,e.length)}function Sm(t){return t.search(ym)}function vd(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let s=new RegExp(`\\b(${vm(o)})\\b`,"gi");n=n.replace(s,"<strong>$1</strong>")}),n}function xd(t){return t.replace(is,'<mark data-type="placeholder">$1</mark>')}function An(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function bm(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 yi(t,e,n={}){if(e){let o=xm(e.toLowerCase(),t.toLowerCase()),s=An(t.substring(o,t.length));if(n.stripAgentPart){let d=t.substring(0,o),l=Sm(d);return`<span style="opacity: 0.5">${d.substring(l+1)}</span>${s}`}let i=e.split(qa).length>3||e.length>30?bm(e.trim(),o):0;return`${`${i>0?"\u2026":""}${An(t.substring(i,o))}`}<strong>${s}</strong>`}return t}var Cm=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function Co(t){return Cm.test(t)}function vi(t){var n;let e=document.createElement("template");return e.innerHTML=t,(n=e.content.textContent)!=null?n:""}var Os=O(require("react")),Cd=require("react/jsx-runtime"),Sd=Os.default.createContext(void 0);function Mn(){let t=Os.default.useContext(Sd);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var bd=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r})=>{let i=Os.default.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r}),[n,e,s]);return(0,Cd.jsx)(Sd.Provider,{value:i,children:t})};var Ve=O(require("react")),U=require("@floating-ui/react");var Ds={tooltip:"dd-XpCXd",tooltipTrigger:"dd-8TKeF",arrow:"dd-ZEu2Y"};var ke=require("react/jsx-runtime");function Tm({initialOpen:t=!1,placement:e="bottom",modal:n,tooltip:o,open:s,onOpenChange:r}={}){let[i,a]=Ve.useState(t),d=s!=null?s:i,l=r!=null?r:a,c=(0,U.useFloating)({placement:e,open:d,onOpenChange:l,whileElementsMounted:U.autoUpdate,middleware:[(0,U.offset)(5),(0,U.flip)({crossAxis:e.includes("-"),fallbackAxisSideDirection:"end",padding:5}),(0,U.shift)({padding:10})]}),u=c.context,p=(0,U.useClick)(u,{enabled:s==null}),f=(0,U.useDismiss)(u),m=(0,U.useRole)(u),g=(0,U.useHover)(u,{enabled:o!=null?o:!1,handleClose:(0,U.safePolygon)()}),h=(0,U.useInteractions)([p,f,m,g]);return Ve.useMemo(()=>S(y(y({open:d,setOpen:l},h),c),{modal:n}),[d,l,h,c,n])}var Td=Ve.createContext(null),xi=()=>{let t=Ve.useContext(Td);if(t==null)throw new Error("Popover components must be wrapped in <Popover />");return t},Zt=o=>{var s=o,{children:t,modal:e=!1}=s,n=M(s,["children","modal"]);let r=Tm(y({modal:e},n));return(0,ke.jsx)(Td.Provider,{value:r,children:t})};function wm(o){var s=o,{as:t,children:e}=s,n=M(s,["as","children"]);let r=xi(),i=t||"button",a=e.ref,d=(0,U.useMergeRefs)([r.refs.setReference,a]);return(0,ke.jsx)(i,S(y({ref:d,type:"button"},r.getReferenceProps(n)),{children:e}))}var Em=Ve.forwardRef(function(s,o){var r=s,{style:e}=r,n=M(r,["style"]);let l=xi(),{context:i}=l,a=M(l,["context"]),d=(0,U.useMergeRefs)([a.refs.setFloating,o]);return i.open?(0,ke.jsx)(U.FloatingPortal,{children:(0,ke.jsx)(U.FloatingFocusManager,{context:i,modal:a.modal,disabled:n.disableFocusManager,children:(0,ke.jsx)("div",S(y({ref:d,style:y(S(y({},a.floatingStyles),{zIndex:1e7}),e)},a.getFloatingProps(n)),{children:n.children}))})}):null});function km(s){var r=s,{as:t,children:e,onClick:n}=r,o=M(r,["as","children","onClick"]);let{setOpen:i}=xi();return(0,ke.jsx)(t||"button",S(y({type:"button",onClick:l=>{n(l),i(!1),l.stopPropagation()}},o),{children:e}))}function wd({trigger:t,children:e,placement:n="top"}){return(0,ke.jsxs)(Zt,{tooltip:!0,placement:n,children:[(0,ke.jsxs)(Zt.Content,{className:Ds.tooltip,children:[e,(0,ke.jsx)("div",{className:Ds.arrow})]}),(0,ke.jsx)(Zt.Trigger,{className:Ds.tooltipTrigger,children:t})]})}Zt.Trigger=wm;Zt.Content=Em;Zt.Button=km;var ee=Zt;var ae=require("react/jsx-runtime"),Rm=3,Pm=90,Ed=({children:t})=>{let e=x("CommandPalette",xe);return(0,ae.jsx)("div",{className:e.listItemActions,children:t})};function bi(f){var m=f,{closeOnSelect:t=!0,lineClamp:e,tooltip:n,children:o,onClick:s,extra:r,onSourceClick:i,description:a,sources:d,id:l,styles:c,defaultSourcesAmount:u=Rm}=m,p=M(m,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var Ce;let g=R(st),[h,b]=(0,Et.useState)(!1),{selected:T,onChangeOpen:C}=Mn(),[w,L]=(0,Et.useState)(!1),N=x("CommandPalette",xe);function B(_){s(_),t&&C(!1)}let X=(0,Et.useMemo)(()=>typeof a!="string"?a:Co(a)?vi(a).trim():a,[a]),Le=(0,Et.useMemo)(()=>typeof n!="string"?n:Co(n)?vi(n).trim():n,[n]);return(0,Et.useEffect)(()=>{L(T===l)},[T]),(0,ae.jsxs)("div",{className:(0,To.default)(N.listItem,l===T&&N.listItemSelected),children:[(0,ae.jsxs)(ee,{placement:"right-start",tooltip:!0,onOpenChange:L,open:w,children:[(0,ae.jsx)(ee.Trigger,S(y({className:N.listItemAction,"aria-disabled":(Ce=p.disabled)!=null?Ce:!1,onClick:B,"data-command-palette-item":!0,"data-item-id":l},p),{children:(0,ae.jsxs)("div",{className:N.listItemContent,children:[typeof o=="string"?(0,ae.jsx)("p",{className:(0,To.default)(N.listItemText,N.truncate,c==null?void 0:c.title),children:o}):o,X&&typeof X=="string"?(0,ae.jsx)(Si.Interweave,{tagName:"p",allowList:[],content:X,className:(0,To.default)(N.listItemDescription,c==null?void 0:c.description,e?N.lineClamp:N.truncate)}):a]})})),Le&&Le.length>Pm&&(0,ae.jsx)(ee.Content,{className:N.listItemTooltip,disableFocusManager:!0,children:(0,ae.jsx)(Si.Interweave,{className:N.listItemTooltipContent,allowList:["h1","h2","h3","h4","h5","h6","a","p","br"],tagName:"div",content:Le.replace(/\n/g,"<br />")})})]}),l===T&&r,d&&d.length>0&&(0,ae.jsxs)("div",{className:N.sources,children:[(0,ae.jsx)("span",{className:N.sourcesTitle,children:g("sources")}),d.slice(0,h?d.length:u).map(_=>(0,ae.jsx)("a",{className:N.source,href:_.url,target:"_blank",title:_.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i==null?void 0:i(_),children:_.name},_.url)),!h&&d.length>u&&(0,ae.jsx)("button",{className:(0,To.default)(N.source,N.sourceShowMore),type:"button",onClick:()=>b(!0),children:g("showMore",{amount:d.length-u})})]})]})}var wo=require("react/jsx-runtime"),kd=()=>(0,wo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,wo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,wo.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 Yt=require("react/jsx-runtime");function Ci({children:t,title:e,id:n,onDismiss:o}){let s=R(st),r=x("CommandPalette",xe),{page:i}=Mn();return i!==n?null:(0,Yt.jsxs)("div",{className:r.page,id:`page_${n}`,tabIndex:-1,children:[o&&(0,Yt.jsxs)("div",{className:r.pageNav,children:[(0,Yt.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:o,children:[(0,Yt.jsx)(kd,{}),s("back")]}),e&&(0,Yt.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var Rd=require("react");var Eo=require("react/jsx-runtime"),Nn=()=>(0,Eo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Eo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Eo.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 _e=require("react/jsx-runtime");function Im({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:s,value:r,selectedType:i},a){let d=x("CommandPalette",xe);return(0,_e.jsxs)("div",{className:d.search,children:[(0,_e.jsx)("div",{className:d.searchIcon,children:(0,_e.jsx)(Nn,{})}),(0,_e.jsxs)("div",{className:d.searchInputWrapper,children:[(0,_e.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:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&(0,_e.jsx)("div",{className:d.selectWrapper,children:(0,_e.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,_e.jsx)("option",{children:o}),s.map(l=>(0,_e.jsx)("option",{value:l.value,children:l.label},l.value))]})})]})]})}var Pd=(0,Rd.forwardRef)(Im);var Ti=O(require("classnames"));var _s=require("react/jsx-runtime"),Lm=s=>{var r=s,{onClick:t,shortKeys:e,children:n}=r,o=M(r,["onClick","shortKeys","children"]);let i=x("CommandPalette",xe);return(0,_s.jsxs)("button",S(y({type:"button"},o),{onClick:t,className:(0,Ti.default)(i.actionButton,o.className,{[i.hasShortKeys]:e&&e.length>0}),children:[n,e==null?void 0:e.map(a=>(0,_s.jsx)("span",{className:(0,Ti.default)(i.actionShortcut,a===8629&&i.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},Id=Lm;var ko=require("react/jsx-runtime"),Am="[data-command-palette-item]";function en({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:d,types:l,children:c,isOpen:u,search:p,updateDeps:f=[]}){let[m,g]=(0,rt.useState)(),h=(0,rt.useRef)(null),b=()=>{s&&s(n),i(void 0),r(""),a(!1)},T=()=>{var _;if(o!==n&&s){s(n);return}if(d&&i){i(void 0),(_=h.current)==null||_.focus();return}if(p.length>0){r("");return}a(!1)},C=()=>{let _=w();_.length!==0&&g(_[0].dataset.itemId)},w=()=>Array.from(document.querySelectorAll(Am)||[]),L=_=>document.querySelector(`[data-item-id=${_}]`),N=_=>{let W=L(_);W&&g(W.dataset.itemId)},B=_=>{let W=L(_);W&&W.scrollIntoView({behavior:"smooth"})},X=()=>{if(!m)return;let _=w(),W=L(m);if(!W)return;let Ye=_.indexOf(W),Te=_[Ye+1];Te!=null&&Te.dataset.itemId?N(Te.dataset.itemId):C()},Le=()=>{if(!m)return;let _=w(),W=L(m);if(!W)return;let Ye=_.indexOf(W),Te=_[Ye-1];Te!=null&&Te.dataset.itemId?N(Te.dataset.itemId):N(_[_.length-1].dataset.itemId)},Ce=(0,rt.useCallback)(_=>{switch(_.key){case"ArrowDown":{_.preventDefault(),X();break}case"ArrowUp":{_.preventDefault(),Le();break}case"Enter":{if(m){let W=L(m);W==null||W.click()}break}}},[m]);return(0,rt.useEffect)(()=>{C()},[p,o,d,u,...f]),(0,rt.useEffect)(()=>{m&&B(m)},[m]),(0,ko.jsx)(In,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:T,onClose:b,onKeyDown:Ce,children:(0,ko.jsxs)(bd,{selected:m,setSelected:g,isOpen:u,onChangeOpen:a,page:o,children:[o===n&&(0,ko.jsx)(Pd,{ref:h,onChange:r,onChangeType:i,placeholder:t,value:p,selectedType:d,types:l,typePlaceholder:e}),c]})})}en.Page=Ci;en.List=hi;en.Image=fd;en.ListItem=bi;en.ListItemActions=Ed;en.Button=Id;var te=en;var Ld=require("react");function Ad(t,e){(0,Ld.useEffect)(()=>{let n=o=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var Ro=require("react"),Hs=require("react-redux");var On=require("@reduxjs/toolkit");var Md={data:null,fetchState:"idle"},Mm=t=>{var e;return(e=t.entities.data)!=null?e:null},Fs=(0,On.createSelector)([Mm,En,Pl],(t,e,n)=>{var a;let o=[],{visitorName:s}=n!=null?n:{},{agentName:r,agentNickname:i}=e!=null?e:{};return r&&r!==s&&o.push(r),i&&i!==s&&o.push(i),(a=t==null?void 0:t.filter(d=>!o.includes(d.text)))!=null?a:null}),Fe=(0,On.createAsyncThunk)("entities/getEntities",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let s=o.conversationQuery,r=yield s();return r.length===0?Promise.resolve([]):n.getEntities(r)})),Nm=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),Om=(0,On.createSlice)({name:"entities",initialState:Md,reducers:{},extraReducers:t=>{t.addCase(Fe.pending,e=>{e.fetchState="loading"}).addCase(Fe.rejected,e=>{e.fetchState="error"}).addCase(Fe.fulfilled,(e,n)=>{e.fetchState="done",e.data=Nm(e.data?[...e.data,...n.payload]:n.payload)}).addCase(J,()=>Md)}}),Nd=Om.reducer;var wi={};Y(wi,{enUS:()=>Dm,nlNL:()=>_m});var Dm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},_m={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Od={root:"dd-TYTKs",empty:"dd-AU7uT"};var Dn=require("react/jsx-runtime"),Fm=({onCopy:t})=>{let e=(0,Ro.useRef)(null),n=x("EntitiesList",Od),o=(0,Hs.useSelector)(Fs),{setSelected:s}=Mn(),r=R(wi),i=(0,Hs.useDispatch)();return(0,Ro.useEffect)(()=>{i(Fe())},[]),(0,Ro.useEffect)(()=>{e.current&&(e.current.focus(),s("entity-0"))},[e]),(0,Dn.jsxs)("div",{className:n.root,ref:e,tabIndex:-1,children:[o&&o.length>0&&(0,Dn.jsx)(te.List,{children:o.map((a,d)=>(0,Dn.jsx)(te.ListItem,{id:`entity-${d}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),o&&o.length===0&&(0,Dn.jsx)("p",{className:n.empty,children:r("noResults")})]})},Dd=Fm;var Ei=require("react/jsx-runtime"),Bs=t=>(0,Ei.jsx)("svg",S(y({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},t),{children:(0,Ei.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 Po={};Y(Po,{enUS:()=>Hm,nlNL:()=>Bm});var Hm={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"}]},Bm={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 kt=t=>e=>{let{passwordlessToken:{token:n},settings:{isEmbedded:o,adminUrl:s}}=e,r=s||window.location.origin;return o&&!n?null:o&&n?`${r}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${r}${t}`};var ki=require("react-redux");var Us={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var Fd=require("react-redux");var _d=require("@reduxjs/toolkit");function Ks(t){return(0,_d.createAsyncThunk)("analytics/logEvent",(e,n)=>{var r,i,a;let o=(i=(r=n.getState())==null?void 0:r.conversation.current)==null?void 0:i.id,s=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,S(y({conversationId:o},s),{data:e.data}))})(t)}function V(){let t=(0,Fd.useDispatch)();return(e,n)=>v(null,null,function*(){yield t(Ks({name:e,data:n}))})}var tn=require("react/jsx-runtime"),Um=({suggestion:t,source:e,context:n})=>{let o=R(Po),s=(0,ki.useSelector)(ze),r=V(),i=E("enableSuggestionFeedback"),a=`${t.text}`,d=(0,ki.useSelector)(kt(`/admin/feedback?conversationId=${s}&type=${e}&text=${a}&data=${JSON.stringify({context:n})}`)),l=()=>{r("suggestion feedback",{text:t.text,source:e,context:n})};return!i||!d?null:(0,tn.jsxs)(ee,{placement:"top-end",children:[(0,tn.jsx)(ee.Trigger,{className:Us.trigger,children:(0,tn.jsx)(Bs,{"data-testid":"feedback-dropdown-trigger"})}),(0,tn.jsx)(ee.Content,{className:Us.content,children:(0,tn.jsx)(ee.Button,{className:Us.item,as:"a",onClick:l,target:"_blank",href:d,children:o("giveFeedback")})})]})},zs=Um;var Io={};Y(Io,{enUS:()=>Km,nlNL:()=>zm});var Km={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?"}]},zm={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 $d=require("react"),js=require("react-redux");var nn=require("@reduxjs/toolkit");var Wm=["{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}"],Vm=new RegExp(Wm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Hd(t,e){let n=t.split(Vm),o=0,s=[];for(let r=0;r<n.length;r++){let i=n[r];if(s.push(i),r===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[r+1],d=r===n.length-2;o+=i.length;let l=o;if(d){let u=a.charAt(0),p=0;do l=u?e.indexOf(u,l+1):-1,p+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&p>2)return t}else l=a&&a!==""?e.indexOf(a,o):-1;let c=l===-1?e.slice(o):e.slice(o,l);s.push(c),o=l}return s.join("")}function Bd(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Kd={suggestions:[],fetchState:"idle"},Ud={default:Kd},zd=t=>e=>{var n,o;return(o=(n=e.textSuggestions[t])==null?void 0:n.suggestions)!=null?o:[]},Ws=t=>t.textSuggestions,Wd=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Vs=(0,nn.createAction)("textSuggestions/refresh"),He=(0,nn.createAsyncThunk)("textSuggestions/recommendations",(t,e)=>v(null,null,function*(){var c,u,p;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:s}=o.info,{textSuggestionsCount:r,inlineSuggestions:i}=o.settings,a=Cn(o),d=(c=o.conversation.current)==null?void 0:c.id;if(!d)throw new Error("No current conversation to fetch text suggestions");if(!((u=o.profile.data)!=null&&u.recommendationEngine))return[];let l=[];if(t==="sticky-messages"){let f=(p=o.profile.data)==null?void 0:p.code;if(!f)throw new Error("No current profile to fetch pinned messages");l=yield n.getPinnedMessages(f)}else l=yield n.getTextSuggestions(d,so(o),t);if(s&&(l=l.map(f=>y(S(y({},f),{text:Ne(f.text,s)}),f.title?{title:Ne(f.title,s)}:{}))),t==="default"){let f=i?l.filter(Wd(a)):l;e.dispatch(Tt(f.slice(0,r)))}return l})),Lo=(0,nn.createAsyncThunk)("textSuggestions/autocompletions",(t,e)=>v(null,null,function*(){var c,u;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(c=o.conversation.current)==null?void 0:c.id,{platformVariables:r}=o.info,{textSuggestionsCount:i,deanonymize:a,inlineSuggestions:d}=o.settings;if(!((u=o.profile.data)!=null&&u.recommendationEngine))return[];if(!s)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(s,S(y({},so(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return d&&(l=l.filter(Wd(t))),r&&(l=l.map(p=>S(y({},p),{text:Ne(p.text,r)}))),a&&(l=l.map(p=>S(y({},p),{text:p.source!=="trie-with-typos"?Hd(p.text,t):p.text}))),l=Bd(l,i),e.dispatch(Tt(l)),l})),Vd=(0,nn.createSlice)({name:"textSuggestions",initialState:Ud,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:n}=e.payload;t[n].fetchState="done",t[n].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}}},extraReducers:t=>{t.addCase(He.pending,(e,n)=>{let o=n.meta.arg,s=e[o]||Kd;return S(y({},e),{[o]:S(y({},s),{fetchState:"loading"})})}).addCase(He.rejected,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="error")}).addCase(He.fulfilled,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="done",e[o].suggestions=n.payload)}).addCase(Lo.pending,e=>{e.default.fetchState="loading"}).addCase(Lo.rejected,e=>{e.default.fetchState="error"}).addCase(Lo.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(J,()=>Ud)}}),{setTextSuggestions:cC}=Vd.actions,jd=Vd.reducer;var on=require("react/jsx-runtime"),jm=({types:t,commands:e,onClick:n})=>{let o=(0,js.useDispatch)(),s=R(Io),r=(0,js.useSelector)(Ws);return(0,$d.useEffect)(()=>{t.forEach(({type:i})=>{(!r[i]||r[i].suggestions.length===0)&&o(He(i))})},[]),(0,on.jsxs)("div",{children:[e.length>0&&(0,on.jsx)(te.List,{heading:s("commands"),children:e.map((i,a)=>(0,on.jsx)(te.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:i.onClick,children:i.label},i.label))}),t.map(({type:i,title:a})=>{var d;return(0,on.jsx)(te.List,{heading:a,orientation:"vertical",children:(d=r[i])==null?void 0:d.suggestions.map((l,c)=>(0,on.jsx)(te.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)})]})},Gd=jm;var le=require("react/jsx-runtime"),Gm=200,qm=5,Xm=4,Ri=(t,e,n)=>t.slice(0,n?10:e.toLowerCase()==="image"?Xm:qm),Jm=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Qm=()=>{var Ye,Te,Ta;let t=(0,je.useDispatch)(),e=me(),n=R(Io),[o,s]=(0,fe.useState)(!1),[r,i]=(0,fe.useState)(""),a=(0,je.useSelector)(Hl),d=(0,je.useSelector)(Jt),[l,c]=(0,fe.useState)(),u=(0,je.useSelector)(ne),p=E("showSearch"),f=E("enableSuggestionFeedback"),m=E("showEntitiesCommand"),g=E("showImageSearch"),h=E("searchTriggerKey"),b=(0,je.useSelector)(ad),T=(0,je.useSelector)(ti),C=(0,je.useSelector)(Bl),w=(0,je.useSelector)(Fl),L=((Ta=(Te=(Ye=d==null?void 0:d.uiConfig)==null?void 0:Ye.search)==null?void 0:Te.initialTypes)==null?void 0:Ta.filter(({isActive:A})=>A))||[],N=V(),B=(0,fe.useMemo)(()=>{let A=ue=>Ri(T.filter($=>$.type===ue.toUpperCase()),ue,l),Z=(b==null?void 0:b.map(ue=>({value:ue.code.toUpperCase(),label:`${ue.name}s`,list:A(ue.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(Z.push({value:"PERSONAL",label:n("personalSuggestions"),list:A("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:A("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:A("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),g&&Z.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:A("IMAGE"),listOrientation:"horizontal"}),L.length===0)return Z;let Qn=L.map(ue=>Z.find($=>$.value.toLowerCase()===ue.type)).filter(ue=>!!ue),zr=Z.filter(ue=>!Qn.find($=>$.value===ue.value));return[...Qn,...zr]},[b,L,g,l]),X=[{label:n("entitiesClipboard"),onClick:()=>t(Rn("entities")),shouldShow:m&&Jm(n("entitiesClipboard"),r)}].filter(A=>A.shouldShow).filter(()=>!l),Le=(0,fe.useCallback)((0,qd.default)((A,Z)=>{t(qt({query:A,type:Z,tags:["search-overlay"],size:l?50:20}))},Gm),[l]),Ce=(0,fe.useCallback)((A,Z)=>{Z.type==="IMAGE"?e.send(oi,{suggestion:Z}):e.send(nt,{text:A,suggestion:Z}),t(Oe(!1))},[t]),_=A=>{We(A.text),N("entity copied",{entity:A,type:"copy"}),t(Oe(!1))};function W(A){return Z=>{o?window.confirm(n("warning"))&&(A(Z),s(!1)):A(Z)}}return(0,fe.useEffect)(()=>{r?Le(r,l):t(vs())},[r,l]),(0,fe.useEffect)(()=>{u&&t(xo())},[u]),Ad(h,()=>{t(Oe(!0)),N("open search",{via:"ctrl+k"})}),!p||!d?null:(0,le.jsxs)(te,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:W(A=>t(Oe(A))),onChangeType:A=>c(A),onChangePage:W(A=>t(Rn(A))),selectedType:l,search:r,page:a,isOpen:w,types:B,updateDeps:[T],children:[(0,le.jsxs)(te.Page,{id:"search",children:[r.length===0&&(0,le.jsx)(Gd,{types:L,commands:X,onClick:Ce}),r.length>0&&(0,le.jsxs)(fe.Fragment,{children:[X.length>0&&(0,le.jsx)(te.List,{heading:n("commands"),children:X.map((A,Z)=>(0,le.jsx)(te.ListItem,{closeOnSelect:!1,onClick:A.onClick,id:`commands-${Z}`,children:A.label},A.label))}),B.map(({value:A,label:Z,list:Qn,lineClamp:zr,listOrientation:ue})=>(0,le.jsx)(te.List,{heading:Z,orientation:ue==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(A),hasMore:!l&&C[A.toLowerCase()]>Ri(Qn,A,l).length,children:Ri(Qn,A,l).map($=>(0,le.jsx)(te.ListItem,{id:`${A}-${$.id}`,closeOnSelect:!1,lineClamp:zr,onClick:()=>Ce($.text,$),description:A!=="IMAGE"?$.title&&$.text:void 0,tooltip:$.text,extra:f&&(0,le.jsx)(te.ListItemActions,{children:(0,le.jsx)(zs,{context:r,source:"search",suggestion:$})}),children:A==="IMAGE"?(0,le.jsx)(te.Image,{title:$.title||$.text,src:$.image}):$.title||$.text},`${$.id}-${$.text}`))},A))]})]}),(0,le.jsx)(te.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:W(()=>{t(Rn("search"))}),children:(0,le.jsx)(Dd,{onCopy:_})})]})},Xd=Qm;var Ao=require("react/jsx-runtime"),Zm=()=>{let t=E("showSearch"),e=E("isEmbedded");return(0,Ao.jsxs)(Jd.Fragment,{children:[t&&(0,Ao.jsx)(Xd,{}),e&&(0,Ao.jsx)(rd,{})]})},Qd=Zm;var tc=O(require("classnames")),nc=require("react-redux");var $s=require("react/jsx-runtime"),Zd=({className:t})=>(0,$s.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,$s.jsx)("g",{children:(0,$s.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 w=n.getPluralRules(e,{type:c.pluralType}).select(p-(c.offset||0));C=c.options[w]||c.options.other}if(!C)throw new li(c.value,p,Object.keys(c.options),i);a.push.apply(a,ho(C.value,e,n,o,s,p-(c.offset||0)));continue}}return $g(a)}function qg(t,e){return e?ve(ve(ve({},t||{}),e||{}),Object.keys(t).reduce(function(n,o){return n[o]=ve(ve({},t[o]),e[o]||{}),n},{})):t}function Xg(t,e){return e?Object.keys(t).reduce(function(n,o){return n[o]=qg(t[o],e[o]),n},ve({},t)):t}function di(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,n){t[e]=n}}}}}function Jg(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:bs(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,Ss([void 0],n,!1)))},{cache:di(t.number),strategy:Cs.variadic}),getDateTimeFormat:bs(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,Ss([void 0],n,!1)))},{cache:di(t.dateTime),strategy:Cs.variadic}),getPluralRules:bs(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,Ss([void 0],n,!1)))},{cache:di(t.pluralRules),strategy:Cs.variadic})}}var ci=(function(){function t(e,n,o,s){n===void 0&&(n=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(l){var c=r.formatToParts(l);if(c.length===1)return c[0].value;var u=c.reduce(function(p,f){return!p.length||f.type!==se.literal||typeof p[p.length-1]!="string"?p.push(f.value):p[p.length-1]+=f.value,p},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(l){return ho(r.ast,r.locales,r.formatters,r.formats,l,void 0,r.message)},this.resolvedOptions=function(){var l;return{locale:((l=r.resolvedLocale)===null||l===void 0?void 0:l.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=n,this.resolvedLocale=t.resolveLocale(n),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,d=jl(i,["formatters"]);this.ast=t.__parse(e,ve(ve({},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=Xg(t.formats,o),this.formatters=s&&s.formatters||Jg(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=Xl,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 Qg(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var Zg="dummy",pi=(0,Rs.createContext)(null);function R(t){var o;let e=(0,Rs.useContext)(pi);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=(o=t[e])!=null?o:{};return(s,r)=>{let i=Qg(n,s);return i?new ci(i).format(r):(e!==Zg&&console.warn(`${s} does not exist in messages of ${e}`),`[${s}]`)}}var Ps=require("react");var Zl={root:"dd-tvkOF",content:"dd-eXA1D"};var ui=require("react/jsx-runtime"),Yg=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:s,onKeyDown:r,overlayAriaLabel:i,contentAriaLabel:a})=>{let d=(0,Ps.useRef)(null),l=x("Dialog",Zl),c=p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),s();return}r&&r(p)},u=p=>{p.target===d.current&&t&&o()};return(0,Ps.useEffect)(()=>{var p,f;!d.current||!t||!e||(f=(p=d.current)==null?void 0:p.querySelector("input, textarea"))==null||f.focus()},[t,e,d]),t?(0,ui.jsx)("div",{role:"dialog","data-testid":"dialog",className:l.root,"aria-label":i,ref:d,onKeyDown:c,onMouseDown:u,children:(0,ui.jsx)("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:n})}):null},In=Yg;var ed=O(require("classnames"));var Yl={root:"dd-ranhW"};var td=require("react/jsx-runtime"),em=o=>{var s=o,{className:t,value:e}=s,n=M(s,["className","value"]);let r=x("TextInput",Yl);return(0,td.jsx)("input",y({className:(0,ed.default)(t,r.root),type:"text",value:e},n))},yo=em;var gi={};Y(gi,{enUS:()=>tm,nlNL:()=>nm});var tm={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"}]},nm={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 nd={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 G=require("react/jsx-runtime");var om=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch(e){return t}},sm=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:s})=>{let r=R(gi),i=x("LoginTokenDialog",nd),a=(0,Ls.useSelector)(el),d=(0,Ls.useDispatch)(),l=E("productName"),[c,u]=(0,De.useState)(t||""),[p,f]=(0,De.useState)(0),[m,g]=(0,De.useState)(""),h=(0,De.useCallback)(w=>v(null,null,function*(){w.preventDefault(),d(ol({email:c})),f(1)}),[n,c]),b=()=>{g(""),f(0)},T=(0,De.useCallback)(w=>v(null,null,function*(){w.preventDefault();let L=om(w.target.elements.token.value);if(!L){g(r("verifyCodeError",{login:C}));return}d(eo({token:L}))}),[n]),C=(0,De.useMemo)(()=>w=>(0,G.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:b,children:w},"back-button"),[]);return(0,De.useEffect)(()=>{a==="error"&&g(r("verifyCodeError",{login:C})),a==="done"&&o()},[a]),(0,G.jsx)(In,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:l}),overlayAriaLabel:r("promptTitle",{productName:l}),onClose:s,onBack:s,children:(0,G.jsxs)("div",{className:i.root,children:[(0,G.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:l})}),p===0&&(0,G.jsxs)("form",{onSubmit:h,children:[(0,G.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,G.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:l})}),(0,G.jsx)(yo,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:c,onChange:w=>u(w.target.value)}),(0,G.jsx)("div",{className:i.actions,children:(0,G.jsx)("button",{type:"submit",className:(0,Is.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),p===1&&(0,G.jsxs)("form",{onSubmit:T,children:[(0,G.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,G.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,G.jsx)(yo,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&(0,G.jsx)("div",{className:i.errorMessage,children:m}),(0,G.jsxs)("div",{className:i.actions,children:[(0,G.jsx)("button",{type:"button",className:(0,Is.default)(i.button),onClick:b,children:r("back")}),(0,G.jsx)("button",{type:"submit",className:(0,Is.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},od=sm;var rd=require("react/jsx-runtime"),rm=()=>{let t=(0,mi.useSelector)(tl),e=(0,mi.useSelector)(En),n=E("adminUrl"),o=me(),s=()=>o.send(Pn,!1),r=()=>{o.send(Pn,!1),o.send(so)};return(0,rd.jsx)(od,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:s,onSuccess:r})},sd=rm;var Gd=O(require("lodash.debounce")),fe=require("react"),je=require("react-redux");var As=require("@reduxjs/toolkit");var im={data:null,fetchState:"idle"},id=t=>t.contentTypes.data,vo=(0,As.createAsyncThunk)("contentTypes/getContentTypes",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),am=(0,As.createSlice)({name:"contentTypes",initialState:im,reducers:{},extraReducers:t=>{t.addCase(vo.pending,e=>{e.fetchState="loading"}).addCase(vo.rejected,e=>{e.fetchState="error"}).addCase(vo.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),ad=am.reducer;var Ln=require("@reduxjs/toolkit");var lm={data:null,fetchState:"idle"},dm=[],Xt=t=>t.profile.data,cm=t=>t.profile.data?t.profile.data.uiConfig.widget.types:dm,So=(0,Ln.createSelector)([cm],t=>t.filter(e=>e.isActive)),ld=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},dd=t=>e=>So(e).find(n=>n.type===t),cd=t=>t.profile.data?!!t.profile.data.uiConfig.widget.types.find(e=>e.type==="custom-data"):!1,pd=t=>{var e,n;return(n=(e=t.profile.data)==null?void 0:e.knowledgeAssistantNew)!=null?n:null},xo=(0,Ln.createAsyncThunk)("profile/getProfile",(t,e)=>v(null,null,function*(){var r;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=o.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=o.profile.data)==null?void 0:r.code)===s.profileCode?o.profile.data:n.getProfile(s.profileCode)})),pm=(0,Ln.createSlice)({name:"profile",initialState:lm,reducers:{},extraReducers:t=>{t.addCase(xo.pending,e=>{e.fetchState="loading"}).addCase(xo.rejected,e=>{e.fetchState="error"}).addCase(xo.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),ud=pm.reducer;function We(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 rt=require("react");var gd=require("react"),Ms=O(require("classnames"));var xe={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 st={};Y(st,{enUS:()=>um,nlNL:()=>gm});var um={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"}]},gm={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 wt=require("react/jsx-runtime"),mm=({src:t,title:e})=>{let n=x("CommandPalette",xe),[o,s]=(0,gd.useState)("loading"),r=R(st);return(0,wt.jsxs)("div",{className:n.image,children:[(0,wt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,Ms.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&(0,wt.jsx)("span",{className:(0,Ms.default)(n.imageSrc,n.imageSrcStatus),children:r("loading")}),o==="error"&&(0,wt.jsx)("span",{className:(0,Ms.default)(n.imageSrc,n.imageSrcStatus),children:(0,wt.jsx)(Yo,{})}),e&&(0,wt.jsx)("span",{className:n.imageTitle,children:e})]})},md=mm;var fd=O(require("react")),hd=O(require("classnames"));var Jt=require("react/jsx-runtime");function fi({children:t,heading:e,orientation:n,hasMore:o,onShowAll:s}){let r=R(st),i=x("CommandPalette",xe);return fd.default.Children.count(t)===0?null:(0,Jt.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||o)&&(0,Jt.jsxs)("div",{className:i.listHeader,children:[e&&(0,Jt.jsx)("h4",{className:i.listHeading,children:e}),o&&s&&(0,Jt.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,Jt.jsx)("div",{className:(0,hd.default)(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}var Co=O(require("classnames")),xi=require("interweave"),Et=require("react");var fm=/[.*+?^${}()|[\]\\]/g,hm=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function ym(t){return t.replace(fm,"\\$&")}function vm(t,e){let n=t.split("").findIndex((o,s)=>o!==e[s]);return n>-1?n:Math.min(t.length,e.length)}function xm(t){return t.search(hm)}function yd(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let s=new RegExp(`\\b(${ym(o)})\\b`,"gi");n=n.replace(s,"<strong>$1</strong>")}),n}function vd(t){return t.replace(rs,'<mark data-type="placeholder">$1</mark>')}function An(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Sm(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 hi(t,e,n={}){if(e){let o=vm(e.toLowerCase(),t.toLowerCase()),s=An(t.substring(o,t.length));if(n.stripAgentPart){let d=t.substring(0,o),l=xm(d);return`<span style="opacity: 0.5">${d.substring(l+1)}</span>${s}`}let i=e.split(Ga).length>3||e.length>30?Sm(e.trim(),o):0;return`${`${i>0?"\u2026":""}${An(t.substring(i,o))}`}<strong>${s}</strong>`}return t}var bm=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function bo(t){return bm.test(t)}function yi(t){var n;let e=document.createElement("template");return e.innerHTML=t,(n=e.content.textContent)!=null?n:""}var Ns=O(require("react")),bd=require("react/jsx-runtime"),xd=Ns.default.createContext(void 0);function Mn(){let t=Ns.default.useContext(xd);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Sd=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r})=>{let i=Ns.default.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r}),[n,e,s]);return(0,bd.jsx)(xd.Provider,{value:i,children:t})};var Ve=O(require("react")),U=require("@floating-ui/react");var Os={tooltip:"dd-XpCXd",tooltipTrigger:"dd-8TKeF",arrow:"dd-ZEu2Y"};var ke=require("react/jsx-runtime");function Cm({initialOpen:t=!1,placement:e="bottom",modal:n,tooltip:o,open:s,onOpenChange:r}={}){let[i,a]=Ve.useState(t),d=s!=null?s:i,l=r!=null?r:a,c=(0,U.useFloating)({placement:e,open:d,onOpenChange:l,whileElementsMounted:U.autoUpdate,middleware:[(0,U.offset)(5),(0,U.flip)({crossAxis:e.includes("-"),fallbackAxisSideDirection:"end",padding:5}),(0,U.shift)({padding:10})]}),u=c.context,p=(0,U.useClick)(u,{enabled:s==null}),f=(0,U.useDismiss)(u),m=(0,U.useRole)(u),g=(0,U.useHover)(u,{enabled:o!=null?o:!1,handleClose:(0,U.safePolygon)()}),h=(0,U.useInteractions)([p,f,m,g]);return Ve.useMemo(()=>S(y(y({open:d,setOpen:l},h),c),{modal:n}),[d,l,h,c,n])}var Cd=Ve.createContext(null),vi=()=>{let t=Ve.useContext(Cd);if(t==null)throw new Error("Popover components must be wrapped in <Popover />");return t},Qt=o=>{var s=o,{children:t,modal:e=!1}=s,n=M(s,["children","modal"]);let r=Cm(y({modal:e},n));return(0,ke.jsx)(Cd.Provider,{value:r,children:t})};function Tm(o){var s=o,{as:t,children:e}=s,n=M(s,["as","children"]);let r=vi(),i=t||"button",a=e.ref,d=(0,U.useMergeRefs)([r.refs.setReference,a]);return(0,ke.jsx)(i,S(y({ref:d,type:"button"},r.getReferenceProps(n)),{children:e}))}var wm=Ve.forwardRef(function(s,o){var r=s,{style:e}=r,n=M(r,["style"]);let l=vi(),{context:i}=l,a=M(l,["context"]),d=(0,U.useMergeRefs)([a.refs.setFloating,o]);return i.open?(0,ke.jsx)(U.FloatingPortal,{children:(0,ke.jsx)(U.FloatingFocusManager,{context:i,modal:a.modal,disabled:n.disableFocusManager,children:(0,ke.jsx)("div",S(y({ref:d,style:y(S(y({},a.floatingStyles),{zIndex:1e7}),e)},a.getFloatingProps(n)),{children:n.children}))})}):null});function Em(s){var r=s,{as:t,children:e,onClick:n}=r,o=M(r,["as","children","onClick"]);let{setOpen:i}=vi();return(0,ke.jsx)(t||"button",S(y({type:"button",onClick:l=>{n(l),i(!1),l.stopPropagation()}},o),{children:e}))}function Td({trigger:t,children:e,placement:n="top"}){return(0,ke.jsxs)(Qt,{tooltip:!0,placement:n,children:[(0,ke.jsxs)(Qt.Content,{className:Os.tooltip,children:[e,(0,ke.jsx)("div",{className:Os.arrow})]}),(0,ke.jsx)(Qt.Trigger,{className:Os.tooltipTrigger,children:t})]})}Qt.Trigger=Tm;Qt.Content=wm;Qt.Button=Em;var ee=Qt;var ae=require("react/jsx-runtime"),km=3,Rm=90,wd=({children:t})=>{let e=x("CommandPalette",xe);return(0,ae.jsx)("div",{className:e.listItemActions,children:t})};function Si(f){var m=f,{closeOnSelect:t=!0,lineClamp:e,tooltip:n,children:o,onClick:s,extra:r,onSourceClick:i,description:a,sources:d,id:l,styles:c,defaultSourcesAmount:u=km}=m,p=M(m,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var Ce;let g=R(st),[h,b]=(0,Et.useState)(!1),{selected:T,onChangeOpen:C}=Mn(),[w,L]=(0,Et.useState)(!1),N=x("CommandPalette",xe);function B(_){s(_),t&&C(!1)}let X=(0,Et.useMemo)(()=>typeof a!="string"?a:bo(a)?yi(a).trim():a,[a]),Le=(0,Et.useMemo)(()=>typeof n!="string"?n:bo(n)?yi(n).trim():n,[n]);return(0,Et.useEffect)(()=>{L(T===l)},[T]),(0,ae.jsxs)("div",{className:(0,Co.default)(N.listItem,l===T&&N.listItemSelected),children:[(0,ae.jsxs)(ee,{placement:"right-start",tooltip:!0,onOpenChange:L,open:w,children:[(0,ae.jsx)(ee.Trigger,S(y({className:N.listItemAction,"aria-disabled":(Ce=p.disabled)!=null?Ce:!1,onClick:B,"data-command-palette-item":!0,"data-item-id":l},p),{children:(0,ae.jsxs)("div",{className:N.listItemContent,children:[typeof o=="string"?(0,ae.jsx)("p",{className:(0,Co.default)(N.listItemText,N.truncate,c==null?void 0:c.title),children:o}):o,X&&typeof X=="string"?(0,ae.jsx)(xi.Interweave,{tagName:"p",allowList:[],content:X,className:(0,Co.default)(N.listItemDescription,c==null?void 0:c.description,e?N.lineClamp:N.truncate)}):a]})})),Le&&Le.length>Rm&&(0,ae.jsx)(ee.Content,{className:N.listItemTooltip,disableFocusManager:!0,children:(0,ae.jsx)(xi.Interweave,{className:N.listItemTooltipContent,allowList:["h1","h2","h3","h4","h5","h6","a","p","br"],tagName:"div",content:Le.replace(/\n/g,"<br />")})})]}),l===T&&r,d&&d.length>0&&(0,ae.jsxs)("div",{className:N.sources,children:[(0,ae.jsx)("span",{className:N.sourcesTitle,children:g("sources")}),d.slice(0,h?d.length:u).map(_=>(0,ae.jsx)("a",{className:N.source,href:_.url,target:"_blank",title:_.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i==null?void 0:i(_),children:_.name},_.url)),!h&&d.length>u&&(0,ae.jsx)("button",{className:(0,Co.default)(N.source,N.sourceShowMore),type:"button",onClick:()=>b(!0),children:g("showMore",{amount:d.length-u})})]})]})}var To=require("react/jsx-runtime"),Ed=()=>(0,To.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,To.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,To.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 Zt=require("react/jsx-runtime");function bi({children:t,title:e,id:n,onDismiss:o}){let s=R(st),r=x("CommandPalette",xe),{page:i}=Mn();return i!==n?null:(0,Zt.jsxs)("div",{className:r.page,id:`page_${n}`,tabIndex:-1,children:[o&&(0,Zt.jsxs)("div",{className:r.pageNav,children:[(0,Zt.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:o,children:[(0,Zt.jsx)(Ed,{}),s("back")]}),e&&(0,Zt.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var kd=require("react");var wo=require("react/jsx-runtime"),Nn=()=>(0,wo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,wo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,wo.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 _e=require("react/jsx-runtime");function Pm({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:s,value:r,selectedType:i},a){let d=x("CommandPalette",xe);return(0,_e.jsxs)("div",{className:d.search,children:[(0,_e.jsx)("div",{className:d.searchIcon,children:(0,_e.jsx)(Nn,{})}),(0,_e.jsxs)("div",{className:d.searchInputWrapper,children:[(0,_e.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:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&(0,_e.jsx)("div",{className:d.selectWrapper,children:(0,_e.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,_e.jsx)("option",{children:o}),s.map(l=>(0,_e.jsx)("option",{value:l.value,children:l.label},l.value))]})})]})]})}var Rd=(0,kd.forwardRef)(Pm);var Ci=O(require("classnames"));var Ds=require("react/jsx-runtime"),Im=s=>{var r=s,{onClick:t,shortKeys:e,children:n}=r,o=M(r,["onClick","shortKeys","children"]);let i=x("CommandPalette",xe);return(0,Ds.jsxs)("button",S(y({type:"button"},o),{onClick:t,className:(0,Ci.default)(i.actionButton,o.className,{[i.hasShortKeys]:e&&e.length>0}),children:[n,e==null?void 0:e.map(a=>(0,Ds.jsx)("span",{className:(0,Ci.default)(i.actionShortcut,a===8629&&i.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},Pd=Im;var Eo=require("react/jsx-runtime"),Lm="[data-command-palette-item]";function Yt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:d,types:l,children:c,isOpen:u,search:p,updateDeps:f=[]}){let[m,g]=(0,rt.useState)(),h=(0,rt.useRef)(null),b=()=>{s&&s(n),i(void 0),r(""),a(!1)},T=()=>{var _;if(o!==n&&s){s(n);return}if(d&&i){i(void 0),(_=h.current)==null||_.focus();return}if(p.length>0){r("");return}a(!1)},C=()=>{let _=w();_.length!==0&&g(_[0].dataset.itemId)},w=()=>Array.from(document.querySelectorAll(Lm)||[]),L=_=>document.querySelector(`[data-item-id=${_}]`),N=_=>{let W=L(_);W&&g(W.dataset.itemId)},B=_=>{let W=L(_);W&&W.scrollIntoView({behavior:"smooth"})},X=()=>{if(!m)return;let _=w(),W=L(m);if(!W)return;let Ye=_.indexOf(W),Te=_[Ye+1];Te!=null&&Te.dataset.itemId?N(Te.dataset.itemId):C()},Le=()=>{if(!m)return;let _=w(),W=L(m);if(!W)return;let Ye=_.indexOf(W),Te=_[Ye-1];Te!=null&&Te.dataset.itemId?N(Te.dataset.itemId):N(_[_.length-1].dataset.itemId)},Ce=(0,rt.useCallback)(_=>{switch(_.key){case"ArrowDown":{_.preventDefault(),X();break}case"ArrowUp":{_.preventDefault(),Le();break}case"Enter":{if(m){let W=L(m);W==null||W.click()}break}}},[m]);return(0,rt.useEffect)(()=>{C()},[p,o,d,u,...f]),(0,rt.useEffect)(()=>{m&&B(m)},[m]),(0,Eo.jsx)(In,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:T,onClose:b,onKeyDown:Ce,children:(0,Eo.jsxs)(Sd,{selected:m,setSelected:g,isOpen:u,onChangeOpen:a,page:o,children:[o===n&&(0,Eo.jsx)(Rd,{ref:h,onChange:r,onChangeType:i,placeholder:t,value:p,selectedType:d,types:l,typePlaceholder:e}),c]})})}Yt.Page=bi;Yt.List=fi;Yt.Image=md;Yt.ListItem=Si;Yt.ListItemActions=wd;Yt.Button=Pd;var te=Yt;var Id=require("react");function Ld(t,e){(0,Id.useEffect)(()=>{let n=o=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var ko=require("react"),Fs=require("react-redux");var On=require("@reduxjs/toolkit");var Ad={data:null,fetchState:"idle"},Am=t=>{var e;return(e=t.entities.data)!=null?e:null},_s=(0,On.createSelector)([Am,En,Rl],(t,e,n)=>{var a;let o=[],{visitorName:s}=n!=null?n:{},{agentName:r,agentNickname:i}=e!=null?e:{};return r&&r!==s&&o.push(r),i&&i!==s&&o.push(i),(a=t==null?void 0:t.filter(d=>!o.includes(d.text)))!=null?a:null}),Fe=(0,On.createAsyncThunk)("entities/getEntities",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let s=o.conversationQuery,r=yield s();return r.length===0?Promise.resolve([]):n.getEntities(r)})),Mm=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),Nm=(0,On.createSlice)({name:"entities",initialState:Ad,reducers:{},extraReducers:t=>{t.addCase(Fe.pending,e=>{e.fetchState="loading"}).addCase(Fe.rejected,e=>{e.fetchState="error"}).addCase(Fe.fulfilled,(e,n)=>{e.fetchState="done",e.data=Mm(e.data?[...e.data,...n.payload]:n.payload)}).addCase(J,()=>Ad)}}),Md=Nm.reducer;var Ti={};Y(Ti,{enUS:()=>Om,nlNL:()=>Dm});var Om={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Dm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Nd={root:"dd-TYTKs",empty:"dd-AU7uT"};var Dn=require("react/jsx-runtime"),_m=({onCopy:t})=>{let e=(0,ko.useRef)(null),n=x("EntitiesList",Nd),o=(0,Fs.useSelector)(_s),{setSelected:s}=Mn(),r=R(Ti),i=(0,Fs.useDispatch)();return(0,ko.useEffect)(()=>{i(Fe())},[]),(0,ko.useEffect)(()=>{e.current&&(e.current.focus(),s("entity-0"))},[e]),(0,Dn.jsxs)("div",{className:n.root,ref:e,tabIndex:-1,children:[o&&o.length>0&&(0,Dn.jsx)(te.List,{children:o.map((a,d)=>(0,Dn.jsx)(te.ListItem,{id:`entity-${d}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),o&&o.length===0&&(0,Dn.jsx)("p",{className:n.empty,children:r("noResults")})]})},Od=_m;var wi=require("react/jsx-runtime"),Hs=t=>(0,wi.jsx)("svg",S(y({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},t),{children:(0,wi.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 Ro={};Y(Ro,{enUS:()=>Fm,nlNL:()=>Hm});var Fm={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"}]},Hm={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 kt=t=>e=>{let{passwordlessToken:{token:n},settings:{isEmbedded:o,adminUrl:s}}=e,r=s||window.location.origin;return o&&!n?null:o&&n?`${r}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${r}${t}`};var Ei=require("react-redux");var Bs={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var _d=require("react-redux");var Dd=require("@reduxjs/toolkit");function Us(t){return(0,Dd.createAsyncThunk)("analytics/logEvent",(e,n)=>{var r,i,a;let o=(i=(r=n.getState())==null?void 0:r.conversation.current)==null?void 0:i.id,s=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,S(y({conversationId:o},s),{data:e.data}))})(t)}function V(){let t=(0,_d.useDispatch)();return(e,n)=>v(null,null,function*(){yield t(Us({name:e,data:n}))})}var en=require("react/jsx-runtime"),Bm=({suggestion:t,source:e,context:n})=>{let o=R(Ro),s=(0,Ei.useSelector)(ze),r=V(),i=E("enableSuggestionFeedback"),a=`${t.text}`,d=(0,Ei.useSelector)(kt(`/admin/feedback?conversationId=${s}&type=${e}&text=${a}&data=${JSON.stringify({context:n})}`)),l=()=>{r("suggestion feedback",{text:t.text,source:e,context:n})};return!i||!d?null:(0,en.jsxs)(ee,{placement:"top-end",children:[(0,en.jsx)(ee.Trigger,{className:Bs.trigger,children:(0,en.jsx)(Hs,{"data-testid":"feedback-dropdown-trigger"})}),(0,en.jsx)(ee.Content,{className:Bs.content,children:(0,en.jsx)(ee.Button,{className:Bs.item,as:"a",onClick:l,target:"_blank",href:d,children:o("giveFeedback")})})]})},Ks=Bm;var Po={};Y(Po,{enUS:()=>Um,nlNL:()=>Km});var Um={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?"}]},Km={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 jd=require("react"),Vs=require("react-redux");var tn=require("@reduxjs/toolkit");var zm=["{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}"],Wm=new RegExp(zm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Fd(t,e){let n=t.split(Wm),o=0,s=[];for(let r=0;r<n.length;r++){let i=n[r];if(s.push(i),r===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[r+1],d=r===n.length-2;o+=i.length;let l=o;if(d){let u=a.charAt(0),p=0;do l=u?e.indexOf(u,l+1):-1,p+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&p>2)return t}else l=a&&a!==""?e.indexOf(a,o):-1;let c=l===-1?e.slice(o):e.slice(o,l);s.push(c),o=l}return s.join("")}function Hd(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Ud={suggestions:[],fetchState:"idle"},Bd={default:Ud},Kd=t=>e=>{var n,o;return(o=(n=e.textSuggestions[t])==null?void 0:n.suggestions)!=null?o:[]},zs=t=>t.textSuggestions,zd=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Ws=(0,tn.createAction)("textSuggestions/refresh"),He=(0,tn.createAsyncThunk)("textSuggestions/recommendations",(t,e)=>v(null,null,function*(){var c,u,p;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:s}=o.info,{textSuggestionsCount:r,inlineSuggestions:i}=o.settings,a=Cn(o),d=(c=o.conversation.current)==null?void 0:c.id;if(!d)throw new Error("No current conversation to fetch text suggestions");if(!((u=o.profile.data)!=null&&u.recommendationEngine))return[];let l=[];if(t==="sticky-messages"){let f=(p=o.profile.data)==null?void 0:p.code;if(!f)throw new Error("No current profile to fetch pinned messages");l=yield n.getPinnedMessages(f)}else l=yield n.getTextSuggestions(d,oo(o),t);if(s&&(l=l.map(f=>y(S(y({},f),{text:Ne(f.text,s)}),f.title?{title:Ne(f.title,s)}:{}))),t==="default"){let f=i?l.filter(zd(a)):l;e.dispatch(Tt(f.slice(0,r)))}return l})),Io=(0,tn.createAsyncThunk)("textSuggestions/autocompletions",(t,e)=>v(null,null,function*(){var c,u;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(c=o.conversation.current)==null?void 0:c.id,{platformVariables:r}=o.info,{textSuggestionsCount:i,deanonymize:a,inlineSuggestions:d}=o.settings;if(!((u=o.profile.data)!=null&&u.recommendationEngine))return[];if(!s)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(s,S(y({},oo(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return d&&(l=l.filter(zd(t))),r&&(l=l.map(p=>S(y({},p),{text:Ne(p.text,r)}))),a&&(l=l.map(p=>S(y({},p),{text:p.source!=="trie-with-typos"?Fd(p.text,t):p.text}))),l=Hd(l,i),e.dispatch(Tt(l)),l})),Wd=(0,tn.createSlice)({name:"textSuggestions",initialState:Bd,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:n}=e.payload;t[n].fetchState="done",t[n].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}}},extraReducers:t=>{t.addCase(He.pending,(e,n)=>{let o=n.meta.arg,s=e[o]||Ud;return S(y({},e),{[o]:S(y({},s),{fetchState:"loading"})})}).addCase(He.rejected,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="error")}).addCase(He.fulfilled,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="done",e[o].suggestions=n.payload)}).addCase(Io.pending,e=>{e.default.fetchState="loading"}).addCase(Io.rejected,e=>{e.default.fetchState="error"}).addCase(Io.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(J,()=>Bd)}}),{setTextSuggestions:dC}=Wd.actions,Vd=Wd.reducer;var nn=require("react/jsx-runtime"),Vm=({types:t,commands:e,onClick:n})=>{let o=(0,Vs.useDispatch)(),s=R(Po),r=(0,Vs.useSelector)(zs);return(0,jd.useEffect)(()=>{t.forEach(({type:i})=>{(!r[i]||r[i].suggestions.length===0)&&o(He(i))})},[]),(0,nn.jsxs)("div",{children:[e.length>0&&(0,nn.jsx)(te.List,{heading:s("commands"),children:e.map((i,a)=>(0,nn.jsx)(te.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:i.onClick,children:i.label},i.label))}),t.map(({type:i,title:a})=>{var d;return(0,nn.jsx)(te.List,{heading:a,orientation:"vertical",children:(d=r[i])==null?void 0:d.suggestions.map((l,c)=>(0,nn.jsx)(te.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)})]})},$d=Vm;var le=require("react/jsx-runtime"),$m=200,Gm=5,qm=4,ki=(t,e,n)=>t.slice(0,n?10:e.toLowerCase()==="image"?qm:Gm),Xm=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Jm=()=>{var Ye,Te,Ca;let t=(0,je.useDispatch)(),e=me(),n=R(Po),[o,s]=(0,fe.useState)(!1),[r,i]=(0,fe.useState)(""),a=(0,je.useSelector)(Fl),d=(0,je.useSelector)(Xt),[l,c]=(0,fe.useState)(),u=(0,je.useSelector)(ne),p=E("showSearch"),f=E("enableSuggestionFeedback"),m=E("showEntitiesCommand"),g=E("showImageSearch"),h=E("searchTriggerKey"),b=(0,je.useSelector)(id),T=(0,je.useSelector)(ei),C=(0,je.useSelector)(Hl),w=(0,je.useSelector)(_l),L=((Ca=(Te=(Ye=d==null?void 0:d.uiConfig)==null?void 0:Ye.search)==null?void 0:Te.initialTypes)==null?void 0:Ca.filter(({isActive:A})=>A))||[],N=V(),B=(0,fe.useMemo)(()=>{let A=ue=>ki(T.filter($=>$.type===ue.toUpperCase()),ue,l),Z=(b==null?void 0:b.map(ue=>({value:ue.code.toUpperCase(),label:`${ue.name}s`,list:A(ue.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(Z.push({value:"PERSONAL",label:n("personalSuggestions"),list:A("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:A("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:A("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),g&&Z.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:A("IMAGE"),listOrientation:"horizontal"}),L.length===0)return Z;let Jn=L.map(ue=>Z.find($=>$.value.toLowerCase()===ue.type)).filter(ue=>!!ue),Kr=Z.filter(ue=>!Jn.find($=>$.value===ue.value));return[...Jn,...Kr]},[b,L,g,l]),X=[{label:n("entitiesClipboard"),onClick:()=>t(Rn("entities")),shouldShow:m&&Xm(n("entitiesClipboard"),r)}].filter(A=>A.shouldShow).filter(()=>!l),Le=(0,fe.useCallback)((0,Gd.default)((A,Z)=>{t(Gt({query:A,type:Z,tags:["search-overlay"],size:l?50:20}))},$m),[l]),Ce=(0,fe.useCallback)((A,Z)=>{Z.type==="IMAGE"?e.send(ni,{suggestion:Z}):e.send(nt,{text:A,suggestion:Z}),t(Oe(!1))},[t]),_=A=>{We(A.text),N("entity copied",{entity:A,type:"copy"}),t(Oe(!1))};function W(A){return Z=>{o?window.confirm(n("warning"))&&(A(Z),s(!1)):A(Z)}}return(0,fe.useEffect)(()=>{r?Le(r,l):t(ys())},[r,l]),(0,fe.useEffect)(()=>{u&&t(vo())},[u]),Ld(h,()=>{t(Oe(!0)),N("open search",{via:"ctrl+k"})}),!p||!d?null:(0,le.jsxs)(te,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:W(A=>t(Oe(A))),onChangeType:A=>c(A),onChangePage:W(A=>t(Rn(A))),selectedType:l,search:r,page:a,isOpen:w,types:B,updateDeps:[T],children:[(0,le.jsxs)(te.Page,{id:"search",children:[r.length===0&&(0,le.jsx)($d,{types:L,commands:X,onClick:Ce}),r.length>0&&(0,le.jsxs)(fe.Fragment,{children:[X.length>0&&(0,le.jsx)(te.List,{heading:n("commands"),children:X.map((A,Z)=>(0,le.jsx)(te.ListItem,{closeOnSelect:!1,onClick:A.onClick,id:`commands-${Z}`,children:A.label},A.label))}),B.map(({value:A,label:Z,list:Jn,lineClamp:Kr,listOrientation:ue})=>(0,le.jsx)(te.List,{heading:Z,orientation:ue==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(A),hasMore:!l&&C[A.toLowerCase()]>ki(Jn,A,l).length,children:ki(Jn,A,l).map($=>(0,le.jsx)(te.ListItem,{id:`${A}-${$.id}`,closeOnSelect:!1,lineClamp:Kr,onClick:()=>Ce($.text,$),description:A!=="IMAGE"?$.title&&$.text:void 0,tooltip:$.text,extra:f&&(0,le.jsx)(te.ListItemActions,{children:(0,le.jsx)(Ks,{context:r,source:"search",suggestion:$})}),children:A==="IMAGE"?(0,le.jsx)(te.Image,{title:$.title||$.text,src:$.image}):$.title||$.text},`${$.id}-${$.text}`))},A))]})]}),(0,le.jsx)(te.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:W(()=>{t(Rn("search"))}),children:(0,le.jsx)(Od,{onCopy:_})})]})},qd=Jm;var Lo=require("react/jsx-runtime"),Qm=()=>{let t=E("showSearch"),e=E("isEmbedded");return(0,Lo.jsxs)(Xd.Fragment,{children:[t&&(0,Lo.jsx)(qd,{}),e&&(0,Lo.jsx)(sd,{})]})},Jd=Qm;var ec=O(require("classnames")),tc=require("react-redux");var js=require("react/jsx-runtime"),Qd=({className:t})=>(0,js.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,js.jsx)("g",{children:(0,js.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
|
|
4
4
|
c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
|
|
5
5
|
c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
|
|
6
6
|
c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
|
|
7
|
-
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Pi=require("react/jsx-runtime"),Ym={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Yd=({className:t,color:e})=>(0,Pi.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Pi.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:Ym[e||"pink"]})});var ec={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var Ii={};Y(Ii,{enUS:()=>ef,nlNL:()=>tf});var ef={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},tf={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var oc=require("react-redux"),sn=require("react/jsx-runtime"),sc=({onLogIn:t})=>{let e=R(Ii),n=E("floatingMenu"),o=E("productName"),s=(0,oc.useDispatch)(),r=(0,nc.useSelector)(ne),i=x("FloatingMenu",ec);if(r===null||n===!1)return null;let a=()=>{r===!0?s(Oe(!0)):t()};return(0,sn.jsxs)("button",{type:"button",className:(0,tc.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,sn.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:o})}),(0,sn.jsxs)("div",{className:i.icon,children:[(0,sn.jsx)(Yd,{className:i.logo,color:"pink"}),r===!1&&(0,sn.jsx)(Zd,{className:i.lock})]})]})};var Js=require("react"),it=require("react-redux");var rc=require("react");function Rt(t){(0,rc.useEffect)(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function rn(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}function $e(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:s,selection:r}=t.input;return r.start!==r.end?!1:r.end>=s.length?!0:e?n&&new RegExp(n).test(s.substring(r.end))||o&&new RegExp(o).test(s.substring(0,r.end))?!0:n===!1&&o===!1:!1}var ic=require("@reduxjs/toolkit"),nf={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Gs=({ui:t})=>t.overlayCollapsed,ac=(0,ic.createSlice)({name:"ui",initialState:nf,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:Mo,setInputFocus:qs,setOverlayCollapsed:Pt,setOpenOverlayWhenTyping:lc,setOverlayCollapsedUserOverwrite:dc}=ac.actions,cc=ac.reducer;var hc=require("react");var Ai=require("interweave"),It=require("react"),Oo=require("react-redux");var pc=require("react");function uc(t,e,n){(0,pc.useEffect)(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var gc={root:"dd-1MBCO",actions:"dd--x4cy",closeIconContainer:"dd-1z5NR",closeIcon:"dd-8qMF-",badge:"dd-4Fpkz",formattedText:"dd-EzvTB",assistantContainer:"dd-j6o8F",formattedTextTruncated:"dd-fv169",assistantBadge:"dd-VD57E"};var No=require("react/jsx-runtime"),mc=({title:t})=>(0,No.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24","aria-labelledby":"closeTitle",children:[(0,No.jsx)("title",{id:"closeTitle",children:t}),(0,No.jsx)("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})]});var Li={};Y(Li,{enUS:()=>of,nlNL:()=>sf});var of={assistant:[{type:0,value:"Assistant"}],close:[{type:0,value:"Close"}]},sf={assistant:[{type:0,value:"Assistent"}],close:[{type:0,value:"Sluiten"}]};var Se=require("react/jsx-runtime"),af=["search","personal-collection-search","search-autocomplete"];function lf(t,e,n,o={}){var r;let s="";return af.includes(e)?s=vd(yi(t,n,{stripAgentPart:!0}),(r=o.searchKeywords)!=null?r:[n]):s=yi(t,n,o),o.placeholders===!0&&(s=xd(s)),s}var df=()=>{},cf=({selected:t,suggestion:e})=>{let n=R(Li),o=E("inlineSuggestions"),s=(0,Oo.useSelector)(Cn),[r,i]=(0,It.useState)(!1),a=E("enableSuggestionFeedback"),d=(0,Oo.useSelector)(h=>h.input.text),l=(0,Oo.useDispatch)(),c=x("TextSuggestion",gc),u=(0,It.useRef)(null),p=e.source==="assistant",f=a&&!p;(0,It.useEffect)(()=>{let h=setTimeout(()=>{l(yl({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(h)}},[e]),uc(u,"click",()=>{l(ye({suggestion:e,text:e.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let m=()=>{l(jt({source:e.source,text:e.text,assistantCode:e.assistantCode}))},g=(0,It.useMemo)(()=>lf(e.text,e.source,s,{stripAgentPart:o,placeholders:!0,searchKeywords:e.searchKeywords}),[o,e.text,e.source,s,e.searchKeywords]);return e.source==="gpt"&&!o?null:(0,Se.jsxs)("div",{className:c.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,Se.jsx)(I,{ref:u,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:df,children:e.source==="assistant"?(0,Se.jsxs)("div",{className:c.assistantContainer,children:[(0,Se.jsx)(Ai.Interweave,{containerTagName:"div",tagName:"span",className:c.formattedTextTruncated,content:g}),(0,Se.jsx)("span",{className:c.assistantBadge,children:n("assistant")})]}):(0,Se.jsx)(Ai.Interweave,{containerTagName:"div",tagName:"span",className:c.formattedText,content:g})}),f&&r&&(0,Se.jsx)("div",{className:c.actions,children:(0,Se.jsx)(zs,{source:"overlay",context:d,suggestion:e})}),p&&r&&(0,Se.jsx)("div",{className:c.closeIconContainer,children:(0,Se.jsx)("button",{type:"button",className:c.closeIcon,onClick:m,title:n("close"),children:(0,Se.jsx)(mc,{title:n("close")})})})]})},fc=cf;var yc=require("react/jsx-runtime"),pf=({suggestions:t,selectedIndex:e,reverse:n})=>(0,hc.useMemo)(()=>{let s=t.map((r,i)=>(0,yc.jsx)(fc,{index:i,selected:i===e,suggestion:r},`${r.text}-${r.source}`));return n?s.reverse():s},[t,e,n]),Xs=pf;var vc={root:"dd-PfvRI",paper:"dd-HYlyY"};var Do=require("react/jsx-runtime"),uf=()=>{let t=(0,Js.useRef)(null),e=x("InlineSuggestionsOverlay",vc),n=(0,it.useSelector)($e),o=(0,it.useDispatch)(),s=(0,it.useSelector)(ne),r=(0,it.useSelector)(bn),i=(0,it.useSelector)(Gs),a=E("showTextSuggestions"),d=(0,it.useSelector)(Vt),l=(0,it.useSelector)(no);return Rt(()=>{setTimeout(()=>{o(Pt({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Js.useEffect)(()=>{let c=t.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let u=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-u.right,0)}px`}),i||!n||!a||d.length===0||s!==!0||r===!1?null:(0,Do.jsx)("div",{className:e.root,"data-variant":"inline",children:(0,Do.jsx)("div",{ref:t,className:e.paper,children:(0,Do.jsx)(ie,{children:(0,Do.jsx)(Xs,{suggestions:d,selectedIndex:l})})})})},xc=uf;var Sc=require("react-redux");var _o=require("react/jsx-runtime"),gf=({children:t})=>{let n=E("locale").replace("-","");return(0,_o.jsx)(ui.Provider,{value:n,children:t})},mf=({store:t,customStyles:e={},children:n})=>(0,_o.jsx)(Sc.Provider,{store:t,children:(0,_o.jsx)(gf,{children:(0,_o.jsx)(Yn.Provider,{value:e,children:n})})}),at=mf;var Zs=O(require("classnames")),_n=require("react"),Be=require("react-redux");var bc=require("react");function Cc(t,e){let[n,o]=(0,bc.useState)(()=>{if(typeof window=="undefined")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return k.error(r),e}});return[n,r=>{try{let i=r instanceof Function?r(n):r;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){k.error(i)}}]}var Tc=()=>/Mac/i.test(navigator.platform);var Ec=O(require("classnames")),lt=require("react");var Mi={};Y(Mi,{enUS:()=>ff,nlNL:()=>hf});var ff={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"}]}]},hf={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 Lt=require("react/jsx-runtime"),Ni=(t,e,n)=>o=>(0,Lt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),yf=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o,onLogIn:s})=>{let r=R(Mi),i=me(),a=x("Login",wc),d=E("productName"),l=(0,lt.useCallback)(h=>{h.preventDefault(),o&&o(Number.parseInt(h.target.value,10))},[]),c=(0,lt.useCallback)(h=>{h.preventDefault(),i.send(Pn,!0)},[e]),u=(0,lt.useMemo)(()=>h=>(0,Lt.jsx)("a",{onClick:T=>{T.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),p=(0,lt.useCallback)(h=>(0,Lt.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:h},"prompt"),[c]),{min:f,hour:m,day:g}=(0,lt.useMemo)(()=>({min:Ni(a,600,l),hour:Ni(a,3600,l),day:Ni(a,3600*12,l)}),[]);return(0,Lt.jsxs)("div",{className:(0,Ec.default)(t,a.root),children:[r("loginPlease",{login:n?p:u,productName:d}),o&&(0,Lt.jsxs)(lt.Fragment,{children:[(0,Lt.jsx)("br",{}),r("snooze",{min:f,hour:m,day:g})]})]})},Qs=yf;var Rc=require("react-redux");var kc={root:"dd-DoQhb",text:"dd-Jwnev"};var Fo=require("react/jsx-runtime"),vf=({title:t})=>{let e=x("SearchTrigger",kc),n=(0,Rc.useDispatch)(),o=V();return(0,Fo.jsxs)("button",{type:"button",className:e.root,onClick:()=>{n(Oe(!0)),o("open search",{via:"autocomplete-overlay"})},children:[(0,Fo.jsx)(Nn,{}),(0,Fo.jsx)("span",{className:e.text,children:t})]})},Pc=vf;var Oi={};Y(Oi,{enUS:()=>xf,nlNL:()=>Sf});var xf={arrowHint:[{type:0,value:"Tip: use arrow keys to navigate suggestions"}],searchHintWindows:[{type:0,value:"Press CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],searchHintMac:[{type:0,value:"Press CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Close"}],search:[{type:0,value:"Search"}],dismiss:[{type:0,value:"Dismiss"}],dismissError:[{type:0,value:"Dismiss error"}]},Sf={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}],dismiss:[{type:0,value:"Sluiten"}],dismissError:[{type:0,value:"Foutmelding sluiten"}]};var Ic={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2",loginError:"dd-KCXeb",loginErrorMessage:"dd-Bv-BG",loginErrorDismiss:"dd-iSCjU"};var K=require("react/jsx-runtime"),bf=({onLogIn:t})=>{let e=x("SuggestionsOverlay",Ic),n=R(Oi),o=(0,Be.useSelector)($e),s=(0,Be.useSelector)(hl),r=(0,Be.useDispatch)(),i=(0,_n.useRef)(null),a=E("searchTriggerKey"),d=E("productName"),l=(0,Be.useSelector)(Gs),c=(0,Be.useSelector)(ne),u=(0,Be.useSelector)(ol),p=(0,Be.useSelector)(bn),[f,m]=(0,_n.useState)(null),g=E("showSearch"),h=E("showTextSuggestions"),b=E("adminUrl"),T=E("isEmbedded"),C=E("suggestionsPlacement"),[w,L]=Cc("dd-snooze-until-ms",0),N=l||w>Date.now(),B=(0,Be.useSelector)(Vt),X=(0,Be.useSelector)(no),Le=B.filter(W=>W.source!=="gpt").length,Ce=()=>{N&&L(0),r(dc(!N))},_=W=>{let Ye=Date.now()+W*1e3;L(Ye),k.info(`Snooze until: ${new Date(Ye)}`),r(Pt({collapse:!0}))};return(0,_n.useEffect)(()=>{Le===0&&m(null)},[B,Le]),Rt(()=>{r(Pt({collapse:!0,skipWhenInputFocus:!0}))}),c===null||p===!1?null:c===!1?(0,K.jsxs)("div",{ref:i,className:(0,Zs.default)(e.root,{[e.isCollapsed]:N}),children:[!N&&(0,K.jsxs)("div",{className:e.triggers,children:[(0,K.jsx)("div",{style:{flex:1}}),(0,K.jsx)("div",{className:e.triggersRight,children:(0,K.jsx)(Ut,{className:e.toggleButton,title:n("collapse"),onClick:Ce,isCollapsed:!1})})]}),(0,K.jsx)("div",{className:e.toggleButtonWrapper,children:(0,K.jsx)(Ut,{className:e.toggleButton,title:n("open",{productName:d}),onClick:Ce,isCollapsed:!0})}),(0,K.jsxs)("div",{className:e.collapsible,children:[u&&(0,K.jsxs)("div",{className:e.loginError,children:[(0,K.jsx)("span",{className:e.loginErrorMessage,children:u}),(0,K.jsx)("button",{type:"button",className:e.loginErrorDismiss,onClick:()=>r(ds()),"aria-label":n("dismissError"),children:n("dismiss")})]}),(0,K.jsx)(Qs,{loginUrl:b,isEmbedded:T,onLogIn:t,onSnooze:_})]})]}):!s||!o?null:(0,K.jsxs)("div",{ref:i,className:(0,Zs.default)(e.root,{[e.isCollapsed]:N}),children:[!N&&(0,K.jsxs)("div",{className:e.triggers,children:[(0,K.jsx)("div",{style:{flex:1},children:g&&(0,K.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(n(Tc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:a.toUpperCase()})),onMouseLeave:()=>m(null),children:(0,K.jsx)(Pc,{title:n("search")})})}),(0,K.jsxs)("div",{className:e.triggersRight,onFocus:()=>{},children:[(0,K.jsx)("div",{className:(0,Zs.default)(!f&&e.hintsHidden,e.hints),children:f}),(0,K.jsx)(Ut,{className:e.toggleButton,title:n("collapse"),onClick:Ce,isCollapsed:!1})]})]}),(0,K.jsx)("div",{className:e.toggleButtonWrapper,children:(0,K.jsx)(Ut,{className:e.toggleButton,title:n("open",{productName:d}),onClick:Ce,isCollapsed:!0})}),Le>0&&h&&(0,K.jsx)("div",{className:e.collapsible,onFocus:()=>{},children:(0,K.jsx)(ie,{children:(0,K.jsx)(Xs,{suggestions:B,selectedIndex:X,reverse:C==="above"})})})]})},Lc=bf;var mr=O(require("classnames")),ep=require("interweave"),ut=require("react"),tp=require("react-redux");var Fn=require("react");function Ys(t){return t.contentEditable==="true"}function Cf(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let s=o.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),n=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:n}}function Ac(t){let{selectionStart:e,selectionEnd:n}=Ys(t)?Cf(t):t;return[e,n]}function Mc(t){let[,e]=(0,Fn.useState)(),n=(0,Fn.useRef)(null);return n.current=Ac(t),(0,Fn.useEffect)(()=>{let o=()=>{var a;let[s,r]=(a=n.current)!=null?a:[],i=Ac(t);(!i||s!==i[0]||r!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function Nc(t,e){if(!e)return;let n=t,{value:o}=n,[s,r]=e,i=o.match(is);if(!i||i.length===0)return;let a=0;i.find(d=>{let l=o.indexOf(d,a);return s>l&&r<l+d.length?(n.selectionStart=l,n.selectionEnd=l+d.length,!0):(a=l+d.length,!1)})}var Oc=require("react"),Tf=["div","span","mark","strong","b","i","u","em"];function Di(t,e,n=0){var r;let o=t[t.length-1],s=typeof o=="object"&&o!==null?(r=o.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,o];if(Tf.includes(s)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),(0,Oc.cloneElement)(o,{children:Di(i,e,n+1)})]}return[...t,...e]}function an(t){return t.tagName.toLowerCase()==="textarea"}var Dc={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 jc=O(require("classnames")),$c=require("interweave"),lr=require("react");var Hn=require("react");function _c(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let s=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(n)]}function er(t){let e=(0,Hn.useRef)(null),[n,o]=(0,Hn.useState)(!1);return(0,Hn.useEffect)(()=>{var c;let s=!1,r=Number.parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[i,a]=_c((u,p)=>{let f=e.current;if(!f)return;let m=u/r,g=p/r,h=f.getBoundingClientRect(),b=m>h.x&&m<h.x+h.width&&g>h.y&&g<h.y+h.height;b&&!s?(s=!0,o(!0)):!b&&s&&(s=!1,o(!1))},({clientX:u,clientY:p})=>[u,p]),[d,l]=_c(()=>{s=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",d),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",d)}},[e]),[e,n]}function Fc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function tr(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function Hc(t){return t!=null}var Fi=O(require("classnames")),Re=require("react");var nr=require("react"),wf=["bottom","height","left","right","top","width"],Ef=(t={},e={})=>wf.some(n=>t[n]!==e[n]),dt=new Map,Bc,Uc=()=>{let t=[],e=[];dt.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let s=o.getBoundingClientRect();Ef(s,n.rect)&&(n.rect=s,t.push(n))}),e.forEach(n=>{dt.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),Bc=window.requestAnimationFrame(Uc)};function kf(t,e){return{observe(){let n=dt.size===0;if(dt.has(t)){let o=dt.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else dt.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&Uc()},unobserve(){let n=dt.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||dt.delete(t),dt.size||cancelAnimationFrame(Bc)}}}}function _i(t){let[e,n]=(0,nr.useState)(null);return(0,nr.useLayoutEffect)(()=>{if(!t.current)return;let o=kf(t.current,s=>{n(s)});return o.observe(),()=>{o.unobserve()}},[t]),e}var Bn=require("react"),zc=require("react-dom");var Kc={root:"dd-r-dgo"};var Wc=({children:t,parentNode:e})=>{let[n,o]=(0,Bn.useState)(null),s=(0,Bn.useContext)(Yn);return(0,Bn.useLayoutEffect)(()=>{let r=document.createElement("div");return rn(r),r.classList.add(Kc.root),s!=null&&s.portalRootNode&&r.classList.add(s==null?void 0:s.portalRootNode),(e||document.body).appendChild(r),o(r),()=>{r.isConnected&&r.remove()}},[]),n?(0,zc.createPortal)(t,n):null};var Ge={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 or=require("react/jsx-runtime"),sr=(t=!1)=>{let[e,n]=(0,Re.useState)(t),o=(0,Re.useCallback)(()=>n(!0),[]),s=(0,Re.useCallback)(()=>n(!1),[]),r=(0,Re.useCallback)(()=>n(a=>!a),[]),i=(0,Re.useRef)(null);return{opened:e,open:o,close:s,toggle:r,triggerRef:i}};function Hi(t,e=null,n=0){if(!t)return{display:"none"};let o=e?t.top-e.top<0||t.top<e.top-n?e.top-n:t.top+t.height>e.top+e.height+n?e.top+e.height+n-t.height:t.top:t.top,s=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:s,height:t.height,width:t.width}}var Un=l=>{var c=l,{className:t,triggerRef:e,boundaryRef:n=(0,Re.createRef)(),position:o="above",align:s="center",children:r,toStyle:i=Hi,parentNode:a}=c,d=M(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let u=_i(e),p=_i(n),f=(0,Re.useMemo)(()=>i(u,p,0),[u,p]);return(0,or.jsx)(Wc,{parentNode:a,children:(0,or.jsx)("div",S(y({className:(0,Fi.default)(Ge.ref,{[Ge.positionAbove]:o==="above",[Ge.positionBelow]:o==="below",[Ge.positionLeft]:o==="left",[Ge.positionRight]:o==="right",[Ge.alignStart]:s==="start",[Ge.alignCenter]:s==="center",[Ge.alignEnd]:s==="end"}),style:f},d),{role:"dialog",children:(0,or.jsx)("div",{className:(0,Fi.default)(t,Ge.root),children:r})}))})};var Vc=O(require("classnames")),rr=require("react");var ct={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 Bi=require("react/jsx-runtime"),ir=(0,rr.forwardRef)((s,o)=>{var r=s,{className:t,children:e}=r,n=M(r,["className","children"]);let i=(0,rr.useRef)(null),a=x("TabCompletion",ct);return(0,Bi.jsx)("div",S(y({ref:tr([i,o]),className:(0,Vc.default)(t,a.popoverContentContainer)},n),{children:(0,Bi.jsx)("div",{className:a.popoverContent,children:e})}))});var At=require("react/jsx-runtime"),Rf=t=>e=>{let n=Hi(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},Pf=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:s})=>{let r=x("TabCompletion",ct),i=sr(),a=(0,lr.useMemo)(()=>Rf(t.getBoundingClientRect()),[t]),[d,l]=er(t);return(0,lr.useEffect)(()=>{l?i.open():i.close()},[l]),(0,At.jsxs)("span",{children:[(0,At.jsx)("mark",{ref:tr([d,i.triggerRef]),className:(0,jc.default)(r.matchKeyword,{[r.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&(0,At.jsx)(Un,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,At.jsx)(ir,{style:n,children:(0,At.jsx)("div",{className:r.hintText,children:s})})})]})},ar=class extends $c.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(s=>S(y({},s),{keywordRegex:new RegExp(`\\b${Fc(s.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=this.preparedKeywordMatches.map(r=>{if(this.usedKeywordMatches.has(r))return null;let i=n.match(r.keywordRegex);if(!i)return null;let a=n.charAt(i.index-1),d=n.charAt(i.index+r.keyword.length);return a==="{"&&d==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:r.suggestion,preparedKeywordMatch:r,valid:!0}}).filter(Hc);if(o.length===0)return null;let s=o.reduce((r,i)=>i.index<r.index?i:r);return this.usedKeywordMatches.add(s.preparedKeywordMatch),s}replaceWith(n,o){return(0,At.jsx)(Pf,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:n},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Gc=require("interweave"),qc=O(require("classnames"));var Ui=require("react/jsx-runtime"),If=({inputElement:t,children:e})=>{let n=x("TabCompletion",ct),[o,s]=er(t);return(0,Ui.jsx)("mark",{ref:o,className:(0,qc.default)(n.matchPlaceholder,{[n.hover]:s}),children:e})},dr=class extends Gc.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,Ui.jsx)(If,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var pr=O(require("classnames")),Yc=require("interweave"),de=require("react"),gr=require("react-redux");var Ki=require("react/jsx-runtime"),Xc=()=>(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"),Ho=require("react-redux"),Qc=O(require("lodash.debounce"));var Jc={root:"dd-ky-Bv",content:"dd-kV5e1"};function cr(t,e,n){var s;let o=((s=t.imageSizes)==null?void 0:s[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(r){return null}}function zi(t){return t.replace("https://www.","").replace("https://","")}var Pe=require("react/jsx-runtime"),Lf=3,Af=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Mf=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:s=Lf})=>{let r=x("LinkSearch",Jc),[i,a]=(0,qe.useState)(""),d=(0,Ho.useDispatch)(),l=(0,Ho.useSelector)(zd("url")),c=(0,Ho.useSelector)(Ul("URL")),u=(0,qe.useMemo)(()=>c.map(Af),[c]),[p,f]=(0,qe.useState)(u.length-1),m=E("fallbackImage"),g=C=>{let w=C.target;a(w.value)},h=(C,w)=>{C.stopPropagation(),C.preventDefault(),window.open(w,"_blank")},b=C=>{var N;let w=p-1<0?u.length-1:p-1,L=p+1===u.length?0:p+1;C.code==="Escape"&&(a(""),e()),C.code==="ArrowUp"&&f(w),C.code==="ArrowDown"&&f(L),C.code==="Enter"&&t(((N=u[p])==null?void 0:N.text)||i)},T=(0,qe.useCallback)((0,Qc.default)(C=>{d(qt({query:C,type:"URL",tags:["link-search"]}))},300),[]);return(0,qe.useEffect)(()=>{i&&T(i)},[i]),(0,qe.useEffect)(()=>()=>{d(vs())},[]),(0,Pe.jsxs)("div",{className:r.root,children:[(0,Pe.jsx)(ie,{withDivider:!0,children:(i?u:l).slice(0,s).map((C,w)=>(0,Pe.jsx)(I,{selected:p===w,onClick:()=>t(C.text),"data-testid":"linksearch-suggestion",children:(0,Pe.jsxs)(F,{children:[(0,Pe.jsx)(F.Image,{src:cr(C,"small",m||void 0),title:C.title||C.text}),(0,Pe.jsxs)(F.Content,{className:r.content,cropText:!0,children:[(0,Pe.jsx)(F.Title,{children:C.title||zi(C.text)}),C.title&&zi(C.text)]}),(0,Pe.jsx)(I.Actions,{children:(0,Pe.jsx)(I.ActionButton,{label:o,onClick:L=>h(L,C.text)})})]})},C.text))}),(0,Pe.jsx)(vo,{value:i,onChange:g,autoFocus:!0,placeholder:n,onKeyUp:b})]})},Zc=Mf;var Wi={};Y(Wi,{enUS:()=>Nf,nlNL:()=>Of});var Nf={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}],addToPersonalCollection:[{type:0,value:"Add to Personal Collection"}]},Of={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}],addToPersonalCollection:[{type:0,value:"Toevoegen aan Personal Collection"}]};var oe=require("react/jsx-runtime"),Df=(0,de.forwardRef)((t,e)=>{let n=x("TabCompletion",ct);return(0,oe.jsx)("mark",{ref:e,className:(0,pr.default)(n.matchSelection)},"selection-start")}),_f=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:s})=>{let r=R(Wi),i=x("TabCompletion",ct),a=E("addToPersonalCollection"),d=(0,gr.useSelector)(kt("/admin/personal-collection/new")),l=(0,de.useRef)(null),c=(0,de.useRef)(null),[u,p]=(0,de.useState)(null),f=(0,gr.useDispatch)(),m=sr(document.activeElement===o),[g]=(0,de.useState)(()=>document.createRange());m.triggerRef.current=g,(0,de.useEffect)(()=>()=>g.detach(),[]),(0,de.useEffect)(()=>{let b=t.current,T=l.current;!b||!T||(g.setStart(b,0),g.setEnd(T,0))},[t.current,l.current]),Rt(()=>{m.close()});let h=(0,de.useCallback)(b=>{let T=g.toString(),C=/^http(s?):\/\//.test(b)?b:`https://${b}`,w=`[${T}](${C})`;f(ye({text:w,suggestion:{text:w,source:"search-url",type:"url"},eventMetrics:{inputType:"mouse"},replace:"selection"}))},[]);return(0,oe.jsxs)("span",{children:[(0,oe.jsx)("mark",{ref:l,className:(0,pr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":m.opened?"true":"false",children:s}),m.opened&&(0,oe.jsx)(Un,{className:i.popoverRoot,triggerRef:m.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,oe.jsxs)(ir,{style:n,ref:c,children:[(0,oe.jsxs)("div",{className:(0,pr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:u!==null}),children:[(0,oe.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,oe.jsx)(Xc,{}),(0,oe.jsx)("span",{children:"\xA0"}),(0,oe.jsx)("span",{children:r("insertLink")})]}),a&&d&&(0,oe.jsx)("button",{type:"button",tabIndex:u===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>{let b=g.toString(),T=`${d}?text=${encodeURIComponent(b)}`;window.open(T,"_blank")},children:(0,oe.jsx)("span",{children:r("addToPersonalCollection")})})]}),u==="insertLink"&&(0,oe.jsx)(Zc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{p(null),m.close()}})]})})]},"selection-end")},ur=class extends Yc.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,de.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,s]=this.props.selection;if(o===s)return null;let r=this.foundIndex===0?o:s,i=r>=this.charCount&&r<=this.charCount+n.length?{index:r-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let a=this.foundIndex===1;return i&&a?this.charCount+=r-this.charCount:this.charCount+=n.length,i?y({isStart:a},i):null}replaceWith(n,o){return o.isStart?(0,oe.jsx)(Df,{ref:this.startRef}):(0,oe.jsx)(_f,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var np=require("react-redux");var pt=require("react/jsx-runtime"),Ff=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:d})=>{let l=x("TabCompletion",Dc),c=E("insertLink"),u=E("addToPersonalCollection"),p=E("showMidSentenceSuggestions"),f=E("inlineSuggestions"),m=Mc(a),g=(0,ut.useRef)(null),h=(0,np.useSelector)(ne);(0,ut.useEffect)(()=>{an(a)&&m&&Nc(a,m)},[m]);let b=(0,ut.useCallback)(w=>{if(!s||!n)return w;let L=[(0,pt.jsx)("span",{className:l.resetIndent,children:"\u200B"},"u200B"),(0,pt.jsx)("span",{"data-testid":"tab-completion",className:(0,mr.default)(l.tabText,l.resetIndent),"data-source":d,children:n},"tabText")];return o&&L.push((0,pt.jsx)("span",{className:(0,mr.default)(l.hint,l.resetIndent),children:(0,pt.jsx)(os,{keyCode:"tab"},"tabHint")},"tabHint")),Di(w,L)},[s,n,o]),T=(0,ut.useMemo)(()=>{let w=[];return(c||u)&&w.push(new ur("selection")),w.push(new dr("placeholders")),r&&w.push(new ar("keywords")),w},[f,c,u,r]),C=(0,ut.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||!h?null:(0,pt.jsxs)("div",{ref:w=>{w!=null&&w.parentElement&&(g.current=w==null?void 0:w.parentElement)},className:l.root,style:C,children:[(0,pt.jsx)(ep.Interweave,{tagName:"span",containerTagName:"div",className:(0,mr.default)(l.container,l.agentText),disableLineBreaks:an(a),content:e||"\u200B",onAfterParse:b,matchers:T,selection:m,keywordMatches:i,inputElement:a,inputStyle:C,boundaryRef:g,inlineSuggestionsOnlyAtEnd:!p}),(0,pt.jsx)("br",{})]},"tab-completion")},Hf=t=>{var h,b,T;let{input:e,ui:n,settings:o,styleSuggestions:s,conversation:r}=t,i=Tn({input:e}),a=(i==null?void 0:i.text)||"",d=(i==null?void 0:i.source)||"",l=(h=e.html)!=null?h:An(e.text),c=a.indexOf(e.text)===0?a.slice(e.text.length):"",{showTabHint:u}=n,{isSupported:p}=r,{showTabCompletion:f,visible:m,showStyleSuggestions:g}=o;return{showTabHint:u,showStyleSuggestions:g,showTabCompletion:f&&$e(t),content:l,tabText:c,source:d,keywordMatches:(T=(b=s.list)==null?void 0:b.keywordMatches)!=null?T:[],enabled:m&&p!==!1}},op=(0,tp.connect)(Hf)(Ff);var Ot=require("react"),q=require("react-redux");var Mt=require("@reduxjs/toolkit");var sp=require("marked"),rp=(t,e)=>{let n=[],o=new sp.Marked,s=r=>{r.type==="code"&&r.lang===e&&n.push(r.text)};return o.use({walkTokens:s}),o.parse(t),n};var ip={cues:[],threads:{},pending:[]},ap=t=>{var e;return(e=t.assistants)==null?void 0:e.cues};var lp=t=>e=>{var n,o;return(o=(n=e.assistants)==null?void 0:n.threads[t])!=null?o:null},fr=(0,Mt.createAction)("assistants/callToAction"),Bo=(0,Mt.createAsyncThunk)("assistants/evaluateKnowledgeAssistant",(t,e)=>v(null,null,function*(){var l;let{threadId:n}=t,{onNewThreadId:o}=t,{deepdeskAPI:s}=e.extra,r=e.getState(),{platformVariables:i}=r.info;n||(n=(yield s.createAssistantThread({assistantCode:t.assistantCode})).id,o&&o(n)),yield s.postMessageToAssistantThread({assistantCode:t.assistantCode,threadId:n,message:t.input});let a=yield e.dispatch(Xe(S(y({skipState:!0},t),{input:{},threadId:n})));if(a.error)throw new Error(a.error.message);let d=a.payload.output[0];return{threadId:n,question:t.input,evaluationId:a.payload.evaluationId,answer:{answer:Ne(d.response,i!=null?i:{}),sources:(l=d.sources)!=null?l:[]}}})),Sk=(0,Mt.createAction)("assistants/extractedTextSuggestions"),Xe=(0,Mt.createAsyncThunk)("assistants/evaluate",(t,e)=>v(null,null,function*(){var g;let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra,{transcript:s,input:r={},threadId:i}=t,a=e.getState(),{platformVariables:d}=a.info,l=(g=a.conversation.current)==null?void 0:g.externalId,c;if(s==="in-memory-transcript"){if(!o.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");c=yield o.conversationQuery()}else Array.isArray(s)&&(c=s);if(t.includeMetadata){if(!a.conversation.current)throw new Error("Can't include metadata, no current conversation");let{metadata:h}=a.conversation.current;Object.assign(r,{metadata:h})}let u=yield n.evaluateAssistant(t.assistantCode,{input:r,transcript:c,externalConversationId:l,threadId:i});if(u.evaluationStatus!=="success")return e.rejectWithValue(`Assistant ${t.assistantCode} evaluation failed: ${u.evaluationStatus}`);let f=(Array.isArray(u.output)?u.output:[u.output]).map(h=>S(y({},h),{name:Ne(h.name,d),response:Ne(h.response,d)})),m=[];return f.forEach(h=>{let b=rp(h.response,"reply"),T=b.length>0?b:[h.response];m.push(...T.map(C=>({text:C,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name})))}),m.length>0&&e.dispatch(wn(m)),S(y({},u),{output:f})})),dp=(0,Mt.createSlice)({name:"assistants",initialState:ip,reducers:{resetCues(t){t.cues=[]},removeCueByCode(t,e){t.cues=t.cues.filter(n=>n.code!==e.payload.code)},removeThreadById(t,e){delete t.threads[e.payload]},receiveChunk(t,e){let{code:n,name:o,payload:s,evaluationId:r}=e.payload,i=t.cues.findIndex(a=>a.code===n);i!==-1?t.cues[i].response+=s.text:t.cues.push({code:n,name:o,evaluationId:r,response:s.text})},userNotification(t,e){let n=t.cues.filter(d=>d.code!==e.payload.code),{code:o,name:s,evaluationId:r,payload:i}=e.payload,{callToAction:a}=i;t.cues=[...n,{code:o,name:s,evaluationId:r,response:i.message,editable:i.editableMessage,callToAction:a&&{label:a.displayName,event:a.onClickEvent,value:a.eventPayload}}]}},extraReducers:t=>{t.addCase(Xe.pending,(e,n)=>{e.pending.includes(n.meta.arg.assistantCode)&&k.warn(`Assistant ${n.meta.arg.assistantCode} already evaluating`),e.pending.push(n.meta.arg.assistantCode)}).addCase(Xe.rejected,(e,n)=>{var s;k.warn((s=n.error)==null?void 0:s.message);let o=e.pending.indexOf(n.meta.arg.assistantCode);o!==-1&&e.pending.splice(o,1)}).addCase(Xe.fulfilled,(e,n)=>{let o=e.pending.indexOf(n.meta.arg.assistantCode);if(o!==-1&&e.pending.splice(o,1),n.meta.arg.skipState)return;let{evaluationId:s,output:r}=n.payload,i=r.map(l=>l.code),a=e.cues.filter(l=>!i.includes(l.code)),d=r.map(l=>S(y({},l),{evaluationId:s}));e.cues=[...a,...d]}).addCase(Bo.fulfilled,(e,n)=>{let r=n.payload,{threadId:o}=r,s=M(r,["threadId"]);e.threads[o]=[...e.threads[o]||[],s]}).addCase(J,()=>ip)}}),{removeCueByCode:hr,resetCues:bk,removeThreadById:cp,receiveChunk:pp,userNotification:up}=dp.actions,gp=dp.reducer;var Uo=require("@reduxjs/toolkit");var Bf={token:null,interval:null},Vi=(0,Uo.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),ji=(0,Uo.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(Vi()),setInterval(()=>o(Vi()),n)}),mp=(0,Uo.createSlice)({name:"passwordlessToken",initialState:Bf,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(ji.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollPasswordlessToken:fp}=mp.actions,hp=mp.reducer;var yp=require("@reduxjs/toolkit");function Uf(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}var vp=(0,yp.createSelector)([ap],t=>t.map(n=>({text:n.response,title:n.name,callToAction:n.callToAction,editable:n.editable,isLoading:n.isLoading,evaluationId:n.evaluationId,rule:{id:Uf(n.code),label:n.code,name:n.name,description:n.name}})));var yr=require("react"),Gi=O(require("classnames"));var $i=require("react/jsx-runtime"),Kn=()=>(0,$i.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,$i.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 xp={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"),Kf=({entities:t})=>{let e=x("EntitiesWidgetList",xp),[n,o]=(0,yr.useState)(void 0),s=V(),r=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),We(a.text),s("entity copied",{entity:a,type:"copy"}))};return(0,yr.useEffect)(()=>{let a=setTimeout(r,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,Gi.default)(e.icon),children:(0,Je.jsx)(Kn,{})}),(0,Je.jsx)("span",{className:(0,Gi.default)(e.icon,n===d&&e.iconClicked),children:(0,Je.jsx)(Kn,{})})]})]},a.text))})},Sp=Kf;var qi=require("react/jsx-runtime"),bp=()=>(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 Ip=require("react"),Lp=require("react-redux");var zn=require("react"),Cp=require("react-redux");function vr(t,e){let n=(0,zn.useRef)(t);n.current=t;let[o,s]=(0,zn.useState)(void 0),[r,i]=(0,zn.useState)(void 0),[a,d]=(0,zn.useState)("idle"),l=(0,Cp.useDispatch)();return{error:r,state:a,data:o,call:p=>v(null,null,function*(){d("loading"),yield l(n.current(p)).unwrap().then(f=>{s(f),d("done"),e!=null&&e.onSuccess&&(e==null||e.onSuccess(f))}).catch(f=>{i(f),d("error"),e!=null&&e.onError&&(e==null||e.onError(f))})}),reset:()=>{d("idle"),s(void 0),i(void 0)}}}var Tp={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var wp={root:"dd-nazq3",rotation:"dd-3EHTv"};var kp=require("react/jsx-runtime"),zf=({size:t=12})=>{let e=x("LoadingSpinner",wp);return(0,kp.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},Ep=zf;var Xi=require("react/jsx-runtime"),Rp=()=>(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 Ko=require("react/jsx-runtime"),Pp=t=>(0,Ko.jsxs)("svg",S(y({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},t),{children:[(0,Ko.jsx)("title",{id:"checkTitle",children:"Check"}),(0,Ko.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 Ji={};Y(Ji,{enUS:()=>Wf,nlNL:()=>Vf});var Wf={error:[{type:0,value:"Something went wrong"}]},Vf={error:[{type:0,value:"Er ging iets fout"}]};var be=require("react/jsx-runtime"),jf=3e3,$f=({assistantOptions:t})=>{let e=x("OnDemandAssistants",Tp),n=R(Ji),o=(0,Ip.useRef)(),s=vr(Xe),r=(0,Lp.useSelector)(dd),i=V(),a=r.filter(c=>c.isPinned),d=r.filter(c=>!c.isPinned),l=c=>v(null,null,function*(){clearTimeout(o.current),i("trigger on demand assistant",{assistantCode:c}),yield s.call(S(y({},t),{assistantCode:c})),o.current=setTimeout(()=>s.reset(),jf)});return r.length===0?null:(0,be.jsxs)("div",{className:e.root,children:[a.map(({assistant:c,assistantName:u,displayName:p})=>(0,be.jsx)("button",{type:"button",className:e.button,disabled:s.state==="loading",onClick:()=>l(c),children:p||u},c)),d.length>0&&(0,be.jsxs)(ee,{placement:"top-end",children:[(0,be.jsx)(ee.Trigger,{className:e.trigger,disabled:s.state==="loading",children:(0,be.jsx)(Bs,{"data-testid":"trigger"})}),(0,be.jsx)(ee.Content,{className:e.nav,"data-testid":"popover",children:d.map(({assistant:c,assistantName:u,displayName:p})=>(0,be.jsx)(ee.Button,{className:e.item,disabled:s.state==="loading",onClick:()=>l(c),children:p||u},c))})]}),s.state==="loading"&&(0,be.jsx)(Ep,{}),s.state==="done"&&(0,be.jsx)(Pp,{"data-testid":"trigger-done"}),s.state==="error"&&(0,be.jsx)(wd,{trigger:(0,be.jsx)(Rp,{}),children:n("error")})]})},Ap=$f;var zp=require("react-redux");var Op=require("react");var Mp={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var Np=require("react/jsx-runtime"),Gf=({width:t})=>{let e=x("LoadingProgressBar",Mp);return(0,Np.jsx)("div",{className:e.loadingBar,style:{width:t}})},xr=Gf;var gt=require("react/jsx-runtime"),Sr=({title:t})=>{let e=(0,Op.useRef)(null);return ss(e),(0,gt.jsx)(I,{ref:e,children:(0,gt.jsx)(F,{children:(0,gt.jsxs)(F.Content,{children:[(0,gt.jsx)(F.Title,{children:t}),(0,gt.jsx)(xr,{width:"60%"}),(0,gt.jsx)(xr,{width:"90%"}),(0,gt.jsx)(xr,{width:"50%"})]})})})};var zo={};Y(zo,{enUS:()=>qf,nlNL:()=>Xf});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"}]},Xf={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 dn=require("react");var br=O(require("classnames")),Fp=require("react");var Qi=require("react/jsx-runtime"),Zi=t=>(0,Qi.jsx)("svg",S(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Qi.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 Yi=require("react/jsx-runtime"),Dp=t=>(0,Yi.jsx)("svg",S(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Yi.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 Nt(t,e){var s;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(r=>{n.classList.add(r)}),n.addEventListener("animationend",()=>n.remove()),(s=t.parentElement)==null||s.appendChild(n)}var ea={};Y(ea,{enUS:()=>Jf,nlNL:()=>Qf});var Jf={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},Qf={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var _p={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};var ta=require("react-redux");var mt=require("react/jsx-runtime"),Zf=({assistantCode:t,assistantOutput:e,evaluationId:n,feedbackType:o,feedbackText:s})=>{let r=x("FeedbackThumbs",_p),i=E("enableFeedbackForm"),a=(0,ta.useSelector)(ze),d=(0,ta.useSelector)(kt(`/admin/feedback?conversationId=${a}&evaluationId=${n}&type=${o}&text=${s}&assistantCode=${t}&assistantOutput=${e}`)),l=R(ea),c=V(),[u,p]=(0,Fp.useState)(null),f=h=>{c("Assistant response feedback",{assistantCode:t,assistantOutput:e,evaluationId:n,rating:h})},m=h=>{h.stopPropagation(),Nt(h.target,r.fadeup),p("up"),f("up")},g=h=>{h.stopPropagation(),Nt(h.target,r.fadedown),p("down"),f("down")};return(0,mt.jsxs)("div",{className:r.thumbs,children:[(0,mt.jsx)(I.Button,{title:l("thumbsUp"),onClick:m,icon:(0,mt.jsx)(Dp,{}),className:(0,br.default)(r.thumbsUp,u==="up"&&r.selected),disabled:!!u}),i&&d?(0,mt.jsx)(I.Button,{as:"a",title:l("thumbsDown"),href:d,target:"_blank",rel:"noreferrer",onClick:g,icon:(0,mt.jsx)(Zi,{}),className:(0,br.default)(r.thumbsDown,u==="down"&&r.selected),disabled:!!u}):(0,mt.jsx)(I.Button,{title:l("thumbsDown"),onClick:g,icon:(0,mt.jsx)(Zi,{}),className:(0,br.default)(r.thumbsDown,u==="down"&&r.selected),disabled:!!u})]})},Cr=Zf;var Bp=O(require("dompurify")),ft=require("react");var Hp={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 Up=require("marked"),Ue=require("react/jsx-runtime");function Yf(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 na(t){var n,o;let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(s=>s.remove()),(o=(n=e.textContent)==null?void 0:n.trim())!=null?o:""}function eh(t){return t.replace(/\r\n/g,`
|
|
8
|
-
`)}var th=({content:t,useLabel:e,copyLabel:n,onCopy:o,onUse:s})=>{let r=x("Markdown",Hp),i=(0,ft.useRef)(null),[a,d]=(0,ft.useState)(null),l=(0,ft.useMemo)(()=>{let g=Up.marked.parse(eh(t));return Bp.default.sanitize(g.toString()).replaceAll("</code>",`${Yf(r.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[t]),c=g=>{var T;let h=g.target,b=!!((T=i.current)!=null&&T.querySelector("code"));if(["A","BUTTON"].includes(h.tagName)){d(null);return}a||b&&h.tagName!=="CODE"||!b&&h!==i.current||(h.addEventListener("mouseleave",()=>d(null),{once:!0}),d(h))},u=()=>{if(!a)return;d(null);let g=a.querySelector("button");g&&(Nt(g,r.fadeup),o==null||o(na(a)))},p=g=>{let h=g.target,b=h instanceof HTMLElement?h:null;if(h instanceof Element?h.closest("a"):null){g.stopPropagation();return}b&&"copyIcon"in b.dataset&&(Nt(b,r.fadeup),o==null||o(na(b.parentElement)))},f=()=>{!a||!s||(d(null),s(na(a)))},m=g=>{if(g===null)return;let h=g.getBoundingClientRect();h.left<0?g.style.transform=`translateX(${-h.left+2}px)`:h.right>window.innerWidth&&(g.style.transform=`translateX(${window.innerWidth-h.right-2}px)`)};return(0,Ue.jsxs)(ft.Fragment,{children:[a&&(o||s)&&(0,Ue.jsxs)(Un,{triggerRef:{current:a},className:r.popover,parentNode:a,children:[(0,Ue.jsxs)("div",{className:r.options,ref:m,children:[o&&(a==null?void 0:a.tagName)==="CODE"&&(0,Ue.jsx)("button",{type:"button",className:r.option,onClick:u,children:n}),s&&(0,Ue.jsxs)(ft.Fragment,{children:[(0,Ue.jsx)("div",{className:r.divider}),(0,Ue.jsx)("button",{type:"button",className:r.option,onClick:f,children:e})]})]}),(0,Ue.jsx)("div",{className:r.arrow})]}),(0,Ue.jsx)("div",{ref:i,"data-testid":"widget-markdown-content",className:r.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:c,onClick:p})]})},ln=th;var oa={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 ce=require("react/jsx-runtime"),nh=500,oh=100,sh=({content:t,onChange:e,onCopy:n})=>{let o=(0,dn.useRef)(null),s=x("WidgetCue",oa);return(0,dn.useEffect)(()=>{let r=o.current;if(!r)return;r.style.setProperty("height","0px");let i=Math.min(Math.max(r.scrollHeight,oh),nh);r.style.setProperty("height",`${i}px`)},[t]),(0,ce.jsx)("textarea",{ref:o,className:s.editableCue,onCopy:n,onChange:e,value:t})},rh=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:s})=>{let r=x("WidgetCue",oa),i=R(zo),a=V(),d=E("hasKeyboardInput"),[l,c]=(0,dn.useState)(t.text),u=()=>{e&&e(l,t),n(t)},p=(g,h)=>{o&&o(g,t),h&&Nt(h,r.fadeup)},f=g=>{s&&s(g,t)},m=g=>{g.preventDefault(),g.stopPropagation(),n(t)};return(0,dn.useEffect)(()=>{a("Assistant response displayed",{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text})},[]),(0,ce.jsxs)(I,{"data-testid":"cue",children:[(0,ce.jsx)(F,{children:(0,ce.jsxs)(F.Content,{children:[t.title&&(0,ce.jsx)(F.Title,{className:r.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?i(t.rule.label):t.title}),t.editable?(0,ce.jsx)(sh,{content:l,onCopy:()=>{let g=document.getSelection();g&&p(g.toString())},onChange:g=>{var h;return c((h=g.target.value)!=null?h:"")}}):(0,ce.jsx)(ln,{content:t.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:p,onUse:d?f:void 0})]})}),(0,ce.jsxs)(I.ButtonsContainer,{children:[(0,ce.jsxs)("div",{className:r.actions,children:[(0,ce.jsx)(I.Button,{onClick:g=>p(l,g.target),variant:"primary",children:i("copyCue")}),t.callToAction&&(0,ce.jsx)(I.Button,{onClick:u,variant:"primary",children:t.callToAction.label}),(0,ce.jsx)(I.Button,{onClick:m,variant:"secondary",children:i("removeCue")})]}),(0,ce.jsx)(Cr,{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text,feedbackText:t.text,feedbackType:"assistant"})]})]})},Kp=rh;var Wn=require("react/jsx-runtime"),ih=({cues:t})=>{let e=(0,zp.useDispatch)(),n=me(),o=R(zo),s=V(),r=l=>{e(hr({code:l.rule.label})),s("Assistant response closed",{evaluationId:l.evaluationId,assistantCode:l.rule.label,assistantOutput:l.text})},i=(l,c)=>{We(l),s("Assistant response copied",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,copiedText:l})},a=(l,c)=>{var u;c.callToAction&&(e(fr(c)),s("Assistant call to action",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,eventName:c.callToAction.event,value:(u=c.callToAction.value)!=null?u:l}))},d=(l,c)=>{var u;n.send(nt,{text:l,suggestion:{source:"assistant",assistantCode:(u=c.rule)==null?void 0:u.label,sourceText:l}}),s("Assistant response used",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,usedText:l})};return(0,Wn.jsx)(Wn.Fragment,{children:t.map(l=>l.isLoading?(0,Wn.jsx)(Sr,{title:l.rule.label.startsWith("__")?o(l.rule.label):l.title},l.rule.id):(0,Wn.jsx)(Kp,{cue:l,onCallToAction:a,onRemove:r,onCopy:i,onUse:d},l.evaluationId))})},Wp=ih;var Tr=require("react");var Vp={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var he=require("react/jsx-runtime");function ah(t,e){return e.split(".").reduce((n,o)=>!n||typeof n!="object"||!(o in n)?null:n[o],t)}var jp=({data:t,schema:e})=>{let n=x("WidgetCustomData",Vp),o=s=>{We(s)};return(0,Tr.useEffect)(()=>{k.info("Custom data",t,e)},[t]),(0,he.jsx)("dl",{className:n.root,children:e.map(s=>{let r=ah(t,s.path);return(0,he.jsxs)(Tr.Fragment,{children:[(0,he.jsx)("dt",{className:n.label,children:s.label}),(0,he.jsx)("dd",{className:n.value,children:s.type==="boolean"&&r?(0,he.jsx)("span",{className:n.isTrue,children:s.trueValue}):s.type==="boolean"&&!r?(0,he.jsx)("span",{className:n.isFalse,children:s.falseValue}):s.type==="array"&&Array.isArray(r)&&r.length>0?(0,he.jsxs)("button",{type:"button",onClick:()=>o(r.join(", ")),className:n.copyButton,children:[(0,he.jsx)("span",{className:n.copyButtonText,children:r.join(", ")}),(0,he.jsx)(Kn,{})]}):typeof r=="string"||typeof r=="number"?(0,he.jsxs)("button",{type:"button",onClick:()=>o(`${r}`),className:n.copyButton,children:[(0,he.jsx)("span",{className:n.copyButtonText,children:r}),(0,he.jsx)(Kn,{})]}):"-"})]},s.label)})})};var j=require("react"),Er=require("react-redux");var Vn={};Y(Vn,{enUS:()=>lh,nlNL:()=>dh});var lh={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"}]},dh={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 wr={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 Gp=require("react");var $p={error:"dd-CoAuB"};var sa={};Y(sa,{enUS:()=>ch,nlNL:()=>ph});var ch={errorPrefix:[{type:0,value:"Error:"}]},ph={errorPrefix:[{type:0,value:"Foutmelding:"}]};var Wo=require("react/jsx-runtime"),qp=({message:t})=>{let e=(0,Gp.useRef)(null),n=x("WidgetCardError",$p),o=R(sa);return ss(e),(0,Wo.jsx)(I,{ref:e,children:(0,Wo.jsx)(F,{children:(0,Wo.jsxs)(F.Content,{className:n.error,children:[o("errorPrefix")," ",t]})})})};var D=require("react/jsx-runtime"),uh=3,gh=({sources:t,onClick:e})=>{let n=R(Vn),o=x("WidgetKnowledgeAssistant",wr),[s,r]=(0,j.useState)(!1),i=s?t:t.slice(0,uh);return i.length===0?null:(0,D.jsxs)("ul",{className:o.sources,children:[i.map(a=>(0,D.jsx)("li",{className:o.source,"data-testid":"knowledge-assist-source",children:(0,D.jsxs)(ee,{tooltip:!0,placement:"top-start",children:[(0,D.jsx)(ee.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:d=>{d.stopPropagation(),e(a)},children:(0,D.jsx)("span",{className:o.linkContent,children:a.name})}),a.url&&(0,D.jsx)(ee.Content,{className:o.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),i<t&&(0,D.jsx)("button",{type:"button",className:o.showMoreSources,onClick:()=>r(!0),children:n("showMore",{amount:t.length-i.length})})]})},mh=({title:t,description:e})=>(0,D.jsx)(I,{"data-testid":"knowledge-assist-empty-state",children:(0,D.jsx)(F,{children:(0,D.jsxs)(F.Content,{children:[(0,D.jsx)(F.Title,{children:t}),(0,D.jsx)(ln,{content:e})]})})}),fh=({innerRef:t,item:e,hasKeyboardInput:n,onCopy:o,onUse:s,onSourceClick:r})=>{var d;let i=R(Vn),a=(0,j.useContext)(kr);return(0,D.jsxs)(I,{"data-testid":"knowledge-assist-answer",ref:t,children:[(0,D.jsx)(F,{children:(0,D.jsxs)(F.Content,{children:[(0,D.jsx)(F.Title,{children:e.question}),(0,D.jsx)(ln,{content:e.answer.answer,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:o,onUse:n?s:void 0}),(0,D.jsx)(gh,{sources:(d=e.answer.sources)!=null?d:[],onClick:r})]})}),a.assistantCode&&(0,D.jsxs)(I.ButtonsContainer,{children:[(0,D.jsx)("div",{}),(0,D.jsx)(Cr,{evaluationId:e.evaluationId,feedbackType:"assistant",assistantCode:a.assistantCode,assistantOutput:e.answer.answer,feedbackText:e.answer.answer})]})]})},kr=(0,j.createContext)(null),Rr=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,children:o})=>{let[s,r]=(0,j.useState)(null),[i,a]=(0,j.useState)(!1),[d,l]=(0,j.useState)(null),[c,u]=(0,j.useState)(!!n),[p,f]=(0,j.useState)(null),m=(0,Er.useDispatch)(),g=V(),h=vr(C=>{if(!t)throw new Error("No knowledge assistant was defined");return l(null),e({assistantCode:t,input:C,threadId:s,onNewThreadId(w){r(w)}})},{onSuccess(C){var w;g("Assistant response displayed",{evaluationId:C.evaluationId,assistantCode:t,assistantOutput:C.answer.answer,input:C.question,sources:(w=C.answer.sources)!=null?w:[]}),u(!1)},onError(C){var w;l((w=C.message)!=null?w:"Unknown error")}}),b=C=>v(null,null,function*(){a(!0),f(C),yield h.call(C),a(!1),f(null)}),T={isEnabled:!!t,assistantCode:t,isSubmitting:i,threadId:s,pendingInput:p,errorMessage:d,onSubmit:b,onReset(){s&&m(cp(s)),l(null),r(null),t&&g("Assistant thread reset",{threadId:s!=null?s:void 0,assistantCode:t})}};return(0,j.useEffect)(()=>{n&&T.isEnabled&&b(n)},[n]),(0,D.jsx)(kr.Provider,{value:T,children:o})},Pr=()=>{let t=R(Vn),e=x("WidgetKnowledgeAssistant",wr),n=(0,j.useContext)(kr),o=(0,j.useRef)(null),[s,r]=(0,j.useState)(""),i=d=>{r(d.target.value)},a=d=>{d.preventDefault(),n.onSubmit(s).then(()=>{var l;o.current&&((l=o.current)==null||l.focus(),r(""))})};return n.isEnabled?(0,D.jsxs)("form",{className:e.form,onSubmit:a,children:[(0,D.jsx)("input",{ref:o,className:e.formInput,placeholder:t("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:s,onChange:i}),(0,D.jsx)("button",{type:"submit",disabled:n.isSubmitting||s==="",className:e.formSubmit,children:t("submitLabel")})]}):null},Ir=({title:t,emptyState:e})=>{var m,g;let n=R(Vn),o=V(),s=x("WidgetKnowledgeAssistant",wr),r=(0,j.useRef)(null),i=(0,j.useContext)(kr),a=(g=(0,Er.useSelector)(lp((m=i.threadId)!=null?m:-1)))!=null?g:[],d=E("hasKeyboardInput"),l=me(),c=(h,b)=>{We(h),i.assistantCode&&o("Assistant response copied",{assistantCode:i.assistantCode,assistantOutput:h,copiedText:h,evaluationId:b.evaluationId})},u=(h,b)=>{i.assistantCode&&o("Assistant source clicked",{evaluationId:b.evaluationId,assistantCode:i.assistantCode,source:h})},p=h=>{h.preventDefault(),i.onReset()},f=(h,b)=>{l.send(nt,{text:h,suggestion:{source:"assistant",sourceText:h}}),i.assistantCode&&o("Assistant response used",{assistantCode:i.assistantCode,evaluationId:b.evaluationId,assistantOutput:b.answer.answer,usedText:h})};return!i.isEnabled||(a==null?void 0:a.length)===0&&!i.isSubmitting&&!e&&!i.errorMessage?null:(0,D.jsxs)(j.Fragment,{children:[(0,D.jsx)(Ke,{type:"knowledge",title:t,"data-testid":"knowledge",children:(0,D.jsxs)(ie,{withDivider:!0,children:[e&&a.length===0&&!i.pendingInput&&(0,D.jsx)(mh,y({},e)),a.map((h,b)=>(0,D.jsx)(fh,{innerRef:b===a.length-1?r:void 0,item:h,hasKeyboardInput:d,onCopy:T=>c(T,h),onUse:T=>f(T,h),onSourceClick:T=>u(T,h)},`${h.question}_${h.answer}_${b}`)),i.pendingInput&&(0,D.jsx)(Sr,{title:i.pendingInput}),i.errorMessage&&(0,D.jsx)(qp,{message:i.errorMessage})]})}),a.length>0&&(0,D.jsx)("div",{className:s.resetContainer,children:(0,D.jsx)(I.Button,{disabled:i.threadId===null||i.isSubmitting,onClick:p,children:n("resetLabel")})})]})};var Qp=require("react");var hh=/(https?:\/\/[^\s]+)/,Jp=t=>t.split(" ").find(e=>hh.test(e));var Ie=require("react/jsx-runtime"),yh=({suggestion:t,lines:e,onUse:n})=>{var u;let o=t.text||t.url||t.message,s=Jp(o),r=R(Po),i=E("showImages"),a=E("fallbackImage"),d=E("hasKeyboardInput"),l=p=>{p.preventDefault(),p.stopPropagation(),d&&n(o)},c=(0,Qp.useCallback)(p=>{window.open(s,"_blank"),p.stopPropagation(),p.preventDefault()},[s]);return(0,Ie.jsxs)(I,{onClick:d?l:void 0,"data-testid":"edit-suggestion",children:[(0,Ie.jsxs)(F,{children:[i&&t.image&&(0,Ie.jsx)(F.Image,{src:cr(t,"small",a||void 0),title:t.title}),(0,Ie.jsxs)(F.Content,{children:[t.title&&(0,Ie.jsx)(F.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,Ie.jsx)(I.Labels,{labels:t.searchKeywords}),(0,Ie.jsx)(F.Content,{cropText:e==="single",lineClamp:e==="multiple",children:o})]})]}),(0,Ie.jsxs)(I.Actions,{children:[s&&(0,Ie.jsx)(I.ActionButton,{onClick:c,label:r("visitUrl")}),d&&(0,Ie.jsx)(I.ActionButton,{primary:!0,onClick:l,label:r("useSuggestion")})]})]})},Zp=yh;var Vo=require("react/jsx-runtime"),vh=({lines:t,suggestions:e})=>{let n=me(),o=(s,r)=>{n.send(nt,{text:s,suggestion:S(y({},r),{source:r.source,sourceText:r.text})})};return(0,Vo.jsx)(Vo.Fragment,{children:e.map(s=>(0,Vo.jsx)(Zp,{suggestion:s,lines:t,onUse:r=>o(r,s)},s.text||s.url||s.message))})},Yp=vh;var jo={};Y(jo,{enUS:()=>xh,nlNL:()=>Sh});var xh={waiting:[{type:0,value:"Loading\u2026"}],waitingForConversation:[{type:0,value:"Waiting for conversation\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}],close:[{type:0,value:"Close"}]},Sh={waiting:[{type:0,value:"Laden\u2026"}],waitingForConversation:[{type:0,value:"Wachten op gesprek\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}],close:[{type:0,value:"Sluiten"}]};var 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)(ne);(0,Ot.useEffect)(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},bh=({onLogIn:t})=>{let e=x("Widget",jn),n=E("isEmbedded"),o=E("adminUrl");return(0,P.jsx)("div",{className:e.loginText,children:(0,P.jsx)("div",{children:(0,P.jsx)(Qs,{isEmbedded:n,loginUrl:o,onLogIn:t})})},"login")},ra=({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")},Ch=()=>{let t=R(jo),e=(0,q.useDispatch)(),n=x("Widget",jn),o=E("showSearch"),s=E("isEmbedded"),r=(0,q.useSelector)(kt("/admin/")),i=me(),a=E("productName"),d=V();return eu(()=>{if(s)return e(ji()),()=>{e(fp())}},[e,s]),!o&&!r?null:(0,P.jsxs)("div",{className:n.shortcutList,children:[o&&(0,P.jsx)(I.Button,{"data-testid":"shortcut-search","aria-label":t("linkSearch"),className:n.shortcut,icon:(0,P.jsx)(Nn,{}),onClick:()=>{i.send("ShowCommandPalette",{isOpen:!0}),d("open search",{via:"widget-shortcut"})},children:t("linkSearch")}),r&&(0,P.jsx)(I.Button,{as:"a",target:"_blank",icon:(0,P.jsx)(bp,{}),href:r,"data-testid":"shortcut-studio-login","aria-label":t("linkStudioLogin",{productName:a}),className:n.shortcut,rel:"noreferrer",onClick:()=>{d("open my deepdesk",{via:"widget-shortcut"})},children:t("linkStudioLogin",{productName:a})})]})},Th=({title:t,content:e})=>{let n=R(jo),[o,s]=(0,Ot.useState)(!0);return o?(0,P.jsx)(Ke,{"data-testid":"custom-data-banner",type:"custom-data-banner",title:t,children:(0,P.jsx)(ie,{withDivider:!0,children:(0,P.jsxs)(I,{children:[(0,P.jsx)(F,{children:(0,P.jsx)(F.Content,{children:(0,P.jsx)(ln,{content:e})})}),(0,P.jsx)(I.ButtonsContainer,{children:(0,P.jsx)(I.Button,{onClick:()=>s(!1),children:n("close")})})]})})}):null},wh=()=>{let t=(0,q.useDispatch)(),e=(0,q.useSelector)(bo),n=(0,q.useSelector)(pd),o=(0,q.useSelector)(vp),s=(0,q.useSelector)(Il),r=(0,q.useSelector)(Fs),i=(0,q.useSelector)(Ws),a=(0,q.useSelector)(Jt),d=(0,q.useSelector)(ze);return(0,Ot.useEffect)(()=>{s&&!n&&k.warn("Custom data provided, but no schema.")},[s,n]),eu(()=>{e.forEach(({type:l})=>{l==="entities"?t(Fe()):as.includes(l)||t(He(l))})},[t,d,a]),(0,Ot.useEffect)(()=>{o.length>0&&!e.some(l=>l.type==="cues")&&k.warn("Received cues, but cues are not configured in widget.")},[e,o]),(0,P.jsx)(Ot.Fragment,{children:e.map(({type:l,title:c,amount:u,lines:p,schema:f,property:m})=>{var g,h;switch(l){case"entities":return r&&r.length>0&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(Sp,{entities:r})},l);case"cues":return o&&o.length>0&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ie,{withDivider:!0,children:(0,P.jsx)(Wp,{cues:o})})},l);case"custom-data-banner":return s&&m&&s[m]&&(0,P.jsx)(Th,{title:c,content:String(s[m])},l);case"custom-data":return s&&f&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ie,{withDivider:!0,children:(0,P.jsx)(jp,{data:s,schema:f})})},l);default:return((h=(g=i[l])==null?void 0:g.suggestions)==null?void 0:h.length)>0&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ie,{withDivider:!0,children:(0,P.jsx)(Yp,{lines:p,contentType:l,suggestions:i[l].suggestions.slice(0,u)||[]})})},l)}})})},ia=({children:t})=>{let e=x("Widget",jn);return(0,P.jsx)("div",{className:e.footer,children:t})},aa=({children:t})=>{let e=x("Widget",jn);return(0,P.jsx)("div",{className:e.root,"data-testid":"widget",children:t})},Eh=({onLogIn:t,knowledgeAssistOptions:e={},assistantOptions:n={transcript:"in-memory-transcript"}})=>{let o=R(jo),s=(0,q.useSelector)(bn),r=(0,q.useSelector)(ne),i=(0,q.useSelector)(ul),a=(0,q.useSelector)(Jt),d=(0,q.useSelector)(cd("knowledge-assist")),l=(0,q.useSelector)(ud);return s===!1?(0,P.jsx)(ra,{text:o("notSupported")}):r===!1?(0,P.jsx)(bh,{onLogIn:t}):r===null?(0,P.jsx)(ra,{text:o("waiting")}):!i||!a?(0,P.jsx)(ra,{text:o("waitingForConversation")}):(0,P.jsx)(aa,{children:(0,P.jsxs)(Rr,{initialQuestion:e.initialQuestion,assistantCode:l!=null?l:void 0,evaluateKnowledgeAssistFn:Bo,children:[(0,P.jsxs)(hn,{children:[(0,P.jsx)(Ch,{}),(0,P.jsx)(wh,{}),d&&(0,P.jsx)(Ir,{title:d.title,emptyState:e.emptyState})]}),(0,P.jsxs)(ia,{children:[d&&(0,P.jsx)(Pr,{}),(0,P.jsx)(Ap,{assistantOptions:n})]})]})})},tu=Eh;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 Lr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Ar(t){return"tagName"in t&&t.tagName==="BR"}var $o=/[\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 s=0,r=!1;function i(d,l){let c=-1,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(d))return l;for(let p=0;p<=d.length;p++)if(u.test(d[p])||c++,c===l)return p;throw new Error("Offset out of range")}function a(d){switch(d.nodeType){case Node.TEXT_NODE:{let l=d.textContent,c=l.replace($o,""),u=s+c.length,p=e>=s&&e<=u,f=n>=s&&n<=u;if(p){let m=i(l,e-s);m===0&&!f?o.setStartBefore(d):o.setStart(d,m)}f&&(o.setEnd(d,i(l,n-s)),r=!0),s=u;break}case Node.ELEMENT_NODE:{if(Ar(d)&&(s===e&&o.setStartBefore(d),s++,s===n)){o.setEndAfter(d),r=!0;return}for(let c=0;c<d.childNodes.length&&(a(d.childNodes[c]),!r);c++);let l=d.lastChild;Lr(d)&&l&&!Lr(l)&&!Ar(l)&&s++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}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:s,endOffset:r,collapsed:i}=e,a,d,l=0;function c(u){let p=u===t,f=u===n,m=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let g=u.textContent;f&&(a=l+g.substring(0,o).replace($o,"").length),m&&(d=l+g.substring(0,r).replace($o,"").length),l+=g.replace($o,"").length;break}case Node.ELEMENT_NODE:{if(Ar(u)&&u.nextSibling){l++;break}!p&&Lr(u)&&u.previousSibling&&l++;for(let g=0;g<u.childNodes.length;g++){let h=f&&g===o,b=m&&g===r;if(h&&(a=l),b&&(d=l),d!==void 0||((!h||!i)&&c(u.childNodes[g]),m&&g===r-1&&(d=l),d!==void 0))break}m&&(d=l);break}default:break}}if(c(t),d===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:d,end:d}}function qo(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r,collapsed:i}=e,a=0,d="";function l(c){let u=c===t,p=c===n,f=c===s;switch(p&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let m=p?o:0,g=f?r:void 0;d+=c.textContent.replace($o,"").substring(m,g);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&Ar(c)&&c.nextSibling){d+=`
|
|
9
|
-
`;break}!u&&!i&&a===1&&
|
|
10
|
-
`);let m=p?o:0,g=f?Math.min(r,c.childNodes.length):c.childNodes.length;for(let h=m;h<g&&(l(c.childNodes[h]),a!==2);h++);break}default:break}f&&(a=2)}return l(t),d}var ou=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(ou||{}),ht=class{constructor(e){this.element=e;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(e,n){let o=s=>{n(s)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}handleInteraction(){let e=this.getText(),n=this.getHTML(),o=this.getSelection(),s=this.cachedCaretPosition===null;if(!this.isActive||(e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),e!==this.cachedText?(this.cachedText=e,this.cachedHTML=n,s=!0,this.emit("change",{plainText:e,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,s=!0,this.emit("change",{plainText:e,rawHTML:n})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,s=!0,this.emit("selection",o)),!s))return;let r=this.getCaretPosition();Ct(r,this.cachedCaretPosition)||(this.cachedCaretPosition=r,this.emit("caretposition",r))}handleClick(){this.handleInteraction()}handleFocus(){let e=!this.isFocused;this.isFocused=!0,e&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let e=this.isFocused;this.isFocused=!1,e&&this.emit("blur")}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(ou).includes(n)||n.toLowerCase()==="z"&&(o||s),this.emit("keydown",e)}handleKeyUp(e){this.handleInteraction(),this.emit("keyup",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var o,s;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()})}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}off(e,n){if(!this.eventListeners[e])return;let o=this.eventListeners[e].indexOf(n);o!==-1&&this.eventListeners[e].splice(o,1)}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function su(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var cn=class extends ht{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),qo(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){let n=this.getRootNode();if(n.activeElement!==this.element)return null;let o="getSelection"in n?n.getSelection():window.getSelection();if(!o)return null;let s=o.rangeCount>0?o.getRangeAt(0):null;if(!s)return null;let r=this.element.ownerDocument.createRange();return r.setStart(s==null?void 0:s.startContainer,s==null?void 0:s.startOffset),r.setEnd(s==null?void 0:s.endContainer,s==null?void 0:s.endOffset),!r||!this.element.contains(r.startContainer)||!this.element.contains(r.endContainer)?null:r}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let o=n.getBoundingClientRect();return!su(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!su(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let n=this.getRange();if(n)return Go(this.element,n);let o=this.lastKnownSelection;if(o&&nu(this.element,o.start,o.end))return o;let s=$n(this.element);return s.collapse(!1),Go(this.element,s)}getSelectedText(){let{start:n,end:o}=this.getSelection();return qo(this.element,Dt(this.element,n,o))}listen(){super.listen();let n=new MutationObserver(r=>{var i,a;r.length===2&&r[0].addedNodes.length===1&&((i=r[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=r[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let o=this.element.isContentEditable,s=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>s.disconnect())}};var kh=["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 ru(t,e){let n="mozInnerScreenX"in window,o=document.createElement("div");o.id="input-textarea-caret-position-mirror-div";let s=o.style,r=window.getComputedStyle(t),i=t.ownerDocument.body;s.whiteSpace="pre-wrap",s.wordWrap="break-word",s.position="absolute",s.visibility="hidden",kh.forEach(c=>{s[c]=r[c]}),n?t.scrollHeight>Number.parseInt(r.height)&&(s.overflowY="scroll"):s.overflow="hidden",o.textContent=t.value.substring(0,e);let a=document.createElement("span");a.textContent=t.value.substring(e)||".",o.appendChild(a),i.appendChild(o);let d=t.getBoundingClientRect(),l={top:d.top-t.scrollTop+a.offsetTop+Number.parseInt(r.borderTopWidth)+a.offsetHeight,left:d.left-t.scrollLeft+a.offsetLeft+Number.parseInt(r.borderLeftWidth)};return i.removeChild(o),l}var pn=class extends ht{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 ru(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var r;return(r=n==null?void 0:n.get)==null?void 0:r.call(this.element)},set:r=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,r),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let o=this.element.disabled,s=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>s.disconnect())}};function iu(t,e,n){let o=`deepdesk-iframe-${t}`,s=document.getElementById(o);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(n).forEach(([a,d])=>{i.searchParams.append(a,d)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=o,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}function Rh(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch(e){return t}}var la=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()}},da=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()}},ca=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(e){this.externalId!==e&&(this.cleanup(),k.info("Set externalId",e),this.externalId=e,this.channel=this.createChannel(e))}createChannel(e){let n=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new da(e,this.deepdeskUrl,{debug:!0}):new la(e),o=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=Rh(s.data);typeof r!="object"||r.type!=="event"||r.channel!==e||(k.info("Received broadcast event",this.externalId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return n.onMessage(o),n}send(e,n,o){var i,a;k.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let s={type:"event",name:e,payload:n};o!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,n));let r=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage(S(y({},s),{channel:this.externalId}))}cleanup(e=!1){var n,o;(n=this.channel)==null||n.close(),this.channel=void 0,e&&((o=this.defaultChannel)==null||o.close(),this.defaultChannel=void 0)}},au=ca;function Ph(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(y({},e),{[Ph(n)]:z(t[n])}),{}):t}function Ih(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function pe(t){return Array.isArray(t)?t.map(pe):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>S(y({},e),{[Ih(n)]:pe(t[n])}),{}):t}var Gn=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var pa=t=>new Promise(e=>{setTimeout(e,t)});var qn=class extends Gn{constructor(){super(...arguments);this.name="ClientError"}},ga=class extends Gn{constructor(){super(...arguments);this.name="ServerError"}},ua=new Map;function Lh(t){return v(this,null,function*(){if(t.status===204)return t.text().catch(()=>{}),null;let e=t.headers.get("content-type");if(e!=null&&e.includes("application/json"))return t.json();let n=yield t.text();return n===""?null:(k.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var _t=class _t{constructor(e="",n={}){this.baseUrl=e;this.options=n;this.latestRequestByUrl={};var o;this.fetch=(o=n.fetch)!=null?o:window.fetch.bind(window)}patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,n={}){return new Promise((o,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,d=n.method===void 0||n.method.toLowerCase()==="get",N=n,{useCache:l=!1,abortLatest:c=!1,attempts:u=1,retryDelay:p=500,refreshTokenOn401:f=!0,retryOnError:m=B=>B instanceof TypeError,retryOnResponse:g=B=>B.status>=500,version:h=null}=N,b=M(N,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(l){if(!d)throw new Error(`Can't use 'useCache' for ${n.method}`);if(ua.has(i)){o(ua.get(i));return}}let T=S(y({credentials:"include"},b),{headers:y({Accept:"application/json","Content-Type":"application/json"},b.headers)});!d&&this.csrfToken&&(T.headers=S(y({},T.headers),{"X-CSRFToken":this.csrfToken})),typeof h=="string"&&(T.headers=S(y({},T.headers),{"X-Deepdesk-API-Version":h}));let C=u,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&c&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let L=()=>v(this,null,function*(){return C--,a(i,T).then(B=>v(this,null,function*(){return g(B)&&!r.isAborted&&C>0?(yield pa(p),L()):B.status===401&&f===!0&&w===!1?(w=!0,yield this.refreshToken(),L()):B})).catch(B=>v(this,null,function*(){if(m(B)&&!r.isAborted&&C>0)return yield pa(p),L();throw B}))});L().then(B=>v(this,null,function*(){let X=yield Lh(B);if(delete this.latestRequestByUrl[i],B.status>=500){s(new ga("Server Error",X));return}if(B.status===401){s(new qn("Unauthorized",X));return}if(B.status===403){s(new qn("Forbidden",X));return}if(B.status===404){s(new qn("Not Found",X));return}if(B.status>=400){s(new qn("Bad Request",X));return}l&&ua.set(i,X),o(X)})).catch(B=>{s(B)})})}validateToken(){return v(this,null,function*(){let{has_valid_access_token:e,is_logged_in:n}=yield this.get("/apis/admin/session/validate/");if(!e)try{yield this.refreshToken();let{is_logged_in:o}=yield this.get("/apis/admin/session/validate/");return o}catch(o){return!1}return n})}refreshToken(){return _t.refreshingToken||(_t.refreshingToken=this.get("/apis/admin/session/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,y({method:"POST",body:JSON.stringify(n)},o))}patch(e,n,o){return this.request(e,y({method:"PATCH",body:JSON.stringify(n)},o))}put(e,n,o){return this.request(e,y({method:"PUT",body:JSON.stringify(n)},o))}delete(e,n){return this.request(e,y({method:"DELETE"},n))}};_t.refreshingToken=null;var un=_t;var lu;(e=>{let t;(a=>(a.SUCCESS="success",a.FAILURE="failure",a.CONDITIONS_NOT_MET="conditions_not_met",a.MAX_RECURSION_LEVEL="max_recursion_level",a.NO_ACCESS_TO_ASSISTANT="no_access_to_assistant"))(t=e.EvaluationStatus||(e.EvaluationStatus={}))})(lu||(lu={}));function ma(t){return S(y({},z(t)),{metadata:t.metadata})}var gn=class gn{constructor(e,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new un(e,{fetch:n.fetch}),this.client.patchFetch(o=>(s,r)=>v(this,null,function*(){let i=yield o(s,r);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return v(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=yield this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(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(),k.info(`Creating conversation for session ${e.externalId} and agent ${e.agentId}`);let n=yield this.client.post("/api/v2/conversations",S(y({chat_start_time:new Date().toISOString()},pe(e)),{metadata:(o=e.metadata)!=null?o:{}}));return ma(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/",pe(e))})}patchMe(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",pe(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(),k.info(`Getting conversation for session ${e}`);let{attempts:s=1,retryDelay:r=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return k.info(`Successfully retrieved conversation ${i.id} for session ${e}`),ma(i)})}isConversationSupported(o){return v(this,arguments,function*(e,n={}){k.info(`Check if conversation for session ${e} is supported`);let{attempts:s=1,retryDelay:r=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(e,n){return v(this,null,function*(){var r;yield this.preflight();let o=pe(n);n.metadata&&(o.metadata=(r=n.metadata)!=null?r:{});let s=yield this.client.put(`/api/v2/conversations/${e}`,o);return ma(s)})}postMessages(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${e}/messages`,n.map(o=>S(y({},pe(o)),{metadata:o.metadata})))})}sendEvent(e,n){return v(this,null,function*(){yield this.preflight();let a=n,{data:o}=a,s=M(a,["data"]),r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((d,[l,c])=>S(y({},d),{[l]:c}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((d,l)=>(s[l]&&(d[l]=s[l]),d),{});return this.client.post("/api/v2/events",pe(S(y(y({},r),i),{data:o,name:e})),{version:"v2"})})}getEntities(e){return v(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:e.filter(o=>o.text)})})}getTemporaryExchangeToken(){return v(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(e){return v(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:e}).catch(n=>{throw k.warn(`Invalid token '${e}'`),n})})}authenticateWithKey(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",pe(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(s){return v(this,arguments,function*(e,n={},o){if(yield this.preflight(),o==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${e}/recommend/${o}`,pe(n),{abortLatest:!0})).map(i=>S(y({},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`,pe(n),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))})}getPinnedMessages(e){return v(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return z(n).map(o=>S(y({},o),{text:o.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(e){return v(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",pe(e),{abortLatest:!0,version:"v2"});return z(n)})}search(e){return v(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${e.profile}/search`,pe(e));return z(n)})}requestLoginByEmail(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:e});return 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)})}evaluateAssistant(e,n){return v(this,null,function*(){var i;yield this.preflight();let o=new URLSearchParams;n!=null&&n.externalConversationId&&o.append("external_conversation_id",n.externalConversationId);let s=n!=null&&n.threadId?`/api/v2/assistants/${e}/threads/${n==null?void 0:n.threadId}/evaluate?${o.toString()}`:`/api/v2/assistants/${e}/evaluate?${o.toString()}`,r=yield this.client.post(s,{input:(i=n==null?void 0:n.input)!=null?i:{},conversation:n==null?void 0:n.transcript});return z(r)})}createAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n}=e,o=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return z(o)})}postMessageToAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:s}=e,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:s,role:"user"});return z(r)})}translateMessages(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",pe(e));return z(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let s=o.toLowerCase(),r=s.match(Xa);if(!n||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&k.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};gn.exchangeTokenPromise=null;var yt=gn;var Dr=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(J,()=>du)}}),{handlingTimeStart:gu,handlingTimeStop:Mr,handlingTimeReset:mu}=uu.actions,fu=uu.reducer;var hu=(t={})=>{let e=y({onAuthError:Sn(!1)},t);return n=>o=>s=>("error"in s&&s.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(s))};var Or=require("@reduxjs/toolkit");var Nr={list:{keywordMatches:[]},fetchState:"idle"};var mn=(0,Or.createAsyncThunk)("styleSuggestions/getAll",(n,o)=>v(null,[n,o],function*({text:t},e){var d;let{deepdeskAPI:s}=e.extra,r=e.getState(),{showStyleSuggestions:i}=r.settings,a=(d=r.conversation.current)==null?void 0:d.profileCode;if(!i)return Nr.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return s.getStyleSuggestions({profileCode:a,message:t})})),Ah=(0,Or.createSlice)({name:"styleSuggestions",initialState:Nr,reducers:{},extraReducers:t=>{t.addCase(mn.pending,e=>{e.fetchState="loading"}).addCase(mn.rejected,e=>{e.fetchState="error"}).addCase(mn.fulfilled,(e,n)=>{e.fetchState="done",Ct(e.list,n.payload)||(e.list=n.payload)}).addCase($t,e=>{e.list=Nr.list}).addCase(J,()=>Nr)}}),yu=Ah.reducer;var vu=(t={})=>{let e,n=!0,o=y({getStyleSuggestions:mn,debounce:500},t);return s=>r=>i=>{var f;let a=s.getState().input.text,d=r(i),l=s.getState();if(l.auth.isLoggedIn!==!0)return d;let{showStyleSuggestions:c}=l.settings;if(!((f=l.conversation.current)==null?void 0:f.id)||!c)return d;let{text:p}=l.input;return p===a&&!n||(clearTimeout(e),p==="")||(e=setTimeout(()=>{n=!1,s.dispatch(o.getStyleSuggestions({text:p}))},t.debounce)),d}};function Mh(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var xu=(t={})=>{let e=y({getTextSuggestions:He,getAutocompleteSuggestions:Lo,debounce:200,check:$e},t),n;return o=>s=>r=>{var g;let{input:i}=o.getState(),a=s(r),d=o.getState();if(d.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:c}=d.settings,u=(g=d.conversation.current)==null?void 0:g.id,p=r.type===Vs.toString();if(!u||!l&&!c)return a;let{input:f}=d;return Mh(f,i)&&!p||(clearTimeout(n),!e.check(d))||(n=setTimeout(()=>{let h=Cn(d);h===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(h))},p?0:e.debounce)),a}};var Su=mn.fulfilled.toString();function Nh(t,e){let n=new Set([...e.keywordMatches.map(s=>s.keyword)]),o=[];return n.forEach(s=>{let r=t.keywordMatches.filter(d=>d.keyword===s),i=e.keywordMatches.filter(d=>d.keyword===s),a=i.length-r.length;a<=0||o.push(...i.slice(0,a))}),o}var bu=t=>e=>n=>o=>{var l;if(o.type!==Su){n(o);return}let s=e.getState().styleSuggestions.list;n(o);let r=e.getState(),i=r.styleSuggestions.list,a=(l=r.conversation)==null?void 0:l.current;if(s===i)return;let d=Nh(s,i);o.type===Su&&d.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:d}})};var Oh=(0,Dr.combineReducers)({assistants:gp,auth:al,conversation:gl,contentTypes:ld,passwordlessToken:hp,entities:Nd,handlingTime:fu,info:_l,input:kl,settings:el,profile:gd,search:zl,styleSuggestions:yu,ui:cc,textSuggestions:jd});function Cu(t){return(0,Dr.configureStore)({reducer:Oh,middleware:e=>{var o;let n=e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}).concat(hu()).concat(xu({debounce:200})).concat(vu({debounce:500})).concat(bu(t.deepdeskAPI));return((o=t.middleware)!=null?o:[]).reduce((s,r)=>s.concat(r),n)},preloadedState:t.preloadedState})}var Dh=t=>{var e,n;return(n=(e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())!=null?n:"unknown"},_h=t=>e=>n=>o=>{var a,d;let s=e.getState(),r=vn("inlineSuggestions")(s);switch(o.type){case Sn.toString():{!o.payload&&t.emit("logout",void 0);break}case Fe.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:(a=s.conversation.current)==null?void 0:a.id,data:{entities:o.payload}});break;case $t.toString():t.logSendMessage(o.payload);break;case fr.toString():t.emit("call-to-action",{cue:o.payload});break;case Xe.fulfilled.toString():o.isBroadcasted||t.broadcast(ni,o,!1);break;default:break}let i=n(o);switch(o.type){case $t.toString():t.handleAfterSendMessage(o.payload);break;case Mo.toString():t.onUpdateShowTabHint(o.payload);break;case Mr.toString():t.logHandlingTime();break;case wn.toString():t.broadcast(Ss,o);break;case jt.toString():t.broadcast(Ss,o);break;case hr.toString():e.dispatch(jt({source:"assistant",assistantCode:o.payload.code}));break;case"analytics/logEvent/fulfilled":{let l=s.assistants.cues.find(c=>c.code===o.meta.arg.data.assistantCode);t.emit("event",S(y({},o.meta.arg),{cue:l}));break}case ye.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",S(y({type:Dh(o.payload.suggestion)},o.payload),{replace:o.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}})),r&&e.dispatch(Tt([]));break}case gs.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(d=s.conversation.current)==null?void 0:d.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Tt.toString():{r&&o.payload.length>0&&e.dispatch(ms(0));break}default:break}return i},Tu=_h;var wu=require("@reduxjs/toolkit");function fa(t){return t.toISOString().replace("T"," ").replace("Z","")}var Fh=(t,e)=>e.version,Eu=(0,wu.createSelector)([En,ze,pu,Fh],(t,e,n,o)=>{if(!e)return k.warn("No conversationId for handling time metrics"),null;let{startTime:s,stopTime:r}=n;return!s||!r?(k.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:e,clientVersion:o,agentId:t==null?void 0:t.agentId,agentName:t==null?void 0:t.agentName,agentEmail:t==null?void 0:t.agentEmail,timeStart:fa(s),timeStop:fa(r)}});function ku(t,e){let{text:n,metrics:{numPaste:o,pastes:s,textSuggestions:r}}=t.input,i=n.length;return{source:"agent",clientVersion:e.version,pastes:s,lenTextTotal:i,numPastes:o,suggestions:r}}function ha(t,e){var r;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return ha(o,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?ha(s,e):null}function ya(t,e){return ha(t,e)}function Ru(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Hh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function _r(t){return Hh(t)&&(an(t)||Ys(t))}var Iu,Qe=new Map,Bh=["bottom","height","left","right","top","width"],Pu=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:Bh.some(n=>t[n]!==e[n]);function Lu(t){var n,o,s;if(t.ownerDocument===document)return[];let e=(s=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?s:null;return e?[e,...Lu(e)]:[]}function Au(t,e){return!t||!e?null:S(y({},t),{top:t.top+e.top,left:t.left+e.left})}var Fr=!1,Mu=()=>{Fr=!0;let t=[];if(Qe.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),Qe.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}),Qe.size===0){Fr=!1;return}Iu=window.requestAnimationFrame(Mu)};function va(t,e){let n=Lu(t),o=[],s=n.map((r,i)=>va(r,a=>{o[i]=a;let d=Qe.get(t);if(!d)return;let l=o.reduce(Au,d.rect);d.callbacks.forEach(c=>c(l))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Qe.has(t)){let i=Qe.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Qe.set(t,{rect:void 0,callbacks:[e],parentRects:o});r&&!Fr&&Mu()},unobserve(){s.forEach(i=>i.unobserve());let r=Qe.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Qe.delete(t),Qe.size||(cancelAnimationFrame(Iu),Fr=!1)}}}}var Nu,Ze=new Map,Ou=()=>{Ze.forEach((t,e)=>{if(!e.isConnected){Ze.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,s=o>n;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),Ze.size!==0&&(Nu=window.requestAnimationFrame(Ou))};function Du(t,e){return{observe(){let n=Ze.size===0;Ze.has(t)?Ze.get(t).callbacks.push(e):Ze.set(t,{visible:void 0,callbacks:[e]}),n&&Ou()},unobserve(){let n=Ze.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||Ze.delete(t),Ze.size||cancelAnimationFrame(Nu)}}}}var xa=["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 Sa(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function Xn(t){return Number.parseFloat(t)}function Hr(t){return Math.round(t*1e6)}function _u(t){return t/1e6}function ba(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,s=Xn(t.width),r=Xn(t.borderLeftWidth),i=Xn(t.borderRightWidth),a=Xn(t.paddingRight),d=_u(Hr(s)-Hr(r)-Hr(i)),l=_u(Hr(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",rn(n);let o=window.getComputedStyle(t),s=!0,r=()=>{n.scrollTop=t.scrollTop};Sa(o,n,xa),ba(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",r));let i=Du(t,()=>{Sa(o,n,xa),ba(o,t,n),r(),setTimeout(r,0)}),a,d=!0,l=va(t,p=>{if(p===null){e.onRemove&&e.onRemove(),n.remove();return}if(!d&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),d=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),d=!1},200),p.height===0&&p.width===0){if(s===!0)return;e.onHide&&e.onHide(),n.style.display="none",s=!0;return}if(Sa(o,n,xa),ba(o,t,n),r(),e.placement==="below"&&n.classList.add("below"),n.style.top=`${p.top}px`,n.style.left=`${p.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let f=e.closestScrollElement.getBoundingClientRect(),m=window.getComputedStyle(e.closestScrollElement),g=Xn(m.borderTopWidth),h=Xn(m.borderBottomWidth),b=f.top+g-p.top,T=p.top+p.height+-(f.top+f.height-h);n.style.clipPath=`inset(${b}px 0px ${T}px 0px)`}s&&(n.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(n):(u=t.parentElement)==null||u.appendChild(n),l.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",r),l.unobserve(),i.unobserve(),n.remove()}]}var 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){k.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Uh(t){return t.offsetParent!==null}function Hu(t){if(!Uh(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 Br(t,e,n=100){let o=Hu(t);e({isVisible:o});let s=setInterval(()=>{let r=Hu(t);r!==o&&(o=r,e({isVisible:o}))},n);return()=>{clearTimeout(s)}}var Jo=class extends Error{};function Kh(){let t,e;return{promise:new Promise((o,s)=>{t=o,e=s}),resolve:t,reject:e}}var Ur=class{constructor(){this.queues={}}push(e,n){let o=()=>{let r=this.queues[e][1];r?(this.queues[e]=[r.promise,null],r.resolve()):delete this.queues[e]};if(!this.queues[e]){let r=n().finally(o);return this.queues[e]=[r,null],r}this.queues[e][1]&&this.queues[e][1].reject(new Jo("Queued async function is outdated"));let s=Kh();return this.queues[e][1]=s,s.promise.then(()=>n().finally(o))}};var zh={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},Bu=(t,e)=>{var s,r,i;if(!((i=(r=(s=t.uiConfig)==null?void 0:s.widget)==null?void 0:r.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return k.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let o=t[zh[e]];return o&&o.length>0?o.map(a=>a.code):(k.warn(`No assistant set in profile for conversation event "${e}"`),[])};var Kr=class{constructor(e){this.options=e;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,o;this.socket,this.eventListeners=new Map,this.url=e.url,this.maxReconnectAttempts=(n=e.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(o=e.reconnectInterval)!=null?o:this.reconnectInterval,this.shouldReconnect=e.shouldReconnect}connect(){let e=()=>this.cleanup();window.addEventListener("beforeunload",e),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",e)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=e=>{var n;try{let o=z(JSON.parse(e.data));o.event&&this.eventListeners.has(o.event)&&((n=this.eventListeners.get(o.event))==null||n.forEach(s=>s(o.data)))}catch(o){console.error("Error parsing WebSocket message:",o)}},this.socket.onclose=e=>{console.log("WebSocket connection closed:",e),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=e=>{console.error("WebSocket error:",e)})}reconnect(){var e,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(e=this.socket)==null||e.close();return}if(!this.shouldReconnect()){console.error("Should not reconnect, closing WebSocket connection."),(n=this.socket)==null||n.close();return}this.socket&&(this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this.socket=new WebSocket(this.url),this.setupListeners(),this.maxReconnectAttempts--}send(e,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:e,data:n}))}on(e,n){this.eventListeners.has(e)||this.eventListeners.set(e,[]);let o=this.eventListeners.get(e);o&&!o.includes(n)&&o.push(n)}close(){var e;(e=this.socket)==null||e.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(e=>e()),this.cleanupCallbacks=[]}};var Ft=O(require("react"));var Uu={root:"dd-7zvcP",dialogContent:"dd-4C0lK",continueButton:"dd-YUPQW",buttonContinueWrapper:"dd-IKpYs",nicknameInput:"dd-rxhGp",titleWrapper:"dd-nw3nD",title:"dd-5iof5",closeButtonWrapper:"dd-UUAzA",closeButton:"dd-7rjP5",buttonsWrapper:"dd-5e9Xb",errorMessage:"dd--5VgX",errorLink:"dd-u461n"};var Ku=require("react-redux");var Ca={};Y(Ca,{enUS:()=>Wh,nlNL:()=>Vh});var Wh={title:[{type:0,value:"Enter your nickname"}],close:[{type:0,value:"Close"}],nicknameDialogTitle:[{type:0,value:"Please enter the name you'd like customers to see during chat conversations. This nickname will be used across your Deepdesk environment."}],nicknameDialogInputPlaceholder:[{type:0,value:"Enter your nickname"}],nicknameDialogContinueButton:[{type:0,value:"Continue"}],nicknameDialogError:[{type:0,value:"Nickname cannot be empty or spaces only"}],nicknameDialogEmojiError:[{type:0,value:"You cannot use emojis in this field."}],nicknameDialogSaveError:[{type:0,value:"We couldn't save your details just now. Please try again, or update it at "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We couldn\u2019t save your details just now. Please try again later, or update them in My Deepdesk \u2192 Settings."}]},Vh={title:[{type:0,value:"Voer je bijnaam in"}],close:[{type:0,value:"Sluiten"}],nicknameDialogTitle:[{type:0,value:"Voer de naam in die je wilt dat klanten zien tijdens chatgesprekken. Deze bijnaam wordt gebruikt in je Deepdesk-omgeving."}],nicknameDialogInputPlaceholder:[{type:0,value:"Voer je bijnaam in"}],nicknameDialogContinueButton:[{type:0,value:"Doorgaan"}],nicknameDialogError:[{type:0,value:"Bijnaam mag niet leeg of alleen spaties zijn"}],nicknameDialogEmojiError:[{type:0,value:"Je kunt geen emoji's gebruiken in dit veld."}],nicknameDialogSaveError:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw of werk het bij op "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw later, of werk ze bij in My Deepdesk \u2192 Instellingen."}]};var Q=require("react/jsx-runtime"),zu=({onClose:t,onSave:e,id:n,error:o})=>{let[s,r]=(0,Ft.useState)(""),[i,a]=(0,Ft.useState)(!1),[d,l]=(0,Ft.useState)(!1),c=x("Nickname",Uu),u=Ft.default.useRef(null),p=(0,Ku.useSelector)(b=>b.info.showNicknameDialog),f=R(Ca),m=E("adminUrl");(0,Ft.useEffect)(()=>{o&&a(!0)},[o]);let g=()=>{if(!u.current)return;s.trim()?u.current.setCustomValidity(""):u.current.setCustomValidity(f("nicknameDialogError")),u.current.reportValidity()},h=b=>{b.preventDefault();let T=s.trim(),C=b.currentTarget.querySelector("#nickname-input");if(!T){C.setCustomValidity(f("nicknameDialogError")),C.reportValidity();return}C.setCustomValidity(""),e(T)};return(0,Q.jsxs)(In,{isOpen:p,"datatest-id":n,onClose:t||(()=>{}),onBack:t||(()=>{}),children:[(0,Q.jsx)("div",{className:c.titleWrapper,children:(0,Q.jsx)("h1",{className:c.title,children:f("title")})}),(0,Q.jsxs)("form",{className:c.dialogContent,onSubmit:h,children:[(0,Q.jsx)("p",{children:f("nicknameDialogTitle")}),i&&o&&(0,Q.jsx)("div",{className:c.errorMessage,children:m?(()=>{let b=f("nicknameDialogSaveError",{account:m}),T=`${m}.deepdesk.com/admin/user-settings`,C=b.indexOf(T);if(C!==-1){let w=b.substring(0,C),L=b.substring(C+T.length);return(0,Q.jsxs)(Q.Fragment,{children:[w,(0,Q.jsx)("a",{href:T,target:"_blank",rel:"noopener noreferrer",className:c.errorLink,children:T}),L]})}return b})():f("nicknameDialogSaveErrorWithoutLink")}),(0,Q.jsx)("input",{required:!0,minLength:1,maxLength:20,"data-testid":"nickname-input",id:"nickname-input",className:c.nicknameInput,type:"text",placeholder:f("nicknameDialogInputPlaceholder"),value:s,onChange:b=>{l(new RegExp("\\p{Extended_Pictographic}","u").test(b.target.value)),r(b.target.value)},onBlur:g,ref:u}),d&&(0,Q.jsx)("div",{className:c.errorMessage,role:"alert",children:f("nicknameDialogEmojiError")}),(0,Q.jsxs)("div",{className:c.buttonsWrapper,children:[o?(0,Q.jsx)("div",{className:c.closeButtonWrapper,children:(0,Q.jsx)("button",{type:"button",className:c.closeButton,onClick:()=>t==null?void 0:t(),children:f("close")})}):null,(0,Q.jsx)("div",{className:c.buttonContinueWrapper,children:(0,Q.jsx)("button",{type:"submit",className:c.continueButton,disabled:!s.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(s),children:f("nicknameDialogContinueButton")})})]})]})]})};var H=require("react/jsx-runtime");var Wu=Fu("showTabHint",!0),Jn=class Jn{constructor({deepdeskUrl:e,version:n=Jn.version||"unknown",locale:o="en-US",token:s,fetch:r,productName:i,createCustomChannel:a,websocketClient:d=Kr}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.disposeHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.belowSuggestions=null;this.floatingMenu=null;this.widgetElement=null;this.widgetRoot=null;this.nicknameDialogUnsubscribe=null;this.nicknameDialogFailed=!1;this.dynamicThunkObject={};this.queues=new Ur;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=e.replace(/\/api$/,"");this.deepdeskApi=new yt(l,{token:s,fetch:r}),this.version=n,this.instanceId=Jn.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Tu({broadcast:(m,g,h)=>{this.broadcastEvents.send(m,g,h)},emit:(m,g)=>this.emit(m,g),handleAfterSendMessage:m=>this.handleAfterSendMessage(m),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:m=>this.logSendMessage(m),onUpdateShowTabHint:m=>Wu.update(m),sendEvent:(m,g)=>this.deepdeskApi.sendEvent(m,g)})]};this.store=Cu(c),this.broadcastEvents=new au({debug:!0,deepdeskUrl:l,eventMap:Wl(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new d({url:`${l}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>v(this,null,function*(){var m;return(m=ne(this.state))!=null?m:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(Mo(Wu.value())),this.store.dispatch(ls({locale:o,adminUrl:l,productName:i}));let u=[],p=m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(up(m))};this.hasConversation()?g():u.push(g)};this.ws.on("assistants::direct_response",p),this.ws.on("assistants::user_notification",p),this.ws.on("assistants::response_chunk",m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(pp(m))};this.hasConversation()?g():u.push(g)}),this.ws.on("assistants::suggest_as_reply",m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(wn([{text:m.payload.message,type:"text",source:"assistant",assistantCode:m.code,sourceLabel:m.name}]))};this.hasConversation()?g():u.push(g)});let f=this.whenConversationLoaded(()=>{var m;this.broadcastEvents.setExternalId((m=this.state.conversation.current)==null?void 0:m.externalId),u.forEach(g=>g()),u.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),u.length=0,f()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var e;return(e=Vt(this.state)[this.state.input.selectedSuggestionIndex])!=null?e:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}externalId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.externalId}shouldAbort(){return this.state.conversation.isSupported===!1?(k.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(k.warn("Profile has not been loaded (yet)"),!0):(k.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(e){if(ne(this.state))e();else{let n=this.subscribe(ne,o=>{o&&e()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch(Sn(null)),this.store.dispatch(tt()),new Promise(e=>{this.whenLoggedIn(()=>e())})}isLoggedIn(){return v(this,null,function*(){return(yield this.store.dispatch(tt())).payload})}isConversationSupported(e,n){return v(this,null,function*(){return(yield this.store.dispatch(Xr({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(cs(S(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}getConversationByExternalId(e,n){return v(this,null,function*(){return this.hasConversation()&&this.externalId()!==e&&this.resetConversation(),(yield this.store.dispatch(ps({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(Jr(S(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return v(this,null,function*(){yield this.store.dispatch(Qr(e))})}updateConversation(e){return v(this,null,function*(){return(yield this.store.dispatch(us(e))).payload})}resetConversation(){this.store.dispatch(J()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(ls(e))}setVisitorInfo(e){this.store.dispatch(Ml(e))}setCustomData(e){this.store.dispatch(Nl(e))}setAgentInfo(e,n){return v(this,null,function*(){var s;yield this.store.dispatch(oo(y(y({},e),n))),(s=this.state.info.agentInfo)!=null&&s.agentNickname||this.broadcastEvents.send(xs,{showNicknameDialog:!0})})}setAgentSettings(e){return v(this,null,function*(){yield this.store.dispatch(Yr(e))})}getAgentSettings(){return v(this,null,function*(){return(yield this.store.dispatch(ei())).payload})}refresh(){return v(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let e=[];return e.push(this.refreshTextSuggestions()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(fs({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}))}notifyExternalSuggestion(e){this.store.dispatch(ye(e))}evaluateAssistant(e,n){return v(this,null,function*(){var d;let{input:o={},transcript:s,showCuesInWidget:r=!0,includeMetadata:i}=n||{},a=yield this.store.dispatch(Xe({assistantCode:e,transcript:s,includeMetadata:i,input:o,skipState:!r}));if(a.error)throw new Error(`Assistant evaluation failed: ${(d=a.payload)!=null?d:a.error.message}`);return a.payload.output})}evaluateConversationAssistant(e,n){return v(this,null,function*(){yield this.loadProfileConfig();let o=this.state.profile.data;if(!o){k.warn("Can't evaluate assistant when profile is not loaded yet.");return}let s=Bu(o,e);yield Promise.all(s.map(r=>this.queues.push(r,()=>v(this,null,function*(){yield this.evaluateAssistant(r,y({includeMetadata:!0},n))})).catch(i=>{if(i instanceof Jo){k.warn(`Queued assistant "${r}" was outdated and dropped`);return}throw i})))})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:s,selectedSuggestionIndex:r,selection:i}=this.state.input,{inlineSuggestions:a,showTextSuggestions:d,suggestionsPlacement:l}=this.settings,c=l==="inline"||l==="below"?"below":"above",u=s.length>0;if(this.store.dispatch(xl(Zr(e))),!$e(this.state)||e.key!=="Tab"&&!d)return;let p=()=>{n||!u||i&&(e.shiftKey||(this.store.dispatch(Cl()),e.preventDefault()))},f=()=>{n||!u||a&&r<=0||i&&(e.shiftKey||(this.store.dispatch(Tl()),e.preventDefault()))};switch(e.key){case"ArrowUp":c==="below"?f():p();break;case"ArrowDown":{c==="below"?p():f();break}case"Escape":{n||(this.store.dispatch(ms(-1)),this.store.dispatch(Pt({collapse:!0})),this.store.dispatch(lc(!0)),e.preventDefault());break}case"Tab":{e.preventDefault();let m=Tn(this.state);if(!m)return;this.store.dispatch(Mo(!1)),this.store.dispatch(ye({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(ye({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(ye({text:m.text,suggestion:m,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),e.preventDefault();break}default:}n&&o&&this.store.dispatch(Pt({collapse:!1}))}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Tt([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(gu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(Mr()))}logSendMessage(e){let n=ku(this.state,{version:this.version});n&&(e&&(Object.assign(n,{text:e}),Object.assign(n,{lenTextTotal:e.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let e=Eu(this.state,{version:this.version});e&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:e}),this.store.dispatch(mu()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch($t((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(El()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(s=>{try{s(n)}catch(r){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.error(r)}})}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}setPlatformVariables(e){this.store.dispatch(Ol(e))}whenConversationLoaded(e){let n=r=>{var i;return(i=r.conversation.current)==null?void 0:i.id},o=()=>this.loadProfileConfig().then(()=>e());return n(this.state)&&o(),this.subscribe(n,r=>{r&&o()})}overlayContainerFactory(e,n,o,s){let[r,i]=Xo(n,o);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),[r,i]}createInlineContainer(e,n){var a;let o=document.createElement("div");o.style.position="absolute",o.style.top="0px",o.style.left="0px",o.style.height="0px",o.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",o.appendChild(s);let r=(a=e.ownerDocument.defaultView)==null?void 0:a.frameElement,i=r?r.ownerDocument.defaultView:null;if(r&&(i===window||(i==null?void 0:i.parent)===window)){let[d,l]=Xo(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});d.dataset.testid=n,d.style.zIndex="2",d.appendChild(o),this.unmountHandlers.push(()=>{l()})}else document.body.appendChild(o);return s}createContainer(e,n=document.body){let o=window.getComputedStyle(n),s=document.createElement("div");return rn(s),s.dataset.testid=e,s.style.color=o.color,s.style.fontSize=o.fontSize,s.style.fontFamily=o.fontFamily,s.style.fontVariant=o.fontVariant,s.setAttribute("translate","no"),n.appendChild(s),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,n),k.info(`Stored analytics for ${this.conversationId()}`)}catch(e){}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(e);if(!n)return;let o=JSON.parse(n);o.text.trim()===this.state.input.text.trim()?(k.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(wl(o.metrics))):k.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch(e){}}mount(e,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!_r(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let p=n,{customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i,inputMediator:a}=p,d=M(p,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i};this.configure(d),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),rn(e),this.inputMediator=a||(an(e)?new pn(e):new cn(e)),this.inputMediator.on("change",({plainText:f,rawHTML:m})=>{this.store.dispatch(fs({text:f,html:m}))}),this.inputMediator.on("keyup",f=>{this.store.dispatch(Sl(Zr(f)))}),this.inputMediator.on("keydown",f=>{this.handleKeyDown(f)}),this.inputMediator.on("paste",({pastedText:f,selectionText:m})=>{this.store.dispatch(bl({text:f,selectionText:m}))}),this.inputMediator.on("cut",({selectionText:f})=>{this.store.dispatch(vl(f))});let c;this.inputMediator.on("selection",f=>{clearTimeout(c),f===null?c=setTimeout(()=>{f!==null&&this.store.dispatch(hs(f))},500):this.store.dispatch(hs(f))}),this.unmountHandlers.push(()=>{clearTimeout(c)}),this.inputMediator.on("disabled",()=>{var f;(f=this.inputMediator)==null||f.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(qs(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(qs(!0))}),this.renderSuggestions(e,l),this.subscribe(vn("inlineSuggestions"),()=>{this.renderSuggestions(e,l)}),this.subscribe(vn("suggestionsPlacement"),()=>{this.renderSuggestions(e,l)});let u=this.renderOverlays(n);this.unmountHandlers.push(()=>{u.unmount()}),this.store.dispatch(fs({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(hs(this.inputMediator.getSelection())),this.store.dispatch(qs(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{this.restoreMetrics(),this.syncInputMediator(),this.refreshTextSuggestions(),this.promptForNickname()}),this.isMounted=!0}promptForNickname(e){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let o=(0,vt.createRoot)(n),s=null,r=a=>{s=a,i()},i=()=>{o==null||o.render((0,H.jsx)(at,{store:this.store,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(zu,{id:"deepdesk-nickname-dialog",error:s,onSave:a=>v(this,null,function*(){try{yield this.store.dispatch(Ll({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(xs,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(d){k.error("Error setting agent nickname",d),r("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{o.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(e,n){let o=e(this.store.getState());return this.store.subscribe(()=>{let s=e(this.store.getState());s!==o&&(o=s,n(o))})}unmount(){var e,n,o,s,r;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.belowSuggestions)==null||o.unmount(),(s=this.floatingMenu)==null||s.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(r=this.inputMediator)==null||r.dispose(),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe(),this.isMounted=!1}dispose(){this.unmount(),this.unmountWidget(),this.disposeHandlers.forEach(e=>e()),this.disposeHandlers=[],this.off()}renderSuggestions(e,n){var o,s,r,i;(o=this.floatingMenu)==null||o.unmount(),(s=this.inlineSuggestions)==null||s.unmount(),(r=this.aboveSuggestions)==null||r.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(e,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(e,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(e,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(e,n,"above")}renderInlineSuggestions(e,n){let{customStyles:o}=n,s=this.createInlineContainer(e,"deepdesk-caret"),r=(0,vt.createRoot)(s);r.render((0,H.jsx)(at,{store:this.store,customStyles:o,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(xc,{})})}));let i=a=>{a?(s.style.display="block",s.style.top=`${a.top}px`,s.style.left=`${a.left}px`):s.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),r.unmount(),s.remove()}}}renderAboveOrBelowSuggestions(e,n,o){let{customStyles:s,closestScrollSelector:r,appendOverlayTo:i}=n,a=r&&ya(e,r)||void 0,[d,l]=this.overlayContainerFactory("deepdesk-tab-completion",a||e,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},s==null?void 0:s.rootNode),[c,u]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||e,{appendTo:i,placement:o},s==null?void 0:s.suggestionsRootNode),p=(0,vt.createRoot)(d);p.render((0,H.jsx)(at,{store:this.store,customStyles:s,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(op,{inputElement:e})})}));let f=(0,vt.createRoot)(c);return f.render((0,H.jsx)(at,{store:this.store,customStyles:s,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(Lc,{onLogIn:()=>this.loginViaPopup().catch(m=>k.warn(m.message))})})})),{unmount(){p.unmount(),f.unmount(),l(),u()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:s,appendOverlayTo:r,floatingMenuParent:i}=n,a=s&&ya(e,s)||void 0,[d,l]=this.overlayContainerFactory("floating-menu",a||e,{appendTo:i!=null?i:r},o==null?void 0:o.floatingMenuParent),c=(0,vt.createRoot)(d);return c.render((0,H.jsx)(at,{store:this.store,customStyles:o,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(sc,{onLogIn:()=>this.loginViaPopup().catch(u=>k.warn(u.message))})})})),{unmount(){c.unmount(),l()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays"),s=(0,vt.createRoot)(o);return s.render((0,H.jsx)(at,{store:this.store,customStyles:n,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(Qd,{})})})),{unmount(){s.unmount(),o.remove()}}}renderWidget(e,n={}){if(this.widgetElement&&k.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:s,isEmbedded:r}=n;this.widgetElement=e,this.configure({showImages:s,isEmbedded:r}),this.widgetRoot=(0,vt.createRoot)(e),this.widgetRoot.render((0,H.jsx)(at,{store:this.store,customStyles:o,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(tu,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(i=>k.warn(i.message))})})}))}unmountWidget(){var e,n;(n=(e=this.widgetRoot)==null?void 0:e.unmount)==null||n.call(e),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(e,n,o={}){let{customStyles:s,initialQuestion:r}=o,i=(0,vt.createRoot)(n);return i.render((0,H.jsx)(at,{store:this.store,customStyles:s,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(aa,{children:(0,H.jsxs)(Rr,{assistantCode:e,initialQuestion:r,evaluateKnowledgeAssistFn:Bo,children:[(0,H.jsx)(hn,{children:(0,H.jsx)(Ir,{title:o.title,emptyState:o.emptyState})}),(0,H.jsx)(ia,{children:(0,H.jsx)(Pr,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(e){let n=Br(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(()=>v(this,null,function*(){yield this.store.dispatch(So());let e=Jt(this.state);e&&this.store.dispatch(ls({showSearch:e.search,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:!!e.summarizerAssistantNew,showKnowledgeSearch:!!e.knowledgeAssistantNew||!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions}))})),this.loadProfileConfigPromise)}loginViaPopup(e){return v(this,null,function*(){return new Promise((n,o)=>{this.store.dispatch(ds());let s=new MessageChannel,r=s.port1,i=this.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let d=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",u),clearInterval(p)};r.onmessage=f=>v(this,null,function*(){var m,g;if((m=f.data)!=null&&m.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((g=f.data)==null?void 0:g.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(ro),d=!0,s.port1.close(),n()}catch(h){console.error(h),o(h)}finally{d=!0,l()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&o(new Error("Popup blocked by browser"));let u=f=>v(this,null,function*(){var m;if(f.origin===a.origin)switch((m=f.data)==null?void 0:m.type){case"deepdesk-popup-request-origin":{try{let g=JSON.stringify({type:"deepdesk-popup-parent-origin"});c==null||c.postMessage(g,a.origin)}catch(g){k.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-loaded":{try{let g=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(g,a.origin,[s.port2])}catch(g){k.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-error":{if(l(),f.data.message==="Platform account url mismatch"){let g=`Please contact your administrator: The platform account url (${f.data.targetOrigin}) is misconfigured as it differs from the origin of the page that opened the popup (${f.data.openerOrigin}).`;k.warn(g),this.store.dispatch(qr(g)),o(new Error(g))}if(f.data.message==="Timeout"){let g="Please contact your administrator: Popup timed out. Check if the account's platform url is configured correctly.";k.warn(g),this.store.dispatch(qr(g)),o(new Error(g))}o(new Error(f.data.message));break}}});window.addEventListener("message",u);let p=setInterval(()=>{c&&!c.closed||(l(),d||o(new Error("Popup closed by user")))},200);this.disposeHandlers.push(l)})})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}refreshTextSuggestions(){return v(this,null,function*(){this.isMounted&&(yield this.store.dispatch(Vs()))})}refreshWidgetSuggestions(){return v(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=bo(this.state);try{n.forEach(({type:o})=>{switch(o){case"entities":this.store.dispatch(Fe());break;case"pinned-messages":case"sticky-messages":break;default:as.includes(o)||this.store.dispatch(He(o))}})}catch(o){this.handleError(o)}})}};Jn.version="19.1.1-beta.1",Jn.count=0;var Qo=Jn;function jh(t){return v(this,null,function*(){var s,r,i;let n=yield((s=t.fetch)!=null?s:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(r=t.mimeType)!=null?r:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function Vu(t,e){return v(this,null,function*(){let n=yield jh(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 ju(t,e,n){return v(this,null,function*(){yield new yt(t).authenticateWithKey(e,n)})}function $u(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Gu(o,s){return v(this,arguments,function*(t,e,n={}){var u,p;let{value:r}=t,{start:i,end:a}=(u=n.replace)!=null?u:{start:0,end:r.length},d=`${r.slice(0,i)}${e}${r.slice(a)}`,l=(p=n.selectionAfter)!=null?p:{start:i+e.length,end:i+e.length},c=()=>{if(n.setValue)return n.setValue(d);t.value=d};return Promise.resolve(c()).then(()=>{t.selectionStart=l.start,t.selectionEnd=l.end,t.blur(),t.focus()})})}function qu(o,s){return v(this,arguments,function*(t,e,n={}){let r=n.replace?Dt(t,n.replace.start,n.replace.end):$n(t),i,a=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),i=document.createElement("span"),r.insertNode(i),n.insertBRs!==!1?e.split(`
|
|
11
|
-
`).reverse().forEach((d,l)=>{l>0&&r.insertNode(document.createElement("br")),r.insertNode(document.createTextNode(d))}):r.insertNode(document.createTextNode(e))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let d=n.selectionAfter?Dt(t,n.selectionAfter.start,n.selectionAfter.end):(r.collapse(!1),r),l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(d)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function
|
|
12
|
-
`).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=n.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(n.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(n.slice(r)))}),e}function
|
|
7
|
+
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Ri=require("react/jsx-runtime"),Zm={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Zd=({className:t,color:e})=>(0,Ri.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ri.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:Zm[e||"pink"]})});var Yd={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var Pi={};Y(Pi,{enUS:()=>Ym,nlNL:()=>ef});var Ym={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},ef={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var nc=require("react-redux"),on=require("react/jsx-runtime"),oc=({onLogIn:t})=>{let e=R(Pi),n=E("floatingMenu"),o=E("productName"),s=(0,nc.useDispatch)(),r=(0,tc.useSelector)(ne),i=x("FloatingMenu",Yd);if(r===null||n===!1)return null;let a=()=>{r===!0?s(Oe(!0)):t()};return(0,on.jsxs)("button",{type:"button",className:(0,ec.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,on.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:o})}),(0,on.jsxs)("div",{className:i.icon,children:[(0,on.jsx)(Zd,{className:i.logo,color:"pink"}),r===!1&&(0,on.jsx)(Qd,{className:i.lock})]})]})};var Xs=require("react"),it=require("react-redux");var sc=require("react");function Rt(t){(0,sc.useEffect)(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function sn(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}function $e(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:s,selection:r}=t.input;return r.start!==r.end?!1:r.end>=s.length?!0:e?n&&new RegExp(n).test(s.substring(r.end))||o&&new RegExp(o).test(s.substring(0,r.end))?!0:n===!1&&o===!1:!1}var rc=require("@reduxjs/toolkit"),tf={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},$s=({ui:t})=>t.overlayCollapsed,ic=(0,rc.createSlice)({name:"ui",initialState:tf,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:Ao,setInputFocus:Gs,setOverlayCollapsed:Pt,setOpenOverlayWhenTyping:ac,setOverlayCollapsedUserOverwrite:lc}=ic.actions,dc=ic.reducer;var fc=require("react");var Li=require("interweave"),It=require("react"),No=require("react-redux");var cc=require("react");function pc(t,e,n){(0,cc.useEffect)(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var uc={root:"dd-1MBCO",actions:"dd--x4cy",closeIconContainer:"dd-1z5NR",closeIcon:"dd-8qMF-",badge:"dd-4Fpkz",formattedText:"dd-EzvTB",assistantContainer:"dd-j6o8F",formattedTextTruncated:"dd-fv169",assistantBadge:"dd-VD57E"};var Mo=require("react/jsx-runtime"),gc=({title:t})=>(0,Mo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24","aria-labelledby":"closeTitle",children:[(0,Mo.jsx)("title",{id:"closeTitle",children:t}),(0,Mo.jsx)("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})]});var Ii={};Y(Ii,{enUS:()=>nf,nlNL:()=>of});var nf={assistant:[{type:0,value:"Assistant"}],close:[{type:0,value:"Close"}]},of={assistant:[{type:0,value:"Assistent"}],close:[{type:0,value:"Sluiten"}]};var Se=require("react/jsx-runtime"),rf=["search","personal-collection-search","search-autocomplete"];function af(t,e,n,o={}){var r;let s="";return rf.includes(e)?s=yd(hi(t,n,{stripAgentPart:!0}),(r=o.searchKeywords)!=null?r:[n]):s=hi(t,n,o),o.placeholders===!0&&(s=vd(s)),s}var lf=()=>{},df=({selected:t,suggestion:e})=>{let n=R(Ii),o=E("inlineSuggestions"),s=(0,No.useSelector)(Cn),[r,i]=(0,It.useState)(!1),a=E("enableSuggestionFeedback"),d=(0,No.useSelector)(h=>h.input.text),l=(0,No.useDispatch)(),c=x("TextSuggestion",uc),u=(0,It.useRef)(null),p=e.source==="assistant",f=a&&!p;(0,It.useEffect)(()=>{let h=setTimeout(()=>{l(hl({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(h)}},[e]),pc(u,"click",()=>{l(ye({suggestion:e,text:e.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let m=()=>{l(Vt({source:e.source,text:e.text,assistantCode:e.assistantCode}))},g=(0,It.useMemo)(()=>af(e.text,e.source,s,{stripAgentPart:o,placeholders:!0,searchKeywords:e.searchKeywords}),[o,e.text,e.source,s,e.searchKeywords]);return e.source==="gpt"&&!o?null:(0,Se.jsxs)("div",{className:c.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,Se.jsx)(I,{ref:u,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:lf,children:e.source==="assistant"?(0,Se.jsxs)("div",{className:c.assistantContainer,children:[(0,Se.jsx)(Li.Interweave,{containerTagName:"div",tagName:"span",className:c.formattedTextTruncated,content:g}),(0,Se.jsx)("span",{className:c.assistantBadge,children:n("assistant")})]}):(0,Se.jsx)(Li.Interweave,{containerTagName:"div",tagName:"span",className:c.formattedText,content:g})}),f&&r&&(0,Se.jsx)("div",{className:c.actions,children:(0,Se.jsx)(Ks,{source:"overlay",context:d,suggestion:e})}),p&&r&&(0,Se.jsx)("div",{className:c.closeIconContainer,children:(0,Se.jsx)("button",{type:"button",className:c.closeIcon,onClick:m,title:n("close"),children:(0,Se.jsx)(gc,{title:n("close")})})})]})},mc=df;var hc=require("react/jsx-runtime"),cf=({suggestions:t,selectedIndex:e,reverse:n})=>(0,fc.useMemo)(()=>{let s=t.map((r,i)=>(0,hc.jsx)(mc,{index:i,selected:i===e,suggestion:r},`${r.text}-${r.source}`));return n?s.reverse():s},[t,e,n]),qs=cf;var yc={root:"dd-PfvRI",paper:"dd-HYlyY"};var Oo=require("react/jsx-runtime"),pf=()=>{let t=(0,Xs.useRef)(null),e=x("InlineSuggestionsOverlay",yc),n=(0,it.useSelector)($e),o=(0,it.useDispatch)(),s=(0,it.useSelector)(ne),r=(0,it.useSelector)(bn),i=(0,it.useSelector)($s),a=E("showTextSuggestions"),d=(0,it.useSelector)(Wt),l=(0,it.useSelector)(to);return Rt(()=>{setTimeout(()=>{o(Pt({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Xs.useEffect)(()=>{let c=t.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let u=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-u.right,0)}px`}),i||!n||!a||d.length===0||s!==!0||r===!1?null:(0,Oo.jsx)("div",{className:e.root,"data-variant":"inline",children:(0,Oo.jsx)("div",{ref:t,className:e.paper,children:(0,Oo.jsx)(ie,{children:(0,Oo.jsx)(qs,{suggestions:d,selectedIndex:l})})})})},vc=pf;var xc=require("react-redux");var Do=require("react/jsx-runtime"),uf=({children:t})=>{let n=E("locale").replace("-","");return(0,Do.jsx)(pi.Provider,{value:n,children:t})},gf=({store:t,customStyles:e={},children:n})=>(0,Do.jsx)(xc.Provider,{store:t,children:(0,Do.jsx)(uf,{children:(0,Do.jsx)(Zn.Provider,{value:e,children:n})})}),at=gf;var Qs=O(require("classnames")),_n=require("react"),Be=require("react-redux");var Sc=require("react");function bc(t,e){let[n,o]=(0,Sc.useState)(()=>{if(typeof window=="undefined")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return k.error(r),e}});return[n,r=>{try{let i=r instanceof Function?r(n):r;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){k.error(i)}}]}var Cc=()=>/Mac/i.test(navigator.platform);var wc=O(require("classnames")),lt=require("react");var Ai={};Y(Ai,{enUS:()=>mf,nlNL:()=>ff});var mf={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"}]}]},ff={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 Tc={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var Lt=require("react/jsx-runtime"),Mi=(t,e,n)=>o=>(0,Lt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),hf=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o,onLogIn:s})=>{let r=R(Ai),i=me(),a=x("Login",Tc),d=E("productName"),l=(0,lt.useCallback)(h=>{h.preventDefault(),o&&o(Number.parseInt(h.target.value,10))},[]),c=(0,lt.useCallback)(h=>{h.preventDefault(),i.send(Pn,!0)},[e]),u=(0,lt.useMemo)(()=>h=>(0,Lt.jsx)("a",{onClick:T=>{T.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),p=(0,lt.useCallback)(h=>(0,Lt.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:h},"prompt"),[c]),{min:f,hour:m,day:g}=(0,lt.useMemo)(()=>({min:Mi(a,600,l),hour:Mi(a,3600,l),day:Mi(a,3600*12,l)}),[]);return(0,Lt.jsxs)("div",{className:(0,wc.default)(t,a.root),children:[r("loginPlease",{login:n?p:u,productName:d}),o&&(0,Lt.jsxs)(lt.Fragment,{children:[(0,Lt.jsx)("br",{}),r("snooze",{min:f,hour:m,day:g})]})]})},Js=hf;var kc=require("react-redux");var Ec={root:"dd-DoQhb",text:"dd-Jwnev"};var _o=require("react/jsx-runtime"),yf=({title:t})=>{let e=x("SearchTrigger",Ec),n=(0,kc.useDispatch)(),o=V();return(0,_o.jsxs)("button",{type:"button",className:e.root,onClick:()=>{n(Oe(!0)),o("open search",{via:"autocomplete-overlay"})},children:[(0,_o.jsx)(Nn,{}),(0,_o.jsx)("span",{className:e.text,children:t})]})},Rc=yf;var Ni={};Y(Ni,{enUS:()=>vf,nlNL:()=>xf});var vf={arrowHint:[{type:0,value:"Tip: use arrow keys to navigate suggestions"}],searchHintWindows:[{type:0,value:"Press CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],searchHintMac:[{type:0,value:"Press CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Close"}],search:[{type:0,value:"Search"}],dismiss:[{type:0,value:"Dismiss"}],dismissError:[{type:0,value:"Dismiss error"}]},xf={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}],dismiss:[{type:0,value:"Sluiten"}],dismissError:[{type:0,value:"Foutmelding sluiten"}]};var Pc={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2",loginError:"dd-KCXeb",loginErrorMessage:"dd-Bv-BG",loginErrorDismiss:"dd-iSCjU"};var K=require("react/jsx-runtime"),Sf=({onLogIn:t})=>{let e=x("SuggestionsOverlay",Pc),n=R(Ni),o=(0,Be.useSelector)($e),s=(0,Be.useSelector)(fl),r=(0,Be.useDispatch)(),i=(0,_n.useRef)(null),a=E("searchTriggerKey"),d=E("productName"),l=(0,Be.useSelector)($s),c=(0,Be.useSelector)(ne),u=(0,Be.useSelector)(nl),p=(0,Be.useSelector)(bn),[f,m]=(0,_n.useState)(null),g=E("showSearch"),h=E("showTextSuggestions"),b=E("adminUrl"),T=E("isEmbedded"),C=E("suggestionsPlacement"),[w,L]=bc("dd-snooze-until-ms",0),N=l||w>Date.now(),B=(0,Be.useSelector)(Wt),X=(0,Be.useSelector)(to),Le=B.filter(W=>W.source!=="gpt").length,Ce=()=>{N&&L(0),r(lc(!N))},_=W=>{let Ye=Date.now()+W*1e3;L(Ye),k.info(`Snooze until: ${new Date(Ye)}`),r(Pt({collapse:!0}))};return(0,_n.useEffect)(()=>{Le===0&&m(null)},[B,Le]),Rt(()=>{r(Pt({collapse:!0,skipWhenInputFocus:!0}))}),c===null||p===!1?null:c===!1?(0,K.jsxs)("div",{ref:i,className:(0,Qs.default)(e.root,{[e.isCollapsed]:N}),children:[!N&&(0,K.jsxs)("div",{className:e.triggers,children:[(0,K.jsx)("div",{style:{flex:1}}),(0,K.jsx)("div",{className:e.triggersRight,children:(0,K.jsx)(Bt,{className:e.toggleButton,title:n("collapse"),onClick:Ce,isCollapsed:!1})})]}),(0,K.jsx)("div",{className:e.toggleButtonWrapper,children:(0,K.jsx)(Bt,{className:e.toggleButton,title:n("open",{productName:d}),onClick:Ce,isCollapsed:!0})}),(0,K.jsxs)("div",{className:e.collapsible,children:[u&&(0,K.jsxs)("div",{className:e.loginError,children:[(0,K.jsx)("span",{className:e.loginErrorMessage,children:u}),(0,K.jsx)("button",{type:"button",className:e.loginErrorDismiss,onClick:()=>r(ls()),"aria-label":n("dismissError"),children:n("dismiss")})]}),(0,K.jsx)(Js,{loginUrl:b,isEmbedded:T,onLogIn:t,onSnooze:_})]})]}):!s||!o?null:(0,K.jsxs)("div",{ref:i,className:(0,Qs.default)(e.root,{[e.isCollapsed]:N}),children:[!N&&(0,K.jsxs)("div",{className:e.triggers,children:[(0,K.jsx)("div",{style:{flex:1},children:g&&(0,K.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(n(Cc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:a.toUpperCase()})),onMouseLeave:()=>m(null),children:(0,K.jsx)(Rc,{title:n("search")})})}),(0,K.jsxs)("div",{className:e.triggersRight,onFocus:()=>{},children:[(0,K.jsx)("div",{className:(0,Qs.default)(!f&&e.hintsHidden,e.hints),children:f}),(0,K.jsx)(Bt,{className:e.toggleButton,title:n("collapse"),onClick:Ce,isCollapsed:!1})]})]}),(0,K.jsx)("div",{className:e.toggleButtonWrapper,children:(0,K.jsx)(Bt,{className:e.toggleButton,title:n("open",{productName:d}),onClick:Ce,isCollapsed:!0})}),Le>0&&h&&(0,K.jsx)("div",{className:e.collapsible,onFocus:()=>{},children:(0,K.jsx)(ie,{children:(0,K.jsx)(qs,{suggestions:B,selectedIndex:X,reverse:C==="above"})})})]})},Ic=Sf;var gr=O(require("classnames")),Yc=require("interweave"),ut=require("react"),ep=require("react-redux");var Fn=require("react");function Zs(t){return t.contentEditable==="true"}function bf(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let s=o.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),n=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:n}}function Lc(t){let{selectionStart:e,selectionEnd:n}=Zs(t)?bf(t):t;return[e,n]}function Ac(t){let[,e]=(0,Fn.useState)(),n=(0,Fn.useRef)(null);return n.current=Lc(t),(0,Fn.useEffect)(()=>{let o=()=>{var a;let[s,r]=(a=n.current)!=null?a:[],i=Lc(t);(!i||s!==i[0]||r!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function Mc(t,e){if(!e)return;let n=t,{value:o}=n,[s,r]=e,i=o.match(rs);if(!i||i.length===0)return;let a=0;i.find(d=>{let l=o.indexOf(d,a);return s>l&&r<l+d.length?(n.selectionStart=l,n.selectionEnd=l+d.length,!0):(a=l+d.length,!1)})}var Nc=require("react"),Cf=["div","span","mark","strong","b","i","u","em"];function Oi(t,e,n=0){var r;let o=t[t.length-1],s=typeof o=="object"&&o!==null?(r=o.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,o];if(Cf.includes(s)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),(0,Nc.cloneElement)(o,{children:Oi(i,e,n+1)})]}return[...t,...e]}function rn(t){return t.tagName.toLowerCase()==="textarea"}var Oc={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 Vc=O(require("classnames")),jc=require("interweave"),ar=require("react");var Hn=require("react");function Dc(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let s=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(n)]}function Ys(t){let e=(0,Hn.useRef)(null),[n,o]=(0,Hn.useState)(!1);return(0,Hn.useEffect)(()=>{var c;let s=!1,r=Number.parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[i,a]=Dc((u,p)=>{let f=e.current;if(!f)return;let m=u/r,g=p/r,h=f.getBoundingClientRect(),b=m>h.x&&m<h.x+h.width&&g>h.y&&g<h.y+h.height;b&&!s?(s=!0,o(!0)):!b&&s&&(s=!1,o(!1))},({clientX:u,clientY:p})=>[u,p]),[d,l]=Dc(()=>{s=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",d),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",d)}},[e]),[e,n]}function _c(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function er(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function Fc(t){return t!=null}var _i=O(require("classnames")),Re=require("react");var tr=require("react"),Tf=["bottom","height","left","right","top","width"],wf=(t={},e={})=>Tf.some(n=>t[n]!==e[n]),dt=new Map,Hc,Bc=()=>{let t=[],e=[];dt.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let s=o.getBoundingClientRect();wf(s,n.rect)&&(n.rect=s,t.push(n))}),e.forEach(n=>{dt.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),Hc=window.requestAnimationFrame(Bc)};function Ef(t,e){return{observe(){let n=dt.size===0;if(dt.has(t)){let o=dt.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else dt.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&Bc()},unobserve(){let n=dt.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||dt.delete(t),dt.size||cancelAnimationFrame(Hc)}}}}function Di(t){let[e,n]=(0,tr.useState)(null);return(0,tr.useLayoutEffect)(()=>{if(!t.current)return;let o=Ef(t.current,s=>{n(s)});return o.observe(),()=>{o.unobserve()}},[t]),e}var Bn=require("react"),Kc=require("react-dom");var Uc={root:"dd-r-dgo"};var zc=({children:t,parentNode:e})=>{let[n,o]=(0,Bn.useState)(null),s=(0,Bn.useContext)(Zn);return(0,Bn.useLayoutEffect)(()=>{let r=document.createElement("div");return sn(r),r.classList.add(Uc.root),s!=null&&s.portalRootNode&&r.classList.add(s==null?void 0:s.portalRootNode),(e||document.body).appendChild(r),o(r),()=>{r.isConnected&&r.remove()}},[]),n?(0,Kc.createPortal)(t,n):null};var Ge={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 nr=require("react/jsx-runtime"),or=(t=!1)=>{let[e,n]=(0,Re.useState)(t),o=(0,Re.useCallback)(()=>n(!0),[]),s=(0,Re.useCallback)(()=>n(!1),[]),r=(0,Re.useCallback)(()=>n(a=>!a),[]),i=(0,Re.useRef)(null);return{opened:e,open:o,close:s,toggle:r,triggerRef:i}};function Fi(t,e=null,n=0){if(!t)return{display:"none"};let o=e?t.top-e.top<0||t.top<e.top-n?e.top-n:t.top+t.height>e.top+e.height+n?e.top+e.height+n-t.height:t.top:t.top,s=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:s,height:t.height,width:t.width}}var Un=l=>{var c=l,{className:t,triggerRef:e,boundaryRef:n=(0,Re.createRef)(),position:o="above",align:s="center",children:r,toStyle:i=Fi,parentNode:a}=c,d=M(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let u=Di(e),p=Di(n),f=(0,Re.useMemo)(()=>i(u,p,0),[u,p]);return(0,nr.jsx)(zc,{parentNode:a,children:(0,nr.jsx)("div",S(y({className:(0,_i.default)(Ge.ref,{[Ge.positionAbove]:o==="above",[Ge.positionBelow]:o==="below",[Ge.positionLeft]:o==="left",[Ge.positionRight]:o==="right",[Ge.alignStart]:s==="start",[Ge.alignCenter]:s==="center",[Ge.alignEnd]:s==="end"}),style:f},d),{role:"dialog",children:(0,nr.jsx)("div",{className:(0,_i.default)(t,Ge.root),children:r})}))})};var Wc=O(require("classnames")),sr=require("react");var ct={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"),rr=(0,sr.forwardRef)((s,o)=>{var r=s,{className:t,children:e}=r,n=M(r,["className","children"]);let i=(0,sr.useRef)(null),a=x("TabCompletion",ct);return(0,Hi.jsx)("div",S(y({ref:er([i,o]),className:(0,Wc.default)(t,a.popoverContentContainer)},n),{children:(0,Hi.jsx)("div",{className:a.popoverContent,children:e})}))});var At=require("react/jsx-runtime"),kf=t=>e=>{let n=Fi(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},Rf=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:s})=>{let r=x("TabCompletion",ct),i=or(),a=(0,ar.useMemo)(()=>kf(t.getBoundingClientRect()),[t]),[d,l]=Ys(t);return(0,ar.useEffect)(()=>{l?i.open():i.close()},[l]),(0,At.jsxs)("span",{children:[(0,At.jsx)("mark",{ref:er([d,i.triggerRef]),className:(0,Vc.default)(r.matchKeyword,{[r.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&(0,At.jsx)(Un,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,At.jsx)(rr,{style:n,children:(0,At.jsx)("div",{className:r.hintText,children:s})})})]})},ir=class extends jc.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(s=>S(y({},s),{keywordRegex:new RegExp(`\\b${_c(s.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=this.preparedKeywordMatches.map(r=>{if(this.usedKeywordMatches.has(r))return null;let i=n.match(r.keywordRegex);if(!i)return null;let a=n.charAt(i.index-1),d=n.charAt(i.index+r.keyword.length);return a==="{"&&d==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:r.suggestion,preparedKeywordMatch:r,valid:!0}}).filter(Fc);if(o.length===0)return null;let s=o.reduce((r,i)=>i.index<r.index?i:r);return this.usedKeywordMatches.add(s.preparedKeywordMatch),s}replaceWith(n,o){return(0,At.jsx)(Rf,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:n},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var $c=require("interweave"),Gc=O(require("classnames"));var Bi=require("react/jsx-runtime"),Pf=({inputElement:t,children:e})=>{let n=x("TabCompletion",ct),[o,s]=Ys(t);return(0,Bi.jsx)("mark",{ref:o,className:(0,Gc.default)(n.matchPlaceholder,{[n.hover]:s}),children:e})},lr=class extends $c.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,Bi.jsx)(Pf,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var cr=O(require("classnames")),Zc=require("interweave"),de=require("react"),ur=require("react-redux");var Ui=require("react/jsx-runtime"),qc=()=>(0,Ui.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,Ui.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"),Fo=require("react-redux"),Jc=O(require("lodash.debounce"));var Xc={root:"dd-ky-Bv",content:"dd-kV5e1"};function dr(t,e,n){var s;let o=((s=t.imageSizes)==null?void 0:s[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(r){return null}}function Ki(t){return t.replace("https://www.","").replace("https://","")}var Pe=require("react/jsx-runtime"),If=3,Lf=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Af=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:s=If})=>{let r=x("LinkSearch",Xc),[i,a]=(0,qe.useState)(""),d=(0,Fo.useDispatch)(),l=(0,Fo.useSelector)(Kd("url")),c=(0,Fo.useSelector)(Bl("URL")),u=(0,qe.useMemo)(()=>c.map(Lf),[c]),[p,f]=(0,qe.useState)(u.length-1),m=E("fallbackImage"),g=C=>{let w=C.target;a(w.value)},h=(C,w)=>{C.stopPropagation(),C.preventDefault(),window.open(w,"_blank")},b=C=>{var N;let w=p-1<0?u.length-1:p-1,L=p+1===u.length?0:p+1;C.code==="Escape"&&(a(""),e()),C.code==="ArrowUp"&&f(w),C.code==="ArrowDown"&&f(L),C.code==="Enter"&&t(((N=u[p])==null?void 0:N.text)||i)},T=(0,qe.useCallback)((0,Jc.default)(C=>{d(Gt({query:C,type:"URL",tags:["link-search"]}))},300),[]);return(0,qe.useEffect)(()=>{i&&T(i)},[i]),(0,qe.useEffect)(()=>()=>{d(ys())},[]),(0,Pe.jsxs)("div",{className:r.root,children:[(0,Pe.jsx)(ie,{withDivider:!0,children:(i?u:l).slice(0,s).map((C,w)=>(0,Pe.jsx)(I,{selected:p===w,onClick:()=>t(C.text),"data-testid":"linksearch-suggestion",children:(0,Pe.jsxs)(F,{children:[(0,Pe.jsx)(F.Image,{src:dr(C,"small",m||void 0),title:C.title||C.text}),(0,Pe.jsxs)(F.Content,{className:r.content,cropText:!0,children:[(0,Pe.jsx)(F.Title,{children:C.title||Ki(C.text)}),C.title&&Ki(C.text)]}),(0,Pe.jsx)(I.Actions,{children:(0,Pe.jsx)(I.ActionButton,{label:o,onClick:L=>h(L,C.text)})})]})},C.text))}),(0,Pe.jsx)(yo,{value:i,onChange:g,autoFocus:!0,placeholder:n,onKeyUp:b})]})},Qc=Af;var zi={};Y(zi,{enUS:()=>Mf,nlNL:()=>Nf});var Mf={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}],addToPersonalCollection:[{type:0,value:"Add to Personal Collection"}]},Nf={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}],addToPersonalCollection:[{type:0,value:"Toevoegen aan Personal Collection"}]};var oe=require("react/jsx-runtime"),Of=(0,de.forwardRef)((t,e)=>{let n=x("TabCompletion",ct);return(0,oe.jsx)("mark",{ref:e,className:(0,cr.default)(n.matchSelection)},"selection-start")}),Df=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:s})=>{let r=R(zi),i=x("TabCompletion",ct),a=E("addToPersonalCollection"),d=(0,ur.useSelector)(kt("/admin/personal-collection/new")),l=(0,de.useRef)(null),c=(0,de.useRef)(null),[u,p]=(0,de.useState)(null),f=(0,ur.useDispatch)(),m=or(document.activeElement===o),[g]=(0,de.useState)(()=>document.createRange());m.triggerRef.current=g,(0,de.useEffect)(()=>()=>g.detach(),[]),(0,de.useEffect)(()=>{let b=t.current,T=l.current;!b||!T||(g.setStart(b,0),g.setEnd(T,0))},[t.current,l.current]),Rt(()=>{m.close()});let h=(0,de.useCallback)(b=>{let T=g.toString(),C=/^http(s?):\/\//.test(b)?b:`https://${b}`,w=`[${T}](${C})`;f(ye({text:w,suggestion:{text:w,source:"search-url",type:"url"},eventMetrics:{inputType:"mouse"},replace:"selection"}))},[]);return(0,oe.jsxs)("span",{children:[(0,oe.jsx)("mark",{ref:l,className:(0,cr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":m.opened?"true":"false",children:s}),m.opened&&(0,oe.jsx)(Un,{className:i.popoverRoot,triggerRef:m.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,oe.jsxs)(rr,{style:n,ref:c,children:[(0,oe.jsxs)("div",{className:(0,cr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:u!==null}),children:[(0,oe.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,oe.jsx)(qc,{}),(0,oe.jsx)("span",{children:"\xA0"}),(0,oe.jsx)("span",{children:r("insertLink")})]}),a&&d&&(0,oe.jsx)("button",{type:"button",tabIndex:u===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>{let b=g.toString(),T=`${d}?text=${encodeURIComponent(b)}`;window.open(T,"_blank")},children:(0,oe.jsx)("span",{children:r("addToPersonalCollection")})})]}),u==="insertLink"&&(0,oe.jsx)(Qc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{p(null),m.close()}})]})})]},"selection-end")},pr=class extends Zc.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,de.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,s]=this.props.selection;if(o===s)return null;let r=this.foundIndex===0?o:s,i=r>=this.charCount&&r<=this.charCount+n.length?{index:r-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let a=this.foundIndex===1;return i&&a?this.charCount+=r-this.charCount:this.charCount+=n.length,i?y({isStart:a},i):null}replaceWith(n,o){return o.isStart?(0,oe.jsx)(Of,{ref:this.startRef}):(0,oe.jsx)(Df,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var tp=require("react-redux");var pt=require("react/jsx-runtime"),_f=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:d})=>{let l=x("TabCompletion",Oc),c=E("insertLink"),u=E("addToPersonalCollection"),p=E("showMidSentenceSuggestions"),f=E("inlineSuggestions"),m=Ac(a),g=(0,ut.useRef)(null),h=(0,tp.useSelector)(ne);(0,ut.useEffect)(()=>{rn(a)&&m&&Mc(a,m)},[m]);let b=(0,ut.useCallback)(w=>{if(!s||!n)return w;let L=[(0,pt.jsx)("span",{className:l.resetIndent,children:"\u200B"},"u200B"),(0,pt.jsx)("span",{"data-testid":"tab-completion",className:(0,gr.default)(l.tabText,l.resetIndent),"data-source":d,children:n},"tabText")];return o&&L.push((0,pt.jsx)("span",{className:(0,gr.default)(l.hint,l.resetIndent),children:(0,pt.jsx)(ns,{keyCode:"tab"},"tabHint")},"tabHint")),Oi(w,L)},[s,n,o]),T=(0,ut.useMemo)(()=>{let w=[];return(c||u)&&w.push(new pr("selection")),w.push(new lr("placeholders")),r&&w.push(new ir("keywords")),w},[f,c,u,r]),C=(0,ut.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||!h?null:(0,pt.jsxs)("div",{ref:w=>{w!=null&&w.parentElement&&(g.current=w==null?void 0:w.parentElement)},className:l.root,style:C,children:[(0,pt.jsx)(Yc.Interweave,{tagName:"span",containerTagName:"div",className:(0,gr.default)(l.container,l.agentText),disableLineBreaks:rn(a),content:e||"\u200B",onAfterParse:b,matchers:T,selection:m,keywordMatches:i,inputElement:a,inputStyle:C,boundaryRef:g,inlineSuggestionsOnlyAtEnd:!p}),(0,pt.jsx)("br",{})]},"tab-completion")},Ff=t=>{var h,b,T;let{input:e,ui:n,settings:o,styleSuggestions:s,conversation:r}=t,i=Tn({input:e}),a=(i==null?void 0:i.text)||"",d=(i==null?void 0:i.source)||"",l=(h=e.html)!=null?h:An(e.text),c=a.indexOf(e.text)===0?a.slice(e.text.length):"",{showTabHint:u}=n,{isSupported:p}=r,{showTabCompletion:f,visible:m,showStyleSuggestions:g}=o;return{showTabHint:u,showStyleSuggestions:g,showTabCompletion:f&&$e(t),content:l,tabText:c,source:d,keywordMatches:(T=(b=s.list)==null?void 0:b.keywordMatches)!=null?T:[],enabled:m&&p!==!1}},np=(0,ep.connect)(Ff)(_f);var Ot=require("react"),q=require("react-redux");var Mt=require("@reduxjs/toolkit");var op=require("marked"),sp=(t,e)=>{let n=[],o=new op.Marked,s=r=>{r.type==="code"&&r.lang===e&&n.push(r.text)};return o.use({walkTokens:s}),o.parse(t),n};var rp={cues:[],threads:{},pending:[]},ip=t=>{var e;return(e=t.assistants)==null?void 0:e.cues};var ap=t=>e=>{var n,o;return(o=(n=e.assistants)==null?void 0:n.threads[t])!=null?o:null},mr=(0,Mt.createAction)("assistants/callToAction"),Ho=(0,Mt.createAsyncThunk)("assistants/evaluateKnowledgeAssistant",(t,e)=>v(null,null,function*(){var l;let{threadId:n}=t,{onNewThreadId:o}=t,{deepdeskAPI:s}=e.extra,r=e.getState(),{platformVariables:i}=r.info;n||(n=(yield s.createAssistantThread({assistantCode:t.assistantCode})).id,o&&o(n)),yield s.postMessageToAssistantThread({assistantCode:t.assistantCode,threadId:n,message:t.input});let a=yield e.dispatch(Xe(S(y({skipState:!0},t),{input:{},threadId:n})));if(a.error)throw new Error(a.error.message);let d=a.payload.output[0];return{threadId:n,question:t.input,evaluationId:a.payload.evaluationId,answer:{answer:Ne(d.response,i!=null?i:{}),sources:(l=d.sources)!=null?l:[]}}})),xk=(0,Mt.createAction)("assistants/extractedTextSuggestions"),Xe=(0,Mt.createAsyncThunk)("assistants/evaluate",(t,e)=>v(null,null,function*(){var g;let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra,{transcript:s,input:r={},threadId:i}=t,a=e.getState(),{platformVariables:d}=a.info,l=(g=a.conversation.current)==null?void 0:g.externalId,c;if(s==="in-memory-transcript"){if(!o.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");c=yield o.conversationQuery()}else Array.isArray(s)&&(c=s);if(t.includeMetadata){if(!a.conversation.current)throw new Error("Can't include metadata, no current conversation");let{metadata:h}=a.conversation.current;Object.assign(r,{metadata:h})}let u=yield n.evaluateAssistant(t.assistantCode,{input:r,transcript:c,externalConversationId:l,threadId:i});if(u.evaluationStatus!=="success")return e.rejectWithValue(`Assistant ${t.assistantCode} evaluation failed: ${u.evaluationStatus}`);let f=(Array.isArray(u.output)?u.output:[u.output]).map(h=>S(y({},h),{name:Ne(h.name,d),response:Ne(h.response,d)})),m=[];return f.forEach(h=>{let b=sp(h.response,"reply"),T=b.length>0?b:[h.response];m.push(...T.map(C=>({text:C,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name})))}),m.length>0&&e.dispatch(wn(m)),S(y({},u),{output:f})})),lp=(0,Mt.createSlice)({name:"assistants",initialState:rp,reducers:{resetCues(t){t.cues=[]},removeCueByCode(t,e){t.cues=t.cues.filter(n=>n.code!==e.payload.code)},removeThreadById(t,e){delete t.threads[e.payload]},receiveChunk(t,e){let{code:n,name:o,payload:s,evaluationId:r}=e.payload,i=t.cues.findIndex(a=>a.code===n);i!==-1?t.cues[i].response+=s.text:t.cues.push({code:n,name:o,evaluationId:r,response:s.text})},userNotification(t,e){let n=t.cues.filter(d=>d.code!==e.payload.code),{code:o,name:s,evaluationId:r,payload:i}=e.payload,{callToAction:a}=i;t.cues=[...n,{code:o,name:s,evaluationId:r,response:i.message,editable:i.editableMessage,callToAction:a&&{label:a.displayName,event:a.onClickEvent,value:a.eventPayload}}]}},extraReducers:t=>{t.addCase(Xe.pending,(e,n)=>{e.pending.includes(n.meta.arg.assistantCode)&&k.warn(`Assistant ${n.meta.arg.assistantCode} already evaluating`),e.pending.push(n.meta.arg.assistantCode)}).addCase(Xe.rejected,(e,n)=>{var s;k.warn((s=n.error)==null?void 0:s.message);let o=e.pending.indexOf(n.meta.arg.assistantCode);o!==-1&&e.pending.splice(o,1)}).addCase(Xe.fulfilled,(e,n)=>{let o=e.pending.indexOf(n.meta.arg.assistantCode);if(o!==-1&&e.pending.splice(o,1),n.meta.arg.skipState)return;let{evaluationId:s,output:r}=n.payload,i=r.map(l=>l.code),a=e.cues.filter(l=>!i.includes(l.code)),d=r.map(l=>S(y({},l),{evaluationId:s}));e.cues=[...a,...d]}).addCase(Ho.fulfilled,(e,n)=>{let r=n.payload,{threadId:o}=r,s=M(r,["threadId"]);e.threads[o]=[...e.threads[o]||[],s]}).addCase(J,()=>rp)}}),{removeCueByCode:fr,resetCues:Sk,removeThreadById:dp,receiveChunk:cp,userNotification:pp}=lp.actions,up=lp.reducer;var Bo=require("@reduxjs/toolkit");var Hf={token:null,interval:null},Wi=(0,Bo.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),Vi=(0,Bo.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(Wi()),setInterval(()=>o(Wi()),n)}),gp=(0,Bo.createSlice)({name:"passwordlessToken",initialState:Hf,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Wi.fulfilled,(e,n)=>{e.token=n.payload.token}),t.addCase(Vi.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollPasswordlessToken:mp}=gp.actions,fp=gp.reducer;var hp=require("@reduxjs/toolkit");function Bf(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}var yp=(0,hp.createSelector)([ip],t=>t.map(n=>({text:n.response,title:n.name,callToAction:n.callToAction,editable:n.editable,isLoading:n.isLoading,evaluationId:n.evaluationId,rule:{id:Bf(n.code),label:n.code,name:n.name,description:n.name}})));var hr=require("react"),$i=O(require("classnames"));var ji=require("react/jsx-runtime"),Kn=()=>(0,ji.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,ji.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 vp={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"),Uf=({entities:t})=>{let e=x("EntitiesWidgetList",vp),[n,o]=(0,hr.useState)(void 0),s=V(),r=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),We(a.text),s("entity copied",{entity:a,type:"copy"}))};return(0,hr.useEffect)(()=>{let a=setTimeout(r,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,$i.default)(e.icon),children:(0,Je.jsx)(Kn,{})}),(0,Je.jsx)("span",{className:(0,$i.default)(e.icon,n===d&&e.iconClicked),children:(0,Je.jsx)(Kn,{})})]})]},a.text))})},xp=Uf;var Gi=require("react/jsx-runtime"),Sp=()=>(0,Gi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Gi.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 Pp=require("react"),Ip=require("react-redux");var zn=require("react"),bp=require("react-redux");function yr(t,e){let n=(0,zn.useRef)(t);n.current=t;let[o,s]=(0,zn.useState)(void 0),[r,i]=(0,zn.useState)(void 0),[a,d]=(0,zn.useState)("idle"),l=(0,bp.useDispatch)();return{error:r,state:a,data:o,call:p=>v(null,null,function*(){d("loading"),yield l(n.current(p)).unwrap().then(f=>{s(f),d("done"),e!=null&&e.onSuccess&&(e==null||e.onSuccess(f))}).catch(f=>{i(f),d("error"),e!=null&&e.onError&&(e==null||e.onError(f))})}),reset:()=>{d("idle"),s(void 0),i(void 0)}}}var Cp={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var Tp={root:"dd-nazq3",rotation:"dd-3EHTv"};var Ep=require("react/jsx-runtime"),Kf=({size:t=12})=>{let e=x("LoadingSpinner",Tp);return(0,Ep.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},wp=Kf;var qi=require("react/jsx-runtime"),kp=()=>(0,qi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:(0,qi.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 Uo=require("react/jsx-runtime"),Rp=t=>(0,Uo.jsxs)("svg",S(y({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},t),{children:[(0,Uo.jsx)("title",{id:"checkTitle",children:"Check"}),(0,Uo.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 Xi={};Y(Xi,{enUS:()=>zf,nlNL:()=>Wf});var zf={error:[{type:0,value:"Something went wrong"}]},Wf={error:[{type:0,value:"Er ging iets fout"}]};var be=require("react/jsx-runtime"),Vf=3e3,jf=({assistantOptions:t})=>{let e=x("OnDemandAssistants",Cp),n=R(Xi),o=(0,Pp.useRef)(),s=yr(Xe),r=(0,Ip.useSelector)(ld),i=V(),a=r.filter(c=>c.isPinned),d=r.filter(c=>!c.isPinned),l=c=>v(null,null,function*(){clearTimeout(o.current),i("trigger on demand assistant",{assistantCode:c}),yield s.call(S(y({},t),{assistantCode:c})),o.current=setTimeout(()=>s.reset(),Vf)});return r.length===0?null:(0,be.jsxs)("div",{className:e.root,children:[a.map(({assistant:c,assistantName:u,displayName:p})=>(0,be.jsx)("button",{type:"button",className:e.button,disabled:s.state==="loading",onClick:()=>l(c),children:p||u},c)),d.length>0&&(0,be.jsxs)(ee,{placement:"top-end",children:[(0,be.jsx)(ee.Trigger,{className:e.trigger,disabled:s.state==="loading",children:(0,be.jsx)(Hs,{"data-testid":"trigger"})}),(0,be.jsx)(ee.Content,{className:e.nav,"data-testid":"popover",children:d.map(({assistant:c,assistantName:u,displayName:p})=>(0,be.jsx)(ee.Button,{className:e.item,disabled:s.state==="loading",onClick:()=>l(c),children:p||u},c))})]}),s.state==="loading"&&(0,be.jsx)(wp,{}),s.state==="done"&&(0,be.jsx)(Rp,{"data-testid":"trigger-done"}),s.state==="error"&&(0,be.jsx)(Td,{trigger:(0,be.jsx)(kp,{}),children:n("error")})]})},Lp=jf;var Kp=require("react-redux");var Np=require("react");var Ap={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var Mp=require("react/jsx-runtime"),$f=({width:t})=>{let e=x("LoadingProgressBar",Ap);return(0,Mp.jsx)("div",{className:e.loadingBar,style:{width:t}})},vr=$f;var gt=require("react/jsx-runtime"),xr=({title:t})=>{let e=(0,Np.useRef)(null);return os(e),(0,gt.jsx)(I,{ref:e,children:(0,gt.jsx)(F,{children:(0,gt.jsxs)(F.Content,{children:[(0,gt.jsx)(F.Title,{children:t}),(0,gt.jsx)(vr,{width:"60%"}),(0,gt.jsx)(vr,{width:"90%"}),(0,gt.jsx)(vr,{width:"50%"})]})})})};var Ko={};Y(Ko,{enUS:()=>Gf,nlNL:()=>qf});var Gf={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"}]},qf={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 ln=require("react");var Sr=O(require("classnames")),_p=require("react");var Ji=require("react/jsx-runtime"),Qi=t=>(0,Ji.jsx)("svg",S(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Ji.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 Zi=require("react/jsx-runtime"),Op=t=>(0,Zi.jsx)("svg",S(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Zi.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 Nt(t,e){var s;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(r=>{n.classList.add(r)}),n.addEventListener("animationend",()=>n.remove()),(s=t.parentElement)==null||s.appendChild(n)}var Yi={};Y(Yi,{enUS:()=>Xf,nlNL:()=>Jf});var Xf={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},Jf={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Dp={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};var ea=require("react-redux");var mt=require("react/jsx-runtime"),Qf=({assistantCode:t,assistantOutput:e,evaluationId:n,feedbackType:o,feedbackText:s})=>{let r=x("FeedbackThumbs",Dp),i=E("enableFeedbackForm"),a=(0,ea.useSelector)(ze),d=(0,ea.useSelector)(kt(`/admin/feedback?conversationId=${a}&evaluationId=${n}&type=${o}&text=${s}&assistantCode=${t}&assistantOutput=${e}`)),l=R(Yi),c=V(),[u,p]=(0,_p.useState)(null),f=h=>{c("Assistant response feedback",{assistantCode:t,assistantOutput:e,evaluationId:n,rating:h})},m=h=>{h.stopPropagation(),Nt(h.target,r.fadeup),p("up"),f("up")},g=h=>{h.stopPropagation(),Nt(h.target,r.fadedown),p("down"),f("down")};return(0,mt.jsxs)("div",{className:r.thumbs,children:[(0,mt.jsx)(I.Button,{title:l("thumbsUp"),onClick:m,icon:(0,mt.jsx)(Op,{}),className:(0,Sr.default)(r.thumbsUp,u==="up"&&r.selected),disabled:!!u}),i&&d?(0,mt.jsx)(I.Button,{as:"a",title:l("thumbsDown"),href:d,target:"_blank",rel:"noreferrer",onClick:g,icon:(0,mt.jsx)(Qi,{}),className:(0,Sr.default)(r.thumbsDown,u==="down"&&r.selected),disabled:!!u}):(0,mt.jsx)(I.Button,{title:l("thumbsDown"),onClick:g,icon:(0,mt.jsx)(Qi,{}),className:(0,Sr.default)(r.thumbsDown,u==="down"&&r.selected),disabled:!!u})]})},br=Qf;var Hp=O(require("dompurify")),ft=require("react");var Fp={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 Bp=require("marked"),Ue=require("react/jsx-runtime");function Zf(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 ta(t){var n,o;let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(s=>s.remove()),(o=(n=e.textContent)==null?void 0:n.trim())!=null?o:""}function Yf(t){return t.replace(/\r\n/g,`
|
|
8
|
+
`)}var eh=({content:t,useLabel:e,copyLabel:n,onCopy:o,onUse:s})=>{let r=x("Markdown",Fp),i=(0,ft.useRef)(null),[a,d]=(0,ft.useState)(null),l=(0,ft.useMemo)(()=>{let g=Bp.marked.parse(Yf(t));return Hp.default.sanitize(g.toString()).replaceAll("</code>",`${Zf(r.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[t]),c=g=>{var T;let h=g.target,b=!!((T=i.current)!=null&&T.querySelector("code"));if(["A","BUTTON"].includes(h.tagName)){d(null);return}a||b&&h.tagName!=="CODE"||!b&&h!==i.current||(h.addEventListener("mouseleave",()=>d(null),{once:!0}),d(h))},u=()=>{if(!a)return;d(null);let g=a.querySelector("button");g&&(Nt(g,r.fadeup),o==null||o(ta(a)))},p=g=>{let h=g.target,b=h instanceof HTMLElement?h:null;if(h instanceof Element?h.closest("a"):null){g.stopPropagation();return}b&&"copyIcon"in b.dataset&&(Nt(b,r.fadeup),o==null||o(ta(b.parentElement)))},f=()=>{!a||!s||(d(null),s(ta(a)))},m=g=>{if(g===null)return;let h=g.getBoundingClientRect();h.left<0?g.style.transform=`translateX(${-h.left+2}px)`:h.right>window.innerWidth&&(g.style.transform=`translateX(${window.innerWidth-h.right-2}px)`)};return(0,Ue.jsxs)(ft.Fragment,{children:[a&&(o||s)&&(0,Ue.jsxs)(Un,{triggerRef:{current:a},className:r.popover,parentNode:a,children:[(0,Ue.jsxs)("div",{className:r.options,ref:m,children:[o&&(a==null?void 0:a.tagName)==="CODE"&&(0,Ue.jsx)("button",{type:"button",className:r.option,onClick:u,children:n}),s&&(0,Ue.jsxs)(ft.Fragment,{children:[(0,Ue.jsx)("div",{className:r.divider}),(0,Ue.jsx)("button",{type:"button",className:r.option,onClick:f,children:e})]})]}),(0,Ue.jsx)("div",{className:r.arrow})]}),(0,Ue.jsx)("div",{ref:i,"data-testid":"widget-markdown-content",className:r.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:c,onClick:p})]})},an=eh;var na={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 ce=require("react/jsx-runtime"),th=500,nh=100,oh=({content:t,onChange:e,onCopy:n})=>{let o=(0,ln.useRef)(null),s=x("WidgetCue",na);return(0,ln.useEffect)(()=>{let r=o.current;if(!r)return;r.style.setProperty("height","0px");let i=Math.min(Math.max(r.scrollHeight,nh),th);r.style.setProperty("height",`${i}px`)},[t]),(0,ce.jsx)("textarea",{ref:o,className:s.editableCue,onCopy:n,onChange:e,value:t})},sh=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:s})=>{let r=x("WidgetCue",na),i=R(Ko),a=V(),d=E("hasKeyboardInput"),[l,c]=(0,ln.useState)(t.text),u=()=>{e&&e(l,t),n(t)},p=(g,h)=>{o&&o(g,t),h&&Nt(h,r.fadeup)},f=g=>{s&&s(g,t)},m=g=>{g.preventDefault(),g.stopPropagation(),n(t)};return(0,ln.useEffect)(()=>{a("Assistant response displayed",{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text})},[]),(0,ce.jsxs)(I,{"data-testid":"cue",children:[(0,ce.jsx)(F,{children:(0,ce.jsxs)(F.Content,{children:[t.title&&(0,ce.jsx)(F.Title,{className:r.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?i(t.rule.label):t.title}),t.editable?(0,ce.jsx)(oh,{content:l,onCopy:()=>{let g=document.getSelection();g&&p(g.toString())},onChange:g=>{var h;return c((h=g.target.value)!=null?h:"")}}):(0,ce.jsx)(an,{content:t.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:p,onUse:d?f:void 0})]})}),(0,ce.jsxs)(I.ButtonsContainer,{children:[(0,ce.jsxs)("div",{className:r.actions,children:[(0,ce.jsx)(I.Button,{onClick:g=>p(l,g.target),variant:"primary",children:i("copyCue")}),t.callToAction&&(0,ce.jsx)(I.Button,{onClick:u,variant:"primary",children:t.callToAction.label}),(0,ce.jsx)(I.Button,{onClick:m,variant:"secondary",children:i("removeCue")})]}),(0,ce.jsx)(br,{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text,feedbackText:t.text,feedbackType:"assistant"})]})]})},Up=sh;var Wn=require("react/jsx-runtime"),rh=({cues:t})=>{let e=(0,Kp.useDispatch)(),n=me(),o=R(Ko),s=V(),r=l=>{e(fr({code:l.rule.label})),s("Assistant response closed",{evaluationId:l.evaluationId,assistantCode:l.rule.label,assistantOutput:l.text})},i=(l,c)=>{We(l),s("Assistant response copied",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,copiedText:l})},a=(l,c)=>{var u;c.callToAction&&(e(mr(c)),s("Assistant call to action",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,eventName:c.callToAction.event,value:(u=c.callToAction.value)!=null?u:l}))},d=(l,c)=>{var u;n.send(nt,{text:l,suggestion:{source:"assistant",assistantCode:(u=c.rule)==null?void 0:u.label,sourceText:l}}),s("Assistant response used",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,usedText:l})};return(0,Wn.jsx)(Wn.Fragment,{children:t.map(l=>l.isLoading?(0,Wn.jsx)(xr,{title:l.rule.label.startsWith("__")?o(l.rule.label):l.title},l.rule.id):(0,Wn.jsx)(Up,{cue:l,onCallToAction:a,onRemove:r,onCopy:i,onUse:d},l.evaluationId))})},zp=rh;var Cr=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 he=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 Vp=({data:t,schema:e})=>{let n=x("WidgetCustomData",Wp),o=s=>{We(s)};return(0,Cr.useEffect)(()=>{k.info("Custom data",t,e)},[t]),(0,he.jsx)("dl",{className:n.root,children:e.map(s=>{let r=ih(t,s.path);return(0,he.jsxs)(Cr.Fragment,{children:[(0,he.jsx)("dt",{className:n.label,children:s.label}),(0,he.jsx)("dd",{className:n.value,children:s.type==="boolean"&&r?(0,he.jsx)("span",{className:n.isTrue,children:s.trueValue}):s.type==="boolean"&&!r?(0,he.jsx)("span",{className:n.isFalse,children:s.falseValue}):s.type==="array"&&Array.isArray(r)&&r.length>0?(0,he.jsxs)("button",{type:"button",onClick:()=>o(r.join(", ")),className:n.copyButton,children:[(0,he.jsx)("span",{className:n.copyButtonText,children:r.join(", ")}),(0,he.jsx)(Kn,{})]}):typeof r=="string"||typeof r=="number"?(0,he.jsxs)("button",{type:"button",onClick:()=>o(`${r}`),className:n.copyButton,children:[(0,he.jsx)("span",{className:n.copyButtonText,children:r}),(0,he.jsx)(Kn,{})]}):"-"})]},s.label)})})};var j=require("react"),wr=require("react-redux");var Vn={};Y(Vn,{enUS:()=>ah,nlNL:()=>lh});var ah={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={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 Tr={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 $p=require("react");var jp={error:"dd-CoAuB"};var oa={};Y(oa,{enUS:()=>dh,nlNL:()=>ch});var dh={errorPrefix:[{type:0,value:"Error:"}]},ch={errorPrefix:[{type:0,value:"Foutmelding:"}]};var zo=require("react/jsx-runtime"),Gp=({message:t})=>{let e=(0,$p.useRef)(null),n=x("WidgetCardError",jp),o=R(oa);return os(e),(0,zo.jsx)(I,{ref:e,children:(0,zo.jsx)(F,{children:(0,zo.jsxs)(F.Content,{className:n.error,children:[o("errorPrefix")," ",t]})})})};var D=require("react/jsx-runtime"),ph=3,uh=({sources:t,onClick:e})=>{let n=R(Vn),o=x("WidgetKnowledgeAssistant",Tr),[s,r]=(0,j.useState)(!1),i=s?t:t.slice(0,ph);return i.length===0?null:(0,D.jsxs)("ul",{className:o.sources,children:[i.map(a=>(0,D.jsx)("li",{className:o.source,"data-testid":"knowledge-assist-source",children:(0,D.jsxs)(ee,{tooltip:!0,placement:"top-start",children:[(0,D.jsx)(ee.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:d=>{d.stopPropagation(),e(a)},children:(0,D.jsx)("span",{className:o.linkContent,children:a.name})}),a.url&&(0,D.jsx)(ee.Content,{className:o.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),i<t&&(0,D.jsx)("button",{type:"button",className:o.showMoreSources,onClick:()=>r(!0),children:n("showMore",{amount:t.length-i.length})})]})},gh=({title:t,description:e})=>(0,D.jsx)(I,{"data-testid":"knowledge-assist-empty-state",children:(0,D.jsx)(F,{children:(0,D.jsxs)(F.Content,{children:[(0,D.jsx)(F.Title,{children:t}),(0,D.jsx)(an,{content:e})]})})}),mh=({innerRef:t,item:e,hasKeyboardInput:n,onCopy:o,onUse:s,onSourceClick:r})=>{var d;let i=R(Vn),a=(0,j.useContext)(Er);return(0,D.jsxs)(I,{"data-testid":"knowledge-assist-answer",ref:t,children:[(0,D.jsx)(F,{children:(0,D.jsxs)(F.Content,{children:[(0,D.jsx)(F.Title,{children:e.question}),(0,D.jsx)(an,{content:e.answer.answer,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:o,onUse:n?s:void 0}),(0,D.jsx)(uh,{sources:(d=e.answer.sources)!=null?d:[],onClick:r})]})}),a.assistantCode&&(0,D.jsxs)(I.ButtonsContainer,{children:[(0,D.jsx)("div",{}),(0,D.jsx)(br,{evaluationId:e.evaluationId,feedbackType:"assistant",assistantCode:a.assistantCode,assistantOutput:e.answer.answer,feedbackText:e.answer.answer})]})]})},Er=(0,j.createContext)(null),kr=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,children:o})=>{let[s,r]=(0,j.useState)(null),[i,a]=(0,j.useState)(!1),[d,l]=(0,j.useState)(null),[c,u]=(0,j.useState)(!!n),[p,f]=(0,j.useState)(null),m=(0,wr.useDispatch)(),g=V(),h=yr(C=>{if(!t)throw new Error("No knowledge assistant was defined");return l(null),e({assistantCode:t,input:C,threadId:s,onNewThreadId(w){r(w)}})},{onSuccess(C){var w;g("Assistant response displayed",{evaluationId:C.evaluationId,assistantCode:t,assistantOutput:C.answer.answer,input:C.question,sources:(w=C.answer.sources)!=null?w:[]}),u(!1)},onError(C){var w;l((w=C.message)!=null?w:"Unknown error")}}),b=C=>v(null,null,function*(){a(!0),f(C),yield h.call(C),a(!1),f(null)}),T={isEnabled:!!t,assistantCode:t,isSubmitting:i,threadId:s,pendingInput:p,errorMessage:d,onSubmit:b,onReset(){s&&m(dp(s)),l(null),r(null),t&&g("Assistant thread reset",{threadId:s!=null?s:void 0,assistantCode:t})}};return(0,j.useEffect)(()=>{n&&T.isEnabled&&b(n)},[n]),(0,D.jsx)(Er.Provider,{value:T,children:o})},Rr=()=>{let t=R(Vn),e=x("WidgetKnowledgeAssistant",Tr),n=(0,j.useContext)(Er),o=(0,j.useRef)(null),[s,r]=(0,j.useState)(""),i=d=>{r(d.target.value)},a=d=>{d.preventDefault(),n.onSubmit(s).then(()=>{var l;o.current&&((l=o.current)==null||l.focus(),r(""))})};return n.isEnabled?(0,D.jsxs)("form",{className:e.form,onSubmit:a,children:[(0,D.jsx)("input",{ref:o,className:e.formInput,placeholder:t("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:s,onChange:i}),(0,D.jsx)("button",{type:"submit",disabled:n.isSubmitting||s==="",className:e.formSubmit,children:t("submitLabel")})]}):null},Pr=({title:t,emptyState:e})=>{var m,g;let n=R(Vn),o=V(),s=x("WidgetKnowledgeAssistant",Tr),r=(0,j.useRef)(null),i=(0,j.useContext)(Er),a=(g=(0,wr.useSelector)(ap((m=i.threadId)!=null?m:-1)))!=null?g:[],d=E("hasKeyboardInput"),l=me(),c=(h,b)=>{We(h),i.assistantCode&&o("Assistant response copied",{assistantCode:i.assistantCode,assistantOutput:h,copiedText:h,evaluationId:b.evaluationId})},u=(h,b)=>{i.assistantCode&&o("Assistant source clicked",{evaluationId:b.evaluationId,assistantCode:i.assistantCode,source:h})},p=h=>{h.preventDefault(),i.onReset()},f=(h,b)=>{l.send(nt,{text:h,suggestion:{source:"assistant",sourceText:h}}),i.assistantCode&&o("Assistant response used",{assistantCode:i.assistantCode,evaluationId:b.evaluationId,assistantOutput:b.answer.answer,usedText:h})};return!i.isEnabled||(a==null?void 0:a.length)===0&&!i.isSubmitting&&!e&&!i.errorMessage?null:(0,D.jsxs)(j.Fragment,{children:[(0,D.jsx)(Ke,{type:"knowledge",title:t,"data-testid":"knowledge",children:(0,D.jsxs)(ie,{withDivider:!0,children:[e&&a.length===0&&!i.pendingInput&&(0,D.jsx)(gh,y({},e)),a.map((h,b)=>(0,D.jsx)(mh,{innerRef:b===a.length-1?r:void 0,item:h,hasKeyboardInput:d,onCopy:T=>c(T,h),onUse:T=>f(T,h),onSourceClick:T=>u(T,h)},`${h.question}_${h.answer}_${b}`)),i.pendingInput&&(0,D.jsx)(xr,{title:i.pendingInput}),i.errorMessage&&(0,D.jsx)(Gp,{message:i.errorMessage})]})}),a.length>0&&(0,D.jsx)("div",{className:s.resetContainer,children:(0,D.jsx)(I.Button,{disabled:i.threadId===null||i.isSubmitting,onClick:p,children:n("resetLabel")})})]})};var Jp=require("react");var fh=/(https?:\/\/[^\s]+)/,Xp=t=>t.split(" ").find(e=>fh.test(e));var Ie=require("react/jsx-runtime"),hh=({suggestion:t,lines:e,onUse:n})=>{var u;let o=t.text||t.url||t.message,s=Xp(o),r=R(Ro),i=E("showImages"),a=E("fallbackImage"),d=E("hasKeyboardInput"),l=p=>{p.preventDefault(),p.stopPropagation(),d&&n(o)},c=(0,Jp.useCallback)(p=>{window.open(s,"_blank"),p.stopPropagation(),p.preventDefault()},[s]);return(0,Ie.jsxs)(I,{onClick:d?l:void 0,"data-testid":"edit-suggestion",children:[(0,Ie.jsxs)(F,{children:[i&&t.image&&(0,Ie.jsx)(F.Image,{src:dr(t,"small",a||void 0),title:t.title}),(0,Ie.jsxs)(F.Content,{children:[t.title&&(0,Ie.jsx)(F.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,Ie.jsx)(I.Labels,{labels:t.searchKeywords}),(0,Ie.jsx)(F.Content,{cropText:e==="single",lineClamp:e==="multiple",children:o})]})]}),(0,Ie.jsxs)(I.Actions,{children:[s&&(0,Ie.jsx)(I.ActionButton,{onClick:c,label:r("visitUrl")}),d&&(0,Ie.jsx)(I.ActionButton,{primary:!0,onClick:l,label:r("useSuggestion")})]})]})},Qp=hh;var Wo=require("react/jsx-runtime"),yh=({lines:t,suggestions:e})=>{let n=me(),o=(s,r)=>{n.send(nt,{text:s,suggestion:S(y({},r),{source:r.source,sourceText:r.text})})};return(0,Wo.jsx)(Wo.Fragment,{children:e.map(s=>(0,Wo.jsx)(Qp,{suggestion:s,lines:t,onUse:r=>o(r,s)},s.text||s.url||s.message))})},Zp=yh;var Vo={};Y(Vo,{enUS:()=>vh,nlNL:()=>xh});var vh={waiting:[{type:0,value:"Loading\u2026"}],waitingForConversation:[{type:0,value:"Waiting for conversation\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}],close:[{type:0,value:"Close"}]},xh={waiting:[{type:0,value:"Laden\u2026"}],waitingForConversation:[{type:0,value:"Wachten op gesprek\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}],close:[{type:0,value:"Sluiten"}]};var 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"),Yp=(t,e)=>{let n=(0,q.useSelector)(ne);(0,Ot.useEffect)(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},Sh=({onLogIn:t})=>{let e=x("Widget",jn),n=E("isEmbedded"),o=E("adminUrl");return(0,P.jsx)("div",{className:e.loginText,children:(0,P.jsx)("div",{children:(0,P.jsx)(Js,{isEmbedded:n,loginUrl:o,onLogIn:t})})},"login")},sa=({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")},bh=()=>{let t=R(Vo),e=(0,q.useDispatch)(),n=x("Widget",jn),o=E("showSearch"),s=E("isEmbedded"),r=(0,q.useSelector)(kt("/admin/")),i=me(),a=E("productName"),d=V();return Yp(()=>{if(s)return e(Vi()),()=>{e(mp())}},[e,s]),!o&&!r?null:(0,P.jsxs)("div",{className:n.shortcutList,children:[o&&(0,P.jsx)(I.Button,{"data-testid":"shortcut-search","aria-label":t("linkSearch"),className:n.shortcut,icon:(0,P.jsx)(Nn,{}),onClick:()=>{i.send("ShowCommandPalette",{isOpen:!0}),d("open search",{via:"widget-shortcut"})},children:t("linkSearch")}),r&&(0,P.jsx)(I.Button,{as:"a",target:"_blank",icon:(0,P.jsx)(Sp,{}),href:r,"data-testid":"shortcut-studio-login","aria-label":t("linkStudioLogin",{productName:a}),className:n.shortcut,rel:"noreferrer",onClick:()=>{d("open my deepdesk",{via:"widget-shortcut"})},children:t("linkStudioLogin",{productName:a})})]})},Ch=({title:t,content:e})=>{let n=R(Vo),[o,s]=(0,Ot.useState)(!0);return o?(0,P.jsx)(Ke,{"data-testid":"custom-data-banner",type:"custom-data-banner",title:t,children:(0,P.jsx)(ie,{withDivider:!0,children:(0,P.jsxs)(I,{children:[(0,P.jsx)(F,{children:(0,P.jsx)(F.Content,{children:(0,P.jsx)(an,{content:e})})}),(0,P.jsx)(I.ButtonsContainer,{children:(0,P.jsx)(I.Button,{onClick:()=>s(!1),children:n("close")})})]})})}):null},Th=()=>{let t=(0,q.useDispatch)(),e=(0,q.useSelector)(So),n=(0,q.useSelector)(cd),o=(0,q.useSelector)(yp),s=(0,q.useSelector)(Pl),r=(0,q.useSelector)(_s),i=(0,q.useSelector)(zs),a=(0,q.useSelector)(Xt),d=(0,q.useSelector)(ze);return(0,Ot.useEffect)(()=>{s&&!n&&k.warn("Custom data provided, but no schema.")},[s,n]),Yp(()=>{e.forEach(({type:l})=>{l==="entities"?t(Fe()):is.includes(l)||t(He(l))})},[t,d,a]),(0,Ot.useEffect)(()=>{o.length>0&&!e.some(l=>l.type==="cues")&&k.warn("Received cues, but cues are not configured in widget.")},[e,o]),(0,P.jsx)(Ot.Fragment,{children:e.map(({type:l,title:c,amount:u,lines:p,schema:f,property:m})=>{var g,h;switch(l){case"entities":return r&&r.length>0&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(xp,{entities:r})},l);case"cues":return o&&o.length>0&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ie,{withDivider:!0,children:(0,P.jsx)(zp,{cues:o})})},l);case"custom-data-banner":return s&&m&&s[m]&&(0,P.jsx)(Ch,{title:c,content:String(s[m])},l);case"custom-data":return s&&f&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ie,{withDivider:!0,children:(0,P.jsx)(Vp,{data:s,schema:f})})},l);default:return((h=(g=i[l])==null?void 0:g.suggestions)==null?void 0:h.length)>0&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ie,{withDivider:!0,children:(0,P.jsx)(Zp,{lines:p,contentType:l,suggestions:i[l].suggestions.slice(0,u)||[]})})},l)}})})},ra=({children:t})=>{let e=x("Widget",jn);return(0,P.jsx)("div",{className:e.footer,children:t})},ia=({children:t})=>{let e=x("Widget",jn);return(0,P.jsx)("div",{className:e.root,"data-testid":"widget",children:t})},wh=({onLogIn:t,knowledgeAssistOptions:e={},assistantOptions:n={transcript:"in-memory-transcript"}})=>{let o=R(Vo),s=(0,q.useSelector)(bn),r=(0,q.useSelector)(ne),i=(0,q.useSelector)(pl),a=(0,q.useSelector)(Xt),d=(0,q.useSelector)(dd("knowledge-assist")),l=(0,q.useSelector)(pd);return s===!1?(0,P.jsx)(sa,{text:o("notSupported")}):r===!1?(0,P.jsx)(Sh,{onLogIn:t}):r===null?(0,P.jsx)(sa,{text:o("waiting")}):!i||!a?(0,P.jsx)(sa,{text:o("waitingForConversation")}):(0,P.jsx)(ia,{children:(0,P.jsxs)(kr,{initialQuestion:e.initialQuestion,assistantCode:l!=null?l:void 0,evaluateKnowledgeAssistFn:Ho,children:[(0,P.jsxs)(hn,{children:[(0,P.jsx)(bh,{}),(0,P.jsx)(Th,{}),d&&(0,P.jsx)(Pr,{title:d.title,emptyState:e.emptyState})]}),(0,P.jsxs)(ra,{children:[d&&(0,P.jsx)(Rr,{}),(0,P.jsx)(Lp,{assistantOptions:n})]})]})})},eu=wh;function $n(t){let e=new Range;return e.selectNodeContents(t),e}function tu(t,e,n){try{return Dt(t,e,n),!0}catch(o){return!1}}function Ir(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Lr(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 s=0,r=!1;function i(d,l){let c=-1,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(d))return l;for(let p=0;p<=d.length;p++)if(u.test(d[p])||c++,c===l)return p;throw new Error("Offset out of range")}function a(d){switch(d.nodeType){case Node.TEXT_NODE:{let l=d.textContent,c=l.replace(jo,""),u=s+c.length,p=e>=s&&e<=u,f=n>=s&&n<=u;if(p){let m=i(l,e-s);m===0&&!f?o.setStartBefore(d):o.setStart(d,m)}f&&(o.setEnd(d,i(l,n-s)),r=!0),s=u;break}case Node.ELEMENT_NODE:{if(Lr(d)&&(s===e&&o.setStartBefore(d),s++,s===n)){o.setEndAfter(d),r=!0;return}for(let c=0;c<d.childNodes.length&&(a(d.childNodes[c]),!r);c++);let l=d.lastChild;Ir(d)&&l&&!Ir(l)&&!Lr(l)&&s++;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:s,endOffset:r,collapsed:i}=e,a,d,l=0;function c(u){let p=u===t,f=u===n,m=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let g=u.textContent;f&&(a=l+g.substring(0,o).replace(jo,"").length),m&&(d=l+g.substring(0,r).replace(jo,"").length),l+=g.replace(jo,"").length;break}case Node.ELEMENT_NODE:{if(Lr(u)&&u.nextSibling){l++;break}!p&&Ir(u)&&u.previousSibling&&l++;for(let g=0;g<u.childNodes.length;g++){let h=f&&g===o,b=m&&g===r;if(h&&(a=l),b&&(d=l),d!==void 0||((!h||!i)&&c(u.childNodes[g]),m&&g===r-1&&(d=l),d!==void 0))break}m&&(d=l);break}default:break}}if(c(t),d===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:d,end:d}}function 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:s,endOffset:r,collapsed:i}=e,a=0,d="";function l(c){let u=c===t,p=c===n,f=c===s;switch(p&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let m=p?o:0,g=f?r:void 0;d+=c.textContent.replace(jo,"").substring(m,g);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&Lr(c)&&c.nextSibling){d+=`
|
|
9
|
+
`;break}!u&&!i&&a===1&&Ir(c)&&c.previousSibling&&(d+=`
|
|
10
|
+
`);let m=p?o:0,g=f?Math.min(r,c.childNodes.length):c.childNodes.length;for(let h=m;h<g&&(l(c.childNodes[h]),a!==2);h++);break}default:break}f&&(a=2)}return l(t),d}var nu=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(nu||{}),ht=class{constructor(e){this.element=e;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(e,n){let o=s=>{n(s)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}handleInteraction(){let e=this.getText(),n=this.getHTML(),o=this.getSelection(),s=this.cachedCaretPosition===null;if(!this.isActive||(e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),e!==this.cachedText?(this.cachedText=e,this.cachedHTML=n,s=!0,this.emit("change",{plainText:e,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,s=!0,this.emit("change",{plainText:e,rawHTML:n})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,s=!0,this.emit("selection",o)),!s))return;let r=this.getCaretPosition();Ct(r,this.cachedCaretPosition)||(this.cachedCaretPosition=r,this.emit("caretposition",r))}handleClick(){this.handleInteraction()}handleFocus(){let e=!this.isFocused;this.isFocused=!0,e&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let e=this.isFocused;this.isFocused=!1,e&&this.emit("blur")}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(nu).includes(n)||n.toLowerCase()==="z"&&(o||s),this.emit("keydown",e)}handleKeyUp(e){this.handleInteraction(),this.emit("keyup",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var o,s;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()})}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}off(e,n){if(!this.eventListeners[e])return;let o=this.eventListeners[e].indexOf(n);o!==-1&&this.eventListeners[e].splice(o,1)}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function ou(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var dn=class extends ht{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(){let n=this.getRootNode();if(n.activeElement!==this.element)return null;let o="getSelection"in n?n.getSelection():window.getSelection();if(!o)return null;let s=o.rangeCount>0?o.getRangeAt(0):null;if(!s)return null;let r=this.element.ownerDocument.createRange();return r.setStart(s==null?void 0:s.startContainer,s==null?void 0:s.startOffset),r.setEnd(s==null?void 0:s.endContainer,s==null?void 0:s.endOffset),!r||!this.element.contains(r.startContainer)||!this.element.contains(r.endContainer)?null:r}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let o=n.getBoundingClientRect();return!ou(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!ou(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&&tu(this.element,o.start,o.end))return o;let s=$n(this.element);return s.collapse(!1),$o(this.element,s)}getSelectedText(){let{start:n,end:o}=this.getSelection();return Go(this.element,Dt(this.element,n,o))}listen(){super.listen();let n=new MutationObserver(r=>{var i,a;r.length===2&&r[0].addedNodes.length===1&&((i=r[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=r[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let o=this.element.isContentEditable,s=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>s.disconnect())}};var Eh=["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 s=o.style,r=window.getComputedStyle(t),i=t.ownerDocument.body;s.whiteSpace="pre-wrap",s.wordWrap="break-word",s.position="absolute",s.visibility="hidden",Eh.forEach(c=>{s[c]=r[c]}),n?t.scrollHeight>Number.parseInt(r.height)&&(s.overflowY="scroll"):s.overflow="hidden",o.textContent=t.value.substring(0,e);let a=document.createElement("span");a.textContent=t.value.substring(e)||".",o.appendChild(a),i.appendChild(o);let d=t.getBoundingClientRect(),l={top:d.top-t.scrollTop+a.offsetTop+Number.parseInt(r.borderTopWidth)+a.offsetHeight,left:d.left-t.scrollLeft+a.offsetLeft+Number.parseInt(r.borderLeftWidth)};return i.removeChild(o),l}var cn=class extends ht{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 r;return(r=n==null?void 0:n.get)==null?void 0:r.call(this.element)},set:r=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,r),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let o=this.element.disabled,s=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>s.disconnect())}};function ru(t,e,n){let o=`deepdesk-iframe-${t}`,s=document.getElementById(o);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(n).forEach(([a,d])=>{i.searchParams.append(a,d)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=o,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}function kh(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch(e){return t}}var aa=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()}},la=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()}},da=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(e){this.externalId!==e&&(this.cleanup(),k.info("Set externalId",e),this.externalId=e,this.channel=this.createChannel(e))}createChannel(e){let n=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new la(e,this.deepdeskUrl,{debug:!0}):new aa(e),o=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=kh(s.data);typeof r!="object"||r.type!=="event"||r.channel!==e||(k.info("Received broadcast event",this.externalId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return n.onMessage(o),n}send(e,n,o){var i,a;k.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let s={type:"event",name:e,payload:n};o!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,n));let r=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage(S(y({},s),{channel:this.externalId}))}cleanup(e=!1){var n,o;(n=this.channel)==null||n.close(),this.channel=void 0,e&&((o=this.defaultChannel)==null||o.close(),this.defaultChannel=void 0)}},iu=da;function Rh(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(y({},e),{[Rh(n)]:z(t[n])}),{}):t}function Ph(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function pe(t){return Array.isArray(t)?t.map(pe):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>S(y({},e),{[Ph(n)]:pe(t[n])}),{}):t}var Gn=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var ca=t=>new Promise(e=>{setTimeout(e,t)});var pn=class extends Gn{constructor(){super(...arguments);this.name="ClientError"}},ua=class extends Gn{constructor(){super(...arguments);this.name="ServerError"}},pa=new Map;function Ih(t){return v(this,null,function*(){if(t.status===204)return t.text().catch(()=>{}),null;let e=t.headers.get("content-type");if(e!=null&&e.includes("application/json"))return t.json();let n=yield t.text();return n===""?null:(k.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var un=class{constructor(e="",n={}){this.baseUrl=e;this.options=n;this.latestRequestByUrl={};this.refreshingToken=null;this.lastFailedRefreshAt=null;this.failedRefreshCooldown=1e4;var o;this.fetch=(o=n.fetch)!=null?o:window.fetch.bind(window)}patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,n={}){return new Promise((o,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,d=n.method===void 0||n.method.toLowerCase()==="get",N=n,{useCache:l=!1,abortLatest:c=!1,attempts:u=1,retryDelay:p=500,refreshTokenOn401:f=!0,retryOnError:m=B=>B instanceof TypeError,retryOnResponse:g=B=>B.status>=500,version:h=null}=N,b=M(N,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(l){if(!d)throw new Error(`Can't use 'useCache' for ${n.method}`);if(pa.has(i)){o(pa.get(i));return}}let T=S(y({credentials:"include"},b),{headers:y({Accept:"application/json","Content-Type":"application/json"},b.headers)});!d&&this.csrfToken&&(T.headers=S(y({},T.headers),{"X-CSRFToken":this.csrfToken})),typeof h=="string"&&(T.headers=S(y({},T.headers),{"X-Deepdesk-API-Version":h}));let C=u,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&c&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let L=()=>v(this,null,function*(){return C--,a(i,T).then(B=>v(this,null,function*(){return g(B)&&!r.isAborted&&C>0?(yield ca(p),L()):B.status===401&&f===!0&&w===!1?(w=!0,yield this.refreshToken(),L()):B})).catch(B=>v(this,null,function*(){if(m(B)&&!r.isAborted&&C>0)return yield ca(p),L();throw B}))});L().then(B=>v(this,null,function*(){let X=yield Ih(B);if(delete this.latestRequestByUrl[i],B.status>=500){s(new ua("Server Error",X));return}if(B.status===401){s(new pn("Unauthorized",X));return}if(B.status===403){s(new pn("Forbidden",X));return}if(B.status===404){s(new pn("Not Found",X));return}if(B.status>=400){s(new pn("Bad Request",X));return}l&&pa.set(i,X),o(X)})).catch(B=>{s(B)})})}validateToken(){return v(this,null,function*(){let e,n,o;try{({has_valid_access_token:e,is_logged_in:n,has_valid_refresh_token:o}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1}))}catch(s){return!1}if(!e){if(!o)return!1;try{yield this.refreshToken();let{is_logged_in:s}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return s}catch(s){return!1}}return n})}refreshToken(){let e=Date.now();return this.lastFailedRefreshAt&&e-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new pn("Unauthorized","Failed to refresh token")):this.refreshingToken?this.refreshingToken:(this.refreshingToken=this.get("/apis/admin/session/refresh/",{refreshTokenOn401:!1}).catch(n=>{throw(n==null?void 0:n.message)==="Unauthorized"&&(this.lastFailedRefreshAt=Date.now()),n}).finally(()=>{this.refreshingToken=null}),this.refreshingToken)}get(e,n){return this.request(e,n)}post(e,n,o){return this.request(e,y({method:"POST",body:JSON.stringify(n)},o))}patch(e,n,o){return this.request(e,y({method:"PATCH",body:JSON.stringify(n)},o))}put(e,n,o){return this.request(e,y({method:"PUT",body:JSON.stringify(n)},o))}delete(e,n){return this.request(e,y({method:"DELETE"},n))}};var au;(e=>{let t;(a=>(a.SUCCESS="success",a.FAILURE="failure",a.CONDITIONS_NOT_MET="conditions_not_met",a.MAX_RECURSION_LEVEL="max_recursion_level",a.NO_ACCESS_TO_ASSISTANT="no_access_to_assistant"))(t=e.EvaluationStatus||(e.EvaluationStatus={}))})(au||(au={}));function ga(t){return S(y({},z(t)),{metadata:t.metadata})}var gn=class gn{constructor(e,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new un(e,{fetch:n.fetch}),this.client.patchFetch(o=>(s,r)=>v(this,null,function*(){let i=yield o(s,r);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return v(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=yield this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(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(),k.info(`Creating conversation for session ${e.externalId} and agent ${e.agentId}`);let n=yield this.client.post("/api/v2/conversations",S(y({chat_start_time:new Date().toISOString()},pe(e)),{metadata:(o=e.metadata)!=null?o:{}}));return ga(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/",pe(e))})}patchMe(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",pe(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(),k.info(`Getting conversation for session ${e}`);let{attempts:s=1,retryDelay:r=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return k.info(`Successfully retrieved conversation ${i.id} for session ${e}`),ga(i)})}isConversationSupported(o){return v(this,arguments,function*(e,n={}){k.info(`Check if conversation for session ${e} is supported`);let{attempts:s=1,retryDelay:r=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(e,n){return v(this,null,function*(){var r;yield this.preflight();let o=pe(n);n.metadata&&(o.metadata=(r=n.metadata)!=null?r:{});let s=yield this.client.put(`/api/v2/conversations/${e}`,o);return ga(s)})}postMessages(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${e}/messages`,n.map(o=>S(y({},pe(o)),{metadata:o.metadata})))})}sendEvent(e,n){return v(this,null,function*(){yield this.preflight();let a=n,{data:o}=a,s=M(a,["data"]),r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((d,[l,c])=>S(y({},d),{[l]:c}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((d,l)=>(s[l]&&(d[l]=s[l]),d),{});return this.client.post("/api/v2/events",pe(S(y(y({},r),i),{data:o,name:e})),{version:"v2"})})}getEntities(e){return v(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:e.filter(o=>o.text)})})}getTemporaryExchangeToken(){return v(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(e){return v(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:e}).catch(n=>{throw k.warn(`Invalid token '${e}'`),n})})}authenticateWithKey(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",pe(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(s){return v(this,arguments,function*(e,n={},o){if(yield this.preflight(),o==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${e}/recommend/${o}`,pe(n),{abortLatest:!0})).map(i=>S(y({},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`,pe(n),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))})}getPinnedMessages(e){return v(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return z(n).map(o=>S(y({},o),{text:o.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(e){return v(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",pe(e),{abortLatest:!0,version:"v2"});return z(n)})}search(e){return v(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${e.profile}/search`,pe(e));return z(n)})}requestLoginByEmail(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:e});return 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)})}evaluateAssistant(e,n){return v(this,null,function*(){var i;yield this.preflight();let o=new URLSearchParams;n!=null&&n.externalConversationId&&o.append("external_conversation_id",n.externalConversationId);let s=n!=null&&n.threadId?`/api/v2/assistants/${e}/threads/${n==null?void 0:n.threadId}/evaluate?${o.toString()}`:`/api/v2/assistants/${e}/evaluate?${o.toString()}`,r=yield this.client.post(s,{input:(i=n==null?void 0:n.input)!=null?i:{},conversation:n==null?void 0:n.transcript});return z(r)})}createAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n}=e,o=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return z(o)})}postMessageToAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:s}=e,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:s,role:"user"});return z(r)})}translateMessages(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",pe(e));return z(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let s=o.toLowerCase(),r=s.match(qa);if(!n||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&k.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};gn.exchangeTokenPromise=null;var yt=gn;var Or=require("@reduxjs/toolkit");var du=require("@reduxjs/toolkit");var lu={startTime:null,stopTime:null},cu=t=>t.handlingTime,pu=(0,du.createSlice)({name:"handlingTime",initialState:lu,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(J,()=>lu)}}),{handlingTimeStart:uu,handlingTimeStop:Ar,handlingTimeReset:gu}=pu.actions,mu=pu.reducer;var fu=(t={})=>{let e=y({onAuthError:Sn(!1)},t);return n=>o=>s=>("error"in s&&s.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(s))};var Nr=require("@reduxjs/toolkit");var Mr={list:{keywordMatches:[]},fetchState:"idle"};var mn=(0,Nr.createAsyncThunk)("styleSuggestions/getAll",(n,o)=>v(null,[n,o],function*({text:t},e){var d;let{deepdeskAPI:s}=e.extra,r=e.getState(),{showStyleSuggestions:i}=r.settings,a=(d=r.conversation.current)==null?void 0:d.profileCode;if(!i)return Mr.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return s.getStyleSuggestions({profileCode:a,message:t})})),Lh=(0,Nr.createSlice)({name:"styleSuggestions",initialState:Mr,reducers:{},extraReducers:t=>{t.addCase(mn.pending,e=>{e.fetchState="loading"}).addCase(mn.rejected,e=>{e.fetchState="error"}).addCase(mn.fulfilled,(e,n)=>{e.fetchState="done",Ct(e.list,n.payload)||(e.list=n.payload)}).addCase(jt,e=>{e.list=Mr.list}).addCase(J,()=>Mr)}}),hu=Lh.reducer;var yu=(t={})=>{let e,n=!0,o=y({getStyleSuggestions:mn,debounce:500},t);return s=>r=>i=>{var f;let a=s.getState().input.text,d=r(i),l=s.getState();if(l.auth.isLoggedIn!==!0)return d;let{showStyleSuggestions:c}=l.settings;if(!((f=l.conversation.current)==null?void 0:f.id)||!c)return d;let{text:p}=l.input;return p===a&&!n||(clearTimeout(e),p==="")||(e=setTimeout(()=>{n=!1,s.dispatch(o.getStyleSuggestions({text:p}))},t.debounce)),d}};function Ah(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var vu=(t={})=>{let e=y({getTextSuggestions:He,getAutocompleteSuggestions:Io,debounce:200,check:$e},t),n;return o=>s=>r=>{var g;let{input:i}=o.getState(),a=s(r),d=o.getState();if(d.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:c}=d.settings,u=(g=d.conversation.current)==null?void 0:g.id,p=r.type===Ws.toString();if(!u||!l&&!c)return a;let{input:f}=d;return Ah(f,i)&&!p||(clearTimeout(n),!e.check(d))||(n=setTimeout(()=>{let h=Cn(d);h===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(h))},p?0:e.debounce)),a}};var xu=mn.fulfilled.toString();function Mh(t,e){let n=new Set([...e.keywordMatches.map(s=>s.keyword)]),o=[];return n.forEach(s=>{let r=t.keywordMatches.filter(d=>d.keyword===s),i=e.keywordMatches.filter(d=>d.keyword===s),a=i.length-r.length;a<=0||o.push(...i.slice(0,a))}),o}var Su=t=>e=>n=>o=>{var l;if(o.type!==xu){n(o);return}let s=e.getState().styleSuggestions.list;n(o);let r=e.getState(),i=r.styleSuggestions.list,a=(l=r.conversation)==null?void 0:l.current;if(s===i)return;let d=Mh(s,i);o.type===xu&&d.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:d}})};var Nh=(0,Or.combineReducers)({assistants:up,auth:il,conversation:ul,contentTypes:ad,passwordlessToken:fp,entities:Md,handlingTime:mu,info:Dl,input:El,settings:Ya,profile:ud,search:Kl,styleSuggestions:hu,ui:dc,textSuggestions:Vd});function bu(t){return(0,Or.configureStore)({reducer:Nh,middleware:e=>{var o;let n=e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}).concat(fu()).concat(vu({debounce:200})).concat(yu({debounce:500})).concat(Su(t.deepdeskAPI));return((o=t.middleware)!=null?o:[]).reduce((s,r)=>s.concat(r),n)},preloadedState:t.preloadedState})}var Oh=t=>{var e,n;return(n=(e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())!=null?n:"unknown"},Dh=t=>e=>n=>o=>{var a,d;let s=e.getState(),r=vn("inlineSuggestions")(s);switch(o.type){case Sn.toString():{!o.payload&&t.emit("logout",void 0);break}case Fe.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:(a=s.conversation.current)==null?void 0:a.id,data:{entities:o.payload}});break;case jt.toString():t.logSendMessage(o.payload);break;case mr.toString():t.emit("call-to-action",{cue:o.payload});break;case Xe.fulfilled.toString():o.isBroadcasted||t.broadcast(ti,o,!1);break;default:break}let i=n(o);switch(o.type){case jt.toString():t.handleAfterSendMessage(o.payload);break;case Ao.toString():t.onUpdateShowTabHint(o.payload);break;case Ar.toString():t.logHandlingTime();break;case wn.toString():t.broadcast(xs,o);break;case Vt.toString():t.broadcast(xs,o);break;case fr.toString():e.dispatch(Vt({source:"assistant",assistantCode:o.payload.code}));break;case"analytics/logEvent/fulfilled":{let l=s.assistants.cues.find(c=>c.code===o.meta.arg.data.assistantCode);t.emit("event",S(y({},o.meta.arg),{cue:l}));break}case ye.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",S(y({type:Oh(o.payload.suggestion)},o.payload),{replace:o.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}})),r&&e.dispatch(Tt([]));break}case us.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(d=s.conversation.current)==null?void 0:d.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Tt.toString():{r&&o.payload.length>0&&e.dispatch(gs(0));break}default:break}return i},Cu=Dh;var Tu=require("@reduxjs/toolkit");function ma(t){return t.toISOString().replace("T"," ").replace("Z","")}var _h=(t,e)=>e.version,wu=(0,Tu.createSelector)([En,ze,cu,_h],(t,e,n,o)=>{if(!e)return k.warn("No conversationId for handling time metrics"),null;let{startTime:s,stopTime:r}=n;return!s||!r?(k.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:e,clientVersion:o,agentId:t==null?void 0:t.agentId,agentName:t==null?void 0:t.agentName,agentEmail:t==null?void 0:t.agentEmail,timeStart:ma(s),timeStop:ma(r)}});function Eu(t,e){let{text:n,metrics:{numPaste:o,pastes:s,textSuggestions:r}}=t.input,i=n.length;return{source:"agent",clientVersion:e.version,pastes:s,lenTextTotal:i,numPastes:o,suggestions:r}}function fa(t,e){var r;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return fa(o,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?fa(s,e):null}function ha(t,e){return fa(t,e)}function ku(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Fh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Dr(t){return Fh(t)&&(rn(t)||Zs(t))}var Pu,Qe=new Map,Hh=["bottom","height","left","right","top","width"],Ru=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:Hh.some(n=>t[n]!==e[n]);function Iu(t){var n,o,s;if(t.ownerDocument===document)return[];let e=(s=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?s:null;return e?[e,...Iu(e)]:[]}function Lu(t,e){return!t||!e?null:S(y({},t),{top:t.top+e.top,left:t.left+e.left})}var _r=!1,Au=()=>{_r=!0;let t=[];if(Qe.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),Qe.delete(n);return}let o=n.getBoundingClientRect();Ru(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{let n=e.parentRects?e.parentRects.reduce(Lu,e.rect):e.rect;Ru(n,e.totalRect)&&e.callbacks.forEach(o=>o(n)),e.totalRect=n}),Qe.size===0){_r=!1;return}Pu=window.requestAnimationFrame(Au)};function ya(t,e){let n=Iu(t),o=[],s=n.map((r,i)=>ya(r,a=>{o[i]=a;let d=Qe.get(t);if(!d)return;let l=o.reduce(Lu,d.rect);d.callbacks.forEach(c=>c(l))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Qe.has(t)){let i=Qe.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Qe.set(t,{rect:void 0,callbacks:[e],parentRects:o});r&&!_r&&Au()},unobserve(){s.forEach(i=>i.unobserve());let r=Qe.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Qe.delete(t),Qe.size||(cancelAnimationFrame(Pu),_r=!1)}}}}var Mu,Ze=new Map,Nu=()=>{Ze.forEach((t,e)=>{if(!e.isConnected){Ze.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,s=o>n;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),Ze.size!==0&&(Mu=window.requestAnimationFrame(Nu))};function Ou(t,e){return{observe(){let n=Ze.size===0;Ze.has(t)?Ze.get(t).callbacks.push(e):Ze.set(t,{visible:void 0,callbacks:[e]}),n&&Nu()},unobserve(){let n=Ze.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||Ze.delete(t),Ze.size||cancelAnimationFrame(Mu)}}}}var va=["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 xa(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function qn(t){return Number.parseFloat(t)}function Fr(t){return Math.round(t*1e6)}function Du(t){return t/1e6}function Sa(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,s=qn(t.width),r=qn(t.borderLeftWidth),i=qn(t.borderRightWidth),a=qn(t.paddingRight),d=Du(Fr(s)-Fr(r)-Fr(i)),l=Du(Fr(o));if(d-l>2){let c=d-l;n.style.paddingRight=`${a+c}px`}}function qo(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",sn(n);let o=window.getComputedStyle(t),s=!0,r=()=>{n.scrollTop=t.scrollTop};xa(o,n,va),Sa(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",r));let i=Ou(t,()=>{xa(o,n,va),Sa(o,t,n),r(),setTimeout(r,0)}),a,d=!0,l=ya(t,p=>{if(p===null){e.onRemove&&e.onRemove(),n.remove();return}if(!d&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),d=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),d=!1},200),p.height===0&&p.width===0){if(s===!0)return;e.onHide&&e.onHide(),n.style.display="none",s=!0;return}if(xa(o,n,va),Sa(o,t,n),r(),e.placement==="below"&&n.classList.add("below"),n.style.top=`${p.top}px`,n.style.left=`${p.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let f=e.closestScrollElement.getBoundingClientRect(),m=window.getComputedStyle(e.closestScrollElement),g=qn(m.borderTopWidth),h=qn(m.borderBottomWidth),b=f.top+g-p.top,T=p.top+p.height+-(f.top+f.height-h);n.style.clipPath=`inset(${b}px 0px ${T}px 0px)`}s&&(n.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(n):(u=t.parentElement)==null||u.appendChild(n),l.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",r),l.unobserve(),i.unobserve(),n.remove()}]}var _u=(t,e)=>({value(){try{let n=sessionStorage.getItem(`dd-${t}`);if(!n)return e;try{return JSON.parse(n)}catch(o){return e}}catch(n){return e}},update(n){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(n))}catch(o){k.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Bh(t){return t.offsetParent!==null}function Fu(t){if(!Bh(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 Hr(t,e,n=100){let o=Fu(t);e({isVisible:o});let s=setInterval(()=>{let r=Fu(t);r!==o&&(o=r,e({isVisible:o}))},n);return()=>{clearTimeout(s)}}var Xo=class extends Error{};function Uh(){let t,e;return{promise:new Promise((o,s)=>{t=o,e=s}),resolve:t,reject:e}}var Br=class{constructor(){this.queues={}}push(e,n){let o=()=>{let r=this.queues[e][1];r?(this.queues[e]=[r.promise,null],r.resolve()):delete this.queues[e]};if(!this.queues[e]){let r=n().finally(o);return this.queues[e]=[r,null],r}this.queues[e][1]&&this.queues[e][1].reject(new Xo("Queued async function is outdated"));let s=Uh();return this.queues[e][1]=s,s.promise.then(()=>n().finally(o))}};var Kh={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},Hu=(t,e)=>{var s,r,i;if(!((i=(r=(s=t.uiConfig)==null?void 0:s.widget)==null?void 0:r.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return k.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let o=t[Kh[e]];return o&&o.length>0?o.map(a=>a.code):(k.warn(`No assistant set in profile for conversation event "${e}"`),[])};var Ur=class{constructor(e){this.options=e;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,o;this.socket,this.eventListeners=new Map,this.url=e.url,this.maxReconnectAttempts=(n=e.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(o=e.reconnectInterval)!=null?o:this.reconnectInterval,this.shouldReconnect=e.shouldReconnect}connect(){let e=()=>this.cleanup();window.addEventListener("beforeunload",e),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",e)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=e=>{var n;try{let o=z(JSON.parse(e.data));o.event&&this.eventListeners.has(o.event)&&((n=this.eventListeners.get(o.event))==null||n.forEach(s=>s(o.data)))}catch(o){console.error("Error parsing WebSocket message:",o)}},this.socket.onclose=e=>{console.log("WebSocket connection closed:",e),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=e=>{console.error("WebSocket error:",e)})}reconnect(){var e,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(e=this.socket)==null||e.close();return}if(!this.shouldReconnect()){console.error("Should not reconnect, closing WebSocket connection."),(n=this.socket)==null||n.close();return}this.socket&&(this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this.socket=new WebSocket(this.url),this.setupListeners(),this.maxReconnectAttempts--}send(e,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:e,data:n}))}on(e,n){this.eventListeners.has(e)||this.eventListeners.set(e,[]);let o=this.eventListeners.get(e);o&&!o.includes(n)&&o.push(n)}close(){var e;(e=this.socket)==null||e.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(e=>e()),this.cleanupCallbacks=[]}};var _t=O(require("react"));var Bu={root:"dd-7zvcP",dialogContent:"dd-4C0lK",continueButton:"dd-YUPQW",buttonContinueWrapper:"dd-IKpYs",nicknameInput:"dd-rxhGp",titleWrapper:"dd-nw3nD",title:"dd-5iof5",closeButtonWrapper:"dd-UUAzA",closeButton:"dd-7rjP5",buttonsWrapper:"dd-5e9Xb",errorMessage:"dd--5VgX",errorLink:"dd-u461n"};var Uu=require("react-redux");var ba={};Y(ba,{enUS:()=>zh,nlNL:()=>Wh});var zh={title:[{type:0,value:"Enter your nickname"}],close:[{type:0,value:"Close"}],nicknameDialogTitle:[{type:0,value:"Please enter the name you'd like customers to see during chat conversations. This nickname will be used across your Deepdesk environment."}],nicknameDialogInputPlaceholder:[{type:0,value:"Enter your nickname"}],nicknameDialogContinueButton:[{type:0,value:"Continue"}],nicknameDialogError:[{type:0,value:"Nickname cannot be empty or spaces only"}],nicknameDialogEmojiError:[{type:0,value:"You cannot use emojis in this field."}],nicknameDialogSaveError:[{type:0,value:"We couldn't save your details just now. Please try again, or update it at "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We couldn\u2019t save your details just now. Please try again later, or update them in My Deepdesk \u2192 Settings."}]},Wh={title:[{type:0,value:"Voer je bijnaam in"}],close:[{type:0,value:"Sluiten"}],nicknameDialogTitle:[{type:0,value:"Voer de naam in die je wilt dat klanten zien tijdens chatgesprekken. Deze bijnaam wordt gebruikt in je Deepdesk-omgeving."}],nicknameDialogInputPlaceholder:[{type:0,value:"Voer je bijnaam in"}],nicknameDialogContinueButton:[{type:0,value:"Doorgaan"}],nicknameDialogError:[{type:0,value:"Bijnaam mag niet leeg of alleen spaties zijn"}],nicknameDialogEmojiError:[{type:0,value:"Je kunt geen emoji's gebruiken in dit veld."}],nicknameDialogSaveError:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw of werk het bij op "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw later, of werk ze bij in My Deepdesk \u2192 Instellingen."}]};var Q=require("react/jsx-runtime"),Ku=({onClose:t,onSave:e,id:n,error:o})=>{let[s,r]=(0,_t.useState)(""),[i,a]=(0,_t.useState)(!1),[d,l]=(0,_t.useState)(!1),c=x("Nickname",Bu),u=_t.default.useRef(null),p=(0,Uu.useSelector)(b=>b.info.showNicknameDialog),f=R(ba),m=E("adminUrl");(0,_t.useEffect)(()=>{o&&a(!0)},[o]);let g=()=>{if(!u.current)return;s.trim()?u.current.setCustomValidity(""):u.current.setCustomValidity(f("nicknameDialogError")),u.current.reportValidity()},h=b=>{b.preventDefault();let T=s.trim(),C=b.currentTarget.querySelector("#nickname-input");if(!T){C.setCustomValidity(f("nicknameDialogError")),C.reportValidity();return}C.setCustomValidity(""),e(T)};return(0,Q.jsxs)(In,{isOpen:p,"datatest-id":n,onClose:t||(()=>{}),onBack:t||(()=>{}),children:[(0,Q.jsx)("div",{className:c.titleWrapper,children:(0,Q.jsx)("h1",{className:c.title,children:f("title")})}),(0,Q.jsxs)("form",{className:c.dialogContent,onSubmit:h,children:[(0,Q.jsx)("p",{children:f("nicknameDialogTitle")}),i&&o&&(0,Q.jsx)("div",{className:c.errorMessage,children:m?(()=>{let b=f("nicknameDialogSaveError",{account:m}),T=`${m}.deepdesk.com/admin/user-settings`,C=b.indexOf(T);if(C!==-1){let w=b.substring(0,C),L=b.substring(C+T.length);return(0,Q.jsxs)(Q.Fragment,{children:[w,(0,Q.jsx)("a",{href:T,target:"_blank",rel:"noopener noreferrer",className:c.errorLink,children:T}),L]})}return b})():f("nicknameDialogSaveErrorWithoutLink")}),(0,Q.jsx)("input",{required:!0,minLength:1,maxLength:20,"data-testid":"nickname-input",id:"nickname-input",className:c.nicknameInput,type:"text",placeholder:f("nicknameDialogInputPlaceholder"),value:s,onChange:b=>{l(new RegExp("\\p{Extended_Pictographic}","u").test(b.target.value)),r(b.target.value)},onBlur:g,ref:u}),d&&(0,Q.jsx)("div",{className:c.errorMessage,role:"alert",children:f("nicknameDialogEmojiError")}),(0,Q.jsxs)("div",{className:c.buttonsWrapper,children:[o?(0,Q.jsx)("div",{className:c.closeButtonWrapper,children:(0,Q.jsx)("button",{type:"button",className:c.closeButton,onClick:()=>t==null?void 0:t(),children:f("close")})}):null,(0,Q.jsx)("div",{className:c.buttonContinueWrapper,children:(0,Q.jsx)("button",{type:"submit",className:c.continueButton,disabled:!s.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(s),children:f("nicknameDialogContinueButton")})})]})]})]})};var H=require("react/jsx-runtime");var zu=_u("showTabHint",!0),Xn=class Xn{constructor({deepdeskUrl:e,version:n=Xn.version||"unknown",locale:o="en-US",token:s,fetch:r,productName:i,createCustomChannel:a,websocketClient:d=Ur}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.disposeHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.belowSuggestions=null;this.floatingMenu=null;this.widgetElement=null;this.widgetRoot=null;this.nicknameDialogUnsubscribe=null;this.nicknameDialogFailed=!1;this.dynamicThunkObject={};this.queues=new Br;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=e.replace(/\/api$/,"");this.deepdeskApi=new yt(l,{token:s,fetch:r}),this.version=n,this.instanceId=Xn.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Cu({broadcast:(m,g,h)=>{this.broadcastEvents.send(m,g,h)},emit:(m,g)=>this.emit(m,g),handleAfterSendMessage:m=>this.handleAfterSendMessage(m),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:m=>this.logSendMessage(m),onUpdateShowTabHint:m=>zu.update(m),sendEvent:(m,g)=>this.deepdeskApi.sendEvent(m,g)})]};this.store=bu(c),this.broadcastEvents=new iu({debug:!0,deepdeskUrl:l,eventMap:zl(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new d({url:`${l}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>v(this,null,function*(){var m;return(m=ne(this.state))!=null?m:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(Ao(zu.value())),this.store.dispatch(as({locale:o,adminUrl:l,productName:i}));let u=[],p=m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(pp(m))};this.hasConversation()?g():u.push(g)};this.ws.on("assistants::direct_response",p),this.ws.on("assistants::user_notification",p),this.ws.on("assistants::response_chunk",m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(cp(m))};this.hasConversation()?g():u.push(g)}),this.ws.on("assistants::suggest_as_reply",m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(wn([{text:m.payload.message,type:"text",source:"assistant",assistantCode:m.code,sourceLabel:m.name}]))};this.hasConversation()?g():u.push(g)});let f=this.whenConversationLoaded(()=>{var m;this.broadcastEvents.setExternalId((m=this.state.conversation.current)==null?void 0:m.externalId),u.forEach(g=>g()),u.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),u.length=0,f()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var e;return(e=Wt(this.state)[this.state.input.selectedSuggestionIndex])!=null?e:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}externalId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.externalId}shouldAbort(){return this.state.conversation.isSupported===!1?(k.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(k.warn("Profile has not been loaded (yet)"),!0):(k.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(e){if(ne(this.state))e();else{let n=this.subscribe(ne,o=>{o&&e()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch(Sn(null)),this.store.dispatch(tt()),new Promise(e=>{this.whenLoggedIn(()=>e())})}isLoggedIn(){return v(this,null,function*(){return(yield this.store.dispatch(tt())).payload})}isConversationSupported(e,n){return v(this,null,function*(){return(yield this.store.dispatch(qr({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(ds(S(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}getConversationByExternalId(e,n){return v(this,null,function*(){return this.hasConversation()&&this.externalId()!==e&&this.resetConversation(),(yield this.store.dispatch(cs({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(Xr(S(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return v(this,null,function*(){yield this.store.dispatch(Jr(e))})}updateConversation(e){return v(this,null,function*(){return(yield this.store.dispatch(ps(e))).payload})}resetConversation(){this.store.dispatch(J()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(as(e))}setVisitorInfo(e){this.store.dispatch(Al(e))}setCustomData(e){this.store.dispatch(Ml(e))}setAgentInfo(e,n){return v(this,null,function*(){var s;yield this.store.dispatch(no(y(y({},e),n))),(s=this.state.info.agentInfo)!=null&&s.agentNickname||this.broadcastEvents.send(vs,{showNicknameDialog:!0})})}setAgentSettings(e){return v(this,null,function*(){yield this.store.dispatch(Zr(e))})}getAgentSettings(){return v(this,null,function*(){return(yield this.store.dispatch(Yr())).payload})}refresh(){return v(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let e=[];return e.push(this.refreshTextSuggestions()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(ms({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}))}notifyExternalSuggestion(e){this.store.dispatch(ye(e))}evaluateAssistant(e,n){return v(this,null,function*(){var d;let{input:o={},transcript:s,showCuesInWidget:r=!0,includeMetadata:i}=n||{},a=yield this.store.dispatch(Xe({assistantCode:e,transcript:s,includeMetadata:i,input:o,skipState:!r}));if(a.error)throw new Error(`Assistant evaluation failed: ${(d=a.payload)!=null?d:a.error.message}`);return a.payload.output})}evaluateConversationAssistant(e,n){return v(this,null,function*(){yield this.loadProfileConfig();let o=this.state.profile.data;if(!o){k.warn("Can't evaluate assistant when profile is not loaded yet.");return}let s=Hu(o,e);yield Promise.all(s.map(r=>this.queues.push(r,()=>v(this,null,function*(){yield this.evaluateAssistant(r,y({includeMetadata:!0},n))})).catch(i=>{if(i instanceof Xo){k.warn(`Queued assistant "${r}" was outdated and dropped`);return}throw i})))})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:s,selectedSuggestionIndex:r,selection:i}=this.state.input,{inlineSuggestions:a,showTextSuggestions:d,suggestionsPlacement:l}=this.settings,c=l==="inline"||l==="below"?"below":"above",u=s.length>0;if(this.store.dispatch(vl(Qr(e))),!$e(this.state)||e.key!=="Tab"&&!d)return;let p=()=>{n||!u||i&&(e.shiftKey||(this.store.dispatch(bl()),e.preventDefault()))},f=()=>{n||!u||a&&r<=0||i&&(e.shiftKey||(this.store.dispatch(Cl()),e.preventDefault()))};switch(e.key){case"ArrowUp":c==="below"?f():p();break;case"ArrowDown":{c==="below"?p():f();break}case"Escape":{n||(this.store.dispatch(gs(-1)),this.store.dispatch(Pt({collapse:!0})),this.store.dispatch(ac(!0)),e.preventDefault());break}case"Tab":{e.preventDefault();let m=Tn(this.state);if(!m)return;this.store.dispatch(Ao(!1)),this.store.dispatch(ye({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(ye({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(ye({text:m.text,suggestion:m,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),e.preventDefault();break}default:}n&&o&&this.store.dispatch(Pt({collapse:!1}))}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Tt([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(uu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(Ar()))}logSendMessage(e){let n=Eu(this.state,{version:this.version});n&&(e&&(Object.assign(n,{text:e}),Object.assign(n,{lenTextTotal:e.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let e=wu(this.state,{version:this.version});e&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:e}),this.store.dispatch(gu()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch(jt((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(wl()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(s=>{try{s(n)}catch(r){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.error(r)}})}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}setPlatformVariables(e){this.store.dispatch(Nl(e))}whenConversationLoaded(e){let n=r=>{var i;return(i=r.conversation.current)==null?void 0:i.id},o=()=>this.loadProfileConfig().then(()=>e());return n(this.state)&&o(),this.subscribe(n,r=>{r&&o()})}overlayContainerFactory(e,n,o,s){let[r,i]=qo(n,o);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),[r,i]}createInlineContainer(e,n){var a;let o=document.createElement("div");o.style.position="absolute",o.style.top="0px",o.style.left="0px",o.style.height="0px",o.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",o.appendChild(s);let r=(a=e.ownerDocument.defaultView)==null?void 0:a.frameElement,i=r?r.ownerDocument.defaultView:null;if(r&&(i===window||(i==null?void 0:i.parent)===window)){let[d,l]=qo(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});d.dataset.testid=n,d.style.zIndex="2",d.appendChild(o),this.unmountHandlers.push(()=>{l()})}else document.body.appendChild(o);return s}createContainer(e,n=document.body){let o=window.getComputedStyle(n),s=document.createElement("div");return sn(s),s.dataset.testid=e,s.style.color=o.color,s.style.fontSize=o.fontSize,s.style.fontFamily=o.fontFamily,s.style.fontVariant=o.fontVariant,s.setAttribute("translate","no"),n.appendChild(s),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,n),k.info(`Stored analytics for ${this.conversationId()}`)}catch(e){}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(e);if(!n)return;let o=JSON.parse(n);o.text.trim()===this.state.input.text.trim()?(k.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Tl(o.metrics))):k.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch(e){}}mount(e,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Dr(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let p=n,{customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i,inputMediator:a}=p,d=M(p,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i};this.configure(d),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),sn(e),this.inputMediator=a||(rn(e)?new cn(e):new dn(e)),this.inputMediator.on("change",({plainText:f,rawHTML:m})=>{this.store.dispatch(ms({text:f,html:m}))}),this.inputMediator.on("keyup",f=>{this.store.dispatch(xl(Qr(f)))}),this.inputMediator.on("keydown",f=>{this.handleKeyDown(f)}),this.inputMediator.on("paste",({pastedText:f,selectionText:m})=>{this.store.dispatch(Sl({text:f,selectionText:m}))}),this.inputMediator.on("cut",({selectionText:f})=>{this.store.dispatch(yl(f))});let c;this.inputMediator.on("selection",f=>{clearTimeout(c),f===null?c=setTimeout(()=>{f!==null&&this.store.dispatch(fs(f))},500):this.store.dispatch(fs(f))}),this.unmountHandlers.push(()=>{clearTimeout(c)}),this.inputMediator.on("disabled",()=>{var f;(f=this.inputMediator)==null||f.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(Gs(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Gs(!0))}),this.renderSuggestions(e,l),this.subscribe(vn("inlineSuggestions"),()=>{this.renderSuggestions(e,l)}),this.subscribe(vn("suggestionsPlacement"),()=>{this.renderSuggestions(e,l)});let u=this.renderOverlays(n);this.unmountHandlers.push(()=>{u.unmount()}),this.store.dispatch(ms({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(fs(this.inputMediator.getSelection())),this.store.dispatch(Gs(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{this.restoreMetrics(),this.syncInputMediator(),this.refreshTextSuggestions(),this.promptForNickname()}),this.isMounted=!0}promptForNickname(e){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let o=(0,vt.createRoot)(n),s=null,r=a=>{s=a,i()},i=()=>{o==null||o.render((0,H.jsx)(at,{store:this.store,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(Ku,{id:"deepdesk-nickname-dialog",error:s,onSave:a=>v(this,null,function*(){try{yield this.store.dispatch(Il({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(vs,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(d){k.error("Error setting agent nickname",d),r("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{o.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(e,n){let o=e(this.store.getState());return this.store.subscribe(()=>{let s=e(this.store.getState());s!==o&&(o=s,n(o))})}unmount(){var e,n,o,s,r;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.belowSuggestions)==null||o.unmount(),(s=this.floatingMenu)==null||s.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(r=this.inputMediator)==null||r.dispose(),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe(),this.isMounted=!1}dispose(){this.unmount(),this.unmountWidget(),this.disposeHandlers.forEach(e=>e()),this.disposeHandlers=[],this.off()}renderSuggestions(e,n){var o,s,r,i;(o=this.floatingMenu)==null||o.unmount(),(s=this.inlineSuggestions)==null||s.unmount(),(r=this.aboveSuggestions)==null||r.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(e,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(e,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(e,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(e,n,"above")}renderInlineSuggestions(e,n){let{customStyles:o}=n,s=this.createInlineContainer(e,"deepdesk-caret"),r=(0,vt.createRoot)(s);r.render((0,H.jsx)(at,{store:this.store,customStyles:o,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(vc,{})})}));let i=a=>{a?(s.style.display="block",s.style.top=`${a.top}px`,s.style.left=`${a.left}px`):s.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),r.unmount(),s.remove()}}}renderAboveOrBelowSuggestions(e,n,o){let{customStyles:s,closestScrollSelector:r,appendOverlayTo:i}=n,a=r&&ha(e,r)||void 0,[d,l]=this.overlayContainerFactory("deepdesk-tab-completion",a||e,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},s==null?void 0:s.rootNode),[c,u]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||e,{appendTo:i,placement:o},s==null?void 0:s.suggestionsRootNode),p=(0,vt.createRoot)(d);p.render((0,H.jsx)(at,{store:this.store,customStyles:s,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(np,{inputElement:e})})}));let f=(0,vt.createRoot)(c);return f.render((0,H.jsx)(at,{store:this.store,customStyles:s,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(Ic,{onLogIn:()=>this.loginViaPopup().catch(m=>k.warn(m.message))})})})),{unmount(){p.unmount(),f.unmount(),l(),u()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:s,appendOverlayTo:r,floatingMenuParent:i}=n,a=s&&ha(e,s)||void 0,[d,l]=this.overlayContainerFactory("floating-menu",a||e,{appendTo:i!=null?i:r},o==null?void 0:o.floatingMenuParent),c=(0,vt.createRoot)(d);return c.render((0,H.jsx)(at,{store:this.store,customStyles:o,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(oc,{onLogIn:()=>this.loginViaPopup().catch(u=>k.warn(u.message))})})})),{unmount(){c.unmount(),l()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays"),s=(0,vt.createRoot)(o);return s.render((0,H.jsx)(at,{store:this.store,customStyles:n,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(Jd,{})})})),{unmount(){s.unmount(),o.remove()}}}renderWidget(e,n={}){if(this.widgetElement&&k.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:s,isEmbedded:r}=n;this.widgetElement=e,this.configure({showImages:s,isEmbedded:r}),this.widgetRoot=(0,vt.createRoot)(e),this.widgetRoot.render((0,H.jsx)(at,{store:this.store,customStyles:o,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(eu,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(i=>k.warn(i.message))})})}))}unmountWidget(){var e,n;(n=(e=this.widgetRoot)==null?void 0:e.unmount)==null||n.call(e),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(e,n,o={}){let{customStyles:s,initialQuestion:r}=o,i=(0,vt.createRoot)(n);return i.render((0,H.jsx)(at,{store:this.store,customStyles:s,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(ia,{children:(0,H.jsxs)(kr,{assistantCode:e,initialQuestion:r,evaluateKnowledgeAssistFn:Ho,children:[(0,H.jsx)(hn,{children:(0,H.jsx)(Pr,{title:o.title,emptyState:o.emptyState})}),(0,H.jsx)(ra,{children:(0,H.jsx)(Rr,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(e){let n=Hr(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){ku(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(xo());let e=Xt(this.state);e&&this.store.dispatch(as({showSearch:e.search,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:!!e.summarizerAssistantNew,showKnowledgeSearch:!!e.knowledgeAssistantNew||!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions}))})),this.loadProfileConfigPromise)}loginViaPopup(e){return v(this,null,function*(){return new Promise((n,o)=>{this.store.dispatch(ls());let s=new MessageChannel,r=s.port1,i=this.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let d=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",u),clearInterval(p)};r.onmessage=f=>v(this,null,function*(){var m,g;if((m=f.data)!=null&&m.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((g=f.data)==null?void 0:g.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(so),d=!0,s.port1.close(),n()}catch(h){console.error(h),o(h)}finally{d=!0,l()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&o(new Error("Popup blocked by browser"));let u=f=>v(this,null,function*(){var m;if(f.origin===a.origin)switch((m=f.data)==null?void 0:m.type){case"deepdesk-popup-request-origin":{try{let g=JSON.stringify({type:"deepdesk-popup-parent-origin"});c==null||c.postMessage(g,a.origin)}catch(g){k.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-loaded":{try{let g=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(g,a.origin,[s.port2])}catch(g){k.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-error":{if(l(),f.data.message==="Platform account url mismatch"){let g=`Please contact your administrator: The platform account url (${f.data.targetOrigin}) is misconfigured as it differs from the origin of the page that opened the popup (${f.data.openerOrigin}).`;k.warn(g),this.store.dispatch(Gr(g)),o(new Error(g))}if(f.data.message==="Timeout"){let g="Please contact your administrator: Popup timed out. Check if the account's platform url is configured correctly.";k.warn(g),this.store.dispatch(Gr(g)),o(new Error(g))}o(new Error(f.data.message));break}}});window.addEventListener("message",u);let p=setInterval(()=>{c&&!c.closed||(l(),d||o(new Error("Popup closed by user")))},200);this.disposeHandlers.push(l)})})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}refreshTextSuggestions(){return v(this,null,function*(){this.isMounted&&(yield this.store.dispatch(Ws()))})}refreshWidgetSuggestions(){return v(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=So(this.state);try{n.forEach(({type:o})=>{switch(o){case"entities":this.store.dispatch(Fe());break;case"pinned-messages":case"sticky-messages":break;default:is.includes(o)||this.store.dispatch(He(o))}})}catch(o){this.handleError(o)}})}};Xn.version="19.1.1-beta.2",Xn.count=0;var Jo=Xn;function Vh(t){return v(this,null,function*(){var s,r,i;let n=yield((s=t.fetch)!=null?s:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(r=t.mimeType)!=null?r:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function Wu(t,e){return v(this,null,function*(){let n=yield Vh(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 Vu(t,e,n){return v(this,null,function*(){yield new yt(t).authenticateWithKey(e,n)})}function ju(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function $u(o,s){return v(this,arguments,function*(t,e,n={}){var u,p;let{value:r}=t,{start:i,end:a}=(u=n.replace)!=null?u:{start:0,end:r.length},d=`${r.slice(0,i)}${e}${r.slice(a)}`,l=(p=n.selectionAfter)!=null?p:{start:i+e.length,end:i+e.length},c=()=>{if(n.setValue)return n.setValue(d);t.value=d};return Promise.resolve(c()).then(()=>{t.selectionStart=l.start,t.selectionEnd=l.end,t.blur(),t.focus()})})}function Gu(o,s){return v(this,arguments,function*(t,e,n={}){let r=n.replace?Dt(t,n.replace.start,n.replace.end):$n(t),i,a=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),i=document.createElement("span"),r.insertNode(i),n.insertBRs!==!1?e.split(`
|
|
11
|
+
`).reverse().forEach((d,l)=>{l>0&&r.insertNode(document.createElement("br")),r.insertNode(document.createTextNode(d))}):r.insertNode(document.createTextNode(e))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let d=n.selectionAfter?Dt(t,n.selectionAfter.start,n.selectionAfter.end):(r.collapse(!1),r),l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(d)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function jh(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 $h(t){let e=document.createDocumentFragment();return t.split(`
|
|
12
|
+
`).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=n.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(n.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(n.slice(r)))}),e}function qu(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):qu(n,e)}function Xu(s,r){return v(this,arguments,function*(t,e,{isBlock:n,isHTML:o}={}){let i;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let a=()=>{var p;let d=(p=t.ownerDocument.defaultView)!=null?p:window,l=d.getSelection();if((!l||l.rangeCount===0)&&(t.focus(),l=d.getSelection()),!l||l.rangeCount===0)return;let c=l.getRangeAt(0);if(!c)return;i=document.createElement("span"),c.insertNode(i);let u=o?jh(e):$h(e);n?qu(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,logEvent,updateContentEditable,updateTextArea,useClickOutsideRoot,useStyles,waitForElementVisibilityChange});
|