@deepdesk/deepdesk-sdk 19.1.2-beta.0 → 19.1.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +7 -7
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.esm.js +7 -7
- package/dist/index.iife.js +26 -26
- package/package.json +1 -1
- package/styles/index.js +1 -1
- package/styles.css +1 -1
- package/widget.css +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var Jp=Object.create;var Qn=Object.defineProperty,Qp=Object.defineProperties,Zp=Object.getOwnPropertyDescriptor,Yp=Object.getOwnPropertyDescriptors,eg=Object.getOwnPropertyNames,Qo=Object.getOwnPropertySymbols,tg=Object.getPrototypeOf,Ws=Object.prototype.hasOwnProperty,Ea=Object.prototype.propertyIsEnumerable;var wa=(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={}))Ws.call(e,n)&&wa(t,n,e[n]);if(Qo)for(var n of Qo(e))Ea.call(e,n)&&wa(t,n,e[n]);return t},S=(t,e)=>Qp(t,Yp(e));var M=(t,e)=>{var n={};for(var o in t)Ws.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&&Ea.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})},ka=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of eg(e))!Ws.call(t,r)&&r!==n&&Qn(t,r,{get:()=>e[r],enumerable:!(o=Zp(e,r))||o.enumerable});return t};var O=(t,e,n)=>(n=t!=null?Jp(tg(t)):{},ka(e||!t||!t.__esModule?Qn(n,"default",{value:t,enumerable:!0}):n,t)),ng=t=>ka(Qn({},"__esModule",{value:!0}),t);var v=(t,e,n)=>new Promise((o,r)=>{var s=d=>{try{a(n.next(d))}catch(l){r(l)}},i=d=>{try{a(n.throw(d))}catch(l){r(l)}},a=d=>d.done?o(d.value):Promise.resolve(d.value).then(s,i);a((n=n.apply(t,e)).next())});var qh={};Y(qh,{Card:()=>F,ContentEditableInput:()=>dn,DeepdeskAPI:()=>yt,DeepdeskSDK:()=>Jo,HTTPClient:()=>pn,InputMediator:()=>ht,InputType:()=>Ut,KeyboardHint:()=>nr,Label:()=>Oa,Locale:()=>Yn,Section:()=>Ke,SectionList:()=>hn,Sources:()=>et,Suggestion:()=>I,SuggestionList:()=>ie,TextAreaInput:()=>cn,ToggleButton:()=>Bt,attachFile:()=>Wp,authenticateWithKey:()=>Vp,createFullRange:()=>$n,createOverlayContainer:()=>qo,createRangeFromOffsets:()=>Dt,escapeHTML:()=>An,formatTextMarkup:()=>jp,getRangeOffsets:()=>$o,getRangeText:()=>Go,insertCKEditor:()=>Xp,isHTML:()=>bo,isSupportedInputElement:()=>_s,logEvent:()=>Ur,updateContentEditable:()=>Gp,updateTextArea:()=>$p,useClickOutsideRoot:()=>Rt,useStyles:()=>x,waitForElementVisibilityChange:()=>Bs});module.exports=ng(qh);var js=O(require("classnames")),we=O(require("react"));var Zo=O(require("react")),Ra=O(require("classnames"));var Zn=Zo.default.createContext({});function x(t,e){let s=(0,Zo.useContext)(Zn),{debug:n}=s,r=M(s,["debug"])[t];return Object.entries(e).reduce((i,[a,d])=>{let l=r==null?void 0:r[a];return S(y({},i),{[a]:(0,Ra.default)(d,l,n?`${t}__${a}`:!1)})},{})}var Pa={root:"dd-4s9wq"};var Ft=require("react/jsx-runtime"),Yo=()=>(0,Ft.jsxs)("svg",{className:Pa.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 Vs={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"),er=(0,we.createContext)(Vs),og=({title:t,src:e})=>{let n=(0,we.useContext)(er),[o,r]=(0,we.useState)(!1);return(0,we.useEffect)(()=>{r(!1)},[e]),(0,Ht.jsx)("div",{className:n.imageWrapper,children:e&&!o?(0,Ht.jsx)("img",{className:n.image,alt:t,src:e,onError:()=>r(!0)}):(0,Ht.jsx)(Yo,{})})},rg=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let r=(0,we.useContext)(er);return(0,Ht.jsx)("div",{className:(0,js.default)(r.content,t,{[r.contentIsCropped]:n,[r.lineClamp]:e}),children:o})},sg=s=>{var i=s,{as:t="h1",cropText:e=!1,className:n,children:o}=i,r=M(i,["as","cropText","className","children"]);let a=(0,we.useContext)(er);return we.default.createElement(t,y({className:(0,js.default)(a.title,n,{[a.contentIsCropped]:e})},r),o)},tr=({children:t})=>{let e=x("Card",Vs);return(0,Ht.jsx)("div",{className:e.root,children:(0,Ht.jsx)(er.Provider,{value:e,children:t})})};tr.Image=og;tr.Content=rg;tr.Title=sg;var F=tr;var La=O(require("classnames"));var Ia={root:"dd-llBx9"};var Aa=require("react/jsx-runtime");var ig={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},ag=o=>{var r=o,{className:t,keyCode:e}=r,n=M(r,["className","keyCode"]);let s=x("KeyboardHint",Ia);return(0,Aa.jsx)("span",y({"data-key":ig[e],className:(0,La.default)(t,s.root)},n))},nr=ag;var Na=O(require("classnames"));var Ma={root:"dd-e6HXZ"};var Da=require("react/jsx-runtime"),lg=o=>{var r=o,{className:t,children:e}=r,n=M(r,["className","children"]);let s=x("Label",Ma);return(0,Da.jsx)("span",S(y({},n),{className:(0,Na.default)(t,s.root),children:e}))},Oa=lg;var _a={root:"dd-FiMI7",subTitleContainer:"dd-98jc7",subtitle:"dd-3MnW8",suggestions:"dd-0SGL8"};var fn=require("react/jsx-runtime"),dg=r=>{var s=r,{title:t,children:e,type:n}=s,o=M(s,["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=dg;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 r=t.current;if(!r||r.scrollHeight<=r.clientHeight)return;let{top:s}=r.getBoundingClientRect(),{top:i}=o.getBoundingClientRect(),a=r.scrollTop+(i-s);typeof r.scrollTo=="function"?r.scrollTo({top:a}):r.scrollTop=a},[]);return(0,Ba.jsx)(Fa.Provider,{value:n,children:e})},or=t=>{let e=(0,xt.useContext)(Fa);(0,xt.useEffect)(()=>{let n=t.current;n&&e(n)},[])};var Ua={root:"dd-uoTXh"};var $s=require("react/jsx-runtime"),cg=({className:t,children:e})=>{let n=x("SectionList",Ua),o=(0,za.useRef)(null);return(0,$s.jsx)(Ha,{scrollContainerRef:o,children:(0,$s.jsx)("div",{ref:o,className:(0,Ka.default)(n.root,t),children:e})})},hn=cg;var yn=O(require("classnames")),ge=O(require("react"));var Gs={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 se=require("react/jsx-runtime"),St=(0,ge.createContext)(Gs),ug=o=>{var r=o,{fixed:t,children:e}=r,n=M(r,["fixed","children"]);let s=(0,ge.useContext)(St);return(0,se.jsx)("div",S(y({},n),{className:(0,yn.default)(s.actions,{[s.actionsIsFixed]:t}),children:e}))};function pg(d){var l=d,{as:t,className:e,icon:n,title:o,children:r,disabled:s,variant:i}=l,a=M(l,["as","className","icon","title","children","disabled","variant"]);let c=(0,ge.useContext)(St);return(0,se.jsxs)(t||"button",S(y({type:"button",className:(0,yn.default)(c.button,{[c.buttonWithIcon]:n,[c.buttonDisabled]:s,[c.buttonPrimary]:i==="primary",[c.buttonSecondary]:i==="secondary"},e),title:o,"aria-label":o},a),{children:[n&&(0,se.jsx)("span",{className:c.icon,children:n}),r]}))}var gg=({children:t})=>{let e=(0,ge.useContext)(St);return(0,se.jsx)("div",{className:e.buttonsContainer,children:t})},mg=({className:t,primary:e,disabled:n,label:o,children:r})=>{let s=(0,ge.useContext)(St);return(0,se.jsxs)("div",{className:(0,yn.default)(t,s.actionButton,s.dropdownButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,(0,se.jsx)("ul",{className:s.dropdownList,children:r})]})},fg=({index:t,label:e,onClick:n})=>{let o=(0,ge.useContext)(St);return(0,se.jsx)("li",{className:o.dropdownItem,children:(0,se.jsx)("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},hg=({className:t,primary:e,disabled:n,onClick:o,label:r})=>{let s=(0,ge.useContext)(St);return(0,se.jsx)("button",{type:"button",className:(0,yn.default)(t,s.actionButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onClick:o!=null?o:(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:r})},yg=({labels:t})=>{let e=(0,ge.useContext)(St);return(0,se.jsx)("div",{className:e.labels,children:t.map(n=>(0,se.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:r="div"}=d,s=M(d,["className","selected","onClick","children","as"]);let l=x("Suggestion",Gs),c=(0,ge.useCallback)(p=>{p.preventDefault(),n&&n(p)},[n]);return(0,se.jsx)(r,S(y({},s),{ref:i,className:(0,yn.default)(t,l.root,{[l.isSelected]:e,[l.isClickable]:!!n}),onClick:c,children:(0,se.jsx)(St.Provider,{value:l,children:o})}))});bt.Labels=yg;bt.Actions=ug;bt.ActionButton=hg;bt.DropdownButton=mg;bt.DropdownItem=fg;bt.ButtonsContainer=gg;bt.Button=pg;var I=bt;var Va=O(require("classnames"));var Wa={root:"dd-W35K-",isWithDivider:"dd-sscOy"};var ja=require("react/jsx-runtime"),vg=({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=vg;var Ga=O(require("classnames"));var $a={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};var rr=require("react/jsx-runtime"),xg=({className:t,isCollapsed:e,title:n,onClick:o})=>{let r=x("ToggleButton",$a);return(0,rr.jsx)("button",{type:"button",className:(0,Ga.default)(r.root,t,{[r.isCollapsed]:e}),onClick:o,title:n,children:(0,rr.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,rr.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Bt=xg;var qa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,sr=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Xa=/x-deepdesk-(([a-z0-9\-_])+-version)/,ir=["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||{}),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 Jd=require("react");var Qa=require("@reduxjs/toolkit"),Za=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},Ya=(0,Qa.createSlice)({name:"settings",initialState:Sg,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,r]=n;typeof r!="undefined"&&(t[o]=r)})}}}),{set:ar}=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 bg={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()})),rl=(0,xn.createAsyncThunk)("auth/requestLogin",(n,o)=>v(null,[n,o],function*({email:t},e){let{deepdeskAPI:r}=e.extra;return r.requestLoginByEmail(t)})),eo=(0,xn.createAsyncThunk)("auth/verifyLoginToken",(n,o)=>v(null,[n,o],function*({token:t},e){let{deepdeskAPI:r}=e.extra;return r.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:il,setLoginError:qs,clearLoginError:lr}=sl.actions,al=sl.reducer;var zt=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,r=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==r?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((s,i)=>Ct(s,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 Cg(t){return Math.max(...t.map(e=>e.length))}function Tg(t,e){let n=t.reduce((o,r)=>{if(r){let s=o[r]?o[r]+1:1;return S(y({},o),{[r]:s})}return o},{});return Object.keys(n).reduce((o,r)=>(n[r]<e&&o.push(r),o),[])}function dl(t,e){let o=[...t.map(({text:r})=>r.split(/\b(\w+)\b/))];for(let r=0;r<Cg(o);r++){let s=Tg(o.map(a=>a[r]),e),i=o.filter(a=>!s.includes(a[r]));if(i.length>=e)o=i;else return{text:o[0].slice(0,r).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var wg=2;function cl(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=dl(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 ul={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,Xs=(0,Me.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),dr=(0,Me.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),cr=(0,Me.createAsyncThunk)("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),ur=(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)}),Js=(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:r,agentName:s,agentEmail:i,agentNickname:a,metadata:d}=t;return n.updateConversation(o.id,{agentId:r,agentEmail:i,agentName:s,agentNickname:a,metadata:d})})}),Qs=(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(r=>y({},r)))}),kg=[dr.rejected,cr.rejected,ur.rejected,Qs.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:ul,reducers:{},extraReducers:t=>{t.addCase(Xs.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(dr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(cr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Js.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(ur.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(J,()=>ul).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)})}}),gl=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 Zs(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}}var pr=(0,zt.createAction)("input/applyImageSuggestion"),fl=(0,zt.createSlice)({name:"input",initialState:Kt,reducers:{setInput(t,e){var s,i;let{beforeInputChange:n}=t,{text:o,html:r}=e.payload;if(t.text=o,t.html=r!=null?r:null,o==="")t.metrics=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:p}=n.keyDown;switch(a){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:u}=t,f=(0,ml.diffChars)(n.text,u);n.text.length-u.length>1&&t.metrics.deletions.push(...f.filter(m=>m.removed).map(m=>m.value)),t.metrics.numCharsDeleted+=n.text.length-u.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&&!p){t.metrics.numCharsTyped+=1;let u=((s=n.selection)==null?void 0:s.start)!==void 0&&((i=n.selection)==null?void 0:i.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;u&&u.length>0&&(t.metrics.numCharsDeleted+=u.length,t.metrics.deletions.push(u))}}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:r,abVariant:s,abTestName:i,trainingJobs:a,sourceText:d,searchTerm:l,assistantCode:c,text:p},eventMetrics:{inputType:u},replace:f}=n,m=r==="search"||r==="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=p),t.metrics.textSuggestions.push({text:g,source:r,assistantCode:c,abVariant:s,abTestName:i,inputType:u,sourceText:d,trainingJobs:a||[],searchTerm:m?t.text:l}),t.textSuggestions=[],t.selectedSuggestionIndex=-1},offeredTextSuggestion(t,e){let{text:n,suggestion:{source:o}}=e.payload;t.metrics.offeredTextSuggestions.find(s=>s.text===n)||t.metrics.offeredTextSuggestions.push({text:n,source:o})},registerKeyDown(t,e){let{key:n}=e.payload;["Control","Meta","Shift","Alt"].includes(n)||(t.beforeInputChange={text:t.text,selection:t.selection,keyDown:e.payload})},registerKeyUp(t,e){},registerCut(t,e){let{metrics:n}=t,o=e.payload;t.metrics=S(y({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:r}=e.payload,s=n.numCharsDeleted+(r!=null&&r.length?r.length:0),i=r!=null&&r.length?[...n.deletions,r]:n.deletions;t.metrics=S(y({},t.metrics),{numCharsDeleted:s,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.length+t.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=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),hl=t=>t.input.selection,{commitSuggestion:ye,offeredTextSuggestion:yl,registerCut:vl,registerKeyDown:xl,registerKeyUp:Sl,registerPaste:bl,selectNextTextSuggestion:Cl,selectPreviousTextSuggestion:Tl,selectTextSuggestionByIndex:gr,setInput:mr,setMetrics:wl,setPinnedSuggestions:wn,removePinnedSuggestions:Vt,setSelection:fr,setTextSuggestions:Tt,resetMetrics:El,sendMessage:jt}=fl.actions,kl=fl.reducer;var kn=require("@reduxjs/toolkit");var $t=require("@reduxjs/toolkit");function Rl(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},Pl=t=>{var e;return(e=t.info.visitorInfo)!=null?e:null},Il=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&&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:""}},Ng=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],Ll=(0,$t.createAsyncThunk)("info/setAgentNickname",(n,o)=>v(null,[n,o],function*({agentNickname:t},e){var i;let{deepdeskAPI:r}=e.extra,s=yield r.patchMe({nickname:t});return{agentNickname:(i=s==null?void 0:s.nickname)!=null?i:t}})),no=(0,$t.createAsyncThunk)("info/setAgentInfo",(t,e)=>v(null,null,function*(){var s,i,a;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=[];if(t.agentId&&t.skipSync!==!0&&r.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let d=Ng.reduce((l,[c,p])=>!o[p]&&c in t?S(y({},l),{[p]:t[c]}):l,{});Object.keys(d).length>0&&r.push(n.patchMe(d).then(l=>o=l))}return r.length>0&&(yield Promise.all(r)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(s=o.nickname)!=null?s:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(a=o.defaultLocale)!=null?a:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),Ys=(0,$t.createAsyncThunk)("info/setAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=y(y({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:r}),r})),ei=(0,$t.createAsyncThunk)("info/getAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),Al=(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(Ys.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?t==null?(k.warn("replaceVars called with non-string text; upstream contract violation",{keys:Object.keys(e)}),t):Object.entries(e).reduce((n,[o,r])=>n.replaceAll(o,r),t):t}var hr={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,Og=(0,kn.createSelector)([ti,(t,e)=>e],(t,e)=>t.filter(n=>n.type===e)),Ul=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(),r=(d=o.conversation.current)==null?void 0:d.profileCode,{platformVariables:s}=o.info;if(!r)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:r,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:oo(o)});return{results:i.map(l=>S(y(y({},l),l.title&&s?{title:Ne(l.title,s)}:{}),{text:Ne(l.text,s!=null?s:{}),source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:a}})),Kl=(0,kn.createSlice)({name:"search",initialState:hr,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=hr.fetchState,t.list=hr.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,()=>hr)}}),{resetSearch:yr,setIsOpen:Oe,setPage:Rn}=Kl.actions,zl=Kl.reducer;var ni="SetOutputs",Pn="ShowLoginOverlay",ro="UserLoggedIn",Dg="UserLoggedOut",nt="ApplySuggestion",oi="ApplyImageSuggestion",_g="ShowCommandPalette",vr="ShowNicknameDialog",xr="ReduxAction",Fg="RemovePinnedSuggestion",Hg=t=>({[ni]:e=>{t.dispatch(S(y({},e),{isBroadcasted:!0}))},[xr]: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))},[vr]:e=>{t.dispatch(Dl(e.showNicknameDialog))},[Pn]:e=>{t.dispatch(il(e))},[ro]:()=>{t.dispatch(tt())},[Dg]:()=>{t.dispatch(tt())},[oi]:e=>{t.dispatch(pr({suggestion:e.suggestion}))},[nt]:e=>{t.dispatch(ye(S(y({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),Wl=Hg;var so=O(require("react")),jl=require("react/jsx-runtime"),Vl=so.default.createContext(null),ot=({broadcastEvents:t,children:e})=>{let n=so.default.useMemo(()=>t,[]);return(0,jl.jsx)(Vl.Provider,{value:n,children:e})},me=()=>{let t=(0,so.useContext)(Vl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var Ir=O(require("classnames")),De=require("react"),Lr=require("react-redux");var Rr=require("react");var ri=function(t,e){return ri=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])},ri(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");ri(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,r=arguments.length;o<r;o++){n=arguments[o];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},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 r=0,o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]]);return n}function Sr(t,e,n){if(n||arguments.length===2)for(var o=0,r=e.length,s;o<r;o++)(s||!(o in e))&&(s||(s=Array.prototype.slice.call(e,0,o)),s[o]=e[o]);return t.concat(s||Array.prototype.slice.call(e))}function br(t,e){var n=e&&e.cache?e.cache:jg,o=e&&e.serializer?e.serializer:Wg,r=e&&e.strategy?e.strategy:Ug;return r(t,{cache:n,serializer:o})}function Bg(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Gl(t,e,n,o){var r=Bg(o)?o:n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.call(this,o),e.set(r,s)),s}function ql(t,e,n){var o=Array.prototype.slice.call(arguments,3),r=n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.apply(this,o),e.set(r,s)),s}function si(t,e,n,o,r){return n.bind(e,t,o,r)}function Ug(t,e){var n=t.length===1?Gl:ql;return si(t,this,n,e.cache.create(),e.serializer)}function Kg(t,e){return si(t,this,ql,e.cache.create(),e.serializer)}function zg(t,e){return si(t,this,Gl,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}},Cr={variadic:Kg,monadic:zg};var Tr;(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"})(Tr||(Tr={}));var wr=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 Er;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Er||(Er={}));function ii(t){return t.type===Ee.literal}function ai(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 uo(t){return t.type===Ee.select}function po(t){return t.type===Ee.plural}function Xl(t){return t.type===Ee.pound}function go(t){return t.type===Ee.tag}function kr(t){return!!(t&&typeof t=="object"&&t.type===Er.number)}function mo(t){return!!(t&&typeof t=="object"&&t.type===Er.dateTime)}function li(t){t.forEach(function(e){if(delete e.location,uo(e)||po(e))for(var n in e.options)delete e.options[n].location,li(e.options[n].value);else ao(e)&&kr(e.style)||(lo(e)||co(e))&&mo(e.style)?delete e.style.location:go(e)&&li(e.children)})}function Jl(t,e){e===void 0&&(e={}),e=ve({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new wr(t,e).parse();if(n.err){var o=SyntaxError(Tr[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 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,r){var s=t.call(this,n)||this;return s.code=o,s.originalMessage=r,s}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e})(Error);var di=(function(t){io(e,t);function e(n,o,r,s){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(r).join('", "'),'"'),qt.INVALID_VALUE,s)||this}return e})(fo);var Ql=(function(t){io(e,t);function e(n,o,r){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),qt.INVALID_VALUE,r)||this}return e})(fo);var Zl=(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 re;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(re||(re={}));function $g(t){return t.length<2?t:t.reduce(function(e,n){var o=e[e.length-1];return!o||o.type!==re.literal||n.type!==re.literal?e.push(n):o.value+=n.value,e},[])}function Gg(t){return typeof t=="function"}function ho(t,e,n,o,r,s,i){if(t.length===1&&ii(t[0]))return[{type:re.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:re.literal,value:c.value});continue}if(Xl(c)){typeof s=="number"&&a.push({type:re.literal,value:n.getNumberFormat(e).format(s)});continue}var p=c.value;if(!(r&&p in r))throw new Zl(p,i);var u=r[p];if(ai(c)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?re.literal:re.object,value:u});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:re.literal,value:n.getDateTimeFormat(e,f).format(u)});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:re.literal,value:n.getDateTimeFormat(e,f).format(u)});continue}if(ao(c)){var f=typeof c.style=="string"?o.number[c.style]:kr(c.style)?c.style.parsedOptions:void 0;f&&f.scale&&(u=u*(f.scale||1)),a.push({type:re.literal,value:n.getNumberFormat(e,f).format(u)});continue}if(go(c)){var m=c.children,g=c.value,h=r[g];if(!Gg(h))throw new Ql(g,"function",i);var b=ho(m,e,n,o,r,s),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"?re.literal:re.object,value:L}}))}if(uo(c)){var C=c.options[u]||c.options.other;if(!C)throw new di(c.value,u,Object.keys(c.options),i);a.push.apply(a,ho(C.value,e,n,o,r));continue}if(po(c)){var C=c.options["=".concat(u)];if(!C){if(!Intl.PluralRules)throw new fo(`Intl.PluralRules is not available in this environment.
|
|
1
|
+
"use strict";var Qp=Object.create;var Qn=Object.defineProperty,Zp=Object.defineProperties,Yp=Object.getOwnPropertyDescriptor,eg=Object.getOwnPropertyDescriptors,tg=Object.getOwnPropertyNames,Qo=Object.getOwnPropertySymbols,ng=Object.getPrototypeOf,Ws=Object.prototype.hasOwnProperty,Ea=Object.prototype.propertyIsEnumerable;var wa=(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={}))Ws.call(e,n)&&wa(t,n,e[n]);if(Qo)for(var n of Qo(e))Ea.call(e,n)&&wa(t,n,e[n]);return t},x=(t,e)=>Zp(t,eg(e));var M=(t,e)=>{var n={};for(var o in t)Ws.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&&Ea.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})},ka=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of tg(e))!Ws.call(t,r)&&r!==n&&Qn(t,r,{get:()=>e[r],enumerable:!(o=Yp(e,r))||o.enumerable});return t};var O=(t,e,n)=>(n=t!=null?Qp(ng(t)):{},ka(e||!t||!t.__esModule?Qn(n,"default",{value:t,enumerable:!0}):n,t)),og=t=>ka(Qn({},"__esModule",{value:!0}),t);var v=(t,e,n)=>new Promise((o,r)=>{var s=d=>{try{a(n.next(d))}catch(l){r(l)}},i=d=>{try{a(n.throw(d))}catch(l){r(l)}},a=d=>d.done?o(d.value):Promise.resolve(d.value).then(s,i);a((n=n.apply(t,e)).next())});var Qh={};Y(Qh,{Card:()=>F,ContentEditableInput:()=>dn,DeepdeskAPI:()=>yt,DeepdeskSDK:()=>Jo,HTTPClient:()=>pn,InputMediator:()=>ht,InputType:()=>Ut,KeyboardHint:()=>nr,Label:()=>Oa,Locale:()=>Yn,Section:()=>Ke,SectionList:()=>hn,Sources:()=>et,Suggestion:()=>I,SuggestionList:()=>ae,TextAreaInput:()=>cn,ToggleButton:()=>Bt,attachFile:()=>Vp,authenticateWithKey:()=>jp,createFullRange:()=>$n,createOverlayContainer:()=>qo,createRangeFromOffsets:()=>Dt,escapeHTML:()=>An,formatTextMarkup:()=>$p,getRangeOffsets:()=>$o,getRangeText:()=>Go,insertCKEditor:()=>Jp,isHTML:()=>bo,isSupportedInputElement:()=>_s,logEvent:()=>Ur,updateContentEditable:()=>qp,updateTextArea:()=>Gp,useClickOutsideRoot:()=>Rt,useStyles:()=>S,waitForElementVisibilityChange:()=>Bs});module.exports=og(Qh);var js=O(require("classnames")),we=O(require("react"));var Zo=O(require("react")),Ra=O(require("classnames"));var Zn=Zo.default.createContext({});function S(t,e){let s=(0,Zo.useContext)(Zn),{debug:n}=s,r=M(s,["debug"])[t];return Object.entries(e).reduce((i,[a,d])=>{let l=r==null?void 0:r[a];return x(y({},i),{[a]:(0,Ra.default)(d,l,n?`${t}__${a}`:!1)})},{})}var Pa={root:"dd-4s9wq"};var Ft=require("react/jsx-runtime"),Yo=()=>(0,Ft.jsxs)("svg",{className:Pa.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 Vs={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"),er=(0,we.createContext)(Vs),rg=({title:t,src:e})=>{let n=(0,we.useContext)(er),[o,r]=(0,we.useState)(!1);return(0,we.useEffect)(()=>{r(!1)},[e]),(0,Ht.jsx)("div",{className:n.imageWrapper,children:e&&!o?(0,Ht.jsx)("img",{className:n.image,alt:t,src:e,onError:()=>r(!0)}):(0,Ht.jsx)(Yo,{})})},sg=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let r=(0,we.useContext)(er);return(0,Ht.jsx)("div",{className:(0,js.default)(r.content,t,{[r.contentIsCropped]:n,[r.lineClamp]:e}),children:o})},ig=s=>{var i=s,{as:t="h1",cropText:e=!1,className:n,children:o}=i,r=M(i,["as","cropText","className","children"]);let a=(0,we.useContext)(er);return we.default.createElement(t,y({className:(0,js.default)(a.title,n,{[a.contentIsCropped]:e})},r),o)},tr=({children:t})=>{let e=S("Card",Vs);return(0,Ht.jsx)("div",{className:e.root,children:(0,Ht.jsx)(er.Provider,{value:e,children:t})})};tr.Image=rg;tr.Content=sg;tr.Title=ig;var F=tr;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 r=o,{className:t,keyCode:e}=r,n=M(r,["className","keyCode"]);let s=S("KeyboardHint",Ia);return(0,Aa.jsx)("span",y({"data-key":ag[e],className:(0,La.default)(t,s.root)},n))},nr=lg;var Na=O(require("classnames"));var Ma={root:"dd-e6HXZ"};var Da=require("react/jsx-runtime"),dg=o=>{var r=o,{className:t,children:e}=r,n=M(r,["className","children"]);let s=S("Label",Ma);return(0,Da.jsx)("span",x(y({},n),{className:(0,Na.default)(t,s.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=r=>{var s=r,{title:t,children:e,type:n}=s,o=M(s,["title","children","type"]);let i=S("Section",_a);return(0,fn.jsxs)("section",x(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 r=t.current;if(!r||r.scrollHeight<=r.clientHeight)return;let{top:s}=r.getBoundingClientRect(),{top:i}=o.getBoundingClientRect(),a=r.scrollTop+(i-s);typeof r.scrollTo=="function"?r.scrollTo({top:a}):r.scrollTop=a},[]);return(0,Ba.jsx)(Fa.Provider,{value:n,children:e})},or=t=>{let e=(0,xt.useContext)(Fa);(0,xt.useEffect)(()=>{let n=t.current;n&&e(n)},[])};var Ua={root:"dd-uoTXh"};var $s=require("react/jsx-runtime"),ug=({className:t,children:e})=>{let n=S("SectionList",Ua),o=(0,za.useRef)(null);return(0,$s.jsx)(Ha,{scrollContainerRef:o,children:(0,$s.jsx)("div",{ref:o,className:(0,Ka.default)(n.root,t),children:e})})},hn=ug;var yn=O(require("classnames")),ge=O(require("react"));var Gs={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 ie=require("react/jsx-runtime"),St=(0,ge.createContext)(Gs),pg=o=>{var r=o,{fixed:t,children:e}=r,n=M(r,["fixed","children"]);let s=(0,ge.useContext)(St);return(0,ie.jsx)("div",x(y({},n),{className:(0,yn.default)(s.actions,{[s.actionsIsFixed]:t}),children:e}))};function gg(d){var l=d,{as:t,className:e,icon:n,title:o,children:r,disabled:s,variant:i}=l,a=M(l,["as","className","icon","title","children","disabled","variant"]);let c=(0,ge.useContext)(St);return(0,ie.jsxs)(t||"button",x(y({type:"button",className:(0,yn.default)(c.button,{[c.buttonWithIcon]:n,[c.buttonDisabled]:s,[c.buttonPrimary]:i==="primary",[c.buttonSecondary]:i==="secondary"},e),title:o,"aria-label":o},a),{children:[n&&(0,ie.jsx)("span",{className:c.icon,children:n}),r]}))}var mg=({children:t})=>{let e=(0,ge.useContext)(St);return(0,ie.jsx)("div",{className:e.buttonsContainer,children:t})},fg=({className:t,primary:e,disabled:n,label:o,children:r})=>{let s=(0,ge.useContext)(St);return(0,ie.jsxs)("div",{className:(0,yn.default)(t,s.actionButton,s.dropdownButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,(0,ie.jsx)("ul",{className:s.dropdownList,children:r})]})},hg=({index:t,label:e,onClick:n})=>{let o=(0,ge.useContext)(St);return(0,ie.jsx)("li",{className:o.dropdownItem,children:(0,ie.jsx)("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},yg=({className:t,primary:e,disabled:n,onClick:o,label:r})=>{let s=(0,ge.useContext)(St);return(0,ie.jsx)("button",{type:"button",className:(0,yn.default)(t,s.actionButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onClick:o!=null?o:(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:r})},vg=({labels:t})=>{let e=(0,ge.useContext)(St);return(0,ie.jsx)("div",{className:e.labels,children:t.map(n=>(0,ie.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:r="div"}=d,s=M(d,["className","selected","onClick","children","as"]);let l=S("Suggestion",Gs),c=(0,ge.useCallback)(p=>{p.preventDefault(),n&&n(p)},[n]);return(0,ie.jsx)(r,x(y({},s),{ref:i,className:(0,yn.default)(t,l.root,{[l.isSelected]:e,[l.isClickable]:!!n}),onClick:c,children:(0,ie.jsx)(St.Provider,{value:l,children:o})}))});bt.Labels=vg;bt.Actions=pg;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=S("SuggestionList",Wa);return(0,ja.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Va.default)(n.root,{[n.isWithDivider]:t}),children:e})},ae=xg;var Ga=O(require("classnames"));var $a={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};var rr=require("react/jsx-runtime"),Sg=({className:t,isCollapsed:e,title:n,onClick:o})=>{let r=S("ToggleButton",$a);return(0,rr.jsx)("button",{type:"button",className:(0,Ga.default)(r.root,t,{[r.isCollapsed]:e}),onClick:o,title:n,children:(0,rr.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,rr.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Bt=Sg;var qa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,sr=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Xa=/x-deepdesk-(([a-z0-9\-_])+-version)/,ir=["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||{}),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 Jd=require("react");var Qa=require("@reduxjs/toolkit"),Za=require("react-redux");var Yn=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(Yn||{});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,r]=n;typeof r!="undefined"&&(t[o]=r)})}}}),{set:ar}=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()})),rl=(0,xn.createAsyncThunk)("auth/requestLogin",(n,o)=>v(null,[n,o],function*({email:t},e){let{deepdeskAPI:r}=e.extra;return r.requestLoginByEmail(t)})),eo=(0,xn.createAsyncThunk)("auth/verifyLoginToken",(n,o)=>v(null,[n,o],function*({token:t},e){let{deepdeskAPI:r}=e.extra;return r.verifyLoginToken(t)})),sl=(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(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:il,setLoginError:qs,clearLoginError:lr}=sl.actions,al=sl.reducer;var zt=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,r=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==r?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((s,i)=>Ct(s,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,r)=>{if(r){let s=o[r]?o[r]+1:1;return x(y({},o),{[r]:s})}return o},{});return Object.keys(n).reduce((o,r)=>(n[r]<e&&o.push(r),o),[])}function dl(t,e){let o=[...t.map(({text:r})=>r.split(/\b(\w+)\b/))];for(let r=0;r<Tg(o);r++){let s=wg(o.map(a=>a[r]),e),i=o.filter(a=>!s.includes(a[r]));if(i.length>=e)o=i;else return{text:o[0].slice(0,r).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var 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 ul={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,Xs=(0,Me.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),dr=(0,Me.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),cr=(0,Me.createAsyncThunk)("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),ur=(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)}),Js=(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:r,agentName:s,agentEmail:i,agentNickname:a,metadata:d}=t;return n.updateConversation(o.id,{agentId:r,agentEmail:i,agentName:s,agentNickname:a,metadata:d})})}),Qs=(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(r=>y({},r)))}),Rg=[dr.rejected,cr.rejected,ur.rejected,Qs.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:ul,reducers:{},extraReducers:t=>{t.addCase(Xs.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(dr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(cr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Js.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(ur.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(J,()=>ul).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 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 Zs(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}}var pr=(0,zt.createAction)("input/applyImageSuggestion"),fl=(0,zt.createSlice)({name:"input",initialState:Kt,reducers:{setInput(t,e){var s,i;let{beforeInputChange:n}=t,{text:o,html:r}=e.payload;if(t.text=o,t.html=r!=null?r:null,o==="")t.metrics=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:p}=n.keyDown;switch(a){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:u}=t,f=(0,ml.diffChars)(n.text,u);n.text.length-u.length>1&&t.metrics.deletions.push(...f.filter(m=>m.removed).map(m=>m.value)),t.metrics.numCharsDeleted+=n.text.length-u.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&&!p){t.metrics.numCharsTyped+=1;let u=((s=n.selection)==null?void 0:s.start)!==void 0&&((i=n.selection)==null?void 0:i.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;u&&u.length>0&&(t.metrics.numCharsDeleted+=u.length,t.metrics.deletions.push(u))}}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:r,abVariant:s,abTestName:i,trainingJobs:a,sourceText:d,searchTerm:l,assistantCode:c,text:p},eventMetrics:{inputType:u},replace:f}=n,m=r==="search"||r==="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=p),t.metrics.textSuggestions.push({text:g,source:r,assistantCode:c,abVariant:s,abTestName:i,inputType:u,sourceText:d,trainingJobs:a||[],searchTerm:m?t.text:l}),t.textSuggestions=[],t.selectedSuggestionIndex=-1},offeredTextSuggestion(t,e){let{text:n,suggestion:{source:o}}=e.payload;t.metrics.offeredTextSuggestions.find(s=>s.text===n)||t.metrics.offeredTextSuggestions.push({text:n,source:o})},registerKeyDown(t,e){let{key:n}=e.payload;["Control","Meta","Shift","Alt"].includes(n)||(t.beforeInputChange={text:t.text,selection:t.selection,keyDown:e.payload})},registerKeyUp(t,e){},registerCut(t,e){let{metrics:n}=t,o=e.payload;t.metrics=x(y({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:r}=e.payload,s=n.numCharsDeleted+(r!=null&&r.length?r.length:0),i=r!=null&&r.length?[...n.deletions,r]:n.deletions;t.metrics=x(y({},t.metrics),{numCharsDeleted:s,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.length+t.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=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),Lg=t=>t.input.mixedSuggestion,Ag=t=>t.input.pinnedSuggestions,Mg=t=>t.input.textSuggestions,to=t=>t.input.selectedSuggestionIndex,Wt=(0,zt.createSelector)([Mg,Ag],(t,e)=>[...t,...e]),Tn=(0,zt.createSelector)([Wt,Lg,to],(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:gr,setInput:mr,setMetrics:wl,setPinnedSuggestions:wn,removePinnedSuggestions:Vt,setSelection:fr,setTextSuggestions:Tt,resetMetrics:El,sendMessage:jt}=fl.actions,kl=fl.reducer;var kn=require("@reduxjs/toolkit");var $t=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},oo=({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,$t.createAsyncThunk)("info/setAgentNickname",(n,o)=>v(null,[n,o],function*({agentNickname:t},e){var i;let{deepdeskAPI:r}=e.extra,s=yield r.patchMe({nickname:t});return{agentNickname:(i=s==null?void 0:s.nickname)!=null?i:t}})),no=(0,$t.createAsyncThunk)("info/setAgentInfo",(t,e)=>v(null,null,function*(){var s,i,a;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=[];if(t.agentId&&t.skipSync!==!0&&r.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let d=Og.reduce((l,[c,p])=>!o[p]&&c in t?x(y({},l),{[p]:t[c]}):l,{});Object.keys(d).length>0&&r.push(n.patchMe(d).then(l=>o=l))}return r.length>0&&(yield Promise.all(r)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(s=o.nickname)!=null?s:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(a=o.defaultLocale)!=null?a:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),Ys=(0,$t.createAsyncThunk)("info/setAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=y(y({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:r}),r})),ei=(0,$t.createAsyncThunk)("info/getAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),Al=(0,$t.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(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(Ys.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?t==null?(k.warn("replaceVars called with non-string text; upstream contract violation",{keys:Object.keys(e)}),t):Object.entries(e).reduce((n,[o,r])=>n.replaceAll(o,r),t):t}var hr={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),Gt=(0,kn.createAsyncThunk)("search/getAll",(t,e)=>v(null,null,function*(){var d;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=(d=o.conversation.current)==null?void 0:d.profileCode,{platformVariables:s}=o.info;if(!r)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:r,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:oo(o)});return{results:i.map(l=>x(y(y({},l),l.title&&s?{title:Ne(l.title,s)}:{}),{text:Ne(l.text,s!=null?s:{}),source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:a}})),Kl=(0,kn.createSlice)({name:"search",initialState:hr,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=hr.fetchState,t.list=hr.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,()=>hr)}}),{resetSearch:yr,setIsOpen:Oe,setPage:Rn}=Kl.actions,zl=Kl.reducer;var ni="SetOutputs",Pn="ShowLoginOverlay",ro="UserLoggedIn",_g="UserLoggedOut",nt="ApplySuggestion",oi="ApplyImageSuggestion",Fg="ShowCommandPalette",vr="ShowNicknameDialog",xr="ReduxAction",Hg="RemovePinnedSuggestion",Bg=t=>({[ni]:e=>{t.dispatch(x(y({},e),{isBroadcasted:!0}))},[xr]:e=>{e.isBroadcasted||t.dispatch(x(y({},e),{isBroadcasted:!0}))},[Hg]:e=>{t.dispatch(Vt(e))},[Fg]:e=>{t.dispatch(Oe(e.isOpen)),e.page&&t.dispatch(Rn(e.page))},[vr]:e=>{t.dispatch(Dl(e.showNicknameDialog))},[Pn]:e=>{t.dispatch(il(e))},[ro]:()=>{t.dispatch(tt())},[_g]:()=>{t.dispatch(tt())},[oi]:e=>{t.dispatch(pr({suggestion:e.suggestion}))},[nt]:e=>{t.dispatch(ye(x(y({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),Wl=Bg;var so=O(require("react")),jl=require("react/jsx-runtime"),Vl=so.default.createContext(null),ot=({broadcastEvents:t,children:e})=>{let n=so.default.useMemo(()=>t,[]);return(0,jl.jsx)(Vl.Provider,{value:n,children:e})},me=()=>{let t=(0,so.useContext)(Vl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var Ir=O(require("classnames")),De=require("react"),Lr=require("react-redux");var Rr=require("react");var ri=function(t,e){return ri=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])},ri(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");ri(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,r=arguments.length;o<r;o++){n=arguments[o];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},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 r=0,o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]]);return n}function Sr(t,e,n){if(n||arguments.length===2)for(var o=0,r=e.length,s;o<r;o++)(s||!(o in e))&&(s||(s=Array.prototype.slice.call(e,0,o)),s[o]=e[o]);return t.concat(s||Array.prototype.slice.call(e))}function br(t,e){var n=e&&e.cache?e.cache:$g,o=e&&e.serializer?e.serializer:Vg,r=e&&e.strategy?e.strategy:Kg;return r(t,{cache:n,serializer:o})}function Ug(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Gl(t,e,n,o){var r=Ug(o)?o:n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.call(this,o),e.set(r,s)),s}function ql(t,e,n){var o=Array.prototype.slice.call(arguments,3),r=n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.apply(this,o),e.set(r,s)),s}function si(t,e,n,o,r){return n.bind(e,t,o,r)}function Kg(t,e){var n=t.length===1?Gl:ql;return si(t,this,n,e.cache.create(),e.serializer)}function zg(t,e){return si(t,this,ql,e.cache.create(),e.serializer)}function Wg(t,e){return si(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}},Cr={variadic:zg,monadic:Wg};var Tr;(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"})(Tr||(Tr={}));var wr=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 Er;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Er||(Er={}));function ii(t){return t.type===Ee.literal}function ai(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 uo(t){return t.type===Ee.select}function po(t){return t.type===Ee.plural}function Xl(t){return t.type===Ee.pound}function go(t){return t.type===Ee.tag}function kr(t){return!!(t&&typeof t=="object"&&t.type===Er.number)}function mo(t){return!!(t&&typeof t=="object"&&t.type===Er.dateTime)}function li(t){t.forEach(function(e){if(delete e.location,uo(e)||po(e))for(var n in e.options)delete e.options[n].location,li(e.options[n].value);else ao(e)&&kr(e.style)||(lo(e)||co(e))&&mo(e.style)?delete e.style.location:go(e)&&li(e.children)})}function Jl(t,e){e===void 0&&(e={}),e=ve({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new wr(t,e).parse();if(n.err){var o=SyntaxError(Tr[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 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,r){var s=t.call(this,n)||this;return s.code=o,s.originalMessage=r,s}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e})(Error);var di=(function(t){io(e,t);function e(n,o,r,s){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(r).join('", "'),'"'),qt.INVALID_VALUE,s)||this}return e})(fo);var Ql=(function(t){io(e,t);function e(n,o,r){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),qt.INVALID_VALUE,r)||this}return e})(fo);var Zl=(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 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 ho(t,e,n,o,r,s,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 s=="number"&&a.push({type:se.literal,value:n.getNumberFormat(e).format(s)});continue}var p=c.value;if(!(r&&p in r))throw new Zl(p,i);var u=r[p];if(ai(c)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?se.literal:se.object,value:u});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(u)});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(u)});continue}if(ao(c)){var f=typeof c.style=="string"?o.number[c.style]:kr(c.style)?c.style.parsedOptions:void 0;f&&f.scale&&(u=u*(f.scale||1)),a.push({type:se.literal,value:n.getNumberFormat(e,f).format(u)});continue}if(go(c)){var m=c.children,g=c.value,h=r[g];if(!qg(h))throw new Ql(g,"function",i);var b=ho(m,e,n,o,r,s),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[u]||c.options.other;if(!C)throw new di(c.value,u,Object.keys(c.options),i);a.push.apply(a,ho(C.value,e,n,o,r));continue}if(po(c)){var C=c.options["=".concat(u)];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
|
-
`,qt.MISSING_INTL_API,i);var w=n.getPluralRules(e,{type:c.pluralType}).select(u-(c.offset||0));C=c.options[w]||c.options.other}if(!C)throw new di(c.value,u,Object.keys(c.options),i);a.push.apply(a,ho(C.value,e,n,o,r,u-(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 ci(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:br(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,Sr([void 0],n,!1)))},{cache:ci(t.number),strategy:Cr.variadic}),getDateTimeFormat:br(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,Sr([void 0],n,!1)))},{cache:ci(t.dateTime),strategy:Cr.variadic}),getPluralRules:br(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,Sr([void 0],n,!1)))},{cache:ci(t.pluralRules),strategy:Cr.variadic})}}var ui=(function(){function t(e,n,o,r){n===void 0&&(n=t.defaultLocale);var s=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(l){var c=s.formatToParts(l);if(c.length===1)return c[0].value;var p=c.reduce(function(u,f){return!u.length||f.type!==re.literal||typeof u[u.length-1]!="string"?u.push(f.value):u[u.length-1]+=f.value,u},[]);return p.length<=1?p[0]||"":p},this.formatToParts=function(l){return ho(s.ast,s.locales,s.formatters,s.formats,l,void 0,s.message)},this.resolvedOptions=function(){var l;return{locale:((l=s.resolvedLocale)===null||l===void 0?void 0:l.toString())||Intl.NumberFormat.supportedLocalesOf(s.locales)[0]}},this.getAst=function(){return s.ast},this.locales=n,this.resolvedLocale=t.resolveLocale(n),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=r||{},a=i.formatters,d=$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=Xg(t.formats,o),this.formatters=r&&r.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=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 Qg(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var Zg="dummy",pi=(0,Rr.createContext)(null);function R(t){var o;let e=(0,Rr.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(r,s)=>{let i=Qg(n,r);return i?new ui(i).format(s):(e!==Zg&&console.warn(`${r} does not exist in messages of ${e}`),`[${r}]`)}}var Pr=require("react");var Yl={root:"dd-tvkOF",content:"dd-eXA1D"};var gi=require("react/jsx-runtime"),Yg=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:r,onKeyDown:s,overlayAriaLabel:i,contentAriaLabel:a})=>{let d=(0,Pr.useRef)(null),l=x("Dialog",Yl),c=u=>{if(u.key==="Escape"){u.preventDefault(),u.stopPropagation(),r();return}s&&s(u)},p=u=>{u.target===d.current&&t&&o()};return(0,Pr.useEffect)(()=>{var u,f;!d.current||!t||!e||(f=(u=d.current)==null?void 0:u.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:p,children:(0,gi.jsx)("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:n})}):null},In=Yg;var td=O(require("classnames"));var ed={root:"dd-ranhW"};var nd=require("react/jsx-runtime"),em=o=>{var r=o,{className:t,value:e}=r,n=M(r,["className","value"]);let s=x("TextInput",ed);return(0,nd.jsx)("input",y({className:(0,td.default)(t,s.root),type:"text",value:e},n))},yo=em;var mi={};Y(mi,{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 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 om=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:r})=>{let s=R(mi),i=x("LoginTokenDialog",od),a=(0,Lr.useSelector)(tl),d=(0,Lr.useDispatch)(),l=E("productName"),[c,p]=(0,De.useState)(t||""),[u,f]=(0,De.useState)(0),[m,g]=(0,De.useState)(""),h=(0,De.useCallback)(w=>v(null,null,function*(){w.preventDefault(),d(rl({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(s("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(s("verifyCodeError",{login:C})),a==="done"&&o()},[a]),(0,G.jsx)(In,{autoFocus:!0,isOpen:e,contentAriaLabel:s("promptTitle",{productName:l}),overlayAriaLabel:s("promptTitle",{productName:l}),onClose:r,onBack:r,children:(0,G.jsxs)("div",{className:i.root,children:[(0,G.jsx)("h1",{className:i.title,children:s("promptTitle",{productName:l})}),u===0&&(0,G.jsxs)("form",{onSubmit:h,children:[(0,G.jsx)("h2",{className:i.subtitle,children:s("requestCodeTitle")}),(0,G.jsx)("p",{className:i.text,children:s("requestCodeBody",{productName:l})}),(0,G.jsx)(yo,{className:i.input,name:"email",placeholder:s("requestCodeInputPlaceholder"),value:c,onChange:w=>p(w.target.value)}),(0,G.jsx)("div",{className:i.actions,children:(0,G.jsx)("button",{type:"submit",className:(0,Ir.default)(i.button,i.primaryButton),children:s("requestCodeSubmitLabel")})})]}),u===1&&(0,G.jsxs)("form",{onSubmit:T,children:[(0,G.jsx)("h2",{className:i.subtitle,children:s("verifyCodeTitle")}),(0,G.jsx)("p",{className:i.text,children:s("verifyCodeBody")}),(0,G.jsx)(yo,{className:i.input,name:"token",placeholder:s("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,Ir.default)(i.button),onClick:b,children:s("back")}),(0,G.jsx)("button",{type:"submit",className:(0,Ir.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:s("verifyCodeSubmitLabel")})]})]})]})})},rd=rm;var id=require("react/jsx-runtime"),sm=()=>{let t=(0,fi.useSelector)(nl),e=(0,fi.useSelector)(En),n=E("adminUrl"),o=me(),r=()=>o.send(Pn,!1),s=()=>{o.send(Pn,!1),o.send(ro)};return(0,id.jsx)(rd,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:r,onSuccess:s})},sd=sm;var qd=O(require("lodash.debounce")),fe=require("react"),je=require("react-redux");var Ar=require("@reduxjs/toolkit");var im={data:null,fetchState:"idle"},ad=t=>t.contentTypes.data,vo=(0,Ar.createAsyncThunk)("contentTypes/getContentTypes",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),am=(0,Ar.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})}}),ld=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)),dd=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},cd=t=>e=>So(e).find(n=>n.type===t),ud=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 s;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=o.conversation.current;if(!r||!r.profileCode)throw new Error("No conversation of conversation profileCode found");return((s=o.profile.data)==null?void 0:s.code)===r.profileCode?o.profile.data:n.getProfile(r.profileCode)})),um=(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})}}),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 st=require("react");var md=require("react"),Mr=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 rt={};Y(rt,{enUS:()=>pm,nlNL:()=>gm});var pm={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,r]=(0,md.useState)("loading"),s=R(rt);return(0,wt.jsxs)("div",{className:n.image,children:[(0,wt.jsx)("img",{src:t,alt:e,onLoad:()=>r("done"),onError:()=>r("error"),className:(0,Mr.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&(0,wt.jsx)("span",{className:(0,Mr.default)(n.imageSrc,n.imageSrcStatus),children:s("loading")}),o==="error"&&(0,wt.jsx)("span",{className:(0,Mr.default)(n.imageSrc,n.imageSrcStatus),children:(0,wt.jsx)(Yo,{})}),e&&(0,wt.jsx)("span",{className:n.imageTitle,children:e})]})},fd=mm;var hd=O(require("react")),yd=O(require("classnames"));var Jt=require("react/jsx-runtime");function hi({children:t,heading:e,orientation:n,hasMore:o,onShowAll:r}){let s=R(rt),i=x("CommandPalette",xe);return hd.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&&r&&(0,Jt.jsx)("button",{onClick:r,className:i.listMoreButton,type:"button",children:s("showAll")})]}),(0,Jt.jsx)("div",{className:(0,yd.default)(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}var Co=O(require("classnames")),Si=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,r)=>o!==e[r]);return n>-1?n:Math.min(t.length,e.length)}function xm(t){return t.search(hm)}function vd(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let r=new RegExp(`\\b(${ym(o)})\\b`,"gi");n=n.replace(r,"<strong>$1</strong>")}),n}function xd(t){return t.replace(sr,'<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 yi(t,e,n={}){if(e){let o=vm(e.toLowerCase(),t.toLowerCase()),r=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>${r}`}let i=e.split(qa).length>3||e.length>30?Sm(e.trim(),o):0;return`${`${i>0?"\u2026":""}${An(t.substring(i,o))}`}<strong>${r}</strong>`}return t}var bm=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function bo(t){return bm.test(t)}function vi(t){var n;let e=document.createElement("template");return e.innerHTML=t,(n=e.content.textContent)!=null?n:""}var Nr=O(require("react")),Cd=require("react/jsx-runtime"),Sd=Nr.default.createContext(void 0);function Mn(){let t=Nr.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:r,setSelected:s})=>{let i=Nr.default.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:r,setSelected:s}),[n,e,r]);return(0,Cd.jsx)(Sd.Provider,{value:i,children:t})};var Ve=O(require("react")),U=require("@floating-ui/react");var Or={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:r,onOpenChange:s}={}){let[i,a]=Ve.useState(t),d=r!=null?r:i,l=s!=null?s: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})]}),p=c.context,u=(0,U.useClick)(p,{enabled:r==null}),f=(0,U.useDismiss)(p),m=(0,U.useRole)(p),g=(0,U.useHover)(p,{enabled:o!=null?o:!1,handleClose:(0,U.safePolygon)()}),h=(0,U.useInteractions)([u,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},Qt=o=>{var r=o,{children:t,modal:e=!1}=r,n=M(r,["children","modal"]);let s=Cm(y({modal:e},n));return(0,ke.jsx)(Td.Provider,{value:s,children:t})};function Tm(o){var r=o,{as:t,children:e}=r,n=M(r,["as","children"]);let s=xi(),i=t||"button",a=e.ref,d=(0,U.useMergeRefs)([s.refs.setReference,a]);return(0,ke.jsx)(i,S(y({ref:d,type:"button"},s.getReferenceProps(n)),{children:e}))}var wm=Ve.forwardRef(function(r,o){var s=r,{style:e}=s,n=M(s,["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 Em(r){var s=r,{as:t,children:e,onClick:n}=s,o=M(s,["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)(Qt,{tooltip:!0,placement:n,children:[(0,ke.jsxs)(Qt.Content,{className:Or.tooltip,children:[e,(0,ke.jsx)("div",{className:Or.arrow})]}),(0,ke.jsx)(Qt.Trigger,{className:Or.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,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:r,extra:s,onSourceClick:i,description:a,sources:d,id:l,styles:c,defaultSourcesAmount:p=km}=m,u=M(m,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var Ce;let g=R(rt),[h,b]=(0,Et.useState)(!1),{selected:T,onChangeOpen:C}=Mn(),[w,L]=(0,Et.useState)(!1),N=x("CommandPalette",xe);function B(_){r(_),t&&C(!1)}let X=(0,Et.useMemo)(()=>typeof a!="string"?a:bo(a)?vi(a).trim():a,[a]),Le=(0,Et.useMemo)(()=>typeof n!="string"?n:bo(n)?vi(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=u.disabled)!=null?Ce:!1,onClick:B,"data-command-palette-item":!0,"data-item-id":l},u),{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)(Si.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)(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&&s,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:p).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>p&&(0,ae.jsx)("button",{className:(0,Co.default)(N.source,N.sourceShowMore),type:"button",onClick:()=>b(!0),children:g("showMore",{amount:d.length-p})})]})]})}var To=require("react/jsx-runtime"),kd=()=>(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 Ci({children:t,title:e,id:n,onDismiss:o}){let r=R(rt),s=x("CommandPalette",xe),{page:i}=Mn();return i!==n?null:(0,Zt.jsxs)("div",{className:s.page,id:`page_${n}`,tabIndex:-1,children:[o&&(0,Zt.jsxs)("div",{className:s.pageNav,children:[(0,Zt.jsxs)("button",{className:s.pageBackButton,type:"button",onClick:o,children:[(0,Zt.jsx)(kd,{}),r("back")]}),e&&(0,Zt.jsx)("h3",{className:s.pageTitle,children:e})]}),t]})}var Rd=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:r,value:s,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:s,type:"text",id:"command-palette-search-input",autoFocus:!0}),r&&r.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}),r.map(l=>(0,_e.jsx)("option",{value:l.value,children:l.label},l.value))]})})]})]})}var Pd=(0,Rd.forwardRef)(Pm);var Ti=O(require("classnames"));var Dr=require("react/jsx-runtime"),Im=r=>{var s=r,{onClick:t,shortKeys:e,children:n}=s,o=M(s,["onClick","shortKeys","children"]);let i=x("CommandPalette",xe);return(0,Dr.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,Dr.jsx)("span",{className:(0,Ti.default)(i.actionShortcut,a===8629&&i.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},Id=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:r,onChangeSearch:s,onChangeType:i,onChangeOpen:a,selectedType:d,types:l,children:c,isOpen:p,search:u,updateDeps:f=[]}){let[m,g]=(0,st.useState)(),h=(0,st.useRef)(null),b=()=>{r&&r(n),i(void 0),s(""),a(!1)},T=()=>{var _;if(o!==n&&r){r(n);return}if(d&&i){i(void 0),(_=h.current)==null||_.focus();return}if(u.length>0){s("");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,st.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,st.useEffect)(()=>{C()},[u,o,d,p,...f]),(0,st.useEffect)(()=>{m&&B(m)},[m]),(0,Eo.jsx)(In,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:T,onClose:b,onKeyDown:Ce,children:(0,Eo.jsxs)(bd,{selected:m,setSelected:g,isOpen:p,onChangeOpen:a,page:o,children:[o===n&&(0,Eo.jsx)(Pd,{ref:h,onChange:s,onChangeType:i,placeholder:t,value:u,selectedType:d,types:l,typePlaceholder:e}),c]})})}Yt.Page=Ci;Yt.List=hi;Yt.Image=fd;Yt.ListItem=bi;Yt.ListItemActions=Ed;Yt.Button=Id;var te=Yt;var Ld=require("react");function Ad(t,e){(0,Ld.useEffect)(()=>{let n=o=>{var r;((r=navigator==null?void 0:navigator.platform)!=null&&r.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var ko=require("react"),Fr=require("react-redux");var On=require("@reduxjs/toolkit");var Md={data:null,fetchState:"idle"},Am=t=>{var e;return(e=t.entities.data)!=null?e:null},_r=(0,On.createSelector)([Am,En,Pl],(t,e,n)=>{var a;let o=[],{visitorName:r}=n!=null?n:{},{agentName:s,agentNickname:i}=e!=null?e:{};return s&&s!==r&&o.push(s),i&&i!==r&&o.push(i),(a=t==null?void 0:t.filter(d=>!o.includes(d.text)))!=null?a:null}),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 r=o.conversationQuery,s=yield r();return s.length===0?Promise.resolve([]):n.getEntities(s)})),Mm=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),Nm=(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=Mm(e.data?[...e.data,...n.payload]:n.payload)}).addCase(J,()=>Md)}}),Nd=Nm.reducer;var wi={};Y(wi,{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 Od={root:"dd-TYTKs",empty:"dd-AU7uT"};var Dn=require("react/jsx-runtime"),_m=({onCopy:t})=>{let e=(0,ko.useRef)(null),n=x("EntitiesList",Od),o=(0,Fr.useSelector)(_r),{setSelected:r}=Mn(),s=R(wi),i=(0,Fr.useDispatch)();return(0,ko.useEffect)(()=>{i(Fe())},[]),(0,ko.useEffect)(()=>{e.current&&(e.current.focus(),r("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:s("noResults")})]})},Dd=_m;var Ei=require("react/jsx-runtime"),Hr=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 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:r}}=e,s=r||window.location.origin;return o&&!n?null:o&&n?`${s}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${s}${t}`};var ki=require("react-redux");var Br={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var Fd=require("react-redux");var _d=require("@reduxjs/toolkit");function Ur(t){return(0,_d.createAsyncThunk)("analytics/logEvent",(e,n)=>{var s,i,a;let o=(i=(s=n.getState())==null?void 0:s.conversation.current)==null?void 0:i.id,r=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,S(y({conversationId:o},r),{data:e.data}))})(t)}function V(){let t=(0,Fd.useDispatch)();return(e,n)=>v(null,null,function*(){yield t(Ur({name:e,data:n}))})}var en=require("react/jsx-runtime"),Bm=({suggestion:t,source:e,context:n})=>{let o=R(Ro),r=(0,ki.useSelector)(ze),s=V(),i=E("enableSuggestionFeedback"),a=`${t.text}`,d=(0,ki.useSelector)(kt(`/admin/feedback?conversationId=${r}&type=${e}&text=${a}&data=${JSON.stringify({context:n})}`)),l=()=>{s("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:Br.trigger,children:(0,en.jsx)(Hr,{"data-testid":"feedback-dropdown-trigger"})}),(0,en.jsx)(ee.Content,{className:Br.content,children:(0,en.jsx)(ee.Button,{className:Br.item,as:"a",onClick:l,target:"_blank",href:d,children:o("giveFeedback")})})]})},Kr=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 $d=require("react"),Vr=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 Hd(t,e){let n=t.split(Wm),o=0,r=[];for(let s=0;s<n.length;s++){let i=n[s];if(r.push(i),s===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[s+1],d=s===n.length-2;o+=i.length;let l=o;if(d){let p=a.charAt(0),u=0;do l=p?e.indexOf(p,l+1):-1,u+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&u>2)return t}else l=a&&a!==""?e.indexOf(a,o):-1;let c=l===-1?e.slice(o):e.slice(o,l);r.push(c),o=l}return r.join("")}function 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:[]},zr=t=>t.textSuggestions,Wd=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Wr=(0,tn.createAction)("textSuggestions/refresh"),He=(0,tn.createAsyncThunk)("textSuggestions/recommendations",(t,e)=>v(null,null,function*(){var c,p,u;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:r}=o.info,{textSuggestionsCount:s,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(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];let l=[];if(t==="sticky-messages"){let f=(u=o.profile.data)==null?void 0:u.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(r&&(l=l.map(f=>y(S(y({},f),{text:Ne(f.text,r)}),f.title?{title:Ne(f.title,r)}:{}))),t==="default"){let f=i?l.filter(Wd(a)):l;e.dispatch(Tt(f.slice(0,s)))}return l})),Io=(0,tn.createAsyncThunk)("textSuggestions/autocompletions",(t,e)=>v(null,null,function*(){var c,p;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=(c=o.conversation.current)==null?void 0:c.id,{platformVariables:s}=o.info,{textSuggestionsCount:i,deanonymize:a,inlineSuggestions:d}=o.settings;if(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];if(!r)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(r,S(y({},oo(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return d&&(l=l.filter(Wd(t))),s&&(l=l.map(u=>S(y({},u),{text:Ne(u.text,s)}))),a&&(l=l.map(u=>S(y({},u),{text:u.source!=="trie-with-typos"?Hd(u.text,t):u.text}))),l=Bd(l,i),e.dispatch(Tt(l)),l})),Vd=(0,tn.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,r=e[o]||Kd;return S(y({},e),{[o]:S(y({},r),{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,()=>Ud)}}),{setTextSuggestions:uC}=Vd.actions,jd=Vd.reducer;var nn=require("react/jsx-runtime"),Vm=({types:t,commands:e,onClick:n})=>{let o=(0,Vr.useDispatch)(),r=R(Po),s=(0,Vr.useSelector)(zr);return(0,$d.useEffect)(()=>{t.forEach(({type:i})=>{(!s[i]||s[i].suggestions.length===0)&&o(He(i))})},[]),(0,nn.jsxs)("div",{children:[e.length>0&&(0,nn.jsx)(te.List,{heading:r("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=s[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)})]})},Gd=Vm;var le=require("react/jsx-runtime"),$m=200,Gm=5,qm=4,Ri=(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,Ta;let t=(0,je.useDispatch)(),e=me(),n=R(Po),[o,r]=(0,fe.useState)(!1),[s,i]=(0,fe.useState)(""),a=(0,je.useSelector)(Hl),d=(0,je.useSelector)(Xt),[l,c]=(0,fe.useState)(),p=(0,je.useSelector)(ne),u=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=pe=>Ri(T.filter($=>$.type===pe.toUpperCase()),pe,l),Z=(b==null?void 0:b.map(pe=>({value:pe.code.toUpperCase(),label:`${pe.name}s`,list:A(pe.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(pe=>Z.find($=>$.value.toLowerCase()===pe.type)).filter(pe=>!!pe),zs=Z.filter(pe=>!Jn.find($=>$.value===pe.value));return[...Jn,...zs]},[b,L,g,l]),X=[{label:n("entitiesClipboard"),onClick:()=>t(Rn("entities")),shouldShow:m&&Xm(n("entitiesClipboard"),s)}].filter(A=>A.shouldShow).filter(()=>!l),Le=(0,fe.useCallback)((0,qd.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(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),r(!1)):A(Z)}}return(0,fe.useEffect)(()=>{s?Le(s,l):t(yr())},[s,l]),(0,fe.useEffect)(()=>{p&&t(vo())},[p]),Ad(h,()=>{t(Oe(!0)),N("open search",{via:"ctrl+k"})}),!u||!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:s,page:a,isOpen:w,types:B,updateDeps:[T],children:[(0,le.jsxs)(te.Page,{id:"search",children:[s.length===0&&(0,le.jsx)(Gd,{types:L,commands:X,onClick:Ce}),s.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:zs,listOrientation:pe})=>(0,le.jsx)(te.List,{heading:Z,orientation:pe==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(A),hasMore:!l&&C[A.toLowerCase()]>Ri(Jn,A,l).length,children:Ri(Jn,A,l).map($=>(0,le.jsx)(te.ListItem,{id:`${A}-${$.id}`,closeOnSelect:!1,lineClamp:zs,onClick:()=>Ce($.text,$),description:A!=="IMAGE"?$.title&&$.text:void 0,tooltip:$.text,extra:f&&(0,le.jsx)(te.ListItemActions,{children:(0,le.jsx)(Kr,{context:s,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=Jm;var Lo=require("react/jsx-runtime"),Qm=()=>{let t=E("showSearch"),e=E("isEmbedded");return(0,Lo.jsxs)(Jd.Fragment,{children:[t&&(0,Lo.jsx)(Xd,{}),e&&(0,Lo.jsx)(sd,{})]})},Qd=Qm;var tc=O(require("classnames")),nc=require("react-redux");var jr=require("react/jsx-runtime"),Zd=({className:t})=>(0,jr.jsx)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:t,children:(0,jr.jsx)("g",{children:(0,jr.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
3
|
+
`,qt.MISSING_INTL_API,i);var w=n.getPluralRules(e,{type:c.pluralType}).select(u-(c.offset||0));C=c.options[w]||c.options.other}if(!C)throw new di(c.value,u,Object.keys(c.options),i);a.push.apply(a,ho(C.value,e,n,o,r,u-(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:br(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,Sr([void 0],n,!1)))},{cache:ci(t.number),strategy:Cr.variadic}),getDateTimeFormat:br(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,Sr([void 0],n,!1)))},{cache:ci(t.dateTime),strategy:Cr.variadic}),getPluralRules:br(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,Sr([void 0],n,!1)))},{cache:ci(t.pluralRules),strategy:Cr.variadic})}}var ui=(function(){function t(e,n,o,r){n===void 0&&(n=t.defaultLocale);var s=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(l){var c=s.formatToParts(l);if(c.length===1)return c[0].value;var p=c.reduce(function(u,f){return!u.length||f.type!==se.literal||typeof u[u.length-1]!="string"?u.push(f.value):u[u.length-1]+=f.value,u},[]);return p.length<=1?p[0]||"":p},this.formatToParts=function(l){return ho(s.ast,s.locales,s.formatters,s.formats,l,void 0,s.message)},this.resolvedOptions=function(){var l;return{locale:((l=s.resolvedLocale)===null||l===void 0?void 0:l.toString())||Intl.NumberFormat.supportedLocalesOf(s.locales)[0]}},this.getAst=function(){return s.ast},this.locales=n,this.resolvedLocale=t.resolveLocale(n),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=r||{},a=i.formatters,d=$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=r&&r.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",pi=(0,Rr.createContext)(null);function R(t){var o;let e=(0,Rr.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(r,s)=>{let i=Zg(n,r);return i?new ui(i).format(s):(e!==Yg&&console.warn(`${r} does not exist in messages of ${e}`),`[${r}]`)}}var Pr=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:r,onKeyDown:s,overlayAriaLabel:i,contentAriaLabel:a})=>{let d=(0,Pr.useRef)(null),l=S("Dialog",Yl),c=u=>{if(u.key==="Escape"){u.preventDefault(),u.stopPropagation(),r();return}s&&s(u)},p=u=>{u.target===d.current&&t&&o()};return(0,Pr.useEffect)(()=>{var u,f;!d.current||!t||!e||(f=(u=d.current)==null?void 0:u.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:p,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 r=o,{className:t,value:e}=r,n=M(r,["className","value"]);let s=S("TextInput",ed);return(0,nd.jsx)("input",y({className:(0,td.default)(t,s.root),type:"text",value:e},n))},yo=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 rm=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:r})=>{let s=R(mi),i=S("LoginTokenDialog",od),a=(0,Lr.useSelector)(tl),d=(0,Lr.useDispatch)(),l=E("productName"),[c,p]=(0,De.useState)(t||""),[u,f]=(0,De.useState)(0),[m,g]=(0,De.useState)(""),h=(0,De.useCallback)(w=>v(null,null,function*(){w.preventDefault(),d(rl({email:c})),f(1)}),[n,c]),b=()=>{g(""),f(0)},T=(0,De.useCallback)(w=>v(null,null,function*(){w.preventDefault();let L=rm(w.target.elements.token.value);if(!L){g(s("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(s("verifyCodeError",{login:C})),a==="done"&&o()},[a]),(0,G.jsx)(In,{autoFocus:!0,isOpen:e,contentAriaLabel:s("promptTitle",{productName:l}),overlayAriaLabel:s("promptTitle",{productName:l}),onClose:r,onBack:r,children:(0,G.jsxs)("div",{className:i.root,children:[(0,G.jsx)("h1",{className:i.title,children:s("promptTitle",{productName:l})}),u===0&&(0,G.jsxs)("form",{onSubmit:h,children:[(0,G.jsx)("h2",{className:i.subtitle,children:s("requestCodeTitle")}),(0,G.jsx)("p",{className:i.text,children:s("requestCodeBody",{productName:l})}),(0,G.jsx)(yo,{className:i.input,name:"email",placeholder:s("requestCodeInputPlaceholder"),value:c,onChange:w=>p(w.target.value)}),(0,G.jsx)("div",{className:i.actions,children:(0,G.jsx)("button",{type:"submit",className:(0,Ir.default)(i.button,i.primaryButton),children:s("requestCodeSubmitLabel")})})]}),u===1&&(0,G.jsxs)("form",{onSubmit:T,children:[(0,G.jsx)("h2",{className:i.subtitle,children:s("verifyCodeTitle")}),(0,G.jsx)("p",{className:i.text,children:s("verifyCodeBody")}),(0,G.jsx)(yo,{className:i.input,name:"token",placeholder:s("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,Ir.default)(i.button),onClick:b,children:s("back")}),(0,G.jsx)("button",{type:"submit",className:(0,Ir.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:s("verifyCodeSubmitLabel")})]})]})]})})},rd=sm;var id=require("react/jsx-runtime"),im=()=>{let t=(0,fi.useSelector)(nl),e=(0,fi.useSelector)(En),n=E("adminUrl"),o=me(),r=()=>o.send(Pn,!1),s=()=>{o.send(Pn,!1),o.send(ro)};return(0,id.jsx)(rd,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:r,onSuccess:s})},sd=im;var qd=O(require("lodash.debounce")),fe=require("react"),je=require("react-redux");var Ar=require("@reduxjs/toolkit");var am={data:null,fetchState:"idle"},ad=t=>t.contentTypes.data,vo=(0,Ar.createAsyncThunk)("contentTypes/getContentTypes",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),lm=(0,Ar.createSlice)({name:"contentTypes",initialState:am,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})}}),ld=lm.reducer;var Ln=require("@reduxjs/toolkit");var dm={data:null,fetchState:"idle"},cm=[],Xt=t=>t.profile.data,um=t=>t.profile.data?t.profile.data.uiConfig.widget.types:cm,So=(0,Ln.createSelector)([um],t=>t.filter(e=>e.isActive)),dd=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},cd=t=>e=>So(e).find(n=>n.type===t),ud=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 s;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=o.conversation.current;if(!r||!r.profileCode)throw new Error("No conversation of conversation profileCode found");return((s=o.profile.data)==null?void 0:s.code)===r.profileCode?o.profile.data:n.getProfile(r.profileCode)})),pm=(0,Ln.createSlice)({name:"profile",initialState:dm,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})}}),gd=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 st=require("react");var md=require("react"),Mr=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 rt={};Y(rt,{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=S("CommandPalette",xe),[o,r]=(0,md.useState)("loading"),s=R(rt);return(0,wt.jsxs)("div",{className:n.image,children:[(0,wt.jsx)("img",{src:t,alt:e,onLoad:()=>r("done"),onError:()=>r("error"),className:(0,Mr.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&(0,wt.jsx)("span",{className:(0,Mr.default)(n.imageSrc,n.imageSrcStatus),children:s("loading")}),o==="error"&&(0,wt.jsx)("span",{className:(0,Mr.default)(n.imageSrc,n.imageSrcStatus),children:(0,wt.jsx)(Yo,{})}),e&&(0,wt.jsx)("span",{className:n.imageTitle,children:e})]})},fd=fm;var hd=O(require("react")),yd=O(require("classnames"));var Jt=require("react/jsx-runtime");function hi({children:t,heading:e,orientation:n,hasMore:o,onShowAll:r}){let s=R(rt),i=S("CommandPalette",xe);return hd.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&&r&&(0,Jt.jsx)("button",{onClick:r,className:i.listMoreButton,type:"button",children:s("showAll")})]}),(0,Jt.jsx)("div",{className:(0,yd.default)(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}var Co=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,r)=>o!==e[r]);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 r=new RegExp(`\\b(${vm(o)})\\b`,"gi");n=n.replace(r,"<strong>$1</strong>")}),n}function xd(t){return t.replace(sr,'<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()),r=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>${r}`}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>${r}</strong>`}return t}var Cm=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function bo(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 Nr=O(require("react")),Cd=require("react/jsx-runtime"),Sd=Nr.default.createContext(void 0);function Mn(){let t=Nr.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:r,setSelected:s})=>{let i=Nr.default.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:r,setSelected:s}),[n,e,r]);return(0,Cd.jsx)(Sd.Provider,{value:i,children:t})};var Ve=O(require("react")),U=require("@floating-ui/react");var Or={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:r,onOpenChange:s}={}){let[i,a]=Ve.useState(t),d=r!=null?r:i,l=s!=null?s: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})]}),p=c.context,u=(0,U.useClick)(p,{enabled:r==null}),f=(0,U.useDismiss)(p),m=(0,U.useRole)(p),g=(0,U.useHover)(p,{enabled:o!=null?o:!1,handleClose:(0,U.safePolygon)()}),h=(0,U.useInteractions)([u,f,m,g]);return Ve.useMemo(()=>x(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},Qt=o=>{var r=o,{children:t,modal:e=!1}=r,n=M(r,["children","modal"]);let s=Tm(y({modal:e},n));return(0,ke.jsx)(Td.Provider,{value:s,children:t})};function wm(o){var r=o,{as:t,children:e}=r,n=M(r,["as","children"]);let s=xi(),i=t||"button",a=e.ref,d=(0,U.useMergeRefs)([s.refs.setReference,a]);return(0,ke.jsx)(i,x(y({ref:d,type:"button"},s.getReferenceProps(n)),{children:e}))}var Em=Ve.forwardRef(function(r,o){var s=r,{style:e}=s,n=M(s,["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",x(y({ref:d,style:y(x(y({},a.floatingStyles),{zIndex:1e7}),e)},a.getFloatingProps(n)),{children:n.children}))})}):null});function km(r){var s=r,{as:t,children:e,onClick:n}=s,o=M(s,["as","children","onClick"]);let{setOpen:i}=xi();return(0,ke.jsx)(t||"button",x(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)(Qt,{tooltip:!0,placement:n,children:[(0,ke.jsxs)(Qt.Content,{className:Or.tooltip,children:[e,(0,ke.jsx)("div",{className:Or.arrow})]}),(0,ke.jsx)(Qt.Trigger,{className:Or.tooltipTrigger,children:t})]})}Qt.Trigger=wm;Qt.Content=Em;Qt.Button=km;var ee=Qt;var le=require("react/jsx-runtime"),Rm=3,Pm=90,Ed=({children:t})=>{let e=S("CommandPalette",xe);return(0,le.jsx)("div",{className:e.listItemActions,children:t})};function bi(f){var m=f,{closeOnSelect:t=!0,lineClamp:e,tooltip:n,children:o,onClick:r,extra:s,onSourceClick:i,description:a,sources:d,id:l,styles:c,defaultSourcesAmount:p=Rm}=m,u=M(m,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var Ce;let g=R(rt),[h,b]=(0,Et.useState)(!1),{selected:T,onChangeOpen:C}=Mn(),[w,L]=(0,Et.useState)(!1),N=S("CommandPalette",xe);function B(_){r(_),t&&C(!1)}let X=(0,Et.useMemo)(()=>typeof a!="string"?a:bo(a)?vi(a).trim():a,[a]),Le=(0,Et.useMemo)(()=>typeof n!="string"?n:bo(n)?vi(n).trim():n,[n]);return(0,Et.useEffect)(()=>{L(T===l)},[T]),(0,le.jsxs)("div",{className:(0,Co.default)(N.listItem,l===T&&N.listItemSelected),children:[(0,le.jsxs)(ee,{placement:"right-start",tooltip:!0,onOpenChange:L,open:w,children:[(0,le.jsx)(ee.Trigger,x(y({className:N.listItemAction,"aria-disabled":(Ce=u.disabled)!=null?Ce:!1,onClick:B,"data-command-palette-item":!0,"data-item-id":l},u),{children:(0,le.jsxs)("div",{className:N.listItemContent,children:[typeof o=="string"?(0,le.jsx)("p",{className:(0,Co.default)(N.listItemText,N.truncate,c==null?void 0:c.title),children:o}):o,X&&typeof X=="string"?(0,le.jsx)(Si.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>Pm&&(0,le.jsx)(ee.Content,{className:N.listItemTooltip,disableFocusManager:!0,children:(0,le.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&&s,d&&d.length>0&&(0,le.jsxs)("div",{className:N.sources,children:[(0,le.jsx)("span",{className:N.sourcesTitle,children:g("sources")}),d.slice(0,h?d.length:p).map(_=>(0,le.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>p&&(0,le.jsx)("button",{className:(0,Co.default)(N.source,N.sourceShowMore),type:"button",onClick:()=>b(!0),children:g("showMore",{amount:d.length-p})})]})]})}var To=require("react/jsx-runtime"),kd=()=>(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 Ci({children:t,title:e,id:n,onDismiss:o}){let r=R(rt),s=S("CommandPalette",xe),{page:i}=Mn();return i!==n?null:(0,Zt.jsxs)("div",{className:s.page,id:`page_${n}`,tabIndex:-1,children:[o&&(0,Zt.jsxs)("div",{className:s.pageNav,children:[(0,Zt.jsxs)("button",{className:s.pageBackButton,type:"button",onClick:o,children:[(0,Zt.jsx)(kd,{}),r("back")]}),e&&(0,Zt.jsx)("h3",{className:s.pageTitle,children:e})]}),t]})}var Rd=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 Im({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:r,value:s,selectedType:i},a){let d=S("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:s,type:"text",id:"command-palette-search-input",autoFocus:!0}),r&&r.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}),r.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 Dr=require("react/jsx-runtime"),Lm=r=>{var s=r,{onClick:t,shortKeys:e,children:n}=s,o=M(s,["onClick","shortKeys","children"]);let i=S("CommandPalette",xe);return(0,Dr.jsxs)("button",x(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,Dr.jsx)("span",{className:(0,Ti.default)(i.actionShortcut,a===8629&&i.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},Id=Lm;var Eo=require("react/jsx-runtime"),Am="[data-command-palette-item]";function Yt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:r,onChangeSearch:s,onChangeType:i,onChangeOpen:a,selectedType:d,types:l,children:c,isOpen:p,search:u,updateDeps:f=[]}){let[m,g]=(0,st.useState)(),h=(0,st.useRef)(null),b=()=>{r&&r(n),i(void 0),s(""),a(!1)},T=()=>{var _;if(o!==n&&r){r(n);return}if(d&&i){i(void 0),(_=h.current)==null||_.focus();return}if(u.length>0){s("");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,st.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,st.useEffect)(()=>{C()},[u,o,d,p,...f]),(0,st.useEffect)(()=>{m&&B(m)},[m]),(0,Eo.jsx)(In,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:T,onClose:b,onKeyDown:Ce,children:(0,Eo.jsxs)(bd,{selected:m,setSelected:g,isOpen:p,onChangeOpen:a,page:o,children:[o===n&&(0,Eo.jsx)(Pd,{ref:h,onChange:s,onChangeType:i,placeholder:t,value:u,selectedType:d,types:l,typePlaceholder:e}),c]})})}Yt.Page=Ci;Yt.List=hi;Yt.Image=fd;Yt.ListItem=bi;Yt.ListItemActions=Ed;Yt.Button=Id;var te=Yt;var Ld=require("react");function Ad(t,e){(0,Ld.useEffect)(()=>{let n=o=>{var r;((r=navigator==null?void 0:navigator.platform)!=null&&r.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var ko=require("react"),Fr=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},_r=(0,On.createSelector)([Mm,En,Pl],(t,e,n)=>{var a;let o=[],{visitorName:r}=n!=null?n:{},{agentName:s,agentNickname:i}=e!=null?e:{};return s&&s!==r&&o.push(s),i&&i!==r&&o.push(i),(a=t==null?void 0:t.filter(d=>!o.includes(d.text)))!=null?a:null}),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 r=o.conversationQuery,s=yield r();return s.length===0?Promise.resolve([]):n.getEntities(s)})),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,ko.useRef)(null),n=S("EntitiesList",Od),o=(0,Fr.useSelector)(_r),{setSelected:r}=Mn(),s=R(wi),i=(0,Fr.useDispatch)();return(0,ko.useEffect)(()=>{i(Fe())},[]),(0,ko.useEffect)(()=>{e.current&&(e.current.focus(),r("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:s("noResults")})]})},Dd=Fm;var Ei=require("react/jsx-runtime"),Hr=t=>(0,Ei.jsx)("svg",x(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 Ro={};Y(Ro,{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:r}}=e,s=r||window.location.origin;return o&&!n?null:o&&n?`${s}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${s}${t}`};var ki=require("react-redux");var Br={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var Fd=require("react-redux");var _d=require("@reduxjs/toolkit");function Ur(t){return(0,_d.createAsyncThunk)("analytics/logEvent",(e,n)=>{var s,i,a;let o=(i=(s=n.getState())==null?void 0:s.conversation.current)==null?void 0:i.id,r=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,x(y({conversationId:o},r),{data:e.data}))})(t)}function V(){let t=(0,Fd.useDispatch)();return(e,n)=>v(null,null,function*(){yield t(Ur({name:e,data:n}))})}var en=require("react/jsx-runtime"),Um=({suggestion:t,source:e,context:n})=>{let o=R(Ro),r=(0,ki.useSelector)(ze),s=V(),i=E("enableSuggestionFeedback"),a=`${t.text}`,d=(0,ki.useSelector)(kt(`/admin/feedback?conversationId=${r}&type=${e}&text=${a}&data=${JSON.stringify({context:n})}`)),l=()=>{s("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:Br.trigger,children:(0,en.jsx)(Hr,{"data-testid":"feedback-dropdown-trigger"})}),(0,en.jsx)(ee.Content,{className:Br.content,children:(0,en.jsx)(ee.Button,{className:Br.item,as:"a",onClick:l,target:"_blank",href:d,children:o("giveFeedback")})})]})},Kr=Um;var Po={};Y(Po,{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"),Vr=require("react-redux");var tn=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,r=[];for(let s=0;s<n.length;s++){let i=n[s];if(r.push(i),s===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[s+1],d=s===n.length-2;o+=i.length;let l=o;if(d){let p=a.charAt(0),u=0;do l=p?e.indexOf(p,l+1):-1,u+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&u>2)return t}else l=a&&a!==""?e.indexOf(a,o):-1;let c=l===-1?e.slice(o):e.slice(o,l);r.push(c),o=l}return r.join("")}function 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:[]},zr=t=>t.textSuggestions,Wd=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Wr=(0,tn.createAction)("textSuggestions/refresh"),He=(0,tn.createAsyncThunk)("textSuggestions/recommendations",(t,e)=>v(null,null,function*(){var c,p,u;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:r}=o.info,{textSuggestionsCount:s,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(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];let l=[];if(t==="sticky-messages"){let f=(u=o.profile.data)==null?void 0:u.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(r&&(l=l.map(f=>y(x(y({},f),{text:Ne(f.text,r)}),f.title?{title:Ne(f.title,r)}:{}))),t==="default"){let f=i?l.filter(Wd(a)):l;e.dispatch(Tt(f.slice(0,s)))}return l})),Io=(0,tn.createAsyncThunk)("textSuggestions/autocompletions",(t,e)=>v(null,null,function*(){var c,p;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=(c=o.conversation.current)==null?void 0:c.id,{platformVariables:s}=o.info,{textSuggestionsCount:i,deanonymize:a,inlineSuggestions:d}=o.settings;if(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];if(!r)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(r,x(y({},oo(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return d&&(l=l.filter(Wd(t))),s&&(l=l.map(u=>x(y({},u),{text:Ne(u.text,s)}))),a&&(l=l.map(u=>x(y({},u),{text:u.source!=="trie-with-typos"?Hd(u.text,t):u.text}))),l=Bd(l,i),e.dispatch(Tt(l)),l})),Vd=(0,tn.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,r=e[o]||Kd;return x(y({},e),{[o]:x(y({},r),{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,()=>Ud)}}),{setTextSuggestions:mC}=Vd.actions,jd=Vd.reducer;var nn=require("react/jsx-runtime"),jm=({types:t,commands:e,onClick:n})=>{let o=(0,Vr.useDispatch)(),r=R(Po),s=(0,Vr.useSelector)(zr);return(0,$d.useEffect)(()=>{t.forEach(({type:i})=>{(!s[i]||s[i].suggestions.length===0)&&o(He(i))})},[]),(0,nn.jsxs)("div",{children:[e.length>0&&(0,nn.jsx)(te.List,{heading:r("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=s[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)})]})},Gd=jm;var de=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(Po),[o,r]=(0,fe.useState)(!1),[s,i]=(0,fe.useState)(""),a=(0,je.useSelector)(Hl),d=(0,je.useSelector)(Xt),[l,c]=(0,fe.useState)(),p=(0,je.useSelector)(ne),u=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=pe=>Ri(T.filter($=>$.type===pe.toUpperCase()),pe,l),Z=(b==null?void 0:b.map(pe=>({value:pe.code.toUpperCase(),label:`${pe.name}s`,list:A(pe.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(pe=>Z.find($=>$.value.toLowerCase()===pe.type)).filter(pe=>!!pe),zs=Z.filter(pe=>!Jn.find($=>$.value===pe.value));return[...Jn,...zs]},[b,L,g,l]),X=[{label:n("entitiesClipboard"),onClick:()=>t(Rn("entities")),shouldShow:m&&Jm(n("entitiesClipboard"),s)}].filter(A=>A.shouldShow).filter(()=>!l),Le=(0,fe.useCallback)((0,qd.default)((A,Z)=>{t(Gt({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),r(!1)):A(Z)}}return(0,fe.useEffect)(()=>{s?Le(s,l):t(yr())},[s,l]),(0,fe.useEffect)(()=>{p&&t(vo())},[p]),Ad(h,()=>{t(Oe(!0)),N("open search",{via:"ctrl+k"})}),!u||!d?null:(0,de.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:s,page:a,isOpen:w,types:B,updateDeps:[T],children:[(0,de.jsxs)(te.Page,{id:"search",children:[s.length===0&&(0,de.jsx)(Gd,{types:L,commands:X,onClick:Ce}),s.length>0&&(0,de.jsxs)(fe.Fragment,{children:[X.length>0&&(0,de.jsx)(te.List,{heading:n("commands"),children:X.map((A,Z)=>(0,de.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:zs,listOrientation:pe})=>(0,de.jsx)(te.List,{heading:Z,orientation:pe==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(A),hasMore:!l&&C[A.toLowerCase()]>Ri(Jn,A,l).length,children:Ri(Jn,A,l).map($=>(0,de.jsx)(te.ListItem,{id:`${A}-${$.id}`,closeOnSelect:!1,lineClamp:zs,onClick:()=>Ce($.text,$),description:A!=="IMAGE"?$.title&&$.text:void 0,tooltip:$.text,extra:f&&(0,de.jsx)(te.ListItemActions,{children:(0,de.jsx)(Kr,{context:s,source:"search",suggestion:$})}),children:A==="IMAGE"?(0,de.jsx)(te.Image,{title:$.title||$.text,src:$.image}):$.title||$.text},`${$.id}-${$.text}`))},A))]})]}),(0,de.jsx)(te.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:W(()=>{t(Rn("search"))}),children:(0,de.jsx)(Dd,{onCopy:_})})]})},Xd=Qm;var Lo=require("react/jsx-runtime"),Zm=()=>{let t=E("showSearch"),e=E("isEmbedded");return(0,Lo.jsxs)(Jd.Fragment,{children:[t&&(0,Lo.jsx)(Xd,{}),e&&(0,Lo.jsx)(sd,{})]})},Qd=Zm;var tc=O(require("classnames")),nc=require("react-redux");var jr=require("react/jsx-runtime"),Zd=({className:t})=>(0,jr.jsx)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:t,children:(0,jr.jsx)("g",{children:(0,jr.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
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"),Zm={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:Zm[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:()=>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 oc=require("react-redux"),on=require("react/jsx-runtime"),rc=({onLogIn:t})=>{let e=R(Ii),n=E("floatingMenu"),o=E("productName"),r=(0,oc.useDispatch)(),s=(0,nc.useSelector)(ne),i=x("FloatingMenu",ec);if(s===null||n===!1)return null;let a=()=>{s===!0?r(Oe(!0)):t()};return(0,on.jsxs)("button",{type:"button",className:(0,tc.default)(i.root,{[i.isLoggedIn]:s,[i.isLoggedOut]:!s}),onClick:a,children:[(0,on.jsx)("div",{className:i.text,children:e(s?"search":"signin",{productName:o})}),(0,on.jsxs)("div",{className:i.icon,children:[(0,on.jsx)(Yd,{className:i.logo,color:"pink"}),s===!1&&(0,on.jsx)(Zd,{className:i.lock})]})]})};var Xr=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 rn(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}function $e(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:r,selection:s}=t.input;return s.start!==s.end?!1:s.end>=r.length?!0:e?n&&new RegExp(n).test(r.substring(s.end))||o&&new RegExp(o).test(r.substring(0,s.end))?!0:n===!1&&o===!1:!1}var ic=require("@reduxjs/toolkit"),tf={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},$r=({ui:t})=>t.overlayCollapsed,ac=(0,ic.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:Gr,setOverlayCollapsed:Pt,setOpenOverlayWhenTyping:lc,setOverlayCollapsedUserOverwrite:dc}=ac.actions,cc=ac.reducer;var hc=require("react");var Ai=require("interweave"),It=require("react"),No=require("react-redux");var uc=require("react");function pc(t,e,n){(0,uc.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 Mo=require("react/jsx-runtime"),mc=({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 Li={};Y(Li,{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"),sf=["search","personal-collection-search","search-autocomplete"];function af(t,e,n,o={}){var s;let r="";return sf.includes(e)?r=vd(yi(t,n,{stripAgentPart:!0}),(s=o.searchKeywords)!=null?s:[n]):r=yi(t,n,o),o.placeholders===!0&&(r=xd(r)),r}var lf=()=>{},df=({selected:t,suggestion:e})=>{let n=R(Li),o=E("inlineSuggestions"),r=(0,No.useSelector)(Cn),[s,i]=(0,It.useState)(!1),a=E("enableSuggestionFeedback"),d=(0,No.useSelector)(h=>h.input.text),l=(0,No.useDispatch)(),c=x("TextSuggestion",gc),p=(0,It.useRef)(null),u=e.source==="assistant",f=a&&!u;(0,It.useEffect)(()=>{let h=setTimeout(()=>{l(yl({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(h)}},[e]),pc(p,"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,r,{stripAgentPart:o,placeholders:!0,searchKeywords:e.searchKeywords}),[o,e.text,e.source,r,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:p,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)(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&&s&&(0,Se.jsx)("div",{className:c.actions,children:(0,Se.jsx)(Kr,{source:"overlay",context:d,suggestion:e})}),u&&s&&(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=df;var yc=require("react/jsx-runtime"),cf=({suggestions:t,selectedIndex:e,reverse:n})=>(0,hc.useMemo)(()=>{let r=t.map((s,i)=>(0,yc.jsx)(fc,{index:i,selected:i===e,suggestion:s},`${s.text}-${s.source}`));return n?r.reverse():r},[t,e,n]),qr=cf;var vc={root:"dd-PfvRI",paper:"dd-HYlyY"};var Oo=require("react/jsx-runtime"),uf=()=>{let t=(0,Xr.useRef)(null),e=x("InlineSuggestionsOverlay",vc),n=(0,it.useSelector)($e),o=(0,it.useDispatch)(),r=(0,it.useSelector)(ne),s=(0,it.useSelector)(bn),i=(0,it.useSelector)($r),a=E("showTextSuggestions"),d=(0,it.useSelector)(Wt),l=(0,it.useSelector)(to);return Rt(()=>{setTimeout(()=>{o(Pt({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Xr.useEffect)(()=>{let c=t.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let p=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),i||!n||!a||d.length===0||r!==!0||s===!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)(qr,{suggestions:d,selectedIndex:l})})})})},xc=uf;var Sc=require("react-redux");var Do=require("react/jsx-runtime"),pf=({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)(Sc.Provider,{store:t,children:(0,Do.jsx)(pf,{children:(0,Do.jsx)(Zn.Provider,{value:e,children:n})})}),at=gf;var Qr=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 s=window.localStorage.getItem(t);return s?JSON.parse(s):e}catch(s){return k.error(s),e}});return[n,s=>{try{let i=s instanceof Function?s(n):s;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){k.error(i)}}]}var Tc=()=>/Mac/i.test(navigator.platform);var Ec=O(require("classnames")),lt=require("react");var Mi={};Y(Mi,{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 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),hf=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o,onLogIn:r})=>{let s=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]),p=(0,lt.useMemo)(()=>h=>(0,Lt.jsx)("a",{onClick:T=>{T.preventDefault(),r()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),u=(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:[s("loginPlease",{login:n?u:p,productName:d}),o&&(0,Lt.jsxs)(lt.Fragment,{children:[(0,Lt.jsx)("br",{}),s("snooze",{min:f,hour:m,day:g})]})]})},Jr=hf;var Rc=require("react-redux");var kc={root:"dd-DoQhb",text:"dd-Jwnev"};var _o=require("react/jsx-runtime"),yf=({title:t})=>{let e=x("SearchTrigger",kc),n=(0,Rc.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})]})},Pc=yf;var Oi={};Y(Oi,{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 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"),Sf=({onLogIn:t})=>{let e=x("SuggestionsOverlay",Ic),n=R(Oi),o=(0,Be.useSelector)($e),r=(0,Be.useSelector)(hl),s=(0,Be.useDispatch)(),i=(0,_n.useRef)(null),a=E("searchTriggerKey"),d=E("productName"),l=(0,Be.useSelector)($r),c=(0,Be.useSelector)(ne),p=(0,Be.useSelector)(ol),u=(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)(Wt),X=(0,Be.useSelector)(to),Le=B.filter(W=>W.source!=="gpt").length,Ce=()=>{N&&L(0),s(dc(!N))},_=W=>{let Ye=Date.now()+W*1e3;L(Ye),k.info(`Snooze until: ${new Date(Ye)}`),s(Pt({collapse:!0}))};return(0,_n.useEffect)(()=>{Le===0&&m(null)},[B,Le]),Rt(()=>{s(Pt({collapse:!0,skipWhenInputFocus:!0}))}),c===null||u===!1?null:c===!1?(0,K.jsxs)("div",{ref:i,className:(0,Qr.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:[p&&(0,K.jsxs)("div",{className:e.loginError,children:[(0,K.jsx)("span",{className:e.loginErrorMessage,children:p}),(0,K.jsx)("button",{type:"button",className:e.loginErrorDismiss,onClick:()=>s(lr()),"aria-label":n("dismissError"),children:n("dismiss")})]}),(0,K.jsx)(Jr,{loginUrl:b,isEmbedded:T,onLogIn:t,onSnooze:_})]})]}):!r||!o?null:(0,K.jsxs)("div",{ref:i,className:(0,Qr.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,Qr.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)(qr,{suggestions:B,selectedIndex:X,reverse:C==="above"})})})]})},Lc=Sf;var gs=O(require("classnames")),eu=require("interweave"),pt=require("react"),tu=require("react-redux");var Fn=require("react");function Zr(t){return t.contentEditable==="true"}function bf(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let r=o.getRangeAt(0),s=r.cloneRange();s.selectNodeContents(t),s.setEnd(r.endContainer,r.endOffset),n=s.toString().length,s.selectNodeContents(t),s.setEnd(r.startContainer,r.startOffset),e=s.toString().length}return{selectionStart:e,selectionEnd:n}}function Ac(t){let{selectionStart:e,selectionEnd:n}=Zr(t)?bf(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[r,s]=(a=n.current)!=null?a:[],i=Ac(t);(!i||r!==i[0]||s!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function Nc(t,e){if(!e)return;let n=t,{value:o}=n,[r,s]=e,i=o.match(sr);if(!i||i.length===0)return;let a=0;i.find(d=>{let l=o.indexOf(d,a);return r>l&&s<l+d.length?(n.selectionStart=l,n.selectionEnd=l+d.length,!0):(a=l+d.length,!1)})}var Oc=require("react"),Cf=["div","span","mark","strong","b","i","u","em"];function Di(t,e,n=0){var s;let o=t[t.length-1],r=typeof o=="object"&&o!==null?(s=o.props)==null?void 0:s.tagName:void 0;if(r==="br")return t.pop(),[...t,...e,o];if(Cf.includes(r)){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 sn(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"),as=require("react");var Hn=require("react");function _c(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let r=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...r)})},()=>window.cancelAnimationFrame(n)]}function Yr(t){let e=(0,Hn.useRef)(null),[n,o]=(0,Hn.useState)(!1);return(0,Hn.useEffect)(()=>{var c;let r=!1,s=Number.parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[i,a]=_c((p,u)=>{let f=e.current;if(!f)return;let m=p/s,g=u/s,h=f.getBoundingClientRect(),b=m>h.x&&m<h.x+h.width&&g>h.y&&g<h.y+h.height;b&&!r?(r=!0,o(!0)):!b&&r&&(r=!1,o(!1))},({clientX:p,clientY:u})=>[p,u]),[d,l]=_c(()=>{r=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",d),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",d)}},[e]),[e,n]}function Fc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function es(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 ts=require("react"),Tf=["bottom","height","left","right","top","width"],wf=(t={},e={})=>Tf.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 r=o.getBoundingClientRect();wf(r,n.rect)&&(n.rect=r,t.push(n))}),e.forEach(n=>{dt.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),Bc=window.requestAnimationFrame(Uc)};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&&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,ts.useState)(null);return(0,ts.useLayoutEffect)(()=>{if(!t.current)return;let o=Ef(t.current,r=>{n(r)});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),r=(0,Bn.useContext)(Zn);return(0,Bn.useLayoutEffect)(()=>{let s=document.createElement("div");return rn(s),s.classList.add(Kc.root),r!=null&&r.portalRootNode&&s.classList.add(r==null?void 0:r.portalRootNode),(e||document.body).appendChild(s),o(s),()=>{s.isConnected&&s.remove()}},[]),n?(0,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 ns=require("react/jsx-runtime"),os=(t=!1)=>{let[e,n]=(0,Re.useState)(t),o=(0,Re.useCallback)(()=>n(!0),[]),r=(0,Re.useCallback)(()=>n(!1),[]),s=(0,Re.useCallback)(()=>n(a=>!a),[]),i=(0,Re.useRef)(null);return{opened:e,open:o,close:r,toggle:s,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,r=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:r,height:t.height,width:t.width}}var Un=l=>{var c=l,{className:t,triggerRef:e,boundaryRef:n=(0,Re.createRef)(),position:o="above",align:r="center",children:s,toStyle:i=Hi,parentNode:a}=c,d=M(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let p=_i(e),u=_i(n),f=(0,Re.useMemo)(()=>i(p,u,0),[p,u]);return(0,ns.jsx)(Wc,{parentNode:a,children:(0,ns.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]:r==="start",[Ge.alignCenter]:r==="center",[Ge.alignEnd]:r==="end"}),style:f},d),{role:"dialog",children:(0,ns.jsx)("div",{className:(0,Fi.default)(t,Ge.root),children:s})}))})};var Vc=O(require("classnames")),rs=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"),ss=(0,rs.forwardRef)((r,o)=>{var s=r,{className:t,children:e}=s,n=M(s,["className","children"]);let i=(0,rs.useRef)(null),a=x("TabCompletion",ct);return(0,Bi.jsx)("div",S(y({ref:es([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"),kf=t=>e=>{let n=Hi(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:r})=>{let s=x("TabCompletion",ct),i=os(),a=(0,as.useMemo)(()=>kf(t.getBoundingClientRect()),[t]),[d,l]=Yr(t);return(0,as.useEffect)(()=>{l?i.open():i.close()},[l]),(0,At.jsxs)("span",{children:[(0,At.jsx)("mark",{ref:es([d,i.triggerRef]),className:(0,jc.default)(s.matchKeyword,{[s.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&(0,At.jsx)(Un,{className:s.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,At.jsx)(ss,{style:n,children:(0,At.jsx)("div",{className:s.hintText,children:r})})})]})},is=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(r=>S(y({},r),{keywordRegex:new RegExp(`\\b${Fc(r.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let i=n.match(s.keywordRegex);if(!i)return null;let a=n.charAt(i.index-1),d=n.charAt(i.index+s.keyword.length);return a==="{"&&d==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(Hc);if(o.length===0)return null;let r=o.reduce((s,i)=>i.index<s.index?i:s);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(n,o){return(0,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 Gc=require("interweave"),qc=O(require("classnames"));var Ui=require("react/jsx-runtime"),Pf=({inputElement:t,children:e})=>{let n=x("TabCompletion",ct),[o,r]=Yr(t);return(0,Ui.jsx)("mark",{ref:o,className:(0,qc.default)(n.matchPlaceholder,{[n.hover]:r}),children:e})},ls=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)(Pf,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var cs=O(require("classnames")),Yc=require("interweave"),de=require("react"),ps=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"),Fo=require("react-redux"),Qc=O(require("lodash.debounce"));var Jc={root:"dd-ky-Bv",content:"dd-kV5e1"};function ds(t,e,n){var r;let o=((r=t.imageSizes)==null?void 0:r[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(s){return null}}function zi(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:r=If})=>{let s=x("LinkSearch",Jc),[i,a]=(0,qe.useState)(""),d=(0,Fo.useDispatch)(),l=(0,Fo.useSelector)(zd("url")),c=(0,Fo.useSelector)(Ul("URL")),p=(0,qe.useMemo)(()=>c.map(Lf),[c]),[u,f]=(0,qe.useState)(p.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=u-1<0?p.length-1:u-1,L=u+1===p.length?0:u+1;C.code==="Escape"&&(a(""),e()),C.code==="ArrowUp"&&f(w),C.code==="ArrowDown"&&f(L),C.code==="Enter"&&t(((N=p[u])==null?void 0:N.text)||i)},T=(0,qe.useCallback)((0,Qc.default)(C=>{d(Gt({query:C,type:"URL",tags:["link-search"]}))},300),[]);return(0,qe.useEffect)(()=>{i&&T(i)},[i]),(0,qe.useEffect)(()=>()=>{d(yr())},[]),(0,Pe.jsxs)("div",{className:s.root,children:[(0,Pe.jsx)(ie,{withDivider:!0,children:(i?p:l).slice(0,r).map((C,w)=>(0,Pe.jsx)(I,{selected:u===w,onClick:()=>t(C.text),"data-testid":"linksearch-suggestion",children:(0,Pe.jsxs)(F,{children:[(0,Pe.jsx)(F.Image,{src:ds(C,"small",m||void 0),title:C.title||C.text}),(0,Pe.jsxs)(F.Content,{className:s.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)(yo,{value:i,onChange:g,autoFocus:!0,placeholder:n,onKeyUp:b})]})},Zc=Af;var Wi={};Y(Wi,{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,cs.default)(n.matchSelection)},"selection-start")}),Df=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:r})=>{let s=R(Wi),i=x("TabCompletion",ct),a=E("addToPersonalCollection"),d=(0,ps.useSelector)(kt("/admin/personal-collection/new")),l=(0,de.useRef)(null),c=(0,de.useRef)(null),[p,u]=(0,de.useState)(null),f=(0,ps.useDispatch)(),m=os(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,cs.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":m.opened?"true":"false",children:r}),m.opened&&(0,oe.jsx)(Un,{className:i.popoverRoot,triggerRef:m.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,oe.jsxs)(ss,{style:n,ref:c,children:[(0,oe.jsxs)("div",{className:(0,cs.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:p!==null}),children:[(0,oe.jsxs)("button",{type:"button",tabIndex:p===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>u("insertLink"),children:[(0,oe.jsx)(Xc,{}),(0,oe.jsx)("span",{children:"\xA0"}),(0,oe.jsx)("span",{children:s("insertLink")})]}),a&&d&&(0,oe.jsx)("button",{type:"button",tabIndex:p===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:s("addToPersonalCollection")})})]}),p==="insertLink"&&(0,oe.jsx)(Zc,{placeholder:s("linkInputPlaceholder"),visitUrlText:s("visitUrl"),onSelectLink:h,onDismiss:()=>{u(null),m.close()}})]})})]},"selection-end")},us=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,r]=this.props.selection;if(o===r)return null;let s=this.foundIndex===0?o:r,i=s>=this.charCount&&s<=this.charCount+n.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let a=this.foundIndex===1;return i&&a?this.charCount+=s-this.charCount:this.charCount+=n.length,i?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 nu=require("react-redux");var ut=require("react/jsx-runtime"),_f=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:r,showStyleSuggestions:s,keywordMatches:i,inputElement:a,source:d})=>{let l=x("TabCompletion",Dc),c=E("insertLink"),p=E("addToPersonalCollection"),u=E("showMidSentenceSuggestions"),f=E("inlineSuggestions"),m=Mc(a),g=(0,pt.useRef)(null),h=(0,nu.useSelector)(ne);(0,pt.useEffect)(()=>{sn(a)&&m&&Nc(a,m)},[m]);let b=(0,pt.useCallback)(w=>{if(!r||!n)return w;let L=[(0,ut.jsx)("span",{className:l.resetIndent,children:"\u200B"},"u200B"),(0,ut.jsx)("span",{"data-testid":"tab-completion",className:(0,gs.default)(l.tabText,l.resetIndent),"data-source":d,children:n},"tabText")];return o&&L.push((0,ut.jsx)("span",{className:(0,gs.default)(l.hint,l.resetIndent),children:(0,ut.jsx)(nr,{keyCode:"tab"},"tabHint")},"tabHint")),Di(w,L)},[r,n,o]),T=(0,pt.useMemo)(()=>{let w=[];return(c||p)&&w.push(new us("selection")),w.push(new ls("placeholders")),s&&w.push(new is("keywords")),w},[f,c,p,s]),C=(0,pt.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,ut.jsxs)("div",{ref:w=>{w!=null&&w.parentElement&&(g.current=w==null?void 0:w.parentElement)},className:l.root,style:C,children:[(0,ut.jsx)(eu.Interweave,{tagName:"span",containerTagName:"div",className:(0,gs.default)(l.container,l.agentText),disableLineBreaks:sn(a),content:e||"\u200B",onAfterParse:b,matchers:T,selection:m,keywordMatches:i,inputElement:a,inputStyle:C,boundaryRef:g,inlineSuggestionsOnlyAtEnd:!u}),(0,ut.jsx)("br",{})]},"tab-completion")},Ff=t=>{var h,b,T;let{input:e,ui:n,settings:o,styleSuggestions:r,conversation:s}=t,i=Tn({input:e}),a=(i==null?void 0:i.text)||"",d=(i==null?void 0:i.source)||"",l=(h=e.html)!=null?h:An(e.text),c=a.indexOf(e.text)===0?a.slice(e.text.length):"",{showTabHint:p}=n,{isSupported:u}=s,{showTabCompletion:f,visible:m,showStyleSuggestions:g}=o;return{showTabHint:p,showStyleSuggestions:g,showTabCompletion:f&&$e(t),content:l,tabText:c,source:d,keywordMatches:(T=(b=r.list)==null?void 0:b.keywordMatches)!=null?T:[],enabled:m&&u!==!1}},ou=(0,tu.connect)(Ff)(_f);var Ot=require("react"),q=require("react-redux");var Mt=require("@reduxjs/toolkit");var ru=require("marked"),ms=(t,e)=>{let n=[],o=new ru.Marked,r=s=>{s.type==="code"&&s.lang===e&&n.push(s.text)};return o.use({walkTokens:r}),o.parse(t),n};var su={cues:[],threads:{},pending:[]},iu=t=>{var e;return(e=t.assistants)==null?void 0:e.cues};var au=t=>e=>{var n,o;return(o=(n=e.assistants)==null?void 0:n.threads[t])!=null?o:null},fs=(0,Mt.createAction)("assistants/callToAction"),Ho=(0,Mt.createAsyncThunk)("assistants/evaluateKnowledgeAssistant",(t,e)=>v(null,null,function*(){var l,c,p;let{threadId:n}=t,{onNewThreadId:o}=t,{deepdeskAPI:r}=e.extra,s=e.getState(),{platformVariables:i}=s.info;n||(n=(yield r.createAssistantThread({assistantCode:t.assistantCode})).id,o&&o(n)),yield r.postMessageToAssistantThread({assistantCode:t.assistantCode,threadId:n,message:t.input});let a=yield e.dispatch(Xe(S(y({skipState:!0},t),{input:{},threadId:n})));if(a.error)throw new Error(a.error.message);let d=(l=a.payload.output[0])!=null?l:{response:"",sources:[]};return{threadId:n,question:t.input,evaluationId:a.payload.evaluationId,answer:{answer:(c=Ne(d.response,i!=null?i:{}))!=null?c:"",sources:(p=d.sources)!=null?p:[]}}})),bk=(0,Mt.createAction)("assistants/extractedTextSuggestions");function Hf(t,e){var n,o;return Array.isArray(t.output)?t.output:typeof t.output=="string"?[{code:e,name:e,response:t.output}]:[S(y({code:e,name:e},t.output&&typeof t.output=="object"?t.output:{}),{response:(o=(n=t.output)==null?void 0:n.response)!=null?o:""})]}var Xe=(0,Mt.createAsyncThunk)("assistants/evaluate",(t,e)=>v(null,null,function*(){var g;let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra,{transcript:r,input:s={},threadId:i}=t,a=e.getState(),{platformVariables:d}=a.info,l=(g=a.conversation.current)==null?void 0:g.externalId,c;if(r==="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(r)&&(c=r);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(s,{metadata:h})}let p=yield n.evaluateAssistant(t.assistantCode,{input:s,transcript:c,externalConversationId:l,threadId:i});if(p.evaluationStatus!=="success")return e.rejectWithValue(`Assistant ${t.assistantCode} evaluation failed: ${p.evaluationStatus}`);let f=Hf(p,t.assistantCode).map(h=>S(y({},h),{name:Ne(h.name,d),response:Ne(h.response,d)||""})),m=[];return f.forEach(h=>{if(!h.response)return;let b=ms(h.response,"reply");b.length!==0&&m.push(...b.map(T=>({text:T,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name})))}),m.length>0&&e.dispatch(wn(m)),S(y({},p),{output:f})})),lu=(0,Mt.createSlice)({name:"assistants",initialState:su,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:r,evaluationId:s}=e.payload,i=t.cues.findIndex(a=>a.code===n);i!==-1?t.cues[i].response+=r.text:t.cues.push({code:n,name:o,evaluationId:s,response:r.text})},userNotification(t,e){let n=t.cues.filter(d=>d.code!==e.payload.code),{code:o,name:r,evaluationId:s,payload:i}=e.payload,{callToAction:a}=i;t.cues=[...n,{code:o,name:r,evaluationId:s,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 r;k.warn((r=n.error)==null?void 0:r.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:r,output:s}=n.payload,i=s.map(l=>l.code),a=e.cues.filter(l=>!i.includes(l.code)),d=s.map(l=>S(y({},l),{evaluationId:r}));e.cues=[...a,...d]}).addCase(Ho.fulfilled,(e,n)=>{let s=n.payload,{threadId:o}=s,r=M(s,["threadId"]);e.threads[o]=[...e.threads[o]||[],r]}).addCase(J,()=>su)}}),{removeCueByCode:hs,resetCues:Ck,removeThreadById:du,receiveChunk:cu,userNotification:uu}=lu.actions,pu=lu.reducer;var Bo=require("@reduxjs/toolkit");var Bf={token:null,interval:null},Vi=(0,Bo.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),ji=(0,Bo.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(Vi()),setInterval(()=>o(Vi()),n)}),gu=(0,Bo.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:mu}=gu.actions,fu=gu.reducer;var hu=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 yu=(0,hu.createSelector)([iu],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 ys=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 vu={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",vu),[n,o]=(0,ys.useState)(void 0),r=V(),s=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),We(a.text),r("entity copied",{entity:a,type:"copy"}))};return(0,ys.useEffect)(()=>{let a=setTimeout(s,500);return()=>{clearTimeout(a)}},[n]),!t||t.length===0?null:(0,Je.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,d)=>(0,Je.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Je.jsx)("span",{className:e.entityText,children:a.text}),(0,Je.jsxs)("span",{className:e.iconWrapper,children:[(0,Je.jsx)("span",{className:(0,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))})},xu=Kf;var qi=require("react/jsx-runtime"),Su=()=>(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 Pu=require("react"),Iu=require("react-redux");var zn=require("react"),bu=require("react-redux");function vs(t,e){let n=(0,zn.useRef)(t);n.current=t;let[o,r]=(0,zn.useState)(void 0),[s,i]=(0,zn.useState)(void 0),[a,d]=(0,zn.useState)("idle"),l=(0,bu.useDispatch)();return{error:s,state:a,data:o,call:u=>v(null,null,function*(){d("loading"),yield l(n.current(u)).unwrap().then(f=>{r(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"),r(void 0),i(void 0)}}}var Cu={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var Tu={root:"dd-nazq3",rotation:"dd-3EHTv"};var Eu=require("react/jsx-runtime"),zf=({size:t=12})=>{let e=x("LoadingSpinner",Tu);return(0,Eu.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},wu=zf;var Xi=require("react/jsx-runtime"),ku=()=>(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 Uo=require("react/jsx-runtime"),Ru=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 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",Cu),n=R(Ji),o=(0,Pu.useRef)(),r=vs(Xe),s=(0,Iu.useSelector)(dd),i=V(),a=s.filter(c=>c.isPinned),d=s.filter(c=>!c.isPinned),l=c=>v(null,null,function*(){clearTimeout(o.current),i("trigger on demand assistant",{assistantCode:c}),yield r.call(S(y({},t),{assistantCode:c})),o.current=setTimeout(()=>r.reset(),jf)});return s.length===0?null:(0,be.jsxs)("div",{className:e.root,children:[a.map(({assistant:c,assistantName:p,displayName:u})=>(0,be.jsx)("button",{type:"button",className:e.button,disabled:r.state==="loading",onClick:()=>l(c),children:u||p},c)),d.length>0&&(0,be.jsxs)(ee,{placement:"top-end",children:[(0,be.jsx)(ee.Trigger,{className:e.trigger,disabled:r.state==="loading",children:(0,be.jsx)(Hr,{"data-testid":"trigger"})}),(0,be.jsx)(ee.Content,{className:e.nav,"data-testid":"popover",children:d.map(({assistant:c,assistantName:p,displayName:u})=>(0,be.jsx)(ee.Button,{className:e.item,disabled:r.state==="loading",onClick:()=>l(c),children:u||p},c))})]}),r.state==="loading"&&(0,be.jsx)(wu,{}),r.state==="done"&&(0,be.jsx)(Ru,{"data-testid":"trigger-done"}),r.state==="error"&&(0,be.jsx)(wd,{trigger:(0,be.jsx)(ku,{}),children:n("error")})]})},Lu=$f;var Ku=require("react-redux");var Nu=require("react");var Au={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var Mu=require("react/jsx-runtime"),Gf=({width:t})=>{let e=x("LoadingProgressBar",Au);return(0,Mu.jsx)("div",{className:e.loadingBar,style:{width:t}})},xs=Gf;var gt=require("react/jsx-runtime"),Ss=({title:t})=>{let e=(0,Nu.useRef)(null);return or(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)(xs,{width:"60%"}),(0,gt.jsx)(xs,{width:"90%"}),(0,gt.jsx)(xs,{width:"50%"})]})})})};var Ko={};Y(Ko,{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 ln=require("react");var bs=O(require("classnames")),_u=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"),Ou=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 r;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(s=>{n.classList.add(s)}),n.addEventListener("animationend",()=>n.remove()),(r=t.parentElement)==null||r.appendChild(n)}var 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 Du={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:r})=>{let s=x("FeedbackThumbs",Du),i=E("enableFeedbackForm"),a=(0,ta.useSelector)(ze),d=(0,ta.useSelector)(kt(`/admin/feedback?conversationId=${a}&evaluationId=${n}&type=${o}&text=${r}&assistantCode=${t}&assistantOutput=${e}`)),l=R(ea),c=V(),[p,u]=(0,_u.useState)(null),f=h=>{c("Assistant response feedback",{assistantCode:t,assistantOutput:e,evaluationId:n,rating:h})},m=h=>{h.stopPropagation(),Nt(h.target,s.fadeup),u("up"),f("up")},g=h=>{h.stopPropagation(),Nt(h.target,s.fadedown),u("down"),f("down")};return(0,mt.jsxs)("div",{className:s.thumbs,children:[(0,mt.jsx)(I.Button,{title:l("thumbsUp"),onClick:m,icon:(0,mt.jsx)(Ou,{}),className:(0,bs.default)(s.thumbsUp,p==="up"&&s.selected),disabled:!!p}),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,bs.default)(s.thumbsDown,p==="down"&&s.selected),disabled:!!p}):(0,mt.jsx)(I.Button,{title:l("thumbsDown"),onClick:g,icon:(0,mt.jsx)(Zi,{}),className:(0,bs.default)(s.thumbsDown,p==="down"&&s.selected),disabled:!!p})]})},Cs=Zf;var Hu=O(require("dompurify")),ft=require("react");var Fu={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 Bu=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(r=>r.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:r})=>{let s=x("Markdown",Fu),i=(0,ft.useRef)(null),[a,d]=(0,ft.useState)(null),l=(0,ft.useMemo)(()=>{let g=Bu.marked.parse(eh(t));return Hu.default.sanitize(g.toString()).replaceAll("</code>",`${Yf(s.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))},p=()=>{if(!a)return;d(null);let g=a.querySelector("button");g&&(Nt(g,s.fadeup),o==null||o(na(a)))},u=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,s.fadeup),o==null||o(na(b.parentElement)))},f=()=>{!a||!r||(d(null),r(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||r)&&(0,Ue.jsxs)(Un,{triggerRef:{current:a},className:s.popover,parentNode:a,children:[(0,Ue.jsxs)("div",{className:s.options,ref:m,children:[o&&(a==null?void 0:a.tagName)==="CODE"&&(0,Ue.jsx)("button",{type:"button",className:s.option,onClick:p,children:n}),r&&(0,Ue.jsxs)(ft.Fragment,{children:[(0,Ue.jsx)("div",{className:s.divider}),(0,Ue.jsx)("button",{type:"button",className:s.option,onClick:f,children:e})]})]}),(0,Ue.jsx)("div",{className:s.arrow})]}),(0,Ue.jsx)("div",{ref:i,"data-testid":"widget-markdown-content",className:s.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:c,onClick:u})]})},an=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,rh=({content:t,onChange:e,onCopy:n})=>{let o=(0,ln.useRef)(null),r=x("WidgetCue",oa);return(0,ln.useEffect)(()=>{let s=o.current;if(!s)return;s.style.setProperty("height","0px");let i=Math.min(Math.max(s.scrollHeight,oh),nh);s.style.setProperty("height",`${i}px`)},[t]),(0,ce.jsx)("textarea",{ref:o,className:r.editableCue,onCopy:n,onChange:e,value:t})},sh=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:r})=>{let s=x("WidgetCue",oa),i=R(Ko),a=V(),d=E("hasKeyboardInput"),[l,c]=(0,ln.useState)(t.text),p=()=>{e&&e(l,t),n(t)},u=(g,h)=>{o&&o(g,t),h&&Nt(h,s.fadeup)},f=g=>{r&&r(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:s.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?i(t.rule.label):t.title}),t.editable?(0,ce.jsx)(rh,{content:l,onCopy:()=>{let g=document.getSelection();g&&u(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:u,onUse:d?f:void 0})]})}),(0,ce.jsxs)(I.ButtonsContainer,{children:[(0,ce.jsxs)("div",{className:s.actions,children:[(0,ce.jsx)(I.Button,{onClick:g=>{var h;return u((h=ms(l,"reply")[0])!=null?h:l,g.target)},variant:"primary",children:i("copyCue")}),t.callToAction&&(0,ce.jsx)(I.Button,{onClick:p,variant:"primary",children:t.callToAction.label}),(0,ce.jsx)(I.Button,{onClick:m,variant:"secondary",children:i("removeCue")})]}),(0,ce.jsx)(Cs,{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text,feedbackText:t.text,feedbackType:"assistant"})]})]})},Uu=sh;var Wn=require("react/jsx-runtime"),ih=({cues:t})=>{let e=(0,Ku.useDispatch)(),n=me(),o=R(Ko),r=V(),s=l=>{e(hs({code:l.rule.label})),r("Assistant response closed",{evaluationId:l.evaluationId,assistantCode:l.rule.label,assistantOutput:l.text})},i=(l,c)=>{We(l),r("Assistant response copied",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,copiedText:l})},a=(l,c)=>{var p;c.callToAction&&(e(fs(c)),r("Assistant call to action",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,eventName:c.callToAction.event,value:(p=c.callToAction.value)!=null?p:l}))},d=(l,c)=>{var p;n.send(nt,{text:l,suggestion:{source:"assistant",assistantCode:(p=c.rule)==null?void 0:p.label,sourceText:l}}),r("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)(Ss,{title:l.rule.label.startsWith("__")?o(l.rule.label):l.title},l.rule.id):(0,Wn.jsx)(Uu,{cue:l,onCallToAction:a,onRemove:s,onCopy:i,onUse:d},l.evaluationId))})},zu=ih;var Ts=require("react");var Wu={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 Vu=({data:t,schema:e})=>{let n=x("WidgetCustomData",Wu),o=r=>{We(r)};return(0,Ts.useEffect)(()=>{k.info("Custom data",t,e)},[t]),(0,he.jsx)("dl",{className:n.root,children:e.map(r=>{let s=ah(t,r.path);return(0,he.jsxs)(Ts.Fragment,{children:[(0,he.jsx)("dt",{className:n.label,children:r.label}),(0,he.jsx)("dd",{className:n.value,children:r.type==="boolean"&&s?(0,he.jsx)("span",{className:n.isTrue,children:r.trueValue}):r.type==="boolean"&&!s?(0,he.jsx)("span",{className:n.isFalse,children:r.falseValue}):r.type==="array"&&Array.isArray(s)&&s.length>0?(0,he.jsxs)("button",{type:"button",onClick:()=>o(s.join(", ")),className:n.copyButton,children:[(0,he.jsx)("span",{className:n.copyButtonText,children:s.join(", ")}),(0,he.jsx)(Kn,{})]}):typeof s=="string"||typeof s=="number"?(0,he.jsxs)("button",{type:"button",onClick:()=>o(`${s}`),className:n.copyButton,children:[(0,he.jsx)("span",{className:n.copyButtonText,children:s}),(0,he.jsx)(Kn,{})]}):"-"})]},r.label)})})};var j=require("react"),Es=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 ws={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 $u=require("react");var ju={error:"dd-CoAuB"};var ra={};Y(ra,{enUS:()=>ch,nlNL:()=>uh});var ch={errorPrefix:[{type:0,value:"Error:"}]},uh={errorPrefix:[{type:0,value:"Foutmelding:"}]};var zo=require("react/jsx-runtime"),Gu=({message:t})=>{let e=(0,$u.useRef)(null),n=x("WidgetCardError",ju),o=R(ra);return or(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,gh=({sources:t,onClick:e})=>{let n=R(Vn),o=x("WidgetKnowledgeAssistant",ws),[r,s]=(0,j.useState)(!1),i=r?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:()=>s(!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)(an,{content:e})]})})}),fh=({innerRef:t,item:e,hasKeyboardInput:n,onCopy:o,onUse:r,onSourceClick:s})=>{var d;let i=R(Vn),a=(0,j.useContext)(ks);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?r:void 0}),(0,D.jsx)(gh,{sources:(d=e.answer.sources)!=null?d:[],onClick:s})]})}),a.assistantCode&&(0,D.jsxs)(I.ButtonsContainer,{children:[(0,D.jsx)("div",{}),(0,D.jsx)(Cs,{evaluationId:e.evaluationId,feedbackType:"assistant",assistantCode:a.assistantCode,assistantOutput:e.answer.answer,feedbackText:e.answer.answer})]})]})},ks=(0,j.createContext)(null),Rs=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,children:o})=>{let[r,s]=(0,j.useState)(null),[i,a]=(0,j.useState)(!1),[d,l]=(0,j.useState)(null),[c,p]=(0,j.useState)(!!n),[u,f]=(0,j.useState)(null),m=(0,Es.useDispatch)(),g=V(),h=vs(C=>{if(!t)throw new Error("No knowledge assistant was defined");return l(null),e({assistantCode:t,input:C,threadId:r,onNewThreadId(w){s(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:[]}),p(!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:r,pendingInput:u,errorMessage:d,onSubmit:b,onReset(){r&&m(du(r)),l(null),s(null),t&&g("Assistant thread reset",{threadId:r!=null?r:void 0,assistantCode:t})}};return(0,j.useEffect)(()=>{n&&T.isEnabled&&b(n)},[n]),(0,D.jsx)(ks.Provider,{value:T,children:o})},Ps=()=>{let t=R(Vn),e=x("WidgetKnowledgeAssistant",ws),n=(0,j.useContext)(ks),o=(0,j.useRef)(null),[r,s]=(0,j.useState)(""),i=d=>{s(d.target.value)},a=d=>{d.preventDefault(),n.onSubmit(r).then(()=>{var l;o.current&&((l=o.current)==null||l.focus(),s(""))})};return n.isEnabled?(0,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:r,onChange:i}),(0,D.jsx)("button",{type:"submit",disabled:n.isSubmitting||r==="",className:e.formSubmit,children:t("submitLabel")})]}):null},Is=({title:t,emptyState:e})=>{var m,g;let n=R(Vn),o=V(),r=x("WidgetKnowledgeAssistant",ws),s=(0,j.useRef)(null),i=(0,j.useContext)(ks),a=(g=(0,Es.useSelector)(au((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})},p=(h,b)=>{i.assistantCode&&o("Assistant source clicked",{evaluationId:b.evaluationId,assistantCode:i.assistantCode,source:h})},u=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?s:void 0,item:h,hasKeyboardInput:d,onCopy:T=>c(T,h),onUse:T=>f(T,h),onSourceClick:T=>p(T,h)},`${h.question}_${h.answer}_${b}`)),i.pendingInput&&(0,D.jsx)(Ss,{title:i.pendingInput}),i.errorMessage&&(0,D.jsx)(Gu,{message:i.errorMessage})]})}),a.length>0&&(0,D.jsx)("div",{className:r.resetContainer,children:(0,D.jsx)(I.Button,{disabled:i.threadId===null||i.isSubmitting,onClick:u,children:n("resetLabel")})})]})};var Ju=require("react");var hh=/(https?:\/\/[^\s]+)/,Xu=t=>t.split(" ").find(e=>hh.test(e));var Ie=require("react/jsx-runtime"),yh=({suggestion:t,lines:e,onUse:n})=>{var p;let o=t.text||t.url||t.message,r=Xu(o),s=R(Ro),i=E("showImages"),a=E("fallbackImage"),d=E("hasKeyboardInput"),l=u=>{u.preventDefault(),u.stopPropagation(),d&&n(o)},c=(0,Ju.useCallback)(u=>{window.open(r,"_blank"),u.stopPropagation(),u.preventDefault()},[r]);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:ds(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&&((p=t.searchKeywords)==null?void 0:p.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:[r&&(0,Ie.jsx)(I.ActionButton,{onClick:c,label:s("visitUrl")}),d&&(0,Ie.jsx)(I.ActionButton,{primary:!0,onClick:l,label:s("useSuggestion")})]})]})},Qu=yh;var Wo=require("react/jsx-runtime"),vh=({lines:t,suggestions:e})=>{let n=me(),o=(r,s)=>{n.send(nt,{text:r,suggestion:S(y({},s),{source:s.source,sourceText:s.text})})};return(0,Wo.jsx)(Wo.Fragment,{children:e.map(r=>(0,Wo.jsx)(Qu,{suggestion:r,lines:t,onUse:s=>o(s,r)},r.text||r.url||r.message))})},Zu=vh;var Vo={};Y(Vo,{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"),Yu=(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)(Jr,{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")},Ch=()=>{let t=R(Vo),e=(0,q.useDispatch)(),n=x("Widget",jn),o=E("showSearch"),r=E("isEmbedded"),s=(0,q.useSelector)(kt("/admin/")),i=me(),a=E("productName"),d=V();return Yu(()=>{if(r)return e(ji()),()=>{e(mu())}},[e,r]),!o&&!s?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")}),s&&(0,P.jsx)(I.Button,{as:"a",target:"_blank",icon:(0,P.jsx)(Su,{}),href:s,"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(Vo),[o,r]=(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:()=>r(!1),children:n("close")})})]})})}):null},wh=()=>{let t=(0,q.useDispatch)(),e=(0,q.useSelector)(So),n=(0,q.useSelector)(ud),o=(0,q.useSelector)(yu),r=(0,q.useSelector)(Il),s=(0,q.useSelector)(_r),i=(0,q.useSelector)(zr),a=(0,q.useSelector)(Xt),d=(0,q.useSelector)(ze);return(0,Ot.useEffect)(()=>{r&&!n&&k.warn("Custom data provided, but no schema.")},[r,n]),Yu(()=>{e.forEach(({type:l})=>{l==="entities"?t(Fe()):ir.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:p,lines:u,schema:f,property:m})=>{var g,h;switch(l){case"entities":return s&&s.length>0&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(xu,{entities:s})},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)(zu,{cues:o})})},l);case"custom-data-banner":return r&&m&&r[m]&&(0,P.jsx)(Th,{title:c,content:String(r[m])},l);case"custom-data":return r&&f&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ie,{withDivider:!0,children:(0,P.jsx)(Vu,{data:r,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)(Zu,{lines:u,contentType:l,suggestions:i[l].suggestions.slice(0,p)||[]})})},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(Vo),r=(0,q.useSelector)(bn),s=(0,q.useSelector)(ne),i=(0,q.useSelector)(pl),a=(0,q.useSelector)(Xt),d=(0,q.useSelector)(cd("knowledge-assist")),l=(0,q.useSelector)(pd);return r===!1?(0,P.jsx)(sa,{text:o("notSupported")}):s===!1?(0,P.jsx)(bh,{onLogIn:t}):s===null?(0,P.jsx)(sa,{text:o("waiting")}):!i||!a?(0,P.jsx)(sa,{text:o("waitingForConversation")}):(0,P.jsx)(aa,{children:(0,P.jsxs)(Rs,{initialQuestion:e.initialQuestion,assistantCode:l!=null?l:void 0,evaluateKnowledgeAssistFn:Ho,children:[(0,P.jsxs)(hn,{children:[(0,P.jsx)(Ch,{}),(0,P.jsx)(wh,{}),d&&(0,P.jsx)(Is,{title:d.title,emptyState:e.emptyState})]}),(0,P.jsxs)(ia,{children:[d&&(0,P.jsx)(Ps,{}),(0,P.jsx)(Lu,{assistantOptions:n})]})]})})},ep=Eh;function $n(t){let e=new Range;return e.selectNodeContents(t),e}function tp(t,e,n){try{return Dt(t,e,n),!0}catch(o){return!1}}function Ls(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function As(t){return"tagName"in t&&t.tagName==="BR"}var jo=/[\u200B-\u200D\uFEFF]/g;function Dt(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let r=0,s=!1;function i(d,l){let c=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(d))return l;for(let u=0;u<=d.length;u++)if(p.test(d[u])||c++,c===l)return u;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,""),p=r+c.length,u=e>=r&&e<=p,f=n>=r&&n<=p;if(u){let m=i(l,e-r);m===0&&!f?o.setStartBefore(d):o.setStart(d,m)}f&&(o.setEnd(d,i(l,n-r)),s=!0),r=p;break}case Node.ELEMENT_NODE:{if(As(d)&&(r===e&&o.setStartBefore(d),r++,r===n)){o.setEndAfter(d),s=!0;return}for(let c=0;c<d.childNodes.length&&(a(d.childNodes[c]),!s);c++);let l=d.lastChild;Ls(d)&&l&&!Ls(l)&&!As(l)&&r++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function $o(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:r,endOffset:s,collapsed:i}=e,a,d,l=0;function c(p){let u=p===t,f=p===n,m=p===r;switch(p.nodeType){case Node.TEXT_NODE:{let g=p.textContent;f&&(a=l+g.substring(0,o).replace(jo,"").length),m&&(d=l+g.substring(0,s).replace(jo,"").length),l+=g.replace(jo,"").length;break}case Node.ELEMENT_NODE:{if(As(p)&&p.nextSibling){l++;break}!u&&Ls(p)&&p.previousSibling&&l++;for(let g=0;g<p.childNodes.length;g++){let h=f&&g===o,b=m&&g===s;if(h&&(a=l),b&&(d=l),d!==void 0||((!h||!i)&&c(p.childNodes[g]),m&&g===s-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:r,endOffset:s,collapsed:i}=e,a=0,d="";function l(c){let p=c===t,u=c===n,f=c===r;switch(u&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let m=u?o:0,g=f?s:void 0;d+=c.textContent.replace(jo,"").substring(m,g);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&As(c)&&c.nextSibling){d+=`
|
|
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"),on=require("react/jsx-runtime"),rc=({onLogIn:t})=>{let e=R(Ii),n=E("floatingMenu"),o=E("productName"),r=(0,oc.useDispatch)(),s=(0,nc.useSelector)(ne),i=S("FloatingMenu",ec);if(s===null||n===!1)return null;let a=()=>{s===!0?r(Oe(!0)):t()};return(0,on.jsxs)("button",{type:"button",className:(0,tc.default)(i.root,{[i.isLoggedIn]:s,[i.isLoggedOut]:!s}),onClick:a,children:[(0,on.jsx)("div",{className:i.text,children:e(s?"search":"signin",{productName:o})}),(0,on.jsxs)("div",{className:i.icon,children:[(0,on.jsx)(Yd,{className:i.logo,color:"pink"}),s===!1&&(0,on.jsx)(Zd,{className:i.lock})]})]})};var Xr=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 rn(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}function $e(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:r,selection:s}=t.input;return s.start!==s.end?!1:s.end>=r.length?!0:e?n&&new RegExp(n).test(r.substring(s.end))||o&&new RegExp(o).test(r.substring(0,s.end))?!0:n===!1&&o===!1:!1}var ic=require("@reduxjs/toolkit"),nf={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},$r=({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:Ao,setInputFocus:Gr,setOverlayCollapsed:Pt,setOpenOverlayWhenTyping:lc,setOverlayCollapsedUserOverwrite:dc}=ac.actions,cc=ac.reducer;var hc=require("react");var Ai=require("interweave"),It=require("react"),No=require("react-redux");var uc=require("react");function pc(t,e,n){(0,uc.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 Mo=require("react/jsx-runtime"),mc=({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 Li={};Y(Li,{enUS:()=>of,nlNL:()=>rf});var of={assistant:[{type:0,value:"Assistant"}],close:[{type:0,value:"Close"}]},rf={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 s;let r="";return af.includes(e)?r=vd(yi(t,n,{stripAgentPart:!0}),(s=o.searchKeywords)!=null?s:[n]):r=yi(t,n,o),o.placeholders===!0&&(r=xd(r)),r}var df=()=>{},cf=({selected:t,suggestion:e})=>{let n=R(Li),o=E("inlineSuggestions"),r=(0,No.useSelector)(Cn),[s,i]=(0,It.useState)(!1),a=E("enableSuggestionFeedback"),d=(0,No.useSelector)(h=>h.input.text),l=(0,No.useDispatch)(),c=S("TextSuggestion",gc),p=(0,It.useRef)(null),u=e.source==="assistant",f=a&&!u;(0,It.useEffect)(()=>{let h=setTimeout(()=>{l(yl({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(h)}},[e]),pc(p,"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)(()=>lf(e.text,e.source,r,{stripAgentPart:o,placeholders:!0,searchKeywords:e.searchKeywords}),[o,e.text,e.source,r,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:p,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&&s&&(0,Se.jsx)("div",{className:c.actions,children:(0,Se.jsx)(Kr,{source:"overlay",context:d,suggestion:e})}),u&&s&&(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"),uf=({suggestions:t,selectedIndex:e,reverse:n})=>(0,hc.useMemo)(()=>{let r=t.map((s,i)=>(0,yc.jsx)(fc,{index:i,selected:i===e,suggestion:s},`${s.text}-${s.source}`));return n?r.reverse():r},[t,e,n]),qr=uf;var vc={root:"dd-PfvRI",paper:"dd-HYlyY"};var Oo=require("react/jsx-runtime"),pf=()=>{let t=(0,Xr.useRef)(null),e=S("InlineSuggestionsOverlay",vc),n=(0,it.useSelector)($e),o=(0,it.useDispatch)(),r=(0,it.useSelector)(ne),s=(0,it.useSelector)(bn),i=(0,it.useSelector)($r),a=E("showTextSuggestions"),d=(0,it.useSelector)(Wt),l=(0,it.useSelector)(to);return Rt(()=>{setTimeout(()=>{o(Pt({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Xr.useEffect)(()=>{let c=t.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let p=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),i||!n||!a||d.length===0||r!==!0||s===!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)(ae,{children:(0,Oo.jsx)(qr,{suggestions:d,selectedIndex:l})})})})},xc=pf;var Sc=require("react-redux");var Do=require("react/jsx-runtime"),gf=({children:t})=>{let n=E("locale").replace("-","");return(0,Do.jsx)(pi.Provider,{value:n,children:t})},mf=({store:t,customStyles:e={},children:n})=>(0,Do.jsx)(Sc.Provider,{store:t,children:(0,Do.jsx)(gf,{children:(0,Do.jsx)(Zn.Provider,{value:e,children:n})})}),at=mf;var Qr=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 s=window.localStorage.getItem(t);return s?JSON.parse(s):e}catch(s){return k.error(s),e}});return[n,s=>{try{let i=s instanceof Function?s(n):s;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){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:r})=>{let s=R(Mi),i=me(),a=S("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]),p=(0,lt.useMemo)(()=>h=>(0,Lt.jsx)("a",{onClick:T=>{T.preventDefault(),r()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),u=(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:[s("loginPlease",{login:n?u:p,productName:d}),o&&(0,Lt.jsxs)(lt.Fragment,{children:[(0,Lt.jsx)("br",{}),s("snooze",{min:f,hour:m,day:g})]})]})},Jr=yf;var Rc=require("react-redux");var kc={root:"dd-DoQhb",text:"dd-Jwnev"};var _o=require("react/jsx-runtime"),vf=({title:t})=>{let e=S("SearchTrigger",kc),n=(0,Rc.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})]})},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=S("SuggestionsOverlay",Ic),n=R(Oi),o=(0,Be.useSelector)($e),r=(0,Be.useSelector)(hl),s=(0,Be.useDispatch)(),i=(0,_n.useRef)(null),a=E("searchTriggerKey"),d=E("productName"),l=(0,Be.useSelector)($r),c=(0,Be.useSelector)(ne),p=(0,Be.useSelector)(ol),u=(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)(Wt),X=(0,Be.useSelector)(to),Le=B.filter(W=>W.source!=="gpt").length,Ce=()=>{N&&L(0),s(dc(!N))},_=W=>{let Ye=Date.now()+W*1e3;L(Ye),k.info(`Snooze until: ${new Date(Ye)}`),s(Pt({collapse:!0}))};return(0,_n.useEffect)(()=>{Le===0&&m(null)},[B,Le]),Rt(()=>{s(Pt({collapse:!0,skipWhenInputFocus:!0}))}),c===null||u===!1?null:c===!1?(0,K.jsxs)("div",{ref:i,className:(0,Qr.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:[p&&(0,K.jsxs)("div",{className:e.loginError,children:[(0,K.jsx)("span",{className:e.loginErrorMessage,children:p}),(0,K.jsx)("button",{type:"button",className:e.loginErrorDismiss,onClick:()=>s(lr()),"aria-label":n("dismissError"),children:n("dismiss")})]}),(0,K.jsx)(Jr,{loginUrl:b,isEmbedded:T,onLogIn:t,onSnooze:_})]})]}):!r||!o?null:(0,K.jsxs)("div",{ref:i,className:(0,Qr.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,Qr.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)(ae,{children:(0,K.jsx)(qr,{suggestions:B,selectedIndex:X,reverse:C==="above"})})})]})},Lc=bf;var gs=O(require("classnames")),eu=require("interweave"),pt=require("react"),tu=require("react-redux");var Fn=require("react");function Zr(t){return t.contentEditable==="true"}function Cf(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let r=o.getRangeAt(0),s=r.cloneRange();s.selectNodeContents(t),s.setEnd(r.endContainer,r.endOffset),n=s.toString().length,s.selectNodeContents(t),s.setEnd(r.startContainer,r.startOffset),e=s.toString().length}return{selectionStart:e,selectionEnd:n}}function Ac(t){let{selectionStart:e,selectionEnd:n}=Zr(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[r,s]=(a=n.current)!=null?a:[],i=Ac(t);(!i||r!==i[0]||s!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function Nc(t,e){if(!e)return;let n=t,{value:o}=n,[r,s]=e,i=o.match(sr);if(!i||i.length===0)return;let a=0;i.find(d=>{let l=o.indexOf(d,a);return r>l&&s<l+d.length?(n.selectionStart=l,n.selectionEnd=l+d.length,!0):(a=l+d.length,!1)})}var Oc=require("react"),Tf=["div","span","mark","strong","b","i","u","em"];function Di(t,e,n=0){var s;let o=t[t.length-1],r=typeof o=="object"&&o!==null?(s=o.props)==null?void 0:s.tagName:void 0;if(r==="br")return t.pop(),[...t,...e,o];if(Tf.includes(r)){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 sn(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"),as=require("react");var Hn=require("react");function _c(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let r=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...r)})},()=>window.cancelAnimationFrame(n)]}function Yr(t){let e=(0,Hn.useRef)(null),[n,o]=(0,Hn.useState)(!1);return(0,Hn.useEffect)(()=>{var c;let r=!1,s=Number.parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[i,a]=_c((p,u)=>{let f=e.current;if(!f)return;let m=p/s,g=u/s,h=f.getBoundingClientRect(),b=m>h.x&&m<h.x+h.width&&g>h.y&&g<h.y+h.height;b&&!r?(r=!0,o(!0)):!b&&r&&(r=!1,o(!1))},({clientX:p,clientY:u})=>[p,u]),[d,l]=_c(()=>{r=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",d),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",d)}},[e]),[e,n]}function Fc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function es(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 ts=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 r=o.getBoundingClientRect();Ef(r,n.rect)&&(n.rect=r,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,ts.useState)(null);return(0,ts.useLayoutEffect)(()=>{if(!t.current)return;let o=kf(t.current,r=>{n(r)});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),r=(0,Bn.useContext)(Zn);return(0,Bn.useLayoutEffect)(()=>{let s=document.createElement("div");return rn(s),s.classList.add(Kc.root),r!=null&&r.portalRootNode&&s.classList.add(r==null?void 0:r.portalRootNode),(e||document.body).appendChild(s),o(s),()=>{s.isConnected&&s.remove()}},[]),n?(0,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 ns=require("react/jsx-runtime"),os=(t=!1)=>{let[e,n]=(0,Re.useState)(t),o=(0,Re.useCallback)(()=>n(!0),[]),r=(0,Re.useCallback)(()=>n(!1),[]),s=(0,Re.useCallback)(()=>n(a=>!a),[]),i=(0,Re.useRef)(null);return{opened:e,open:o,close:r,toggle:s,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,r=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:r,height:t.height,width:t.width}}var Un=l=>{var c=l,{className:t,triggerRef:e,boundaryRef:n=(0,Re.createRef)(),position:o="above",align:r="center",children:s,toStyle:i=Hi,parentNode:a}=c,d=M(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let p=_i(e),u=_i(n),f=(0,Re.useMemo)(()=>i(p,u,0),[p,u]);return(0,ns.jsx)(Wc,{parentNode:a,children:(0,ns.jsx)("div",x(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]:r==="start",[Ge.alignCenter]:r==="center",[Ge.alignEnd]:r==="end"}),style:f},d),{role:"dialog",children:(0,ns.jsx)("div",{className:(0,Fi.default)(t,Ge.root),children:s})}))})};var Vc=O(require("classnames")),rs=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"),ss=(0,rs.forwardRef)((r,o)=>{var s=r,{className:t,children:e}=s,n=M(s,["className","children"]);let i=(0,rs.useRef)(null),a=S("TabCompletion",ct);return(0,Bi.jsx)("div",x(y({ref:es([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:r})=>{let s=S("TabCompletion",ct),i=os(),a=(0,as.useMemo)(()=>Rf(t.getBoundingClientRect()),[t]),[d,l]=Yr(t);return(0,as.useEffect)(()=>{l?i.open():i.close()},[l]),(0,At.jsxs)("span",{children:[(0,At.jsx)("mark",{ref:es([d,i.triggerRef]),className:(0,jc.default)(s.matchKeyword,{[s.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&(0,At.jsx)(Un,{className:s.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,At.jsx)(ss,{style:n,children:(0,At.jsx)("div",{className:s.hintText,children:r})})})]})},is=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(r=>x(y({},r),{keywordRegex:new RegExp(`\\b${Fc(r.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let i=n.match(s.keywordRegex);if(!i)return null;let a=n.charAt(i.index-1),d=n.charAt(i.index+s.keyword.length);return a==="{"&&d==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(Hc);if(o.length===0)return null;let r=o.reduce((s,i)=>i.index<s.index?i:s);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(n,o){return(0,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=S("TabCompletion",ct),[o,r]=Yr(t);return(0,Ui.jsx)("mark",{ref:o,className:(0,qc.default)(n.matchPlaceholder,{[n.hover]:r}),children:e})},ls=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 cs=O(require("classnames")),Yc=require("interweave"),ce=require("react"),ps=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"),Fo=require("react-redux"),Qc=O(require("lodash.debounce"));var Jc={root:"dd-ky-Bv",content:"dd-kV5e1"};function ds(t,e,n){var r;let o=((r=t.imageSizes)==null?void 0:r[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(s){return null}}function 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:r=Lf})=>{let s=S("LinkSearch",Jc),[i,a]=(0,qe.useState)(""),d=(0,Fo.useDispatch)(),l=(0,Fo.useSelector)(zd("url")),c=(0,Fo.useSelector)(Ul("URL")),p=(0,qe.useMemo)(()=>c.map(Af),[c]),[u,f]=(0,qe.useState)(p.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=u-1<0?p.length-1:u-1,L=u+1===p.length?0:u+1;C.code==="Escape"&&(a(""),e()),C.code==="ArrowUp"&&f(w),C.code==="ArrowDown"&&f(L),C.code==="Enter"&&t(((N=p[u])==null?void 0:N.text)||i)},T=(0,qe.useCallback)((0,Qc.default)(C=>{d(Gt({query:C,type:"URL",tags:["link-search"]}))},300),[]);return(0,qe.useEffect)(()=>{i&&T(i)},[i]),(0,qe.useEffect)(()=>()=>{d(yr())},[]),(0,Pe.jsxs)("div",{className:s.root,children:[(0,Pe.jsx)(ae,{withDivider:!0,children:(i?p:l).slice(0,r).map((C,w)=>(0,Pe.jsx)(I,{selected:u===w,onClick:()=>t(C.text),"data-testid":"linksearch-suggestion",children:(0,Pe.jsxs)(F,{children:[(0,Pe.jsx)(F.Image,{src:ds(C,"small",m||void 0),title:C.title||C.text}),(0,Pe.jsxs)(F.Content,{className:s.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)(yo,{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,ce.forwardRef)((t,e)=>{let n=S("TabCompletion",ct);return(0,oe.jsx)("mark",{ref:e,className:(0,cs.default)(n.matchSelection)},"selection-start")}),_f=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:r})=>{let s=R(Wi),i=S("TabCompletion",ct),a=E("addToPersonalCollection"),d=(0,ps.useSelector)(kt("/admin/personal-collection/new")),l=(0,ce.useRef)(null),c=(0,ce.useRef)(null),[p,u]=(0,ce.useState)(null),f=(0,ps.useDispatch)(),m=os(document.activeElement===o),[g]=(0,ce.useState)(()=>document.createRange());m.triggerRef.current=g,(0,ce.useEffect)(()=>()=>g.detach(),[]),(0,ce.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,ce.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,cs.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":m.opened?"true":"false",children:r}),m.opened&&(0,oe.jsx)(Un,{className:i.popoverRoot,triggerRef:m.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,oe.jsxs)(ss,{style:n,ref:c,children:[(0,oe.jsxs)("div",{className:(0,cs.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:p!==null}),children:[(0,oe.jsxs)("button",{type:"button",tabIndex:p===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>u("insertLink"),children:[(0,oe.jsx)(Xc,{}),(0,oe.jsx)("span",{children:"\xA0"}),(0,oe.jsx)("span",{children:s("insertLink")})]}),a&&d&&(0,oe.jsx)("button",{type:"button",tabIndex:p===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:s("addToPersonalCollection")})})]}),p==="insertLink"&&(0,oe.jsx)(Zc,{placeholder:s("linkInputPlaceholder"),visitUrlText:s("visitUrl"),onSelectLink:h,onDismiss:()=>{u(null),m.close()}})]})})]},"selection-end")},us=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,ce.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,r]=this.props.selection;if(o===r)return null;let s=this.foundIndex===0?o:r,i=s>=this.charCount&&s<=this.charCount+n.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let a=this.foundIndex===1;return i&&a?this.charCount+=s-this.charCount:this.charCount+=n.length,i?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 nu=require("react-redux");var ut=require("react/jsx-runtime"),Ff=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:r,showStyleSuggestions:s,keywordMatches:i,inputElement:a,source:d})=>{let l=S("TabCompletion",Dc),c=E("insertLink"),p=E("addToPersonalCollection"),u=E("showMidSentenceSuggestions"),f=E("inlineSuggestions"),m=Mc(a),g=(0,pt.useRef)(null),h=(0,nu.useSelector)(ne);(0,pt.useEffect)(()=>{sn(a)&&m&&Nc(a,m)},[m]);let b=(0,pt.useCallback)(w=>{if(!r||!n)return w;let L=[(0,ut.jsx)("span",{className:l.resetIndent,children:"\u200B"},"u200B"),(0,ut.jsx)("span",{"data-testid":"tab-completion",className:(0,gs.default)(l.tabText,l.resetIndent),"data-source":d,children:n},"tabText")];return o&&L.push((0,ut.jsx)("span",{className:(0,gs.default)(l.hint,l.resetIndent),children:(0,ut.jsx)(nr,{keyCode:"tab"},"tabHint")},"tabHint")),Di(w,L)},[r,n,o]),T=(0,pt.useMemo)(()=>{let w=[];return(c||p)&&w.push(new us("selection")),w.push(new ls("placeholders")),s&&w.push(new is("keywords")),w},[f,c,p,s]),C=(0,pt.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,ut.jsxs)("div",{ref:w=>{w!=null&&w.parentElement&&(g.current=w==null?void 0:w.parentElement)},className:l.root,style:C,children:[(0,ut.jsx)(eu.Interweave,{tagName:"span",containerTagName:"div",className:(0,gs.default)(l.container,l.agentText),disableLineBreaks:sn(a),content:e||"\u200B",onAfterParse:b,matchers:T,selection:m,keywordMatches:i,inputElement:a,inputStyle:C,boundaryRef:g,inlineSuggestionsOnlyAtEnd:!u}),(0,ut.jsx)("br",{})]},"tab-completion")},Hf=t=>{var h,b,T;let{input:e,ui:n,settings:o,styleSuggestions:r,conversation:s}=t,i=Tn({input:e}),a=(i==null?void 0:i.text)||"",d=(i==null?void 0:i.source)||"",l=(h=e.html)!=null?h:An(e.text),c=a.indexOf(e.text)===0?a.slice(e.text.length):"",{showTabHint:p}=n,{isSupported:u}=s,{showTabCompletion:f,visible:m,showStyleSuggestions:g}=o;return{showTabHint:p,showStyleSuggestions:g,showTabCompletion:f&&$e(t),content:l,tabText:c,source:d,keywordMatches:(T=(b=r.list)==null?void 0:b.keywordMatches)!=null?T:[],enabled:m&&u!==!1}},ou=(0,tu.connect)(Hf)(Ff);var Ot=require("react"),q=require("react-redux");var Mt=require("@reduxjs/toolkit");var ru=require("marked"),ms=(t,e)=>{let n=[],o=new ru.Marked,r=s=>{s.type==="code"&&s.lang===e&&n.push(s.text)};return o.use({walkTokens:r}),o.parse(t),n};var su={cues:[],threads:{},pending:[]},iu=t=>{var e;return(e=t.assistants)==null?void 0:e.cues};var au=t=>e=>{var n,o;return(o=(n=e.assistants)==null?void 0:n.threads[t])!=null?o:null},fs=(0,Mt.createAction)("assistants/callToAction"),Ho=(0,Mt.createAsyncThunk)("assistants/evaluateKnowledgeAssistant",(t,e)=>v(null,null,function*(){var l,c,p;let{threadId:n}=t,{onNewThreadId:o}=t,{deepdeskAPI:r}=e.extra,s=e.getState(),{platformVariables:i}=s.info;n||(n=(yield r.createAssistantThread({assistantCode:t.assistantCode})).id,o&&o(n)),yield r.postMessageToAssistantThread({assistantCode:t.assistantCode,threadId:n,message:t.input});let a=yield e.dispatch(Xe(x(y({skipState:!0},t),{input:{},threadId:n})));if(a.error)throw new Error(a.error.message);let d=(l=a.payload.output[0])!=null?l:{response:"",sources:[]};return{threadId:n,question:t.input,evaluationId:a.payload.evaluationId,answer:{answer:(c=Ne(d.response,i!=null?i:{}))!=null?c:"",sources:(p=d.sources)!=null?p:[]}}})),wk=(0,Mt.createAction)("assistants/extractedTextSuggestions");function Bf(t,e){var n,o;return Array.isArray(t.output)?t.output:typeof t.output=="string"?[{code:e,name:e,response:t.output}]:[x(y({code:e,name:e},t.output&&typeof t.output=="object"?t.output:{}),{response:(o=(n=t.output)==null?void 0:n.response)!=null?o:""})]}var Xe=(0,Mt.createAsyncThunk)("assistants/evaluate",(t,e)=>v(null,null,function*(){var g;let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra,{transcript:r,input:s={},threadId:i}=t,a=e.getState(),{platformVariables:d}=a.info,l=(g=a.conversation.current)==null?void 0:g.externalId,c;if(r==="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(r)&&(c=r);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(s,{metadata:h})}let p=yield n.evaluateAssistant(t.assistantCode,{input:s,transcript:c,externalConversationId:l,threadId:i});if(p.evaluationStatus!=="success")return e.rejectWithValue(`Assistant ${t.assistantCode} evaluation failed: ${p.evaluationStatus}`);let f=Bf(p,t.assistantCode).map(h=>x(y({},h),{name:Ne(h.name,d),response:Ne(h.response,d)||""})),m=[];return f.forEach(h=>{if(!h.response)return;let b=ms(h.response,"reply");b.length!==0&&m.push(...b.map(T=>({text:T,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name})))}),m.length>0&&e.dispatch(wn(m)),x(y({},p),{output:f})})),lu=(0,Mt.createSlice)({name:"assistants",initialState:su,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:r,evaluationId:s}=e.payload,i=t.cues.findIndex(a=>a.code===n);i!==-1?t.cues[i].response+=r.text:t.cues.push({code:n,name:o,evaluationId:s,response:r.text})},userNotification(t,e){let n=t.cues.filter(d=>d.code!==e.payload.code),{code:o,name:r,evaluationId:s,payload:i}=e.payload,{callToAction:a}=i;t.cues=[...n,{code:o,name:r,evaluationId:s,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 r;k.warn((r=n.error)==null?void 0:r.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:r,output:s}=n.payload,i=s.map(l=>l.code),a=e.cues.filter(l=>!i.includes(l.code)),d=s.map(l=>x(y({},l),{evaluationId:r}));e.cues=[...a,...d]}).addCase(Ho.fulfilled,(e,n)=>{let s=n.payload,{threadId:o}=s,r=M(s,["threadId"]);e.threads[o]=[...e.threads[o]||[],r]}).addCase(J,()=>su)}}),{removeCueByCode:hs,resetCues:Ek,removeThreadById:du,receiveChunk:cu,userNotification:uu}=lu.actions,pu=lu.reducer;var Bo=require("@reduxjs/toolkit");var Uf={token:null,interval:null},Vi=(0,Bo.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),ji=(0,Bo.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(Vi()),setInterval(()=>o(Vi()),n)}),gu=(0,Bo.createSlice)({name:"passwordlessToken",initialState:Uf,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:mu}=gu.actions,fu=gu.reducer;var hu=require("@reduxjs/toolkit");function Kf(t){return"buttonText"in t&&"eventName"in t}function yu(t){if(t)return Kf(t)?{label:t.buttonText,event:t.eventName,value:t.payload}:t}function zf(t){return t==null?void 0:t.map(e=>yu(e))}function Wf(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}var vu=(0,hu.createSelector)([iu],t=>t.map(n=>{let o=yu(n.callToAction),r=zf(n.callToActions);return x(y(y(y({text:n.response,title:n.name},o?{callToAction:o}:{}),r!=null&&r.length?{callToActions:r}:{}),n.message!==void 0?{message:n.message}:{}),{editable:n.editable,isLoading:n.isLoading,evaluationId:n.evaluationId,rule:{id:Wf(n.code),label:n.code,name:n.name,description:n.name}})}));var ys=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 xu={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"),Vf=({entities:t})=>{let e=S("EntitiesWidgetList",xu),[n,o]=(0,ys.useState)(void 0),r=V(),s=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),We(a.text),r("entity copied",{entity:a,type:"copy"}))};return(0,ys.useEffect)(()=>{let a=setTimeout(s,500);return()=>{clearTimeout(a)}},[n]),!t||t.length===0?null:(0,Je.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,d)=>(0,Je.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Je.jsx)("span",{className:e.entityText,children:a.text}),(0,Je.jsxs)("span",{className:e.iconWrapper,children:[(0,Je.jsx)("span",{className:(0,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))})},Su=Vf;var qi=require("react/jsx-runtime"),bu=()=>(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 Iu=require("react"),Lu=require("react-redux");var zn=require("react"),Cu=require("react-redux");function vs(t,e){let n=(0,zn.useRef)(t);n.current=t;let[o,r]=(0,zn.useState)(void 0),[s,i]=(0,zn.useState)(void 0),[a,d]=(0,zn.useState)("idle"),l=(0,Cu.useDispatch)();return{error:s,state:a,data:o,call:u=>v(null,null,function*(){d("loading"),yield l(n.current(u)).unwrap().then(f=>{r(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"),r(void 0),i(void 0)}}}var Tu={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var wu={root:"dd-nazq3",rotation:"dd-3EHTv"};var ku=require("react/jsx-runtime"),jf=({size:t=12})=>{let e=S("LoadingSpinner",wu);return(0,ku.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},Eu=jf;var Xi=require("react/jsx-runtime"),Ru=()=>(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 Uo=require("react/jsx-runtime"),Pu=t=>(0,Uo.jsxs)("svg",x(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 Ji={};Y(Ji,{enUS:()=>$f,nlNL:()=>Gf});var $f={error:[{type:0,value:"Something went wrong"}]},Gf={error:[{type:0,value:"Er ging iets fout"}]};var be=require("react/jsx-runtime"),qf=3e3,Xf=({assistantOptions:t})=>{let e=S("OnDemandAssistants",Tu),n=R(Ji),o=(0,Iu.useRef)(),r=vs(Xe),s=(0,Lu.useSelector)(dd),i=V(),a=s.filter(c=>c.isPinned),d=s.filter(c=>!c.isPinned),l=c=>v(null,null,function*(){clearTimeout(o.current),i("trigger on demand assistant",{assistantCode:c}),yield r.call(x(y({},t),{assistantCode:c})),o.current=setTimeout(()=>r.reset(),qf)});return s.length===0?null:(0,be.jsxs)("div",{className:e.root,children:[a.map(({assistant:c,assistantName:p,displayName:u})=>(0,be.jsx)("button",{type:"button",className:e.button,disabled:r.state==="loading",onClick:()=>l(c),children:u||p},c)),d.length>0&&(0,be.jsxs)(ee,{placement:"top-end",children:[(0,be.jsx)(ee.Trigger,{className:e.trigger,disabled:r.state==="loading",children:(0,be.jsx)(Hr,{"data-testid":"trigger"})}),(0,be.jsx)(ee.Content,{className:e.nav,"data-testid":"popover",children:d.map(({assistant:c,assistantName:p,displayName:u})=>(0,be.jsx)(ee.Button,{className:e.item,disabled:r.state==="loading",onClick:()=>l(c),children:u||p},c))})]}),r.state==="loading"&&(0,be.jsx)(Eu,{}),r.state==="done"&&(0,be.jsx)(Pu,{"data-testid":"trigger-done"}),r.state==="error"&&(0,be.jsx)(wd,{trigger:(0,be.jsx)(Ru,{}),children:n("error")})]})},Au=Xf;var zu=require("react-redux");var Ou=require("react");var Mu={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var Nu=require("react/jsx-runtime"),Jf=({width:t})=>{let e=S("LoadingProgressBar",Mu);return(0,Nu.jsx)("div",{className:e.loadingBar,style:{width:t}})},xs=Jf;var gt=require("react/jsx-runtime"),Ss=({title:t})=>{let e=(0,Ou.useRef)(null);return or(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)(xs,{width:"60%"}),(0,gt.jsx)(xs,{width:"90%"}),(0,gt.jsx)(xs,{width:"50%"})]})})})};var Ko={};Y(Ko,{enUS:()=>Qf,nlNL:()=>Zf});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"}]},Zf={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 bs=O(require("classnames")),Fu=require("react");var Qi=require("react/jsx-runtime"),Zi=t=>(0,Qi.jsx)("svg",x(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"),Du=t=>(0,Yi.jsx)("svg",x(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 r;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(s=>{n.classList.add(s)}),n.addEventListener("animationend",()=>n.remove()),(r=t.parentElement)==null||r.appendChild(n)}var ea={};Y(ea,{enUS:()=>Yf,nlNL:()=>eh});var Yf={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},eh={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var _u={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"),th=({assistantCode:t,assistantOutput:e,evaluationId:n,feedbackType:o,feedbackText:r})=>{let s=S("FeedbackThumbs",_u),i=E("enableFeedbackForm"),a=(0,ta.useSelector)(ze),d=(0,ta.useSelector)(kt(`/admin/feedback?conversationId=${a}&evaluationId=${n}&type=${o}&text=${r}&assistantCode=${t}&assistantOutput=${e}`)),l=R(ea),c=V(),[p,u]=(0,Fu.useState)(null),f=h=>{c("Assistant response feedback",{assistantCode:t,assistantOutput:e,evaluationId:n,rating:h})},m=h=>{h.stopPropagation(),Nt(h.target,s.fadeup),u("up"),f("up")},g=h=>{h.stopPropagation(),Nt(h.target,s.fadedown),u("down"),f("down")};return(0,mt.jsxs)("div",{className:s.thumbs,children:[(0,mt.jsx)(I.Button,{title:l("thumbsUp"),onClick:m,icon:(0,mt.jsx)(Du,{}),className:(0,bs.default)(s.thumbsUp,p==="up"&&s.selected),disabled:!!p}),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,bs.default)(s.thumbsDown,p==="down"&&s.selected),disabled:!!p}):(0,mt.jsx)(I.Button,{title:l("thumbsDown"),onClick:g,icon:(0,mt.jsx)(Zi,{}),className:(0,bs.default)(s.thumbsDown,p==="down"&&s.selected),disabled:!!p})]})},Cs=th;var Bu=O(require("dompurify")),ft=require("react");var Hu={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 Uu=require("marked"),Ue=require("react/jsx-runtime");function nh(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(r=>r.remove()),(o=(n=e.textContent)==null?void 0:n.trim())!=null?o:""}function oh(t){return t.replace(/\r\n/g,`
|
|
8
|
+
`)}var rh=({content:t,useLabel:e,copyLabel:n,onCopy:o,onUse:r})=>{let s=S("Markdown",Hu),i=(0,ft.useRef)(null),[a,d]=(0,ft.useState)(null),l=(0,ft.useMemo)(()=>{let g=Uu.marked.parse(oh(t));return Bu.default.sanitize(g.toString()).replaceAll("</code>",`${nh(s.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))},p=()=>{if(!a)return;d(null);let g=a.querySelector("button");g&&(Nt(g,s.fadeup),o==null||o(na(a)))},u=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,s.fadeup),o==null||o(na(b.parentElement)))},f=()=>{!a||!r||(d(null),r(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||r)&&(0,Ue.jsxs)(Un,{triggerRef:{current:a},className:s.popover,parentNode:a,children:[(0,Ue.jsxs)("div",{className:s.options,ref:m,children:[o&&(a==null?void 0:a.tagName)==="CODE"&&(0,Ue.jsx)("button",{type:"button",className:s.option,onClick:p,children:n}),r&&(0,Ue.jsxs)(ft.Fragment,{children:[(0,Ue.jsx)("div",{className:s.divider}),(0,Ue.jsx)("button",{type:"button",className:s.option,onClick:f,children:e})]})]}),(0,Ue.jsx)("div",{className:s.arrow})]}),(0,Ue.jsx)("div",{ref:i,"data-testid":"widget-markdown-content",className:s.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:c,onClick:u})]})},an=rh;var oa={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",ctaMessage:"dd-ge8nB",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 re=require("react/jsx-runtime"),sh=500,ih=100,ah=({content:t,onChange:e,onCopy:n})=>{let o=(0,ln.useRef)(null),r=S("WidgetCue",oa);return(0,ln.useEffect)(()=>{let s=o.current;if(!s)return;s.style.setProperty("height","0px");let i=Math.min(Math.max(s.scrollHeight,ih),sh);s.style.setProperty("height",`${i}px`)},[t]),(0,re.jsx)("textarea",{ref:o,className:r.editableCue,onCopy:n,onChange:e,value:t})},lh=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:r})=>{var g;let s=S("WidgetCue",oa),i=R(Ko),a=V(),d=E("hasKeyboardInput"),[l,c]=(0,ln.useState)(t.text),p=h=>{let b=h?x(y({},t),{callToAction:h}):t;e&&e(l,b),n(t)},u=(h,b)=>{o&&o(h,t),b&&Nt(b,s.fadeup)},f=h=>{r&&r(h,t)},m=h=>{h.preventDefault(),h.stopPropagation(),n(t)};return(0,ln.useEffect)(()=>{a("Assistant response displayed",{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text})},[]),(0,re.jsxs)(I,{"data-testid":"cue",children:[(0,re.jsx)(F,{children:(0,re.jsxs)(F.Content,{children:[t.title&&(0,re.jsx)(F.Title,{className:s.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?i(t.rule.label):t.title}),t.message&&(0,re.jsx)("p",{className:s.ctaMessage,children:t.message}),t.editable?(0,re.jsx)(ah,{content:l,onCopy:()=>{let h=document.getSelection();h&&u(h.toString())},onChange:h=>{var b;return c((b=h.target.value)!=null?b:"")}}):(0,re.jsx)(an,{content:t.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:u,onUse:d?f:void 0})]})}),(0,re.jsxs)(I.ButtonsContainer,{children:[(0,re.jsxs)("div",{className:s.actions,children:[(0,re.jsx)(I.Button,{onClick:h=>{var b;return u((b=ms(l,"reply")[0])!=null?b:l,h.target)},variant:"primary",children:i("copyCue")}),t.callToAction&&(0,re.jsx)(I.Button,{onClick:()=>p(),variant:"primary",children:t.callToAction.label}),(g=t.callToActions)==null?void 0:g.map((h,b)=>(0,re.jsx)(I.Button,{onClick:()=>p(h),variant:"primary",children:h.label},`${h.event}-${h.label}-${b}`)),(0,re.jsx)(I.Button,{onClick:m,variant:"secondary",children:i("removeCue")})]}),(0,re.jsx)(Cs,{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text,feedbackText:t.text,feedbackType:"assistant"})]})]})},Ku=lh;var Wn=require("react/jsx-runtime"),dh=({cues:t})=>{let e=(0,zu.useDispatch)(),n=me(),o=R(Ko),r=V(),s=l=>{e(hs({code:l.rule.label})),r("Assistant response closed",{evaluationId:l.evaluationId,assistantCode:l.rule.label,assistantOutput:l.text})},i=(l,c)=>{We(l),r("Assistant response copied",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,copiedText:l})},a=(l,c)=>{var p;c.callToAction&&(e(fs(c)),r("Assistant call to action",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,eventName:c.callToAction.event,value:(p=c.callToAction.value)!=null?p:l}))},d=(l,c)=>{var p;n.send(nt,{text:l,suggestion:{source:"assistant",assistantCode:(p=c.rule)==null?void 0:p.label,sourceText:l}}),r("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)(Ss,{title:l.rule.label.startsWith("__")?o(l.rule.label):l.title},l.rule.id):(0,Wn.jsx)(Ku,{cue:l,onCallToAction:a,onRemove:s,onCopy:i,onUse:d},l.evaluationId))})},Wu=dh;var Ts=require("react");var Vu={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 ch(t,e){return e.split(".").reduce((n,o)=>!n||typeof n!="object"||!(o in n)?null:n[o],t)}var ju=({data:t,schema:e})=>{let n=S("WidgetCustomData",Vu),o=r=>{We(r)};return(0,Ts.useEffect)(()=>{k.info("Custom data",t,e)},[t]),(0,he.jsx)("dl",{className:n.root,children:e.map(r=>{let s=ch(t,r.path);return(0,he.jsxs)(Ts.Fragment,{children:[(0,he.jsx)("dt",{className:n.label,children:r.label}),(0,he.jsx)("dd",{className:n.value,children:r.type==="boolean"&&s?(0,he.jsx)("span",{className:n.isTrue,children:r.trueValue}):r.type==="boolean"&&!s?(0,he.jsx)("span",{className:n.isFalse,children:r.falseValue}):r.type==="array"&&Array.isArray(s)&&s.length>0?(0,he.jsxs)("button",{type:"button",onClick:()=>o(s.join(", ")),className:n.copyButton,children:[(0,he.jsx)("span",{className:n.copyButtonText,children:s.join(", ")}),(0,he.jsx)(Kn,{})]}):typeof s=="string"||typeof s=="number"?(0,he.jsxs)("button",{type:"button",onClick:()=>o(`${s}`),className:n.copyButton,children:[(0,he.jsx)("span",{className:n.copyButtonText,children:s}),(0,he.jsx)(Kn,{})]}):"-"})]},r.label)})})};var j=require("react"),Es=require("react-redux");var Vn={};Y(Vn,{enUS:()=>uh,nlNL:()=>ph});var uh={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"}]},ph={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 ws={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 Gu=require("react");var $u={error:"dd-CoAuB"};var ra={};Y(ra,{enUS:()=>gh,nlNL:()=>mh});var gh={errorPrefix:[{type:0,value:"Error:"}]},mh={errorPrefix:[{type:0,value:"Foutmelding:"}]};var zo=require("react/jsx-runtime"),qu=({message:t})=>{let e=(0,Gu.useRef)(null),n=S("WidgetCardError",$u),o=R(ra);return or(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"),fh=3,hh=({sources:t,onClick:e})=>{let n=R(Vn),o=S("WidgetKnowledgeAssistant",ws),[r,s]=(0,j.useState)(!1),i=r?t:t.slice(0,fh);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:()=>s(!0),children:n("showMore",{amount:t.length-i.length})})]})},yh=({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})]})})}),vh=({innerRef:t,item:e,hasKeyboardInput:n,onCopy:o,onUse:r,onSourceClick:s})=>{var d;let i=R(Vn),a=(0,j.useContext)(ks);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?r:void 0}),(0,D.jsx)(hh,{sources:(d=e.answer.sources)!=null?d:[],onClick:s})]})}),a.assistantCode&&(0,D.jsxs)(I.ButtonsContainer,{children:[(0,D.jsx)("div",{}),(0,D.jsx)(Cs,{evaluationId:e.evaluationId,feedbackType:"assistant",assistantCode:a.assistantCode,assistantOutput:e.answer.answer,feedbackText:e.answer.answer})]})]})},ks=(0,j.createContext)(null),Rs=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,children:o})=>{let[r,s]=(0,j.useState)(null),[i,a]=(0,j.useState)(!1),[d,l]=(0,j.useState)(null),[c,p]=(0,j.useState)(!!n),[u,f]=(0,j.useState)(null),m=(0,Es.useDispatch)(),g=V(),h=vs(C=>{if(!t)throw new Error("No knowledge assistant was defined");return l(null),e({assistantCode:t,input:C,threadId:r,onNewThreadId(w){s(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:[]}),p(!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:r,pendingInput:u,errorMessage:d,onSubmit:b,onReset(){r&&m(du(r)),l(null),s(null),t&&g("Assistant thread reset",{threadId:r!=null?r:void 0,assistantCode:t})}};return(0,j.useEffect)(()=>{n&&T.isEnabled&&b(n)},[n]),(0,D.jsx)(ks.Provider,{value:T,children:o})},Ps=()=>{let t=R(Vn),e=S("WidgetKnowledgeAssistant",ws),n=(0,j.useContext)(ks),o=(0,j.useRef)(null),[r,s]=(0,j.useState)(""),i=d=>{s(d.target.value)},a=d=>{d.preventDefault(),n.onSubmit(r).then(()=>{var l;o.current&&((l=o.current)==null||l.focus(),s(""))})};return n.isEnabled?(0,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:r,onChange:i}),(0,D.jsx)("button",{type:"submit",disabled:n.isSubmitting||r==="",className:e.formSubmit,children:t("submitLabel")})]}):null},Is=({title:t,emptyState:e})=>{var m,g;let n=R(Vn),o=V(),r=S("WidgetKnowledgeAssistant",ws),s=(0,j.useRef)(null),i=(0,j.useContext)(ks),a=(g=(0,Es.useSelector)(au((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})},p=(h,b)=>{i.assistantCode&&o("Assistant source clicked",{evaluationId:b.evaluationId,assistantCode:i.assistantCode,source:h})},u=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)(ae,{withDivider:!0,children:[e&&a.length===0&&!i.pendingInput&&(0,D.jsx)(yh,y({},e)),a.map((h,b)=>(0,D.jsx)(vh,{innerRef:b===a.length-1?s:void 0,item:h,hasKeyboardInput:d,onCopy:T=>c(T,h),onUse:T=>f(T,h),onSourceClick:T=>p(T,h)},`${h.question}_${h.answer}_${b}`)),i.pendingInput&&(0,D.jsx)(Ss,{title:i.pendingInput}),i.errorMessage&&(0,D.jsx)(qu,{message:i.errorMessage})]})}),a.length>0&&(0,D.jsx)("div",{className:r.resetContainer,children:(0,D.jsx)(I.Button,{disabled:i.threadId===null||i.isSubmitting,onClick:u,children:n("resetLabel")})})]})};var Qu=require("react");var xh=/(https?:\/\/[^\s]+)/,Ju=t=>t.split(" ").find(e=>xh.test(e));var Ie=require("react/jsx-runtime"),Sh=({suggestion:t,lines:e,onUse:n})=>{var p;let o=t.text||t.url||t.message,r=Ju(o),s=R(Ro),i=E("showImages"),a=E("fallbackImage"),d=E("hasKeyboardInput"),l=u=>{u.preventDefault(),u.stopPropagation(),d&&n(o)},c=(0,Qu.useCallback)(u=>{window.open(r,"_blank"),u.stopPropagation(),u.preventDefault()},[r]);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:ds(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&&((p=t.searchKeywords)==null?void 0:p.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:[r&&(0,Ie.jsx)(I.ActionButton,{onClick:c,label:s("visitUrl")}),d&&(0,Ie.jsx)(I.ActionButton,{primary:!0,onClick:l,label:s("useSuggestion")})]})]})},Zu=Sh;var Wo=require("react/jsx-runtime"),bh=({lines:t,suggestions:e})=>{let n=me(),o=(r,s)=>{n.send(nt,{text:r,suggestion:x(y({},s),{source:s.source,sourceText:s.text})})};return(0,Wo.jsx)(Wo.Fragment,{children:e.map(r=>(0,Wo.jsx)(Zu,{suggestion:r,lines:t,onUse:s=>o(s,r)},r.text||r.url||r.message))})},Yu=bh;var Vo={};Y(Vo,{enUS:()=>Ch,nlNL:()=>Th});var Ch={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"}]},Th={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"),ep=(t,e)=>{let n=(0,q.useSelector)(ne);(0,Ot.useEffect)(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},wh=({onLogIn:t})=>{let e=S("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)(Jr,{isEmbedded:n,loginUrl:o,onLogIn:t})})},"login")},sa=({text:t})=>{let e=S("Widget",jn);return(0,P.jsx)("div",{className:e.stateText,children:(0,P.jsx)("div",{children:(0,P.jsx)("p",{children:t})})},"notification")},Eh=()=>{let t=R(Vo),e=(0,q.useDispatch)(),n=S("Widget",jn),o=E("showSearch"),r=E("isEmbedded"),s=(0,q.useSelector)(kt("/admin/")),i=me(),a=E("productName"),d=V();return ep(()=>{if(r)return e(ji()),()=>{e(mu())}},[e,r]),!o&&!s?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")}),s&&(0,P.jsx)(I.Button,{as:"a",target:"_blank",icon:(0,P.jsx)(bu,{}),href:s,"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})})]})},kh=({title:t,content:e})=>{let n=R(Vo),[o,r]=(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)(ae,{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:()=>r(!1),children:n("close")})})]})})}):null},Rh=()=>{let t=(0,q.useDispatch)(),e=(0,q.useSelector)(So),n=(0,q.useSelector)(ud),o=(0,q.useSelector)(vu),r=(0,q.useSelector)(Il),s=(0,q.useSelector)(_r),i=(0,q.useSelector)(zr),a=(0,q.useSelector)(Xt),d=(0,q.useSelector)(ze);return(0,Ot.useEffect)(()=>{r&&!n&&k.warn("Custom data provided, but no schema.")},[r,n]),ep(()=>{e.forEach(({type:l})=>{l==="entities"?t(Fe()):ir.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:p,lines:u,schema:f,property:m})=>{var g,h;switch(l){case"entities":return s&&s.length>0&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(Su,{entities:s})},l);case"cues":return o&&o.length>0&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ae,{withDivider:!0,children:(0,P.jsx)(Wu,{cues:o})})},l);case"custom-data-banner":return r&&m&&r[m]&&(0,P.jsx)(kh,{title:c,content:String(r[m])},l);case"custom-data":return r&&f&&(0,P.jsx)(Ke,{type:l,title:c,"data-testid":`type-${l}`,children:(0,P.jsx)(ae,{withDivider:!0,children:(0,P.jsx)(ju,{data:r,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)(ae,{withDivider:!0,children:(0,P.jsx)(Yu,{lines:u,contentType:l,suggestions:i[l].suggestions.slice(0,p)||[]})})},l)}})})},ia=({children:t})=>{let e=S("Widget",jn);return(0,P.jsx)("div",{className:e.footer,children:t})},aa=({children:t})=>{let e=S("Widget",jn);return(0,P.jsx)("div",{className:e.root,"data-testid":"widget",children:t})},Ph=({onLogIn:t,knowledgeAssistOptions:e={},assistantOptions:n={transcript:"in-memory-transcript"}})=>{let o=R(Vo),r=(0,q.useSelector)(bn),s=(0,q.useSelector)(ne),i=(0,q.useSelector)(pl),a=(0,q.useSelector)(Xt),d=(0,q.useSelector)(cd("knowledge-assist")),l=(0,q.useSelector)(pd);return r===!1?(0,P.jsx)(sa,{text:o("notSupported")}):s===!1?(0,P.jsx)(wh,{onLogIn:t}):s===null?(0,P.jsx)(sa,{text:o("waiting")}):!i||!a?(0,P.jsx)(sa,{text:o("waitingForConversation")}):(0,P.jsx)(aa,{children:(0,P.jsxs)(Rs,{initialQuestion:e.initialQuestion,assistantCode:l!=null?l:void 0,evaluateKnowledgeAssistFn:Ho,children:[(0,P.jsxs)(hn,{children:[(0,P.jsx)(Eh,{}),(0,P.jsx)(Rh,{}),d&&(0,P.jsx)(Is,{title:d.title,emptyState:e.emptyState})]}),(0,P.jsxs)(ia,{children:[d&&(0,P.jsx)(Ps,{}),(0,P.jsx)(Au,{assistantOptions:n})]})]})})},tp=Ph;function $n(t){let e=new Range;return e.selectNodeContents(t),e}function np(t,e,n){try{return Dt(t,e,n),!0}catch(o){return!1}}function Ls(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function As(t){return"tagName"in t&&t.tagName==="BR"}var jo=/[\u200B-\u200D\uFEFF]/g;function Dt(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let r=0,s=!1;function i(d,l){let c=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(d))return l;for(let u=0;u<=d.length;u++)if(p.test(d[u])||c++,c===l)return u;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,""),p=r+c.length,u=e>=r&&e<=p,f=n>=r&&n<=p;if(u){let m=i(l,e-r);m===0&&!f?o.setStartBefore(d):o.setStart(d,m)}f&&(o.setEnd(d,i(l,n-r)),s=!0),r=p;break}case Node.ELEMENT_NODE:{if(As(d)&&(r===e&&o.setStartBefore(d),r++,r===n)){o.setEndAfter(d),s=!0;return}for(let c=0;c<d.childNodes.length&&(a(d.childNodes[c]),!s);c++);let l=d.lastChild;Ls(d)&&l&&!Ls(l)&&!As(l)&&r++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function $o(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:r,endOffset:s,collapsed:i}=e,a,d,l=0;function c(p){let u=p===t,f=p===n,m=p===r;switch(p.nodeType){case Node.TEXT_NODE:{let g=p.textContent;f&&(a=l+g.substring(0,o).replace(jo,"").length),m&&(d=l+g.substring(0,s).replace(jo,"").length),l+=g.replace(jo,"").length;break}case Node.ELEMENT_NODE:{if(As(p)&&p.nextSibling){l++;break}!u&&Ls(p)&&p.previousSibling&&l++;for(let g=0;g<p.childNodes.length;g++){let h=f&&g===o,b=m&&g===s;if(h&&(a=l),b&&(d=l),d!==void 0||((!h||!i)&&c(p.childNodes[g]),m&&g===s-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:r,endOffset:s,collapsed:i}=e,a=0,d="";function l(c){let p=c===t,u=c===n,f=c===r;switch(u&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let m=u?o:0,g=f?s:void 0;d+=c.textContent.replace(jo,"").substring(m,g);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&As(c)&&c.nextSibling){d+=`
|
|
9
9
|
`;break}!p&&!i&&a===1&&Ls(c)&&c.previousSibling&&(d+=`
|
|
10
|
-
`);let m=u?o:0,g=f?Math.min(s,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 np=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(np||{}),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=r=>{n(r)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}handleInteraction(){let e=this.getText(),n=this.getHTML(),o=this.getSelection(),r=this.cachedCaretPosition===null;if(!this.isActive||(e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),e!==this.cachedText?(this.cachedText=e,this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,r=!0,this.emit("selection",o)),!r))return;let s=this.getCaretPosition();Ct(s,this.cachedCaretPosition)||(this.cachedCaretPosition=s,this.emit("caretposition",s))}handleClick(){this.handleInteraction()}handleFocus(){let e=!this.isFocused;this.isFocused=!0,e&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let e=this.isFocused;this.isFocused=!1,e&&this.emit("blur")}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:r}=e;this.isPossibleClearInputAction=Object.values(np).includes(n)||n.toLowerCase()==="z"&&(o||r),this.emit("keydown",e)}handleKeyUp(e){this.handleInteraction(),this.emit("keyup",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var o,r;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((r=e.clipboardData)==null?void 0:r.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()})}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}off(e,n){if(!this.eventListeners[e])return;let o=this.eventListeners[e].indexOf(n);o!==-1&&this.eventListeners[e].splice(o,1)}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function op(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 r=o.rangeCount>0?o.getRangeAt(0):null;if(!r)return null;let s=this.element.ownerDocument.createRange();return s.setStart(r==null?void 0:r.startContainer,r==null?void 0:r.startOffset),s.setEnd(r==null?void 0:r.endContainer,r==null?void 0:r.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let o=n.getBoundingClientRect();return!op(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!op(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&&tp(this.element,o.start,o.end))return o;let r=$n(this.element);return r.collapse(!1),$o(this.element,r)}getSelectedText(){let{start:n,end:o}=this.getSelection();return Go(this.element,Dt(this.element,n,o))}listen(){super.listen();let n=new MutationObserver(s=>{var i,a;s.length===2&&s[0].addedNodes.length===1&&((i=s[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=s[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let o=this.element.isContentEditable,r=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>r.disconnect())}};var 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 rp(t,e){let n="mozInnerScreenX"in window,o=document.createElement("div");o.id="input-textarea-caret-position-mirror-div";let r=o.style,s=window.getComputedStyle(t),i=t.ownerDocument.body;r.whiteSpace="pre-wrap",r.wordWrap="break-word",r.position="absolute",r.visibility="hidden",kh.forEach(c=>{r[c]=s[c]}),n?t.scrollHeight>Number.parseInt(s.height)&&(r.overflowY="scroll"):r.overflow="hidden",o.textContent=t.value.substring(0,e);let a=document.createElement("span");a.textContent=t.value.substring(e)||".",o.appendChild(a),i.appendChild(o);let d=t.getBoundingClientRect(),l={top:d.top-t.scrollTop+a.offsetTop+Number.parseInt(s.borderTopWidth)+a.offsetHeight,left:d.left-t.scrollLeft+a.offsetLeft+Number.parseInt(s.borderLeftWidth)};return i.removeChild(o),l}var 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 rp(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=n==null?void 0:n.get)==null?void 0:s.call(this.element)},set:s=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,s),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let o=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};function sp(t,e,n){let o=`deepdesk-iframe-${t}`,r=document.getElementById(o);if(r)return r;let s=document.createElement("iframe"),i=new URL(e);return Object.entries(n).forEach(([a,d])=>{i.searchParams.append(a,d)}),s.style.position="absolute",s.style.left="-999em",s.style.width="0px",s.style.height="0px",s.tabIndex=-1,s.id=o,s.title=`iframe-${t}`,s.src=i.toString(),window.document.body.appendChild(s),s}function 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=sp(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=r=>{var i,a;if(r.origin!==this.deepdeskUrl)return;let s=Rh(r.data);typeof s!="object"||s.type!=="event"||s.channel!==e||(k.info("Received broadcast event",this.externalId,r),(a=(i=this.eventMap)[s.name])==null||a.call(i,s.payload))};return n.onMessage(o),n}send(e,n,o){var i,a;k.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let r={type:"event",name:e,payload:n};o!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,n));let s=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage(S(y({},r),{channel:this.externalId}))}cleanup(e=!1){var n,o;(n=this.channel)==null||n.close(),this.channel=void 0,e&&((o=this.defaultChannel)==null||o.close(),this.defaultChannel=void 0)}},ip=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 ue(t){return Array.isArray(t)?t.map(ue):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>S(y({},e),{[Ih(n)]:ue(t[n])}),{}):t}var Gn=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var ua=t=>new Promise(e=>{setTimeout(e,t)});var un=class extends Gn{constructor(){super(...arguments);this.name="ClientError"}},ga=class extends Gn{constructor(){super(...arguments);this.name="ServerError"}},pa=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 pn=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,r)=>{let s={isAborted:!1,reject:r},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:p=1,retryDelay:u=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=p,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]=s;let L=()=>v(this,null,function*(){return C--,a(i,T).then(B=>v(this,null,function*(){return g(B)&&!s.isAborted&&C>0?(yield ua(u),L()):B.status===401&&f===!0&&w===!1?(w=!0,yield this.refreshToken(),L()):B})).catch(B=>v(this,null,function*(){if(m(B)&&!s.isAborted&&C>0)return yield ua(u),L();throw B}))});L().then(B=>v(this,null,function*(){let X=yield Lh(B);if(delete this.latestRequestByUrl[i],B.status>=500){r(new ga("Server Error",X));return}if(B.status===401){r(new un("Unauthorized",X));return}if(B.status===403){r(new un("Forbidden",X));return}if(B.status===404){r(new un("Not Found",X));return}if(B.status>=400){r(new un("Bad Request",X));return}l&&pa.set(i,X),o(X)})).catch(B=>{r(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(r){return!1}if(!e){if(!o)return!1;try{yield this.refreshToken();let{is_logged_in:r}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return r}catch(r){return!1}}return n})}refreshToken(){let e=Date.now();return this.lastFailedRefreshAt&&e-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new un("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 ap;(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={}))})(ap||(ap={}));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 pn(e,{fetch:n.fetch}),this.client.patchFetch(o=>(r,s)=>v(this,null,function*(){let i=yield o(r,s);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return v(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=yield this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(gn.exchangeTokenPromise||(gn.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),gn.exchangeTokenPromise):Promise.resolve()})}createConversation(e){return v(this,null,function*(){var o;yield this.preflight(),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()},ue(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/",ue(e))})}patchMe(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",ue(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:r=1,retryDelay:s=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:r,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return 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:r=1,retryDelay:s=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:r,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(e,n){return v(this,null,function*(){var s;yield this.preflight();let o=ue(n);n.metadata&&(o.metadata=(s=n.metadata)!=null?s:{});let r=yield this.client.put(`/api/v2/conversations/${e}`,o);return ma(r)})}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({},ue(o)),{metadata:o.metadata})))})}sendEvent(e,n){return v(this,null,function*(){yield this.preflight();let a=n,{data:o}=a,r=M(a,["data"]),s=Object.entries(this.latestReceivedDeepdeskVersions).reduce((d,[l,c])=>S(y({},d),{[l]:c}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((d,l)=>(r[l]&&(d[l]=r[l]),d),{});return this.client.post("/api/v2/events",ue(S(y(y({},s),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/",ue(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(r){return v(this,arguments,function*(e,n={},o){if(yield this.preflight(),o==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${e}/recommend/${o}`,ue(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`,ue(n),{abortLatest:!0})).map(r=>({score:1,source:r.source,sourceText:r.source_text,text:r.label,trainingJobs:r.training_jobs,searchKeywords:r.search_keywords,type:r.source})).filter((r,s,i)=>s===i.findIndex(a=>a.text===r.text))})}getPinnedMessages(e){return v(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return z(n).map(o=>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",ue(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`,ue(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 r=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()}`,s=yield this.client.post(r,{input:(i=n==null?void 0:n.input)!=null?i:{},conversation:n==null?void 0:n.transcript});return z(s)})}createAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n}=e,o=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return z(o)})}postMessageToAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:r}=e,s=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:r,role:"user"});return z(s)})}translateMessages(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",ue(e));return z(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let r=o.toLowerCase(),s=r.match(Xa);if(!n||!s)return;let i=s[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&k.warn(`Overwritten Version header ${r}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};gn.exchangeTokenPromise=null;var yt=gn;var Ds=require("@reduxjs/toolkit");var dp=require("@reduxjs/toolkit");var lp={startTime:null,stopTime:null},cp=t=>t.handlingTime,up=(0,dp.createSlice)({name:"handlingTime",initialState:lp,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,()=>lp)}}),{handlingTimeStart:pp,handlingTimeStop:Ms,handlingTimeReset:gp}=up.actions,mp=up.reducer;var fp=(t={})=>{let e=y({onAuthError:Sn(!1)},t);return n=>o=>r=>("error"in r&&r.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(r))};var Os=require("@reduxjs/toolkit");var Ns={list:{keywordMatches:[]},fetchState:"idle"};var mn=(0,Os.createAsyncThunk)("styleSuggestions/getAll",(n,o)=>v(null,[n,o],function*({text:t},e){var d;let{deepdeskAPI:r}=e.extra,s=e.getState(),{showStyleSuggestions:i}=s.settings,a=(d=s.conversation.current)==null?void 0:d.profileCode;if(!i)return Ns.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return r.getStyleSuggestions({profileCode:a,message:t})})),Ah=(0,Os.createSlice)({name:"styleSuggestions",initialState:Ns,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=Ns.list}).addCase(J,()=>Ns)}}),hp=Ah.reducer;var yp=(t={})=>{let e,n=!0,o=y({getStyleSuggestions:mn,debounce:500},t);return r=>s=>i=>{var f;let a=r.getState().input.text,d=s(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return d;let{showStyleSuggestions:c}=l.settings;if(!((f=l.conversation.current)==null?void 0:f.id)||!c)return d;let{text:u}=l.input;return u===a&&!n||(clearTimeout(e),u==="")||(e=setTimeout(()=>{n=!1,r.dispatch(o.getStyleSuggestions({text:u}))},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 vp=(t={})=>{let e=y({getTextSuggestions:He,getAutocompleteSuggestions:Io,debounce:200,check:$e},t),n;return o=>r=>s=>{var g;let{input:i}=o.getState(),a=r(s),d=o.getState();if(d.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:c}=d.settings,p=(g=d.conversation.current)==null?void 0:g.id,u=s.type===Wr.toString();if(!p||!l&&!c)return a;let{input:f}=d;return Mh(f,i)&&!u||(clearTimeout(n),!e.check(d))||(n=setTimeout(()=>{let h=Cn(d);h===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(h))},u?0:e.debounce)),a}};var xp=mn.fulfilled.toString();function Nh(t,e){let n=new Set([...e.keywordMatches.map(r=>r.keyword)]),o=[];return n.forEach(r=>{let s=t.keywordMatches.filter(d=>d.keyword===r),i=e.keywordMatches.filter(d=>d.keyword===r),a=i.length-s.length;a<=0||o.push(...i.slice(0,a))}),o}var Sp=t=>e=>n=>o=>{var l;if(o.type!==xp){n(o);return}let r=e.getState().styleSuggestions.list;n(o);let s=e.getState(),i=s.styleSuggestions.list,a=(l=s.conversation)==null?void 0:l.current;if(r===i)return;let d=Nh(r,i);o.type===xp&&d.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:d}})};var Oh=(0,Ds.combineReducers)({assistants:pu,auth:al,conversation:gl,contentTypes:ld,passwordlessToken:fu,entities:Nd,handlingTime:mp,info:_l,input:kl,settings:el,profile:gd,search:zl,styleSuggestions:hp,ui:cc,textSuggestions:jd});function bp(t){return(0,Ds.configureStore)({reducer:Oh,middleware:e=>{var o;let n=e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}).concat(fp()).concat(vp({debounce:200})).concat(yp({debounce:500})).concat(Sp(t.deepdeskAPI));return((o=t.middleware)!=null?o:[]).reduce((r,s)=>r.concat(s),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 r=e.getState(),s=vn("inlineSuggestions")(r);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=r.conversation.current)==null?void 0:a.id,data:{entities:o.payload}});break;case jt.toString():t.logSendMessage(o.payload);break;case fs.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 jt.toString():t.handleAfterSendMessage(o.payload);break;case Ao.toString():t.onUpdateShowTabHint(o.payload);break;case Ms.toString():t.logHandlingTime();break;case wn.toString():t.broadcast(xr,o);break;case Vt.toString():t.broadcast(xr,o);break;case hs.toString():e.dispatch(Vt({source:"assistant",assistantCode:o.payload.code}));break;case"analytics/logEvent/fulfilled":{let l=r.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}=r.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}})),s&&e.dispatch(Tt([]));break}case pr.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(d=r.conversation.current)==null?void 0:d.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Tt.toString():{s&&o.payload.length>0&&e.dispatch(gr(0));break}default:break}return i},Cp=_h;var Tp=require("@reduxjs/toolkit");function fa(t){return t.toISOString().replace("T"," ").replace("Z","")}var Fh=(t,e)=>e.version,wp=(0,Tp.createSelector)([En,ze,cp,Fh],(t,e,n,o)=>{if(!e)return k.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:s}=n;return!r||!s?(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(r),timeStop:fa(s)}});function Ep(t,e){let{text:n,metrics:{numPaste:o,pastes:r,textSuggestions:s}}=t.input,i=n.length;return{source:"agent",clientVersion:e.version,pastes:r,lenTextTotal:i,numPastes:o,suggestions:s}}function ha(t,e){var s;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return ha(o,e);let r=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;return r?ha(r,e):null}function ya(t,e){return ha(t,e)}function kp(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 _s(t){return Hh(t)&&(sn(t)||Zr(t))}var Pp,Qe=new Map,Bh=["bottom","height","left","right","top","width"],Rp=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:Bh.some(n=>t[n]!==e[n]);function Ip(t){var n,o,r;if(t.ownerDocument===document)return[];let e=(r=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?r:null;return e?[e,...Ip(e)]:[]}function Lp(t,e){return!t||!e?null:S(y({},t),{top:t.top+e.top,left:t.left+e.left})}var Fs=!1,Ap=()=>{Fs=!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();Rp(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{let n=e.parentRects?e.parentRects.reduce(Lp,e.rect):e.rect;Rp(n,e.totalRect)&&e.callbacks.forEach(o=>o(n)),e.totalRect=n}),Qe.size===0){Fs=!1;return}Pp=window.requestAnimationFrame(Ap)};function va(t,e){let n=Ip(t),o=[],r=n.map((s,i)=>va(s,a=>{o[i]=a;let d=Qe.get(t);if(!d)return;let l=o.reduce(Lp,d.rect);d.callbacks.forEach(c=>c(l))}));return{observe(s=!0){if(r.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});s&&!Fs&&Ap()},unobserve(){r.forEach(i=>i.unobserve());let s=Qe.get(t);if(s){let i=s.callbacks.indexOf(e);i>=0&&s.callbacks.splice(i,1),s.callbacks.length||Qe.delete(t),Qe.size||(cancelAnimationFrame(Pp),Fs=!1)}}}}var Mp,Ze=new Map,Np=()=>{Ze.forEach((t,e)=>{if(!e.isConnected){Ze.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,r=o>n;t.visible!==r&&(t.visible=r,t.callbacks.forEach(s=>s(t.visible)))}),Ze.size!==0&&(Mp=window.requestAnimationFrame(Np))};function Op(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&&Np()},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(Mp)}}}}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 qn(t){return Number.parseFloat(t)}function Hs(t){return Math.round(t*1e6)}function Dp(t){return t/1e6}function ba(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,r=qn(t.width),s=qn(t.borderLeftWidth),i=qn(t.borderRightWidth),a=qn(t.paddingRight),d=Dp(Hs(r)-Hs(s)-Hs(i)),l=Dp(Hs(o));if(d-l>2){let c=d-l;n.style.paddingRight=`${a+c}px`}}function qo(t,e={}){var c,p;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),r=!0,s=()=>{n.scrollTop=t.scrollTop};Sa(o,n,xa),ba(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",s));let i=Op(t,()=>{Sa(o,n,xa),ba(o,t,n),s(),setTimeout(s,0)}),a,d=!0,l=va(t,u=>{if(u===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),u.height===0&&u.width===0){if(r===!0)return;e.onHide&&e.onHide(),n.style.display="none",r=!0;return}if(Sa(o,n,xa),ba(o,t,n),s(),e.placement==="below"&&n.classList.add("below"),n.style.top=`${u.top}px`,n.style.left=`${u.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-u.top,T=u.top+u.height+-(f.top+f.height-h);n.style.clipPath=`inset(${b}px 0px ${T}px 0px)`}r&&(n.style.display="block",e.onShow&&e.onShow(),r=!1)});return e.appendTo?e.appendTo.appendChild(n):(p=t.parentElement)==null||p.appendChild(n),l.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",s),l.unobserve(),i.unobserve(),n.remove()}]}var _p=(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 Fp(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 Bs(t,e,n=100){let o=Fp(t);e({isVisible:o});let r=setInterval(()=>{let s=Fp(t);s!==o&&(o=s,e({isVisible:o}))},n);return()=>{clearTimeout(r)}}var Xo=class extends Error{};function Kh(){let t,e;return{promise:new Promise((o,r)=>{t=o,e=r}),resolve:t,reject:e}}var Us=class{constructor(){this.queues={}}push(e,n){let o=()=>{let s=this.queues[e][1];s?(this.queues[e]=[s.promise,null],s.resolve()):delete this.queues[e]};if(!this.queues[e]){let s=n().finally(o);return this.queues[e]=[s,null],s}this.queues[e][1]&&this.queues[e][1].reject(new Xo("Queued async function is outdated"));let r=Kh();return this.queues[e][1]=r,r.promise.then(()=>n().finally(o))}};var zh={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},Hp=(t,e)=>{var r,s,i;if(!((i=(s=(r=t.uiConfig)==null?void 0:r.widget)==null?void 0:s.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 Ks=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(r=>r(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 Bp={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 Up=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"),Kp=({onClose:t,onSave:e,id:n,error:o})=>{let[r,s]=(0,_t.useState)(""),[i,a]=(0,_t.useState)(!1),[d,l]=(0,_t.useState)(!1),c=x("Nickname",Bp),p=_t.default.useRef(null),u=(0,Up.useSelector)(b=>b.info.showNicknameDialog),f=R(Ca),m=E("adminUrl");(0,_t.useEffect)(()=>{o&&a(!0)},[o]);let g=()=>{if(!p.current)return;r.trim()?p.current.setCustomValidity(""):p.current.setCustomValidity(f("nicknameDialogError")),p.current.reportValidity()},h=b=>{b.preventDefault();let T=r.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:u,"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:r,onChange:b=>{l(new RegExp("\\p{Extended_Pictographic}","u").test(b.target.value)),s(b.target.value)},onBlur:g,ref:p}),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:!r.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(r),children:f("nicknameDialogContinueButton")})})]})]})]})};var H=require("react/jsx-runtime");var zp=_p("showTabHint",!0),Xn=class Xn{constructor({deepdeskUrl:e,version:n=Xn.version||"unknown",locale:o="en-US",token:r,fetch:s,productName:i,createCustomChannel:a,websocketClient:d=Ks}){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 Us;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=e.replace(/\/api$/,"");this.deepdeskApi=new yt(l,{token:r,fetch:s}),this.version=n,this.instanceId=Xn.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Cp({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=>zp.update(m),sendEvent:(m,g)=>this.deepdeskApi.sendEvent(m,g)})]};this.store=bp(c),this.broadcastEvents=new ip({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(Ao(zp.value())),this.store.dispatch(ar({locale:o,adminUrl:l,productName:i}));let p=[],u=m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(uu(m))};this.hasConversation()?g():p.push(g)};this.ws.on("assistants::direct_response",u),this.ws.on("assistants::user_notification",u),this.ws.on("assistants::response_chunk",m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(cu(m))};this.hasConversation()?g():p.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():p.push(g)});let f=this.whenConversationLoaded(()=>{var m;this.broadcastEvents.setExternalId((m=this.state.conversation.current)==null?void 0:m.externalId),p.forEach(g=>g()),p.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),p.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(Xs({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(dr(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(cr({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(Js(S(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return v(this,null,function*(){yield this.store.dispatch(Qs(e))})}updateConversation(e){return v(this,null,function*(){return(yield this.store.dispatch(ur(e))).payload})}resetConversation(){this.store.dispatch(J()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(ar(e))}setVisitorInfo(e){this.store.dispatch(Ml(e))}setCustomData(e){this.store.dispatch(Nl(e))}setAgentInfo(e,n){return v(this,null,function*(){var r;yield this.store.dispatch(no(y(y({},e),n))),(r=this.state.info.agentInfo)!=null&&r.agentNickname||this.broadcastEvents.send(vr,{showNicknameDialog:!0})})}setAgentSettings(e){return v(this,null,function*(){yield this.store.dispatch(Ys(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(mr({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:r,showCuesInWidget:s=!0,includeMetadata:i}=n||{},a=yield this.store.dispatch(Xe({assistantCode:e,transcript:r,includeMetadata:i,input:o,skipState:!s}));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 r=Hp(o,e);yield Promise.all(r.map(s=>this.queues.push(s,()=>v(this,null,function*(){yield this.evaluateAssistant(s,y({includeMetadata:!0},n))})).catch(i=>{if(i instanceof Xo){k.warn(`Queued assistant "${s}" was outdated and dropped`);return}throw i})))})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:s,selection:i}=this.state.input,{inlineSuggestions:a,showTextSuggestions:d,suggestionsPlacement:l}=this.settings,c=l==="inline"||l==="below"?"below":"above",p=r.length>0;if(this.store.dispatch(xl(Zs(e))),!$e(this.state)||e.key!=="Tab"&&!d)return;let u=()=>{n||!p||i&&(e.shiftKey||(this.store.dispatch(Cl()),e.preventDefault()))},f=()=>{n||!p||a&&s<=0||i&&(e.shiftKey||(this.store.dispatch(Tl()),e.preventDefault()))};switch(e.key){case"ArrowUp":c==="below"?f():u();break;case"ArrowDown":{c==="below"?u():f();break}case"Escape":{n||(this.store.dispatch(gr(-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(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(pp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(Ms()))}logSendMessage(e){let n=Ep(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=wp(this.state,{version:this.version});e&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:e}),this.store.dispatch(gp()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch(jt((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(El()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(r=>{try{r(n)}catch(s){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.error(s)}})}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}setPlatformVariables(e){this.store.dispatch(Ol(e))}whenConversationLoaded(e){let n=s=>{var i;return(i=s.conversation.current)==null?void 0:i.id},o=()=>this.loadProfileConfig().then(()=>e());return n(this.state)&&o(),this.subscribe(n,s=>{s&&o()})}overlayContainerFactory(e,n,o,r){let[s,i]=qo(n,o);return s.setAttribute("translate","no"),s.dataset.testid=e,r&&s.classList.add(r),[s,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 r=document.createElement("div");r.style.display="none",r.style.position="absolute",r.style.height="0px",r.style.width="0px",r.style.backgroundColor="red",o.appendChild(r);let s=(a=e.ownerDocument.defaultView)==null?void 0:a.frameElement,i=s?s.ownerDocument.defaultView:null;if(s&&(i===window||(i==null?void 0:i.parent)===window)){let[d,l]=qo(s,{appendTo:document.body,onMoveStart:()=>{r.style.display="none"}});d.dataset.testid=n,d.style.zIndex="2",d.appendChild(o),this.unmountHandlers.push(()=>{l()})}else document.body.appendChild(o);return r}createContainer(e,n=document.body){let o=window.getComputedStyle(n),r=document.createElement("div");return rn(r),r.dataset.testid=e,r.style.color=o.color,r.style.fontSize=o.fontSize,r.style.fontFamily=o.fontFamily,r.style.fontVariant=o.fontVariant,r.setAttribute("translate","no"),n.appendChild(r),r}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,n),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(!_s(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let u=n,{customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i,inputMediator:a}=u,d=M(u,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i};this.configure(d),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),rn(e),this.inputMediator=a||(sn(e)?new cn(e):new dn(e)),this.inputMediator.on("change",({plainText:f,rawHTML:m})=>{this.store.dispatch(mr({text:f,html:m}))}),this.inputMediator.on("keyup",f=>{this.store.dispatch(Sl(Zs(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(fr(f))},500):this.store.dispatch(fr(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(Gr(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Gr(!0))}),this.renderSuggestions(e,l),this.subscribe(vn("inlineSuggestions"),()=>{this.renderSuggestions(e,l)}),this.subscribe(vn("suggestionsPlacement"),()=>{this.renderSuggestions(e,l)});let p=this.renderOverlays(n);this.unmountHandlers.push(()=>{p.unmount()}),this.store.dispatch(mr({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(fr(this.inputMediator.getSelection())),this.store.dispatch(Gr(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),r=null,s=a=>{r=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)(Kp,{id:"deepdesk-nickname-dialog",error:r,onSave:a=>v(this,null,function*(){try{yield this.store.dispatch(Ll({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(vr,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(d){k.error("Error setting agent nickname",d),s("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 r=e(this.store.getState());r!==o&&(o=r,n(o))})}unmount(){var e,n,o,r,s;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.belowSuggestions)==null||o.unmount(),(r=this.floatingMenu)==null||r.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(s=this.inputMediator)==null||s.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,r,s,i;(o=this.floatingMenu)==null||o.unmount(),(r=this.inlineSuggestions)==null||r.unmount(),(s=this.aboveSuggestions)==null||s.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,r=this.createInlineContainer(e,"deepdesk-caret"),s=(0,vt.createRoot)(r);s.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?(r.style.display="block",r.style.top=`${a.top}px`,r.style.left=`${a.left}px`):r.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),s.unmount(),r.remove()}}}renderAboveOrBelowSuggestions(e,n,o){let{customStyles:r,closestScrollSelector:s,appendOverlayTo:i}=n,a=s&&ya(e,s)||void 0,[d,l]=this.overlayContainerFactory("deepdesk-tab-completion",a||e,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),[c,p]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||e,{appendTo:i,placement:o},r==null?void 0:r.suggestionsRootNode),u=(0,vt.createRoot)(d);u.render((0,H.jsx)(at,{store:this.store,customStyles:r,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(ou,{inputElement:e})})}));let f=(0,vt.createRoot)(c);return f.render((0,H.jsx)(at,{store:this.store,customStyles:r,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(Lc,{onLogIn:()=>this.loginViaPopup().catch(m=>k.warn(m.message))})})})),{unmount(){u.unmount(),f.unmount(),l(),p()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:r,appendOverlayTo:s,floatingMenuParent:i}=n,a=r&&ya(e,r)||void 0,[d,l]=this.overlayContainerFactory("floating-menu",a||e,{appendTo:i!=null?i:s},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)(rc,{onLogIn:()=>this.loginViaPopup().catch(p=>k.warn(p.message))})})})),{unmount(){c.unmount(),l()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays"),r=(0,vt.createRoot)(o);return r.render((0,H.jsx)(at,{store:this.store,customStyles:n,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(Qd,{})})})),{unmount(){r.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:r,isEmbedded:s}=n;this.widgetElement=e,this.configure({showImages:r,isEmbedded:s}),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)(ep,{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:r,initialQuestion:s}=o,i=(0,vt.createRoot)(n);return i.render((0,H.jsx)(at,{store:this.store,customStyles:r,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(aa,{children:(0,H.jsxs)(Rs,{assistantCode:e,initialQuestion:s,evaluateKnowledgeAssistFn:Ho,children:[(0,H.jsx)(hn,{children:(0,H.jsx)(Is,{title:o.title,emptyState:o.emptyState})}),(0,H.jsx)(ia,{children:(0,H.jsx)(Ps,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(e){let n=Bs(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){kp(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(ar({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(lr());let r=new MessageChannel,s=r.port1,i=this.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let d=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",p),clearInterval(u)};s.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,r.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 p=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,[r.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(qs(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(qs(g)),o(new Error(g))}o(new Error(f.data.message));break}}});window.addEventListener("message",p);let u=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(Wr()))})}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:ir.includes(o)||this.store.dispatch(He(o))}})}catch(o){this.handleError(o)}})}};Xn.version="19.1.2-beta.0",Xn.count=0;var Jo=Xn;function jh(t){return v(this,null,function*(){var r,s,i;let n=yield((r=t.fetch)!=null?r:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(s=t.mimeType)!=null?s:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function Wp(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 Vp(t,e,n){return v(this,null,function*(){yield new yt(t).authenticateWithKey(e,n)})}function jp(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function $p(o,r){return v(this,arguments,function*(t,e,n={}){var p,u;let{value:s}=t,{start:i,end:a}=(p=n.replace)!=null?p:{start:0,end:s.length},d=`${s.slice(0,i)}${e}${s.slice(a)}`,l=(u=n.selectionAfter)!=null?u:{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 Gp(o,r){return v(this,arguments,function*(t,e,n={}){let s=n.replace?Dt(t,n.replace.start,n.replace.end):$n(t),i,a=()=>{if(n.setRange)return n.setRange(s.cloneRange());s.deleteContents(),i=document.createElement("span"),s.insertNode(i),n.insertBRs!==!1?e.split(`
|
|
11
|
-
`).reverse().forEach((d,l)=>{l>0&&s.insertNode(document.createElement("br")),s.insertNode(document.createTextNode(d))}):s.insertNode(document.createTextNode(e))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let d=n.selectionAfter?Dt(t,n.selectionAfter.start,n.selectionAfter.end):(s.collapse(!1),s),l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(d)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function
|
|
12
|
-
`).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let r={index:0},s=0;for(;r=n.slice(s).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=r[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(r[2])),e.appendChild(document.createTextNode(n.slice(s,s+r.index))),e.appendChild(i),s=s+r.index+r[0].length}e.appendChild(document.createTextNode(n.slice(s)))}),e}function
|
|
10
|
+
`);let m=u?o:0,g=f?Math.min(s,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 op=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(op||{}),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=r=>{n(r)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}handleInteraction(){let e=this.getText(),n=this.getHTML(),o=this.getSelection(),r=this.cachedCaretPosition===null;if(!this.isActive||(e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),e!==this.cachedText?(this.cachedText=e,this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,r=!0,this.emit("selection",o)),!r))return;let s=this.getCaretPosition();Ct(s,this.cachedCaretPosition)||(this.cachedCaretPosition=s,this.emit("caretposition",s))}handleClick(){this.handleInteraction()}handleFocus(){let e=!this.isFocused;this.isFocused=!0,e&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let e=this.isFocused;this.isFocused=!1,e&&this.emit("blur")}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:r}=e;this.isPossibleClearInputAction=Object.values(op).includes(n)||n.toLowerCase()==="z"&&(o||r),this.emit("keydown",e)}handleKeyUp(e){this.handleInteraction(),this.emit("keyup",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var o,r;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((r=e.clipboardData)==null?void 0:r.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()})}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}off(e,n){if(!this.eventListeners[e])return;let o=this.eventListeners[e].indexOf(n);o!==-1&&this.eventListeners[e].splice(o,1)}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function rp(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 r=o.rangeCount>0?o.getRangeAt(0):null;if(!r)return null;let s=this.element.ownerDocument.createRange();return s.setStart(r==null?void 0:r.startContainer,r==null?void 0:r.startOffset),s.setEnd(r==null?void 0:r.endContainer,r==null?void 0:r.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let o=n.getBoundingClientRect();return!rp(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!rp(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&&np(this.element,o.start,o.end))return o;let r=$n(this.element);return r.collapse(!1),$o(this.element,r)}getSelectedText(){let{start:n,end:o}=this.getSelection();return Go(this.element,Dt(this.element,n,o))}listen(){super.listen();let n=new MutationObserver(s=>{var i,a;s.length===2&&s[0].addedNodes.length===1&&((i=s[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=s[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let o=this.element.isContentEditable,r=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>r.disconnect())}};var Ih=["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 sp(t,e){let n="mozInnerScreenX"in window,o=document.createElement("div");o.id="input-textarea-caret-position-mirror-div";let r=o.style,s=window.getComputedStyle(t),i=t.ownerDocument.body;r.whiteSpace="pre-wrap",r.wordWrap="break-word",r.position="absolute",r.visibility="hidden",Ih.forEach(c=>{r[c]=s[c]}),n?t.scrollHeight>Number.parseInt(s.height)&&(r.overflowY="scroll"):r.overflow="hidden",o.textContent=t.value.substring(0,e);let a=document.createElement("span");a.textContent=t.value.substring(e)||".",o.appendChild(a),i.appendChild(o);let d=t.getBoundingClientRect(),l={top:d.top-t.scrollTop+a.offsetTop+Number.parseInt(s.borderTopWidth)+a.offsetHeight,left:d.left-t.scrollLeft+a.offsetLeft+Number.parseInt(s.borderLeftWidth)};return i.removeChild(o),l}var 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 sp(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=n==null?void 0:n.get)==null?void 0:s.call(this.element)},set:s=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,s),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let o=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};function ip(t,e,n){let o=`deepdesk-iframe-${t}`,r=document.getElementById(o);if(r)return r;let s=document.createElement("iframe"),i=new URL(e);return Object.entries(n).forEach(([a,d])=>{i.searchParams.append(a,d)}),s.style.position="absolute",s.style.left="-999em",s.style.width="0px",s.style.height="0px",s.tabIndex=-1,s.id=o,s.title=`iframe-${t}`,s.src=i.toString(),window.document.body.appendChild(s),s}function Lh(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=ip(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=r=>{var i,a;if(r.origin!==this.deepdeskUrl)return;let s=Lh(r.data);typeof s!="object"||s.type!=="event"||s.channel!==e||(k.info("Received broadcast event",this.externalId,r),(a=(i=this.eventMap)[s.name])==null||a.call(i,s.payload))};return n.onMessage(o),n}send(e,n,o){var i,a;k.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let r={type:"event",name:e,payload:n};o!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,n));let s=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage(x(y({},r),{channel:this.externalId}))}cleanup(e=!1){var n,o;(n=this.channel)==null||n.close(),this.channel=void 0,e&&((o=this.defaultChannel)==null||o.close(),this.defaultChannel=void 0)}},ap=ca;function Ah(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function z(t){return Array.isArray(t)?t.map(z):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>x(y({},e),{[Ah(n)]:z(t[n])}),{}):t}function Mh(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function ue(t){return Array.isArray(t)?t.map(ue):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>x(y({},e),{[Mh(n)]:ue(t[n])}),{}):t}var Gn=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var ua=t=>new Promise(e=>{setTimeout(e,t)});var un=class extends Gn{constructor(){super(...arguments);this.name="ClientError"}},ga=class extends Gn{constructor(){super(...arguments);this.name="ServerError"}},pa=new Map;function Nh(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 pn=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,r)=>{let s={isAborted:!1,reject:r},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:p=1,retryDelay:u=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=x(y({credentials:"include"},b),{headers:y({Accept:"application/json","Content-Type":"application/json"},b.headers)});!d&&this.csrfToken&&(T.headers=x(y({},T.headers),{"X-CSRFToken":this.csrfToken})),typeof h=="string"&&(T.headers=x(y({},T.headers),{"X-Deepdesk-API-Version":h}));let C=p,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]=s;let L=()=>v(this,null,function*(){return C--,a(i,T).then(B=>v(this,null,function*(){return g(B)&&!s.isAborted&&C>0?(yield ua(u),L()):B.status===401&&f===!0&&w===!1?(w=!0,yield this.refreshToken(),L()):B})).catch(B=>v(this,null,function*(){if(m(B)&&!s.isAborted&&C>0)return yield ua(u),L();throw B}))});L().then(B=>v(this,null,function*(){let X=yield Nh(B);if(delete this.latestRequestByUrl[i],B.status>=500){r(new ga("Server Error",X));return}if(B.status===401){r(new un("Unauthorized",X));return}if(B.status===403){r(new un("Forbidden",X));return}if(B.status===404){r(new un("Not Found",X));return}if(B.status>=400){r(new un("Bad Request",X));return}l&&pa.set(i,X),o(X)})).catch(B=>{r(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(r){return!1}if(!e){if(!o)return!1;try{yield this.refreshToken();let{is_logged_in:r}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return r}catch(r){return!1}}return n})}refreshToken(){let e=Date.now();return this.lastFailedRefreshAt&&e-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new un("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 lp;(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={}))})(lp||(lp={}));function ma(t){return x(y({},z(t)),{metadata:t.metadata})}var gn=class gn{constructor(e,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new pn(e,{fetch:n.fetch}),this.client.patchFetch(o=>(r,s)=>v(this,null,function*(){let i=yield o(r,s);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return v(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=yield this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(gn.exchangeTokenPromise||(gn.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),gn.exchangeTokenPromise):Promise.resolve()})}createConversation(e){return v(this,null,function*(){var o;yield this.preflight(),k.info(`Creating conversation for session ${e.externalId} and agent ${e.agentId}`);let n=yield this.client.post("/api/v2/conversations",x(y({chat_start_time:new Date().toISOString()},ue(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/",ue(e))})}patchMe(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",ue(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:r=1,retryDelay:s=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:r,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return 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:r=1,retryDelay:s=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:r,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(e,n){return v(this,null,function*(){var s;yield this.preflight();let o=ue(n);n.metadata&&(o.metadata=(s=n.metadata)!=null?s:{});let r=yield this.client.put(`/api/v2/conversations/${e}`,o);return ma(r)})}postMessages(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${e}/messages`,n.map(o=>x(y({},ue(o)),{metadata:o.metadata})))})}sendEvent(e,n){return v(this,null,function*(){yield this.preflight();let a=n,{data:o}=a,r=M(a,["data"]),s=Object.entries(this.latestReceivedDeepdeskVersions).reduce((d,[l,c])=>x(y({},d),{[l]:c}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((d,l)=>(r[l]&&(d[l]=r[l]),d),{});return this.client.post("/api/v2/events",ue(x(y(y({},s),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/",ue(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(r){return v(this,arguments,function*(e,n={},o){if(yield this.preflight(),o==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${e}/recommend/${o}`,ue(n),{abortLatest:!0})).map(i=>x(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`,ue(n),{abortLatest:!0})).map(r=>({score:1,source:r.source,sourceText:r.source_text,text:r.label,trainingJobs:r.training_jobs,searchKeywords:r.search_keywords,type:r.source})).filter((r,s,i)=>s===i.findIndex(a=>a.text===r.text))})}getPinnedMessages(e){return v(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return z(n).map(o=>x(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",ue(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`,ue(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 r=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()}`,s=yield this.client.post(r,{input:(i=n==null?void 0:n.input)!=null?i:{},conversation:n==null?void 0:n.transcript});return z(s)})}createAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n}=e,o=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return z(o)})}postMessageToAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:r}=e,s=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:r,role:"user"});return z(s)})}translateMessages(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",ue(e));return z(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let r=o.toLowerCase(),s=r.match(Xa);if(!n||!s)return;let i=s[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&k.warn(`Overwritten Version header ${r}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};gn.exchangeTokenPromise=null;var yt=gn;var Ds=require("@reduxjs/toolkit");var cp=require("@reduxjs/toolkit");var dp={startTime:null,stopTime:null},up=t=>t.handlingTime,pp=(0,cp.createSlice)({name:"handlingTime",initialState:dp,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,()=>dp)}}),{handlingTimeStart:gp,handlingTimeStop:Ms,handlingTimeReset:mp}=pp.actions,fp=pp.reducer;var hp=(t={})=>{let e=y({onAuthError:Sn(!1)},t);return n=>o=>r=>("error"in r&&r.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(r))};var Os=require("@reduxjs/toolkit");var Ns={list:{keywordMatches:[]},fetchState:"idle"};var mn=(0,Os.createAsyncThunk)("styleSuggestions/getAll",(n,o)=>v(null,[n,o],function*({text:t},e){var d;let{deepdeskAPI:r}=e.extra,s=e.getState(),{showStyleSuggestions:i}=s.settings,a=(d=s.conversation.current)==null?void 0:d.profileCode;if(!i)return Ns.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return r.getStyleSuggestions({profileCode:a,message:t})})),Oh=(0,Os.createSlice)({name:"styleSuggestions",initialState:Ns,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=Ns.list}).addCase(J,()=>Ns)}}),yp=Oh.reducer;var vp=(t={})=>{let e,n=!0,o=y({getStyleSuggestions:mn,debounce:500},t);return r=>s=>i=>{var f;let a=r.getState().input.text,d=s(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return d;let{showStyleSuggestions:c}=l.settings;if(!((f=l.conversation.current)==null?void 0:f.id)||!c)return d;let{text:u}=l.input;return u===a&&!n||(clearTimeout(e),u==="")||(e=setTimeout(()=>{n=!1,r.dispatch(o.getStyleSuggestions({text:u}))},t.debounce)),d}};function Dh(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var xp=(t={})=>{let e=y({getTextSuggestions:He,getAutocompleteSuggestions:Io,debounce:200,check:$e},t),n;return o=>r=>s=>{var g;let{input:i}=o.getState(),a=r(s),d=o.getState();if(d.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:c}=d.settings,p=(g=d.conversation.current)==null?void 0:g.id,u=s.type===Wr.toString();if(!p||!l&&!c)return a;let{input:f}=d;return Dh(f,i)&&!u||(clearTimeout(n),!e.check(d))||(n=setTimeout(()=>{let h=Cn(d);h===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(h))},u?0:e.debounce)),a}};var Sp=mn.fulfilled.toString();function _h(t,e){let n=new Set([...e.keywordMatches.map(r=>r.keyword)]),o=[];return n.forEach(r=>{let s=t.keywordMatches.filter(d=>d.keyword===r),i=e.keywordMatches.filter(d=>d.keyword===r),a=i.length-s.length;a<=0||o.push(...i.slice(0,a))}),o}var bp=t=>e=>n=>o=>{var l;if(o.type!==Sp){n(o);return}let r=e.getState().styleSuggestions.list;n(o);let s=e.getState(),i=s.styleSuggestions.list,a=(l=s.conversation)==null?void 0:l.current;if(r===i)return;let d=_h(r,i);o.type===Sp&&d.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:d}})};var Fh=(0,Ds.combineReducers)({assistants:pu,auth:al,conversation:gl,contentTypes:ld,passwordlessToken:fu,entities:Nd,handlingTime:fp,info:_l,input:kl,settings:el,profile:gd,search:zl,styleSuggestions:yp,ui:cc,textSuggestions:jd});function Cp(t){return(0,Ds.configureStore)({reducer:Fh,middleware:e=>{var o;let n=e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}).concat(hp()).concat(xp({debounce:200})).concat(vp({debounce:500})).concat(bp(t.deepdeskAPI));return((o=t.middleware)!=null?o:[]).reduce((r,s)=>r.concat(s),n)},preloadedState:t.preloadedState})}var Hh=t=>{var e,n;return(n=(e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())!=null?n:"unknown"},Bh=t=>e=>n=>o=>{var a,d;let r=e.getState(),s=vn("inlineSuggestions")(r);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=r.conversation.current)==null?void 0:a.id,data:{entities:o.payload}});break;case jt.toString():t.logSendMessage(o.payload);break;case fs.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 jt.toString():t.handleAfterSendMessage(o.payload);break;case Ao.toString():t.onUpdateShowTabHint(o.payload);break;case Ms.toString():t.logHandlingTime();break;case wn.toString():t.broadcast(xr,o);break;case Vt.toString():t.broadcast(xr,o);break;case hs.toString():e.dispatch(Vt({source:"assistant",assistantCode:o.payload.code}));break;case"analytics/logEvent/fulfilled":{let l=r.assistants.cues.find(c=>c.code===o.meta.arg.data.assistantCode);t.emit("event",x(y({},o.meta.arg),{cue:l}));break}case ye.toString():{let{start:l,end:c}=r.input.selection;t.emit("select-suggestion",x(y({type:Hh(o.payload.suggestion)},o.payload),{replace:o.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}})),s&&e.dispatch(Tt([]));break}case pr.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(d=r.conversation.current)==null?void 0:d.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Tt.toString():{s&&o.payload.length>0&&e.dispatch(gr(0));break}default:break}return i},Tp=Bh;var wp=require("@reduxjs/toolkit");function fa(t){return t.toISOString().replace("T"," ").replace("Z","")}var Uh=(t,e)=>e.version,Ep=(0,wp.createSelector)([En,ze,up,Uh],(t,e,n,o)=>{if(!e)return k.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:s}=n;return!r||!s?(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(r),timeStop:fa(s)}});function kp(t,e){let{text:n,metrics:{numPaste:o,pastes:r,textSuggestions:s}}=t.input,i=n.length;return{source:"agent",clientVersion:e.version,pastes:r,lenTextTotal:i,numPastes:o,suggestions:s}}function ha(t,e){var s;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return ha(o,e);let r=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;return r?ha(r,e):null}function ya(t,e){return ha(t,e)}function Rp(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Kh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function _s(t){return Kh(t)&&(sn(t)||Zr(t))}var Ip,Qe=new Map,zh=["bottom","height","left","right","top","width"],Pp=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:zh.some(n=>t[n]!==e[n]);function Lp(t){var n,o,r;if(t.ownerDocument===document)return[];let e=(r=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?r:null;return e?[e,...Lp(e)]:[]}function Ap(t,e){return!t||!e?null:x(y({},t),{top:t.top+e.top,left:t.left+e.left})}var Fs=!1,Mp=()=>{Fs=!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();Pp(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{let n=e.parentRects?e.parentRects.reduce(Ap,e.rect):e.rect;Pp(n,e.totalRect)&&e.callbacks.forEach(o=>o(n)),e.totalRect=n}),Qe.size===0){Fs=!1;return}Ip=window.requestAnimationFrame(Mp)};function va(t,e){let n=Lp(t),o=[],r=n.map((s,i)=>va(s,a=>{o[i]=a;let d=Qe.get(t);if(!d)return;let l=o.reduce(Ap,d.rect);d.callbacks.forEach(c=>c(l))}));return{observe(s=!0){if(r.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});s&&!Fs&&Mp()},unobserve(){r.forEach(i=>i.unobserve());let s=Qe.get(t);if(s){let i=s.callbacks.indexOf(e);i>=0&&s.callbacks.splice(i,1),s.callbacks.length||Qe.delete(t),Qe.size||(cancelAnimationFrame(Ip),Fs=!1)}}}}var Np,Ze=new Map,Op=()=>{Ze.forEach((t,e)=>{if(!e.isConnected){Ze.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,r=o>n;t.visible!==r&&(t.visible=r,t.callbacks.forEach(s=>s(t.visible)))}),Ze.size!==0&&(Np=window.requestAnimationFrame(Op))};function Dp(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&&Op()},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(Np)}}}}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 qn(t){return Number.parseFloat(t)}function Hs(t){return Math.round(t*1e6)}function _p(t){return t/1e6}function ba(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,r=qn(t.width),s=qn(t.borderLeftWidth),i=qn(t.borderRightWidth),a=qn(t.paddingRight),d=_p(Hs(r)-Hs(s)-Hs(i)),l=_p(Hs(o));if(d-l>2){let c=d-l;n.style.paddingRight=`${a+c}px`}}function qo(t,e={}){var c,p;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),r=!0,s=()=>{n.scrollTop=t.scrollTop};Sa(o,n,xa),ba(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",s));let i=Dp(t,()=>{Sa(o,n,xa),ba(o,t,n),s(),setTimeout(s,0)}),a,d=!0,l=va(t,u=>{if(u===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),u.height===0&&u.width===0){if(r===!0)return;e.onHide&&e.onHide(),n.style.display="none",r=!0;return}if(Sa(o,n,xa),ba(o,t,n),s(),e.placement==="below"&&n.classList.add("below"),n.style.top=`${u.top}px`,n.style.left=`${u.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-u.top,T=u.top+u.height+-(f.top+f.height-h);n.style.clipPath=`inset(${b}px 0px ${T}px 0px)`}r&&(n.style.display="block",e.onShow&&e.onShow(),r=!1)});return e.appendTo?e.appendTo.appendChild(n):(p=t.parentElement)==null||p.appendChild(n),l.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",s),l.unobserve(),i.unobserve(),n.remove()}]}var Fp=(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 Wh(t){return t.offsetParent!==null}function Hp(t){if(!Wh(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 Bs(t,e,n=100){let o=Hp(t);e({isVisible:o});let r=setInterval(()=>{let s=Hp(t);s!==o&&(o=s,e({isVisible:o}))},n);return()=>{clearTimeout(r)}}var Xo=class extends Error{};function Vh(){let t,e;return{promise:new Promise((o,r)=>{t=o,e=r}),resolve:t,reject:e}}var Us=class{constructor(){this.queues={}}push(e,n){let o=()=>{let s=this.queues[e][1];s?(this.queues[e]=[s.promise,null],s.resolve()):delete this.queues[e]};if(!this.queues[e]){let s=n().finally(o);return this.queues[e]=[s,null],s}this.queues[e][1]&&this.queues[e][1].reject(new Xo("Queued async function is outdated"));let r=Vh();return this.queues[e][1]=r,r.promise.then(()=>n().finally(o))}};var jh={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},Bp=(t,e)=>{var r,s,i;if(!((i=(s=(r=t.uiConfig)==null?void 0:r.widget)==null?void 0:s.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[jh[e]];return o&&o.length>0?o.map(a=>a.code):(k.warn(`No assistant set in profile for conversation event "${e}"`),[])};var Ks=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(r=>r(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 Up={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 Kp=require("react-redux");var Ca={};Y(Ca,{enUS:()=>$h,nlNL:()=>Gh});var $h={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."}]},Gh={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"),zp=({onClose:t,onSave:e,id:n,error:o})=>{let[r,s]=(0,_t.useState)(""),[i,a]=(0,_t.useState)(!1),[d,l]=(0,_t.useState)(!1),c=S("Nickname",Up),p=_t.default.useRef(null),u=(0,Kp.useSelector)(b=>b.info.showNicknameDialog),f=R(Ca),m=E("adminUrl");(0,_t.useEffect)(()=>{o&&a(!0)},[o]);let g=()=>{if(!p.current)return;r.trim()?p.current.setCustomValidity(""):p.current.setCustomValidity(f("nicknameDialogError")),p.current.reportValidity()},h=b=>{b.preventDefault();let T=r.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:u,"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:r,onChange:b=>{l(new RegExp("\\p{Extended_Pictographic}","u").test(b.target.value)),s(b.target.value)},onBlur:g,ref:p}),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:!r.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(r),children:f("nicknameDialogContinueButton")})})]})]})]})};var H=require("react/jsx-runtime");var Wp=Fp("showTabHint",!0),Xn=class Xn{constructor({deepdeskUrl:e,version:n=Xn.version||"unknown",locale:o="en-US",token:r,fetch:s,productName:i,createCustomChannel:a,websocketClient:d=Ks}){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 Us;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=e.replace(/\/api$/,"");this.deepdeskApi=new yt(l,{token:r,fetch:s}),this.version=n,this.instanceId=Xn.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Tp({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=>Wp.update(m),sendEvent:(m,g)=>this.deepdeskApi.sendEvent(m,g)})]};this.store=Cp(c),this.broadcastEvents=new ap({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(Ao(Wp.value())),this.store.dispatch(ar({locale:o,adminUrl:l,productName:i}));let p=[],u=m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(uu(m))};this.hasConversation()?g():p.push(g)};this.ws.on("assistants::direct_response",u),this.ws.on("assistants::user_notification",u),this.ws.on("assistants::response_chunk",m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(cu(m))};this.hasConversation()?g():p.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():p.push(g)});let f=this.whenConversationLoaded(()=>{var m;this.broadcastEvents.setExternalId((m=this.state.conversation.current)==null?void 0:m.externalId),p.forEach(g=>g()),p.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),p.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(Xs({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(dr(x(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(cr({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(Js(x(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return v(this,null,function*(){yield this.store.dispatch(Qs(e))})}updateConversation(e){return v(this,null,function*(){return(yield this.store.dispatch(ur(e))).payload})}resetConversation(){this.store.dispatch(J()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(ar(e))}setVisitorInfo(e){this.store.dispatch(Ml(e))}setCustomData(e){this.store.dispatch(Nl(e))}setAgentInfo(e,n){return v(this,null,function*(){var r;yield this.store.dispatch(no(y(y({},e),n))),(r=this.state.info.agentInfo)!=null&&r.agentNickname||this.broadcastEvents.send(vr,{showNicknameDialog:!0})})}setAgentSettings(e){return v(this,null,function*(){yield this.store.dispatch(Ys(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(mr({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:r,showCuesInWidget:s=!0,includeMetadata:i}=n||{},a=yield this.store.dispatch(Xe({assistantCode:e,transcript:r,includeMetadata:i,input:o,skipState:!s}));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 r=Bp(o,e);yield Promise.all(r.map(s=>this.queues.push(s,()=>v(this,null,function*(){yield this.evaluateAssistant(s,y({includeMetadata:!0},n))})).catch(i=>{if(i instanceof Xo){k.warn(`Queued assistant "${s}" was outdated and dropped`);return}throw i})))})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:s,selection:i}=this.state.input,{inlineSuggestions:a,showTextSuggestions:d,suggestionsPlacement:l}=this.settings,c=l==="inline"||l==="below"?"below":"above",p=r.length>0;if(this.store.dispatch(xl(Zs(e))),!$e(this.state)||e.key!=="Tab"&&!d)return;let u=()=>{n||!p||i&&(e.shiftKey||(this.store.dispatch(Cl()),e.preventDefault()))},f=()=>{n||!p||a&&s<=0||i&&(e.shiftKey||(this.store.dispatch(Tl()),e.preventDefault()))};switch(e.key){case"ArrowUp":c==="below"?f():u();break;case"ArrowDown":{c==="below"?u():f();break}case"Escape":{n||(this.store.dispatch(gr(-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(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(gp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(Ms()))}logSendMessage(e){let n=kp(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=Ep(this.state,{version:this.version});e&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:e}),this.store.dispatch(mp()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch(jt((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(El()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(r=>{try{r(n)}catch(s){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.error(s)}})}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}setPlatformVariables(e){this.store.dispatch(Ol(e))}whenConversationLoaded(e){let n=s=>{var i;return(i=s.conversation.current)==null?void 0:i.id},o=()=>this.loadProfileConfig().then(()=>e());return n(this.state)&&o(),this.subscribe(n,s=>{s&&o()})}overlayContainerFactory(e,n,o,r){let[s,i]=qo(n,o);return s.setAttribute("translate","no"),s.dataset.testid=e,r&&s.classList.add(r),[s,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 r=document.createElement("div");r.style.display="none",r.style.position="absolute",r.style.height="0px",r.style.width="0px",r.style.backgroundColor="red",o.appendChild(r);let s=(a=e.ownerDocument.defaultView)==null?void 0:a.frameElement,i=s?s.ownerDocument.defaultView:null;if(s&&(i===window||(i==null?void 0:i.parent)===window)){let[d,l]=qo(s,{appendTo:document.body,onMoveStart:()=>{r.style.display="none"}});d.dataset.testid=n,d.style.zIndex="2",d.appendChild(o),this.unmountHandlers.push(()=>{l()})}else document.body.appendChild(o);return r}createContainer(e,n=document.body){let o=window.getComputedStyle(n),r=document.createElement("div");return rn(r),r.dataset.testid=e,r.style.color=o.color,r.style.fontSize=o.fontSize,r.style.fontFamily=o.fontFamily,r.style.fontVariant=o.fontVariant,r.setAttribute("translate","no"),n.appendChild(r),r}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,n),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(!_s(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let u=n,{customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i,inputMediator:a}=u,d=M(u,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i};this.configure(d),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),rn(e),this.inputMediator=a||(sn(e)?new cn(e):new dn(e)),this.inputMediator.on("change",({plainText:f,rawHTML:m})=>{this.store.dispatch(mr({text:f,html:m}))}),this.inputMediator.on("keyup",f=>{this.store.dispatch(Sl(Zs(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(fr(f))},500):this.store.dispatch(fr(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(Gr(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Gr(!0))}),this.renderSuggestions(e,l),this.subscribe(vn("inlineSuggestions"),()=>{this.renderSuggestions(e,l)}),this.subscribe(vn("suggestionsPlacement"),()=>{this.renderSuggestions(e,l)});let p=this.renderOverlays(n);this.unmountHandlers.push(()=>{p.unmount()}),this.store.dispatch(mr({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(fr(this.inputMediator.getSelection())),this.store.dispatch(Gr(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),r=null,s=a=>{r=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)(zp,{id:"deepdesk-nickname-dialog",error:r,onSave:a=>v(this,null,function*(){try{yield this.store.dispatch(Ll({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(vr,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(d){k.error("Error setting agent nickname",d),s("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 r=e(this.store.getState());r!==o&&(o=r,n(o))})}unmount(){var e,n,o,r,s;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.belowSuggestions)==null||o.unmount(),(r=this.floatingMenu)==null||r.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(s=this.inputMediator)==null||s.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,r,s,i;(o=this.floatingMenu)==null||o.unmount(),(r=this.inlineSuggestions)==null||r.unmount(),(s=this.aboveSuggestions)==null||s.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,r=this.createInlineContainer(e,"deepdesk-caret"),s=(0,vt.createRoot)(r);s.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?(r.style.display="block",r.style.top=`${a.top}px`,r.style.left=`${a.left}px`):r.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),s.unmount(),r.remove()}}}renderAboveOrBelowSuggestions(e,n,o){let{customStyles:r,closestScrollSelector:s,appendOverlayTo:i}=n,a=s&&ya(e,s)||void 0,[d,l]=this.overlayContainerFactory("deepdesk-tab-completion",a||e,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),[c,p]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||e,{appendTo:i,placement:o},r==null?void 0:r.suggestionsRootNode),u=(0,vt.createRoot)(d);u.render((0,H.jsx)(at,{store:this.store,customStyles:r,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(ou,{inputElement:e})})}));let f=(0,vt.createRoot)(c);return f.render((0,H.jsx)(at,{store:this.store,customStyles:r,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(Lc,{onLogIn:()=>this.loginViaPopup().catch(m=>k.warn(m.message))})})})),{unmount(){u.unmount(),f.unmount(),l(),p()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:r,appendOverlayTo:s,floatingMenuParent:i}=n,a=r&&ya(e,r)||void 0,[d,l]=this.overlayContainerFactory("floating-menu",a||e,{appendTo:i!=null?i:s},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)(rc,{onLogIn:()=>this.loginViaPopup().catch(p=>k.warn(p.message))})})})),{unmount(){c.unmount(),l()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays"),r=(0,vt.createRoot)(o);return r.render((0,H.jsx)(at,{store:this.store,customStyles:n,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(Qd,{})})})),{unmount(){r.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:r,isEmbedded:s}=n;this.widgetElement=e,this.configure({showImages:r,isEmbedded:s}),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)(tp,{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:r,initialQuestion:s}=o,i=(0,vt.createRoot)(n);return i.render((0,H.jsx)(at,{store:this.store,customStyles:r,children:(0,H.jsx)(ot,{broadcastEvents:this.broadcastEvents,children:(0,H.jsx)(aa,{children:(0,H.jsxs)(Rs,{assistantCode:e,initialQuestion:s,evaluateKnowledgeAssistFn:Ho,children:[(0,H.jsx)(hn,{children:(0,H.jsx)(Is,{title:o.title,emptyState:o.emptyState})}),(0,H.jsx)(ia,{children:(0,H.jsx)(Ps,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(e){let n=Bs(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Rp(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(ar({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(lr());let r=new MessageChannel,s=r.port1,i=this.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let d=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",p),clearInterval(u)};s.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,r.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 p=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,[r.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(qs(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(qs(g)),o(new Error(g))}o(new Error(f.data.message));break}}});window.addEventListener("message",p);let u=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(Wr()))})}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:ir.includes(o)||this.store.dispatch(He(o))}})}catch(o){this.handleError(o)}})}};Xn.version="19.1.2-beta.1",Xn.count=0;var Jo=Xn;function qh(t){return v(this,null,function*(){var r,s,i;let n=yield((r=t.fetch)!=null?r:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(s=t.mimeType)!=null?s:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function Vp(t,e){return v(this,null,function*(){let n=yield qh(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 jp(t,e,n){return v(this,null,function*(){yield new yt(t).authenticateWithKey(e,n)})}function $p(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Gp(o,r){return v(this,arguments,function*(t,e,n={}){var p,u;let{value:s}=t,{start:i,end:a}=(p=n.replace)!=null?p:{start:0,end:s.length},d=`${s.slice(0,i)}${e}${s.slice(a)}`,l=(u=n.selectionAfter)!=null?u:{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 qp(o,r){return v(this,arguments,function*(t,e,n={}){let s=n.replace?Dt(t,n.replace.start,n.replace.end):$n(t),i,a=()=>{if(n.setRange)return n.setRange(s.cloneRange());s.deleteContents(),i=document.createElement("span"),s.insertNode(i),n.insertBRs!==!1?e.split(`
|
|
11
|
+
`).reverse().forEach((d,l)=>{l>0&&s.insertNode(document.createElement("br")),s.insertNode(document.createTextNode(d))}):s.insertNode(document.createTextNode(e))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let d=n.selectionAfter?Dt(t,n.selectionAfter.start,n.selectionAfter.end):(s.collapse(!1),s),l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(d)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function Xh(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 Jh(t){let e=document.createDocumentFragment();return t.split(`
|
|
12
|
+
`).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let r={index:0},s=0;for(;r=n.slice(s).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=r[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(r[2])),e.appendChild(document.createTextNode(n.slice(s,s+r.index))),e.appendChild(i),s=s+r.index+r[0].length}e.appendChild(document.createTextNode(n.slice(s)))}),e}function Xp(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):Xp(n,e)}function Jp(r,s){return v(this,arguments,function*(t,e,{isBlock:n,isHTML:o}={}){let i;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let a=()=>{var u;let d=(u=t.ownerDocument.defaultView)!=null?u: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 p=o?Xh(e):Jh(e);n?Xp(c.startContainer,p):(c.insertNode(p),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});
|