@deepdesk/deepdesk-sdk 10.12.1-beta.0 → 10.12.1-beta.10
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/dialogs.css +1 -1
- package/dist/index.cjs.js +7 -7
- package/dist/index.d.mts +112 -140
- package/dist/index.d.ts +112 -140
- package/dist/index.esm.js +7 -7
- package/dist/index.iife.js +14 -14
- package/input.css +1 -1
- package/package.json +1 -1
- package/styles/index.js +1 -1
- package/styles.css +1 -1
- package/widget.css +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var Id=Object.defineProperty;var q=(t,e)=>{for(var o in e)Id(t,o,{get:e[o],enumerable:!0})};import ds from"classnames";import Md,{createContext as Nd,useContext as us,useEffect as Od,useState as Dd}from"react";import Rd,{useContext as Pd}from"react";import Ad from"classnames";var zt=Rd.createContext({});function y(t,e){let{debug:o,...n}=Pd(zt),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:Ad(a,l,o?`${t}__${i}`:!1)}},{}):e}var ci={root:"_root_vr71j_1"};import{jsx as Io,jsxs as Ld}from"react/jsx-runtime";var Ro=()=>Ld("svg",{className:ci.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[Io("defs",{children:Io("style",{children:".cls-1 { fill: #b3b3b3; }"})}),Io("title",{children:"Failed loading image"}),Io("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 ps={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};import{jsx as dt}from"react/jsx-runtime";var Po=Nd(ps),Hd=({title:t,src:e})=>{let o=us(Po),[n,s]=Dd(!1);return Od(()=>{s(!1)},[e]),dt("div",{className:o.imageWrapper,children:e&&!n?dt("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):dt(Ro,{})})},Bd=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=us(Po);return dt("div",{className:ds(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Fd=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=us(Po);return Md.createElement(t,{className:ds(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Ao=({children:t})=>{let e=y("Card",ps);return dt("div",{className:ds(e.root),children:dt(Po.Provider,{value:e,children:t})})};Ao.Image=Hd;Ao.Content=Bd;Ao.Title=Fd;var F=Ao;import Kd from"classnames";var pi={root:"_root_cq1yq_1"};import{jsx as jd}from"react/jsx-runtime";var Ud={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},zd=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",pi);return jd("span",{"data-key":Ud[e],className:Kd(t,n.root),...o})},gs=zd;import Vd from"classnames";var di={root:"_root_4a08n_1"};import{jsx as Wd}from"react/jsx-runtime";var qd=({className:t,children:e,...o})=>{let n=y("Label",di);return Wd("span",{...o,className:Vd(t,n.root),children:e})},ms=qd;var ui={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as fs,jsxs as Gd}from"react/jsx-runtime";var $d=({title:t,children:e,type:o,...n})=>{let s=y("Section",ui);return Gd("section",{...n,className:s.root,"data-section-type":o,children:[t&&fs("div",{className:s.subTitleContainer,children:fs("span",{className:s.subtitle,children:t})}),fs("div",{className:s.suggestions,children:e})]})},We=$d;import Xd from"classnames";import Zd from"react";var gi={root:"_root_19wxp_1"};import{jsx as Jd}from"react/jsx-runtime";var Qd=Zd.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",gi);return Jd("div",{ref:o,className:Xd(n.root,t),children:e})}),hs=Qd;import Lo from"classnames";import Yd,{createContext as eu,useCallback as tu,useContext as jt}from"react";var ys={root:"_root_ipo0b_11",fadein:"_fadein_ipo0b_1",isClickable:"_isClickable_ipo0b_46",isSelected:"_isSelected_ipo0b_51",actions:"_actions_ipo0b_75",actionsIsFixed:"_actionsIsFixed_ipo0b_97",actionButton:"_actionButton_ipo0b_105",dropdownList:"_dropdownList_ipo0b_126",dropdownButton:"_dropdownButton_ipo0b_141",dropdownItem:"_dropdownItem_ipo0b_151",dropdownItemButton:"_dropdownItemButton_ipo0b_160",actionButtonIsPrimary:"_actionButtonIsPrimary_ipo0b_174",actionButtonIsDisabled:"_actionButtonIsDisabled_ipo0b_178",labels:"_labels_ipo0b_186",label:"_label_ipo0b_186"};import{jsx as _e,jsxs as iu}from"react/jsx-runtime";var ut=eu(ys),ou=({fixed:t,children:e,...o})=>{let n=jt(ut);return _e("div",{...o,className:Lo(n.actions,{[n.actionsIsFixed]:t}),children:e})},nu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=jt(ut);return iu("div",{className:Lo(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,_e("ul",{className:r.dropdownList,children:s})]})},su=({index:t,label:e,onClick:o})=>{let n=jt(ut);return _e("li",{className:n.dropdownItem,children:_e("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},ru=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=jt(ut);return _e("button",{type:"button",className:Lo(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},vs=({labels:t})=>{let e=jt(ut);return _e("div",{className:e.labels,children:t.map(o=>_e("span",{className:e.label,children:o},o))})},gt=Yd.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",ys),l=tu(c=>{c.preventDefault(),o&&o(c)},[o]);return _e(s,{...r,ref:i,className:Lo(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:_e(ut.Provider,{value:a,children:n})})});gt.Labels=vs;gt.Actions=ou;gt.ActionButton=ru;gt.DropdownButton=nu;gt.DropdownItem=su;var D=gt;import au from"classnames";var mi={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as cu}from"react/jsx-runtime";var lu=({withDivider:t,children:e})=>{let o=y("SuggestionList",mi);return cu("div",{"data-testid":"suggestions-overlay-list",className:au(o.root,{[o.isWithDivider]:t}),children:e})},ie=lu;import pu from"classnames";var fi={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as Ss}from"react/jsx-runtime";var du=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",fi);return Ss("button",{type:"button",className:pu(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:Ss("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:Ss("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},mt=du;var hi=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,ft=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var yi=/x-deepdesk-(([a-z0-9\-_])+-version)/,ge=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(ge||{}),$e=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))($e||{});import{render as Ut,unmountComponentAtNode as as}from"react-dom";import{Fragment as eh}from"react";import{createSlice as uu}from"@reduxjs/toolkit";import{useSelector as gu}from"react-redux";var Mo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Mo||{});var mu={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,floatingMenu:!1,adminUrl:void 0,productName:"Deepdesk"},vi=uu({name:"settings",initialState:mu,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Vt}=vi.actions,_s=t=>e=>e.settings[t],C=t=>gu(_s(t)),Si=vi.reducer;import{useState as Lm}from"react";import{useDispatch as Mm,useSelector as ur}from"react-redux";import{createAction as Ge,createSlice as bu}from"@reduxjs/toolkit";import{diffChars as Cu}from"diff";import{useSelector as wu}from"react-redux";function _i(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Me(t,e,o=10){let n=typeof t,s=typeof e;if(o===0)throw new Error("Max depth deepEqual, possible circular references?");return n!==s?!1:t==null||n==="string"||n==="number"||n==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>Me(r,e[i],o-1)):_i(t)&&_i(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Me(t[i],e[i],o-1)):!1}function fu(t){return Math.max(...t.map(e=>e.length))}function hu(t,e){let o=t.reduce((n,s)=>{if(s){let r=n[s]?n[s]+1:1;return{...n,[s]:r}}return n},{});return Object.keys(o).reduce((n,s)=>(o[s]<e&&n.push(s),n),[])}function xi(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<fu(n);s++){let r=hu(n.map(a=>a[s]),e),i=n.filter(a=>!r.includes(a[s]));if(i.length>=e)n=i;else return{text:n[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var yu=2;function xs(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=xi(t,yu);return o&&o.text!==e?o:t[0]}import{createAction as vu,createAsyncThunk as ht,createSlice as Su}from"@reduxjs/toolkit";var bi={current:null,isSupported:null},L=vu("resetConversation"),No=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Oo=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},yt=t=>t.conversation.isSupported,bs=ht("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Do=ht("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Ho=ht("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Bo=ht("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Oo(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Cs=ht("conversation/upsert",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId).catch(()=>null).then(n=>{if(!n)return o.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),Fo=ht("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Oo(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),_u=[Do.rejected,Ho.rejected,Bo.rejected,Fo.rejected].map(t=>t==null?void 0:t.toString()),xu=Su({name:"conversation",initialState:bi,reducers:{},extraReducers:t=>{t.addCase(bs.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Do.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Ho.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Cs.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Bo.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Fo.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(L,()=>bi).addMatcher(e=>_u.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),Ci=xu.reducer;var Ne={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Uo(t){let{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}=t;return{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}}var zo=Ge("input/replaceText"),jo=Ge("input/keyDown"),Xe=Ge("input/sendMessage"),Vo=Ge("input/sendEditSuggestionMessage"),qo=Ge("input/uiInputChange"),Wo=Ge("input/applyImageSuggestion"),W=Ge("input/sendEvent");function Ko(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,d=o==="search"||o==="personal-collection-search",g=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(g=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(g=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:g,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:d?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var wi=t=>bu({name:t,initialState:Ne,reducers:{initialInput(e,o){let{text:n,selection:s,html:r}=o.payload;e.text=n,e.selection.start=(s==null?void 0:s.start)??n.length,e.selection.end=(s==null?void 0:s.end)??n.length,e.userCommitted.text=n,e.userCommitted.selection.start=(s==null?void 0:s.start)??n.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??n.length,e.html=r||null},reset(e){Object.assign(e,{...Ne,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=xs(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(Me(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Ko(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:g,metaKey:u,altKey:m}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=e,{text:h}=o.payload,E=Cu(f,h);f.length-h.length>1&&e.metrics.deletions.push(...E.filter(_=>_.removed).map(_=>_.value)),e.metrics.numCharsDeleted+=f.length-h.length;break}case"C":case"V":case"X":if(!g&&!u){e.metrics.numCharsTyped+=1;let f=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}break;case"Shift":break;default:if(!g&&!u&&!m){e.metrics.numCharsTyped+=1;let f=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=Ne.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Ko(e);let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end,e.userCommitted.selection.start=r.start,e.userCommitted.selection.end=r.end),e.text=n,e.html=s||null,e.userCommitted.text=n,e.previousKeyDownEvent=null},stageSuggestion(e,o){let{text:n}=o.payload;switch(e.stagedSuggestion=o.payload,e.tabCompletionSuggestion=void 0,o.payload.replace){case"selection":e.text=`${e.text.slice(0,e.selection.start)}${n}${e.text.slice(e.selection.end)}`,e.selection.end=e.selection.start+n.length,e.selection.start+=n.length;break;case"until-selection-end":e.text=`${n}${e.text.slice(e.selection.end)}`,e.selection.start=n.length,e.selection.end=n.length;break;default:throw new Error(`Unknown replace ${o.payload.replace}`)}o.payload.eventMetrics.inputType==="tab"&&Ko(e)},commitSuggestion(e){Ko(e)},offeredTextSuggestion(e,o){let{text:n,suggestion:{source:s}}=o.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:s})},registerCut(e,o){let{metrics:n}=e,s=o.payload;e.metrics={...e.metrics,numCharsCut:n.numCharsCut+s.length,cuts:[...n.cuts,s]}},registerPaste(e,o){let{metrics:n}=e,{text:s,selectionText:r}=o.payload,i=n.numCharsDeleted+(r&&r.length?r.length:0),a=r&&r.length?[...n.deletions,r]:n.deletions;e.metrics={...e.metrics,numCharsDeleted:i,deletions:a,numCharsPasted:n.numCharsPasted+s.length,numPaste:n.numPaste+1,pastes:[...n.pastes,s]}},registerKeyDown(e,o){e.previousKeyDownEvent=o.payload},nextTextSuggestionIndex(e){let o=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<o-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},previousTextSuggestionIndex(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},setTextSuggestions(e,o){if(e.selectedSuggestionIndex=-1,e.textSuggestions=o.payload,o.payload.length===0)return;let n=e.userCommitted.text.substring(0,e.userCommitted.selection.end),s=xs(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)},setMetrics(e,{payload:o}){e.metrics=o}},extraReducers:e=>{e.addCase(L,o=>{o.tabCompletionSuggestion=Ne.tabCompletionSuggestion,o.previousKeyDownEvent=Ne.previousKeyDownEvent,o.textSuggestions=Ne.textSuggestions,o.selectedSuggestionIndex=Ne.selectedSuggestionIndex,o.metrics=Ne.metrics})}}),ws=wi("input"),vt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Tu=t=>t.input.selection,Ti=()=>wu(Tu),{userInput:Ei,changeSelection:Ts,initialInput:ki,mergeMetrics:Ii,nextTextSuggestionIndex:Ri,offeredTextSuggestion:Pi,previousTextSuggestionIndex:Ai,registerCut:Li,registerKeyDown:Mi,registerPaste:Ni,reset:Oi,resetToCommitted:qt,platformInput:Di,setSelectedTextSuggestionIndex:Oe,setTextSuggestions:me,stageSuggestion:ae,commitSuggestion:xe,setMetrics:Hi}=ws.actions,Q=wi("overlay");import{useEffect as Fi,useRef as Ki}from"react";var Bi={root:"_root_1h19b_1",content:"_content_1h19b_24"};import{jsx as Ui}from"react/jsx-runtime";var Eu=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=Ki(null),l=Ki(null),c=y("Dialog",Bi);return Fi(()=>{var g,u;let p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),s())},d=m=>{let f=window.getSelection();f!=null&&f.toString()||m.target===a.current&&t&&n()};return(g=a.current)==null||g.addEventListener("click",d),(u=a.current)==null||u.addEventListener("keyup",p),()=>{var m,f;(m=a.current)==null||m.removeEventListener("click",d),(f=a.current)==null||f.removeEventListener("keyup",p)}},[a,l,s,n]),Fi(()=>{var p,d;!a.current||!t||!e||(d=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||d.focus()},[t,e,a]),t?Ui("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Ui("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},St=Eu;import{useEffect as Ya}from"react";import{useDispatch as gm,useSelector as mm}from"react-redux";var Es={};q(Es,{enUS:()=>ku,nlNL:()=>Iu});var ku={dismiss:[{type:0,value:"Close"}],add:[{type:0,value:"Add to message"}],next:[{type:0,value:"Next"}],previous:[{type:0,value:"Previous"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},Iu={dismiss:[{type:0,value:"Sluiten"}],add:[{type:0,value:"Toevoegen"}],next:[{type:0,value:"Volgende"}],previous:[{type:0,value:"Vorige"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var zi={root:"_root_jcr8j_1",content:"_content_jcr8j_3",title:"_title_jcr8j_7",actions:"_actions_jcr8j_15",pagination:"_pagination_jcr8j_19",primaryButton:"_primaryButton_jcr8j_50",primaryButtons:"_primaryButtons_jcr8j_54"};import{createContext as Ku,useContext as Uu}from"react";var ks=function(t,e){return ks=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(o[s]=n[s])},ks(t,e)};function Wt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ks(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var oe=function(){return oe=Object.assign||function(e){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},oe.apply(this,arguments)};function ji(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(o[n[s]]=t[n[s]]);return o}function $o(t,e,o){if(o||arguments.length===2)for(var n=0,s=e.length,r;n<s;n++)(r||!(n in e))&&(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))}var Go;(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"})(Go||(Go={}));var Xo=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var le;(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"})(le||(le={}));var Zo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Zo||(Zo={}));function Is(t){return t.type===le.literal}function Vi(t){return t.type===le.argument}function Qo(t){return t.type===le.number}function Jo(t){return t.type===le.date}function Yo(t){return t.type===le.time}function en(t){return t.type===le.select}function tn(t){return t.type===le.plural}function qi(t){return t.type===le.pound}function on(t){return t.type===le.tag}function nn(t){return!!(t&&typeof t=="object"&&t.type===Zo.number)}function $t(t){return!!(t&&typeof t=="object"&&t.type===Zo.dateTime)}function Rs(t){t.forEach(function(e){if(delete e.location,en(e)||tn(e))for(var o in e.options)delete e.options[o].location,Rs(e.options[o].value);else Qo(e)&&nn(e.style)||(Jo(e)||Yo(e))&&$t(e.style)?delete e.style.location:on(e)&&Rs(e.children)})}function Wi(t,e){e===void 0&&(e={}),e=oe({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Xo(t,e).parse();if(o.err){var n=SyntaxError(Go[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Rs(o.val),o.val}function sn(t,e){var o=e&&e.cache?e.cache:Nu,n=e&&e.serializer?e.serializer:Mu,s=e&&e.strategy?e.strategy:Pu;return s(t,{cache:o,serializer:n})}function Ru(t){return t==null||typeof t=="number"||typeof t=="boolean"}function $i(t,e,o,n){var s=Ru(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Gi(t,e,o){var n=Array.prototype.slice.call(arguments,3),s=o(n),r=e.get(s);return typeof r>"u"&&(r=t.apply(this,n),e.set(s,r)),r}function Ps(t,e,o,n,s){return o.bind(e,t,n,s)}function Pu(t,e){var o=t.length===1?$i:Gi;return Ps(t,this,o,e.cache.create(),e.serializer)}function Au(t,e){return Ps(t,this,Gi,e.cache.create(),e.serializer)}function Lu(t,e){return Ps(t,this,$i,e.cache.create(),e.serializer)}var Mu=function(){return JSON.stringify(arguments)};function As(){this.cache=Object.create(null)}As.prototype.get=function(t){return this.cache[t]};As.prototype.set=function(t,e){this.cache[t]=e};var Nu={create:function(){return new As}},rn={variadic:Au,monadic:Lu};var Ze;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Ze||(Ze={}));var Gt=function(t){Wt(e,t);function e(o,n,s){var r=t.call(this,o)||this;return r.code=n,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var Ls=function(t){Wt(e,t);function e(o,n,s,r){return t.call(this,'Invalid values for "'.concat(o,'": "').concat(n,'". Options are "').concat(Object.keys(s).join('", "'),'"'),Ze.INVALID_VALUE,r)||this}return e}(Gt);var Xi=function(t){Wt(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Ze.INVALID_VALUE,s)||this}return e}(Gt);var Zi=function(t){Wt(e,t);function e(o,n){return t.call(this,'The intl string context variable "'.concat(o,'" was not provided to the string "').concat(n,'"'),Ze.MISSING_VALUE,n)||this}return e}(Gt);var $;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})($||($={}));function Ou(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==$.literal||o.type!==$.literal?e.push(o):n.value+=o.value,e},[])}function Du(t){return typeof t=="function"}function Xt(t,e,o,n,s,r,i){if(t.length===1&&Is(t[0]))return[{type:$.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Is(p)){a.push({type:$.literal,value:p.value});continue}if(qi(p)){typeof r=="number"&&a.push({type:$.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new Zi(d,i);var g=s[d];if(Vi(p)){(!g||typeof g=="string"||typeof g=="number")&&(g=typeof g=="string"||typeof g=="number"?String(g):""),a.push({type:typeof g=="string"?$.literal:$.object,value:g});continue}if(Jo(p)){var u=typeof p.style=="string"?n.date[p.style]:$t(p.style)?p.style.parsedOptions:void 0;a.push({type:$.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(Yo(p)){var u=typeof p.style=="string"?n.time[p.style]:$t(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:$.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(Qo(p)){var u=typeof p.style=="string"?n.number[p.style]:nn(p.style)?p.style.parsedOptions:void 0;u&&u.scale&&(g=g*(u.scale||1)),a.push({type:$.literal,value:o.getNumberFormat(e,u).format(g)});continue}if(on(p)){var m=p.children,f=p.value,h=s[f];if(!Du(h))throw new Xi(f,"function",i);var E=Xt(m,e,o,n,s,r),_=h(E.map(function(v){return v.value}));Array.isArray(_)||(_=[_]),a.push.apply(a,_.map(function(v){return{type:typeof v=="string"?$.literal:$.object,value:v}}))}if(en(p)){var x=p.options[g]||p.options.other;if(!x)throw new Ls(p.value,g,Object.keys(p.options),i);a.push.apply(a,Xt(x.value,e,o,n,s));continue}if(tn(p)){var x=p.options["=".concat(g)];if(!x){if(!Intl.PluralRules)throw new Gt(`Intl.PluralRules is not available in this environment.
|
|
1
|
+
var Bd=Object.defineProperty;var Z=(t,e)=>{for(var o in e)Bd(t,o,{get:e[o],enumerable:!0})};import zn from"classnames";import qd,{createContext as $d,useContext as go,useEffect as Wd,useState as Gd}from"react";import Kd,{useContext as Ud}from"react";import zd from"classnames";var Pt=Kd.createContext({});function h(t,e){let{debug:o,...n}=Ud(Pt),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:zd(a,l,o?`${t}__${i}`:!1)}},{}):e}import{jsx as Ar,jsxs as jd}from"react/jsx-runtime";var Lr=({className:t})=>jd("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:t,children:[Ar("line",{x1:"1",y1:"11",x2:"11",y2:"1",stroke:"black",strokeWidth:"2"}),Ar("line",{x1:"1",y1:"1",x2:"11",y2:"11",stroke:"black",strokeWidth:"2"})]});var Mr={root:"_root_vr71j_1"};import{jsx as po,jsxs as Vd}from"react/jsx-runtime";var uo=()=>Vd("svg",{className:Mr.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[po("defs",{children:po("style",{children:".cls-1 { fill: #b3b3b3; }"})}),po("title",{children:"Failed loading image"}),po("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 Un={root:"_root_15d2a_1",imageWrapper:"_imageWrapper_15d2a_7",image:"_image_15d2a_7",content:"_content_15d2a_24",title:"_title_15d2a_35",contentIsCropped:"_contentIsCropped_15d2a_45",lineClamp:"_lineClamp_15d2a_51",closeIcon:"_closeIcon_15d2a_58"};import{jsx as Ee}from"react/jsx-runtime";var At=$d(Un),Xd=({title:t,src:e})=>{let o=go(At),[n,s]=Gd(!1);return Wd(()=>{s(!1)},[e]),Ee("div",{className:o.imageWrapper,children:e&&!n?Ee("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):Ee(uo,{})})},Zd=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=go(At);return Ee("div",{className:zn(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Qd=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=go(At);return qd.createElement(t,{className:zn(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Jd=({className:t,title:e,...o})=>{let n=go(At);return Ee("div",{className:zn(n.closeIcon,t),title:e,role:"button","aria-label":e,...o,children:Ee(Lr,{})})},Lt=({children:t})=>{let e=h("Card",Un);return Ee("div",{className:e.root,children:Ee(At.Provider,{value:e,children:t})})};Lt.Image=Xd;Lt.Content=Zd;Lt.Title=Qd;Lt.CloseIcon=Jd;var N=Lt;import Yd from"classnames";var Or={root:"_root_cq1yq_1"};import{jsx as op}from"react/jsx-runtime";var ep={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},tp=({className:t,keyCode:e,...o})=>{let n=h("KeyboardHint",Or);return op("span",{"data-key":ep[e],className:Yd(t,n.root),...o})},jn=tp;import np from"classnames";var Nr={root:"_root_4a08n_1"};import{jsx as rp}from"react/jsx-runtime";var sp=({className:t,children:e,...o})=>{let n=h("Label",Nr);return rp("span",{...o,className:np(t,n.root),children:e})},Vn=sp;var Dr={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as qn,jsxs as ap}from"react/jsx-runtime";var ip=({title:t,children:e,type:o,...n})=>{let s=h("Section",Dr);return ap("section",{...n,className:s.root,"data-section-type":o,children:[t&&qn("div",{className:s.subTitleContainer,children:qn("span",{className:s.subtitle,children:t})}),qn("div",{className:s.suggestions,children:e})]})},ke=ip;import lp from"classnames";import cp from"react";var Hr={root:"_root_19wxp_1"};import{jsx as pp}from"react/jsx-runtime";var dp=cp.forwardRef(({className:t,children:e},o)=>{let n=h("SectionList",Hr);return pp("div",{ref:o,className:lp(n.root,t),children:e})}),$n=dp;import mo from"classnames";import up,{createContext as gp,useCallback as mp,useContext as Mt}from"react";var Wn={root:"_root_ipo0b_11",fadein:"_fadein_ipo0b_1",isClickable:"_isClickable_ipo0b_46",isSelected:"_isSelected_ipo0b_51",actions:"_actions_ipo0b_75",actionsIsFixed:"_actionsIsFixed_ipo0b_97",actionButton:"_actionButton_ipo0b_105",dropdownList:"_dropdownList_ipo0b_126",dropdownButton:"_dropdownButton_ipo0b_141",dropdownItem:"_dropdownItem_ipo0b_151",dropdownItemButton:"_dropdownItemButton_ipo0b_160",actionButtonIsPrimary:"_actionButtonIsPrimary_ipo0b_174",actionButtonIsDisabled:"_actionButtonIsDisabled_ipo0b_178",labels:"_labels_ipo0b_186",label:"_label_ipo0b_186"};import{jsx as he,jsxs as _p}from"react/jsx-runtime";var tt=gp(Wn),fp=({fixed:t,children:e,...o})=>{let n=Mt(tt);return he("div",{...o,className:mo(n.actions,{[n.actionsIsFixed]:t}),children:e})},hp=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=Mt(tt);return _p("div",{className:mo(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,he("ul",{className:r.dropdownList,children:s})]})},yp=({index:t,label:e,onClick:o})=>{let n=Mt(tt);return he("li",{className:n.dropdownItem,children:he("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},vp=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=Mt(tt);return he("button",{type:"button",className:mo(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Sp=({labels:t})=>{let e=Mt(tt);return he("div",{className:e.labels,children:t.map(o=>he("span",{className:e.label,children:o},o))})},ot=up.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=h("Suggestion",Wn),l=mp(c=>{c.preventDefault(),o&&o(c)},[o]);return he(s,{...r,ref:i,className:mo(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:he(tt.Provider,{value:a,children:n})})});ot.Labels=Sp;ot.Actions=fp;ot.ActionButton=vp;ot.DropdownButton=hp;ot.DropdownItem=yp;var L=ot;import xp from"classnames";var Fr={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as wp}from"react/jsx-runtime";var bp=({withDivider:t,children:e})=>{let o=h("SuggestionList",Fr);return wp("div",{"data-testid":"suggestions-overlay-list",className:xp(o.root,{[o.isWithDivider]:t}),children:e})},te=bp;import Cp from"classnames";var Br={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as Gn}from"react/jsx-runtime";var Tp=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=h("ToggleButton",Br);return Gn("button",{type:"button",className:Cp(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:Gn("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:Gn("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},nt=Tp;var Kr=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,fo=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Ur=/x-deepdesk-(([a-z0-9\-_])+-version)/,Ie=(m=>(m.SEARCH="search",m.TEMPLATE="template",m.ELASTIC_SEARCH="search-autocomplete",m.GPT="gpt",m.TRIE="trie",m.TRIE_WITH_TYPOS="trie-with-typos",m.SEMANTIC="semantic",m.TEXT_RECOMMENDATION="text_recommendation",m.URL_RECOMMENDATION="url_recommendation",m.LINK_RECOMMENDATION="link_recommendation",m.PERSONAL_COLLECTION="personal-collection",m.PERSONAL_COLLECTION_SEARCH="personal-collection-search",m.SEARCH_OVERLAY="search-overlay",m.SEARCH_PREVIEW="search-preview",m.SEARCH_URL="search-url",m))(Ie||{}),st=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(st||{});import{render as Rt,unmountComponentAtNode as Hn}from"react-dom";import{Fragment as Lm}from"react";import{createSlice as Ep}from"@reduxjs/toolkit";import{useSelector as kp}from"react-redux";var ho=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(ho||{});var Ip={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,floatingMenu:!1,adminUrl:void 0,productName:"Deepdesk"},zr=Ep({name:"settings",initialState:Ip,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:yo}=zr.actions,Xn=t=>e=>e.settings[t],b=t=>kp(Xn(t)),jr=zr.reducer;import{useSelector as Xi}from"react-redux";import{createAsyncThunk as Zn,createSlice as Rp}from"@reduxjs/toolkit";var Pp={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},G=t=>t.auth.isLoggedIn,Vr=t=>t.auth.loginFetchState,qr=t=>t.auth.verifyFetchState,$r=t=>t.auth.showLoginOverlay,ye=Zn("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Wr=Zn("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Ot=Zn("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Gr=Rp({name:"auth",initialState:Pp,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(ye.pending,e=>{e.loginFetchState="loading"}),t.addCase(ye.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(ye.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Ot.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Ot.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Ot.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:rt,setShowLoginOverlay:Xr}=Gr.actions,Zr=Gr.reducer;import{createAction as lt,createSlice as Bp}from"@reduxjs/toolkit";import{diffChars as Kp}from"diff";import{useSelector as Up}from"react-redux";function Qr(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Re(t,e,o=10){let n=typeof t,s=typeof e;if(o===0)throw new Error("Max depth deepEqual, possible circular references?");return n!==s?!1:t==null||n==="string"||n==="number"||n==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>Re(r,e[i],o-1)):Qr(t)&&Qr(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Re(t[i],e[i],o-1)):!1}function Ap(t){return Math.max(...t.map(e=>e.length))}function Lp(t,e){let o=t.reduce((n,s)=>{if(s){let r=n[s]?n[s]+1:1;return{...n,[s]:r}}return n},{});return Object.keys(o).reduce((n,s)=>(o[s]<e&&n.push(s),n),[])}function Jr(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Ap(n);s++){let r=Lp(n.map(a=>a[s]),e),i=n.filter(a=>!r.includes(a[s]));if(i.length>=e)n=i;else return{text:n[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Mp=2;function Qn(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Jr(t,Mp);return o&&o.text!==e?o:t[0]}import{createAction as Np,createAsyncThunk as it,createSlice as Dp}from"@reduxjs/toolkit";var Op={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},C=Op;var Yr={current:null,isSupported:null},M=Np("resetConversation"),vo=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},So=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},at=t=>t.conversation.isSupported,Jn=it("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),_o=it("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),xo=it("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),bo=it("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=So(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Yn=it("conversation/upsert",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId).catch(()=>null).then(n=>{if(!n)return o.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),wo=it("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=So(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Hp=[_o.rejected,xo.rejected,bo.rejected,wo.rejected].map(t=>t==null?void 0:t.toString()),Fp=Dp({name:"conversation",initialState:Yr,reducers:{},extraReducers:t=>{t.addCase(Jn.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(_o.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(xo.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Yn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(bo.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(wo.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(M,()=>Yr).addMatcher(e=>Hp.includes(e.type),(e,o)=>{var n;throw C.info("Conversation action rejected",o.type,((n=o.error)==null?void 0:n.message)||"No message"),new Error(o.error.message)})}}),ei=Fp.reducer;var Pe={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function ti(t){let{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}=t;return{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}}var To=lt("input/replaceText"),Eo=lt("input/keyDown"),Ue=lt("input/sendMessage"),ko=lt("input/uiInputChange"),Io=lt("input/applyImageSuggestion"),$=lt("input/sendEvent");function Co(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:d}=t.stagedSuggestion,p=o==="search"||o==="personal-collection-search",g=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(p||d==="selection")&&(g=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(g=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:g,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:p?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var oi=Bp({name:"input",initialState:Pe,reducers:{initialInput(t,e){let{text:o,selection:n,html:s}=e.payload;t.text=o,t.selection.start=(n==null?void 0:n.start)??o.length,t.selection.end=(n==null?void 0:n.end)??o.length,t.userCommitted.text=o,t.userCommitted.selection.start=(n==null?void 0:n.start)??o.length,t.userCommitted.selection.end=(n==null?void 0:n.end)??o.length,t.html=s||null},reset(t){Object.assign(t,{...Pe,selection:t.selection})},resetToCommitted(t){t.text=t.userCommitted.text,t.selection=t.userCommitted.selection,t.stagedSuggestion=null,t.tabCompletionSuggestion=Qn(t.textSuggestions,t.userCommitted.text)},changeSelection(t,e){e.payload&&(Re(t.selection,e.payload)||(t.selection=e.payload,t.userCommitted.selection=t.selection,t.stagedSuggestion&&Co(t)))},platformInput(t,e){let{text:o,html:n,selection:s}=e.payload;s&&(t.selection.start=s.start,t.selection.end=s.end),t.text=o,t.html=n||null},userInput(t,e){var r,i,a,l;if(t.previousKeyDownEvent){let{key:c,shiftKey:d,ctrlKey:p,metaKey:g,altKey:u}=t.previousKeyDownEvent;switch(c){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=t,{text:m}=e.payload,v=Kp(f,m);f.length-m.length>1&&t.metrics.deletions.push(...v.filter(T=>T.removed).map(T=>T.value)),t.metrics.numCharsDeleted+=f.length-m.length;break}case"C":case"V":case"X":if(!p&&!g){t.metrics.numCharsTyped+=1;let f=((r=t.selection)==null?void 0:r.start)!==void 0&&((i=t.selection)==null?void 0:i.end)!==void 0?t.text.substring(t.selection.start,t.selection.end):null;f&&f.length>0&&(t.metrics.numCharsDeleted+=f.length,t.metrics.deletions.push(f))}break;case"Shift":break;default:if(!p&&!g&&!u){t.metrics.numCharsTyped+=1;let f=((a=t.selection)==null?void 0:a.start)!==void 0&&((l=t.selection)==null?void 0:l.end)!==void 0?t.text.substring(t.selection.start,t.selection.end):null;f&&f.length>0&&(t.metrics.numCharsDeleted+=f.length,t.metrics.deletions.push(f))}}}!t.metrics.agentStartedTypingTimestamp&&e.payload.text!==t.text&&(t.metrics.agentStartedTypingTimestamp=Date.now()),e.payload.text===""&&(t.metrics=Pe.metrics,t.textSuggestions=[],t.stagedSuggestion=null),t.text!==e.payload.text&&Co(t);let{text:o,html:n,selection:s}=e.payload;s&&(t.selection.start=s.start,t.selection.end=s.end,t.userCommitted.selection.start=s.start,t.userCommitted.selection.end=s.end),t.text=o,t.html=n||null,t.userCommitted.text=o,t.previousKeyDownEvent=null},stageSuggestion(t,e){let{text:o}=e.payload;switch(t.stagedSuggestion=e.payload,t.tabCompletionSuggestion=void 0,e.payload.replace){case"selection":t.text=`${t.text.slice(0,t.selection.start)}${o}${t.text.slice(t.selection.end)}`,t.selection.end=t.selection.start+o.length,t.selection.start+=o.length;break;case"until-selection-end":t.text=`${o}${t.text.slice(t.selection.end)}`,t.selection.start=o.length,t.selection.end=o.length;break;default:throw new Error(`Unknown replace ${e.payload.replace}`)}e.payload.eventMetrics.inputType==="tab"&&Co(t)},commitSuggestion(t){Co(t)},offeredTextSuggestion(t,e){let{text:o,suggestion:{source:n}}=e.payload;t.metrics.offeredTextSuggestions.find(r=>r.text===o)||t.metrics.offeredTextSuggestions.push({text:o,source:n})},registerCut(t,e){let{metrics:o}=t,n=e.payload;t.metrics={...t.metrics,numCharsCut:o.numCharsCut+n.length,cuts:[...o.cuts,n]}},registerPaste(t,e){let{metrics:o}=t,{text:n,selectionText:s}=e.payload,r=o.numCharsDeleted+(s&&s.length?s.length:0),i=s&&s.length?[...o.deletions,s]:o.deletions;t.metrics={...t.metrics,numCharsDeleted:r,deletions:i,numCharsPasted:o.numCharsPasted+n.length,numPaste:o.numPaste+1,pastes:[...o.pastes,n]}},registerKeyDown(t,e){t.previousKeyDownEvent=e.payload},nextTextSuggestionIndex(t){let e=t.textSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},previousTextSuggestionIndex(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0)return;let o=t.userCommitted.text.substring(0,t.userCommitted.selection.end),n=Qn(e.payload,o);t.tabCompletionSuggestion=n!=null&&n.text.includes(o)?n:void 0},setSelectedTextSuggestionIndex(t,e){t.selectedSuggestionIndex=e.payload},setMetrics(t,{payload:e}){t.metrics=e}},extraReducers:t=>{t.addCase(M,e=>{e.tabCompletionSuggestion=Pe.tabCompletionSuggestion,e.previousKeyDownEvent=Pe.previousKeyDownEvent,e.textSuggestions=Pe.textSuggestions,e.selectedSuggestionIndex=Pe.selectedSuggestionIndex,e.metrics=Pe.metrics})}}),ct=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),zp=t=>t.input.selection,ni=()=>Up(zp),{userInput:si,changeSelection:es,initialInput:ri,nextTextSuggestionIndex:ii,offeredTextSuggestion:ai,previousTextSuggestionIndex:li,registerCut:ci,registerKeyDown:di,registerPaste:pi,reset:ui,resetToCommitted:Nt,platformInput:gi,setSelectedTextSuggestionIndex:Ae,setTextSuggestions:ce,stageSuggestion:se,commitSuggestion:ve,setMetrics:mi}=oi.actions,fi=oi.reducer;import{createAsyncThunk as $p,createSlice as Wp}from"@reduxjs/toolkit";import{createAsyncThunk as os,createSlice as Vp}from"@reduxjs/toolkit";function jp(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function R(t){return Array.isArray(t)?t.map(R):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[jp(o)]:R(t[o])}),{}):t}function ts(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function U(t){return Array.isArray(t)?t.map(U):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[ts(o)]:U(t[o])}),{}):t}var qp={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Ht=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},Dt=os("info/setAgentInfo",async(t,e)=>{let{deepdeskAPI:o}=e.extra;if(!t.agentId&&!t.agentNickname)throw new Error("At least provide agentId or agentNickname");let n=await o.client.get("/apis/admin/session/me/",{version:null}),s={};return n.external_id||(s.external_id=t.agentId),n.nickname||(s.nickname=t.agentNickname),!s.external_id&&!s.nickname?R(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),R(n))}),ns=os("info/setAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.client.get("/apis/admin/session/me/",{version:null}),s={...typeof n.ui_config=="object"?n.ui_config:{},...t};return await o.client.patch("/apis/admin/session/me/",{ui_config:s}),s}),ss=os("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),hi=t=>t.info.agentInfo,yi=Vp({name:"info",initialState:qp,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Dt.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Dt.rejected,e=>{e.fetchState="error"}).addCase(Dt.fulfilled,(e,o)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...o.meta.arg,agentId:o.payload.externalId||o.meta.arg.agentId||"",agentNickname:o.payload.nickname||o.meta.arg.agentNickname||""}}).addCase(ns.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(ss.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(M,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:vi}=yi.actions,Si=yi.reducer;var Ro={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},_i=t=>t.search.isOpen,xi=t=>t.search.page,bi=t=>t.search.list,wi=t=>t.search.aggregates;function Ci(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var ze=$p("search/getAll",async(t,e)=>{var a;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(a=n.conversation.current)==null?void 0:a.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r,aggregates:i}=await o.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:Ht(n)});return{results:r.map(l=>({...l,source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:i}}),Ti=Wp({name:"search",initialState:Ro,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=Ro.fetchState,t.list=Ro.list}},extraReducers:t=>{t.addCase(ze.pending,e=>{e.fetchState="loading"}).addCase(ze.rejected,(e,o)=>{e.fetchState="error",C.error(o.error)}).addCase(ze.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload.results,e.aggregates=o.payload.aggregates||{}}).addCase(M,()=>Ro)}}),{resetSearch:Po,setIsOpen:Y,setPage:re}=Ti.actions,Ei=Ti.reducer;import{createAction as Gp,createAsyncThunk as Xp,createSlice as Zp}from"@reduxjs/toolkit";var rs={cues:[],fetchState:"idle"},ki=t=>{var e;return(e=t.rules)==null?void 0:e.cues},Qp=Gp("rules/resetCues"),Se=Xp("rules/evaluate",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=(r=e.getState().conversation.current)==null?void 0:r.id;if(!n)throw new Error("No current conversation to evaulate rules");return await o.evaluateRule(t.label,n,t.params)}),Ii=Zp({name:"answer",initialState:rs,reducers:{removeCue(t,e){t.cues=t.cues.filter(o=>o.id!==e.payload.id)}},extraReducers:t=>{t.addCase(Se.pending,e=>{e.fetchState="loading"}).addCase(Se.rejected,e=>{e.fetchState="error"}).addCase(Se.fulfilled,(e,o)=>{let n=Date.now(),s=o.payload.map(a=>({id:a.id||a.text,timestamp:n,...a})),r=s.map(a=>a.id),i=e.cues.filter(a=>!r.includes(a.id));e.fetchState="done",e.cues=[...s,...i]}).addCase(M,()=>rs).addCase(Qp.toString(),()=>rs)}}),{removeCue:Ri}=Ii.actions,Pi=Ii.reducer;var is="SetCues",dt="ShowLoginOverlay",Ft="UserLoggedIn",Jp="UserLoggedOut",pt="ApplySuggestion",as="ApplyImageSuggestion",Yp="ShowCommandPalette",eu=t=>({[is]:e=>{t.dispatch({type:Se.fulfilled,payload:e})},[Yp]:e=>{t.dispatch(Y(e.isOpen)),e.page&&t.dispatch(re(e.page))},[dt]:e=>{t.dispatch(Xr(e))},[Ft]:()=>{t.dispatch(ye())},[Jp]:()=>{t.dispatch(ye())},[as]:e=>{t.dispatch(Io({suggestion:e.suggestion}))},[pt]:e=>{t.dispatch(se({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(ve())}}),Ai=eu;import Li,{useContext as tu}from"react";import{jsx as ou}from"react/jsx-runtime";var Mi=Li.createContext(null),je=({broadcastEvents:t,children:e})=>{let o=Li.useMemo(()=>t,[]);return ou(Mi.Provider,{value:o,children:e})},de=()=>{let t=tu(Mi);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import ys from"classnames";import{useCallback as Wi,useEffect as Eu,useMemo as ku,useState as vs}from"react";import{useDispatch as Iu,useSelector as Ru}from"react-redux";import{createContext as mu,useContext as fu}from"react";var ls=function(t,e){return ls=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(o[s]=n[s])},ls(t,e)};function Bt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ls(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var ee=function(){return ee=Object.assign||function(e){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},ee.apply(this,arguments)};function Oi(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(o[n[s]]=t[n[s]]);return o}function Ao(t,e,o){if(o||arguments.length===2)for(var n=0,s=e.length,r;n<s;n++)(r||!(n in e))&&(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))}var Lo;(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"})(Lo||(Lo={}));var Mo=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var ie;(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"})(ie||(ie={}));var Oo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Oo||(Oo={}));function cs(t){return t.type===ie.literal}function Ni(t){return t.type===ie.argument}function No(t){return t.type===ie.number}function Do(t){return t.type===ie.date}function Ho(t){return t.type===ie.time}function Fo(t){return t.type===ie.select}function Bo(t){return t.type===ie.plural}function Di(t){return t.type===ie.pound}function Ko(t){return t.type===ie.tag}function Uo(t){return!!(t&&typeof t=="object"&&t.type===Oo.number)}function Kt(t){return!!(t&&typeof t=="object"&&t.type===Oo.dateTime)}function ds(t){t.forEach(function(e){if(delete e.location,Fo(e)||Bo(e))for(var o in e.options)delete e.options[o].location,ds(e.options[o].value);else No(e)&&Uo(e.style)||(Do(e)||Ho(e))&&Kt(e.style)?delete e.style.location:Ko(e)&&ds(e.children)})}function Hi(t,e){e===void 0&&(e={}),e=ee({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Mo(t,e).parse();if(o.err){var n=SyntaxError(Lo[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||ds(o.val),o.val}function zo(t,e){var o=e&&e.cache?e.cache:lu,n=e&&e.serializer?e.serializer:au,s=e&&e.strategy?e.strategy:su;return s(t,{cache:o,serializer:n})}function nu(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Fi(t,e,o,n){var s=nu(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Bi(t,e,o){var n=Array.prototype.slice.call(arguments,3),s=o(n),r=e.get(s);return typeof r>"u"&&(r=t.apply(this,n),e.set(s,r)),r}function ps(t,e,o,n,s){return o.bind(e,t,n,s)}function su(t,e){var o=t.length===1?Fi:Bi;return ps(t,this,o,e.cache.create(),e.serializer)}function ru(t,e){return ps(t,this,Bi,e.cache.create(),e.serializer)}function iu(t,e){return ps(t,this,Fi,e.cache.create(),e.serializer)}var au=function(){return JSON.stringify(arguments)};function us(){this.cache=Object.create(null)}us.prototype.get=function(t){return this.cache[t]};us.prototype.set=function(t,e){this.cache[t]=e};var lu={create:function(){return new us}},jo={variadic:ru,monadic:iu};var Ve;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Ve||(Ve={}));var Ut=function(t){Bt(e,t);function e(o,n,s){var r=t.call(this,o)||this;return r.code=n,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var gs=function(t){Bt(e,t);function e(o,n,s,r){return t.call(this,'Invalid values for "'.concat(o,'": "').concat(n,'". Options are "').concat(Object.keys(s).join('", "'),'"'),Ve.INVALID_VALUE,r)||this}return e}(Ut);var Ki=function(t){Bt(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Ve.INVALID_VALUE,s)||this}return e}(Ut);var Ui=function(t){Bt(e,t);function e(o,n){return t.call(this,'The intl string context variable "'.concat(o,'" was not provided to the string "').concat(n,'"'),Ve.MISSING_VALUE,n)||this}return e}(Ut);var W;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(W||(W={}));function cu(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==W.literal||o.type!==W.literal?e.push(o):n.value+=o.value,e},[])}function du(t){return typeof t=="function"}function zt(t,e,o,n,s,r,i){if(t.length===1&&cs(t[0]))return[{type:W.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var d=c[l];if(cs(d)){a.push({type:W.literal,value:d.value});continue}if(Di(d)){typeof r=="number"&&a.push({type:W.literal,value:o.getNumberFormat(e).format(r)});continue}var p=d.value;if(!(s&&p in s))throw new Ui(p,i);var g=s[p];if(Ni(d)){(!g||typeof g=="string"||typeof g=="number")&&(g=typeof g=="string"||typeof g=="number"?String(g):""),a.push({type:typeof g=="string"?W.literal:W.object,value:g});continue}if(Do(d)){var u=typeof d.style=="string"?n.date[d.style]:Kt(d.style)?d.style.parsedOptions:void 0;a.push({type:W.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(Ho(d)){var u=typeof d.style=="string"?n.time[d.style]:Kt(d.style)?d.style.parsedOptions:n.time.medium;a.push({type:W.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(No(d)){var u=typeof d.style=="string"?n.number[d.style]:Uo(d.style)?d.style.parsedOptions:void 0;u&&u.scale&&(g=g*(u.scale||1)),a.push({type:W.literal,value:o.getNumberFormat(e,u).format(g)});continue}if(Ko(d)){var f=d.children,m=d.value,v=s[m];if(!du(v))throw new Ki(m,"function",i);var T=zt(f,e,o,n,s,r),_=v(T.map(function(S){return S.value}));Array.isArray(_)||(_=[_]),a.push.apply(a,_.map(function(S){return{type:typeof S=="string"?W.literal:W.object,value:S}}))}if(Fo(d)){var y=d.options[g]||d.options.other;if(!y)throw new gs(d.value,g,Object.keys(d.options),i);a.push.apply(a,zt(y.value,e,o,n,s));continue}if(Bo(d)){var y=d.options["=".concat(g)];if(!y){if(!Intl.PluralRules)throw new Ut(`Intl.PluralRules is not available in this environment.
|
|
2
2
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
3
|
-
`,Ze.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(g-(p.offset||0));x=p.options[b]||p.options.other}if(!x)throw new Ls(p.value,g,Object.keys(p.options),i);a.push.apply(a,Xt(x.value,e,o,n,s,g-(p.offset||0)));continue}}return Ou(a)}function Hu(t,e){return e?oe(oe(oe({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=oe(oe({},t[n]),e[n]||{}),o},{})):t}function Bu(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Hu(t[n],e[n]),o},oe({},t)):t}function Ms(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Fu(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:sn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,$o([void 0],o,!1)))},{cache:Ms(t.number),strategy:rn.variadic}),getDateTimeFormat:sn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,$o([void 0],o,!1)))},{cache:Ms(t.dateTime),strategy:rn.variadic}),getPluralRules:sn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,$o([void 0],o,!1)))},{cache:Ms(t.pluralRules),strategy:rn.variadic})}}var Qi=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var d=p.reduce(function(g,u){return!g.length||u.type!==$.literal||typeof g[g.length-1]!="string"?g.push(u.value):g[g.length-1]+=u.value,g},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Xt(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,l=ji(i,["formatters"]);this.ast=t.__parse(e,oe(oe({},l),{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=Bu(t.formats,n),this.formatters=s&&s.formatters||Fu(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>"u")){var o=Intl.NumberFormat.supportedLocalesOf(e);return o.length>0?new Intl.Locale(o[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Wi,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 zu(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var ju="dummy",Ns=Ku(null);function w(t){let e=Uu(Ns);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let o=t[e]??{};return(n,s)=>{let r=zu(o,n);return r?new Qi(r).format(s):(e!==ju&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}import{jsx as Ji,jsxs as Vu}from"react/jsx-runtime";var an=()=>Vu("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Ji("title",{id:"angleLeftTitle",children:"AngleLeft"}),Ji("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});import{jsx as Yi,jsxs as qu}from"react/jsx-runtime";var ea=()=>qu("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[Yi("title",{id:"angleRightTitle",children:"AngleRight"}),Yi("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});import{useEffect as Qt,useRef as js,useState as fg}from"react";import{useDispatch as hg}from"react-redux";import{Interweave as xa}from"interweave";import ba from"classnames";var Os={root:"_root_smoda_1",agentText:"_agentText_smoda_3",textInput:"_textInput_smoda_8",textInputWrapper:"_textInputWrapper_smoda_27",alert:"_alert_smoda_31",alertText:"_alertText_smoda_50",warning:"_warning_smoda_60",success:"_success_smoda_69"};import{Matcher as Xu}from"interweave";import Zu from"classnames";import{useEffect as Wu,useRef as $u,useState as Gu}from"react";function ta(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function ln(t){let e=$u(null),[o,n]=Gu(!1);return Wu(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=ta((p,d)=>{let g=e.current;if(!g)return;let u=p/r,m=d/r,f=g.getBoundingClientRect(),h=u>f.x&&u<f.x+f.width&&m>f.y&&m<f.y+f.height;h&&!s?(s=!0,n(!0)):!h&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=ta(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var be={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};import{jsx as oa}from"react/jsx-runtime";var Qu=({inputElement:t,children:e})=>{let o=y("TabCompletion",be),[n,s]=ln(t);return oa("mark",{ref:n,className:Zu(o.matchPlaceholder,{[o.hover]:s}),children:e})},_t=class extends Xu{match(e){let o=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return o?{index:o.index,length:o[0].length,match:o[0],matchString:o[0],valid:!0}:null}replaceWith(e,o){return oa(Qu,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{useEffect as Ju,useRef as Yu,useState as eg}from"react";function cn(t){return t.contentEditable==="true"}function tg(t){let e=0,o=0,n=window.getSelection();if(n.rangeCount!==0){let s=n.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),o=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:o}}function na(t){let{selectionStart:e,selectionEnd:o}=cn(t)?tg(t):t;return[e,o]}function pn(t){let[,e]=eg(),o=Yu(null);return o.current=na(t),Ju(()=>{let n=()=>{let[s,r]=o.current??[],i=na(t);(!i||s!==i[0]||r!==i[1])&&(o.current=i,e({}))};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",n)}},[t]),o.current}function dn(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(ft);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=n.indexOf(l,a);return s>c&&r<c+l.length?(o.selectionStart=c,o.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}import{useEffect as og}from"react";function xt(t){og(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Qe(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var sa,fe=new Map,ng=["bottom","height","left","right","top","width"],sg=(t={},e={})=>ng.some(o=>t[o]!==e[o]);function ra(t){var o,n;if(t.ownerDocument===document)return[];let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...ra(e)]:[]}function ia(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var un=!1,aa=()=>{un=!0;let t=[];if(fe.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),fe.delete(o);return}let n=o.getBoundingClientRect();sg(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(ia,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),fe.size===0){un=!1;return}sa=window.requestAnimationFrame(aa)};function Ds(t,e){let o=ra(t),n=[],s=o.map((r,i)=>Ds(r,a=>{n[i]=a;let l=fe.get(t);if(!l)return;let c=n.reduce(ia,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),fe.has(t)){let i=fe.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else fe.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!un&&aa()},unobserve(){s.forEach(i=>i.unobserve());let r=fe.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||fe.delete(t),fe.size||(cancelAnimationFrame(sa),un=!1)}}}}var la,he=new Map,ca=()=>{he.forEach((t,e)=>{if(!e.isConnected){he.delete(e);return}let{clientHeight:o,scrollHeight:n}=e,s=n>o;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),he.size!==0&&(la=window.requestAnimationFrame(ca))};function pa(t,e){return{observe(){let o=he.size===0;he.has(t)?he.get(t).callbacks.push(e):he.set(t,{visible:void 0,callbacks:[e]}),o&&ca()},unobserve(){let o=he.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||he.delete(t),he.size||cancelAnimationFrame(la)}}}}var Hs=["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 Bs(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function bt(t){return parseFloat(t)}function gn(t){return Math.round(t*1e6)}function da(t){return t/1e6}function Fs(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=bt(t.width),r=bt(t.borderLeftWidth),i=bt(t.borderRightWidth),a=bt(t.paddingRight),l=da(gn(s)-gn(r)-gn(i)),c=da(gn(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Ct(t,e={}){var p;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Qe(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Bs(n,o,Hs),Fs(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=pa(t,()=>{Bs(n,o,Hs),Fs(n,t,o),r(),setTimeout(r,0)}),a,l=!0,c=Ds(t,d=>{if(d===null){e.onRemove&&e.onRemove(),o.remove();return}if(!l&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Bs(n,o,Hs),Fs(n,t,o),r(),o.style.top=`${d.top}px`,o.style.left=`${d.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let g=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),m=bt(u.borderTopWidth),f=bt(u.borderBottomWidth),h=g.top+m-d.top,E=d.top+d.height+-(g.top+g.height-f);o.style.clipPath=`inset(${h}px 0px ${E}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(p=t.parentElement)==null||p.appendChild(o),c.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),c.unobserve(),i.unobserve()}]}var Ks={};q(Ks,{enUS:()=>rg,nlNL:()=>ig});var rg={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},ig={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};import{jsx as ua,jsxs as ag}from"react/jsx-runtime";var ga=()=>ag("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[ua("title",{id:"circleCheckTitle",children:"Check"}),ua("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});import{jsx as ma}from"react/jsx-runtime";var fa=()=>ma("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:ma("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 ha=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(ha||{}),De=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e}),n&&(this.currentSelection=this.getSelection()),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e}),this.triggerCaretPosition(),this.currentHTML=o))}triggerSelection(){let e=this.getSelection();(e.start!==this.currentSelection.start||e.end!==this.currentSelection.end)&&(this.currentSelection=e,this.emit("selection",e),this.triggerCaretPosition())}triggerCaretPosition(){let e=this.getCaretPosition();Me(e,this.currentCaret)||(this.currentCaret=e,this.emit("caret",e))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(ha).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",o=>this.handlePaste(o)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},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()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var He=class extends De{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var lg=/[.*+?^${}()|[\]\\]/g,cg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function pg(t){return t.replace(lg,"\\$&")}function dg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function ug(t){return t.search(cg)}function ya(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${pg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function va(t){return t.replace(ft,'<mark data-type="placeholder">$1</mark>')}function Zt(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function gg(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 Us(t,e,o={}){if(e){let n=dg(e.toLowerCase(),t.toLowerCase()),s=Zt(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=ug(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(hi).length>3||e.length>30?gg(e.trim(),n):0;return`${`${i>0?"\u2026":""}${Zt(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var mg=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function wt(t){return mg.test(t)}function Sa(t){if(wt(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}function _a(t){let e=document.createElement("template");return e.innerHTML=t,e.content.textContent??""}import{jsx as ce,jsxs as zs}from"react/jsx-runtime";var yg=({value:t,onUse:e,...o})=>{var d;let n=w(Ks),s=hg(),r=wt(t),i=y("EditSuggestionTextInput",Os),[a,l]=fg(null),c=js(null),p=((d=t.match(ft))==null?void 0:d.length)||0;return Qt(()=>{let g;return c.current&&(l(c.current),g=new He(c.current),g.on("change",({plainText:u})=>{s(Q.actions.userInput({text:u,selection:g.getSelection()}))}),g.on("keydown",u=>{s(Q.actions.registerKeyDown(Uo(u))),u.code==="Enter"&&u.shiftKey&&e(g.getText())}),g.on("paste",({pastedText:u,selectionText:m})=>{s(Q.actions.registerPaste({text:u,selectionText:m}))}),g.on("cut",({selectionText:u})=>{s(Q.actions.registerCut(u))})),()=>{s(Q.actions.reset()),g.dispose(),g.deactivate()}},[c]),Qt(()=>{t&&c.current&&(c.current.value=t)},[t,c]),Qt(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let g=c.current.value.length;c.current.setSelectionRange(g,g),c.current.focus()},0)},[c]),r?ce("div",{className:i.textInputWrapper,children:ce(xa,{className:i.textInput,tagName:"div",content:t})}):zs("div",{className:i.textInputWrapper,children:[ce("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&ce(vg,{inputElement:c.current,value:t}),zs("div",{className:ba(i.alert,p===0?i.success:i.warning),children:[ce("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?ce(ga,{}):ce(fa,{})]})]})},vg=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",Os),n=js(null),s=pn(t);return Qt(()=>{dn(t,s)},[s,t]),ce(Sg,{inputElement:t,children:zs("div",{ref:n,className:ba(o.root,o.agentText),children:[ce(xa,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new _t("placeholders")],inputElement:t,boundaryRef:n}),ce("br",{})]})})},Sg=({inputElement:t,children:e})=>{let o=js(null);return Qt(()=>{if(!o.current)return()=>{};let[n,s]=Ct(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),ce("div",{ref:o,children:e})},Ca=yg;import{useEffect as cm,useState as pm,useRef as dm}from"react";import{useState as bg}from"react";import Vs from"classnames";var J={root:"_root_1xflk_1",list:"_list_1xflk_2",listWrapper:"_listWrapper_1xflk_6",listHorizontal:"_listHorizontal_1xflk_10",page:"_page_1xflk_19",search:"_search_1xflk_25",pageNav:"_pageNav_1xflk_33",pageTitle:"_pageTitle_1xflk_41",pageBackButton:"_pageBackButton_1xflk_48",listHeader:"_listHeader_1xflk_62",listHeading:"_listHeading_1xflk_68",listMoreButton:"_listMoreButton_1xflk_76",listItem:"_listItem_1xflk_87",listItemContent:"_listItemContent_1xflk_96",listItemText:"_listItemText_1xflk_114",listItemDescription:"_listItemDescription_1xflk_122",listItemActions:"_listItemActions_1xflk_129",truncate:"_truncate_1xflk_140",lineClamp:"_lineClamp_1xflk_146",listItemTitle:"_listItemTitle_1xflk_153",listItemAction:"_listItemAction_1xflk_129",listItemPrimaryAction:"_listItemPrimaryAction_1xflk_174",listItemSelected:"_listItemSelected_1xflk_179",sources:"_sources_1xflk_183",sourcesTitle:"_sourcesTitle_1xflk_190",source:"_source_1xflk_183",icon:"_icon_1xflk_205",searchIcon:"_searchIcon_1xflk_222",searchInputWrapper:"_searchInputWrapper_1xflk_227",searchInput:"_searchInput_1xflk_227",select:"_select_1xflk_248",selectType:"_selectType_1xflk_265",selectWrapper:"_selectWrapper_1xflk_269",image:"_image_1xflk_299",imageSrc:"_imageSrc_1xflk_306",imageSrcHidden:"_imageSrcHidden_1xflk_317",imageSrcStatus:"_imageSrcStatus_1xflk_321",imageTitle:"_imageTitle_1xflk_331",actions:"_actions_1xflk_336",actionsWrapper:"_actionsWrapper_1xflk_340",actionsBar:"_actionsBar_1xflk_346",actionButton:"_actionButton_1xflk_355",hasShortKeys:"_hasShortKeys_1xflk_368",actionShortcut:"_actionShortcut_1xflk_377",actionShortcutFixKerning:"_actionShortcutFixKerning_1xflk_384"};var Ce={};q(Ce,{enUS:()=>_g,nlNL:()=>xg});var _g={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"}]},xg={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"}]};import{jsx as Jt,jsxs as wg}from"react/jsx-runtime";var Cg=({src:t,title:e})=>{let o=y("CommandPalette",J),[n,s]=bg("loading"),r=w(Ce);return wg("div",{className:o.image,children:[Jt("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:Vs(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&Jt("span",{className:Vs(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&Jt("span",{className:Vs(o.imageSrc,o.imageSrcStatus),children:Jt(Ro,{})}),e&&Jt("span",{className:o.imageTitle,children:e})]})},wa=Cg;import Tg from"react";import Eg from"classnames";import{jsx as qs,jsxs as Ta}from"react/jsx-runtime";function Ws({children:t,heading:e,orientation:o,hasMore:n,onShowAll:s}){let r=w(Ce),i=y("CommandPalette",J);return Tg.Children.count(t)===0?null:Ta("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||n)&&Ta("div",{className:i.listHeader,children:[e&&qs("h4",{className:i.listHeading,children:e}),n&&s&&qs("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),qs("div",{className:Eg(i.listWrapper,o==="horizontal"&&i.listHorizontal),children:t})]})}import hn from"classnames";import{Interweave as zg}from"interweave";import kg,{useState as Ea,useEffect as ka,useMemo as Ig,useRef as Ia,useCallback as Rg,useContext as Pg}from"react";import Ag from"classnames";var $s={root:"_root_1oh4w_1",trigger:"_trigger_1oh4w_5",content:"_content_1oh4w_19",contentOpen:"_contentOpen_1oh4w_33",contentTop:"_contentTop_1oh4w_37",contentBottom:"_contentBottom_1oh4w_41",item:"_item_1oh4w_45"};import{jsx as mn,jsxs as Og}from"react/jsx-runtime";var Lg=0,Ra=kg.createContext(null),Mg=()=>{let t=Pg(Ra);if(!t)throw new Error("Invalid DropdownContext");return t},Pa=({trigger:t,children:e,position:o="bottom"})=>{let n=Ig(()=>++Lg,[]),s=Ia(null),r=Ia(null),i=y("Dropdown",$s),[a,l]=Ea(!1),[c,p]=Ea(o),d=u=>{u.preventDefault(),u.stopPropagation(),l(!a)},g=Rg(([u])=>{!u.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return ka(()=>{let u=m=>{s.current&&!s.current.contains(m.target)&&l(!1)};return document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}},[]),ka(()=>{if(!r.current&&!a)return()=>{};let u=new IntersectionObserver(g,{root:null,rootMargin:"0px",threshold:1});return r.current&&u.observe(r.current),()=>{r.current&&u.unobserve(r.current)}},[r,a]),mn(Ra.Provider,{value:{setIsOpen:l},children:Og("div",{ref:s,className:i.root,children:[mn("button",{id:`dropdown-${n}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:i.trigger,onClick:d,children:t}),mn("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:Ag(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Ng({as:t,children:e,onClick:o,...n}){let s=t||"button",r=y("Dropdown",$s),{setIsOpen:i}=Mg(),a=l=>{i(!1),o(l),l.stopPropagation()};return mn(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Pa.Item=Ng;var Gs=Pa;import{jsx as Aa}from"react/jsx-runtime";var La=t=>Aa("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:Aa("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 Je={};q(Je,{enUS:()=>Dg,nlNL:()=>Hg});var Dg={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"}]},Hg={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"}]};import{jsx as Xs}from"react/jsx-runtime";var Bg="%0d%0a%0d%0a%0d%0a",Fg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Bg)}`},Kg=({suggestion:t,onFeedback:e})=>{let o=w(Je),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:Xs(Gs,{trigger:Xs(La,{"data-testid":"feedback-dropdown-trigger"}),children:Xs(Gs.Item,{as:"a",href:Fg(n,t),onClick:e,children:o("giveFeedback")})})},fn=Kg;import Zs from"react";import{jsx as Ug}from"react/jsx-runtime";var Ma=Zs.createContext(void 0);function Be(){let t=Zs.useContext(Ma);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Na=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=Zs.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return Ug(Ma.Provider,{value:i,children:t})};import{jsx as Fe,jsxs as Qs}from"react/jsx-runtime";function Js({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,index:i,description:a,sources:l,styles:c,...p}){let{selected:d,setSelected:g,onChangeOpen:u}=Be(),m=y("CommandPalette",J);function f(h){n(h),t&&u(!1)}return Qs("div",{className:hn(m.listItem,d===i&&m.listItemSelected),children:[Fe("button",{onMouseEnter:()=>g(i),type:"button",className:hn("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:Qs("div",{className:m.listItemContent,children:[typeof o=="string"?Fe("p",{className:hn(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&Fe(zg,{tagName:"p",allowList:[],content:wt(a)?_a(a):a,className:hn(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate)})]})}),s&&d===i&&Fe("div",{className:m.listItemActions,children:Fe(fn,{suggestion:String(o),onFeedback:s})}),l&&Qs("div",{className:m.sources,children:[Fe("span",{className:m.sourcesTitle,children:"Sources"}),l.map(h=>h.url?Fe("a",{className:m.source,href:h.url,target:"_blank",title:h.url,rel:"noopener noreferrer",onClick:()=>r&&r(h),children:h.name},h.url):Fe("span",{className:m.source,children:h.name},h.name))]})]})}import{jsx as Oa,jsxs as Ys}from"react/jsx-runtime";function er({children:t,title:e,id:o,onDismiss:n}){let s=w(Ce),r=y("CommandPalette",J),{page:i}=Be();return i!==o?null:Ys("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&Ys("div",{className:r.pageNav,children:[Ys("button",{className:r.pageBackButton,type:"button",onClick:n,children:[Oa(an,{}),s("back")]}),e&&Oa("h3",{className:r.pageTitle,children:e})]}),t]})}import{Fragment as Yg,useCallback as em,useEffect as tm,useRef as om}from"react";import{createAsyncThunk as $g,createSlice as Gg}from"@reduxjs/toolkit";var jg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},T=jg;import{createAsyncThunk as or,createSlice as qg}from"@reduxjs/toolkit";function Vg(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function P(t){return Array.isArray(t)?t.map(P):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Vg(o)]:P(t[o])}),{}):t}function tr(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function z(t){return Array.isArray(t)?t.map(z):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[tr(o)]:z(t[o])}),{}):t}var Wg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},eo=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},Yt=or("info/setAgentInfo",async(t,e)=>{let{deepdeskAPI:o}=e.extra;if(!t.agentId&&!t.agentNickname)throw new Error("At least provide agentId or agentNickname");let n=await o.client.get("/apis/admin/session/me/",{version:null}),s={};return n.external_id||(s.external_id=t.agentId),n.nickname||(s.nickname=t.agentNickname),!s.external_id&&!s.nickname?P(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),P(n))}),nr=or("info/setAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.client.get("/apis/admin/session/me/",{version:null}),s={...typeof n.ui_config=="object"?n.ui_config:{},...t};return await o.client.patch("/apis/admin/session/me/",{ui_config:s}),s}),sr=or("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Da=t=>t.info.agentInfo,Ha=qg({name:"info",initialState:Wg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Yt.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Yt.rejected,e=>{e.fetchState="error"}).addCase(Yt.fulfilled,(e,o)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...o.meta.arg,agentId:o.payload.externalId||o.meta.arg.agentId||"",agentNickname:o.payload.nickname||o.meta.arg.agentNickname||""}}).addCase(nr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(sr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(L,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Ba}=Ha.actions,Fa=Ha.reducer;var yn={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},Ka=t=>t.search.isOpen,Ua=t=>t.search.page,za=t=>t.search.list,ja=t=>t.search.aggregates;function Va(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Ye=$g("search/getAll",async(t,e)=>{var a;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(a=n.conversation.current)==null?void 0:a.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r,aggregates:i}=await o.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:eo(n)});return{results:r.map(l=>({...l,source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:i}}),qa=Gg({name:"search",initialState:yn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=yn.fetchState,t.list=yn.list}},extraReducers:t=>{t.addCase(Ye.pending,e=>{e.fetchState="loading"}).addCase(Ye.rejected,(e,o)=>{e.fetchState="error",T.error(o.error)}).addCase(Ye.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload.results,e.aggregates=o.payload.aggregates||{}}).addCase(L,()=>yn)}}),{resetSearch:vn,setIsOpen:G,setPage:X}=qa.actions,Wa=qa.reducer;var Xg=/(https?:\/\/[^\s]+)/,Sn=t=>t.split(" ").find(e=>Xg.test(e));var _n=()=>/Mac/i.test(navigator.platform);import $a from"classnames";import{jsx as Qg,jsxs as Jg}from"react/jsx-runtime";var Zg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",J);return Jg("button",{type:"button",...n,onClick:t,className:$a(s.actionButton,n.className,{[s.hasShortKeys]:e&&e.length>0}),children:[o,e&&e.map(r=>Qg("span",{className:$a(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},Tt=Zg;import{jsx as xn,jsxs as rr}from"react/jsx-runtime";var nm=["url","URL"],sm=["default","pinned-message","DEFAULT","STICKYMESSAGE"],rm=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",J),a=w(Ce),{selected:l,setSelected:c}=Be(),p=r[l],d=p&&p.type&&nm.includes(p.type),g=p&&p.type&&sm.includes(p.type)||p&&"secondaryAction"in p,u=d?Sn(p.text):null,m=om(null);function f(v){if(!m.current)return;let R=m.current.querySelectorAll(".command-palette-list-item"),A=0,H=0;v==="down"?(R.forEach((K,k)=>{k===l&&(A=k)}),H=A===R.length-1?0:A+1):v==="up"?(R.forEach((K,k)=>{k===l&&(A=k)}),H=A?A-1:R.length-1):c(0);let N=R[H];N&&typeof H=="number"&&(c(H),N.scrollIntoView&&N.scrollIntoView({behavior:"smooth",block:H?"center":"end"}))}function h(){if(!m.current)return;let v=m.current.querySelectorAll(".command-palette-list-item"),R=0;v.forEach((H,N)=>{N===l&&(R=N)});let A=v[R];A&&A.click()}let E=()=>{u&&window.open(u,"_blank")},_=()=>{p&&n(p,l)},x=()=>{!s||!g||s(p,l)},b=em(v=>{if(v.key==="Enter"&&v.altKey&&u){E();return}if(v.key==="Enter"&&v.shiftKey){x();return}if(v.key==="ArrowDown"){v.preventDefault(),v.stopPropagation(),f("down");return}if(v.key==="ArrowUp"){v.preventDefault(),v.stopPropagation(),f("up");return}v.key==="Enter"&&l!==-1&&(v.preventDefault(),v.stopPropagation(),h())},[l]);return tm(()=>(window.addEventListener("keyup",b),()=>{window.removeEventListener("keyup",b)}),[b]),rr("div",{className:i.actions,children:[xn("div",{className:i.actionsWrapper,ref:m,children:t}),rr("div",{className:i.actionsBar,children:[u&&xn(Tt,{onClick:E,shortKeys:[_n()?8997:"ALT",8629],children:a("visitUrl")}),p&&rr(Yg,{children:[s&&g&&xn(Tt,{onClick:x,shortKeys:[8679,8629],children:o}),xn(Tt,{onClick:_,shortKeys:[8629],children:e})]})]})]})},Xa=rm;import{forwardRef as am}from"react";import{jsx as Za,jsxs as im}from"react/jsx-runtime";var Et=()=>im("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[Za("path",{d:"M0 0h24v24H0z",fill:"none"}),Za("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});import{jsx as kt,jsxs as ir}from"react/jsx-runtime";function lm({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",J);return ir("div",{className:l.search,children:[kt("div",{className:l.searchIcon,children:kt(Et,{})}),ir("div",{className:l.searchInputWrapper,children:[kt("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&kt("div",{className:l.selectWrapper,children:ir("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&&kt("option",{children:n}),s.map(c=>kt("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Qa=am(lm);import{jsx as Ja,jsxs as um}from"react/jsx-runtime";function et({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:d,search:g}){let[u,m]=pm(0),f=dm(null),h=()=>{s&&s(o),i(void 0),r(""),a(!1)},E=()=>{var _;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(_=f.current)==null||_.focus();return}if(g.length>0){r("");return}a(!1)};return cm(()=>{m(0)},[g,n]),Ja(St,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:E,onClose:h,children:um(Na,{selected:u,setSelected:m,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&Ja(Qa,{ref:f,onChange:r,onChangeType:i,placeholder:t,value:g,selectedType:l,types:c,typePlaceholder:e}),p]})})}et.Page=er;et.List=Ws;et.Image=wa;et.ListItem=Js;et.ActionsBar=Xa;et.Button=Tt;var I=et;import{jsx as we,jsxs as to}from"react/jsx-runtime";var fm=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",zi),l=gm(),c=w(Es),p=mm(m=>m.overlayInput.text);Ya(()=>{t&&(l(Q.actions.reset()),l(Q.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Q.actions.commitSuggestion()))},[t]);let d=m=>{m.preventDefault(),g(p)},g=m=>{l(Vo(m)),e(m)},u=m=>f=>{p!==i?window.confirm(c("warning"))&&m(f):m(f)};return Ya(()=>{n&&n(p!==i)},[n,t,p]),to("div",{className:a.root,children:[to("div",{className:a.content,children:[t.title&&we("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&we(vs,{labels:t.searchKeywords}),we(Ca,{onUse:g,value:Sa(p)})]}),to("form",{className:a.actions,onSubmit:d,children:[to("div",{children:[we("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&u(r),children:we(an,{})}),we("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&u(s),children:we(ea,{})})]}),to("div",{className:a.primaryButtons,children:[we(I.Button,{onClick:u(o),shortKeys:["esc"],children:c("dismiss")}),we(I.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},bn=fm;import{createAction as vm,createAsyncThunk as nl,createSlice as Sm}from"@reduxjs/toolkit";var hm=["{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}"],ym=new RegExp(hm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function el(t,e){let o=t.split(ym),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let d=a.charAt(0),g=0;do c=d?e.indexOf(d,c+1):-1,g+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&g>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function tl(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var sl={suggestions:[],fetchState:"idle",isInitialRequest:null},ol={default:sl},Cn=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},rl=t=>{let e=Object.keys(t.textSuggestions).map(o=>{var n;return(n=t.textSuggestions[o])==null?void 0:n.fetchState});return e.length===0?!0:e.every(o=>o!=="done")},Ke=t=>t.textSuggestions,il=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},wn=vm("textSuggestions/refresh"),pe=nl("textSuggestions/recommendations",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,inlineSuggestions:i}=n.settings,a=vt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,eo(n),t);if(t==="default"){let p=i?l.filter(il(a)):l;e.dispatch(me(p.slice(0,r)))}return l}),oo=nl("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getAutocompleteSuggestions(s,{...eo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(il(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?el(p.text,t):p.text}))),l=tl(l,r),e.dispatch(me(l)),l}),al=Sm({name:"textSuggestions",initialState:ol,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:o}=e.payload;t[o].fetchState="done",t[o].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}},setSuggestionState(t,e){return e.payload}},extraReducers:t=>{t.addCase(pe.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||sl;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(pe.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(pe.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(oo.pending,e=>{e.default.fetchState="loading"}).addCase(oo.rejected,e=>{e.default.fetchState="error"}).addCase(oo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(L,()=>ol)}}),{setTextSuggestions:ll,setSuggestionState:cl}=al.actions,pl=al.reducer;import{createSlice as _m}from"@reduxjs/toolkit";var dl={contentType:null,suggestion:null},ul=t=>t.activeSuggestion.suggestion,gl=t=>t.activeSuggestion.contentType,ml=_m({name:"activeSuggestion",initialState:dl,reducers:{setActiveSuggestion(t,e){let{contentType:o,suggestion:n}=e.payload;t.contentType=o,t.suggestion=n},resetActiveSuggestion(t){t.contentType=null,t.suggestion=null}},extraReducers:t=>{t.addCase(L,()=>dl)}}),{setActiveSuggestion:Te,resetActiveSuggestion:ar}=ml.actions,fl=ml.reducer;var lr={};q(lr,{enUS:()=>xm,nlNL:()=>bm});var xm={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},bm={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};import{createSlice as Cm}from"@reduxjs/toolkit";var wm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Tn=({ui:t})=>t.overlayCollapsed;var hl=Cm({name:"ui",initialState:wm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(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:no,setInputHasFocus:It,setOverlayCollapsed:Ue,setOpenOverlayWhenTyping:yl,setOverlayCollapsedUserOverwrite:vl}=hl.actions,Sl=hl.reducer;import _l,{useContext as Tm}from"react";import{jsx as Em}from"react/jsx-runtime";var xl=_l.createContext(null),tt=({broadcastEvents:t,children:e})=>{let o=_l.useMemo(()=>t,[]);return Em(xl.Provider,{value:o,children:e})},se=()=>{let t=Tm(xl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as cr,createSlice as km}from"@reduxjs/toolkit";var Im={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Z=t=>t.auth.isLoggedIn,bl=t=>t.auth.loginFetchState,Cl=t=>t.auth.verifyFetchState,wl=t=>t.auth.showLoginOverlay,Ee=cr("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Tl=cr("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),so=cr("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),El=km({name:"auth",initialState:Im,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Ee.pending,e=>{e.loginFetchState="loading"}),t.addCase(Ee.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Ee.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(so.pending,e=>{e.verifyFetchState="loading"}),t.addCase(so.rejected,e=>{e.verifyFetchState="error"}),t.addCase(so.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Rt,setShowLoginOverlay:kl}=El.actions,Il=El.reducer;var pr="SetActiveSuggestion",Pt="ShowLoginOverlay",ro="UserLoggedIn",Rm="UserLoggedOut",ke="ApplySuggestion",dr="ApplyImageSuggestion",Pm="ShowCommandPalette",Am=t=>({[pr]:e=>{t.dispatch(cl(e.state)),t.dispatch(Te({contentType:e.contentType,suggestion:e.suggestion}))},[Pm]:e=>{t.dispatch(G(e.isOpen)),e.page&&t.dispatch(X(e.page))},[Pt]:e=>{t.dispatch(kl(e))},[ro]:()=>{t.dispatch(Ee())},[Rm]:()=>{t.dispatch(Ee())},[dr]:e=>{t.dispatch(Wo({suggestion:e.suggestion}))},[ke]:e=>{t.dispatch(ae({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(xe())}}),Rl=Am;import{jsx as Pl}from"react/jsx-runtime";var Nm=()=>{var m;let[t,e]=Lm(!1),o=ur(ul),n=ur(gl),s=ur(Ke),r=Mm(),i=se(),a=w(lr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(ar()),r(It(!0)),r(Q.actions.reset())},p=(f,h)=>{r(ar()),r(It(!0)),i.send(ke,{text:f,suggestion:{...h,source:`${h.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(m=s[n])==null?void 0:m.suggestions.indexOf(o),g=d===0||d===null?void 0:()=>r(Te({contentType:n,suggestion:s[n].suggestions[d-1]})),u=d===s[n].suggestions.length-1||d===null?void 0:()=>r(Te({contentType:n,suggestion:s[n].suggestions[d+1]}));return Pl(St,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:Pl(bn,{onTouched:e,onDismiss:c,onUse:f=>p(f,o),suggestion:o,onNext:u,onPrevious:g})})},Al=Nm;import{useSelector as Dl}from"react-redux";import mr from"classnames";import{useCallback as Nl,useEffect as Km,useMemo as Um,useState as fr}from"react";import{useDispatch as zm,useSelector as jm}from"react-redux";import Om from"classnames";var Ll={root:"_root_1ukx5_1"};import{jsx as Hm}from"react/jsx-runtime";var Dm=({className:t,value:e,...o})=>{let n=y("TextInput",Ll);return Hm("input",{className:Om(t,n.root),type:"text",value:e,...o})},io=Dm;var gr={};q(gr,{enUS:()=>Bm,nlNL:()=>Fm});var Bm={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"}]},Fm={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 Ml={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};import{jsx as Y,jsxs as En}from"react/jsx-runtime";var Vm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},qm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=w(gr),i=y("LoginTokenDialog",Ml),a=jm(Cl),l=zm(),c=C("productName"),[p,d]=fr(t||""),[g,u]=fr(0),[m,f]=fr(""),h=Nl(async b=>{b.preventDefault(),l(Tl({email:p})),u(1)},[o,p]),E=()=>{f(""),u(0)},_=Nl(async b=>{b.preventDefault();let v=Vm(b.target.elements.token.value);if(!v){f(r("verifyCodeError",{login:x}));return}l(so({token:v}))},[o]),x=Um(()=>b=>Y("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:E,children:b},"back-button"),[]);return Km(()=>{a==="error"&&f(r("verifyCodeError",{login:x})),a==="done"&&n()},[a]),Y(St,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:En("div",{className:i.root,children:[Y("h1",{className:i.title,children:r("promptTitle",{productName:c})}),g===0&&En("form",{onSubmit:h,children:[Y("h2",{className:i.subtitle,children:r("requestCodeTitle")}),Y("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),Y(io,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>d(b.target.value)}),Y("div",{className:i.actions,children:Y("button",{type:"submit",className:mr(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),g===1&&En("form",{onSubmit:_,children:[Y("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),Y("p",{className:i.text,children:r("verifyCodeBody")}),Y(io,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&Y("div",{className:i.errorMessage,children:m}),En("div",{className:i.actions,children:[Y("button",{type:"button",className:mr(i.button),onClick:E,children:r("back")}),Y("button",{type:"submit",className:mr(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Ol=qm;import{jsx as $m}from"react/jsx-runtime";var Wm=()=>{let t=Dl(wl),e=Dl(Da),o=C("adminUrl"),n=se(),s=()=>n.send(Pt,!1),r=()=>{n.send(Pt,!1),n.send(ro)};return $m(Ol,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Hl=Wm;import $f from"lodash.debounce";import{useCallback as Ln,useEffect as br,useState as go}from"react";import{useDispatch as Gf,useSelector as ot}from"react-redux";import{createAsyncThunk as Gm,createSlice as Xm}from"@reduxjs/toolkit";var Zm={data:null,fetchState:"idle"},Bl=t=>t.contentTypes.data,ao=Gm("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Qm=Xm({name:"contentTypes",initialState:Zm,reducers:{},extraReducers:t=>{t.addCase(ao.pending,e=>{e.fetchState="loading"}).addCase(ao.rejected,e=>{e.fetchState="error"}).addCase(ao.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Fl=Qm.reducer;function lo(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}import{useEffect as Jm}from"react";function Kl(t,e){Jm(()=>{let o=n=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?n.metaKey:n.ctrlKey)&&n.key===t&&(n.preventDefault(),n.stopPropagation(),e())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o)}},[])}import{useEffect as Vl,useRef as rf}from"react";import{useSelector as af,useDispatch as lf}from"react-redux";import{createAsyncThunk as Ym,createSlice as ef}from"@reduxjs/toolkit";var Ul={data:null,fetchState:"idle"},kn=t=>{var r;let e=[],{visitorName:o}=t.info.visitorInfo??{},{agentName:n,agentNickname:s}=t.info.agentInfo??{};return n&&n!==o&&e.push(n),s&&s!==o&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},de=Ym("entities/getEntities",async(t,e)=>{let{deepdeskAPI:o,dynamicThunkObject:n}=e.extra;if(!n.conversationQuery)return Promise.resolve([]);let s=n.conversationQuery,r=await s();return r.length===0?Promise.resolve([]):o.getEntities(r)}),tf=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),of=ef({name:"entities",initialState:Ul,reducers:{},extraReducers:t=>{t.addCase(de.pending,e=>{e.fetchState="loading"}).addCase(de.rejected,e=>{e.fetchState="error"}).addCase(de.fulfilled,(e,o)=>{e.fetchState="done",e.data=tf(e.data?[...e.data,...o.payload]:o.payload)}).addCase(L,()=>Ul)}}),zl=of.reducer;var hr={};q(hr,{enUS:()=>nf,nlNL:()=>sf});var nf={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},sf={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var jl={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as In,jsxs as pf}from"react/jsx-runtime";var cf=({onCopy:t,onUse:e})=>{let o=rf(null),n=y("EntitiesList",jl),s=w(hr),r=af(kn),i=lf();return Vl(()=>{i(de())},[]),Vl(()=>{o.current&&o.current.focus()},[o]),pf("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&In(I.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:In(I.List,{children:r.map((a,l)=>In(I.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&In("p",{className:n.empty,children:s("noResults")})]})},ql=cf;import{Fragment as hf,useEffect as Rn,useRef as yf,useState as vf}from"react";import{useSelector as Ql,useDispatch as Sf}from"react-redux";import{createAsyncThunk as df,createSlice as uf}from"@reduxjs/toolkit";var Wl={data:null,fetchState:"idle"},$l=t=>t.summary.data,Gl=t=>t.summary.fetchState==="error",Ie=df("summary/getSummary",async(t,e)=>{var p,d,g;let o=e.getState().profile.data,n=(p=e.getState().conversation.current)==null?void 0:p.sessionId,s=(g=(d=e.getState().info)==null?void 0:d.agentInfo)==null?void 0:g.agentId;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:i}=e.extra;if(!i.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let a=i.conversationQuery,l=await a();if(l.length===0)return Promise.reject(new Error("No messages are included"));let c=await r.getSummary(l,{externalConversationId:n,agentId:s,promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return c?{summary:c}:Promise.reject(new Error("Summary is not provided"))}),gf=uf({name:"summary",initialState:Wl,reducers:{},extraReducers:t=>{t.addCase(Ie.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Ie.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Ie.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(L,()=>Wl)}}),Xl=gf.reducer;var yr={};q(yr,{enUS:()=>mf,nlNL:()=>ff});var mf={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},ff={copy:[{type:0,value:"Kopieer"}],error:[{type:0,value:"Kon helaas geen samenvatting genereren."}],loading:[{type:0,value:"Samenvatting wordt gemaakt, dit kan even duren."}]};var Zl={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};import{jsx as At,jsxs as xf}from"react/jsx-runtime";var _f=({onCopy:t})=>{let e=yf(null),o=y("SummaryForm",Zl),[n,s]=vf(""),r=w(yr),i=Ql($l),a=Ql(Gl),l=Sf(),c=()=>{l(W({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(W({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return Rn(()=>{l(Ie())},[]),Rn(()=>{s(i||"")},[i]),Rn(()=>{e.current&&i&&e.current.focus()},[e,i]),Rn(()=>{let d=g=>{g.key==="Enter"&&g.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),At("div",{className:o.root,tabIndex:-1,children:a?At("p",{className:o.error,children:r("error")}):xf(hf,{children:[At("div",{className:o.main,children:At("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),At("div",{className:o.actions,children:At(I.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Jl=_f;var co={};q(co,{enUS:()=>bf,nlNL:()=>Cf});var bf={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link 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"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],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?"}]},Cf={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:"Link 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"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};import Of,{useEffect as _r,useRef as Df}from"react";import{useDispatch as Hf,useSelector as ac}from"react-redux";var vr={};q(vr,{enUS:()=>wf,nlNL:()=>Tf});var wf={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},Tf={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var Yl={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};import{createAction as Pf,createAsyncThunk as Af,createSlice as Lf}from"@reduxjs/toolkit";import{createAsyncThunk as Ef,createSlice as kf}from"@reduxjs/toolkit";var If={data:null,fetchState:"idle"},ec=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},po=Ef("knowledgeAssistant/getKnowledgeAssistant",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=(i=n.profile.data)==null?void 0:i.knowledgeAssistant;return r?o.getKnowledgeAssistant(r):null}),Rf=kf({name:"knowledgeAssistant",initialState:If,reducers:{},extraReducers:t=>{t.addCase(po.pending,e=>{e.fetchState="loading"}).addCase(po.rejected,e=>{e.fetchState="error"}).addCase(po.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),tc=Rf.reducer;var Sr={data:[],fetchState:"idle"},oc=t=>{var e;return(e=t.answer)==null?void 0:e.data},nc=t=>t.answer.fetchState,Mt=Pf("answer/resetKnowledgeSearch"),Lt=Af("answer/getAnswer",async(t,e)=>{var l,c,p;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=ec(e.getState()),r=(l=e.getState().conversation.current)==null?void 0:l.sessionId,i=(p=(c=e.getState().info)==null?void 0:c.agentInfo)==null?void 0:p.agentId;if(!s)throw new Error("KnowledgeAssistant is not defined");let a=await o.knowledgeAssist({promptInstruction:s.prompt,question:t},n,s.code,{agentId:i,conversationId:r});return{question:t,answer:a}}),Mf=Lf({name:"answer",initialState:Sr,reducers:{},extraReducers:t=>{t.addCase(Lt.pending,e=>{e.fetchState="loading"}).addCase(Lt.rejected,e=>{e.fetchState="error"}).addCase(Lt.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(L,()=>Sr).addCase(Mt,()=>Sr)}}),sc=Mf.reducer;import{jsx as rc,jsxs as Nf}from"react/jsx-runtime";var ic=()=>Nf("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[rc("title",{id:"paperPlaneTitle",children:"PaperPlane"}),rc("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});import{jsx as Re,jsxs as xr}from"react/jsx-runtime";var Bf=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=Of.useState(""),{setSelected:r}=Be(),i=Df(null),a=y("EntitiesList",Yl),l=w(vr),c=Hf(),p=ac(oc),d=ac(nc),g=async m=>{m.preventDefault(),m.stopPropagation(),n!==""&&c(Lt(n))},u=(m,f)=>{c(W({name:"knowledge assist source viewed",data:{question:f,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return _r(()=>{var m;o&&d==="idle"?c(Lt(o)):(m=i.current)==null||m.focus()},[i,d]),_r(()=>{d==="done"&&(c(W({name:"knowledge assist question answered",data:{question:n||o,sources:p[p.length-1].answer.sources,answer:p[p.length-1].answer.answer,isFollowUpQuestion:p.length>1},options:{includeConversationData:!0}})),r(p.length-1),s(""))},[d,p]),_r(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,p]),xr("div",{className:a.root,children:[p.length>0&&Re("div",{className:a.alignRight,children:Re(I.Button,{onClick:e,children:l("reset")})}),xr(I.ActionsBar,{list:p.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:l("use"),onPrimary:m=>t(m.text),children:[p.map(({question:m,answer:f},h)=>Re(I.List,{children:Re(I.ListItem,{"data-testid":"knowledge-search-answer",index:h,description:f.answer,closeOnSelect:!0,onClick:()=>t(f.answer),onSourceClick:E=>u(E,m),sources:f.sources,styles:{title:a.question,description:a.answer},children:m})},`${f.answer}_${h}`)),d==="loading"&&Re("p",{className:a.status,children:l("loading")}),d==="error"&&Re("p",{className:a.status,children:l("error")}),xr("form",{className:a.form,onSubmit:g,children:[Re("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(-1)},onChange:m=>{r(-1),s(m.target.value)}}),Re("button",{type:"submit",className:a.submit,children:Re(ic,{})})]})]})]})},lc=Bf;import{createAsyncThunk as Ff,createSlice as Kf}from"@reduxjs/toolkit";var Uf={data:null,fetchState:"idle"},ze=t=>t.profile.data,Pn=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],uo=Ff("profile/getProfile",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=n.profile.data)==null?void 0:r.code)===s.profileCode?n.profile.data:o.getProfile(s.profileCode)}),zf=Kf({name:"profile",initialState:Uf,reducers:{},extraReducers:t=>{t.addCase(uo.pending,e=>{e.fetchState="loading"}).addCase(uo.rejected,e=>{e.fetchState="error"}).addCase(uo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),cc=zf.reducer;import{useEffect as jf}from"react";import{useDispatch as Vf}from"react-redux";import{useSelector as pc}from"react-redux";import{jsx as An,jsxs as Wf}from"react/jsx-runtime";var qf=({commands:t,onClick:e,onEdit:o})=>{var p,d,g;let n=Vf(),s=w(co),r=pc(ze),i=pc(Ke),a=((g=(d=(p=r==null?void 0:r.uiConfig)==null?void 0:p.search)==null?void 0:d.initialTypes)==null?void 0:g.filter(({isActive:u})=>u))||[],l=0,c=a.map(({type:u})=>{var m;return(m=i[u])==null?void 0:m.suggestions.map(f=>({text:f.text||f.url||f.message,type:u}))}).flat(1);return jf(()=>{a.forEach(({type:u})=>{(!i[u]||i[u].suggestions.length===0)&&n(pe(u))})},[]),Wf(I.ActionsBar,{list:[...t.map(u=>({text:u.label,type:"command"})),...c],primaryLabel:s("use"),secondaryLabel:s("preview"),onPrimary:({text:u},m)=>e(u,c[m]),onSecondary:(u,m)=>{let f=m-t.length;o(c[f],i[c[f].type].suggestions)},children:[t.length>0&&An(I.List,{heading:s("commands"),children:t.map((u,m)=>An(I.ListItem,{index:m,closeOnSelect:!1,onClick:u.onClick,children:u.label},u.label))}),a.map(({type:u,title:m})=>{var f;return An(I.List,{heading:m,orientation:"vertical",children:(f=i[u])==null?void 0:f.suggestions.map(h=>(l++,An(I.ListItem,{index:l+t.length-1,closeOnSelect:!1,description:h.text,onClick:()=>e(h.text,h),"data-testid":"search-overlay-suggestion",children:h.title},`${h.id}-${h.text}`)))},u)})]})},dc=qf;import{jsx as ee,jsxs as Cr}from"react/jsx-runtime";var Xf=200,Zf=5,Qf=4,Jf=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),uc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Yf=()=>{let t=Gf(),e=se(),o=w(co),[n,s]=go(!1),[r,i]=go(""),a=ot(Ua),l=ot(ze),[c,p]=go(null),[d,g]=go([]),[u,m]=go(),f=ot(Z),h=C("showSearch"),E=C("showEntitiesCommand"),_=C("showSummaryCommand"),x=C("showKnowledgeSearch"),b=C("showImageSearch"),v=C("searchTriggerKey"),R=ot(Bl),A=ot(za),H=ot(ja),N=ot(Ka),K=S=>To(A.filter(O=>O.type===S.toUpperCase()),S),k=[{value:"PERSONAL",label:o("personalSuggestions"),list:K("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:K("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:K("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:K("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(S=>S.shouldShow),B=[{label:o("entitiesClipboard"),onClick:()=>t(X("entities")),shouldShow:E&&uc(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(X("summary")),shouldShow:_&&uc(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(X("knowledgeAssist")),shouldShow:x}].filter(S=>S.shouldShow),ue=(R==null?void 0:R.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:K(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],cs=Ln($f((S,O)=>{t(Ye({query:S,type:O,tags:["search-overlay"],size:u?50:20}))},Xf),[u]),ct=Jf([...ue,...k]),ai=Ln((S,O)=>{t(X("edit")),p({...S,searchTerm:void 0}),g(O)},[t,c,ue]),wo=Ln((S,O)=>{switch(O.type){case"IMAGE":e.send(dr,{suggestion:O});break;default:e.send(ke,{text:S,suggestion:O})}t(G(!1))},[t]),vd=S=>{lo(S.text),t(W({name:"entity copied",data:{entity:S,type:"copy"}})),t(G(!1))},Sd=Ln(S=>{t(W({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),_d=S=>{e.send(ke,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(W({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(X("search")),t(Mt()),t(G(!1))},xd=S=>{lo(S),t(G(!1))},bd=S=>{e.send(ke,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(G(!1))},Cd=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),wd=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function To(S,O){return S.slice(0,u?10:O.toLowerCase()==="image"?Qf:Zf)}function li(S,O,re){return O.reduce((Eo,ko)=>re&&u===re?ko.length+Eo:To(ko,re).length+Eo,S)}function pt(S){return O=>{n?window.confirm(o("warning"))&&(S(O),s(!1)):S(O)}}return br(()=>{r?cs(r,u):t(vn())},[r,u]),br(()=>{a==="search"&&t(Mt())},[a]),br(()=>{f&&t(ao())},[f]),Kl(v,()=>t(G(!0))),!h||!l?null:Cr(I,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:pt(S=>t(G(S))),onChangeType:S=>m(S),onChangePage:pt(S=>t(X(S))),selectedType:u,search:r,page:a,isOpen:N,types:[...ue,...k],children:[Cr(I.Page,{id:"search",children:[r.length===0&&ee(dc,{commands:B,onClick:wo,onEdit:ai}),r.length>0&&Cr(I.ActionsBar,{list:[...B.map(S=>({text:S.label,type:"command"})),...ct.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},O)=>wo(S,ct[O]),onSecondary:(S,O)=>{let re=ct[O-B.length];!re||!re.type||ai(re,K(re.type))},children:[B.length>0&&ee(I.List,{heading:o("commands"),children:B.map((S,O)=>ee(I.ListItem,{index:li(O,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...ue,...k].map(({value:S,label:O,list:re,lineClamp:Eo,listOrientation:ko},Td)=>ee(I.List,{heading:O,orientation:ko==="horizontal"?"horizontal":"vertical",onShowAll:()=>m(S),hasMore:!u&&H[S.toLowerCase()]>To(re,S).length,children:To(re,S).map((ne,Ed)=>ee(I.ListItem,{index:li(B.length+Ed,[...ue,...k].slice(0,Td).map(({list:kd})=>kd),S),closeOnSelect:!1,lineClamp:Eo,onClick:()=>wo(ne.text,ne),description:S!=="IMAGE"?ne.title&&ne.text:void 0,onFeedback:S!=="IMAGE"?()=>Sd(ne):void 0,children:S==="IMAGE"?ee(I.Image,{title:ne.title||ne.text,src:ne.image}):ne.title||ne.text},`${ne.id}-${ne.text}`))},S))]})]}),ee(I.Page,{id:"edit",onDismiss:pt(()=>{t(X("search")),p(null)}),children:c&&ee(bn,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(X("search")),p(null),g([])},onNext:wd,onPrevious:Cd,onUse:S=>{t(X("search")),wo(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(G(!1)),g([]),p(null)}})}),ee(I.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:pt(()=>{t(X("search"))}),children:ee(ql,{onUse:bd,onCopy:vd})}),ee(I.Page,{id:"summary",title:o("summaryTitle"),onDismiss:pt(()=>{t(X("search"))}),children:ee(Jl,{onCopy:xd})}),ee(I.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:pt(()=>{t(Mt()),t(X("search"))}),children:ee(lc,{question:r,onUse:_d,onResetQuestion:()=>{t(Mt()),i("")}})})]})},gc=Yf;import{jsx as wr,jsxs as oh}from"react/jsx-runtime";var th=()=>{let t=C("showSearch"),e=C("isEmbedded");return oh(eh,{children:[t&&wr(gc,{}),wr(Al,{}),e&&wr(Hl,{})]})},mc=th;import ih from"classnames";import{useSelector as ah}from"react-redux";import{jsx as Tr}from"react/jsx-runtime";var fc=({className:t})=>Tr("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:Tr("g",{children:Tr("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
|
+
`,Ve.MISSING_INTL_API,i);var x=o.getPluralRules(e,{type:d.pluralType}).select(g-(d.offset||0));y=d.options[x]||d.options.other}if(!y)throw new gs(d.value,g,Object.keys(d.options),i);a.push.apply(a,zt(y.value,e,o,n,s,g-(d.offset||0)));continue}}return cu(a)}function pu(t,e){return e?ee(ee(ee({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=ee(ee({},t[n]),e[n]||{}),o},{})):t}function uu(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=pu(t[n],e[n]),o},ee({},t)):t}function ms(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function gu(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:zo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Ao([void 0],o,!1)))},{cache:ms(t.number),strategy:jo.variadic}),getDateTimeFormat:zo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Ao([void 0],o,!1)))},{cache:ms(t.dateTime),strategy:jo.variadic}),getPluralRules:zo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Ao([void 0],o,!1)))},{cache:ms(t.pluralRules),strategy:jo.variadic})}}var zi=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var d=r.formatToParts(c);if(d.length===1)return d[0].value;var p=d.reduce(function(g,u){return!g.length||u.type!==W.literal||typeof g[g.length-1]!="string"?g.push(u.value):g[g.length-1]+=u.value,g},[]);return p.length<=1?p[0]||"":p},this.formatToParts=function(c){return zt(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,l=Oi(i,["formatters"]);this.ast=t.__parse(e,ee(ee({},l),{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=uu(t.formats,n),this.formatters=s&&s.formatters||gu(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>"u")){var o=Intl.NumberFormat.supportedLocalesOf(e);return o.length>0?new Intl.Locale(o[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Hi,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 hu(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var yu="dummy",fs=mu(null);function E(t){let e=fu(fs);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let o=t[e]??{};return(n,s)=>{let r=hu(o,n);return r?new zi(r).format(s):(e!==yu&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}import{useEffect as vu,useRef as Su}from"react";var ji={root:"_root_1h19b_1",content:"_content_1h19b_24"};import{jsx as Vi}from"react/jsx-runtime";var _u=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,onKeyDown:r,overlayAriaLabel:i,contentAriaLabel:a})=>{let l=Su(null),c=h("Dialog",ji),d=g=>{if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),s();return}r&&r(g)},p=g=>{g.target===l.current&&t&&n()};return vu(()=>{var g,u;!l.current||!t||!e||(u=(g=l.current)==null?void 0:g.querySelector("input, textarea"))==null||u.focus()},[t,e,l]),t?Vi("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":i,ref:l,onKeyDown:d,onMouseDown:p,children:Vi("div",{"data-testid":"dialog-content",className:c.content,"aria-label":a,children:o})}):null},Vo=_u;import xu from"classnames";var qi={root:"_root_1ukx5_1"};import{jsx as wu}from"react/jsx-runtime";var bu=({className:t,value:e,...o})=>{let n=h("TextInput",qi);return wu("input",{className:xu(t,n.root),type:"text",value:e,...o})},jt=bu;var hs={};Z(hs,{enUS:()=>Cu,nlNL:()=>Tu});var Cu={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"}]},Tu={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 $i={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};import{jsx as Q,jsxs as qo}from"react/jsx-runtime";var Pu=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Au=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(hs),i=h("LoginTokenDialog",$i),a=Ru(qr),l=Iu(),c=b("productName"),[d,p]=vs(t||""),[g,u]=vs(0),[f,m]=vs(""),v=Wi(async x=>{x.preventDefault(),l(Wr({email:d})),u(1)},[o,d]),T=()=>{m(""),u(0)},_=Wi(async x=>{x.preventDefault();let S=Pu(x.target.elements.token.value);if(!S){m(r("verifyCodeError",{login:y}));return}l(Ot({token:S}))},[o]),y=ku(()=>x=>Q("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:T,children:x},"back-button"),[]);return Eu(()=>{a==="error"&&m(r("verifyCodeError",{login:y})),a==="done"&&n()},[a]),Q(Vo,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:qo("div",{className:i.root,children:[Q("h1",{className:i.title,children:r("promptTitle",{productName:c})}),g===0&&qo("form",{onSubmit:v,children:[Q("h2",{className:i.subtitle,children:r("requestCodeTitle")}),Q("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),Q(jt,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:d,onChange:x=>p(x.target.value)}),Q("div",{className:i.actions,children:Q("button",{type:"submit",className:ys(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),g===1&&qo("form",{onSubmit:_,children:[Q("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),Q("p",{className:i.text,children:r("verifyCodeBody")}),Q(jt,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&Q("div",{className:i.errorMessage,children:f}),qo("div",{className:i.actions,children:[Q("button",{type:"button",className:ys(i.button),onClick:T,children:r("back")}),Q("button",{type:"submit",className:ys(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Gi=Au;import{jsx as Mu}from"react/jsx-runtime";var Lu=()=>{let t=Xi($r),e=Xi(hi),o=b("adminUrl"),n=de(),s=()=>n.send(dt,!1),r=()=>{n.send(dt,!1),n.send(Ft)};return Mu(Gi,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Zi=Lu;import Tm from"lodash.debounce";import{Fragment as Em,useCallback as Bs,useEffect as Ks,useState as Us}from"react";import{useDispatch as km,useSelector as We}from"react-redux";import{createAsyncThunk as Ou,createSlice as Nu}from"@reduxjs/toolkit";var Du={data:null,fetchState:"idle"},Qi=t=>t.contentTypes.data,Vt=Ou("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Hu=Nu({name:"contentTypes",initialState:Du,reducers:{},extraReducers:t=>{t.addCase(Vt.pending,e=>{e.fetchState="loading"}).addCase(Vt.rejected,e=>{e.fetchState="error"}).addCase(Vt.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Ji=Hu.reducer;function qt(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}import{useEffect as _a,useState as xg,useRef as bg,useCallback as wg}from"react";import{useState as Ku}from"react";import Ss from"classnames";var oe={root:"_root_1xtw7_1",list:"_list_1xtw7_2",listWrapper:"_listWrapper_1xtw7_6",listHorizontal:"_listHorizontal_1xtw7_10",page:"_page_1xtw7_19",search:"_search_1xtw7_25",pageNav:"_pageNav_1xtw7_33",pageTitle:"_pageTitle_1xtw7_41",pageBackButton:"_pageBackButton_1xtw7_48",listHeader:"_listHeader_1xtw7_62",listHeading:"_listHeading_1xtw7_68",listMoreButton:"_listMoreButton_1xtw7_76",listItem:"_listItem_1xtw7_87",listItemContent:"_listItemContent_1xtw7_96",listItemText:"_listItemText_1xtw7_114",listItemDescription:"_listItemDescription_1xtw7_122",listItemActions:"_listItemActions_1xtw7_129",truncate:"_truncate_1xtw7_140",lineClamp:"_lineClamp_1xtw7_146",listItemTitle:"_listItemTitle_1xtw7_153",listItemAction:"_listItemAction_1xtw7_129",listItemPrimaryAction:"_listItemPrimaryAction_1xtw7_178",listItemSelected:"_listItemSelected_1xtw7_183",sources:"_sources_1xtw7_187",sourcesTitle:"_sourcesTitle_1xtw7_194",source:"_source_1xtw7_187",icon:"_icon_1xtw7_209",searchIcon:"_searchIcon_1xtw7_226",searchInputWrapper:"_searchInputWrapper_1xtw7_231",searchInput:"_searchInput_1xtw7_231",select:"_select_1xtw7_252",selectType:"_selectType_1xtw7_269",selectWrapper:"_selectWrapper_1xtw7_273",image:"_image_1xtw7_303",imageSrc:"_imageSrc_1xtw7_310",imageSrcHidden:"_imageSrcHidden_1xtw7_321",imageSrcStatus:"_imageSrcStatus_1xtw7_325",imageTitle:"_imageTitle_1xtw7_335",actions:"_actions_1xtw7_340",actionsWrapper:"_actionsWrapper_1xtw7_344",actionsBar:"_actionsBar_1xtw7_350",actionButton:"_actionButton_1xtw7_359",hasShortKeys:"_hasShortKeys_1xtw7_372",actionShortcut:"_actionShortcut_1xtw7_381",actionShortcutFixKerning:"_actionShortcutFixKerning_1xtw7_388"};var qe={};Z(qe,{enUS:()=>Fu,nlNL:()=>Bu});var Fu={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"}]},Bu={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"}]};import{jsx as $t,jsxs as zu}from"react/jsx-runtime";var Uu=({src:t,title:e})=>{let o=h("CommandPalette",oe),[n,s]=Ku("loading"),r=E(qe);return zu("div",{className:o.image,children:[$t("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:Ss(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&$t("span",{className:Ss(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&$t("span",{className:Ss(o.imageSrc,o.imageSrcStatus),children:$t(uo,{})}),e&&$t("span",{className:o.imageTitle,children:e})]})},Yi=Uu;import ju from"react";import Vu from"classnames";import{jsx as _s,jsxs as ea}from"react/jsx-runtime";function xs({children:t,heading:e,orientation:o,hasMore:n,onShowAll:s}){let r=E(qe),i=h("CommandPalette",oe);return ju.Children.count(t)===0?null:ea("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||n)&&ea("div",{className:i.listHeader,children:[e&&_s("h4",{className:i.listHeading,children:e}),n&&s&&_s("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),_s("div",{className:Vu(i.listWrapper,o==="horizontal"&&i.listHorizontal),children:t})]})}import Go from"classnames";import{Interweave as gg}from"interweave";var qu=/[.*+?^${}()|[\]\\]/g,$u=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Wu(t){return t.replace(qu,"\\$&")}function Gu(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function Xu(t){return t.search($u)}function ta(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${Wu(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function oa(t){return t.replace(fo,'<mark data-type="placeholder">$1</mark>')}function Wt(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Zu(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 bs(t,e,o={}){if(e){let n=Gu(e.toLowerCase(),t.toLowerCase()),s=Wt(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=Xu(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Kr).length>3||e.length>30?Zu(e.trim(),n):0;return`${`${i>0?"\u2026":""}${Wt(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var Qu=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function ws(t){return Qu.test(t)}function na(t){let e=document.createElement("template");return e.innerHTML=t,e.content.textContent??""}import Ju,{useState as sa,useEffect as ra,useMemo as Yu,useRef as ia,useCallback as eg,useContext as tg}from"react";import og from"classnames";var Cs={root:"_root_1oh4w_1",trigger:"_trigger_1oh4w_5",content:"_content_1oh4w_19",contentOpen:"_contentOpen_1oh4w_33",contentTop:"_contentTop_1oh4w_37",contentBottom:"_contentBottom_1oh4w_41",item:"_item_1oh4w_45"};import{jsx as $o,jsxs as ig}from"react/jsx-runtime";var ng=0,aa=Ju.createContext(null),sg=()=>{let t=tg(aa);if(!t)throw new Error("Invalid DropdownContext");return t},la=({trigger:t,children:e,position:o="bottom"})=>{let n=Yu(()=>++ng,[]),s=ia(null),r=ia(null),i=h("Dropdown",Cs),[a,l]=sa(!1),[c,d]=sa(o),p=u=>{u.preventDefault(),u.stopPropagation(),l(!a)},g=eg(([u])=>{!u.isIntersecting&&a&&d(c==="top"?"bottom":"top")},[a]);return ra(()=>{let u=f=>{s.current&&!s.current.contains(f.target)&&l(!1)};return document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}},[]),ra(()=>{if(!r.current&&!a)return()=>{};let u=new IntersectionObserver(g,{root:null,rootMargin:"0px",threshold:1});return r.current&&u.observe(r.current),()=>{r.current&&u.unobserve(r.current)}},[r,a]),$o(aa.Provider,{value:{setIsOpen:l},children:ig("div",{ref:s,className:i.root,children:[$o("button",{id:`dropdown-${n}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:i.trigger,onClick:p,children:t}),$o("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:og(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function rg({as:t,children:e,onClick:o,...n}){let s=t||"button",r=h("Dropdown",Cs),{setIsOpen:i}=sg(),a=l=>{i(!1),o(l),l.stopPropagation()};return $o(s,{type:"button",className:r.item,onClick:a,...n,children:e})}la.Item=rg;var Ts=la;import{jsx as ca}from"react/jsx-runtime";var da=t=>ca("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:ca("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 $e={};Z($e,{enUS:()=>ag,nlNL:()=>lg});var ag={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"}]},lg={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"}]};import{jsx as Es}from"react/jsx-runtime";var cg="%0d%0a%0d%0a%0d%0a",dg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(cg)}`},pg=({suggestion:t,onFeedback:e})=>{let o=E($e),n=b("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:Es(Ts,{trigger:Es(da,{"data-testid":"feedback-dropdown-trigger"}),children:Es(Ts.Item,{as:"a",href:dg(n,t),onClick:e,children:o("giveFeedback")})})},Wo=pg;import ks from"react";import{jsx as ug}from"react/jsx-runtime";var pa=ks.createContext(void 0);function Le(){let t=ks.useContext(pa);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var ua=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=ks.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return ug(pa.Provider,{value:i,children:t})};import{jsx as Me,jsxs as Is}from"react/jsx-runtime";function Rs({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,description:i,sources:a,id:l,styles:c,...d}){let{selected:p,onChangeOpen:g}=Le(),u=h("CommandPalette",oe);function f(m){n(m),t&&g(!1)}return Is("div",{className:Go(u.listItem,l===p&&u.listItemSelected),children:[Me("button",{type:"button",className:Go(u.listItemAction,u.listItemPrimaryAction),"aria-disabled":d.disabled??!1,onClick:f,"data-command-palette-item":!0,"data-item-id":l,...d,children:Is("div",{className:u.listItemContent,children:[typeof o=="string"?Me("p",{className:Go(u.listItemText,u.truncate,c==null?void 0:c.title),children:o}):o,i&&Me(gg,{tagName:"p",allowList:[],content:ws(i)?na(i):i,className:Go(u.listItemDescription,c==null?void 0:c.description,e?u.lineClamp:u.truncate)})]})}),s&&Me("div",{className:u.listItemActions,children:Me(Wo,{suggestion:String(o),onFeedback:s})}),a&&Is("div",{className:u.sources,children:[Me("span",{className:u.sourcesTitle,children:"Sources"}),a.map(m=>m.url?Me("a",{className:u.source,href:m.url,target:"_blank",title:m.url,rel:"noopener noreferrer",onClick:()=>r&&r(m),children:m.name},m.url):Me("span",{className:u.source,children:m.name},m.name))]})]})}import{jsx as ga,jsxs as mg}from"react/jsx-runtime";var ma=()=>mg("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[ga("title",{id:"angleLeftTitle",children:"AngleLeft"}),ga("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});import{jsx as fa,jsxs as Ps}from"react/jsx-runtime";function As({children:t,title:e,id:o,onDismiss:n}){let s=E(qe),r=h("CommandPalette",oe),{page:i}=Le();return i!==o?null:Ps("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&Ps("div",{className:r.pageNav,children:[Ps("button",{className:r.pageBackButton,type:"button",onClick:n,children:[fa(ma,{}),s("back")]}),e&&fa("h3",{className:r.pageTitle,children:e})]}),t]})}import{forwardRef as hg}from"react";import{jsx as ha,jsxs as fg}from"react/jsx-runtime";var ut=()=>fg("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[ha("path",{d:"M0 0h24v24H0z",fill:"none"}),ha("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});import{jsx as gt,jsxs as Ls}from"react/jsx-runtime";function yg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=h("CommandPalette",oe);return Ls("div",{className:l.search,children:[gt("div",{className:l.searchIcon,children:gt(ut,{})}),Ls("div",{className:l.searchInputWrapper,children:[gt("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&>("div",{className:l.selectWrapper,children:Ls("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&>("option",{children:n}),s.map(c=>gt("option",{value:c.value,children:c.label},c.value))]})})]})]})}var ya=hg(yg);import va from"classnames";import{jsx as Sg,jsxs as _g}from"react/jsx-runtime";var vg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=h("CommandPalette",oe);return _g("button",{type:"button",...n,onClick:t,className:va(s.actionButton,n.className,{[s.hasShortKeys]:e&&e.length>0}),children:[o,e&&e.map(r=>Sg("span",{className:va(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},Sa=vg;import{jsx as xa,jsxs as Tg}from"react/jsx-runtime";var Cg="[data-command-palette-item]";function mt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:d,isOpen:p,search:g}){let[u,f]=xg(),m=bg(null),v=()=>{s&&s(o),i(void 0),r(""),a(!1)},T=()=>{var I;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(I=m.current)==null||I.focus();return}if(g.length>0){r("");return}a(!1)},_=()=>{let I=y();I.length!==0&&f(I[0].dataset.itemId)},y=()=>Array.from(document.querySelectorAll(Cg)||[]),x=I=>document.querySelector(`[data-item-id=${I}]`),S=I=>{let A=x(I);A&&f(A.dataset.itemId)},O=I=>{let A=x(I);A&&A.scrollIntoView({behavior:"smooth"})},F=()=>{if(!u)return;let I=y(),A=x(u);if(!A)return;let k=I.indexOf(A),V=I[k+1];V&&V.dataset.itemId?S(V.dataset.itemId):_()},K=()=>{if(!u)return;let I=y(),A=x(u);if(!A)return;let k=I.indexOf(A),V=I[k-1];V&&V.dataset.itemId?S(V.dataset.itemId):S(I[I.length-1].dataset.itemId)},H=wg(I=>{switch(I.key){case"ArrowDown":{I.preventDefault(),F();break}case"ArrowUp":{I.preventDefault(),K();break}case"Enter":{if(u){let A=x(u);A==null||A.click()}break}}},[u]);return _a(()=>{_()},[g,n,l,p]),_a(()=>{u&&O(u)},[u]),xa(Vo,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:T,onClose:v,onKeyDown:H,children:Tg(ua,{selected:u,setSelected:f,isOpen:p,onChangeOpen:a,page:n,children:[n===o&&xa(ya,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:g,selectedType:l,types:c,typePlaceholder:e}),d]})})}mt.Page=As;mt.List=xs;mt.Image=Yi;mt.ListItem=Rs;mt.Button=Sa;var D=mt;import{useEffect as Eg}from"react";function ba(t,e){Eg(()=>{let o=n=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?n.metaKey:n.ctrlKey)&&n.key===t&&(n.preventDefault(),n.stopPropagation(),e())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o)}},[])}import{useEffect as Ea,useRef as Mg}from"react";import{useSelector as Og,useDispatch as Ng}from"react-redux";import{createAsyncThunk as kg,createSlice as Ig}from"@reduxjs/toolkit";var wa={data:null,fetchState:"idle"},Xo=t=>{var r;let e=[],{visitorName:o}=t.info.visitorInfo??{},{agentName:n,agentNickname:s}=t.info.agentInfo??{};return n&&n!==o&&e.push(n),s&&s!==o&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},ae=kg("entities/getEntities",async(t,e)=>{let{deepdeskAPI:o,dynamicThunkObject:n}=e.extra;if(!n.conversationQuery)return Promise.resolve([]);let s=n.conversationQuery,r=await s();return r.length===0?Promise.resolve([]):o.getEntities(r)}),Rg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Pg=Ig({name:"entities",initialState:wa,reducers:{},extraReducers:t=>{t.addCase(ae.pending,e=>{e.fetchState="loading"}).addCase(ae.rejected,e=>{e.fetchState="error"}).addCase(ae.fulfilled,(e,o)=>{e.fetchState="done",e.data=Rg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(M,()=>wa)}}),Ca=Pg.reducer;var Ms={};Z(Ms,{enUS:()=>Ag,nlNL:()=>Lg});var Ag={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Lg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Ta={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as Os,jsxs as Hg}from"react/jsx-runtime";var Dg=({onCopy:t})=>{let e=Mg(null),o=h("EntitiesList",Ta),n=Og(Xo),{setSelected:s}=Le(),r=E(Ms),i=Ng();return Ea(()=>{i(ae())},[]),Ea(()=>{e.current&&(e.current.focus(),s("entity-0"))},[e]),Hg("div",{className:o.root,ref:e,tabIndex:-1,children:[n&&n.length>0&&Os(D.List,{children:n.map((a,l)=>Os(D.ListItem,{id:`entity-${l}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),n&&n.length===0&&Os("p",{className:o.empty,children:r("noResults")})]})},ka=Dg;import{Fragment as jg,useEffect as Zo,useRef as Vg,useState as qg}from"react";import{useSelector as Ma,useDispatch as $g}from"react-redux";import{createAsyncThunk as Fg,createSlice as Bg}from"@reduxjs/toolkit";var Ia={data:null,fetchState:"idle"},Ra=t=>t.summary.data,Pa=t=>t.summary.fetchState==="error",_e=Fg("summary/getSummary",async(t,e)=>{var d,p,g;let o=e.getState().profile.data,n=(d=e.getState().conversation.current)==null?void 0:d.sessionId,s=(g=(p=e.getState().info)==null?void 0:p.agentInfo)==null?void 0:g.agentId;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:i}=e.extra;if(!i.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let a=i.conversationQuery,l=await a();if(l.length===0)return Promise.reject(new Error("No messages are included"));let c=await r.getSummary(l,{externalConversationId:n,agentId:s,promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return c?{summary:c}:Promise.reject(new Error("Summary is not provided"))}),Kg=Bg({name:"summary",initialState:Ia,reducers:{},extraReducers:t=>{t.addCase(_e.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(_e.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(_e.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(M,()=>Ia)}}),Aa=Kg.reducer;var Ns={};Z(Ns,{enUS:()=>Ug,nlNL:()=>zg});var Ug={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},zg={copy:[{type:0,value:"Kopieer"}],error:[{type:0,value:"Kon helaas geen samenvatting genereren."}],loading:[{type:0,value:"Samenvatting wordt gemaakt, dit kan even duren."}]};var La={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};import{jsx as ft,jsxs as Gg}from"react/jsx-runtime";var Wg=({onCopy:t})=>{let e=Vg(null),o=h("SummaryForm",La),[n,s]=qg(""),r=E(Ns),i=Ma(Ra),a=Ma(Pa),l=$g(),c=()=>{l($({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},d=()=>{let p=document.getSelection();p&&l($({name:"summary copied to clipboard",data:{originalText:i,finalText:p==null?void 0:p.toString()},options:{includeConversationData:!0}}))};return Zo(()=>{l(_e())},[]),Zo(()=>{s(i||"")},[i]),Zo(()=>{e.current&&i&&e.current.focus()},[e,i]),Zo(()=>{let p=g=>{g.key==="Enter"&&g.shiftKey&&c()};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[n]),ft("div",{className:o.root,tabIndex:-1,children:a?ft("p",{className:o.error,children:r("error")}):Gg(jg,{children:[ft("div",{className:o.main,children:ft("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:d,onChange:p=>s(p.target.value)})}),ft("div",{className:o.actions,children:ft(D.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Oa=Wg;var Gt={};Z(Gt,{enUS:()=>Xg,nlNL:()=>Zg});var Xg={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link 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"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},Zg={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link 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"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};import lm,{useEffect as Fs,useRef as cm}from"react";import{useDispatch as dm,useSelector as ja}from"react-redux";var Ds={};Z(Ds,{enUS:()=>Qg,nlNL:()=>Jg});var Qg={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},Jg={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var Na={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};import{createAction as nm,createAsyncThunk as sm,createSlice as rm}from"@reduxjs/toolkit";import{createAsyncThunk as Yg,createSlice as em}from"@reduxjs/toolkit";var tm={data:null,fetchState:"idle"},Da=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},Xt=Yg("knowledgeAssistant/getKnowledgeAssistant",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=(i=n.profile.data)==null?void 0:i.knowledgeAssistant;return r?o.getKnowledgeAssistant(r):null}),om=em({name:"knowledgeAssistant",initialState:tm,reducers:{},extraReducers:t=>{t.addCase(Xt.pending,e=>{e.fetchState="loading"}).addCase(Xt.rejected,e=>{e.fetchState="error"}).addCase(Xt.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Ha=om.reducer;var Hs={data:[],fetchState:"idle"},Fa=t=>{var e;return(e=t.answer)==null?void 0:e.data},Ba=t=>t.answer.fetchState,yt=nm("answer/resetKnowledgeSearch"),ht=sm("answer/getAnswer",async(t,e)=>{var l,c,d;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=Da(e.getState()),r=(l=e.getState().conversation.current)==null?void 0:l.sessionId,i=(d=(c=e.getState().info)==null?void 0:c.agentInfo)==null?void 0:d.agentId;if(!s)throw new Error("KnowledgeAssistant is not defined");let a=await o.knowledgeAssist({promptInstruction:s.prompt,question:t},n,s.code,{agentId:i,conversationId:r});return{question:t,answer:a}}),im=rm({name:"answer",initialState:Hs,reducers:{},extraReducers:t=>{t.addCase(ht.pending,e=>{e.fetchState="loading"}).addCase(ht.rejected,e=>{e.fetchState="error"}).addCase(ht.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(M,()=>Hs).addCase(yt,()=>Hs)}}),Ka=im.reducer;import{jsx as Ua,jsxs as am}from"react/jsx-runtime";var za=()=>am("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[Ua("title",{id:"paperPlaneTitle",children:"PaperPlane"}),Ua("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});import{jsx as xe,jsxs as Va}from"react/jsx-runtime";var pm=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=lm.useState(""),{setSelected:r}=Le(),i=cm(null),a=h("EntitiesList",Na),l=E(Ds),c=dm(),d=ja(Fa),p=ja(Ba),g=async f=>{f.preventDefault(),f.stopPropagation(),n!==""&&c(ht(n))},u=(f,m)=>{c($({name:"knowledge assist source viewed",data:{question:m,sourceViewed:f.url||f.name},options:{includeConversationData:!0}}))};return Fs(()=>{var f;o&&p==="idle"?c(ht(o)):(f=i.current)==null||f.focus()},[i,p]),Fs(()=>{p==="done"&&(c($({name:"knowledge assist question answered",data:{question:n||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),r(`knowledge-assist-${d.length-1}`),s(""))},[p,d]),Fs(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,d]),Va("div",{className:a.root,children:[d.length>0&&xe("div",{className:a.alignRight,children:xe(D.Button,{onClick:e,children:l("reset")})}),d.map(({question:f,answer:m},v)=>xe(D.List,{children:xe(D.ListItem,{id:`knowledge-assist-${v}`,"data-testid":"knowledge-search-answer",description:m.answer,closeOnSelect:!0,onClick:()=>t(m.answer),onSourceClick:T=>u(T,f),sources:m.sources,styles:{title:a.question,description:a.answer},children:f})},`${m.answer}_${v}`)),p==="loading"&&xe("p",{className:a.status,children:l("loading")}),p==="error"&&xe("p",{className:a.status,children:l("error")}),Va("form",{className:a.form,onSubmit:g,children:[xe("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(void 0)},onChange:f=>{r(void 0),s(f.target.value)}}),xe("button",{type:"submit",className:a.submit,children:xe(za,{})})]})]})},qa=pm;import{createAsyncThunk as um,createSlice as gm}from"@reduxjs/toolkit";var mm={data:null,fetchState:"idle"},Oe=t=>t.profile.data,Qo=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],Zt=um("profile/getProfile",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=n.profile.data)==null?void 0:r.code)===s.profileCode?n.profile.data:o.getProfile(s.profileCode)}),fm=gm({name:"profile",initialState:mm,reducers:{},extraReducers:t=>{t.addCase(Zt.pending,e=>{e.fetchState="loading"}).addCase(Zt.rejected,e=>{e.fetchState="error"}).addCase(Zt.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),$a=fm.reducer;import{useEffect as _m}from"react";import{useDispatch as xm}from"react-redux";import{createAction as vm,createAsyncThunk as Za,createSlice as Sm}from"@reduxjs/toolkit";var hm=["{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}"],ym=new RegExp(hm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Wa(t,e){let o=t.split(ym),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let p=a.charAt(0),g=0;do c=p?e.indexOf(p,c+1):-1,g+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&g>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let d=c===-1?e.slice(n):e.slice(n,c);s.push(d),n=c}return s.join("")}function Ga(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Qa={suggestions:[],fetchState:"idle",isInitialRequest:null},Xa={default:Qa},Ja=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},Ya=t=>{let e=Object.keys(t.textSuggestions).map(o=>{var n;return(n=t.textSuggestions[o])==null?void 0:n.fetchState});return e.length===0?!0:e.every(o=>o!=="done")},Jo=t=>t.textSuggestions,el=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},Yo=vm("textSuggestions/refresh"),le=Za("textSuggestions/recommendations",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,inlineSuggestions:i}=n.settings,a=ct(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Ht(n),t);if(t==="default"){let d=i?l.filter(el(a)):l;e.dispatch(ce(d.slice(0,r)))}return l}),Qt=Za("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getAutocompleteSuggestions(s,{...Ht(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(el(t))),i&&(l=l.map(d=>({...d,text:d.source!=="trie-with-typos"?Wa(d.text,t):d.text}))),l=Ga(l,r),e.dispatch(ce(l)),l}),tl=Sm({name:"textSuggestions",initialState:Xa,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:o}=e.payload;t[o].fetchState="done",t[o].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}},setSuggestionState(t,e){return e.payload}},extraReducers:t=>{t.addCase(le.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Qa;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(le.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(le.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Qt.pending,e=>{e.default.fetchState="loading"}).addCase(Qt.rejected,e=>{e.default.fetchState="error"}).addCase(Qt.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(M,()=>Xa)}}),{setTextSuggestions:N0,setSuggestionState:D0}=tl.actions,ol=tl.reducer;import{useSelector as nl}from"react-redux";import{jsx as en,jsxs as wm}from"react/jsx-runtime";var bm=({commands:t,onClick:e})=>{var a,l,c;let o=xm(),n=E(Gt),s=nl(Oe),r=nl(Jo),i=((c=(l=(a=s==null?void 0:s.uiConfig)==null?void 0:a.search)==null?void 0:l.initialTypes)==null?void 0:c.filter(({isActive:d})=>d))||[];return _m(()=>{i.forEach(({type:d})=>{(!r[d]||r[d].suggestions.length===0)&&o(le(d))})},[]),wm("div",{children:[t.length>0&&en(D.List,{heading:n("commands"),children:t.map((d,p)=>en(D.ListItem,{id:`command-${p}`,closeOnSelect:!1,onClick:d.onClick,children:d.label},d.label))}),i.map(({type:d,title:p})=>{var g;return en(D.List,{heading:p,orientation:"vertical",children:(g=r[d])==null?void 0:g.suggestions.map((u,f)=>en(D.ListItem,{id:`${d}-${f}`,closeOnSelect:!1,description:u.text,onClick:()=>e(u.text,u),"data-testid":"search-overlay-suggestion",children:u.title},`${u.id}-${u.text}`))},d)})]})},sl=bm;import{jsx as ne,jsxs as zs}from"react/jsx-runtime";var Im=200,Rm=5,Pm=4,rl=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Am=()=>{let t=km(),e=de(),o=E(Gt),[n,s]=Us(!1),[r,i]=Us(""),a=We(xi),l=We(Oe),[c,d]=Us(),p=We(G),g=b("showSearch"),u=b("showEntitiesCommand"),f=b("showSummaryCommand"),m=b("showKnowledgeSearch"),v=b("showImageSearch"),T=b("searchTriggerKey"),_=We(Qi),y=We(bi),x=We(wi),S=We(_i),O=w=>et(y.filter(q=>q.type===w.toUpperCase()),w),F=[{value:"PERSONAL",label:o("personalSuggestions"),list:O("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:O("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:O("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:O("IMAGE"),listOrientation:"horizontal",shouldShow:v}].filter(w=>w.shouldShow),K=[{label:o("entitiesClipboard"),onClick:()=>t(re("entities")),shouldShow:u&&rl(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(re("summary")),shouldShow:f&&rl(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(re("knowledgeAssist")),shouldShow:m}].filter(w=>w.shouldShow),H=(_==null?void 0:_.map(w=>({value:w.code.toUpperCase(),label:`${w.name}s`,list:O(w.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],I=Bs(Tm((w,q)=>{t(ze({query:w,type:q,tags:["search-overlay"],size:c?50:20}))},Im),[c]),A=Bs((w,q)=>{switch(q.type){case"IMAGE":e.send(as,{suggestion:q});break;default:e.send(pt,{text:w,suggestion:q})}t(Y(!1))},[t]),k=w=>{qt(w.text),t($({name:"entity copied",data:{entity:w,type:"copy"}})),t(Y(!1))},V=Bs(w=>{t($({name:"suggestion feedback",data:{text:w.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),Bn=w=>{e.send(pt,{text:w,suggestion:{source:"knowledge-assist",text:w}}),t($({name:"answer used",data:{originalText:w},options:{includeConversationData:!0}})),i(""),t(re("search")),t(yt()),t(Y(!1))},Kn=w=>{qt(w),t(Y(!1))};function et(w,q){return w.slice(0,c?10:q.toLowerCase()==="image"?Pm:Rm)}function Ke(w){return q=>{n?window.confirm(o("warning"))&&(w(q),s(!1)):w(q)}}return Ks(()=>{r?I(r,c):t(Po())},[r,c]),Ks(()=>{a==="search"&&t(yt())},[a]),Ks(()=>{p&&t(Vt())},[p]),ba(T,()=>t(Y(!0))),!g||!l?null:zs(D,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Ke(w=>t(Y(w))),onChangeType:w=>d(w),onChangePage:Ke(w=>t(re(w))),selectedType:c,search:r,page:a,isOpen:S,types:[...H,...F],children:[zs(D.Page,{id:"search",children:[r.length===0&&ne(sl,{commands:K,onClick:A}),r.length>0&&zs(Em,{children:[K.length>0&&ne(D.List,{heading:o("commands"),children:K.map((w,q)=>ne(D.ListItem,{closeOnSelect:!1,onClick:w.onClick,id:`commands-${q}`,children:w.label},w.label))}),[...H,...F].map(({value:w,label:q,list:Pr,lineClamp:Hd,listOrientation:Fd})=>ne(D.List,{heading:q,orientation:Fd==="horizontal"?"horizontal":"vertical",onShowAll:()=>d(w),hasMore:!c&&x[w.toLowerCase()]>et(Pr,w).length,children:et(Pr,w).map(J=>ne(D.ListItem,{id:`${w}-${J.id}`,closeOnSelect:!1,lineClamp:Hd,onClick:()=>A(J.text,J),description:w!=="IMAGE"?J.title&&J.text:void 0,onFeedback:w!=="IMAGE"?()=>V(J):void 0,children:w==="IMAGE"?ne(D.Image,{title:J.title||J.text,src:J.image}):J.title||J.text},`${J.id}-${J.text}`))},w))]})]}),ne(D.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:Ke(()=>{t(re("search"))}),children:ne(ka,{onCopy:k})}),ne(D.Page,{id:"summary",title:o("summaryTitle"),onDismiss:Ke(()=>{t(re("search"))}),children:ne(Oa,{onCopy:Kn})}),ne(D.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:Ke(()=>{t(yt()),t(re("search"))}),children:ne(qa,{question:r,onUse:Bn,onResetQuestion:()=>{t(yt()),i("")}})})]})},il=Am;import{jsx as al,jsxs as Om}from"react/jsx-runtime";var Mm=()=>{let t=b("showSearch"),e=b("isEmbedded");return Om(Lm,{children:[t&&al(il,{}),e&&al(Zi,{})]})},ll=Mm;import Fm from"classnames";import{useSelector as Bm}from"react-redux";import{jsx as js}from"react/jsx-runtime";var cl=({className:t})=>js("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:js("g",{children:js("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
4
4
|
c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
|
|
5
5
|
c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
|
|
6
6
|
c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
|
|
7
|
-
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});import{jsx as hc}from"react/jsx-runtime";var nh={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},yc=({className:t,color:e})=>hc("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:hc("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:nh[e||"pink"]})});var vc={root:"_root_1tvv4_1",text:"_text_1tvv4_18",isLoggedIn:"_isLoggedIn_1tvv4_25",isLoggedOut:"_isLoggedOut_1tvv4_29",icon:"_icon_1tvv4_39",logo:"_logo_1tvv4_44",lock:"_lock_1tvv4_49"};var Er={};q(Er,{enUS:()=>sh,nlNL:()=>rh});var sh={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},rh={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};import{useDispatch as lh}from"react-redux";import{jsx as kr,jsxs as Sc}from"react/jsx-runtime";var _c=({onLogIn:t})=>{let e=w(Er),o=C("floatingMenu"),n=C("productName"),s=lh(),r=ah(Z),i=y("FloatingMenu",vc);if(r===null||o===!1)return null;let a=()=>{r===!0?s(G(!0)):t()};return Sc("button",{className:ih(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[kr("div",{className:i.text,children:e(r?"search":"signin",{productName:n})}),Sc("div",{className:i.icon,children:[kr(yc,{className:i.logo,color:"pink"}),r===!1&&kr(fc,{className:i.lock})]})]})};import{useEffect as Th,useRef as Eh}from"react";import{connect as kh,useDispatch as Ih,useSelector as On}from"react-redux";function Nt(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:o,showSuggestionsAfterPattern:n}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?o&&new RegExp(o).test(s.substring(r.end))||n&&new RegExp(n).test(s.substring(0,r.end))?!0:o===!1&&n===!1:!1}import{Fragment as bh,useMemo as Ch}from"react";import{Interweave as dh}from"interweave";import{useEffect as uh,useMemo as gh,useRef as mh}from"react";import{useDispatch as fh,useSelector as hh}from"react-redux";import{useEffect as ch}from"react";function xc(t,e,o){ch(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var bc={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};import{jsx as Mn,jsxs as xh}from"react/jsx-runtime";var yh=["search","personal-collection-search","search-autocomplete"];function vh(t,e,o,n={}){let s="";return yh.includes(e)?s=ya(Us(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Us(t,o,n),n.placeholders===!0&&(s=va(s)),s}var Sh=()=>{},_h=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=hh(vt),i=fh(),a=y("TextSuggestion",bc),l=mh(null);uh(()=>{let p=setTimeout(()=>{i(Pi({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),xc(l,"click",()=>{i(Oe(t)),i(ae({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=gh(()=>vh(o.text,o.source,r,{stripAgentPart:s,placeholders:!0,searchKeywords:o.searchKeywords}),[s,o.text,o.source,r,o.searchKeywords]);return o.source==="gpt"&&!s?null:xh("div",{className:a.root,onMouseEnter:()=>i(Oe(t)),children:[Mn(D,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Sh,children:Mn(dh,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&Mn("div",{className:a.actions,children:Mn(fn,{onFeedback:()=>n(o),suggestion:o.text})})]})},Cc=_h;import{jsx as wc}from"react/jsx-runtime";var wh=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=Ch(()=>{let r=e.map((i,a)=>wc(Cc,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return wc(bh,{children:s})},Nn=wh;var Tc={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};import{jsx as Dn}from"react/jsx-runtime";var Rh=({textSuggestions:t,selectedIndex:e})=>{let o=Eh(null),n=y("InlineSuggestionsOverlay",Tc),s=On(Nt),r=Ih(),i=On(Z),a=On(yt),l=On(Tn),c=C("showTextSuggestions");return xt(()=>{r(Ue({collapse:!0,skipWhenInputFocus:!0}))}),Th(()=>{let p=o.current;if(!p||!p.parentElement)return;p.parentElement.style.left="0px";let d=p.getBoundingClientRect();p.parentElement.style.left=`${Math.min(window.innerWidth-4-d.right,0)}px`}),l||!s||!c||t.length===0||i!==!0||a===!1?null:Dn("div",{className:n.root,"data-variant":"inline",children:Dn("div",{ref:o,className:n.paper,children:Dn(ie,{children:Dn(Nn,{suggestions:t,selectedIndex:e})})})})},Ph=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Ec=kh(Ph)(Rh);import{Provider as Ah}from"react-redux";import{jsx as Hn}from"react/jsx-runtime";var Lh=({children:t})=>{let o=C("locale").replace("-","");return Hn(Ns.Provider,{value:o,children:t})},Mh=({store:t,customStyles:e={},children:o})=>Hn(Ah,{store:t,children:Hn(Lh,{children:Hn(zt.Provider,{value:e,children:o})})}),nt=Mh;import Lr from"classnames";import{useEffect as qh,useRef as Wh,useState as $h}from"react";import{connect as Gh,useDispatch as Xh,useSelector as mo}from"react-redux";import{useState as Nh}from"react";function kc(t,e){let[o,n]=Nh(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return T.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){T.error(i)}}]}import Hh from"classnames";import{Fragment as Bh,useCallback as Rr,useMemo as Rc}from"react";var Ir={};q(Ir,{enUS:()=>Oh,nlNL:()=>Dh});var Oh={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"}]}]},Dh={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 Ic={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as Bn,jsxs as Pc}from"react/jsx-runtime";var Pr=(t,e,o)=>n=>Bn("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Fh=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=w(Ir),i=se(),a=y("Login",Ic),l=C("productName"),c=Rr(h=>{h.preventDefault(),n&&n(parseInt(h.target.value,10))},[]),p=Rr(h=>{h.preventDefault(),i.send(Pt,!0)},[e]),d=Rc(()=>h=>Bn("a",{onClick:_=>{_.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),g=Rr(h=>Bn("button",{type:"button",className:a.anchorButton,onClick:p,children:h},"prompt"),[p]),{min:u,hour:m,day:f}=Rc(()=>({min:Pr(a,60*10,c),hour:Pr(a,60*60,c),day:Pr(a,60*60*12,c)}),[]);return Pc("div",{className:Hh(t,a.root),children:[r("loginPlease",{login:o?g:d,productName:l}),n&&Pc(Bh,{children:[Bn("br",{}),r("snooze",{min:u,hour:m,day:f})]})]})},Fn=Fh;import{useDispatch as Kh}from"react-redux";var Ac={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as Lc,jsxs as zh}from"react/jsx-runtime";var Uh=({title:t})=>{let e=y("SearchTrigger",Ac),o=Kh();return zh("button",{type:"button",className:e.root,onClick:()=>o(G(!0)),children:[Lc(Et,{}),Lc("span",{className:e.text,children:t})]})},Mc=Uh;var Ar={};q(Ar,{enUS:()=>jh,nlNL:()=>Vh});var jh={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"}]},Vh={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}]};var Nc={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};import{jsx as V,jsxs as fo}from"react/jsx-runtime";var Zh=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=y("SuggestionsOverlay",Nc),s=w(Ar),r=mo(Nt),i=Ti(),a=Xh(),l=Wh(null),c=C("searchTriggerKey"),p=C("productName"),d=mo(Tn),g=mo(Z),u=mo(yt),[m,f]=$h(null),h=C("showSearch"),E=C("showTextSuggestions"),_=C("adminUrl"),x=C("isEmbedded"),[b,v]=kc("dd-snooze-until-ms",0),R=d||b>Date.now(),A=mo(B=>B.input.text),H=t.filter(B=>B.source!=="gpt").length,N=()=>{R&&v(0),a(vl(!R))},K=B=>{a(W({name:"suggestion feedback",data:{text:B.text,source:"overlay",context:A},options:{includeConversationData:!0}}))},k=B=>{let ue=Date.now()+B*1e3;v(ue),T.info(`Snooze until: ${new Date(ue)}`),a(Ue({collapse:!0}))};return qh(()=>{H===0&&f(null)},[t,H]),xt(()=>{a(Ue({collapse:!0,skipWhenInputFocus:!0}))}),g===null||u===!1?null:g===!1?fo("div",{ref:l,className:Lr(n.root,{[n.isCollapsed]:R}),children:[!R&&fo("div",{className:n.triggers,children:[V("div",{style:{flex:1}}),V("div",{className:n.triggersRight,children:V(mt,{className:n.toggleButton,title:s("collapse"),onClick:N,isCollapsed:!1})})]}),V("div",{className:n.toggleButtonWrapper,children:V(mt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:N,isCollapsed:!0})}),V("div",{className:n.collapsible,children:V(Fn,{loginUrl:_,isEmbedded:x,onLogIn:o,onSnooze:k})})]}):!i||!r?null:fo("div",{ref:l,className:Lr(n.root,{[n.isCollapsed]:R}),children:[!R&&fo("div",{className:n.triggers,children:[V("div",{style:{flex:1},children:h&&V("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(s(_n()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>f(null),children:V(Mc,{title:s("search")})})}),fo("div",{className:n.triggersRight,onFocus:()=>{},children:[V("div",{className:Lr(!m&&n.hintsHidden,n.hints),children:m}),V(mt,{className:n.toggleButton,title:s("collapse"),onClick:N,isCollapsed:!1})]})]}),V("div",{className:n.toggleButtonWrapper,children:V(mt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:N,isCollapsed:!0})}),H>0&&E&&V("div",{className:n.collapsible,onFocus:()=>{},children:V(ie,{children:V(Nn,{onFeedback:K,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Qh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Oc=Gh(Qh)(Zh);import jr from"classnames";import{Interweave as By}from"interweave";import{useCallback as Fy,useEffect as Ky,useMemo as tp,useRef as Uy}from"react";import{connect as zy}from"react-redux";import{cloneElement as Jh}from"react";var Yh=["div","span","mark","strong","b","i","u","em"];function Mr(t,e,o=0){var r;let n=t[t.length-1],s=typeof n=="object"&&n!==null?(r=n.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,n];if(Yh.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),Jh(n,{children:Mr(i,e,o+1)})]}return[...t,...e]}function je(t){return t.tagName.toLowerCase()==="textarea"}var Dc={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};import hy from"classnames";import{Matcher as yy}from"interweave";import{useEffect as vy,useMemo as Sy}from"react";function Hc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Kn(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Bc(t){return t!=null}import jc from"classnames";import{createRef as cy,useCallback as Or,useMemo as py,useRef as dy,useState as uy}from"react";import{useState as ey,useLayoutEffect as ty}from"react";var oy=["bottom","height","left","right","top","width"],ny=(t={},e={})=>oy.some(o=>t[o]!==e[o]),Pe=new Map,Fc,Kc=()=>{let t=[],e=[];Pe.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();ny(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Pe.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Fc=window.requestAnimationFrame(Kc)};function sy(t,e){return{observe(){let o=Pe.size===0;if(Pe.has(t)){let n=Pe.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Pe.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&Kc()},unobserve(){let o=Pe.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Pe.delete(t),Pe.size||cancelAnimationFrame(Fc)}}}}function Nr(t){let[e,o]=ey(null);return ty(()=>{if(!t.current)return;let n=sy(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as ry,useLayoutEffect as iy,useState as ay}from"react";import{createPortal as ly}from"react-dom";var Uc={root:"_root_1jq08_1"};var zc=({children:t})=>{let[e,o]=ay(null),n=ry(zt);return iy(()=>{let s=document.createElement("div");return Qe(s),s.classList.add(Uc.root),n!=null&&n.portalRootNode&&s.classList.add(n==null?void 0:n.portalRootNode),document.body.appendChild(s),o(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?ly(t,e):null};var ye={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};import{jsx as Dr}from"react/jsx-runtime";var Un=(t=!1)=>{let[e,o]=uy(t),n=Or(()=>o(!0),[]),s=Or(()=>o(!1),[]),r=Or(()=>o(a=>!a),[]),i=dy(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Hr(t,e=null,o=0){if(!t)return{display:"none"};let n=e?t.top-e.top<0||t.top<e.top-o?e.top-o:t.top+t.height>e.top+e.height+o?e.top+e.height+o-t.height:t.top:t.top,s=e?t.left<e.left-o?e.left-o:t.left+t.width>e.left+e.width+o?e.left+e.width+o-t.width:t.left:t.left;return{top:n,left:s,height:t.height,width:t.width}}var zn=({className:t,triggerRef:e,boundaryRef:o=cy(),position:n="above",align:s="center",children:r,toStyle:i=Hr,...a})=>{let l=Nr(e),c=Nr(o),p=py(()=>i(l,c,0),[l,c]);return Dr(zc,{children:Dr("div",{className:jc(ye.ref,{[ye.positionAbove]:n==="above",[ye.positionBelow]:n==="below",[ye.positionLeft]:n==="left",[ye.positionRight]:n==="right",[ye.alignStart]:s==="start",[ye.alignCenter]:s==="center",[ye.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:Dr("div",{className:jc(t,ye.root),children:r})})})};import gy from"classnames";import{forwardRef as my,useRef as fy}from"react";import{jsx as Vc}from"react/jsx-runtime";var jn=my(({className:t,children:e,...o},n)=>{let s=fy(null),r=y("TabCompletion",be);return Vc("div",{ref:Kn([s,n]),className:gy(t,r.popoverContentContainer),...o,children:Vc("div",{className:r.popoverContent,children:e})})});import{jsx as ho,jsxs as by}from"react/jsx-runtime";var _y=t=>e=>{let o=Hr(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},xy=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",be),i=Un(),a=Sy(()=>_y(t.getBoundingClientRect()),[t]),[l,c]=ln(t);return vy(()=>{c?i.open():i.close()},[c]),by("span",{children:[ho("mark",{ref:Kn([l,i.triggerRef]),className:hy(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&ho(zn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:ho(jn,{style:o,children:ho("div",{className:r.hintText,children:s})})})]})},Vn=class extends yy{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(n=>({...n,keywordRegex:new RegExp(`\\b${Hc(n.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(Bc);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return ho(xy,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import zr from"classnames";import{Matcher as Ay}from"interweave";import{createRef as Ly,forwardRef as My,useCallback as Ny,useEffect as Jc,useRef as Yc,useState as ep}from"react";import{useDispatch as Oy}from"react-redux";import{jsx as qc}from"react/jsx-runtime";var Wc=()=>qc("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:qc("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});import{useCallback as Cy,useEffect as Gc,useState as Xc}from"react";import{useDispatch as wy,useSelector as Zc}from"react-redux";import Ty from"lodash.debounce";var $c={root:"_root_1muu8_1",content:"_content_1muu8_7"};function qn(t,e,o){var s;let n=((s=t.imageSizes)==null?void 0:s[e])||t.image||o;if(!n)return null;try{return new URL(n).toString()}catch{return null}}function Br(t){return t.replace("https://www.","").replace("https://","")}import{jsx as st,jsxs as Fr}from"react/jsx-runtime";var Ey=3,ky=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Iy=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Ey})=>{let r=y("LinkSearch",$c),[i,a]=Xc(""),l=wy(),c=Zc(Cn("url")),p=Zc(Va("URL",ky)),[d,g]=Xc(p.length-1),u=C("fallbackImage"),m=_=>{let x=_.target;a(x.value)},f=(_,x)=>{_.stopPropagation(),_.preventDefault(),window.open(x,"_blank")},h=_=>{var v;let x=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;_.code==="Escape"&&(a(""),e()),_.code==="ArrowUp"&&g(x),_.code==="ArrowDown"&&g(b),_.code==="Enter"&&t(((v=p[d])==null?void 0:v.text)||i)},E=Cy(Ty(_=>{l(Ye({query:_,type:"URL",tags:["link-search"]}))},300),[]);return Gc(()=>{i&&E(i)},[i]),Gc(()=>()=>{l(vn())},[]),Fr("div",{className:r.root,children:[st(ie,{withDivider:!0,children:(i?p:c).slice(0,s).map((_,x)=>st(D,{selected:d===x,onClick:()=>t(_.text),"data-testid":"linksearch-suggestion",children:Fr(F,{children:[st(F.Image,{src:qn(_,"small",u||void 0),title:_.title||_.text}),Fr(F.Content,{className:r.content,cropText:!0,children:[st(F.Title,{children:_.title||Br(_.text)}),_.title&&Br(_.text)]}),st(D.Actions,{children:st(D.ActionButton,{label:n,onClick:b=>f(b,_.text)})})]})},_.text))}),st(io,{value:i,onChange:m,autoFocus:!0,placeholder:o,onKeyUp:h})]})},Qc=Iy;var Kr={};q(Kr,{enUS:()=>Ry,nlNL:()=>Py});var Ry={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Py={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};import{jsx as ve,jsxs as Ur}from"react/jsx-runtime";var Dy=My((t,e)=>{let o=y("TabCompletion",be);return ve("mark",{ref:e,className:zr(o.matchSelection)},"selection-start")}),Hy=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=w(Kr),i=y("TabCompletion",be),a=Yc(null),l=Yc(null),[c,p]=ep(null),d=Oy(),g=Un(document.activeElement===n),[u]=ep(()=>document.createRange());g.triggerRef.current=u,Jc(()=>()=>u.detach(),[]),Jc(()=>{let f=t.current,h=a.current;!f||!h||(u.setStart(f,0),u.setEnd(h,0))},[t.current,a.current]),xt(()=>{g.close()});let m=Ny(f=>{let h=u.toString(),E=/^http(s?):\/\//.test(f)?f:`https://${f}`;d(zo({text:`[${h}](${E})`,replace:"selection"}))},[]);return Ur("span",{children:[ve("mark",{ref:a,className:zr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":g.opened?"true":"false",children:s}),g.opened&&ve(zn,{className:i.popoverRoot,triggerRef:g.triggerRef,boundaryRef:e,position:"above",align:"start",children:Ur(jn,{style:o,ref:l,children:[ve("div",{className:zr(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:Ur("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[ve(Wc,{}),ve("span",{children:"\xA0"}),ve("span",{children:r("insertLink")})]})}),c==="insertLink"&&ve(Qc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:m,onDismiss:()=>{p(null),g.close()}})]})})]},"selection-end")},Wn=class extends Ay{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=Ly(),this.foundIndex=0,e}match(e){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,n]=this.props.selection;if(o===n)return null;let s=this.foundIndex===0?o:n,r=s>=this.charCount&&s<=this.charCount+e.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;r&&this.foundIndex++;let i=this.foundIndex===1;return r&&i?this.charCount+=s-this.charCount:this.charCount+=e.length,r?{isStart:i,...r}:null}replaceWith(e,o){return o.isStart?ve(Dy,{ref:this.startRef}):ve(Hy,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{useSelector as jy}from"react-redux";import{jsx as Ot,jsxs as Wy}from"react/jsx-runtime";var Vy=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",Dc),p=C("insertLink"),d=C("showMidSentenceSuggestions"),g=C("inlineSuggestions"),u=pn(a),m=Uy(null),f=jy(Z);Ky(()=>{je(a)&&u&&dn(a,u)},[u]);let h=Fy(x=>{if(!s||!o)return x;let b=[Ot("span",{className:c.resetIndent,children:"\u200B"},"u200B"),Ot("span",{"data-testid":"tab-completion",className:jr(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&b.push(Ot("span",{className:jr(c.hint,c.resetIndent),children:Ot(gs,{keyCode:"tab"},"tabHint")})),Mr(x,b)},[s,o,n]),E=tp(()=>{let x=[];return p&&x.push(new Wn("selection")),x.push(new _t("placeholders")),r&&x.push(new Vn("keywords")),x},[g,p,r]),_=tp(()=>{let x=window.getComputedStyle(a);return{"--dd-color":x.color,"--dd-font-size":x.fontSize,"--dd-font-family":x.fontFamily,"--dd-font-variant":x.fontVariant}},[]);return!t||!f?null:Wy("div",{ref:x=>{x!=null&&x.parentElement&&(m.current=x==null?void 0:x.parentElement)},className:c.root,style:_,children:[Ot(By,{tagName:"span",containerTagName:"div",className:jr(c.container,c.agentText),disableLineBreaks:je(a),content:e||"\u200B",onAfterParse:h,matchers:E,selection:u,keywordMatches:i,inputElement:a,inputStyle:_,boundaryRef:m,inlineSuggestionsOnlyAtEnd:!d}),Ot("br",{})]})},qy=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var f;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??Zt(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:g,visible:u,showStyleSuggestions:m}=o;return{showTabHint:p,showStyleSuggestions:m,showTabCompletion:g,content:l,tabText:c,source:a,keywordMatches:((f=n.list)==null?void 0:f.keywordMatches)??[],enabled:u&&d!==!1}},op=zy(qy)(Vy);import kv from"classnames";import{useEffect as Iv}from"react";import{useDispatch as Rv,useSelector as te}from"react-redux";import{createAsyncThunk as yo,createSlice as $y}from"@reduxjs/toolkit";var np={list:[],fetchState:"idle",isInitialRequest:null},rp=t=>t.autoflows.list||[],sp=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ae=yo("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Vr=yo("autoflows/start",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.startAutoflowSession(t),await o(Ae(t.platformSessionId))}),qr=yo("autoflows/stop",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.stopAutoflowSession(t.platformSessionId),await o(Ae(t.platformSessionId))}),Gy=$y({name:"autoflows",initialState:np,reducers:{},extraReducers:t=>{t.addCase(Vr.pending,(e,o)=>{let n=sp(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(qr.pending,(e,o)=>{let n=sp(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Ae.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ae.rejected,e=>{e.fetchState="error"}),t.addCase(Ae.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(L,()=>np)}}),ip=yo("autoflows/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");let s=n.openStream(t);s.on("sessionAborted",()=>{o(Ae(t))}),s.on("sessionCompleted",()=>{o(Ae(t))})}),ap=yo("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),lp=Gy.reducer;import{createAsyncThunk as So,createSlice as Xy}from"@reduxjs/toolkit";var cp={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},pp=t=>t.customMessages.list,dp=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),up=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),gp=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),vo=So("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),$n=So("customMessages/send",async(t,e)=>{let{platformSessionId:o,suggestion:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.sendCustomMessage(o,n)}),Gn=So("customMessages/answer",async(t,e)=>{let{platformSessionId:o,reply:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.answerCustomMessage(o,n)}),mp=Xy({name:"customMessages",initialState:cp,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(vo.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(vo.rejected,e=>{e.fetchState="error"}).addCase(vo.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase($n.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase($n.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Gn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Gn.rejected,(e,o)=>{let n=e.answeredSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1)),e.answeredSuggestions.splice(n,1)}).addCase(L,()=>cp)}}),fp=So("customMessages/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.openStream(t).on("customMessageSuggestion",r=>{o(mp.actions.onCustomMessage(r))})}),hp=So("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),yp=mp.reducer;import{createAsyncThunk as vp,createSlice as Zy}from"@reduxjs/toolkit";var Qy={token:null,accountUrl:null,interval:null},Sp=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},Wr=vp("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),$r=vp("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(Wr()),setInterval(()=>n(Wr()),o)}),_p=Zy({name:"passwordlessToken",initialState:Qy,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Wr.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase($r.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:xp}=_p.actions,bp=_p.reducer;function Cp(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as av}from"react";import{connect as lv}from"react-redux";import sv from"classnames";import{Fragment as rv}from"react";import Jy from"classnames";var wp={root:"_root_838fd_1"};import{jsx as ev}from"react/jsx-runtime";var Yy=({className:t,children:e})=>{let o=y("Unicode",wp);return ev("span",{className:Jy(t,o.root),children:e})},Tp=Yy;var Ep={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var Gr={};q(Gr,{enUS:()=>tv,nlNL:()=>ov});var tv={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},ov={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};import{jsx as rt,jsxs as Xn}from"react/jsx-runtime";var iv=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",Ep),a=w(Gr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return Xn(D,{className:sv(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[rt(F,{children:Xn(F.Content,{children:[Xn(F.Title,{children:[e&&rt("span",{className:i.stateBadge,children:a(e)}),o]}),rt("span",{children:n})]})}),rt(D.Actions,{fixed:e==="Started",children:rt(D.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:Xn(rv,{children:[rt(Tp,{children:c})," ",rt("span",{children:a(l)})]})})})]})},kp=iv;import{jsx as Ip}from"react/jsx-runtime";var cv=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},pv=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>Ip(av,{children:t.map(s=>Ip(kp,{displayName:s.displayName,description:s.description,disabled:s.isBusy||cv(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),dv=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},uv={onStartAutoflow:Vr,onStopAutoflow:qr},Rp=lv(dv,uv)(pv);import{useEffect as gv,useState as mv}from"react";import{useDispatch as fv}from"react-redux";import Lp from"classnames";import{jsx as Pp}from"react/jsx-runtime";var Xr=()=>Pp("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:Pp("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 Ap={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};import{jsx as Dt,jsxs as Mp}from"react/jsx-runtime";var hv=({entities:t})=>{let e=y("EntitiesWidgetList",Ap),[o,n]=mv(void 0),s=fv(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),lo(a.text),s(W({name:"entity copied",data:{entity:a,type:"copy"}})))};return gv(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:Dt("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>Mp("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[Dt("span",{className:e.entityText,children:a.text}),Mp("span",{className:e.iconWrapper,children:[Dt("span",{className:Lp(e.icon),children:Dt(Xr,{})}),Dt("span",{className:Lp(e.icon,o===l&&e.iconClicked),children:Dt(Xr,{})})]})]},a.text))})},Np=hv;import yv from"classnames";import{useCallback as Op}from"react";import{useDispatch as vv,useSelector as Zn}from"react-redux";var Le={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};import{jsx as Ve,jsxs as Qn}from"react/jsx-runtime";var Sv=({suggestion:t})=>{let e=w(Je),o=vv(),n=Zn(dp(t.text)),s=Zn(up(t.text)),r=Zn(gp(t.text)),i=Zn(No),{replyOptions:a}=t,l=Op(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o($n({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=Op(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),g=a[d];o(Gn({platformSessionId:i,reply:g,suggestion:t}))},[t,n,o,i]);return Qn(D,{onClick:l,className:yv(Le.root,{[Le.isUsed]:n,[Le.hasError]:r}),children:[Ve(F,{children:Qn(F.Content,{children:[Qn(F.Title,{className:Le.title,children:[t.text," ",Ve(ms,{className:Le.label,children:"analyse tool"})," ",r&&Ve("span",{className:Le.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&Ve("ul",{className:Le.quickReplies,children:a.map(p=>Ve("li",{className:Le.quickReply,children:p.title},p.title))})]})}),Qn(D.Actions,{fixed:r||n,children:[a&&a.length>0&&Ve(D.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>Ve(D.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),Ve(D.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Dp=Sv;import{jsx as Hp}from"react/jsx-runtime";var Bp=()=>Hp("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Hp("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});import{useSelector as bv}from"react-redux";import{useCallback as _v}from"react";import{jsx as it,jsxs as Jn}from"react/jsx-runtime";var xv=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var g;let s=t.text||t.url||t.message,r=Sn(s),i=w(Je),a=C("showImages"),l=C("fallbackImage"),c=u=>{u.preventDefault(),u.stopPropagation(),n(s)},p=u=>{u.preventDefault(),u.stopPropagation(),o(t)},d=_v(u=>{window.open(r,"_blank"),u.stopPropagation(),u.preventDefault()},[r]);return Jn(D,{onClick:c,"data-testid":"edit-suggestion",children:[Jn(F,{children:[a&&t.image&&it(F.Image,{src:qn(t,"small",l||void 0),title:t.title}),Jn(F.Content,{children:[t.title&&it(F.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((g=t.searchKeywords)==null?void 0:g.length)>0&&it(D.Labels,{labels:t.searchKeywords}),it(F.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),Jn(D.Actions,{children:[r&&it(D.ActionButton,{onClick:d,label:i("visitUrl")}),it(D.ActionButton,{primary:!0,onClick:p,label:i("preview")}),it(D.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Fp=xv;import{Fragment as wv,jsx as Kp}from"react/jsx-runtime";var Cv=({contentType:t,lines:e,suggestions:o})=>{let n=se(),s=bv(Ke),r=a=>{n.send(pr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(ke,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return Kp(wv,{children:o.map(a=>Kp(Fp,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Up=Cv;var Zr={};q(Zr,{enUS:()=>Tv,nlNL:()=>Ev});var Tv={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],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"}]},Ev={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var zp={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};import{jsx as jp}from"react/jsx-runtime";var Vp=()=>jp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:jp("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});import{jsx as qp}from"react/jsx-runtime";var Wp=()=>qp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:qp("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});import{jsx as M,jsxs as Ht}from"react/jsx-runtime";var Yn=(t,e)=>{let o=te(Z);Iv(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},Pv=({onLogIn:t})=>{let e=w(Zr),o=Rv(),n=C("isEmbedded"),s=y("Widget",zp),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=te(ze),d=te(Pn),g=te(rp),u=te(kn),m=te(pp),f=te(Oo),h=te(yt),E=te(Z),_=te(No),x=te(Cp),b=te(Ke),v=se(),R=te(rl),A=te(Sp("/admin/")),H=C("adminUrl"),N=C("productName");if(Yn(()=>(o(vo(_)),o(fp(_)),()=>{o(hp(_))}),[o,h,i,_]),Yn(()=>(o(Ae(_)),o(ip(_)),()=>{o(ap(_))}),[o,h,r,_]),Yn(()=>{d.forEach(({type:k})=>{o(k==="entities"?de():pe(k))})},[o,h,f,p]),Yn(()=>(o($r()),()=>{o(xp())}),[o]),h===!1)return M("div",{className:s.stateText,children:M("div",{children:M("p",{children:e("notSupported")})})},"supported");if(E===!1)return M("div",{className:s.loginText,children:M("div",{children:M(Fn,{isEmbedded:n,loginUrl:H,onLogIn:t})})},"login");if(!p||!_||E===null||R||x)return M("div",{className:s.stateText,children:M("div",{children:M("p",{children:e("waiting")})})},"waiting");let K=c||a||l||A;return M("div",{className:kv(s.root),"data-testid":"widget",children:Ht(hs,{className:s.sectionList,children:[K&&M(We,{title:e("actions"),type:"shortcuts",children:Ht("div",{className:s.shortcutList,children:[c&&Ht("button",{className:s.shortcut,"data-testid":"shortcut-search",onClick:()=>v.send("ShowCommandPalette",{isOpen:!0}),children:[M(Et,{}),e("linkSearch")]}),a&&Ht("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>v.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[M(Wp,{}),e("linkSummary")]}),l&&Ht("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>v.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[M(Vp,{}),e("linkKnowledgeSearch")]}),A&&Ht("a",{className:s.shortcut,target:"_blank",href:A,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[M(Bp,{}),e("linkStudioLogin",{productName:N})]})]})}),i&&m.length>0&&M(We,{type:"custom-messages","data-testid":"custom-messages",children:M(ie,{withDivider:!0,children:m.map(k=>M(Dp,{suggestion:k},k.text))})}),r&&g.length>0&&M(We,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:M(ie,{withDivider:!0,children:M(Rp,{})})}),d.map(({type:k,title:B,amount:ue,lines:cs})=>{var ct;switch(k){case"entities":return u&&u.length>0&&M(We,{type:k,title:B,"data-testid":`type-${k}`,children:M(Np,{entities:u})},k);default:return((ct=b[k])==null?void 0:ct.fetchState)==="done"&&b[k].suggestions.length>0&&M(We,{type:k,title:B,"data-testid":`type-${k}`,children:M(ie,{withDivider:!0,children:M(Up,{lines:cs,contentType:k,suggestions:b[k].suggestions.slice(0,ue)||[]})})},k)}})]})})},$p=Pv;function xo(t){let e=new Range;return e.selectNodeContents(t),e}function Gp(t,e,o){try{return at(t,e,o),!0}catch{return!1}}function es(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function ts(t){return"tagName"in t&&t.tagName==="BR"}var _o=/[\u200B-\u200D\uFEFF]/g;function at(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let g=0;g<=l.length;g++)if(d.test(l[g])||p++,p===c)return g;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(_o,""),d=s+p.length,g=e>=s&&e<=d,u=o>=s&&o<=d;if(g){let m=i(c,e-s);m===0&&!u?n.setStartBefore(l):n.setStart(l,m)}u&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(ts(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let p=0;p<l.childNodes.length&&(a(l.childNodes[p]),!r);p++);let c=l.lastChild;es(l)&&c&&!es(c)&&!ts(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function os(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(d){let g=d===o,u=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let m=d.textContent;g&&(a=c+m.substring(0,n).replace(_o,"").length),u&&(l=c+m.substring(0,r).replace(_o,"").length),c+=m.replace(_o,"").length;break}case Node.ELEMENT_NODE:{let m=d.nextSibling===null;ts(d)&&!m&&c++;for(let f=0;f<d.childNodes.length;f++){let h=g&&f===n,E=u&&f===r;if(h&&(a=c),E&&(l=c),l!==void 0||((!h||!i)&&p(d.childNodes[f]),u&&f===r-1&&(l=c),l!==void 0))break}!u&&es(d)&&!m&&c++,u&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function ns(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let g=p?n:0,u=d?r:void 0,m=c.textContent.replace(_o,"");g===0&&u===void 0?a+=m:a+=m.substring(g,u);break}case Node.ELEMENT_NODE:{let g=c.nextSibling===null;i===0&&ts(c)&&!g&&(a+=`
|
|
8
|
-
`);for(let u=
|
|
9
|
-
`);break}default:break}d&&i++}return l(t),a}function Xp(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Bt=class extends De{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),ns(this.element,e)}getHTML(){return this.element.innerHTML||""}getRange(){var r;let e=this.getRootNode();if(e.activeElement!==this.element)return null;let o="getSelection"in e?e.getSelection():window.getSelection();if(!o)return null;let n="getComposedRanges"in o&&e instanceof ShadowRoot?(r=o.getComposedRanges(e))==null?void 0:r[0]:o.rangeCount>0?o.getRangeAt(0):null;if(!n)return null;let s=this.element.ownerDocument.createRange();return s.setStart(n==null?void 0:n.startContainer,n==null?void 0:n.startOffset),s.setEnd(n==null?void 0:n.endContainer,n==null?void 0:n.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let e=this.getRange();if(!e||!e.collapsed||!("getBoundingClientRect"in e))return null;let o=e.getBoundingClientRect();return!Xp(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Xp(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return os(this.element,e);let o=this.lastKnownSelection;if(o&&Gp(this.element,o.start,o.end))return o;let n=xo(this.element);return n.collapse(!1),os(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return ns(this.element,at(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};function Zp(t,e,o){let n=`deepdesk-iframe-${t}`,s=document.getElementById(n);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(o).forEach(([a,l])=>{i.searchParams.append(a,l)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=n,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}var Qr=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];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()}},Jr=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=Zp(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Yr=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),T.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Jr(e,this.deepdeskUrl,{debug:!0}):new Qr(e),n=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=typeof s.data=="string"?JSON.parse(s.data):s.data;r.type==="event"&&r.channel===e&&(T.info("Received broadcast event",this.sessionId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return o.onMessage(n),o}send(e,o){var r,i;T.info("Broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(i=(r=this.eventMap)[e])==null||i.call(r,o);let s=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage({...n,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Qp=Yr;var Ft=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var ei=t=>new Promise(e=>{setTimeout(e,t)});var Kt=class extends Ft{name="ClientError"},ti=class extends Ft{name="ServerError"},Se=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:d=!0,retryOnError:g=b=>b instanceof TypeError,retryOnResponse:u=b=>b.status>=500,version:m="v1",...f}=o,h={credentials:"include",...f,headers:{"Content-Type":"application/json",...f.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof m=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":m});let E=c,_=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let x=async()=>(E--,a(i,h).then(async b=>u(b)&&!r.isAborted&&E>0?(await ei(p),x()):b.status===401&&d===!0&&_===!1?(_=!0,await this.refreshToken(),x()):b).catch(async b=>{if(g(b)&&!r.isAborted&&E>0)return await ei(p),x();throw b}));x().then(b=>b.json().catch(()=>null).then(v=>{b.status>=500?s(new ti("Server Error",v)):b.status===401?s(new Kt("Unauthorized",v)):b.status===403?s(new Kt("Forbidden",v)):b.status===404?s(new Kt("Not Found",v)):b.status>=400&&s(new Kt("Bad Request",v)),delete this.latestRequestByUrl[i],n(v)})).catch(b=>{s(b)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var Av;(e=>{let t;(l=>(l.SEND_MESSAGE="Send Message",l.HANDLING_TIME="Handling Time",l.START_AUTOFLOW="Start Autoflow",l.ABORT_AUTOFLOW="Abort Autoflow",l.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",l.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(t=e.EventType||={})})(Av||={});function ss(t){return{...P(t),tags:t.tags}}var qe=class t{constructor(e,o={}){this.options=o;this.client=new Se(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),T.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...z(e),tags:e.tags},{version:"v2"});return ss(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return P(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return P(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return P(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return P(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),T.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return ss(r)}async isConversationSupported(e,o={}){T.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=z(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return ss(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...z(s),tags:s.tags})),{version:"v2"})).map(s=>ss(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",z({...r,...s,data:n,name:e}),{version:"v2"})}async sendEventV1(e,o){let n=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[r,i])=>({...s,[r]:i}),{});return this.client.post("/api/events",{event:e,data:z({...o,...n})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(n=>n.text)})).entities}async getSummary(e,o={}){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source),agent_id:o.agentId,id:o.externalConversationId},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw T.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",z(o),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,o={},n){return n==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${n}`,z(o),{abortLatest:!0})).map(r=>({...P(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,o){return(await this.client.post(`/api/conversations/${e}/autocomplete`,z(o),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let o=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return P(o).map(n=>({...n,text:n.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let o=await this.client.post("/api/style-suggestions",z(e),{abortLatest:!0});return P(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,z(e),{version:"v2"});return P(o)}async knowledgeAssist(e,o,n,s={}){let r=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,z({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(i=>({question:i.question,answer:i.answer.answer})),agentId:s.agentId,conversationId:s.conversationId}),{version:"v2"});return P(r)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return P(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return P(e.token)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return P(o)}async evaluateRule(e,o,n,s={}){let r=new URLSearchParams;s.raiseForFailingConditions&&r.set("raise_for_failing_conditions","true");let i=await this.client.post(`/api/conversations/${o}/rules/${e}/evaluate?${r.toString()}`,n,{version:"v2"});return P(i.cues)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(yi);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&T.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var bo=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(tr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,P(s))}catch{T.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var Lv;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Lv||={});var Co=class{constructor(e,o={}){this.apiUrl=e;this.client=new Se(e,o)}client;streams={};logger=T;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return P(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,z(o));return P(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,z(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return P(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",z(e));return P(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new bo(`${this.apiUrl}/sessions/${e}/events`),this.streams[e].connect()),this.streams[e]}closeStream(e){this.streams[e]||(this.streams[e].disconnect(),delete this.streams[e])}};import{combineReducers as Fv,configureStore as Kv}from"@reduxjs/toolkit";import{createSlice as Mv}from"@reduxjs/toolkit";var Jp={startTime:null,stopTime:null},Yp=Mv({name:"handlingTime",initialState:Jp,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(L,()=>Jp)}}),{handlingTimeStart:ed,handlingTimeStop:rs,handlingTimeReset:td}=Yp.actions,od=Yp.reducer;var nd=(t={})=>{let e={onAuthError:Rt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};import{createAsyncThunk as Nv,createSlice as Ov}from"@reduxjs/toolkit";var is={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var lt=Nv("styleSuggestions/getAll",async({text:t},e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),{showStyleSuggestions:s}=n.settings,r=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)return is.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Dv=Ov({name:"styleSuggestions",initialState:is,reducers:{},extraReducers:t=>{t.addCase(lt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(lt.rejected,e=>{e.fetchState="error"}).addCase(lt.fulfilled,(e,o)=>{e.fetchState="done",Me(e.list,o.payload)||(e.list=o.payload)}).addCase(Xe,e=>{e.list=is.list}).addCase(L,()=>is)}}),sd=Dv.reducer;var rd=(t={})=>{let e,o=!0,n={getStyleSuggestions:lt,debounce:500,...t};return s=>r=>i=>{var u;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((u=c.conversation.current)==null?void 0:u.id)||!p)return l;let{text:g}=c.input;return g===a&&!o||(clearTimeout(e),g==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:g}))},t.debounce)),l}};function Hv(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var id=(t={})=>{let e={getTextSuggestions:pe,getAutocompleteSuggestions:oo,debounce:200,check:Nt,...t},o;return n=>s=>r=>{var f;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(f=l.conversation.current)==null?void 0:f.id,g=r.type===wn.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:u}}=l;return Hv(u,i)&&!g||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let h=vt(l);h===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(h))},g?0:e.debounce)),a}};var ad=lt.fulfilled.toString();function Bv(t,e){let o=new Set([...e.keywordMatches.map(s=>s.keyword)]),n=[];return o.forEach(s=>{let r=t.keywordMatches.filter(l=>l.keyword===s),i=e.keywordMatches.filter(l=>l.keyword===s),a=i.length-r.length;a<=0||n.push(...i.slice(0,a))}),n}var ld=t=>e=>o=>n=>{var c;if(n.type!==ad){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(c=r.conversation)==null?void 0:c.current;if(s===i)return;let l=Bv(s,i);n.type===ad&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Uv=Fv({activeSuggestion:fl,answer:sc,auth:Il,autoflows:lp,conversation:Ci,contentTypes:Fl,customMessages:yp,passwordlessToken:bp,entities:zl,knowledgeAssistant:tc,handlingTime:od,info:Fa,input:ws.reducer,overlayInput:Q.reducer,settings:Si,profile:cc,search:Wa,summary:Xl,styleSuggestions:sd,ui:Sl,textSuggestions:pl});function cd(t){return Kv({reducer:Uv,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),nd(),id({debounce:200}),rd({debounce:500}),ld(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var zv=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},jv=t=>e=>o=>n=>{var a;let s=e.getState(),r=_s("inlineSuggestions")(s);switch(n.type){case Te.toString():{let l=Cn(n.payload.contentType)(e.getState()),c=l.indexOf(n.payload.suggestion);t.emit("edit-suggestion",{contentType:n.payload.contentType,index:c,suggestions:l});break}case Rt.toString():{!n.payload&&t.emit("logout",void 0);break}case ae.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:zv(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case zo.toString():{let{start:l,end:c}=s.input.selection;t.emit("replace",{...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case qt.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Wo.toString():t.emit("select-image",n.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:n.payload.suggestion.image,title:n.payload.suggestion.title}});break;case de.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case Ie.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case W.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case jo.toString():t.handleKeyDown(n.payload);break;case Xe.toString():t.logSendMessage(n.payload);break;case Vo.toString():t.logSendEditSuggestionMessage(n.payload);break;case qo.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Xe.toString():t.handleAfterSendMessage(n.payload);break;case no.toString():t.onUpdateShowTabHint(n.payload);break;case rs.toString():t.logHandlingTime();break;case ae.toString():{r&&(e.dispatch(me([])),e.dispatch(xe()));break}case me.toString():{r&&n.payload.length>0&&e.dispatch(Oe(0));break}default:break}return i},pd=jv;function oi(t){return t.toISOString().replace("T"," ").replace("Z","")}function dd(t,e){var s,r,i;let{startTime:o,stopTime:n}=t.handlingTime;if(!o||!n)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:t.conversation.current.id,clientVersion:e.version,agentId:(s=t.info.agentInfo)==null?void 0:s.agentId,agentName:(r=t.info.agentInfo)==null?void 0:r.agentName,agentEmail:(i=t.info.agentInfo)==null?void 0:i.agentEmail,timeStart:oi(o),timeStop:oi(n)}}function ni(t,e,o){var A,H,N;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:g,deletions:u,textSuggestions:m,offeredTextSuggestions:f}}=e[t],h=n.length,_=m.reduce((K,{text:k,searchTerm:B})=>K+k.length-(B?B.length:0),0),x=c??Date.now(),b=(Date.now()-x)/1e3+(p||0),v=s/b,R=m.reduce((K,{searchTerm:k})=>K+(k?k.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:g,deletions:u,lenTextTyped:s+R,lenTextTotal:h,lenTextAssisted:_,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:v,numPastes:l,textSuggestionsV2:m,suggestionsCounters:[{source:"gpt",countOffered:f.filter(K=>K.source==="gpt").length}],agentId:(A=e.info.agentInfo)==null?void 0:A.agentId,agentName:(H=e.info.agentInfo)==null?void 0:H.agentName,agentEmail:(N=e.info.agentInfo)==null?void 0:N.agentEmail}}function si(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return si(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?si(s,e):null}function ud(t,e){return si(t,e)}function gd(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Vv(t){return typeof t=="object"&&t!==null&&"tagName"in t}function ri(t){return Vv(t)&&(je(t)||cn(t))}var md=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{T.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function qv(t){return t.offsetParent!==null}function fd(t){if(!qv(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 ii(t,e,o=100){let n=fd(t);e({isVisible:n});let s=setInterval(()=>{let r=fd(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import{jsx as j}from"react/jsx-runtime";var hd=md("showTabHint",!0),ls=class t{static version="10.12.1-beta.0";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new qe(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[pd({emit:(d,g,u)=>this.emit(d,g,u),handleAfterSendMessage:d=>this.handleAfterSendMessage(d),handleInputChanged:d=>this.handleInputChanged(d),handleKeyDown:d=>this.handleKeyDown(d),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:d=>this.logSendMessage(d),logSendEditSuggestionMessage:d=>this.logSendEditMessage(d),onUpdateShowTabHint:d=>hd.update(d),sendEvent:(d,g)=>this.deepdeskApi.sendEvent(d,g)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new Co(o)}),this.store=cd(p),this.broadcastEvents=new Qp({debug:!0,deepdeskUrl:c,eventMap:Rl(this.store),createCustomChannel:l}),this.store.dispatch(Vt),this.store.dispatch(no(hd.value())),this.store.dispatch(Vt({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(T.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(T.warn("Profile has not been loaded (yet)"),!0):(T.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Rt(null)),this.store.dispatch(Ee()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();Z(n)&&bl(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(Ee())).payload}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){T.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(bs({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Do(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Ho({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Cs(e))).payload}async postMessages(e){return(await this.store.dispatch(Fo(e))).payload}async updateConversation(e){return(await this.store.dispatch(Bo(e))).payload}resetConversation(){this.store.dispatch(L()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Ie());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Vt(e))}setVisitorInfo(e){this.store.dispatch(Ba(e))}async setAgentInfo(e){await this.store.dispatch(Yt(e))}async setAgentSettings(e){await this.store.dispatch(nr(e))}async getAgentSettings(){return(await this.store.dispatch(sr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(wn()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(qo(e))}notifyKeyDown(e){this.store.dispatch(jo(e))}notifyPaste(e,o){this.store.dispatch(Ni({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Li(e))}notifyExternalSuggestion(e){this.store.dispatch(ae(e)),this.store.dispatch(xe())}notifyEditSuggestion(e){this.store.dispatch(ll(e.contentType,e.suggestions)),this.store.dispatch(Te({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(Ue({collapse:!1})),this.inputMediator&&this.store.dispatch(Ei({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(me([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(Mi(Uo(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Ri()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{o||!a||i&&s<=0||r&&(e.shiftKey||(this.store.dispatch(Ai()),e.preventDefault(),!i&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(qt()):this.stageSelectedSuggestion({inputType:"arrow"}))))};switch(e.key){case"Up":case"ArrowUp":i?p():c();return;case"Down":case"ArrowDown":{i?c():p();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(Oe(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Oe(-1)),this.store.dispatch(qt()),e.preventDefault()):o||(this.store.dispatch(Ue({collapse:!0})),this.store.dispatch(yl(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,g=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:u}=this.state.input;this.store.dispatch(no(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&u&&u.text.startsWith(g)&&(this.store.dispatch(ae({text:u.text,suggestion:u,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(xe())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Oi()),this.store.dispatch(me([]))}handlingTimeStart(){this.state.handlingTime.startTime||(T.info("Start handling time"),this.store.dispatch(ed()))}handlingTimeStop(){this.state.handlingTime.startTime&&(T.info("Stop handling time"),this.store.dispatch(rs()))}logSendMessage(e){let o=ni("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=ni("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Ii(this.state.overlayInput.metrics))}logHandlingTime(){let e=dd(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(td())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(xe()),this.store.dispatch(Xe(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(ae({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){T.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),T.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=Ct(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{as(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=Ct(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{as(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Qe(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,s.setAttribute("translate","no"),o.appendChild(s),this.unmountHandlers.push(()=>{as(s),s.remove()}),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,o),T.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=window.sessionStorage.getItem(e);if(!o)return;let n=JSON.parse(o);n.text.trim()===this.state.input.text.trim()?(T.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Hi(n.metrics))):T.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch{}}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!ri(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:d,detectSubmit:g,insertLink:u,inputMediator:m,closestScrollSelector:f,appendOverlayTo:h,inlineSuggestions:E,floatingMenu:_}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:u,isEmbedded:d,inlineSuggestions:E,floatingMenu:!!_}),o.automaticHandlingTime&&this.setupHandlingTime(e),Qe(e),this.inputMediator=m||(je(e)?new He(e):new Bt(e)),this.inputMediator.on("change",({plainText:v})=>{this.notifyInputChanged(v)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Di({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",v=>{this.notifyKeyDown(v)}),this.inputMediator.on("paste",({pastedText:v,selectionText:R})=>{this.notifyPaste(v,R)}),this.inputMediator.on("cut",({selectionText:v})=>{this.notifyCut(v)});let x=f&&ud(e,f)||void 0;if(E){let{customStyles:v,appendOverlayTo:R}=o;if(je(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let A=this.createInlineContainer(e,"deepdesk-caret");Ut(j(nt,{store:this.store,customStyles:v,children:j(tt,{broadcastEvents:this.broadcastEvents,children:j(Ec,{})})}),A),this.inputMediator.on("caret",N=>{this.store.dispatch(me([])),N?(A.style.display="block",A.style.top=`${N.top}px`,A.style.left=`${N.left}px`):A.style.display="none"});let H=this.overlayContainerFactory("floating-menu",x||e,{appendTo:typeof _=="object"&&"appendOverlayTo"in _?_.appendOverlayTo:R},v==null?void 0:v.floatingMenuRootNode);Ut(j(nt,{store:this.store,customStyles:v,children:j(tt,{broadcastEvents:this.broadcastEvents,children:j(_c,{onLogIn:()=>this.loginViaPopup().catch(N=>T.warn(N.message))})})}),H)}else{let v=this.overlayContainerFactory("deepdesk-tab-completion",x||e,{appendTo:h,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),R=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||e,{appendTo:h},n==null?void 0:n.suggestionsRootNode);Ut(j(nt,{store:this.store,customStyles:n,children:j(tt,{broadcastEvents:this.broadcastEvents,children:j(op,{inputElement:e})})}),v),Ut(j(nt,{store:this.store,customStyles:n,children:j(tt,{broadcastEvents:this.broadcastEvents,children:j(Oc,{onLogIn:()=>this.loginViaPopup().catch(A=>T.warn(A.message))})})}),R)}Ut(j(nt,{store:this.store,customStyles:n,children:j(tt,{broadcastEvents:this.broadcastEvents,children:j(mc,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",v=>{clearTimeout(b),v===null?b=setTimeout(()=>{v!==null&&this.store.dispatch(Ts(v))},500):this.store.dispatch(Ts(v))}),this.inputMediator.on("disabled",()=>{var v;(v=this.inputMediator)==null||v.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{g&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(It(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(It(!0))),this.store.dispatch(ki({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(xe()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var v;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((v=this.state.conversation.current)==null?void 0:v.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&T.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,isEmbedded:r}=o;this.widgetRoot=e,this.configure({showImages:s,isEmbedded:r}),Ut(j(nt,{store:this.store,customStyles:n,children:j(tt,{broadcastEvents:this.broadcastEvents,children:j($p,{onLogIn:()=>this.loginViaPopup().catch(i=>T.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&as(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=ii(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){gd(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(uo());let e=ze(this.state);e&&(await this.store.dispatch(po()),this.store.dispatch(Vt({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(e){return new Promise((o,n)=>{let s=new MessageChannel,r=s.port1,i=this.state.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 l=!1,c=()=>{p&&!p.closed&&p.close(),window.removeEventListener("message",d),clearInterval(g)};r.onmessage=async u=>{var m,f;if((m=u.data)!=null&&m.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((f=u.data)==null?void 0:f.jwt),await this.isLoggedIn(),this.broadcastEvents.send(ro),l=!0,s.port1.close(),o()}catch(h){console.error(h),n(h)}finally{l=!0,c()}};let p=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");p===null&&n(new Error("Popup blocked by browser"));let d=async u=>{var m;if(u.origin===a.origin)switch((m=u.data)==null?void 0:m.type){case"deepdesk-popup-loaded":{try{let f=JSON.stringify({type:"deepdesk-popup-create-channel"});p==null||p.postMessage(f,a.origin,[s.port2])}catch(f){T.error("Error posting message to popup",f),n(f)}break}case"deepdesk-popup-error":{c(),u.data.message==="Timeout"&&T.warn("Popup timed out. Check if the account's platform url is configured correctly."),n(new Error(u.data.message));break}}};window.addEventListener("message",d);let g=setInterval(()=>{p&&!p.closed||(c(),l||n(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(T.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;T.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=Pn(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(de()):this.store.dispatch(pe(n))})}catch(n){this.handleError(n)}}};async function Wv(t,e,o={}){let{value:n}=t,{start:s,end:r}=o.replace??{start:0,end:n.length},i=`${n.slice(0,s)}${e}${n.slice(r)}`,a=o.selectionAfter??{start:s+e.length,end:s+e.length},l=()=>{if(o.setValue)return o.setValue(i);t.value=i};return Promise.resolve(l()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function $v(t,e,o={}){let n=o.replace?at(t,o.replace.start,o.replace.end):xo(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),o.insertBRs!==!1?e.split(`
|
|
10
|
-
`).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}):n.insertNode(document.createTextNode(e))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?
|
|
11
|
-
`).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=o.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(o.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(o.slice(r)))}),e}function
|
|
7
|
+
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});import{jsx as dl}from"react/jsx-runtime";var Nm={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},pl=({className:t,color:e})=>dl("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:dl("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:Nm[e||"pink"]})});var ul={root:"_root_1tvv4_1",text:"_text_1tvv4_18",isLoggedIn:"_isLoggedIn_1tvv4_25",isLoggedOut:"_isLoggedOut_1tvv4_29",icon:"_icon_1tvv4_39",logo:"_logo_1tvv4_44",lock:"_lock_1tvv4_49"};var Vs={};Z(Vs,{enUS:()=>Dm,nlNL:()=>Hm});var Dm={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Hm={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};import{useDispatch as Km}from"react-redux";import{jsx as qs,jsxs as gl}from"react/jsx-runtime";var ml=({onLogIn:t})=>{let e=E(Vs),o=b("floatingMenu"),n=b("productName"),s=Km(),r=Bm(G),i=h("FloatingMenu",ul);if(r===null||o===!1)return null;let a=()=>{r===!0?s(Y(!0)):t()};return gl("button",{className:Fm(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[qs("div",{className:i.text,children:e(r?"search":"signin",{productName:n})}),gl("div",{className:i.icon,children:[qs(pl,{className:i.logo,color:"pink"}),r===!1&&qs(cl,{className:i.lock})]})]})};import{useEffect as af,useRef as lf}from"react";import{connect as cf,useDispatch as df,useSelector as sn}from"react-redux";import{useEffect as Um}from"react";function vt(t){Um(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Ge(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}function St(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:o,showSuggestionsAfterPattern:n}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?o&&new RegExp(o).test(s.substring(r.end))||n&&new RegExp(n).test(s.substring(0,r.end))?!0:o===!1&&n===!1:!1}import{createSlice as zm}from"@reduxjs/toolkit";var jm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var tn=({ui:t})=>t.overlayCollapsed;var fl=zm({name:"ui",initialState:jm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(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:Jt,setInputHasFocus:$s,setOverlayCollapsed:Ne,setOpenOverlayWhenTyping:hl,setOverlayCollapsedUserOverwrite:yl}=fl.actions,vl=fl.reducer;import{Fragment as nf,useMemo as sf}from"react";import{Interweave as $m}from"interweave";import{useEffect as Wm,useMemo as Gm,useRef as Xm}from"react";import{useDispatch as Zm,useSelector as Qm}from"react-redux";import{useEffect as Vm}from"react";function Sl(t,e,o){Vm(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var _l={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};import{jsx as on,jsxs as of}from"react/jsx-runtime";var Jm=["search","personal-collection-search","search-autocomplete"];function Ym(t,e,o,n={}){let s="";return Jm.includes(e)?s=ta(bs(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=bs(t,o,n),n.placeholders===!0&&(s=oa(s)),s}var ef=()=>{},tf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=b("inlineSuggestions"),r=Qm(ct),i=Zm(),a=h("TextSuggestion",_l),l=Xm(null);Wm(()=>{let d=setTimeout(()=>{i(ai({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(d)}},[o]),Sl(l,"click",()=>{i(Ae(t)),i(se({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=Gm(()=>Ym(o.text,o.source,r,{stripAgentPart:s,placeholders:!0,searchKeywords:o.searchKeywords}),[s,o.text,o.source,r,o.searchKeywords]);return o.source==="gpt"&&!s?null:of("div",{className:a.root,onMouseEnter:()=>i(Ae(t)),children:[on(L,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:ef,children:on($m,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&on("div",{className:a.actions,children:on(Wo,{onFeedback:()=>n(o),suggestion:o.text})})]})},xl=tf;import{jsx as bl}from"react/jsx-runtime";var rf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=sf(()=>{let r=e.map((i,a)=>bl(xl,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return bl(nf,{children:s})},nn=rf;var wl={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};import{jsx as rn}from"react/jsx-runtime";var pf=({textSuggestions:t,selectedIndex:e})=>{let o=lf(null),n=h("InlineSuggestionsOverlay",wl),s=sn(St),r=df(),i=sn(G),a=sn(at),l=sn(tn),c=b("showTextSuggestions");return vt(()=>{setTimeout(()=>{r(Ne({collapse:!0,skipWhenInputFocus:!0}))})}),af(()=>{let d=o.current;if(!d||!d.parentElement)return;d.parentElement.style.left="0px";let p=d.getBoundingClientRect();d.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),l||!s||!c||t.length===0||i!==!0||a===!1?null:rn("div",{className:n.root,"data-variant":"inline",children:rn("div",{ref:o,className:n.paper,children:rn(te,{children:rn(nn,{suggestions:t,selectedIndex:e})})})})},uf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Cl=cf(uf)(pf);import{Provider as gf}from"react-redux";import{jsx as an}from"react/jsx-runtime";var mf=({children:t})=>{let o=b("locale").replace("-","");return an(fs.Provider,{value:o,children:t})},ff=({store:t,customStyles:e={},children:o})=>an(gf,{store:t,children:an(mf,{children:an(Pt.Provider,{value:e,children:o})})}),Xe=ff;import Qs from"classnames";import{useEffect as kf,useRef as If,useState as Rf}from"react";import{connect as Pf,useDispatch as Af,useSelector as Yt}from"react-redux";import{useState as hf}from"react";function Tl(t,e){let[o,n]=hf(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return C.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){C.error(i)}}]}var El=()=>/Mac/i.test(navigator.platform);import Sf from"classnames";import{Fragment as _f,useCallback as Gs,useMemo as Il}from"react";var Ws={};Z(Ws,{enUS:()=>yf,nlNL:()=>vf});var yf={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"}]}]},vf={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 kl={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as ln,jsxs as Rl}from"react/jsx-runtime";var Xs=(t,e,o)=>n=>ln("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),xf=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=E(Ws),i=de(),a=h("Login",kl),l=b("productName"),c=Gs(v=>{v.preventDefault(),n&&n(parseInt(v.target.value,10))},[]),d=Gs(v=>{v.preventDefault(),i.send(dt,!0)},[e]),p=Il(()=>v=>ln("a",{onClick:_=>{_.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:v},"login"),[e]),g=Gs(v=>ln("button",{type:"button",className:a.anchorButton,onClick:d,children:v},"prompt"),[d]),{min:u,hour:f,day:m}=Il(()=>({min:Xs(a,60*10,c),hour:Xs(a,60*60,c),day:Xs(a,60*60*12,c)}),[]);return Rl("div",{className:Sf(t,a.root),children:[r("loginPlease",{login:o?g:p,productName:l}),n&&Rl(_f,{children:[ln("br",{}),r("snooze",{min:u,hour:f,day:m})]})]})},cn=xf;import{useDispatch as bf}from"react-redux";var Pl={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as Al,jsxs as Cf}from"react/jsx-runtime";var wf=({title:t})=>{let e=h("SearchTrigger",Pl),o=bf();return Cf("button",{type:"button",className:e.root,onClick:()=>o(Y(!0)),children:[Al(ut,{}),Al("span",{className:e.text,children:t})]})},Ll=wf;var Zs={};Z(Zs,{enUS:()=>Tf,nlNL:()=>Ef});var Tf={arrowHint:[{type:0,value:"Tip: use arrow keys to navigate suggestions"}],searchHintWindows:[{type:0,value:"Press CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],searchHintMac:[{type:0,value:"Press CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Close"}],search:[{type:0,value:"Search"}]},Ef={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}]};var Ml={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};import{jsx as j,jsxs as eo}from"react/jsx-runtime";var Lf=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=h("SuggestionsOverlay",Ml),s=E(Zs),r=Yt(St),i=ni(),a=Af(),l=If(null),c=b("searchTriggerKey"),d=b("productName"),p=Yt(tn),g=Yt(G),u=Yt(at),[f,m]=Rf(null),v=b("showSearch"),T=b("showTextSuggestions"),_=b("adminUrl"),y=b("isEmbedded"),[x,S]=Tl("dd-snooze-until-ms",0),O=p||x>Date.now(),F=Yt(k=>k.input.text),K=t.filter(k=>k.source!=="gpt").length,H=()=>{O&&S(0),a(yl(!O))},I=k=>{a($({name:"suggestion feedback",data:{text:k.text,source:"overlay",context:F},options:{includeConversationData:!0}}))},A=k=>{let V=Date.now()+k*1e3;S(V),C.info(`Snooze until: ${new Date(V)}`),a(Ne({collapse:!0}))};return kf(()=>{K===0&&m(null)},[t,K]),vt(()=>{a(Ne({collapse:!0,skipWhenInputFocus:!0}))}),g===null||u===!1?null:g===!1?eo("div",{ref:l,className:Qs(n.root,{[n.isCollapsed]:O}),children:[!O&&eo("div",{className:n.triggers,children:[j("div",{style:{flex:1}}),j("div",{className:n.triggersRight,children:j(nt,{className:n.toggleButton,title:s("collapse"),onClick:H,isCollapsed:!1})})]}),j("div",{className:n.toggleButtonWrapper,children:j(nt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:H,isCollapsed:!0})}),j("div",{className:n.collapsible,children:j(cn,{loginUrl:_,isEmbedded:y,onLogIn:o,onSnooze:A})})]}):!i||!r?null:eo("div",{ref:l,className:Qs(n.root,{[n.isCollapsed]:O}),children:[!O&&eo("div",{className:n.triggers,children:[j("div",{style:{flex:1},children:v&&j("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(s(El()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>m(null),children:j(Ll,{title:s("search")})})}),eo("div",{className:n.triggersRight,onFocus:()=>{},children:[j("div",{className:Qs(!f&&n.hintsHidden,n.hints),children:f}),j(nt,{className:n.toggleButton,title:s("collapse"),onClick:H,isCollapsed:!1})]})]}),j("div",{className:n.toggleButtonWrapper,children:j(nt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:H,isCollapsed:!0})}),K>0&&T&&j("div",{className:n.collapsible,onFocus:()=>{},children:j(te,{children:j(nn,{onFeedback:I,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Mf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Ol=Pf(Mf)(Lf);import lr from"classnames";import{Interweave as Ph}from"interweave";import{useCallback as Ah,useEffect as Lh,useMemo as rc,useRef as Mh}from"react";import{connect as Oh}from"react-redux";import{useEffect as Of,useRef as Nf,useState as Df}from"react";function dn(t){return t.contentEditable==="true"}function Hf(t){let e=0,o=0,n=window.getSelection();if(n.rangeCount!==0){let s=n.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),o=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:o}}function Nl(t){let{selectionStart:e,selectionEnd:o}=dn(t)?Hf(t):t;return[e,o]}function Dl(t){let[,e]=Df(),o=Nf(null);return o.current=Nl(t),Of(()=>{let n=()=>{let[s,r]=o.current??[],i=Nl(t);(!i||s!==i[0]||r!==i[1])&&(o.current=i,e({}))};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",n)}},[t]),o.current}function Hl(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(fo);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=n.indexOf(l,a);return s>c&&r<c+l.length?(o.selectionStart=c,o.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}import{cloneElement as Ff}from"react";var Bf=["div","span","mark","strong","b","i","u","em"];function Js(t,e,o=0){var r;let n=t[t.length-1],s=typeof n=="object"&&n!==null?(r=n.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,n];if(Bf.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),Ff(n,{children:Js(i,e,o+1)})]}return[...t,...e]}function De(t){return t.tagName.toLowerCase()==="textarea"}var Fl={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};import rh from"classnames";import{Matcher as ih}from"interweave";import{useEffect as ah,useMemo as lh}from"react";import{useEffect as Kf,useRef as Uf,useState as zf}from"react";function Bl(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function pn(t){let e=Uf(null),[o,n]=zf(!1);return Kf(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Bl((d,p)=>{let g=e.current;if(!g)return;let u=d/r,f=p/r,m=g.getBoundingClientRect(),v=u>m.x&&u<m.x+m.width&&f>m.y&&f<m.y+m.height;v&&!s?(s=!0,n(!0)):!v&&s&&(s=!1,n(!1))},({clientX:d,clientY:p})=>[d,p]),[l,c]=Bl(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}function Kl(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function un(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Ul(t){return t!=null}import $l from"classnames";import{createRef as Jf,useCallback as er,useMemo as Yf,useRef as eh,useState as th}from"react";import{useState as jf,useLayoutEffect as Vf}from"react";var qf=["bottom","height","left","right","top","width"],$f=(t={},e={})=>qf.some(o=>t[o]!==e[o]),be=new Map,zl,jl=()=>{let t=[],e=[];be.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();$f(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{be.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),zl=window.requestAnimationFrame(jl)};function Wf(t,e){return{observe(){let o=be.size===0;if(be.has(t)){let n=be.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else be.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&jl()},unobserve(){let o=be.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||be.delete(t),be.size||cancelAnimationFrame(zl)}}}}function Ys(t){let[e,o]=jf(null);return Vf(()=>{if(!t.current)return;let n=Wf(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as Gf,useLayoutEffect as Xf,useState as Zf}from"react";import{createPortal as Qf}from"react-dom";var Vl={root:"_root_1jq08_1"};var ql=({children:t})=>{let[e,o]=Zf(null),n=Gf(Pt);return Xf(()=>{let s=document.createElement("div");return Ge(s),s.classList.add(Vl.root),n!=null&&n.portalRootNode&&s.classList.add(n==null?void 0:n.portalRootNode),document.body.appendChild(s),o(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?Qf(t,e):null};var pe={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};import{jsx as tr}from"react/jsx-runtime";var gn=(t=!1)=>{let[e,o]=th(t),n=er(()=>o(!0),[]),s=er(()=>o(!1),[]),r=er(()=>o(a=>!a),[]),i=eh(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function or(t,e=null,o=0){if(!t)return{display:"none"};let n=e?t.top-e.top<0||t.top<e.top-o?e.top-o:t.top+t.height>e.top+e.height+o?e.top+e.height+o-t.height:t.top:t.top,s=e?t.left<e.left-o?e.left-o:t.left+t.width>e.left+e.width+o?e.left+e.width+o-t.width:t.left:t.left;return{top:n,left:s,height:t.height,width:t.width}}var mn=({className:t,triggerRef:e,boundaryRef:o=Jf(),position:n="above",align:s="center",children:r,toStyle:i=or,...a})=>{let l=Ys(e),c=Ys(o),d=Yf(()=>i(l,c,0),[l,c]);return tr(ql,{children:tr("div",{className:$l(pe.ref,{[pe.positionAbove]:n==="above",[pe.positionBelow]:n==="below",[pe.positionLeft]:n==="left",[pe.positionRight]:n==="right",[pe.alignStart]:s==="start",[pe.alignCenter]:s==="center",[pe.alignEnd]:s==="end"}),style:d,...a,role:"dialog",children:tr("div",{className:$l(t,pe.root),children:r})})})};import oh from"classnames";import{forwardRef as nh,useRef as sh}from"react";var we={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};import{jsx as Wl}from"react/jsx-runtime";var fn=nh(({className:t,children:e,...o},n)=>{let s=sh(null),r=h("TabCompletion",we);return Wl("div",{ref:un([s,n]),className:oh(t,r.popoverContentContainer),...o,children:Wl("div",{className:r.popoverContent,children:e})})});import{jsx as to,jsxs as ph}from"react/jsx-runtime";var ch=t=>e=>{let o=or(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},dh=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=h("TabCompletion",we),i=gn(),a=lh(()=>ch(t.getBoundingClientRect()),[t]),[l,c]=pn(t);return ah(()=>{c?i.open():i.close()},[c]),ph("span",{children:[to("mark",{ref:un([l,i.triggerRef]),className:rh(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&to(mn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:to(fn,{style:o,children:to("div",{className:r.hintText,children:s})})})]})},hn=class extends ih{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(n=>({...n,keywordRegex:new RegExp(`\\b${Kl(n.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(Ul);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return to(dh,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{Matcher as uh}from"interweave";import gh from"classnames";import{jsx as Gl}from"react/jsx-runtime";var mh=({inputElement:t,children:e})=>{let o=h("TabCompletion",we),[n,s]=pn(t);return Gl("mark",{ref:n,className:gh(o.matchPlaceholder,{[o.hover]:s}),children:e})},yn=class extends uh{match(e){let o=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return o?{index:o.index,length:o[0].length,match:o[0],matchString:o[0],valid:!0}:null}replaceWith(e,o){return Gl(mh,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import ar from"classnames";import{Matcher as wh}from"interweave";import{createRef as Ch,forwardRef as Th,useCallback as Eh,useEffect as oc,useRef as nc,useState as sc}from"react";import{useDispatch as kh}from"react-redux";import{jsx as Xl}from"react/jsx-runtime";var Zl=()=>Xl("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:Xl("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});import{useCallback as fh,useEffect as Jl,useState as Yl}from"react";import{useDispatch as hh,useSelector as ec}from"react-redux";import yh from"lodash.debounce";var Ql={root:"_root_1muu8_1",content:"_content_1muu8_7"};function vn(t,e,o){var s;let n=((s=t.imageSizes)==null?void 0:s[e])||t.image||o;if(!n)return null;try{return new URL(n).toString()}catch{return null}}function nr(t){return t.replace("https://www.","").replace("https://","")}import{jsx as Ze,jsxs as sr}from"react/jsx-runtime";var vh=3,Sh=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),_h=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=vh})=>{let r=h("LinkSearch",Ql),[i,a]=Yl(""),l=hh(),c=ec(Ja("url")),d=ec(Ci("URL",Sh)),[p,g]=Yl(d.length-1),u=b("fallbackImage"),f=_=>{let y=_.target;a(y.value)},m=(_,y)=>{_.stopPropagation(),_.preventDefault(),window.open(y,"_blank")},v=_=>{var S;let y=p-1<0?d.length-1:p-1,x=p+1===d.length?0:p+1;_.code==="Escape"&&(a(""),e()),_.code==="ArrowUp"&&g(y),_.code==="ArrowDown"&&g(x),_.code==="Enter"&&t(((S=d[p])==null?void 0:S.text)||i)},T=fh(yh(_=>{l(ze({query:_,type:"URL",tags:["link-search"]}))},300),[]);return Jl(()=>{i&&T(i)},[i]),Jl(()=>()=>{l(Po())},[]),sr("div",{className:r.root,children:[Ze(te,{withDivider:!0,children:(i?d:c).slice(0,s).map((_,y)=>Ze(L,{selected:p===y,onClick:()=>t(_.text),"data-testid":"linksearch-suggestion",children:sr(N,{children:[Ze(N.Image,{src:vn(_,"small",u||void 0),title:_.title||_.text}),sr(N.Content,{className:r.content,cropText:!0,children:[Ze(N.Title,{children:_.title||nr(_.text)}),_.title&&nr(_.text)]}),Ze(L.Actions,{children:Ze(L.ActionButton,{label:n,onClick:x=>m(x,_.text)})})]})},_.text))}),Ze(jt,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:v})]})},tc=_h;var rr={};Z(rr,{enUS:()=>xh,nlNL:()=>bh});var xh={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},bh={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};import{jsx as ue,jsxs as ir}from"react/jsx-runtime";var Ih=Th((t,e)=>{let o=h("TabCompletion",we);return ue("mark",{ref:e,className:ar(o.matchSelection)},"selection-start")}),Rh=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(rr),i=h("TabCompletion",we),a=nc(null),l=nc(null),[c,d]=sc(null),p=kh(),g=gn(document.activeElement===n),[u]=sc(()=>document.createRange());g.triggerRef.current=u,oc(()=>()=>u.detach(),[]),oc(()=>{let m=t.current,v=a.current;!m||!v||(u.setStart(m,0),u.setEnd(v,0))},[t.current,a.current]),vt(()=>{g.close()});let f=Eh(m=>{let v=u.toString(),T=/^http(s?):\/\//.test(m)?m:`https://${m}`;p(To({text:`[${v}](${T})`,replace:"selection"}))},[]);return ir("span",{children:[ue("mark",{ref:a,className:ar(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":g.opened?"true":"false",children:s}),g.opened&&ue(mn,{className:i.popoverRoot,triggerRef:g.triggerRef,boundaryRef:e,position:"above",align:"start",children:ir(fn,{style:o,ref:l,children:[ue("div",{className:ar(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:ir("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>d("insertLink"),children:[ue(Zl,{}),ue("span",{children:"\xA0"}),ue("span",{children:r("insertLink")})]})}),c==="insertLink"&&ue(tc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{d(null),g.close()}})]})})]},"selection-end")},Sn=class extends wh{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=Ch(),this.foundIndex=0,e}match(e){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,n]=this.props.selection;if(o===n)return null;let s=this.foundIndex===0?o:n,r=s>=this.charCount&&s<=this.charCount+e.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;r&&this.foundIndex++;let i=this.foundIndex===1;return r&&i?this.charCount+=s-this.charCount:this.charCount+=e.length,r?{isStart:i,...r}:null}replaceWith(e,o){return o.isStart?ue(Ih,{ref:this.startRef}):ue(Rh,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{useSelector as Nh}from"react-redux";import{jsx as _t,jsxs as Fh}from"react/jsx-runtime";var Dh=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=h("TabCompletion",Fl),d=b("insertLink"),p=b("showMidSentenceSuggestions"),g=b("inlineSuggestions"),u=Dl(a),f=Mh(null),m=Nh(G);Lh(()=>{De(a)&&u&&Hl(a,u)},[u]);let v=Ah(y=>{if(!s||!o)return y;let x=[_t("span",{className:c.resetIndent,children:"\u200B"},"u200B"),_t("span",{"data-testid":"tab-completion",className:lr(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push(_t("span",{className:lr(c.hint,c.resetIndent),children:_t(jn,{keyCode:"tab"},"tabHint")})),Js(y,x)},[s,o,n]),T=rc(()=>{let y=[];return d&&y.push(new Sn("selection")),y.push(new yn("placeholders")),r&&y.push(new hn("keywords")),y},[g,d,r]),_=rc(()=>{let y=window.getComputedStyle(a);return{"--dd-color":y.color,"--dd-font-size":y.fontSize,"--dd-font-family":y.fontFamily,"--dd-font-variant":y.fontVariant}},[]);return!t||!m?null:Fh("div",{ref:y=>{y!=null&&y.parentElement&&(f.current=y==null?void 0:y.parentElement)},className:c.root,style:_,children:[_t(Ph,{tagName:"span",containerTagName:"div",className:lr(c.container,c.agentText),disableLineBreaks:De(a),content:e||"\u200B",onAfterParse:v,matchers:T,selection:u,keywordMatches:i,inputElement:a,inputStyle:_,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!p}),_t("br",{})]})},Hh=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var m;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??Wt(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:d}=e,{isSupported:p}=s,{showTabCompletion:g,visible:u,showStyleSuggestions:f}=o;return{showTabHint:d,showStyleSuggestions:f,showTabCompletion:g,content:l,tabText:c,source:a,keywordMatches:((m=n.list)==null?void 0:m.keywordMatches)??[],enabled:u&&p!==!1}},ic=Oh(Hh)(Dh);import Ey from"classnames";import{useEffect as ky}from"react";import{useDispatch as Iy,useSelector as X}from"react-redux";import{createAsyncThunk as oo,createSlice as Bh}from"@reduxjs/toolkit";var ac={list:[],fetchState:"idle",isInitialRequest:null},cc=t=>t.autoflows.list||[],lc=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ce=oo("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),cr=oo("autoflows/start",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.startAutoflowSession(t),await o(Ce(t.platformSessionId))}),dr=oo("autoflows/stop",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.stopAutoflowSession(t.platformSessionId),await o(Ce(t.platformSessionId))}),Kh=Bh({name:"autoflows",initialState:ac,reducers:{},extraReducers:t=>{t.addCase(cr.pending,(e,o)=>{let n=lc(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(dr.pending,(e,o)=>{let n=lc(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Ce.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ce.rejected,e=>{e.fetchState="error"}),t.addCase(Ce.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(M,()=>ac)}}),dc=oo("autoflows/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");let s=n.openStream(t);s.on("sessionAborted",()=>{o(Ce(t))}),s.on("sessionCompleted",()=>{o(Ce(t))})}),pc=oo("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),uc=Kh.reducer;import{createAsyncThunk as so,createSlice as Uh}from"@reduxjs/toolkit";var gc={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},mc=t=>t.customMessages.list,fc=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),hc=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),yc=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),no=so("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),_n=so("customMessages/send",async(t,e)=>{let{platformSessionId:o,suggestion:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.sendCustomMessage(o,n)}),xn=so("customMessages/answer",async(t,e)=>{let{platformSessionId:o,reply:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.answerCustomMessage(o,n)}),vc=Uh({name:"customMessages",initialState:gc,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(no.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(no.rejected,e=>{e.fetchState="error"}).addCase(no.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(_n.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(_n.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(xn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(xn.rejected,(e,o)=>{let n=e.answeredSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1)),e.answeredSuggestions.splice(n,1)}).addCase(M,()=>gc)}}),Sc=so("customMessages/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.openStream(t).on("customMessageSuggestion",r=>{o(vc.actions.onCustomMessage(r))})}),_c=so("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),xc=vc.reducer;import{createAsyncThunk as bc,createSlice as zh}from"@reduxjs/toolkit";var jh={token:null,accountUrl:null,interval:null},wc=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},pr=bc("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),ur=bc("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(pr()),setInterval(()=>n(pr()),o)}),Cc=zh({name:"passwordlessToken",initialState:jh,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(pr.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(ur.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:Tc}=Cc.actions,Ec=Cc.reducer;function kc(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as Yh}from"react";import{connect as ey}from"react-redux";import Zh from"classnames";import{Fragment as Qh}from"react";import Vh from"classnames";var Ic={root:"_root_838fd_1"};import{jsx as $h}from"react/jsx-runtime";var qh=({className:t,children:e})=>{let o=h("Unicode",Ic);return $h("span",{className:Vh(t,o.root),children:e})},Rc=qh;var Pc={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var gr={};Z(gr,{enUS:()=>Wh,nlNL:()=>Gh});var Wh={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},Gh={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};import{jsx as Qe,jsxs as bn}from"react/jsx-runtime";var Jh=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=h("Autoflow",Pc),a=E(gr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return bn(L,{className:Zh(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[Qe(N,{children:bn(N.Content,{children:[bn(N.Title,{children:[e&&Qe("span",{className:i.stateBadge,children:a(e)}),o]}),Qe("span",{children:n})]})}),Qe(L.Actions,{fixed:e==="Started",children:Qe(L.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:bn(Qh,{children:[Qe(Rc,{children:c})," ",Qe("span",{children:a(l)})]})})})]})},Ac=Jh;import{jsx as Lc}from"react/jsx-runtime";var ty=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},oy=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>Lc(Yh,{children:t.map(s=>Lc(Ac,{displayName:s.displayName,description:s.description,disabled:s.isBusy||ty(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),ny=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},sy={onStartAutoflow:cr,onStopAutoflow:dr},Mc=ey(ny,sy)(oy);import ry from"classnames";import{useCallback as Oc}from"react";import{useDispatch as iy,useSelector as wn}from"react-redux";var Te={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};import{jsx as He,jsxs as Cn}from"react/jsx-runtime";var ay=({suggestion:t})=>{let e=E($e),o=iy(),n=wn(fc(t.text)),s=wn(hc(t.text)),r=wn(yc(t.text)),i=wn(vo),{replyOptions:a}=t,l=Oc(d=>{d.preventDefault(),d.stopPropagation(),!(n||!i)&&o(_n({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=Oc(d=>{if(d.preventDefault(),d.stopPropagation(),!i||!a)return;let p=parseInt(d.target.dataset.index,10),g=a[p];o(xn({platformSessionId:i,reply:g,suggestion:t}))},[t,n,o,i]);return Cn(L,{onClick:l,className:ry(Te.root,{[Te.isUsed]:n,[Te.hasError]:r}),children:[He(N,{children:Cn(N.Content,{children:[Cn(N.Title,{className:Te.title,children:[t.text," ",He(Vn,{className:Te.label,children:"analyse tool"})," ",r&&He("span",{className:Te.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&He("ul",{className:Te.quickReplies,children:a.map(d=>He("li",{className:Te.quickReply,children:d.title},d.title))})]})}),Cn(L.Actions,{fixed:r||n,children:[a&&a.length>0&&He(L.DropdownButton,{label:e("answer"),disabled:s,children:a.map((d,p)=>He(L.DropdownItem,{index:p,label:d.title,onClick:c},d.title))}),He(L.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Nc=ay;import{useEffect as ly,useState as cy}from"react";import{useDispatch as dy}from"react-redux";import Fc from"classnames";import{jsx as Dc}from"react/jsx-runtime";var mr=()=>Dc("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:Dc("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 Hc={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};import{jsx as xt,jsxs as Bc}from"react/jsx-runtime";var py=({entities:t})=>{let e=h("EntitiesWidgetList",Hc),[o,n]=cy(void 0),s=dy(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),qt(a.text),s($({name:"entity copied",data:{entity:a,type:"copy"}})))};return ly(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:xt("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>Bc("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[xt("span",{className:e.entityText,children:a.text}),Bc("span",{className:e.iconWrapper,children:[xt("span",{className:Fc(e.icon),children:xt(mr,{})}),xt("span",{className:Fc(e.icon,o===l&&e.iconClicked),children:xt(mr,{})})]})]},a.text))})},Kc=py;import{jsx as Uc}from"react/jsx-runtime";var zc=()=>Uc("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Uc("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as jc}from"react/jsx-runtime";var Vc=()=>jc("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:jc("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});import{jsx as qc}from"react/jsx-runtime";var $c=()=>qc("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:qc("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});import{useEffect as my,useState as fy}from"react";var fr={};Z(fr,{enUS:()=>uy,nlNL:()=>gy});var uy={copyCue:[{type:0,value:"Copy"}],copiedCue:[{type:0,value:"Copied!"}],removeCue:[{type:0,value:"Close"}]},gy={copyCue:[{type:0,value:"Kopieer"}],copiedCue:[{type:0,value:"Gekopieerd!"}],removeCue:[{type:0,value:"Sluiten"}]};import{jsx as ro,jsxs as Wc}from"react/jsx-runtime";var hy=({cue:t,onRemove:e,onCopy:o})=>{let n=E(fr),[s,r]=fy(!1),i=l=>{l.preventDefault(),l.stopPropagation(),o&&(o(t.text),r(!0))},a=l=>{l.preventDefault(),l.stopPropagation(),e&&e(t.id)};return my(()=>{if(!s)return;let l=setTimeout(()=>{r(!1)},1e3);return()=>{clearTimeout(l)}},[s]),ro(L,{"data-testid":"cue",children:Wc(N,{children:[Wc(N.Content,{children:[t.title&&ro(N.Title,{"data-testid":"widget-cue-title",children:t.title}),t.text]}),ro(L.Actions,{children:o&&ro(L.ActionButton,{primary:!0,onClick:i,label:n(s?"copiedCue":"copyCue")})}),ro(N.CloseIcon,{title:n("removeCue"),onClick:a})]})})},Gc=hy;import{Fragment as vy,jsx as Xc}from"react/jsx-runtime";var yy=({cues:t,onCopyCue:e,onRemoveCue:o})=>Xc(vy,{children:t.map(n=>Xc(Gc,{cue:n,onRemove:o,onCopy:e},`${n.id}_${n.timestamp}`))}),Zc=yy;import{useCallback as _y}from"react";var Sy=/(https?:\/\/[^\s]+)/,Qc=t=>t.split(" ").find(e=>Sy.test(e));import{jsx as bt,jsxs as Tn}from"react/jsx-runtime";var xy=({suggestion:t,lines:e,onUse:o})=>{var d;let n=t.text||t.url||t.message,s=Qc(n),r=E($e),i=b("showImages"),a=b("fallbackImage"),l=p=>{p.preventDefault(),p.stopPropagation(),o(n)},c=_y(p=>{window.open(s,"_blank"),p.stopPropagation(),p.preventDefault()},[s]);return Tn(L,{onClick:l,"data-testid":"edit-suggestion",children:[Tn(N,{children:[i&&t.image&&bt(N.Image,{src:vn(t,"small",a||void 0),title:t.title}),Tn(N.Content,{children:[t.title&&bt(N.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&bt(L.Labels,{labels:t.searchKeywords}),bt(N.Content,{cropText:e==="single",lineClamp:e==="multiple",children:n})]})]}),Tn(L.Actions,{children:[s&&bt(L.ActionButton,{onClick:c,label:r("visitUrl")}),bt(L.ActionButton,{primary:!0,onClick:l,label:r("useSuggestion")})]})]})},Jc=xy;import{Fragment as wy,jsx as Yc}from"react/jsx-runtime";var by=({lines:t,suggestions:e})=>{let o=de(),n=(s,r)=>{o.send(pt,{text:s,suggestion:{...r,source:r.source,sourceText:r.text}})};return Yc(wy,{children:e.map(s=>Yc(Jc,{suggestion:s,lines:t,onUse:r=>n(r,s)},s.text||s.url||s.message))})},ed=by;var hr={};Z(hr,{enUS:()=>Cy,nlNL:()=>Ty});var Cy={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],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"}]},Ty={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var td={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};import{jsx as P,jsxs as wt}from"react/jsx-runtime";var En=(t,e)=>{let o=X(G);ky(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},Ry=({onLogIn:t})=>{let e=E(hr),o=Iy(),n=b("isEmbedded"),s=h("Widget",td),r=b("showAutoflows"),i=b("showCustomMessages"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),d=X(Oe),p=X(Qo),g=X(cc),u=X(ki),f=X(Xo),m=X(mc),v=X(So),T=X(at),_=X(G),y=X(vo),x=X(kc),S=X(Jo),O=de(),F=X(Ya),K=X(wc("/admin/")),H=b("adminUrl"),I=b("productName");if(En(()=>(o(no(y)),o(Sc(y)),()=>{o(_c(y))}),[o,T,i,y]),En(()=>(o(Ce(y)),o(dc(y)),()=>{o(pc(y))}),[o,T,r,y]),En(()=>{p.forEach(({type:k})=>{o(k==="entities"?ae():le(k))})},[o,T,v,d]),En(()=>(o(ur()),()=>{o(Tc())}),[o]),T===!1)return P("div",{className:s.stateText,children:P("div",{children:P("p",{children:e("notSupported")})})},"supported");if(_===!1)return P("div",{className:s.loginText,children:P("div",{children:P(cn,{isEmbedded:n,loginUrl:H,onLogIn:t})})},"login");if(!d||!y||_===null||F||x)return P("div",{className:s.stateText,children:P("div",{children:P("p",{children:e("waiting")})})},"waiting");let A=c||a||l||K;return P("div",{className:Ey(s.root),"data-testid":"widget",children:wt($n,{className:s.sectionList,children:[A&&P(ke,{title:e("actions"),type:"shortcuts",children:wt("div",{className:s.shortcutList,children:[c&&wt("button",{className:s.shortcut,"data-testid":"shortcut-search",onClick:()=>O.send("ShowCommandPalette",{isOpen:!0}),children:[P(ut,{}),e("linkSearch")]}),a&&wt("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>O.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[P($c,{}),e("linkSummary")]}),l&&wt("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>O.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[P(Vc,{}),e("linkKnowledgeSearch")]}),K&&wt("a",{className:s.shortcut,target:"_blank",href:K,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[P(zc,{}),e("linkStudioLogin",{productName:I})]})]})}),i&&m.length>0&&P(ke,{type:"custom-messages","data-testid":"custom-messages",children:P(te,{withDivider:!0,children:m.map(k=>P(Nc,{suggestion:k},k.text))})}),r&&g.length>0&&P(ke,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:P(te,{withDivider:!0,children:P(Mc,{})})}),p.map(({type:k,title:V,amount:Bn,lines:Kn})=>{var et;switch(k){case"entities":return f&&f.length>0&&P(ke,{type:k,title:V,"data-testid":`type-${k}`,children:P(Kc,{entities:f})},k);case"cues":return u&&u.length>0&&P(ke,{type:k,title:V,"data-testid":`type-${k}`,children:P(te,{withDivider:!0,children:P(Zc,{cues:u,onRemoveCue:Ke=>o(Ri({id:Ke}))})})},k);default:return((et=S[k])==null?void 0:et.fetchState)==="done"&&S[k].suggestions.length>0&&P(ke,{type:k,title:V,"data-testid":`type-${k}`,children:P(te,{withDivider:!0,children:P(ed,{lines:Kn,contentType:k,suggestions:S[k].suggestions.slice(0,Bn)||[]})})},k)}})]})})},od=Ry;function ao(t){let e=new Range;return e.selectNodeContents(t),e}function nd(t,e,o){try{return Je(t,e,o),!0}catch{return!1}}function kn(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function In(t){return"tagName"in t&&t.tagName==="BR"}var io=/[\u200B-\u200D\uFEFF]/g;function Je(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let d=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(l))return c;for(let g=0;g<=l.length;g++)if(p.test(l[g])||d++,d===c)return g;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,d=c.replace(io,""),p=s+d.length,g=e>=s&&e<=p,u=o>=s&&o<=p;if(g){let f=i(c,e-s);f===0&&!u?n.setStartBefore(l):n.setStart(l,f)}u&&(n.setEnd(l,i(c,o-s)),r=!0),s=p;break}case Node.ELEMENT_NODE:{if(In(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let d=0;d<l.childNodes.length&&(a(l.childNodes[d]),!r);d++);let c=l.lastChild;kn(l)&&c&&!kn(c)&&!In(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function Rn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function d(p){let g=p===o,u=p===s;switch(p.nodeType){case Node.TEXT_NODE:{let f=p.textContent;g&&(a=c+f.substring(0,n).replace(io,"").length),u&&(l=c+f.substring(0,r).replace(io,"").length),c+=f.replace(io,"").length;break}case Node.ELEMENT_NODE:{let f=p.nextSibling===null;In(p)&&!f&&c++;for(let m=0;m<p.childNodes.length;m++){let v=g&&m===n,T=u&&m===r;if(v&&(a=c),T&&(l=c),l!==void 0||((!v||!i)&&d(p.childNodes[m]),u&&m===r-1&&(l=c),l!==void 0))break}!u&&kn(p)&&!f&&c++,u&&(l=c);break}default:break}}if(d(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function Pn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let d=c===o,p=c===s;switch(d&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let g=d?n:0,u=p?r:void 0,f=c.textContent.replace(io,"");g===0&&u===void 0?a+=f:a+=f.substring(g,u);break}case Node.ELEMENT_NODE:{let g=c.nextSibling===null;i===0&&In(c)&&!g&&(a+=`
|
|
8
|
+
`);for(let u=d?n:0;u<(p?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[u]),i!==1);u++);!p&&i===0&&kn(c)&&!g&&(a+=`
|
|
9
|
+
`);break}default:break}p&&i++}return l(t),a}var sd=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(sd||{}),Fe=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e}),n&&(this.currentSelection=this.getSelection()),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e}),this.triggerCaretPosition(),this.currentHTML=o))}triggerSelection(){let e=this.getSelection();(e.start!==this.currentSelection.start||e.end!==this.currentSelection.end)&&(this.currentSelection=e,this.emit("selection",e),this.triggerCaretPosition())}triggerCaretPosition(){let e=this.getCaretPosition();Re(e,this.currentCaret)||(this.currentCaret=e,this.emit("caret",e))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(sd).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",o=>this.handlePaste(o)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},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()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function rd(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Ct=class extends Fe{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),Pn(this.element,e)}getHTML(){return this.element.innerHTML||""}getRange(){var r;let e=this.getRootNode();if(e.activeElement!==this.element)return null;let o="getSelection"in e?e.getSelection():window.getSelection();if(!o)return null;let n="getComposedRanges"in o&&e instanceof ShadowRoot?(r=o.getComposedRanges(e))==null?void 0:r[0]:o.rangeCount>0?o.getRangeAt(0):null;if(!n)return null;let s=this.element.ownerDocument.createRange();return s.setStart(n==null?void 0:n.startContainer,n==null?void 0:n.startOffset),s.setEnd(n==null?void 0:n.endContainer,n==null?void 0:n.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let e=this.getRange();if(!e||!e.collapsed||!("getBoundingClientRect"in e))return null;let o=e.getBoundingClientRect();return!rd(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!rd(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return Rn(this.element,e);let o=this.lastKnownSelection;if(o&&nd(this.element,o.start,o.end))return o;let n=ao(this.element);return n.collapse(!1),Rn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return Pn(this.element,Je(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var Tt=class extends Fe{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};function id(t,e,o){let n=`deepdesk-iframe-${t}`,s=document.getElementById(n);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(o).forEach(([a,l])=>{i.searchParams.append(a,l)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=n,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}function Py(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}var yr=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];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()}},vr=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=id(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Sr=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),C.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new vr(e,this.deepdeskUrl,{debug:!0}):new yr(e),n=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=Py(s.data);typeof r!="object"||r.type!=="event"||r.channel!==e||(C.info("Received broadcast event",this.sessionId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return o.onMessage(n),o}send(e,o,n){var i,a;C.info("Broadcast event",{sessionId:this.sessionId,name:e,payload:o});let s={type:"event",name:e,payload:o};n!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,o));let r=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage({...s,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},ad=Sr;var Et=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var _r=t=>new Promise(e=>{setTimeout(e,t)});var kt=class extends Et{name="ClientError"},xr=class extends Et{name="ServerError"},ge=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:g=x=>x instanceof TypeError,retryOnResponse:u=x=>x.status>=500,version:f="v1",...m}=o,v={credentials:"include",...m,headers:{"Content-Type":"application/json",...m.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(v.headers={...v.headers,"X-CSRFToken":this.csrfToken}),typeof f=="string"&&(v.headers={...v.headers,"X-Deepdesk-API-Version":f});let T=c,_=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let y=async()=>(T--,a(i,v).then(async x=>u(x)&&!r.isAborted&&T>0?(await _r(d),y()):x.status===401&&p===!0&&_===!1?(_=!0,await this.refreshToken(),y()):x).catch(async x=>{if(g(x)&&!r.isAborted&&T>0)return await _r(d),y();throw x}));y().then(x=>x.json().catch(()=>null).then(S=>{x.status>=500?s(new xr("Server Error",S)):x.status===401?s(new kt("Unauthorized",S)):x.status===403?s(new kt("Forbidden",S)):x.status===404?s(new kt("Not Found",S)):x.status>=400&&s(new kt("Bad Request",S)),delete this.latestRequestByUrl[i],n(S)})).catch(x=>{s(x)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var Ay;(e=>{let t;(l=>(l.SEND_MESSAGE="Send Message",l.HANDLING_TIME="Handling Time",l.START_AUTOFLOW="Start Autoflow",l.ABORT_AUTOFLOW="Abort Autoflow",l.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",l.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(t=e.EventType||={})})(Ay||={});function An(t){return{...R(t),tags:t.tags}}var Be=class t{constructor(e,o={}){this.options=o;this.client=new ge(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),C.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...U(e),tags:e.tags},{version:"v2"});return An(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return R(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return R(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return R(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return R(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),C.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return C.info(`Successfully retrieved conversation ${r.id} for session ${e}`),An(r)}async isConversationSupported(e,o={}){C.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=U(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return An(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...U(s),tags:s.tags})),{version:"v2"})).map(s=>An(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",U({...r,...s,data:n,name:e}),{version:"v2"})}async sendEventV1(e,o){let n=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[r,i])=>({...s,[r]:i}),{});return this.client.post("/api/events",{event:e,data:U({...o,...n})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(n=>n.text)})).entities}async getSummary(e,o={}){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source),agent_id:o.agentId,id:o.externalConversationId},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw C.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.preflight(),await this.client.post("/apis/admin/session/api-key/",U(o),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,o={},n){return n==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${n}`,U(o),{abortLatest:!0})).map(r=>({...R(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,o){return(await this.client.post(`/api/conversations/${e}/autocomplete`,U(o),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let o=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return R(o).map(n=>({...n,text:n.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let o=await this.client.post("/api/style-suggestions",U(e),{abortLatest:!0});return R(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,U(e),{version:"v2"});return R(o)}async knowledgeAssist(e,o,n,s={}){let r=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,U({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(i=>({question:i.question,answer:i.answer.answer})),agentId:s.agentId,conversationId:s.conversationId}),{version:"v2"});return R(r)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return R(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return R(e.token)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return R(o)}async evaluateRule(e,o,n,s={}){let r=new URLSearchParams;s.raiseForFailingConditions&&r.set("raise_for_failing_conditions","true");let i=await this.client.post(`/api/conversations/${o}/rules/${e}/evaluate?${r.toString()}`,n,{version:"v2"});return R(i.cues)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(Ur);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&C.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var lo=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(ts(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,R(s))}catch{C.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var Ly;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Ly||={});var co=class{constructor(e,o={}){this.apiUrl=e;this.client=new ge(e,o)}client;streams={};logger=C;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return R(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,U(o));return R(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,U(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return R(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",U(e));return R(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new lo(`${this.apiUrl}/sessions/${e}/events`),this.streams[e].connect()),this.streams[e]}closeStream(e){this.streams[e]||(this.streams[e].disconnect(),delete this.streams[e])}};import{combineReducers as By,configureStore as Ky}from"@reduxjs/toolkit";import{createSlice as My}from"@reduxjs/toolkit";var ld={startTime:null,stopTime:null},cd=My({name:"handlingTime",initialState:ld,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(M,()=>ld)}}),{handlingTimeStart:dd,handlingTimeStop:Ln,handlingTimeReset:pd}=cd.actions,ud=cd.reducer;var gd=(t={})=>{let e={onAuthError:rt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};import{createAsyncThunk as Oy,createSlice as Ny}from"@reduxjs/toolkit";var Mn={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Ye=Oy("styleSuggestions/getAll",async({text:t},e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),{showStyleSuggestions:s}=n.settings,r=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)return Mn.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Dy=Ny({name:"styleSuggestions",initialState:Mn,reducers:{},extraReducers:t=>{t.addCase(Ye.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Ye.rejected,e=>{e.fetchState="error"}).addCase(Ye.fulfilled,(e,o)=>{e.fetchState="done",Re(e.list,o.payload)||(e.list=o.payload)}).addCase(Ue,e=>{e.list=Mn.list}).addCase(M,()=>Mn)}}),md=Dy.reducer;var fd=(t={})=>{let e,o=!0,n={getStyleSuggestions:Ye,debounce:500,...t};return s=>r=>i=>{var u;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:d}=c.settings;if(!((u=c.conversation.current)==null?void 0:u.id)||!d)return l;let{text:g}=c.input;return g===a&&!o||(clearTimeout(e),g==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:g}))},t.debounce)),l}};function Hy(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var hd=(t={})=>{let e={getTextSuggestions:le,getAutocompleteSuggestions:Qt,debounce:200,check:St,...t},o;return n=>s=>r=>{var m;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:d}=l.settings,p=(m=l.conversation.current)==null?void 0:m.id,g=r.type===Yo.toString();if(!p||!c&&!d)return a;let{input:{userCommitted:u}}=l;return Hy(u,i)&&!g||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=ct(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},g?0:e.debounce)),a}};var yd=Ye.fulfilled.toString();function Fy(t,e){let o=new Set([...e.keywordMatches.map(s=>s.keyword)]),n=[];return o.forEach(s=>{let r=t.keywordMatches.filter(l=>l.keyword===s),i=e.keywordMatches.filter(l=>l.keyword===s),a=i.length-r.length;a<=0||n.push(...i.slice(0,a))}),n}var vd=t=>e=>o=>n=>{var c;if(n.type!==yd){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(c=r.conversation)==null?void 0:c.current;if(s===i)return;let l=Fy(s,i);n.type===yd&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Uy=By({answer:Ka,auth:Zr,autoflows:uc,conversation:ei,contentTypes:Ji,customMessages:xc,passwordlessToken:Ec,entities:Ca,knowledgeAssistant:Ha,handlingTime:ud,info:Si,input:fi,settings:jr,profile:$a,search:Ei,summary:Aa,styleSuggestions:md,ui:vl,rules:Pi,textSuggestions:ol});function Sd(t){return Ky({reducer:Uy,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),gd(),hd({debounce:200}),fd({debounce:500}),vd(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var zy=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},jy=t=>e=>o=>n=>{var a;let s=e.getState(),r=Xn("inlineSuggestions")(s);switch(n.type){case rt.toString():{!n.payload&&t.emit("logout",void 0);break}case se.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:zy(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case To.toString():{let{start:l,end:c}=s.input.selection;t.emit("replace",{...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Nt.toString():{let l=e.getState(),{text:c,selection:d}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:d},{mayApplyChanges:!0});break}case Io.toString():t.emit("select-image",n.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:n.payload.suggestion.image,title:n.payload.suggestion.title}});break;case ae.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case _e.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case $.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case Eo.toString():t.handleKeyDown(n.payload);break;case Ue.toString():t.logSendMessage(n.payload);break;case ko.toString():t.handleInputChanged(n.payload);break;case Se.fulfilled.toString():t.broadcast(is,n.payload,!1),t.emit("cues",n.payload);break;default:break}let i=o(n);switch(n.type){case Ue.toString():t.handleAfterSendMessage(n.payload);break;case Jt.toString():t.onUpdateShowTabHint(n.payload);break;case Ln.toString():t.logHandlingTime();break;case se.toString():{r&&(e.dispatch(ce([])),e.dispatch(ve()));break}case ce.toString():{r&&n.payload.length>0&&e.dispatch(Ae(0));break}default:break}return i},_d=jy;function br(t){return t.toISOString().replace("T"," ").replace("Z","")}function xd(t,e){var s,r,i;let{startTime:o,stopTime:n}=t.handlingTime;if(!o||!n)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:t.conversation.current.id,clientVersion:e.version,agentId:(s=t.info.agentInfo)==null?void 0:s.agentId,agentName:(r=t.info.agentInfo)==null?void 0:r.agentName,agentEmail:(i=t.info.agentInfo)==null?void 0:i.agentEmail,timeStart:br(o),timeStop:br(n)}}function bd(t,e,o){var F,K,H;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:d,pastes:p,cuts:g,deletions:u,textSuggestions:f,offeredTextSuggestions:m}}=e[t],v=n.length,_=f.reduce((I,{text:A,searchTerm:k})=>I+A.length-(k?k.length:0),0),y=c??Date.now(),x=(Date.now()-y)/1e3+(d||0),S=s/x,O=f.reduce((I,{searchTerm:A})=>I+(A?A.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:p,cuts:g,deletions:u,lenTextTyped:s+O,lenTextTotal:v,lenTextAssisted:_,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:x,charsPerSecond:S,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:m.filter(I=>I.source==="gpt").length}],agentId:(F=e.info.agentInfo)==null?void 0:F.agentId,agentName:(K=e.info.agentInfo)==null?void 0:K.agentName,agentEmail:(H=e.info.agentInfo)==null?void 0:H.agentEmail}}function wr(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return wr(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?wr(s,e):null}function wd(t,e){return wr(t,e)}function Cd(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Vy(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Cr(t){return Vy(t)&&(De(t)||dn(t))}var Td,me=new Map,qy=["bottom","height","left","right","top","width"],$y=(t={},e={})=>qy.some(o=>t[o]!==e[o]);function Ed(t){var o,n;if(t.ownerDocument===document)return[];let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...Ed(e)]:[]}function kd(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var On=!1,Id=()=>{On=!0;let t=[];if(me.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),me.delete(o);return}let n=o.getBoundingClientRect();$y(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(kd,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),me.size===0){On=!1;return}Td=window.requestAnimationFrame(Id)};function Tr(t,e){let o=Ed(t),n=[],s=o.map((r,i)=>Tr(r,a=>{n[i]=a;let l=me.get(t);if(!l)return;let c=n.reduce(kd,l.rect);l.callbacks.forEach(d=>d(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),me.has(t)){let i=me.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else me.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!On&&Id()},unobserve(){s.forEach(i=>i.unobserve());let r=me.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||me.delete(t),me.size||(cancelAnimationFrame(Td),On=!1)}}}}var Rd,fe=new Map,Pd=()=>{fe.forEach((t,e)=>{if(!e.isConnected){fe.delete(e);return}let{clientHeight:o,scrollHeight:n}=e,s=n>o;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),fe.size!==0&&(Rd=window.requestAnimationFrame(Pd))};function Ad(t,e){return{observe(){let o=fe.size===0;fe.has(t)?fe.get(t).callbacks.push(e):fe.set(t,{visible:void 0,callbacks:[e]}),o&&Pd()},unobserve(){let o=fe.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||fe.delete(t),fe.size||cancelAnimationFrame(Rd)}}}}var Er=["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 kr(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function It(t){return parseFloat(t)}function Nn(t){return Math.round(t*1e6)}function Ld(t){return t/1e6}function Ir(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=It(t.width),r=It(t.borderLeftWidth),i=It(t.borderRightWidth),a=It(t.paddingRight),l=Ld(Nn(s)-Nn(r)-Nn(i)),c=Ld(Nn(n));if(l-c>2){let d=l-c;o.style.paddingRight=`${a+d}px`}}function Dn(t,e={}){var d;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Ge(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};kr(n,o,Er),Ir(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=Ad(t,()=>{kr(n,o,Er),Ir(n,t,o),r(),setTimeout(r,0)}),a,l=!0,c=Tr(t,p=>{if(p===null){e.onRemove&&e.onRemove(),o.remove();return}if(!l&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),l=!1},200),p.height===0&&p.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(kr(n,o,Er),Ir(n,t,o),r(),o.style.top=`${p.top}px`,o.style.left=`${p.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let g=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),f=It(u.borderTopWidth),m=It(u.borderBottomWidth),v=g.top+f-p.top,T=p.top+p.height+-(g.top+g.height-m);o.style.clipPath=`inset(${v}px 0px ${T}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(d=t.parentElement)==null||d.appendChild(o),c.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),c.unobserve(),i.unobserve()}]}var Md=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{C.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Wy(t){return t.offsetParent!==null}function Od(t){if(!Wy(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 Rr(t,e,o=100){let n=Od(t);e({isVisible:n});let s=setInterval(()=>{let r=Od(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import{jsx as z}from"react/jsx-runtime";var Nd=Md("showTabHint",!0),Fn=class t{static version="10.12.1-beta.10";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new Be(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let d={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[_d({broadcast:(p,g,u)=>{this.broadcastEvents.send(p,g,u)},emit:(p,g,u)=>this.emit(p,g,u),handleAfterSendMessage:p=>this.handleAfterSendMessage(p),handleInputChanged:p=>this.handleInputChanged(p),handleKeyDown:p=>this.handleKeyDown(p),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:p=>this.logSendMessage(p),onUpdateShowTabHint:p=>Nd.update(p),sendEvent:(p,g)=>this.deepdeskApi.sendEvent(p,g)})]};o&&Object.assign(d,{deepdeskBrokerAPI:new co(o)}),this.store=Sd(d),this.broadcastEvents=new ad({debug:!0,deepdeskUrl:c,eventMap:Ai(this.store),createCustomChannel:l}),this.store.dispatch(Jt(Nd.value())),this.store.dispatch(yo({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(C.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(C.warn("Profile has not been loaded (yet)"),!0):(C.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(rt(null)),this.store.dispatch(ye()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();G(n)&&Vr(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(ye())).payload}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){C.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(Jn({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(_o(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(xo({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Yn(e))).payload}async postMessages(e){return(await this.store.dispatch(wo(e))).payload}async updateConversation(e){return(await this.store.dispatch(bo(e))).payload}resetConversation(){this.store.dispatch(M()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(_e());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(yo(e))}setVisitorInfo(e){this.store.dispatch(vi(e))}async setAgentInfo(e){await this.store.dispatch(Dt(e))}async setAgentSettings(e){await this.store.dispatch(ns(e))}async getAgentSettings(){return(await this.store.dispatch(ss())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(Yo()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(ko(e))}notifyKeyDown(e){this.store.dispatch(Eo(e))}notifyPaste(e,o){this.store.dispatch(pi({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(ci(e))}notifyExternalSuggestion(e){this.store.dispatch(se(e)),this.store.dispatch(ve())}async evaluateRule(e,o={}){let{payload:n,error:s}=await this.store.dispatch(Se({label:e,params:o}));if(s)throw s;return n}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(Ne({collapse:!1})),this.inputMediator&&this.store.dispatch(si({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(ce([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(di(ti(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(ii()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},d=()=>{o||!a||i&&s<=0||r&&(e.shiftKey||(this.store.dispatch(li()),e.preventDefault(),!i&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(Nt()):this.stageSelectedSuggestion({inputType:"arrow"}))))};switch(e.key){case"Up":case"ArrowUp":i?d():c();return;case"Down":case"ArrowDown":{i?c():d();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(Ae(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Ae(-1)),this.store.dispatch(Nt()),e.preventDefault()):o||(this.store.dispatch(Ne({collapse:!0})),this.store.dispatch(hl(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:p}=this.state.input,g=p.text.substring(0,p.selection.end),{tabCompletionSuggestion:u}=this.state.input;this.store.dispatch(Jt(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&u&&u.text.startsWith(g)&&(this.store.dispatch(se({text:u.text,suggestion:u,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(ve())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(ui()),this.store.dispatch(ce([]))}handlingTimeStart(){this.state.handlingTime.startTime||(C.info("Start handling time"),this.store.dispatch(dd()))}handlingTimeStop(){this.state.handlingTime.startTime&&(C.info("Stop handling time"),this.store.dispatch(Ln()))}logSendMessage(e){let o=bd("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logHandlingTime(){let e=xd(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(pd())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(ve()),this.store.dispatch(Ue(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(se({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){C.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),C.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=Dn(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{Hn(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=Dn(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{Hn(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Ge(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,s.setAttribute("translate","no"),o.appendChild(s),this.unmountHandlers.push(()=>{Hn(s),s.remove()}),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,o),C.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=window.sessionStorage.getItem(e);if(!o)return;let n=JSON.parse(o);n.text.trim()===this.state.input.text.trim()?(C.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(mi(n.metrics))):C.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch{}}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Cr(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:d,isEmbedded:p,detectSubmit:g,insertLink:u,inputMediator:f,closestScrollSelector:m,appendOverlayTo:v,inlineSuggestions:T,floatingMenu:_}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:d,showTextSuggestions:i,insertLink:u,isEmbedded:p,inlineSuggestions:T,floatingMenu:!!_}),o.automaticHandlingTime&&this.setupHandlingTime(e),Ge(e),this.inputMediator=f||(De(e)?new Tt(e):new Ct(e)),this.inputMediator.on("change",({plainText:S})=>{this.notifyInputChanged(S)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(gi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",S=>{this.notifyKeyDown(S)}),this.inputMediator.on("paste",({pastedText:S,selectionText:O})=>{this.notifyPaste(S,O)}),this.inputMediator.on("cut",({selectionText:S})=>{this.notifyCut(S)});let y=m&&wd(e,m)||void 0;if(T){let{customStyles:S,appendOverlayTo:O}=o;if(De(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let F=this.createInlineContainer(e,"deepdesk-caret");Rt(z(Xe,{store:this.store,customStyles:S,children:z(je,{broadcastEvents:this.broadcastEvents,children:z(Cl,{})})}),F),this.inputMediator.on("caret",H=>{this.store.dispatch(ce([])),H?(F.style.display="block",F.style.top=`${H.top}px`,F.style.left=`${H.left}px`):F.style.display="none"});let K=this.overlayContainerFactory("floating-menu",y||e,{appendTo:typeof _=="object"&&"appendOverlayTo"in _?_.appendOverlayTo:O},S==null?void 0:S.floatingMenuRootNode);Rt(z(Xe,{store:this.store,customStyles:S,children:z(je,{broadcastEvents:this.broadcastEvents,children:z(ml,{onLogIn:()=>this.loginViaPopup().catch(H=>C.warn(H.message))})})}),K)}else{let S=this.overlayContainerFactory("deepdesk-tab-completion",y||e,{appendTo:v,closestScrollElement:y,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),O=this.overlayContainerFactory("deepdesk-suggestions-overlay",y||e,{appendTo:v},n==null?void 0:n.suggestionsRootNode);Rt(z(Xe,{store:this.store,customStyles:n,children:z(je,{broadcastEvents:this.broadcastEvents,children:z(ic,{inputElement:e})})}),S),Rt(z(Xe,{store:this.store,customStyles:n,children:z(je,{broadcastEvents:this.broadcastEvents,children:z(Ol,{onLogIn:()=>this.loginViaPopup().catch(F=>C.warn(F.message))})})}),O)}Rt(z(Xe,{store:this.store,customStyles:n,children:z(je,{broadcastEvents:this.broadcastEvents,children:z(ll,{})})}),this.createContainer("deepdesk-overlays"));let x;this.inputMediator.on("selection",S=>{clearTimeout(x),S===null?x=setTimeout(()=>{S!==null&&this.store.dispatch(es(S))},500):this.store.dispatch(es(S))}),this.inputMediator.on("disabled",()=>{var S;(S=this.inputMediator)==null||S.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{g&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch($s(!1))),this.inputMediator.on("focus",()=>this.store.dispatch($s(!0))),this.store.dispatch(ri({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(ve()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var S;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((S=this.state.conversation.current)==null?void 0:S.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&C.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,isEmbedded:r}=o;this.widgetRoot=e,this.configure({showImages:s,isEmbedded:r}),Rt(z(Xe,{store:this.store,customStyles:n,children:z(je,{broadcastEvents:this.broadcastEvents,children:z(od,{onLogIn:()=>this.loginViaPopup().catch(i=>C.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&Hn(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Rr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Cd(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(Zt());let e=Oe(this.state);e&&(await this.store.dispatch(Xt()),this.store.dispatch(yo({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(e){return new Promise((o,n)=>{let s=new MessageChannel,r=s.port1,i=this.state.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 l=!1,c=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",p),clearInterval(g)};r.onmessage=async u=>{var f,m;if((f=u.data)!=null&&f.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((m=u.data)==null?void 0:m.jwt),await this.isLoggedIn(),this.broadcastEvents.send(Ft),l=!0,s.port1.close(),o()}catch(v){console.error(v),n(v)}finally{l=!0,c()}};let d=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&n(new Error("Popup blocked by browser"));let p=async u=>{var f;if(u.origin===a.origin)switch((f=u.data)==null?void 0:f.type){case"deepdesk-popup-loaded":{try{let m=JSON.stringify({type:"deepdesk-popup-create-channel"});d==null||d.postMessage(m,a.origin,[s.port2])}catch(m){C.error("Error posting message to popup",m),n(m)}break}case"deepdesk-popup-error":{c(),u.data.message==="Timeout"&&C.warn("Popup timed out. Check if the account's platform url is configured correctly."),n(new Error(u.data.message));break}}};window.addEventListener("message",p);let g=setInterval(()=>{d&&!d.closed||(c(),l||n(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(C.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;C.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=Qo(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(ae()):this.store.dispatch(le(n))})}catch(n){this.handleError(n)}}};async function Gy(t,e,o={}){let{value:n}=t,{start:s,end:r}=o.replace??{start:0,end:n.length},i=`${n.slice(0,s)}${e}${n.slice(r)}`,a=o.selectionAfter??{start:s+e.length,end:s+e.length},l=()=>{if(o.setValue)return o.setValue(i);t.value=i};return Promise.resolve(l()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function Xy(t,e,o={}){let n=o.replace?Je(t,o.replace.start,o.replace.end):ao(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),o.insertBRs!==!1?e.split(`
|
|
10
|
+
`).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}):n.insertNode(document.createTextNode(e))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?Je(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Zy(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 Qy(t){let e=document.createDocumentFragment();return t.split(`
|
|
11
|
+
`).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=o.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(o.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(o.slice(r)))}),e}function Dd(t,e){return!t.contains(e)||e===t?null:e.parentNode===t?e:Dd(t,e.parentNode)}async function Jy(t,e,{isBlock:o,isHTML:n}={}){let s;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let r=()=>{let i=t.ownerDocument.defaultView??window,a=i.getSelection();if((!a||a.rangeCount===0)&&(t.focus(),a=i.getSelection()),!a||a.rangeCount===0)return;let l=a.getRangeAt(0);if(!l)return;s=document.createElement("span"),l.insertNode(s);let c=n?Zy(e):Qy(e);if(o){let d=l.startContainer===t?t.childNodes[l.startOffset]:l.startContainer,p=Dd(t,d)??t.firstChild;t.insertBefore(c,(p==null?void 0:p.nextSibling)??null)}else l.insertNode(c),l.collapse(!1)};return Promise.resolve(r()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Yy(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function ev(t,e,o){await new Be(t).authenticateWithKey(e,o)}async function tv(t){let o=await new ge(t).get("/platform/config/",{version:null});return R(o)}async function ov(t){let o=await(t.fetch??window.fetch)(t.url),n=await o.blob();return new File([n],t.name,{type:t.mimeType??o.headers.get("Content-Type")??"image/jpeg"})}async function nv(t,e){let o=await ov(e),n=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[o]}),t.dispatchEvent(n)}finally{Object.hasOwn(t,"files")&&delete t.files}}export{N as Card,Ct as ContentEditableInput,Be as DeepdeskAPI,Fn as DeepdeskSDK,ge as HTTPClient,Fe as InputMediator,st as InputType,jn as KeyboardHint,Vn as Label,ho as Locale,ke as Section,$n as SectionList,Ie as Sources,L as Suggestion,te as SuggestionList,Tt as TextAreaInput,nt as ToggleButton,nv as attachFile,ev as authenticateWithKey,ao as createFullRange,Dn as createOverlayContainer,Je as createRangeFromOffsets,Wt as escapeHTML,tv as fetchPlatformConfig,Yy as formatTextMarkup,Rn as getRangeOffsets,Pn as getRangeText,Jy as insertCKEditor,ws as isHTML,Cr as isSupportedInputElement,Xy as updateContentEditable,Gy as updateTextArea,h as useStyles,Rr as waitForElementVisibilityChange};
|