@deepdesk/deepdesk-sdk 10.9.1 → 10.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";var Fu=Object.create;var kn=Object.defineProperty;var Ku=Object.getOwnPropertyDescriptor;var Uu=Object.getOwnPropertyNames;var zu=Object.getPrototypeOf,ju=Object.prototype.hasOwnProperty;var V=(t,e)=>{for(var o in e)kn(t,o,{get:e[o],enumerable:!0})},aa=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Uu(e))!ju.call(t,s)&&s!==o&&kn(t,s,{get:()=>e[s],enumerable:!(n=Ku(e,s))||n.enumerable});return t};var T=(t,e,o)=>(o=t!=null?Fu(zu(t)):{},aa(e||!t||!t.__esModule?kn(o,"default",{value:t,enumerable:!0}):o,t)),qu=t=>aa(kn({},"__esModule",{value:!0}),t);var lh={};V(lh,{Card:()=>F,ContentEditableInput:()=>qt,DeepdeskAPI:()=>it,DeepdeskSDK:()=>wn,HTTPClient:()=>Me,InputMediator:()=>je,InputType:()=>ct,KeyboardHint:()=>Mn,Label:()=>Nn,Locale:()=>Do,Section:()=>lt,SectionList:()=>On,Sources:()=>Te,Suggestion:()=>D,SuggestionList:()=>Se,TextAreaInput:()=>qe,ToggleButton:()=>kt,attachFile:()=>Ru,authenticateWithKey:()=>ku,createFullRange:()=>Ao,createOverlayContainer:()=>At,createRangeFromOffsets:()=>wt,escapeHTML:()=>po,fetchPlatformConfig:()=>xr,formatTextMarkup:()=>Eu,getRangeOffsets:()=>_n,getRangeText:()=>xn,insertCKEditor:()=>Tu,isSupportedInputElement:()=>vr,updateContentEditable:()=>wu,updateTextArea:()=>Cu,useStyles:()=>y,waitForElementVisibilityChange:()=>Sr});module.exports=qu(lh);var Pn=T(require("classnames")),he=T(require("react"));var Rn=T(require("react")),la=T(require("classnames")),No=Rn.default.createContext({});function y(t,e){let{debug:o,...n}=(0,Rn.useContext)(No),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,la.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var ca={root:"_root_vr71j_1"};var Tt=require("react/jsx-runtime"),In=()=>(0,Tt.jsxs)("svg",{className:ca.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Tt.jsx)("defs",{children:(0,Tt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Tt.jsx)("title",{children:"Failed loading image"}),(0,Tt.jsx)("path",{className:"cls-1",d:"M15 130.896V16.994c0-1.097.898-1.994 2.007-1.994h150.986A2 2 0 0 1 170 16.994v69.147L133.015 51 87.26 120.377l-35.863-17.758L15 130.896zM2 0C.895 0 0 .887 0 2v166c0 1.105.887 2 2 2h181c1.105 0 2-.887 2-2V2c0-1.105-.887-2-2-2H2zm49 72c11.046 0 20-9.178 20-20.5S62.046 31 51 31s-20 9.178-20 20.5S39.954 72 51 72z",fillRule:"evenodd"})]});var wr={root:"_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"};var Et=require("react/jsx-runtime"),An=(0,he.createContext)(wr),Vu=({title:t,src:e})=>{let o=(0,he.useContext)(An),[n,s]=(0,he.useState)(!1);return(0,he.useEffect)(()=>{s(!1)},[e]),(0,Et.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,Et.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,Et.jsx)(In,{})})},Wu=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,he.useContext)(An);return(0,Et.jsx)("div",{className:(0,Pn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Gu=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,he.useContext)(An);return he.default.createElement(t,{className:(0,Pn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Ln=({children:t})=>{let e=y("Card",wr);return(0,Et.jsx)("div",{className:(0,Pn.default)(e.root),children:(0,Et.jsx)(An.Provider,{value:e,children:t})})};Ln.Image=Vu;Ln.Content=Wu;Ln.Title=Gu;var F=Ln;var da=T(require("classnames"));var pa={root:"_root_cq1yq_1"};var ua=require("react/jsx-runtime");var $u={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Xu=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",pa);return(0,ua.jsx)("span",{"data-key":$u[e],className:(0,da.default)(t,n.root),...o})},Mn=Xu;var ma=T(require("classnames"));var ga={root:"_root_4a08n_1"};var fa=require("react/jsx-runtime"),Qu=({className:t,children:e,...o})=>{let n=y("Label",ga);return(0,fa.jsx)("span",{...o,className:(0,ma.default)(t,n.root),children:e})},Nn=Qu;var ha={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var Zt=require("react/jsx-runtime"),Zu=({title:t,children:e,type:o,...n})=>{let s=y("Section",ha);return(0,Zt.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,Zt.jsx)("div",{className:s.subTitleContainer,children:(0,Zt.jsx)("span",{className:s.subtitle,children:t})}),(0,Zt.jsx)("div",{className:s.suggestions,children:e})]})},lt=Zu;var va=T(require("classnames")),Sa=T(require("react"));var ya={root:"_root_19wxp_1"};var _a=require("react/jsx-runtime"),Ju=Sa.default.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",ya);return(0,_a.jsx)("div",{ref:o,className:(0,va.default)(n.root,t),children:e})}),On=Ju;var Oo=T(require("classnames")),ve=T(require("react"));var Tr={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"};var ye=require("react/jsx-runtime"),Jt=(0,ve.createContext)(Tr),Yu=({fixed:t,children:e,...o})=>{let n=(0,ve.useContext)(Jt);return(0,ye.jsx)("div",{...o,className:(0,Oo.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},eg=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,ve.useContext)(Jt);return(0,ye.jsxs)("div",{className:(0,Oo.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,ye.jsx)("ul",{className:r.dropdownList,children:s})]})},tg=({index:t,label:e,onClick:o})=>{let n=(0,ve.useContext)(Jt);return(0,ye.jsx)("li",{className:n.dropdownItem,children:(0,ye.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},og=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,ve.useContext)(Jt);return(0,ye.jsx)("button",{type:"button",className:(0,Oo.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Er=({labels:t})=>{let e=(0,ve.useContext)(Jt);return(0,ye.jsx)("div",{className:e.labels,children:t.map(o=>(0,ye.jsx)("span",{className:e.label,children:o},o))})},Yt=ve.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",Tr),l=(0,ve.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,ye.jsx)(s,{...r,ref:i,className:(0,Oo.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,ye.jsx)(Jt.Provider,{value:a,children:n})})});Yt.Labels=Er;Yt.Actions=Yu;Yt.ActionButton=og;Yt.DropdownButton=eg;Yt.DropdownItem=tg;var D=Yt;var ba=T(require("classnames"));var xa={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var Ca=require("react/jsx-runtime"),ng=({withDivider:t,children:e})=>{let o=y("SuggestionList",xa);return(0,Ca.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,ba.default)(o.root,{[o.isWithDivider]:t}),children:e})},Se=ng;var Ta=T(require("classnames"));var wa={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Dn=require("react/jsx-runtime"),sg=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",wa);return(0,Dn.jsx)("button",{type:"button",className:(0,Ta.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,Dn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Dn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},kt=sg;var Ea=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,eo=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ka=/x-deepdesk-(([a-z0-9\-_])+-version)/,Te=(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))(Te||{}),ct=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(ct||{});var we=require("react-dom");var mp=require("react");var Ra=require("@reduxjs/toolkit"),Ia=require("react-redux");var Do=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Do||{});var rg={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"},Pa=(0,Ra.createSlice)({name:"settings",initialState:rg,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Ho}=Pa.actions,kr=t=>e=>e.settings[t],C=t=>(0,Ia.useSelector)(kr(t)),Aa=Pa.reducer;var Oc=require("react"),xo=require("react-redux");var Ne=require("@reduxjs/toolkit"),Da=require("diff"),Ha=require("react-redux");function La(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function pt(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)=>pt(r,e[i],o-1)):La(t)&&La(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>pt(t[i],e[i],o-1)):!1}function ig(t){return Math.max(...t.map(e=>e.length))}function ag(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 Ma(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<ig(n);s++){let r=ag(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 lg=2;function Rr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Ma(t,lg);return o&&o.text!==e?o:t[0]}var Ee=require("@reduxjs/toolkit"),Na={current:null,isSupported:null},A=(0,Ee.createAction)("resetConversation"),Hn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Bn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},to=t=>t.conversation.isSupported,Ir=(0,Ee.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Fn=(0,Ee.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Kn=(0,Ee.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Un=(0,Ee.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Bn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Pr=(0,Ee.createAsyncThunk)("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})})}),zn=(0,Ee.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Bn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),cg=[Fn.rejected,Kn.rejected,Un.rejected,zn.rejected].map(t=>t==null?void 0:t.toString()),pg=(0,Ee.createSlice)({name:"conversation",initialState:Na,reducers:{},extraReducers:t=>{t.addCase(Ir.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Fn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Kn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Pr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Un.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(zn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(A,()=>Na).addMatcher(e=>cg.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),Oa=pg.reducer;var dt={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 qn(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 Vn=(0,Ne.createAction)("input/replaceText"),Wn=(0,Ne.createAction)("input/keyDown"),Rt=(0,Ne.createAction)("input/sendMessage"),Gn=(0,Ne.createAction)("input/sendEditSuggestionMessage"),$n=(0,Ne.createAction)("input/uiInputChange"),Xn=(0,Ne.createAction)("input/applyImageSuggestion"),X=(0,Ne.createAction)("input/sendEvent");function jn(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",u=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(u=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(u=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:u,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 Ba=t=>(0,Ne.createSlice)({name:t,initialState:dt,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,{...dt,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=Rr(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(pt(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&jn(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:u,metaKey:g,altKey:f}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:m}=e,{text:v}=o.payload,w=(0,Da.diffChars)(m,v);m.length-v.length>1&&e.metrics.deletions.push(...w.filter(h=>h.removed).map(h=>h.value)),e.metrics.numCharsDeleted+=m.length-v.length;break}case"C":case"V":case"X":if(!u&&!g){e.metrics.numCharsTyped+=1;let m=((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;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}break;case"Shift":break;default:if(!u&&!g&&!f){e.metrics.numCharsTyped+=1;let m=((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;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=dt.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&jn(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"&&jn(e)},commitSuggestion(e){jn(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=Rr(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(A,o=>{o.tabCompletionSuggestion=dt.tabCompletionSuggestion,o.previousKeyDownEvent=dt.previousKeyDownEvent,o.textSuggestions=dt.textSuggestions,o.selectedSuggestionIndex=dt.selectedSuggestionIndex,o.metrics=dt.metrics})}}),Ar=Ba("input"),oo=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),dg=t=>t.input.selection,Fa=()=>(0,Ha.useSelector)(dg),{userInput:Ka,changeSelection:Lr,initialInput:Ua,mergeMetrics:za,nextTextSuggestionIndex:ja,offeredTextSuggestion:qa,previousTextSuggestionIndex:Va,registerCut:Wa,registerKeyDown:Ga,registerPaste:$a,reset:Xa,resetToCommitted:Bo,platformInput:Qa,setSelectedTextSuggestionIndex:ut,setTextSuggestions:Oe,stageSuggestion:ke,commitSuggestion:Ue,setMetrics:Za}=Ar.actions,ie=Ba("overlay");var no=require("react");var Ja={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var Mr=require("react/jsx-runtime"),ug=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,no.useRef)(null),l=(0,no.useRef)(null),c=y("Dialog",Ja);return(0,no.useEffect)(()=>{var u,g;let p=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},d=f=>{let m=window.getSelection();m!=null&&m.toString()||f.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(g=a.current)==null||g.addEventListener("keyup",p),()=>{var f,m;(f=a.current)==null||f.removeEventListener("click",d),(m=a.current)==null||m.removeEventListener("keyup",p)}},[a,l,s,n]),(0,no.useEffect)(()=>{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?(0,Mr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,Mr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},so=ug;var di=require("react"),Is=require("react-redux");var Nr={};V(Nr,{enUS:()=>gg,nlNL:()=>mg});var gg={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?"}]},mg={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 Ya={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};var cs=require("react");var Or=function(t,e){return Or=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])},Or(t,e)};function Fo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Or(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var pe=function(){return pe=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},pe.apply(this,arguments)};function el(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 Qn(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 Zn;(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"})(Zn||(Zn={}));var Jn=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Re;(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"})(Re||(Re={}));var Yn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Yn||(Yn={}));function Dr(t){return t.type===Re.literal}function tl(t){return t.type===Re.argument}function es(t){return t.type===Re.number}function ts(t){return t.type===Re.date}function os(t){return t.type===Re.time}function ns(t){return t.type===Re.select}function ss(t){return t.type===Re.plural}function ol(t){return t.type===Re.pound}function rs(t){return t.type===Re.tag}function is(t){return!!(t&&typeof t=="object"&&t.type===Yn.number)}function Ko(t){return!!(t&&typeof t=="object"&&t.type===Yn.dateTime)}function Hr(t){t.forEach(function(e){if(delete e.location,ns(e)||ss(e))for(var o in e.options)delete e.options[o].location,Hr(e.options[o].value);else es(e)&&is(e.style)||(ts(e)||os(e))&&Ko(e.style)?delete e.style.location:rs(e)&&Hr(e.children)})}function nl(t,e){e===void 0&&(e={}),e=pe({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Jn(t,e).parse();if(o.err){var n=SyntaxError(Zn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Hr(o.val),o.val}function as(t,e){var o=e&&e.cache?e.cache:_g,n=e&&e.serializer?e.serializer:Sg,s=e&&e.strategy?e.strategy:hg;return s(t,{cache:o,serializer:n})}function fg(t){return t==null||typeof t=="number"||typeof t=="boolean"}function sl(t,e,o,n){var s=fg(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function rl(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 Br(t,e,o,n,s){return o.bind(e,t,n,s)}function hg(t,e){var o=t.length===1?sl:rl;return Br(t,this,o,e.cache.create(),e.serializer)}function yg(t,e){return Br(t,this,rl,e.cache.create(),e.serializer)}function vg(t,e){return Br(t,this,sl,e.cache.create(),e.serializer)}var Sg=function(){return JSON.stringify(arguments)};function Fr(){this.cache=Object.create(null)}Fr.prototype.get=function(t){return this.cache[t]};Fr.prototype.set=function(t,e){this.cache[t]=e};var _g={create:function(){return new Fr}},ls={variadic:yg,monadic:vg};var It;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(It||(It={}));var Uo=function(t){Fo(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 Kr=function(t){Fo(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('", "'),'"'),It.INVALID_VALUE,r)||this}return e}(Uo);var il=function(t){Fo(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),It.INVALID_VALUE,s)||this}return e}(Uo);var al=function(t){Fo(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,'"'),It.MISSING_VALUE,n)||this}return e}(Uo);var Q;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(Q||(Q={}));function xg(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==Q.literal||o.type!==Q.literal?e.push(o):n.value+=o.value,e},[])}function bg(t){return typeof t=="function"}function zo(t,e,o,n,s,r,i){if(t.length===1&&Dr(t[0]))return[{type:Q.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Dr(p)){a.push({type:Q.literal,value:p.value});continue}if(ol(p)){typeof r=="number"&&a.push({type:Q.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new al(d,i);var u=s[d];if(tl(p)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?Q.literal:Q.object,value:u});continue}if(ts(p)){var g=typeof p.style=="string"?n.date[p.style]:Ko(p.style)?p.style.parsedOptions:void 0;a.push({type:Q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(os(p)){var g=typeof p.style=="string"?n.time[p.style]:Ko(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:Q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(es(p)){var g=typeof p.style=="string"?n.number[p.style]:is(p.style)?p.style.parsedOptions:void 0;g&&g.scale&&(u=u*(g.scale||1)),a.push({type:Q.literal,value:o.getNumberFormat(e,g).format(u)});continue}if(rs(p)){var f=p.children,m=p.value,v=s[m];if(!bg(v))throw new il(m,"function",i);var w=zo(f,e,o,n,s,r),h=v(w.map(function(_){return _.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(_){return{type:typeof _=="string"?Q.literal:Q.object,value:_}}))}if(ns(p)){var x=p.options[u]||p.options.other;if(!x)throw new Kr(p.value,u,Object.keys(p.options),i);a.push.apply(a,zo(x.value,e,o,n,s));continue}if(ss(p)){var x=p.options["=".concat(u)];if(!x){if(!Intl.PluralRules)throw new Uo(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,It.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));x=p.options[b]||p.options.other}if(!x)throw new Kr(p.value,u,Object.keys(p.options),i);a.push.apply(a,zo(x.value,e,o,n,s,u-(p.offset||0)));continue}}return xg(a)}function Cg(t,e){return e?pe(pe(pe({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=pe(pe({},t[n]),e[n]||{}),o},{})):t}function wg(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Cg(t[n],e[n]),o},pe({},t)):t}function Ur(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Tg(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:as(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Qn([void 0],o,!1)))},{cache:Ur(t.number),strategy:ls.variadic}),getDateTimeFormat:as(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Qn([void 0],o,!1)))},{cache:Ur(t.dateTime),strategy:ls.variadic}),getPluralRules:as(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Qn([void 0],o,!1)))},{cache:Ur(t.pluralRules),strategy:ls.variadic})}}var ll=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(u,g){return!u.length||g.type!==Q.literal||typeof u[u.length-1]!="string"?u.push(g.value):u[u.length-1]+=g.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return zo(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=el(i,["formatters"]);this.ast=t.__parse(e,pe(pe({},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=wg(t.formats,n),this.formatters=s&&s.formatters||Tg(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=nl,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 Eg(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var kg="dummy",zr=(0,cs.createContext)(null);function E(t){let e=(0,cs.useContext)(zr);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=Eg(o,n);return r?new ll(r).format(s):(e!==kg&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var jo=require("react/jsx-runtime"),ps=()=>(0,jo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,jo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,jo.jsx)("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});var qo=require("react/jsx-runtime"),cl=()=>(0,qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,qo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,qo.jsx)("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"})]});var _e=require("react"),Rl=require("react-redux"),Yr=require("interweave"),ei=T(require("classnames"));var jr={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var dl=require("interweave"),ul=T(require("classnames"));var ro=require("react");function pl(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function ds(t){let e=(0,ro.useRef)(null),[o,n]=(0,ro.useState)(!1);return(0,ro.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=pl((p,d)=>{let u=e.current;if(!u)return;let g=p/r,f=d/r,m=u.getBoundingClientRect(),v=g>m.x&&g<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:p,clientY:d})=>[p,d]),[l,c]=pl(()=>{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 ze={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"};var qr=require("react/jsx-runtime"),Rg=({inputElement:t,children:e})=>{let o=y("TabCompletion",ze),[n,s]=ds(t);return(0,qr.jsx)("mark",{ref:n,className:(0,ul.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},io=class extends dl.Matcher{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(0,qr.jsx)(Rg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var ao=require("react");function us(t){return t.contentEditable==="true"}function Ig(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 gl(t){let{selectionStart:e,selectionEnd:o}=us(t)?Ig(t):t;return[e,o]}function gs(t){let[,e]=(0,ao.useState)(),o=(0,ao.useRef)(null);return o.current=gl(t),(0,ao.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=gl(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 ms(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(eo);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)})}var ml=require("react");function lo(t){(0,ml.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Pt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var fl,De=new Map,Pg=["bottom","height","left","right","top","width"],Ag=(t={},e={})=>Pg.some(o=>t[o]!==e[o]);function hl(t){var o,n;let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...hl(e)]:[]}function yl(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var fs=!1,vl=()=>{fs=!0;let t=[];if(De.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),De.delete(o);return}let n=o.getBoundingClientRect();Ag(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(yl,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),De.size===0){fs=!1;return}fl=window.requestAnimationFrame(vl)};function Vr(t,e){let o=hl(t),n=[],s=o.map((r,i)=>Vr(r,a=>{n[i]=a;let l=De.get(t);if(!l)return;let c=n.reduce(yl,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),De.has(t)){let i=De.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else De.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!fs&&vl()},unobserve(){s.forEach(i=>i.unobserve());let r=De.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||De.delete(t),De.size||(cancelAnimationFrame(fl),fs=!1)}}}}var Sl,He=new Map,_l=()=>{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&&(Sl=window.requestAnimationFrame(_l))};function xl(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&&_l()},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(Sl)}}}}var Wr=["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 Gr(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function co(t){return parseFloat(t)}function hs(t){return Math.round(t*1e6)}function bl(t){return t/1e6}function $r(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=co(t.width),r=co(t.borderLeftWidth),i=co(t.borderRightWidth),a=co(t.paddingRight),l=bl(hs(s)-hs(r)-hs(i)),c=bl(hs(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function At(t,e={}){var l;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",Pt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Gr(n,o,Wr),$r(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=xl(t,()=>{Gr(n,o,Wr),$r(n,t,o),r(),setTimeout(r,0)}),a=Vr(t,c=>{if(c===null){e.onRemove&&e.onRemove(),o.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Gr(n,o,Wr),$r(n,t,o),r(),o.style.top=`${c.top}px`,o.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),d=window.getComputedStyle(e.closestScrollElement),u=co(d.borderTopWidth),g=co(d.borderBottomWidth),f=p.top+u-c.top,m=c.top+c.height+-(p.top+p.height-g);o.style.clipPath=`inset(${f}px 0px ${m}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var Xr={};V(Xr,{enUS:()=>Lg,nlNL:()=>Mg});var Lg={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"}]},Mg={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"}]};var Vo=require("react/jsx-runtime"),Cl=()=>(0,Vo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Vo.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Vo.jsx)("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"})]});var Qr=require("react/jsx-runtime"),wl=()=>(0,Qr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Qr.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});function Ng(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function ys(t){return t?t instanceof ShadowRoot?ys(t.host):t===t.ownerDocument.body?t.ownerDocument:Ng(t)?t:ys(t.parentNode):document.body}var Tl=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Tl||{}),je=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();pt(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(Tl).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",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),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",n=>this.handlePaste(n)),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()});let o=ys(this.element);if(o){let n=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};o.addEventListener("scroll",n),this.disposeHandlers.push(()=>{o.removeEventListener("scroll",n)})}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 qe=class extends je{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 Og=/[.*+?^${}()|[\]\\]/g,Dg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Hg(t){return t.replace(Og,"\\$&")}function Bg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function Fg(t){return t.search(Dg)}function El(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${Hg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function kl(t){return t.replace(eo,'<mark data-type="placeholder">$1</mark>')}function po(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Kg(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 Zr(t,e,o={}){if(e){let n=Bg(e.toLowerCase(),t.toLowerCase()),s=po(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=Fg(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Ea).length>3||e.length>30?Kg(e.trim(),n):0;return`${`${i>0?"\u2026":""}${po(t.substring(i,n))}`}<strong>${s}</strong>`}return t}function Jr(t){return/<\/?[a-z][\s\S]*>/i.test(t)}function vs(t){if(Jr(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}var Z=require("react/jsx-runtime"),Ug=({value:t,onUse:e,...o})=>{var d;let n=E(Xr),s=(0,Rl.useDispatch)(),r=Jr(t),i=y("EditSuggestionTextInput",jr),[a,l]=(0,_e.useState)(null),c=(0,_e.useRef)(null),p=((d=t.match(eo))==null?void 0:d.length)||0;return(0,_e.useEffect)(()=>{let u;return c.current&&(l(c.current),u=new qe(c.current),u.on("change",({plainText:g})=>{s(ie.actions.userInput({text:g,selection:u.getSelection()}))}),u.on("keydown",g=>{s(ie.actions.registerKeyDown(qn(g))),g.code==="Enter"&&g.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:g,selectionText:f})=>{s(ie.actions.registerPaste({text:g,selectionText:f}))}),u.on("cut",({selectionText:g})=>{s(ie.actions.registerCut(g))})),()=>{s(ie.actions.reset()),u.dispose(),u.deactivate()}},[c]),(0,_e.useEffect)(()=>{t&&c.current&&(c.current.value=t)},[t,c]),(0,_e.useEffect)(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let u=c.current.value.length;c.current.setSelectionRange(u,u),c.current.focus()},0)},[c]),r?(0,Z.jsx)("div",{className:i.textInputWrapper,children:(0,Z.jsx)(Yr.Interweave,{className:i.textInput,tagName:"div",content:t})}):(0,Z.jsxs)("div",{className:i.textInputWrapper,children:[(0,Z.jsx)("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&(0,Z.jsx)(zg,{inputElement:c.current,value:t}),(0,Z.jsxs)("div",{className:(0,ei.default)(i.alert,p===0?i.success:i.warning),children:[(0,Z.jsx)("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?(0,Z.jsx)(Cl,{}):(0,Z.jsx)(wl,{})]})]})},zg=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",jr),n=(0,_e.useRef)(null),s=gs(t);return(0,_e.useEffect)(()=>{ms(t,s)},[s,t]),(0,Z.jsx)(jg,{inputElement:t,children:(0,Z.jsxs)("div",{ref:n,className:(0,ei.default)(o.root,o.agentText),children:[(0,Z.jsx)(Yr.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new io("placeholders")],inputElement:t,boundaryRef:n}),(0,Z.jsx)("br",{})]})})},jg=({inputElement:t,children:e})=>{let o=(0,_e.useRef)(null);return(0,_e.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=At(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,Z.jsx)("div",{ref:o,children:e})},Il=Ug;var fo=require("react");var Pl=require("react"),Ss=T(require("classnames"));var ae={root:"_root_pc5uy_1",list:"_list_pc5uy_2",listWrapper:"_listWrapper_pc5uy_6",listHorizontal:"_listHorizontal_pc5uy_10",page:"_page_pc5uy_19",search:"_search_pc5uy_25",pageNav:"_pageNav_pc5uy_33",pageTitle:"_pageTitle_pc5uy_41",pageBackButton:"_pageBackButton_pc5uy_48",listHeading:"_listHeading_pc5uy_62",listItem:"_listItem_pc5uy_70",listItemContent:"_listItemContent_pc5uy_79",listItemText:"_listItemText_pc5uy_97",listItemDescription:"_listItemDescription_pc5uy_105",listItemActions:"_listItemActions_pc5uy_112",truncate:"_truncate_pc5uy_123",lineClamp:"_lineClamp_pc5uy_129",listItemTitle:"_listItemTitle_pc5uy_136",listItemAction:"_listItemAction_pc5uy_112",listItemPrimaryAction:"_listItemPrimaryAction_pc5uy_157",listItemSelected:"_listItemSelected_pc5uy_162",sources:"_sources_pc5uy_166",sourcesTitle:"_sourcesTitle_pc5uy_173",source:"_source_pc5uy_166",icon:"_icon_pc5uy_188",searchIcon:"_searchIcon_pc5uy_205",searchInputWrapper:"_searchInputWrapper_pc5uy_210",searchInput:"_searchInput_pc5uy_210",select:"_select_pc5uy_231",selectType:"_selectType_pc5uy_248",selectWrapper:"_selectWrapper_pc5uy_252",image:"_image_pc5uy_282",imageSrc:"_imageSrc_pc5uy_289",imageSrcHidden:"_imageSrcHidden_pc5uy_300",imageSrcStatus:"_imageSrcStatus_pc5uy_304",imageTitle:"_imageTitle_pc5uy_314",actions:"_actions_pc5uy_319",actionsWrapper:"_actionsWrapper_pc5uy_323",actionsBar:"_actionsBar_pc5uy_329",actionButton:"_actionButton_pc5uy_338",actionShortcut:"_actionShortcut_pc5uy_356",actionShortcutFixKerning:"_actionShortcutFixKerning_pc5uy_363"};var Lt={};V(Lt,{enUS:()=>qg,nlNL:()=>Vg});var qg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},Vg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var gt=require("react/jsx-runtime"),Wg=({src:t,title:e})=>{let o=y("CommandPalette",ae),[n,s]=(0,Pl.useState)("loading"),r=E(Lt);return(0,gt.jsxs)("div",{className:o.image,children:[(0,gt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,Ss.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,gt.jsx)("span",{className:(0,Ss.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,gt.jsx)("span",{className:(0,Ss.default)(o.imageSrc,o.imageSrcStatus),children:(0,gt.jsx)(In,{})}),e&&(0,gt.jsx)("span",{className:o.imageTitle,children:e})]})},Al=Wg;var Ll=T(require("react")),Ml=T(require("classnames"));var Wo=require("react/jsx-runtime");function ti({children:t,heading:e,orientation:o}){let n=y("CommandPalette",ae);return Ll.default.Children.count(t)===0?null:(0,Wo.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,Wo.jsx)("h4",{className:n.listHeading,children:e}),(0,Wo.jsx)("div",{className:(0,Ml.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var Go=T(require("classnames"));var _s=T(require("react")),Dl=require("react/jsx-runtime"),Nl=_s.default.createContext(void 0);function mt(){let t=_s.default.useContext(Nl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Ol=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=_s.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,Dl.jsx)(Nl.Provider,{value:i,children:t})};var G=T(require("react")),Hl=T(require("classnames"));var oi={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"};var Mt=require("react/jsx-runtime"),Gg=0,Bl=G.default.createContext(null),$g=()=>{let t=(0,G.useContext)(Bl);if(!t)throw new Error("Invalid DropdownContext");return t},Fl=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,G.useMemo)(()=>++Gg,[]),s=(0,G.useRef)(null),r=(0,G.useRef)(null),i=y("Dropdown",oi),[a,l]=(0,G.useState)(!1),[c,p]=(0,G.useState)(o),d=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},u=(0,G.useCallback)(([g])=>{!g.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return(0,G.useEffect)(()=>{let g=f=>{s.current&&!s.current.contains(f.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),(0,G.useEffect)(()=>{if(!r.current&&!a)return()=>{};let g=new IntersectionObserver(u,{root:null,rootMargin:"0px",threshold:1});return r.current&&g.observe(r.current),()=>{r.current&&g.unobserve(r.current)}},[r,a]),(0,Mt.jsx)(Bl.Provider,{value:{setIsOpen:l},children:(0,Mt.jsxs)("div",{ref:s,className:i.root,children:[(0,Mt.jsx)("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}),(0,Mt.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,Hl.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Xg({as:t,children:e,onClick:o,...n}){let s=t||"button",r=y("Dropdown",oi),{setIsOpen:i}=$g(),a=l=>{i(!1),o(l),l.stopPropagation()};return(0,Mt.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Fl.Item=Xg;var ni=Fl;var si=require("react/jsx-runtime"),Kl=t=>(0,si.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,si.jsx)("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})});var Nt={};V(Nt,{enUS:()=>Qg,nlNL:()=>Zg});var Qg={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},Zg={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var xs=require("react/jsx-runtime"),Jg="%0d%0a%0d%0a%0d%0a",Yg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Jg)}`},em=({suggestion:t,onFeedback:e})=>{let o=E(Nt),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,xs.jsx)(ni,{trigger:(0,xs.jsx)(Kl,{"data-testid":"feedback-dropdown-trigger"}),children:(0,xs.jsx)(ni.Item,{as:"a",href:Yg(n,t),onClick:e,children:o("giveFeedback")})})},bs=em;var Ul=require("interweave");var de=require("react/jsx-runtime");function ri({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:u,onChangeOpen:g}=mt(),f=y("CommandPalette",ae);function m(v){n(v),t&&g(!1)}return(0,de.jsxs)("div",{className:(0,Go.default)(f.listItem,d===i&&f.listItemSelected),children:[(0,de.jsx)("button",{onMouseEnter:()=>u(i),type:"button",className:(0,Go.default)("command-palette-list-item",f.listItemAction,f.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:m,...p,children:(0,de.jsxs)("div",{className:f.listItemContent,children:[typeof o=="string"?(0,de.jsx)("p",{className:(0,Go.default)(f.listItemText,f.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,de.jsx)(Ul.Interweave,{tagName:"p",allowList:[],content:vs(a),className:(0,Go.default)(f.listItemDescription,c==null?void 0:c.description,e?f.lineClamp:f.truncate)})]})}),s&&d===i&&(0,de.jsx)("div",{className:f.listItemActions,children:(0,de.jsx)(bs,{suggestion:String(o),onFeedback:s})}),l&&(0,de.jsxs)("div",{className:f.sources,children:[(0,de.jsx)("span",{className:f.sourcesTitle,children:"Sources"}),l.map(v=>v.url?(0,de.jsx)("a",{className:f.source,href:v.url,target:"_blank",title:v.url,rel:"noopener noreferrer",onClick:()=>r&&r(v),children:v.name},v.url):(0,de.jsx)("span",{className:f.source,children:v.name},v.name))]})]})}var Ot=require("react/jsx-runtime");function ii({children:t,title:e,id:o,onDismiss:n}){let s=E(Lt),r=y("CommandPalette",ae),{page:i}=mt();return i!==o?null:(0,Ot.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,Ot.jsxs)("div",{className:r.pageNav,children:[(0,Ot.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,Ot.jsx)(ps,{}),s("back")]}),e&&(0,Ot.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var ft=require("react");var Cs=()=>/Mac/i.test(navigator.platform);var Ts=require("@reduxjs/toolkit");var tm={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=tm;var uo=require("@reduxjs/toolkit");function om(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function L(t){return Array.isArray(t)?t.map(L):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[om(o)]:L(t[o])}),{}):t}function ai(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function j(t){return Array.isArray(t)?t.map(j):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[ai(o)]:j(t[o])}),{}):t}var nm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Xo=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)||""}},$o=(0,uo.createAsyncThunk)("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?L(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),L(n))}),li=(0,uo.createAsyncThunk)("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}),ci=(0,uo.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),zl=t=>t.info.agentInfo,jl=(0,uo.createSlice)({name:"info",initialState:nm,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase($o.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase($o.rejected,e=>{e.fetchState="error"}).addCase($o.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(li.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(ci.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(A,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:ql}=jl.actions,Vl=jl.reducer;var ws={list:[],fetchState:"idle",isOpen:!1,page:"search"},Wl=t=>t.search.isOpen,Gl=t=>t.search.page,$l=t=>t.search.list;function Xl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Dt=(0,Ts.createAsyncThunk)("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:Xo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),Ql=(0,Ts.createSlice)({name:"search",initialState:ws,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ws.fetchState,t.list=ws.list}},extraReducers:t=>{t.addCase(Dt.pending,e=>{e.fetchState="loading"}).addCase(Dt.rejected,(e,o)=>{e.fetchState="error",k.error(o.error)}).addCase(Dt.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(A,()=>ws)}}),{resetSearch:Es,setIsOpen:ee,setPage:te}=Ql.actions,Zl=Ql.reducer;var sm=/(https?:\/\/[^\s]+)/,ks=t=>t.split(" ").find(e=>sm.test(e));var pi=T(require("classnames"));var Rs=require("react/jsx-runtime"),rm=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",ae);return(0,Rs.jsxs)("button",{type:"button",...n,onClick:t,className:(0,pi.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,Rs.jsx)("span",{className:(0,pi.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},go=rm;var Ve=require("react/jsx-runtime"),im=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",ae),a=E(Lt),{selected:l,setSelected:c}=mt(),p=r[l],d=p&&typeof p.text=="string"&&ks(p.text),u=(0,ft.useRef)(null);function g(x){if(!u.current)return;let b=u.current.querySelectorAll(".command-palette-list-item"),_=0,P=0;x==="down"?(b.forEach((re,O)=>{O===l&&(_=O)}),P=_===b.length-1?0:_+1):x==="up"?(b.forEach((re,O)=>{O===l&&(_=O)}),P=_?_-1:b.length-1):c(0);let B=b[P];B&&typeof P=="number"&&(c(P),B.scrollIntoView&&B.scrollIntoView({behavior:"smooth",block:P?"center":"end"}))}function f(){if(!u.current)return;let x=u.current.querySelectorAll(".command-palette-list-item"),b=0;x.forEach((P,B)=>{B===l&&(b=B)});let _=x[b];_&&_.click()}let m=()=>{d&&window.open(d,"_blank")},v=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=(0,ft.useCallback)(x=>{if(x.key==="Enter"&&x.altKey&&d){m();return}if(x.key==="Enter"&&x.shiftKey){w();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),g("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),g("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),f())},[l]);return(0,ft.useEffect)(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),(0,Ve.jsxs)("div",{className:i.actions,children:[(0,Ve.jsx)("div",{className:i.actionsWrapper,ref:u,children:t}),(0,Ve.jsxs)("div",{className:i.actionsBar,children:[d&&(0,Ve.jsx)(go,{onClick:m,shortKeys:[Cs()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Ve.jsxs)(ft.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,Ve.jsx)(go,{onClick:w,shortKeys:[8679,8629],children:o}),(0,Ve.jsx)(go,{onClick:v,shortKeys:[8629],children:e})]})]})]})},Yl=im;var ec=require("react");var Qo=require("react/jsx-runtime"),mo=()=>(0,Qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Qo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Qo.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});var Ie=require("react/jsx-runtime");function am({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",ae);return(0,Ie.jsxs)("div",{className:l.search,children:[(0,Ie.jsx)("div",{className:l.searchIcon,children:(0,Ie.jsx)(mo,{})}),(0,Ie.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Ie.jsx)("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&&(0,Ie.jsx)("div",{className:l.selectWrapper,children:(0,Ie.jsxs)("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&&(0,Ie.jsx)("option",{children:n}),s.map(c=>(0,Ie.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var tc=(0,ec.forwardRef)(am);var Zo=require("react/jsx-runtime");function Ht({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:u}){let[g,f]=(0,fo.useState)(0),m=(0,fo.useRef)(null),v=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var h;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(h=m.current)==null||h.focus();return}if(u.length>0){r("");return}a(!1)};return(0,fo.useEffect)(()=>{f(0)},[u,n]),(0,Zo.jsx)(so,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:v,children:(0,Zo.jsxs)(Ol,{selected:g,setSelected:f,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,Zo.jsx)(tc,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}Ht.Page=ii;Ht.List=ti;Ht.Image=Al;Ht.ListItem=ri;Ht.ActionsBar=Yl;Ht.Button=go;var M=Ht;var J=require("react/jsx-runtime"),lm=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",Ya),l=(0,Is.useDispatch)(),c=E(Nr),p=(0,Is.useSelector)(f=>f.overlayInput.text);(0,di.useEffect)(()=>{t&&(l(ie.actions.reset()),l(ie.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(ie.actions.commitSuggestion()))},[t]);let d=f=>{f.preventDefault(),u(p)},u=f=>{l(Gn(f)),e(f)},g=f=>m=>{p!==i?window.confirm(c("warning"))&&f(m):f(m)};return(0,di.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,J.jsxs)("div",{className:a.root,children:[(0,J.jsxs)("div",{className:a.content,children:[t.title&&(0,J.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,J.jsx)(Er,{labels:t.searchKeywords}),(0,J.jsx)(Il,{onUse:u,value:vs(p)})]}),(0,J.jsxs)("form",{className:a.actions,onSubmit:d,children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:(0,J.jsx)(ps,{})}),(0,J.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:(0,J.jsx)(cl,{})})]}),(0,J.jsxs)("div",{className:a.primaryButtons,children:[(0,J.jsx)(M.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),(0,J.jsx)(M.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},Ps=lm;var Bt=require("@reduxjs/toolkit");var cm=["{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}"],pm=new RegExp(cm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function oc(t,e){let o=t.split(pm),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),u=0;do c=d?e.indexOf(d,c+1):-1,u+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&u>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 nc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var rc={suggestions:[],fetchState:"idle",isInitialRequest:null},sc={default:rc},ic=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},ac=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},lc=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")},ho=t=>t.textSuggestions,cc=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},As=(0,Bt.createAction)("textSuggestions/refresh"),We=(0,Bt.createAsyncThunk)("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=oo(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Xo(n),t);if(t==="default"){let p=i?l.filter(cc(a)):l;e.dispatch(Oe(p.slice(0,r)))}return l}),Jo=(0,Bt.createAsyncThunk)("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,{...Xo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(cc(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?oc(p.text,t):p.text}))),l=nc(l,r),e.dispatch(Oe(l)),l}),pc=(0,Bt.createSlice)({name:"textSuggestions",initialState:sc,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(We.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||rc;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(We.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(We.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Jo.pending,e=>{e.default.fetchState="loading"}).addCase(Jo.rejected,e=>{e.default.fetchState="error"}).addCase(Jo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(A,()=>sc)}}),{setTextSuggestions:dc,setSuggestionState:uc}=pc.actions,gc=pc.reducer;var fc=require("@reduxjs/toolkit");var mc={contentType:null,suggestion:null},hc=t=>t.activeSuggestion.suggestion,yc=t=>t.activeSuggestion.contentType,vc=(0,fc.createSlice)({name:"activeSuggestion",initialState:mc,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(A,()=>mc)}}),{setActiveSuggestion:Ge,resetActiveSuggestion:ui}=vc.actions,Sc=vc.reducer;var gi={};V(gi,{enUS:()=>dm,nlNL:()=>um});var dm={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"}]},um={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"}]};var _c=require("@reduxjs/toolkit"),gm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Ls=({ui:t})=>t.overlayCollapsed;var xc=(0,_c.createSlice)({name:"ui",initialState:gm,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:Yo,setInputHasFocus:yo,setOverlayCollapsed:ht,setOpenOverlayWhenTyping:bc,setOverlayCollapsedUserOverwrite:Cc}=xc.actions,wc=xc.reducer;var en=T(require("react")),Ec=require("react/jsx-runtime"),Tc=en.default.createContext(null),Ft=({broadcastEvents:t,children:e})=>{let o=en.default.useMemo(()=>t,[]);return(0,Ec.jsx)(Tc.Provider,{value:o,children:e})},xe=()=>{let t=(0,en.useContext)(Tc);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var vo=require("@reduxjs/toolkit");var mm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ue=t=>t.auth.isLoggedIn,kc=t=>t.auth.loginFetchState,Rc=t=>t.auth.verifyFetchState,Ic=t=>t.auth.showLoginOverlay,$e=(0,vo.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Pc=(0,vo.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),tn=(0,vo.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Ac=(0,vo.createSlice)({name:"auth",initialState:mm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase($e.pending,e=>{e.loginFetchState="loading"}),t.addCase($e.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase($e.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(tn.pending,e=>{e.verifyFetchState="loading"}),t.addCase(tn.rejected,e=>{e.verifyFetchState="error"}),t.addCase(tn.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:So,setShowLoginOverlay:Lc}=Ac.actions,Mc=Ac.reducer;var mi="SetActiveSuggestion",_o="ShowLoginOverlay",on="UserLoggedIn",fm="UserLoggedOut",Xe="ApplySuggestion",fi="ApplyImageSuggestion",hm="ShowCommandPalette",ym=t=>({[mi]:e=>{t.dispatch(uc(e.state)),t.dispatch(Ge({contentType:e.contentType,suggestion:e.suggestion}))},[hm]:e=>{t.dispatch(ee(e.isOpen)),e.page&&t.dispatch(te(e.page))},[_o]:e=>{t.dispatch(Lc(e))},[on]:()=>{t.dispatch($e())},[fm]:()=>{t.dispatch($e())},[fi]:e=>{t.dispatch(Xn({suggestion:e.suggestion}))},[Xe]:e=>{t.dispatch(ke({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(Ue())}}),Nc=ym;var hi=require("react/jsx-runtime"),vm=()=>{var f;let[t,e]=(0,Oc.useState)(!1),o=(0,xo.useSelector)(hc),n=(0,xo.useSelector)(yc),s=(0,xo.useSelector)(ho),r=(0,xo.useDispatch)(),i=xe(),a=E(gi),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(ui()),r(yo(!0)),r(ie.actions.reset())},p=(m,v)=>{r(ui()),r(yo(!0)),i.send(Xe,{text:m,suggestion:{...v,source:`${v.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(f=s[n])==null?void 0:f.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r(Ge({contentType:n,suggestion:s[n].suggestions[d-1]})),g=d===s[n].suggestions.length-1||d===null?void 0:()=>r(Ge({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,hi.jsx)(so,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,hi.jsx)(Ps,{onTouched:e,onDismiss:c,onUse:m=>p(m,o),suggestion:o,onNext:g,onPrevious:u})})},Dc=vm;var vi=require("react-redux");var Ms=T(require("classnames")),Pe=require("react"),Ns=require("react-redux");var Bc=T(require("classnames"));var Hc={root:"_root_1ukx5_1"};var Fc=require("react/jsx-runtime"),Sm=({className:t,value:e,...o})=>{let n=y("TextInput",Hc);return(0,Fc.jsx)("input",{className:(0,Bc.default)(t,n.root),type:"text",value:e,...o})},nn=Sm;var yi={};V(yi,{enUS:()=>_m,nlNL:()=>xm});var _m={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"}]},xm={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 Kc={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"};var U=require("react/jsx-runtime");var bm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Cm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(yi),i=y("LoginTokenDialog",Kc),a=(0,Ns.useSelector)(Rc),l=(0,Ns.useDispatch)(),c=C("productName"),[p,d]=(0,Pe.useState)(t||""),[u,g]=(0,Pe.useState)(0),[f,m]=(0,Pe.useState)(""),v=(0,Pe.useCallback)(async b=>{b.preventDefault(),l(Pc({email:p})),g(1)},[o,p]),w=()=>{m(""),g(0)},h=(0,Pe.useCallback)(async b=>{b.preventDefault();let _=bm(b.target.elements.token.value);if(!_){m(r("verifyCodeError",{login:x}));return}l(tn({token:_}))},[o]),x=(0,Pe.useMemo)(()=>b=>(0,U.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:b},"back-button"),[]);return(0,Pe.useEffect)(()=>{a==="error"&&m(r("verifyCodeError",{login:x})),a==="done"&&n()},[a]),(0,U.jsx)(so,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,U.jsxs)("div",{className:i.root,children:[(0,U.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),u===0&&(0,U.jsxs)("form",{onSubmit:v,children:[(0,U.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,U.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,U.jsx)(nn,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>d(b.target.value)}),(0,U.jsx)("div",{className:i.actions,children:(0,U.jsx)("button",{type:"submit",className:(0,Ms.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&(0,U.jsxs)("form",{onSubmit:h,children:[(0,U.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,U.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,U.jsx)(nn,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&(0,U.jsx)("div",{className:i.errorMessage,children:f}),(0,U.jsxs)("div",{className:i.actions,children:[(0,U.jsx)("button",{type:"button",className:(0,Ms.default)(i.button),onClick:w,children:r("back")}),(0,U.jsx)("button",{type:"submit",className:(0,Ms.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Uc=Cm;var jc=require("react/jsx-runtime"),wm=()=>{let t=(0,vi.useSelector)(Ic),e=(0,vi.useSelector)(zl),o=C("adminUrl"),n=xe(),s=()=>n.send(_o,!1),r=()=>{n.send(_o,!1),n.send(on)};return(0,jc.jsx)(Uc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},zc=wm;var up=T(require("lodash.debounce")),oe=require("react"),Je=require("react-redux");var Os=require("@reduxjs/toolkit");var Tm={data:null,fetchState:"idle"},qc=t=>t.contentTypes.data,sn=(0,Os.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Em=(0,Os.createSlice)({name:"contentTypes",initialState:Tm,reducers:{},extraReducers:t=>{t.addCase(sn.pending,e=>{e.fetchState="loading"}).addCase(sn.rejected,e=>{e.fetchState="error"}).addCase(sn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Vc=Em.reducer;function rn(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}var Wc=require("react");function Gc(t,e){(0,Wc.useEffect)(()=>{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)}},[])}var an=require("react"),Bs=require("react-redux");var Ds=require("@reduxjs/toolkit");var $c={data:null,fetchState:"idle"},Hs=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=(0,Ds.createAsyncThunk)("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)}),km=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Rm=(0,Ds.createSlice)({name:"entities",initialState:$c,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=km(e.data?[...e.data,...o.payload]:o.payload)}).addCase(A,()=>$c)}}),Xc=Rm.reducer;var Si={};V(Si,{enUS:()=>Im,nlNL:()=>Pm});var Im={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Pm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Qc={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Kt=require("react/jsx-runtime"),Am=({onCopy:t,onUse:e})=>{let o=(0,an.useRef)(null),n=y("EntitiesList",Qc),s=E(Si),r=(0,Bs.useSelector)(Hs),i=(0,Bs.useDispatch)();return(0,an.useEffect)(()=>{i(Ae())},[]),(0,an.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,Kt.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,Kt.jsx)(M.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:(0,Kt.jsx)(M.List,{children:r.map((a,l)=>(0,Kt.jsx)(M.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,Kt.jsx)("p",{className:n.empty,children:s("noResults")})]})},Zc=Am;var Le=require("react"),ln=require("react-redux");var Fs=require("@reduxjs/toolkit");var Jc={data:null,fetchState:"idle"},Yc=t=>t.summary.data,ep=t=>t.summary.fetchState==="error",Qe=(0,Fs.createAsyncThunk)("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();if(i.length===0)return Promise.reject(new Error("No messages are included"));let a=await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return a?{summary:a}:Promise.reject(new Error("Summary is not provided"))}),Lm=(0,Fs.createSlice)({name:"summary",initialState:Jc,reducers:{},extraReducers:t=>{t.addCase(Qe.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Qe.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Qe.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(A,()=>Jc)}}),tp=Lm.reducer;var _i={};V(_i,{enUS:()=>Mm,nlNL:()=>Nm});var Mm={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."}]},Nm={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 op={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var Ze=require("react/jsx-runtime"),Om=({onCopy:t})=>{let e=(0,Le.useRef)(null),o=y("SummaryForm",op),[n,s]=(0,Le.useState)(""),r=E(_i),i=(0,ln.useSelector)(Yc),a=(0,ln.useSelector)(ep),l=(0,ln.useDispatch)(),c=()=>{l(X({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(X({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return(0,Le.useEffect)(()=>{l(Qe())},[]),(0,Le.useEffect)(()=>{s(i||"")},[i]),(0,Le.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Le.useEffect)(()=>{let d=u=>{u.key==="Enter"&&u.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),(0,Ze.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,Ze.jsx)("p",{className:o.error,children:r("error")}):(0,Ze.jsxs)(Le.Fragment,{children:[(0,Ze.jsx)("div",{className:o.main,children:(0,Ze.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),(0,Ze.jsx)("div",{className:o.actions,children:(0,Ze.jsx)(M.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},np=Om;var xi={};V(xi,{enUS:()=>Dm,nlNL:()=>Hm});var Dm={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?"}]},Hm={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?"}]};var yt=T(require("react")),pn=require("react-redux");var bi={};V(bi,{enUS:()=>Bm,nlNL:()=>Fm});var Bm={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"}]},Fm={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 sp={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"};var Co=require("@reduxjs/toolkit");var Ci={data:[],fetchState:"idle"},rp=t=>{var e;return(e=t.answer)==null?void 0:e.data},ip=t=>t.answer.fetchState,wo=(0,Co.createAction)("answer/resetKnowledgeSearch"),bo=(0,Co.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var i,a;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(a=(i=e.getState().profile)==null?void 0:i.data)==null?void 0:a.knowledgeAssistant;if(!s)throw new Error("KnowledgeAssistant is not defined");let r=await o.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),Km=(0,Co.createSlice)({name:"answer",initialState:Ci,reducers:{},extraReducers:t=>{t.addCase(bo.pending,e=>{e.fetchState="loading"}).addCase(bo.rejected,e=>{e.fetchState="error"}).addCase(bo.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(A,()=>Ci).addCase(wo,()=>Ci)}}),ap=Km.reducer;var cn=require("react/jsx-runtime"),lp=()=>(0,cn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,cn.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,cn.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var le=require("react/jsx-runtime"),Um=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=yt.default.useState(""),{setSelected:i}=mt(),a=(0,yt.useRef)(null),l=y("EntitiesList",sp),c=E(bi),p=(0,pn.useDispatch)(),d=(0,pn.useSelector)(rp),u=(0,pn.useSelector)(ip),g=async m=>{m.preventDefault(),m.stopPropagation(),s!==""&&p(bo({question:s,promptInstruction:n}))},f=(m,v)=>{p(X({name:"knowledge assist source viewed",data:{question:v,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,yt.useEffect)(()=>{var m;o&&u==="idle"?p(bo({question:o,promptInstruction:n})):(m=a.current)==null||m.focus()},[a,u]),(0,yt.useEffect)(()=>{u==="done"&&(p(X({name:"knowledge assist question answered",data:{question:s||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),i(d.length-1),r(""))},[u,d]),(0,yt.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,d]),(0,le.jsxs)("div",{className:l.root,children:[d.length>0&&(0,le.jsx)("div",{className:l.alignRight,children:(0,le.jsx)(M.Button,{onClick:e,children:c("reset")})}),(0,le.jsxs)(M.ActionsBar,{list:d.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:m=>t(m.text),children:[d.map(({question:m,answer:v},w)=>(0,le.jsx)(M.List,{children:(0,le.jsx)(M.ListItem,{"data-testid":"knowledge-search-answer",index:w,description:v.answer,closeOnSelect:!0,onClick:()=>t(v.answer),onSourceClick:h=>f(h,m),sources:v.sources,styles:{title:l.question,description:l.answer},children:m})},`${v.answer}_${w}`)),u==="loading"&&(0,le.jsx)("p",{className:l.status,children:c("loading")}),u==="error"&&(0,le.jsx)("p",{className:l.status,children:c("error")}),(0,le.jsxs)("form",{className:l.form,onSubmit:g,children:[(0,le.jsx)("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:m=>{i(-1),r(m.target.value)}}),(0,le.jsx)("button",{type:"submit",className:l.submit,children:(0,le.jsx)(lp,{})})]})]})]})},cp=Um;var Ks=require("@reduxjs/toolkit");var zm={data:null,fetchState:"idle"},To=t=>t.profile.data,Us=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],dn=(0,Ks.createAsyncThunk)("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)}),jm=(0,Ks.createSlice)({name:"profile",initialState:zm,reducers:{},extraReducers:t=>{t.addCase(dn.pending,e=>{e.fetchState="loading"}).addCase(dn.rejected,e=>{e.fetchState="error"}).addCase(dn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),pp=jm.reducer;var q=require("react/jsx-runtime"),qm=200,Vm=5,Wm=4,Gm=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),dp=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),$m=()=>{let t=(0,Je.useDispatch)(),e=xe(),o=E(xi),[n,s]=(0,oe.useState)(!1),[r,i]=(0,oe.useState)(""),a=(0,Je.useSelector)(Gl),l=(0,Je.useSelector)(To),[c,p]=(0,oe.useState)(null),[d,u]=(0,oe.useState)([]),[g,f]=(0,oe.useState)(),m=(0,Je.useSelector)(ue),v=C("showSearch"),w=C("showEntitiesCommand"),h=C("showSummaryCommand"),x=C("showKnowledgeSearch"),b=C("showImageSearch"),_=C("searchTriggerKey"),P=(0,Je.useSelector)(qc),B=(0,Je.useSelector)($l),re=(0,Je.useSelector)(Wl),O=S=>Cr(B.filter(N=>N.type===S.toUpperCase()),S),Y=[{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:b}].filter(S=>S.shouldShow),I=[{label:o("entitiesClipboard"),onClick:()=>t(te("entities")),shouldShow:w&&dp(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(te("summary")),shouldShow:h&&dp(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(te("knowledgeAssist")),shouldShow:x}].filter(S=>S.shouldShow),K=(P==null?void 0:P.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:O(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Gt=(0,oe.useCallback)((0,up.default)((S,N)=>{t(Dt({query:S,type:N,tags:["search-overlay"]}))},qm),[]),$t=Gm([...K,...Y]),Tn=(0,oe.useCallback)((S,N)=>{if(!N)return;let at=[...Y,...K].find(({value:Qt})=>Qt===N);at&&(t(te("edit")),p({...S,searchTerm:void 0}),u(at.list))},[t,c,K]),br=(0,oe.useCallback)((S,N)=>{switch(N.type){case"IMAGE":e.send(fi,{suggestion:N});break;default:e.send(Xe,{text:S,suggestion:N})}t(ee(!1))},[t]),Iu=S=>{rn(S.text),t(X({name:"entity copied",data:{entity:S,type:"copy"}})),t(ee(!1))},Pu=(0,oe.useCallback)(S=>{t(X({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),Au=S=>{e.send(Xe,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(X({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(te("search")),t(wo()),t(ee(!1))},Lu=S=>{rn(S),t(ee(!1))},Mu=S=>{e.send(Xe,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(ee(!1))},Nu=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),Ou=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function Cr(S,N){return S.slice(0,g?10:N.toLowerCase()==="image"?Wm:Vm)}function ia(S,N,at){return N.reduce((Qt,En)=>at&&g===at?En.length+Qt:Cr(En,at).length+Qt,S)}function Xt(S){return N=>{n?window.confirm(o("warning"))&&(S(N),s(!1)):S(N)}}return(0,oe.useEffect)(()=>{r?Gt(r,g):t(Es())},[r,g]),(0,oe.useEffect)(()=>{a==="search"&&t(wo())},[a]),(0,oe.useEffect)(()=>{m&&t(sn())},[m]),Gc(_,()=>t(ee(!0))),!v||!l?null:(0,q.jsxs)(M,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Xt(S=>t(ee(S))),onChangeType:S=>f(S),onChangePage:Xt(S=>t(te(S))),selectedType:g,search:r,page:a,isOpen:re,types:[...K,...Y],children:[(0,q.jsx)(M.Page,{id:"search",children:(0,q.jsxs)(M.ActionsBar,{list:[...I.map(S=>({text:S.label,type:"command"})),...$t.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},N)=>br(S,$t[N]),onSecondary:(S,N)=>{Tn($t[N-I.length],$t[N-I.length].type)},children:[I.length>0&&(0,q.jsx)(M.List,{heading:o("commands"),children:I.map((S,N)=>(0,q.jsx)(M.ListItem,{index:ia(N,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...K,...Y].map(({value:S,label:N,list:at,lineClamp:Qt,listOrientation:En},Du)=>(0,q.jsx)(M.List,{heading:N,orientation:En==="horizontal"?"horizontal":"vertical",children:Cr(at,S).map((fe,Hu)=>(0,q.jsx)(M.ListItem,{index:ia(I.length+Hu,[...K,...Y].slice(0,Du).map(({list:Bu})=>Bu),S),closeOnSelect:!1,lineClamp:Qt,onClick:()=>br(fe.text,fe),description:S!=="IMAGE"?fe.title&&fe.text:void 0,onFeedback:S!=="IMAGE"?()=>Pu(fe):void 0,children:S==="IMAGE"?(0,q.jsx)(M.Image,{title:fe.title||fe.text,src:fe.image}):fe.title||fe.text},`${fe.id}-${fe.text}`))},S))]})}),(0,q.jsx)(M.Page,{id:"edit",onDismiss:Xt(()=>{t(te("search")),p(null)}),children:c&&(0,q.jsx)(Ps,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(te("search")),p(null),u([])},onNext:Ou,onPrevious:Nu,onUse:S=>{t(te("search")),br(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(ee(!1)),u([]),p(null)}})}),(0,q.jsx)(M.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:Xt(()=>{t(te("search"))}),children:(0,q.jsx)(Zc,{onUse:Mu,onCopy:Iu})}),(0,q.jsx)(M.Page,{id:"summary",title:o("summaryTitle"),onDismiss:Xt(()=>{t(te("search"))}),children:(0,q.jsx)(np,{onCopy:Lu})}),(0,q.jsx)(M.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:Xt(()=>{t(wo()),t(te("search"))}),children:(0,q.jsx)(cp,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:Au,onResetQuestion:()=>{t(wo()),i("")}})})]})},gp=$m;var Eo=require("react/jsx-runtime"),Xm=()=>{let t=C("showSearch"),e=C("isEmbedded");return(0,Eo.jsxs)(mp.Fragment,{children:[t&&(0,Eo.jsx)(gp,{}),(0,Eo.jsx)(Dc,{}),e&&(0,Eo.jsx)(zc,{})]})},fp=Xm;var Vs=require("react"),Ye=require("react-redux");function ko(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}var js=require("react");var Sp=require("interweave"),Ro=require("react"),zs=require("react-redux");var hp=require("react");function yp(t,e,o){(0,hp.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var vp={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var Ut=require("react/jsx-runtime"),Zm=["search","personal-collection-search","search-autocomplete"];function Jm(t,e,o,n={}){let s="";return Zm.includes(e)?s=El(Zr(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Zr(t,o,n),n.placeholders===!0&&(s=kl(s)),s}var Ym=()=>{},ef=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=(0,zs.useSelector)(oo),i=(0,zs.useDispatch)(),a=y("TextSuggestion",vp),l=(0,Ro.useRef)(null);(0,Ro.useEffect)(()=>{let p=setTimeout(()=>{i(qa({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),yp(l,"click",()=>{i(ut(t)),i(ke({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,Ro.useMemo)(()=>Jm(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:(0,Ut.jsxs)("div",{className:a.root,onMouseEnter:()=>i(ut(t)),children:[(0,Ut.jsx)(D,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Ym,children:(0,Ut.jsx)(Sp.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&(0,Ut.jsx)("div",{className:a.actions,children:(0,Ut.jsx)(bs,{onFeedback:()=>n(o),suggestion:o.text})})]})},_p=ef;var wi=require("react/jsx-runtime"),tf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,js.useMemo)(()=>{let r=e.map((i,a)=>(0,wi.jsx)(_p,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,wi.jsx)(js.Fragment,{children:s})},qs=tf;var xp={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var un=require("react/jsx-runtime"),of=({textSuggestions:t,selectedIndex:e})=>{let o=(0,Vs.useRef)(null),n=y("InlineSuggestionsOverlay",xp),s=(0,Ye.useSelector)(ko),r=(0,Ye.useDispatch)(),i=(0,Ye.useSelector)(ue),a=(0,Ye.useSelector)(to),l=(0,Ye.useSelector)(Ls),c=C("showTextSuggestions");return lo(()=>{r(ht({collapse:!0,skipWhenInputFocus:!0}))}),(0,Vs.useEffect)(()=>{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:(0,un.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,un.jsx)("div",{ref:o,className:n.paper,children:(0,un.jsx)(Se,{children:(0,un.jsx)(qs,{suggestions:t,selectedIndex:e})})})})},nf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),bp=(0,Ye.connect)(nf)(of);var Gs=T(require("classnames")),Io=require("react"),Be=require("react-redux");var Cp=require("react");function wp(t,e){let[o,n]=(0,Cp.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return k.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){k.error(i)}}]}var Ep=T(require("classnames")),et=require("react");var Ti={};V(Ti,{enUS:()=>sf,nlNL:()=>rf});var sf={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"}]}]},rf={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 Tp={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var vt=require("react/jsx-runtime"),Ei=(t,e,o)=>n=>(0,vt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),af=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=E(Ti),i=xe(),a=y("Login",Tp),l=C("productName"),c=(0,et.useCallback)(v=>{v.preventDefault(),n&&n(parseInt(v.target.value,10))},[]),p=(0,et.useCallback)(v=>{v.preventDefault(),i.send(_o,!0)},[e]),d=(0,et.useMemo)(()=>v=>(0,vt.jsx)("a",{onClick:h=>{h.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:v},"login"),[e]),u=(0,et.useCallback)(v=>(0,vt.jsx)("button",{type:"button",className:a.anchorButton,onClick:p,children:v},"prompt"),[p]),{min:g,hour:f,day:m}=(0,et.useMemo)(()=>({min:Ei(a,60*10,c),hour:Ei(a,60*60,c),day:Ei(a,60*60*12,c)}),[]);return(0,vt.jsxs)("div",{className:(0,Ep.default)(t,a.root),children:[r("loginPlease",{login:o?u:d,productName:l}),n&&(0,vt.jsxs)(et.Fragment,{children:[(0,vt.jsx)("br",{}),r("snooze",{min:g,hour:f,day:m})]})]})},Ws=af;var Rp=require("react-redux");var kp={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var gn=require("react/jsx-runtime"),lf=({title:t})=>{let e=y("SearchTrigger",kp),o=(0,Rp.useDispatch)();return(0,gn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ee(!0)),children:[(0,gn.jsx)(mo,{}),(0,gn.jsx)("span",{className:e.text,children:t})]})},Ip=lf;var ki={};V(ki,{enUS:()=>cf,nlNL:()=>pf});var cf={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"}]},pf={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 Pp={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"};var H=require("react/jsx-runtime"),df=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=y("SuggestionsOverlay",Pp),s=E(ki),r=(0,Be.useSelector)(ko),i=Fa(),a=(0,Be.useDispatch)(),l=(0,Io.useRef)(null),c=C("searchTriggerKey"),p=C("productName"),d=(0,Be.useSelector)(Ls),u=(0,Be.useSelector)(ue),g=(0,Be.useSelector)(to),[f,m]=(0,Io.useState)(null),v=C("showSearch"),w=C("showTextSuggestions"),h=C("adminUrl"),x=C("isEmbedded"),[b,_]=wp("dd-snooze-until-ms",0),P=d||b>Date.now(),B=(0,Be.useSelector)(K=>K.input.text),re=t.filter(K=>K.source!=="gpt").length,O=()=>{P&&_(0),a(Cc(!P))},Y=K=>{a(X({name:"suggestion feedback",data:{text:K.text,source:"overlay",context:B},options:{includeConversationData:!0}}))},I=K=>{let Gt=Date.now()+K*1e3;_(Gt),k.info(`Snooze until: ${new Date(Gt)}`),a(ht({collapse:!0}))};return(0,Io.useEffect)(()=>{re===0&&m(null)},[t,re]),lo(()=>{a(ht({collapse:!0,skipWhenInputFocus:!0}))}),u===null||g===!1?null:u===!1?(0,H.jsxs)("div",{ref:l,className:(0,Gs.default)(n.root,{[n.isCollapsed]:P}),children:[!P&&(0,H.jsxs)("div",{className:n.triggers,children:[(0,H.jsx)("div",{style:{flex:1}}),(0,H.jsx)("div",{className:n.triggersRight,children:(0,H.jsx)(kt,{className:n.toggleButton,title:s("collapse"),onClick:O,isCollapsed:!1})})]}),(0,H.jsx)("div",{className:n.toggleButtonWrapper,children:(0,H.jsx)(kt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:O,isCollapsed:!0})}),(0,H.jsx)("div",{className:n.collapsible,children:(0,H.jsx)(Ws,{loginUrl:h,isEmbedded:x,onLogIn:o,onSnooze:I})})]}):!i||!r?null:(0,H.jsxs)("div",{ref:l,className:(0,Gs.default)(n.root,{[n.isCollapsed]:P}),children:[!P&&(0,H.jsxs)("div",{className:n.triggers,children:[(0,H.jsx)("div",{style:{flex:1},children:v&&(0,H.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(s(Cs()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>m(null),children:(0,H.jsx)(Ip,{title:s("search")})})}),(0,H.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,H.jsx)("div",{className:(0,Gs.default)(!f&&n.hintsHidden,n.hints),children:f}),(0,H.jsx)(kt,{className:n.toggleButton,title:s("collapse"),onClick:O,isCollapsed:!1})]})]}),(0,H.jsx)("div",{className:n.toggleButtonWrapper,children:(0,H.jsx)(kt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:O,isCollapsed:!0})}),re>0&&w&&(0,H.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,H.jsx)(Se,{children:(0,H.jsx)(qs,{onFeedback:Y,suggestions:t,selectedIndex:e,reverse:!0})})})]})},uf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Ap=(0,Be.connect)(uf)(df);var Lp=require("react-redux");var mn=require("react/jsx-runtime"),gf=({children:t})=>{let o=C("locale").replace("-","");return(0,mn.jsx)(zr.Provider,{value:o,children:t})},mf=({store:t,customStyles:e={},children:o})=>(0,mn.jsx)(Lp.Provider,{store:t,children:(0,mn.jsx)(gf,{children:(0,mn.jsx)(No.Provider,{value:e,children:o})})}),zt=mf;var ir=T(require("classnames")),Zp=require("interweave"),nt=require("react"),Jp=require("react-redux");var Mp=require("react"),ff=["div","span","mark","strong","b","i","u","em"];function Ri(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(ff.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,Mp.cloneElement)(n,{children:Ri(i,e,o+1)})]}return[...t,...e]}function St(t){return t.tagName.toLowerCase()==="textarea"}var Np={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"};var jp=T(require("classnames")),qp=require("interweave"),or=require("react");function Op(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function $s(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Dp(t){return t!=null}var Pi=T(require("classnames")),be=require("react");var Xs=require("react"),hf=["bottom","height","left","right","top","width"],yf=(t={},e={})=>hf.some(o=>t[o]!==e[o]),tt=new Map,Hp,Bp=()=>{let t=[],e=[];tt.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();yf(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{tt.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Hp=window.requestAnimationFrame(Bp)};function vf(t,e){return{observe(){let o=tt.size===0;if(tt.has(t)){let n=tt.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else tt.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&Bp()},unobserve(){let o=tt.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||tt.delete(t),tt.size||cancelAnimationFrame(Hp)}}}}function Ii(t){let[e,o]=(0,Xs.useState)(null);return(0,Xs.useLayoutEffect)(()=>{if(!t.current)return;let n=vf(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var Po=require("react"),Kp=require("react-dom");var Fp={root:"_root_1jq08_1"};var Up=({children:t})=>{let[e,o]=(0,Po.useState)(null),n=(0,Po.useContext)(No);return(0,Po.useLayoutEffect)(()=>{let s=document.createElement("div");return Pt(s),s.classList.add(Fp.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?(0,Kp.createPortal)(t,e):null};var Fe={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"};var Qs=require("react/jsx-runtime"),Zs=(t=!1)=>{let[e,o]=(0,be.useState)(t),n=(0,be.useCallback)(()=>o(!0),[]),s=(0,be.useCallback)(()=>o(!1),[]),r=(0,be.useCallback)(()=>o(a=>!a),[]),i=(0,be.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Ai(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 Js=({className:t,triggerRef:e,boundaryRef:o=(0,be.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=Ai,...a})=>{let l=Ii(e),c=Ii(o),p=(0,be.useMemo)(()=>i(l,c,0),[l,c]);return(0,Qs.jsx)(Up,{children:(0,Qs.jsx)("div",{className:(0,Pi.default)(Fe.ref,{[Fe.positionAbove]:n==="above",[Fe.positionBelow]:n==="below",[Fe.positionLeft]:n==="left",[Fe.positionRight]:n==="right",[Fe.alignStart]:s==="start",[Fe.alignCenter]:s==="center",[Fe.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,Qs.jsx)("div",{className:(0,Pi.default)(t,Fe.root),children:r})})})};var zp=T(require("classnames")),Ys=require("react");var Li=require("react/jsx-runtime"),er=(0,Ys.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,Ys.useRef)(null),r=y("TabCompletion",ze);return(0,Li.jsx)("div",{ref:$s([s,n]),className:(0,zp.default)(t,r.popoverContentContainer),...o,children:(0,Li.jsx)("div",{className:r.popoverContent,children:e})})});var _t=require("react/jsx-runtime"),Sf=t=>e=>{let o=Ai(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},_f=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",ze),i=Zs(),a=(0,or.useMemo)(()=>Sf(t.getBoundingClientRect()),[t]),[l,c]=ds(t);return(0,or.useEffect)(()=>{c?i.open():i.close()},[c]),(0,_t.jsxs)("span",{children:[(0,_t.jsx)("mark",{ref:$s([l,i.triggerRef]),className:(0,jp.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,_t.jsx)(Js,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,_t.jsx)(er,{style:o,children:(0,_t.jsx)("div",{className:r.hintText,children:s})})})]})},tr=class extends qp.Matcher{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${Op(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(Dp);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(0,_t.jsx)(_f,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var sr=T(require("classnames")),Xp=require("interweave"),se=require("react"),Qp=require("react-redux");var Mi=require("react/jsx-runtime"),Vp=()=>(0,Mi.jsx)("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:(0,Mi.jsx)("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});var xt=require("react"),fn=require("react-redux"),Gp=T(require("lodash.debounce"));var Wp={root:"_root_1muu8_1",content:"_content_1muu8_7"};function nr(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 Ni(t){return t.replace("https://www.","").replace("https://","")}var Ce=require("react/jsx-runtime"),xf=3,bf=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Cf=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=xf})=>{let r=y("LinkSearch",Wp),[i,a]=(0,xt.useState)(""),l=(0,fn.useDispatch)(),c=(0,fn.useSelector)(ic("url")),p=(0,fn.useSelector)(Xl("URL",bf)),[d,u]=(0,xt.useState)(p.length-1),g=C("fallbackImage"),f=h=>{let x=h.target;a(x.value)},m=(h,x)=>{h.stopPropagation(),h.preventDefault(),window.open(x,"_blank")},v=h=>{var _;let x=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&u(x),h.code==="ArrowDown"&&u(b),h.code==="Enter"&&t(((_=p[d])==null?void 0:_.text)||i)},w=(0,xt.useCallback)((0,Gp.default)(h=>{l(Dt({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,xt.useEffect)(()=>{i&&w(i)},[i]),(0,xt.useEffect)(()=>()=>{l(Es())},[]),(0,Ce.jsxs)("div",{className:r.root,children:[(0,Ce.jsx)(Se,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,x)=>(0,Ce.jsx)(D,{selected:d===x,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:(0,Ce.jsxs)(F,{children:[(0,Ce.jsx)(F.Image,{src:nr(h,"small",g||void 0),title:h.title||h.text}),(0,Ce.jsxs)(F.Content,{className:r.content,cropText:!0,children:[(0,Ce.jsx)(F.Title,{children:h.title||Ni(h.text)}),h.title&&Ni(h.text)]}),(0,Ce.jsx)(D.Actions,{children:(0,Ce.jsx)(D.ActionButton,{label:n,onClick:b=>m(b,h.text)})})]})},h.text))}),(0,Ce.jsx)(nn,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:v})]})},$p=Cf;var Oi={};V(Oi,{enUS:()=>wf,nlNL:()=>Tf});var wf={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Tf={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var ne=require("react/jsx-runtime"),Ef=(0,se.forwardRef)((t,e)=>{let o=y("TabCompletion",ze);return(0,ne.jsx)("mark",{ref:e,className:(0,sr.default)(o.matchSelection)},"selection-start")}),kf=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(Oi),i=y("TabCompletion",ze),a=(0,se.useRef)(null),l=(0,se.useRef)(null),[c,p]=(0,se.useState)(null),d=(0,Qp.useDispatch)(),u=Zs(document.activeElement===n),[g]=(0,se.useState)(()=>document.createRange());u.triggerRef.current=g,(0,se.useEffect)(()=>()=>g.detach(),[]),(0,se.useEffect)(()=>{let m=t.current,v=a.current;!m||!v||(g.setStart(m,0),g.setEnd(v,0))},[t.current,a.current]),lo(()=>{u.close()});let f=(0,se.useCallback)(m=>{let v=g.toString(),w=/^http(s?):\/\//.test(m)?m:`https://${m}`;d(Vn({text:`[${v}](${w})`,replace:"selection"}))},[]);return(0,ne.jsxs)("span",{children:[(0,ne.jsx)("mark",{ref:a,className:(0,sr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&(0,ne.jsx)(Js,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,ne.jsxs)(er,{style:o,ref:l,children:[(0,ne.jsx)("div",{className:(0,sr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,ne.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,ne.jsx)(Vp,{}),(0,ne.jsx)("span",{children:"\xA0"}),(0,ne.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,ne.jsx)($p,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},rr=class extends Xp.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,se.createRef)(),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?(0,ne.jsx)(Ef,{ref:this.startRef}):(0,ne.jsx)(kf,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var ot=require("react/jsx-runtime"),Rf=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",Np),p=C("insertLink"),d=C("showMidSentenceSuggestions"),u=C("inlineSuggestions"),g=gs(a),f=(0,nt.useRef)(null);(0,nt.useEffect)(()=>{St(a)&&g&&ms(a,g)},[g]);let m=(0,nt.useCallback)(h=>{if(!s||!o)return h;let x=[(0,ot.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,ot.jsx)("span",{"data-testid":"tab-completion",className:(0,ir.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push((0,ot.jsx)("span",{className:(0,ir.default)(c.hint,c.resetIndent),children:(0,ot.jsx)(Mn,{keyCode:"tab"},"tabHint")})),Ri(h,x)},[s,o,n]),v=(0,nt.useMemo)(()=>{let h=[];return p&&h.push(new rr("selection")),h.push(new io("placeholders")),r&&h.push(new tr("keywords")),h},[u,p,r]),w=(0,nt.useMemo)(()=>{let h=window.getComputedStyle(a);return{"--dd-color":h.color,"--dd-font-size":h.fontSize,"--dd-font-family":h.fontFamily,"--dd-font-variant":h.fontVariant}},[]);return t?(0,ot.jsxs)("div",{ref:h=>{h!=null&&h.parentElement&&(f.current=h==null?void 0:h.parentElement)},className:c.root,style:w,children:[(0,ot.jsx)(Zp.Interweave,{tagName:"span",containerTagName:"div",className:(0,ir.default)(c.container,c.agentText),disableLineBreaks:St(a),content:e||"\u200B",onAfterParse:m,matchers:v,selection:g,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!d}),(0,ot.jsx)("br",{})]}):null},If=({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??po(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:g,showStyleSuggestions:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((m=n.list)==null?void 0:m.keywordMatches)??[],enabled:g&&d!==!1}},Yp=(0,Jp.connect)(If)(Rf);var qd=T(require("classnames")),Vd=require("react"),$=require("react-redux");var bt=require("@reduxjs/toolkit");var ed={list:[],fetchState:"idle",isInitialRequest:null},od=t=>t.autoflows.list||[],td=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},st=(0,bt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Di=(0,bt.createAsyncThunk)("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(st(t.platformSessionId))}),Hi=(0,bt.createAsyncThunk)("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(st(t.platformSessionId))}),Pf=(0,bt.createSlice)({name:"autoflows",initialState:ed,reducers:{},extraReducers:t=>{t.addCase(Di.pending,(e,o)=>{let n=td(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Hi.pending,(e,o)=>{let n=td(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(st.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(st.rejected,e=>{e.fetchState="error"}),t.addCase(st.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(A,()=>ed)}}),nd=(0,bt.createAsyncThunk)("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(st(t))}),s.on("sessionCompleted",()=>{o(st(t))})}),sd=(0,bt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),rd=Pf.reducer;var Ct=require("@reduxjs/toolkit");var id={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},ad=t=>t.customMessages.list,ld=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),cd=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),pd=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),hn=(0,Ct.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),ar=(0,Ct.createAsyncThunk)("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)}),lr=(0,Ct.createAsyncThunk)("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)}),dd=(0,Ct.createSlice)({name:"customMessages",initialState:id,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(hn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(hn.rejected,e=>{e.fetchState="error"}).addCase(hn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(ar.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(ar.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(lr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(lr.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(A,()=>id)}}),ud=(0,Ct.createAsyncThunk)("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(dd.actions.onCustomMessage(r))})}),gd=(0,Ct.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),md=dd.reducer;var yn=require("@reduxjs/toolkit"),Af={token:null,accountUrl:null,interval:null},fd=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},Bi=(0,yn.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),Fi=(0,yn.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(Bi()),setInterval(()=>n(Bi()),o)}),hd=(0,yn.createSlice)({name:"passwordlessToken",initialState:Af,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Bi.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(Fi.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:yd}=hd.actions,vd=hd.reducer;function Sd(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var Rd=require("react"),Id=require("react-redux");var Td=T(require("classnames")),Ed=require("react");var xd=T(require("classnames"));var _d={root:"_root_838fd_1"};var Cd=require("react/jsx-runtime"),Lf=({className:t,children:e})=>{let o=y("Unicode",_d);return(0,Cd.jsx)("span",{className:(0,xd.default)(t,o.root),children:e})},bd=Lf;var wd={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 Ki={};V(Ki,{enUS:()=>Mf,nlNL:()=>Nf});var Mf={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"}]},Nf={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"}]};var ge=require("react/jsx-runtime"),Df=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",wd),a=E(Ki),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ge.jsxs)(D,{className:(0,Td.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,ge.jsx)(F,{children:(0,ge.jsxs)(F.Content,{children:[(0,ge.jsxs)(F.Title,{children:[e&&(0,ge.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,ge.jsx)("span",{children:n})]})}),(0,ge.jsx)(D.Actions,{fixed:e==="Started",children:(0,ge.jsx)(D.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,ge.jsxs)(Ed.Fragment,{children:[(0,ge.jsx)(bd,{children:c})," ",(0,ge.jsx)("span",{children:a(l)})]})})})]})},kd=Df;var Ui=require("react/jsx-runtime"),Hf=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Bf=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Ui.jsx)(Rd.Fragment,{children:t.map(s=>(0,Ui.jsx)(kd,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Hf(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Ff=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Kf={onStartAutoflow:Di,onStopAutoflow:Hi},Pd=(0,Id.connect)(Ff,Kf)(Bf);var cr=require("react"),Ld=require("react-redux"),qi=T(require("classnames"));var zi=require("react/jsx-runtime"),ji=()=>(0,zi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,zi.jsx)("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var Ad={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var Ke=require("react/jsx-runtime"),Uf=({entities:t})=>{let e=y("EntitiesWidgetList",Ad),[o,n]=(0,cr.useState)(void 0),s=(0,Ld.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),rn(a.text),s(X({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,cr.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Ke.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Ke.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Ke.jsx)("span",{className:e.entityText,children:a.text}),(0,Ke.jsxs)("span",{className:e.iconWrapper,children:[(0,Ke.jsx)("span",{className:(0,qi.default)(e.icon),children:(0,Ke.jsx)(ji,{})}),(0,Ke.jsx)("span",{className:(0,qi.default)(e.icon,o===l&&e.iconClicked),children:(0,Ke.jsx)(ji,{})})]})]},a.text))})},Md=Uf;var Nd=T(require("classnames")),Vi=require("react"),jt=require("react-redux");var rt={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"};var ce=require("react/jsx-runtime"),zf=({suggestion:t})=>{let e=E(Nt),o=(0,jt.useDispatch)(),n=(0,jt.useSelector)(ld(t.text)),s=(0,jt.useSelector)(cd(t.text)),r=(0,jt.useSelector)(pd(t.text)),i=(0,jt.useSelector)(Hn),{replyOptions:a}=t,l=(0,Vi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(ar({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Vi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o(lr({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return(0,ce.jsxs)(D,{onClick:l,className:(0,Nd.default)(rt.root,{[rt.isUsed]:n,[rt.hasError]:r}),children:[(0,ce.jsx)(F,{children:(0,ce.jsxs)(F.Content,{children:[(0,ce.jsxs)(F.Title,{className:rt.title,children:[t.text," ",(0,ce.jsx)(Nn,{className:rt.label,children:"analyse tool"})," ",r&&(0,ce.jsx)("span",{className:rt.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,ce.jsx)("ul",{className:rt.quickReplies,children:a.map(p=>(0,ce.jsx)("li",{className:rt.quickReply,children:p.title},p.title))})]})}),(0,ce.jsxs)(D.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,ce.jsx)(D.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,ce.jsx)(D.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,ce.jsx)(D.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Od=zf;var Wi=require("react/jsx-runtime"),Dd=()=>(0,Wi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Wi.jsx)("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});var Fd=require("react-redux");var Hd=require("react");var me=require("react/jsx-runtime"),jf=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=ks(s),i=E(Nt),a=C("showImages"),l=C("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},d=(0,Hd.useCallback)(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return(0,me.jsxs)(D,{onClick:c,"data-testid":"edit-suggestion",children:[(0,me.jsxs)(F,{children:[a&&t.image&&(0,me.jsx)(F.Image,{src:nr(t,"small",l||void 0),title:t.title}),(0,me.jsxs)(F.Content,{children:[t.title&&(0,me.jsx)(F.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,me.jsx)(D.Labels,{labels:t.searchKeywords}),(0,me.jsx)(F.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,me.jsxs)(D.Actions,{children:[r&&(0,me.jsx)(D.ActionButton,{onClick:d,label:i("visitUrl")}),(0,me.jsx)(D.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,me.jsx)(D.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Bd=jf;var vn=require("react/jsx-runtime"),qf=({contentType:t,lines:e,suggestions:o})=>{let n=xe(),s=(0,Fd.useSelector)(ho),r=a=>{n.send(mi,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Xe,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,vn.jsx)(vn.Fragment,{children:o.map(a=>(0,vn.jsx)(Bd,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Kd=qf;var Gi={};V(Gi,{enUS:()=>Vf,nlNL:()=>Wf});var Vf={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"}]},Wf={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 Ud={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"};var $i=require("react/jsx-runtime"),zd=()=>(0,$i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,$i.jsx)("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});var Xi=require("react/jsx-runtime"),jd=()=>(0,Xi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Xi.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var R=require("react/jsx-runtime"),pr=(t,e)=>{let o=(0,$.useSelector)(ue);(0,Vd.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},Gf=({onLogIn:t})=>{let e=E(Gi),o=(0,$.useDispatch)(),n=C("isEmbedded"),s=y("Widget",Ud),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=(0,$.useSelector)(To),d=(0,$.useSelector)(Us),u=(0,$.useSelector)(od),g=(0,$.useSelector)(Hs),f=(0,$.useSelector)(ad),m=(0,$.useSelector)(Bn),v=(0,$.useSelector)(to),w=(0,$.useSelector)(ue),h=(0,$.useSelector)(Hn),x=(0,$.useSelector)(Sd),b=(0,$.useSelector)(ho),_=xe(),P=(0,$.useSelector)(lc),B=(0,$.useSelector)(fd("/admin/")),re=C("adminUrl"),O=C("productName");if(pr(()=>(o(hn(h)),o(ud(h)),()=>{o(gd(h))}),[o,v,i,h]),pr(()=>(o(st(h)),o(nd(h)),()=>{o(sd(h))}),[o,v,r,h]),pr(()=>{d.forEach(({type:I})=>{o(I==="entities"?Ae():We(I))})},[o,v,m,p]),pr(()=>(o(Fi()),()=>{o(yd())}),[o]),v===!1)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("notSupported")})})},"supported");if(w===!1)return(0,R.jsx)("div",{className:s.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Ws,{isEmbedded:n,loginUrl:re,onLogIn:t})})},"login");if(!p||!h||w===null||P||x)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("waiting")})})},"waiting");let Y=c||a||l||B;return(0,R.jsx)("div",{className:(0,qd.default)(s.root),"data-testid":"widget",children:(0,R.jsxs)(On,{className:s.sectionList,children:[Y&&(0,R.jsx)(lt,{title:e("actions"),type:"shortcuts",children:(0,R.jsxs)("div",{className:s.shortcutList,children:[c&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-search",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(mo,{}),e("linkSearch")]}),a&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(jd,{}),e("linkSummary")]}),l&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(zd,{}),e("linkKnowledgeSearch")]}),B&&(0,R.jsxs)("a",{className:s.shortcut,target:"_blank",href:B,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,R.jsx)(Dd,{}),e("linkStudioLogin",{productName:O})]})]})}),i&&f.length>0&&(0,R.jsx)(lt,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(Se,{withDivider:!0,children:f.map(I=>(0,R.jsx)(Od,{suggestion:I},I.text))})}),r&&u.length>0&&(0,R.jsx)(lt,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)(Pd,{})})}),d.map(({type:I,title:K,amount:Gt,lines:$t})=>{var Tn;switch(I){case"entities":return g&&g.length>0&&(0,R.jsx)(lt,{type:I,title:K,"data-testid":`type-${I}`,children:(0,R.jsx)(Md,{entities:g})},I);default:return((Tn=b[I])==null?void 0:Tn.fetchState)==="done"&&b[I].suggestions.length>0&&(0,R.jsx)(lt,{type:I,title:K,"data-testid":`type-${I}`,children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)(Kd,{lines:$t,contentType:I,suggestions:b[I].suggestions.slice(0,Gt)||[]})})},I)}})]})})},Wd=Gf;function Ao(t){let e=new Range;return e.selectNodeContents(t),e}function Gd(t,e,o){try{return wt(t,e,o),!0}catch{return!1}}function dr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function ur(t){return"tagName"in t&&t.tagName==="BR"}var Sn=/[\u200B-\u200D\uFEFF]/g;function wt(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 u=0;u<=l.length;u++)if(d.test(l[u])||p++,p===c)return u;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(Sn,""),d=s+p.length,u=e>=s&&e<=d,g=o>=s&&o<=d;if(u){let f=i(c,e-s);f===0&&!g?n.setStartBefore(l):n.setStart(l,f)}g&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(ur(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;dr(l)&&c&&!dr(c)&&!ur(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function _n(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 u=d===o,g=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let f=d.textContent;u&&(a=c+f.substring(0,n).replace(Sn,"").length),g&&(l=c+f.substring(0,r).replace(Sn,"").length),c+=f.replace(Sn,"").length;break}case Node.ELEMENT_NODE:{let f=d.nextSibling===null;ur(d)&&!f&&c++;for(let m=0;m<d.childNodes.length;m++){let v=u&&m===n,w=g&&m===r;if(v&&(a=c),w&&(l=c),l!==void 0||((!v||!i)&&p(d.childNodes[m]),g&&m===r-1&&(l=c),l!==void 0))break}!g&&dr(d)&&!f&&c++,g&&(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 xn(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 u=p?n:0,g=d?r:void 0,f=c.textContent.replace(Sn,"");u===0&&g===void 0?a+=f:a+=f.substring(u,g);break}case Node.ELEMENT_NODE:{let u=c.nextSibling===null;i===0&&ur(c)&&!u&&(a+=`
3
+ `,It.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));x=p.options[b]||p.options.other}if(!x)throw new Kr(p.value,u,Object.keys(p.options),i);a.push.apply(a,zo(x.value,e,o,n,s,u-(p.offset||0)));continue}}return xg(a)}function Cg(t,e){return e?pe(pe(pe({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=pe(pe({},t[n]),e[n]||{}),o},{})):t}function wg(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Cg(t[n],e[n]),o},pe({},t)):t}function Ur(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Tg(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:as(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Qn([void 0],o,!1)))},{cache:Ur(t.number),strategy:ls.variadic}),getDateTimeFormat:as(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Qn([void 0],o,!1)))},{cache:Ur(t.dateTime),strategy:ls.variadic}),getPluralRules:as(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Qn([void 0],o,!1)))},{cache:Ur(t.pluralRules),strategy:ls.variadic})}}var ll=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(u,g){return!u.length||g.type!==Q.literal||typeof u[u.length-1]!="string"?u.push(g.value):u[u.length-1]+=g.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return zo(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=el(i,["formatters"]);this.ast=t.__parse(e,pe(pe({},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=wg(t.formats,n),this.formatters=s&&s.formatters||Tg(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=nl,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 Eg(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var kg="dummy",zr=(0,cs.createContext)(null);function E(t){let e=(0,cs.useContext)(zr);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=Eg(o,n);return r?new ll(r).format(s):(e!==kg&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var jo=require("react/jsx-runtime"),ps=()=>(0,jo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,jo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,jo.jsx)("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});var qo=require("react/jsx-runtime"),cl=()=>(0,qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,qo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,qo.jsx)("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"})]});var _e=require("react"),Rl=require("react-redux"),Yr=require("interweave"),ei=T(require("classnames"));var jr={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var dl=require("interweave"),ul=T(require("classnames"));var ro=require("react");function pl(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function ds(t){let e=(0,ro.useRef)(null),[o,n]=(0,ro.useState)(!1);return(0,ro.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=pl((p,d)=>{let u=e.current;if(!u)return;let g=p/r,f=d/r,m=u.getBoundingClientRect(),v=g>m.x&&g<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:p,clientY:d})=>[p,d]),[l,c]=pl(()=>{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 ze={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"};var qr=require("react/jsx-runtime"),Rg=({inputElement:t,children:e})=>{let o=y("TabCompletion",ze),[n,s]=ds(t);return(0,qr.jsx)("mark",{ref:n,className:(0,ul.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},io=class extends dl.Matcher{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(0,qr.jsx)(Rg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var ao=require("react");function us(t){return t.contentEditable==="true"}function Ig(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 gl(t){let{selectionStart:e,selectionEnd:o}=us(t)?Ig(t):t;return[e,o]}function gs(t){let[,e]=(0,ao.useState)(),o=(0,ao.useRef)(null);return o.current=gl(t),(0,ao.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=gl(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 ms(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(eo);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)})}var ml=require("react");function lo(t){(0,ml.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Pt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var fl,De=new Map,Pg=["bottom","height","left","right","top","width"],Ag=(t={},e={})=>Pg.some(o=>t[o]!==e[o]);function hl(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,...hl(e)]:[]}function yl(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var fs=!1,vl=()=>{fs=!0;let t=[];if(De.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),De.delete(o);return}let n=o.getBoundingClientRect();Ag(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(yl,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),De.size===0){fs=!1;return}fl=window.requestAnimationFrame(vl)};function Vr(t,e){let o=hl(t),n=[],s=o.map((r,i)=>Vr(r,a=>{n[i]=a;let l=De.get(t);if(!l)return;let c=n.reduce(yl,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),De.has(t)){let i=De.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else De.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!fs&&vl()},unobserve(){s.forEach(i=>i.unobserve());let r=De.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||De.delete(t),De.size||(cancelAnimationFrame(fl),fs=!1)}}}}var Sl,He=new Map,_l=()=>{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&&(Sl=window.requestAnimationFrame(_l))};function xl(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&&_l()},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(Sl)}}}}var Wr=["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 Gr(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function co(t){return parseFloat(t)}function hs(t){return Math.round(t*1e6)}function bl(t){return t/1e6}function $r(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=co(t.width),r=co(t.borderLeftWidth),i=co(t.borderRightWidth),a=co(t.paddingRight),l=bl(hs(s)-hs(r)-hs(i)),c=bl(hs(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function At(t,e={}){var l;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",Pt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Gr(n,o,Wr),$r(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=xl(t,()=>{Gr(n,o,Wr),$r(n,t,o),r(),setTimeout(r,0)}),a=Vr(t,c=>{if(c===null){e.onRemove&&e.onRemove(),o.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Gr(n,o,Wr),$r(n,t,o),r(),o.style.top=`${c.top}px`,o.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),d=window.getComputedStyle(e.closestScrollElement),u=co(d.borderTopWidth),g=co(d.borderBottomWidth),f=p.top+u-c.top,m=c.top+c.height+-(p.top+p.height-g);o.style.clipPath=`inset(${f}px 0px ${m}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var Xr={};V(Xr,{enUS:()=>Lg,nlNL:()=>Mg});var Lg={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"}]},Mg={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"}]};var Vo=require("react/jsx-runtime"),Cl=()=>(0,Vo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Vo.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Vo.jsx)("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"})]});var Qr=require("react/jsx-runtime"),wl=()=>(0,Qr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Qr.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});function Ng(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function ys(t){return t?t instanceof ShadowRoot?ys(t.host):t===t.ownerDocument.body?t.ownerDocument:Ng(t)?t:ys(t.parentNode):document.body}var Tl=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Tl||{}),je=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();pt(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(Tl).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",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),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",n=>this.handlePaste(n)),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()});let o=ys(this.element);if(o){let n=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};o.addEventListener("scroll",n),this.disposeHandlers.push(()=>{o.removeEventListener("scroll",n)})}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 qe=class extends je{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 Og=/[.*+?^${}()|[\]\\]/g,Dg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Hg(t){return t.replace(Og,"\\$&")}function Bg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function Fg(t){return t.search(Dg)}function El(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${Hg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function kl(t){return t.replace(eo,'<mark data-type="placeholder">$1</mark>')}function po(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Kg(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 Zr(t,e,o={}){if(e){let n=Bg(e.toLowerCase(),t.toLowerCase()),s=po(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=Fg(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Ea).length>3||e.length>30?Kg(e.trim(),n):0;return`${`${i>0?"\u2026":""}${po(t.substring(i,n))}`}<strong>${s}</strong>`}return t}function Jr(t){return/<\/?[a-z][\s\S]*>/i.test(t)}function vs(t){if(Jr(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}var Z=require("react/jsx-runtime"),Ug=({value:t,onUse:e,...o})=>{var d;let n=E(Xr),s=(0,Rl.useDispatch)(),r=Jr(t),i=y("EditSuggestionTextInput",jr),[a,l]=(0,_e.useState)(null),c=(0,_e.useRef)(null),p=((d=t.match(eo))==null?void 0:d.length)||0;return(0,_e.useEffect)(()=>{let u;return c.current&&(l(c.current),u=new qe(c.current),u.on("change",({plainText:g})=>{s(ie.actions.userInput({text:g,selection:u.getSelection()}))}),u.on("keydown",g=>{s(ie.actions.registerKeyDown(qn(g))),g.code==="Enter"&&g.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:g,selectionText:f})=>{s(ie.actions.registerPaste({text:g,selectionText:f}))}),u.on("cut",({selectionText:g})=>{s(ie.actions.registerCut(g))})),()=>{s(ie.actions.reset()),u.dispose(),u.deactivate()}},[c]),(0,_e.useEffect)(()=>{t&&c.current&&(c.current.value=t)},[t,c]),(0,_e.useEffect)(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let u=c.current.value.length;c.current.setSelectionRange(u,u),c.current.focus()},0)},[c]),r?(0,Z.jsx)("div",{className:i.textInputWrapper,children:(0,Z.jsx)(Yr.Interweave,{className:i.textInput,tagName:"div",content:t})}):(0,Z.jsxs)("div",{className:i.textInputWrapper,children:[(0,Z.jsx)("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&(0,Z.jsx)(zg,{inputElement:c.current,value:t}),(0,Z.jsxs)("div",{className:(0,ei.default)(i.alert,p===0?i.success:i.warning),children:[(0,Z.jsx)("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?(0,Z.jsx)(Cl,{}):(0,Z.jsx)(wl,{})]})]})},zg=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",jr),n=(0,_e.useRef)(null),s=gs(t);return(0,_e.useEffect)(()=>{ms(t,s)},[s,t]),(0,Z.jsx)(jg,{inputElement:t,children:(0,Z.jsxs)("div",{ref:n,className:(0,ei.default)(o.root,o.agentText),children:[(0,Z.jsx)(Yr.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new io("placeholders")],inputElement:t,boundaryRef:n}),(0,Z.jsx)("br",{})]})})},jg=({inputElement:t,children:e})=>{let o=(0,_e.useRef)(null);return(0,_e.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=At(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,Z.jsx)("div",{ref:o,children:e})},Il=Ug;var fo=require("react");var Pl=require("react"),Ss=T(require("classnames"));var ae={root:"_root_pc5uy_1",list:"_list_pc5uy_2",listWrapper:"_listWrapper_pc5uy_6",listHorizontal:"_listHorizontal_pc5uy_10",page:"_page_pc5uy_19",search:"_search_pc5uy_25",pageNav:"_pageNav_pc5uy_33",pageTitle:"_pageTitle_pc5uy_41",pageBackButton:"_pageBackButton_pc5uy_48",listHeading:"_listHeading_pc5uy_62",listItem:"_listItem_pc5uy_70",listItemContent:"_listItemContent_pc5uy_79",listItemText:"_listItemText_pc5uy_97",listItemDescription:"_listItemDescription_pc5uy_105",listItemActions:"_listItemActions_pc5uy_112",truncate:"_truncate_pc5uy_123",lineClamp:"_lineClamp_pc5uy_129",listItemTitle:"_listItemTitle_pc5uy_136",listItemAction:"_listItemAction_pc5uy_112",listItemPrimaryAction:"_listItemPrimaryAction_pc5uy_157",listItemSelected:"_listItemSelected_pc5uy_162",sources:"_sources_pc5uy_166",sourcesTitle:"_sourcesTitle_pc5uy_173",source:"_source_pc5uy_166",icon:"_icon_pc5uy_188",searchIcon:"_searchIcon_pc5uy_205",searchInputWrapper:"_searchInputWrapper_pc5uy_210",searchInput:"_searchInput_pc5uy_210",select:"_select_pc5uy_231",selectType:"_selectType_pc5uy_248",selectWrapper:"_selectWrapper_pc5uy_252",image:"_image_pc5uy_282",imageSrc:"_imageSrc_pc5uy_289",imageSrcHidden:"_imageSrcHidden_pc5uy_300",imageSrcStatus:"_imageSrcStatus_pc5uy_304",imageTitle:"_imageTitle_pc5uy_314",actions:"_actions_pc5uy_319",actionsWrapper:"_actionsWrapper_pc5uy_323",actionsBar:"_actionsBar_pc5uy_329",actionButton:"_actionButton_pc5uy_338",actionShortcut:"_actionShortcut_pc5uy_356",actionShortcutFixKerning:"_actionShortcutFixKerning_pc5uy_363"};var Lt={};V(Lt,{enUS:()=>qg,nlNL:()=>Vg});var qg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},Vg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var gt=require("react/jsx-runtime"),Wg=({src:t,title:e})=>{let o=y("CommandPalette",ae),[n,s]=(0,Pl.useState)("loading"),r=E(Lt);return(0,gt.jsxs)("div",{className:o.image,children:[(0,gt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,Ss.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,gt.jsx)("span",{className:(0,Ss.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,gt.jsx)("span",{className:(0,Ss.default)(o.imageSrc,o.imageSrcStatus),children:(0,gt.jsx)(In,{})}),e&&(0,gt.jsx)("span",{className:o.imageTitle,children:e})]})},Al=Wg;var Ll=T(require("react")),Ml=T(require("classnames"));var Wo=require("react/jsx-runtime");function ti({children:t,heading:e,orientation:o}){let n=y("CommandPalette",ae);return Ll.default.Children.count(t)===0?null:(0,Wo.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,Wo.jsx)("h4",{className:n.listHeading,children:e}),(0,Wo.jsx)("div",{className:(0,Ml.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var Go=T(require("classnames"));var _s=T(require("react")),Dl=require("react/jsx-runtime"),Nl=_s.default.createContext(void 0);function mt(){let t=_s.default.useContext(Nl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Ol=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=_s.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,Dl.jsx)(Nl.Provider,{value:i,children:t})};var G=T(require("react")),Hl=T(require("classnames"));var oi={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"};var Mt=require("react/jsx-runtime"),Gg=0,Bl=G.default.createContext(null),$g=()=>{let t=(0,G.useContext)(Bl);if(!t)throw new Error("Invalid DropdownContext");return t},Fl=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,G.useMemo)(()=>++Gg,[]),s=(0,G.useRef)(null),r=(0,G.useRef)(null),i=y("Dropdown",oi),[a,l]=(0,G.useState)(!1),[c,p]=(0,G.useState)(o),d=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},u=(0,G.useCallback)(([g])=>{!g.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return(0,G.useEffect)(()=>{let g=f=>{s.current&&!s.current.contains(f.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),(0,G.useEffect)(()=>{if(!r.current&&!a)return()=>{};let g=new IntersectionObserver(u,{root:null,rootMargin:"0px",threshold:1});return r.current&&g.observe(r.current),()=>{r.current&&g.unobserve(r.current)}},[r,a]),(0,Mt.jsx)(Bl.Provider,{value:{setIsOpen:l},children:(0,Mt.jsxs)("div",{ref:s,className:i.root,children:[(0,Mt.jsx)("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}),(0,Mt.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,Hl.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Xg({as:t,children:e,onClick:o,...n}){let s=t||"button",r=y("Dropdown",oi),{setIsOpen:i}=$g(),a=l=>{i(!1),o(l),l.stopPropagation()};return(0,Mt.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Fl.Item=Xg;var ni=Fl;var si=require("react/jsx-runtime"),Kl=t=>(0,si.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,si.jsx)("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})});var Nt={};V(Nt,{enUS:()=>Qg,nlNL:()=>Zg});var Qg={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},Zg={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var xs=require("react/jsx-runtime"),Jg="%0d%0a%0d%0a%0d%0a",Yg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Jg)}`},em=({suggestion:t,onFeedback:e})=>{let o=E(Nt),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,xs.jsx)(ni,{trigger:(0,xs.jsx)(Kl,{"data-testid":"feedback-dropdown-trigger"}),children:(0,xs.jsx)(ni.Item,{as:"a",href:Yg(n,t),onClick:e,children:o("giveFeedback")})})},bs=em;var Ul=require("interweave");var de=require("react/jsx-runtime");function ri({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:u,onChangeOpen:g}=mt(),f=y("CommandPalette",ae);function m(v){n(v),t&&g(!1)}return(0,de.jsxs)("div",{className:(0,Go.default)(f.listItem,d===i&&f.listItemSelected),children:[(0,de.jsx)("button",{onMouseEnter:()=>u(i),type:"button",className:(0,Go.default)("command-palette-list-item",f.listItemAction,f.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:m,...p,children:(0,de.jsxs)("div",{className:f.listItemContent,children:[typeof o=="string"?(0,de.jsx)("p",{className:(0,Go.default)(f.listItemText,f.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,de.jsx)(Ul.Interweave,{tagName:"p",allowList:[],content:vs(a),className:(0,Go.default)(f.listItemDescription,c==null?void 0:c.description,e?f.lineClamp:f.truncate)})]})}),s&&d===i&&(0,de.jsx)("div",{className:f.listItemActions,children:(0,de.jsx)(bs,{suggestion:String(o),onFeedback:s})}),l&&(0,de.jsxs)("div",{className:f.sources,children:[(0,de.jsx)("span",{className:f.sourcesTitle,children:"Sources"}),l.map(v=>v.url?(0,de.jsx)("a",{className:f.source,href:v.url,target:"_blank",title:v.url,rel:"noopener noreferrer",onClick:()=>r&&r(v),children:v.name},v.url):(0,de.jsx)("span",{className:f.source,children:v.name},v.name))]})]})}var Ot=require("react/jsx-runtime");function ii({children:t,title:e,id:o,onDismiss:n}){let s=E(Lt),r=y("CommandPalette",ae),{page:i}=mt();return i!==o?null:(0,Ot.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,Ot.jsxs)("div",{className:r.pageNav,children:[(0,Ot.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,Ot.jsx)(ps,{}),s("back")]}),e&&(0,Ot.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var ft=require("react");var Cs=()=>/Mac/i.test(navigator.platform);var Ts=require("@reduxjs/toolkit");var tm={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=tm;var uo=require("@reduxjs/toolkit");function om(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function L(t){return Array.isArray(t)?t.map(L):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[om(o)]:L(t[o])}),{}):t}function ai(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function j(t){return Array.isArray(t)?t.map(j):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[ai(o)]:j(t[o])}),{}):t}var nm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Xo=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)||""}},$o=(0,uo.createAsyncThunk)("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?L(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),L(n))}),li=(0,uo.createAsyncThunk)("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}),ci=(0,uo.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),zl=t=>t.info.agentInfo,jl=(0,uo.createSlice)({name:"info",initialState:nm,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase($o.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase($o.rejected,e=>{e.fetchState="error"}).addCase($o.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(li.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(ci.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(A,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:ql}=jl.actions,Vl=jl.reducer;var ws={list:[],fetchState:"idle",isOpen:!1,page:"search"},Wl=t=>t.search.isOpen,Gl=t=>t.search.page,$l=t=>t.search.list;function Xl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Dt=(0,Ts.createAsyncThunk)("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:Xo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),Ql=(0,Ts.createSlice)({name:"search",initialState:ws,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ws.fetchState,t.list=ws.list}},extraReducers:t=>{t.addCase(Dt.pending,e=>{e.fetchState="loading"}).addCase(Dt.rejected,(e,o)=>{e.fetchState="error",k.error(o.error)}).addCase(Dt.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(A,()=>ws)}}),{resetSearch:Es,setIsOpen:ee,setPage:te}=Ql.actions,Zl=Ql.reducer;var sm=/(https?:\/\/[^\s]+)/,ks=t=>t.split(" ").find(e=>sm.test(e));var pi=T(require("classnames"));var Rs=require("react/jsx-runtime"),rm=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",ae);return(0,Rs.jsxs)("button",{type:"button",...n,onClick:t,className:(0,pi.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,Rs.jsx)("span",{className:(0,pi.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},go=rm;var Ve=require("react/jsx-runtime"),im=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",ae),a=E(Lt),{selected:l,setSelected:c}=mt(),p=r[l],d=p&&typeof p.text=="string"&&ks(p.text),u=(0,ft.useRef)(null);function g(x){if(!u.current)return;let b=u.current.querySelectorAll(".command-palette-list-item"),_=0,P=0;x==="down"?(b.forEach((re,O)=>{O===l&&(_=O)}),P=_===b.length-1?0:_+1):x==="up"?(b.forEach((re,O)=>{O===l&&(_=O)}),P=_?_-1:b.length-1):c(0);let B=b[P];B&&typeof P=="number"&&(c(P),B.scrollIntoView&&B.scrollIntoView({behavior:"smooth",block:P?"center":"end"}))}function f(){if(!u.current)return;let x=u.current.querySelectorAll(".command-palette-list-item"),b=0;x.forEach((P,B)=>{B===l&&(b=B)});let _=x[b];_&&_.click()}let m=()=>{d&&window.open(d,"_blank")},v=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=(0,ft.useCallback)(x=>{if(x.key==="Enter"&&x.altKey&&d){m();return}if(x.key==="Enter"&&x.shiftKey){w();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),g("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),g("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),f())},[l]);return(0,ft.useEffect)(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),(0,Ve.jsxs)("div",{className:i.actions,children:[(0,Ve.jsx)("div",{className:i.actionsWrapper,ref:u,children:t}),(0,Ve.jsxs)("div",{className:i.actionsBar,children:[d&&(0,Ve.jsx)(go,{onClick:m,shortKeys:[Cs()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Ve.jsxs)(ft.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,Ve.jsx)(go,{onClick:w,shortKeys:[8679,8629],children:o}),(0,Ve.jsx)(go,{onClick:v,shortKeys:[8629],children:e})]})]})]})},Yl=im;var ec=require("react");var Qo=require("react/jsx-runtime"),mo=()=>(0,Qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Qo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Qo.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});var Ie=require("react/jsx-runtime");function am({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",ae);return(0,Ie.jsxs)("div",{className:l.search,children:[(0,Ie.jsx)("div",{className:l.searchIcon,children:(0,Ie.jsx)(mo,{})}),(0,Ie.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Ie.jsx)("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&&(0,Ie.jsx)("div",{className:l.selectWrapper,children:(0,Ie.jsxs)("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&&(0,Ie.jsx)("option",{children:n}),s.map(c=>(0,Ie.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var tc=(0,ec.forwardRef)(am);var Zo=require("react/jsx-runtime");function Ht({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:u}){let[g,f]=(0,fo.useState)(0),m=(0,fo.useRef)(null),v=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var h;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(h=m.current)==null||h.focus();return}if(u.length>0){r("");return}a(!1)};return(0,fo.useEffect)(()=>{f(0)},[u,n]),(0,Zo.jsx)(so,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:v,children:(0,Zo.jsxs)(Ol,{selected:g,setSelected:f,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,Zo.jsx)(tc,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}Ht.Page=ii;Ht.List=ti;Ht.Image=Al;Ht.ListItem=ri;Ht.ActionsBar=Yl;Ht.Button=go;var M=Ht;var J=require("react/jsx-runtime"),lm=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",Ya),l=(0,Is.useDispatch)(),c=E(Nr),p=(0,Is.useSelector)(f=>f.overlayInput.text);(0,di.useEffect)(()=>{t&&(l(ie.actions.reset()),l(ie.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(ie.actions.commitSuggestion()))},[t]);let d=f=>{f.preventDefault(),u(p)},u=f=>{l(Gn(f)),e(f)},g=f=>m=>{p!==i?window.confirm(c("warning"))&&f(m):f(m)};return(0,di.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,J.jsxs)("div",{className:a.root,children:[(0,J.jsxs)("div",{className:a.content,children:[t.title&&(0,J.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,J.jsx)(Er,{labels:t.searchKeywords}),(0,J.jsx)(Il,{onUse:u,value:vs(p)})]}),(0,J.jsxs)("form",{className:a.actions,onSubmit:d,children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:(0,J.jsx)(ps,{})}),(0,J.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:(0,J.jsx)(cl,{})})]}),(0,J.jsxs)("div",{className:a.primaryButtons,children:[(0,J.jsx)(M.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),(0,J.jsx)(M.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},Ps=lm;var Bt=require("@reduxjs/toolkit");var cm=["{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}"],pm=new RegExp(cm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function oc(t,e){let o=t.split(pm),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),u=0;do c=d?e.indexOf(d,c+1):-1,u+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&u>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 nc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var rc={suggestions:[],fetchState:"idle",isInitialRequest:null},sc={default:rc},ic=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},ac=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},lc=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")},ho=t=>t.textSuggestions,cc=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},As=(0,Bt.createAction)("textSuggestions/refresh"),We=(0,Bt.createAsyncThunk)("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=oo(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Xo(n),t);if(t==="default"){let p=i?l.filter(cc(a)):l;e.dispatch(Oe(p.slice(0,r)))}return l}),Jo=(0,Bt.createAsyncThunk)("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,{...Xo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(cc(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?oc(p.text,t):p.text}))),l=nc(l,r),e.dispatch(Oe(l)),l}),pc=(0,Bt.createSlice)({name:"textSuggestions",initialState:sc,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(We.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||rc;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(We.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(We.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Jo.pending,e=>{e.default.fetchState="loading"}).addCase(Jo.rejected,e=>{e.default.fetchState="error"}).addCase(Jo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(A,()=>sc)}}),{setTextSuggestions:dc,setSuggestionState:uc}=pc.actions,gc=pc.reducer;var fc=require("@reduxjs/toolkit");var mc={contentType:null,suggestion:null},hc=t=>t.activeSuggestion.suggestion,yc=t=>t.activeSuggestion.contentType,vc=(0,fc.createSlice)({name:"activeSuggestion",initialState:mc,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(A,()=>mc)}}),{setActiveSuggestion:Ge,resetActiveSuggestion:ui}=vc.actions,Sc=vc.reducer;var gi={};V(gi,{enUS:()=>dm,nlNL:()=>um});var dm={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"}]},um={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"}]};var _c=require("@reduxjs/toolkit"),gm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Ls=({ui:t})=>t.overlayCollapsed;var xc=(0,_c.createSlice)({name:"ui",initialState:gm,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:Yo,setInputHasFocus:yo,setOverlayCollapsed:ht,setOpenOverlayWhenTyping:bc,setOverlayCollapsedUserOverwrite:Cc}=xc.actions,wc=xc.reducer;var en=T(require("react")),Ec=require("react/jsx-runtime"),Tc=en.default.createContext(null),Ft=({broadcastEvents:t,children:e})=>{let o=en.default.useMemo(()=>t,[]);return(0,Ec.jsx)(Tc.Provider,{value:o,children:e})},xe=()=>{let t=(0,en.useContext)(Tc);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var vo=require("@reduxjs/toolkit");var mm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ue=t=>t.auth.isLoggedIn,kc=t=>t.auth.loginFetchState,Rc=t=>t.auth.verifyFetchState,Ic=t=>t.auth.showLoginOverlay,$e=(0,vo.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Pc=(0,vo.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),tn=(0,vo.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Ac=(0,vo.createSlice)({name:"auth",initialState:mm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase($e.pending,e=>{e.loginFetchState="loading"}),t.addCase($e.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase($e.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(tn.pending,e=>{e.verifyFetchState="loading"}),t.addCase(tn.rejected,e=>{e.verifyFetchState="error"}),t.addCase(tn.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:So,setShowLoginOverlay:Lc}=Ac.actions,Mc=Ac.reducer;var mi="SetActiveSuggestion",_o="ShowLoginOverlay",on="UserLoggedIn",fm="UserLoggedOut",Xe="ApplySuggestion",fi="ApplyImageSuggestion",hm="ShowCommandPalette",ym=t=>({[mi]:e=>{t.dispatch(uc(e.state)),t.dispatch(Ge({contentType:e.contentType,suggestion:e.suggestion}))},[hm]:e=>{t.dispatch(ee(e.isOpen)),e.page&&t.dispatch(te(e.page))},[_o]:e=>{t.dispatch(Lc(e))},[on]:()=>{t.dispatch($e())},[fm]:()=>{t.dispatch($e())},[fi]:e=>{t.dispatch(Xn({suggestion:e.suggestion}))},[Xe]:e=>{t.dispatch(ke({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(Ue())}}),Nc=ym;var hi=require("react/jsx-runtime"),vm=()=>{var f;let[t,e]=(0,Oc.useState)(!1),o=(0,xo.useSelector)(hc),n=(0,xo.useSelector)(yc),s=(0,xo.useSelector)(ho),r=(0,xo.useDispatch)(),i=xe(),a=E(gi),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(ui()),r(yo(!0)),r(ie.actions.reset())},p=(m,v)=>{r(ui()),r(yo(!0)),i.send(Xe,{text:m,suggestion:{...v,source:`${v.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(f=s[n])==null?void 0:f.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r(Ge({contentType:n,suggestion:s[n].suggestions[d-1]})),g=d===s[n].suggestions.length-1||d===null?void 0:()=>r(Ge({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,hi.jsx)(so,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,hi.jsx)(Ps,{onTouched:e,onDismiss:c,onUse:m=>p(m,o),suggestion:o,onNext:g,onPrevious:u})})},Dc=vm;var vi=require("react-redux");var Ms=T(require("classnames")),Pe=require("react"),Ns=require("react-redux");var Bc=T(require("classnames"));var Hc={root:"_root_1ukx5_1"};var Fc=require("react/jsx-runtime"),Sm=({className:t,value:e,...o})=>{let n=y("TextInput",Hc);return(0,Fc.jsx)("input",{className:(0,Bc.default)(t,n.root),type:"text",value:e,...o})},nn=Sm;var yi={};V(yi,{enUS:()=>_m,nlNL:()=>xm});var _m={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"}]},xm={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 Kc={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"};var U=require("react/jsx-runtime");var bm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Cm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(yi),i=y("LoginTokenDialog",Kc),a=(0,Ns.useSelector)(Rc),l=(0,Ns.useDispatch)(),c=C("productName"),[p,d]=(0,Pe.useState)(t||""),[u,g]=(0,Pe.useState)(0),[f,m]=(0,Pe.useState)(""),v=(0,Pe.useCallback)(async b=>{b.preventDefault(),l(Pc({email:p})),g(1)},[o,p]),w=()=>{m(""),g(0)},h=(0,Pe.useCallback)(async b=>{b.preventDefault();let _=bm(b.target.elements.token.value);if(!_){m(r("verifyCodeError",{login:x}));return}l(tn({token:_}))},[o]),x=(0,Pe.useMemo)(()=>b=>(0,U.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:b},"back-button"),[]);return(0,Pe.useEffect)(()=>{a==="error"&&m(r("verifyCodeError",{login:x})),a==="done"&&n()},[a]),(0,U.jsx)(so,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,U.jsxs)("div",{className:i.root,children:[(0,U.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),u===0&&(0,U.jsxs)("form",{onSubmit:v,children:[(0,U.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,U.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,U.jsx)(nn,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>d(b.target.value)}),(0,U.jsx)("div",{className:i.actions,children:(0,U.jsx)("button",{type:"submit",className:(0,Ms.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&(0,U.jsxs)("form",{onSubmit:h,children:[(0,U.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,U.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,U.jsx)(nn,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&(0,U.jsx)("div",{className:i.errorMessage,children:f}),(0,U.jsxs)("div",{className:i.actions,children:[(0,U.jsx)("button",{type:"button",className:(0,Ms.default)(i.button),onClick:w,children:r("back")}),(0,U.jsx)("button",{type:"submit",className:(0,Ms.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Uc=Cm;var jc=require("react/jsx-runtime"),wm=()=>{let t=(0,vi.useSelector)(Ic),e=(0,vi.useSelector)(zl),o=C("adminUrl"),n=xe(),s=()=>n.send(_o,!1),r=()=>{n.send(_o,!1),n.send(on)};return(0,jc.jsx)(Uc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},zc=wm;var up=T(require("lodash.debounce")),oe=require("react"),Je=require("react-redux");var Os=require("@reduxjs/toolkit");var Tm={data:null,fetchState:"idle"},qc=t=>t.contentTypes.data,sn=(0,Os.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Em=(0,Os.createSlice)({name:"contentTypes",initialState:Tm,reducers:{},extraReducers:t=>{t.addCase(sn.pending,e=>{e.fetchState="loading"}).addCase(sn.rejected,e=>{e.fetchState="error"}).addCase(sn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Vc=Em.reducer;function rn(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}var Wc=require("react");function Gc(t,e){(0,Wc.useEffect)(()=>{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)}},[])}var an=require("react"),Bs=require("react-redux");var Ds=require("@reduxjs/toolkit");var $c={data:null,fetchState:"idle"},Hs=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=(0,Ds.createAsyncThunk)("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)}),km=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Rm=(0,Ds.createSlice)({name:"entities",initialState:$c,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=km(e.data?[...e.data,...o.payload]:o.payload)}).addCase(A,()=>$c)}}),Xc=Rm.reducer;var Si={};V(Si,{enUS:()=>Im,nlNL:()=>Pm});var Im={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Pm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Qc={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Kt=require("react/jsx-runtime"),Am=({onCopy:t,onUse:e})=>{let o=(0,an.useRef)(null),n=y("EntitiesList",Qc),s=E(Si),r=(0,Bs.useSelector)(Hs),i=(0,Bs.useDispatch)();return(0,an.useEffect)(()=>{i(Ae())},[]),(0,an.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,Kt.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,Kt.jsx)(M.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:(0,Kt.jsx)(M.List,{children:r.map((a,l)=>(0,Kt.jsx)(M.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,Kt.jsx)("p",{className:n.empty,children:s("noResults")})]})},Zc=Am;var Le=require("react"),ln=require("react-redux");var Fs=require("@reduxjs/toolkit");var Jc={data:null,fetchState:"idle"},Yc=t=>t.summary.data,ep=t=>t.summary.fetchState==="error",Qe=(0,Fs.createAsyncThunk)("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();if(i.length===0)return Promise.reject(new Error("No messages are included"));let a=await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return a?{summary:a}:Promise.reject(new Error("Summary is not provided"))}),Lm=(0,Fs.createSlice)({name:"summary",initialState:Jc,reducers:{},extraReducers:t=>{t.addCase(Qe.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Qe.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Qe.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(A,()=>Jc)}}),tp=Lm.reducer;var _i={};V(_i,{enUS:()=>Mm,nlNL:()=>Nm});var Mm={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."}]},Nm={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 op={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var Ze=require("react/jsx-runtime"),Om=({onCopy:t})=>{let e=(0,Le.useRef)(null),o=y("SummaryForm",op),[n,s]=(0,Le.useState)(""),r=E(_i),i=(0,ln.useSelector)(Yc),a=(0,ln.useSelector)(ep),l=(0,ln.useDispatch)(),c=()=>{l(X({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(X({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return(0,Le.useEffect)(()=>{l(Qe())},[]),(0,Le.useEffect)(()=>{s(i||"")},[i]),(0,Le.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Le.useEffect)(()=>{let d=u=>{u.key==="Enter"&&u.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),(0,Ze.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,Ze.jsx)("p",{className:o.error,children:r("error")}):(0,Ze.jsxs)(Le.Fragment,{children:[(0,Ze.jsx)("div",{className:o.main,children:(0,Ze.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),(0,Ze.jsx)("div",{className:o.actions,children:(0,Ze.jsx)(M.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},np=Om;var xi={};V(xi,{enUS:()=>Dm,nlNL:()=>Hm});var Dm={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?"}]},Hm={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?"}]};var yt=T(require("react")),pn=require("react-redux");var bi={};V(bi,{enUS:()=>Bm,nlNL:()=>Fm});var Bm={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"}]},Fm={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 sp={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"};var Co=require("@reduxjs/toolkit");var Ci={data:[],fetchState:"idle"},rp=t=>{var e;return(e=t.answer)==null?void 0:e.data},ip=t=>t.answer.fetchState,wo=(0,Co.createAction)("answer/resetKnowledgeSearch"),bo=(0,Co.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var i,a;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(a=(i=e.getState().profile)==null?void 0:i.data)==null?void 0:a.knowledgeAssistant;if(!s)throw new Error("KnowledgeAssistant is not defined");let r=await o.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),Km=(0,Co.createSlice)({name:"answer",initialState:Ci,reducers:{},extraReducers:t=>{t.addCase(bo.pending,e=>{e.fetchState="loading"}).addCase(bo.rejected,e=>{e.fetchState="error"}).addCase(bo.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(A,()=>Ci).addCase(wo,()=>Ci)}}),ap=Km.reducer;var cn=require("react/jsx-runtime"),lp=()=>(0,cn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,cn.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,cn.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var le=require("react/jsx-runtime"),Um=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=yt.default.useState(""),{setSelected:i}=mt(),a=(0,yt.useRef)(null),l=y("EntitiesList",sp),c=E(bi),p=(0,pn.useDispatch)(),d=(0,pn.useSelector)(rp),u=(0,pn.useSelector)(ip),g=async m=>{m.preventDefault(),m.stopPropagation(),s!==""&&p(bo({question:s,promptInstruction:n}))},f=(m,v)=>{p(X({name:"knowledge assist source viewed",data:{question:v,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,yt.useEffect)(()=>{var m;o&&u==="idle"?p(bo({question:o,promptInstruction:n})):(m=a.current)==null||m.focus()},[a,u]),(0,yt.useEffect)(()=>{u==="done"&&(p(X({name:"knowledge assist question answered",data:{question:s||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),i(d.length-1),r(""))},[u,d]),(0,yt.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,d]),(0,le.jsxs)("div",{className:l.root,children:[d.length>0&&(0,le.jsx)("div",{className:l.alignRight,children:(0,le.jsx)(M.Button,{onClick:e,children:c("reset")})}),(0,le.jsxs)(M.ActionsBar,{list:d.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:m=>t(m.text),children:[d.map(({question:m,answer:v},w)=>(0,le.jsx)(M.List,{children:(0,le.jsx)(M.ListItem,{"data-testid":"knowledge-search-answer",index:w,description:v.answer,closeOnSelect:!0,onClick:()=>t(v.answer),onSourceClick:h=>f(h,m),sources:v.sources,styles:{title:l.question,description:l.answer},children:m})},`${v.answer}_${w}`)),u==="loading"&&(0,le.jsx)("p",{className:l.status,children:c("loading")}),u==="error"&&(0,le.jsx)("p",{className:l.status,children:c("error")}),(0,le.jsxs)("form",{className:l.form,onSubmit:g,children:[(0,le.jsx)("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:m=>{i(-1),r(m.target.value)}}),(0,le.jsx)("button",{type:"submit",className:l.submit,children:(0,le.jsx)(lp,{})})]})]})]})},cp=Um;var Ks=require("@reduxjs/toolkit");var zm={data:null,fetchState:"idle"},To=t=>t.profile.data,Us=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],dn=(0,Ks.createAsyncThunk)("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)}),jm=(0,Ks.createSlice)({name:"profile",initialState:zm,reducers:{},extraReducers:t=>{t.addCase(dn.pending,e=>{e.fetchState="loading"}).addCase(dn.rejected,e=>{e.fetchState="error"}).addCase(dn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),pp=jm.reducer;var q=require("react/jsx-runtime"),qm=200,Vm=5,Wm=4,Gm=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),dp=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),$m=()=>{let t=(0,Je.useDispatch)(),e=xe(),o=E(xi),[n,s]=(0,oe.useState)(!1),[r,i]=(0,oe.useState)(""),a=(0,Je.useSelector)(Gl),l=(0,Je.useSelector)(To),[c,p]=(0,oe.useState)(null),[d,u]=(0,oe.useState)([]),[g,f]=(0,oe.useState)(),m=(0,Je.useSelector)(ue),v=C("showSearch"),w=C("showEntitiesCommand"),h=C("showSummaryCommand"),x=C("showKnowledgeSearch"),b=C("showImageSearch"),_=C("searchTriggerKey"),P=(0,Je.useSelector)(qc),B=(0,Je.useSelector)($l),re=(0,Je.useSelector)(Wl),O=S=>Cr(B.filter(N=>N.type===S.toUpperCase()),S),Y=[{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:b}].filter(S=>S.shouldShow),I=[{label:o("entitiesClipboard"),onClick:()=>t(te("entities")),shouldShow:w&&dp(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(te("summary")),shouldShow:h&&dp(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(te("knowledgeAssist")),shouldShow:x}].filter(S=>S.shouldShow),K=(P==null?void 0:P.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:O(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Gt=(0,oe.useCallback)((0,up.default)((S,N)=>{t(Dt({query:S,type:N,tags:["search-overlay"]}))},qm),[]),$t=Gm([...K,...Y]),Tn=(0,oe.useCallback)((S,N)=>{if(!N)return;let at=[...Y,...K].find(({value:Qt})=>Qt===N);at&&(t(te("edit")),p({...S,searchTerm:void 0}),u(at.list))},[t,c,K]),br=(0,oe.useCallback)((S,N)=>{switch(N.type){case"IMAGE":e.send(fi,{suggestion:N});break;default:e.send(Xe,{text:S,suggestion:N})}t(ee(!1))},[t]),Iu=S=>{rn(S.text),t(X({name:"entity copied",data:{entity:S,type:"copy"}})),t(ee(!1))},Pu=(0,oe.useCallback)(S=>{t(X({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),Au=S=>{e.send(Xe,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(X({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(te("search")),t(wo()),t(ee(!1))},Lu=S=>{rn(S),t(ee(!1))},Mu=S=>{e.send(Xe,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(ee(!1))},Nu=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),Ou=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function Cr(S,N){return S.slice(0,g?10:N.toLowerCase()==="image"?Wm:Vm)}function ia(S,N,at){return N.reduce((Qt,En)=>at&&g===at?En.length+Qt:Cr(En,at).length+Qt,S)}function Xt(S){return N=>{n?window.confirm(o("warning"))&&(S(N),s(!1)):S(N)}}return(0,oe.useEffect)(()=>{r?Gt(r,g):t(Es())},[r,g]),(0,oe.useEffect)(()=>{a==="search"&&t(wo())},[a]),(0,oe.useEffect)(()=>{m&&t(sn())},[m]),Gc(_,()=>t(ee(!0))),!v||!l?null:(0,q.jsxs)(M,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Xt(S=>t(ee(S))),onChangeType:S=>f(S),onChangePage:Xt(S=>t(te(S))),selectedType:g,search:r,page:a,isOpen:re,types:[...K,...Y],children:[(0,q.jsx)(M.Page,{id:"search",children:(0,q.jsxs)(M.ActionsBar,{list:[...I.map(S=>({text:S.label,type:"command"})),...$t.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},N)=>br(S,$t[N]),onSecondary:(S,N)=>{Tn($t[N-I.length],$t[N-I.length].type)},children:[I.length>0&&(0,q.jsx)(M.List,{heading:o("commands"),children:I.map((S,N)=>(0,q.jsx)(M.ListItem,{index:ia(N,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...K,...Y].map(({value:S,label:N,list:at,lineClamp:Qt,listOrientation:En},Du)=>(0,q.jsx)(M.List,{heading:N,orientation:En==="horizontal"?"horizontal":"vertical",children:Cr(at,S).map((fe,Hu)=>(0,q.jsx)(M.ListItem,{index:ia(I.length+Hu,[...K,...Y].slice(0,Du).map(({list:Bu})=>Bu),S),closeOnSelect:!1,lineClamp:Qt,onClick:()=>br(fe.text,fe),description:S!=="IMAGE"?fe.title&&fe.text:void 0,onFeedback:S!=="IMAGE"?()=>Pu(fe):void 0,children:S==="IMAGE"?(0,q.jsx)(M.Image,{title:fe.title||fe.text,src:fe.image}):fe.title||fe.text},`${fe.id}-${fe.text}`))},S))]})}),(0,q.jsx)(M.Page,{id:"edit",onDismiss:Xt(()=>{t(te("search")),p(null)}),children:c&&(0,q.jsx)(Ps,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(te("search")),p(null),u([])},onNext:Ou,onPrevious:Nu,onUse:S=>{t(te("search")),br(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(ee(!1)),u([]),p(null)}})}),(0,q.jsx)(M.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:Xt(()=>{t(te("search"))}),children:(0,q.jsx)(Zc,{onUse:Mu,onCopy:Iu})}),(0,q.jsx)(M.Page,{id:"summary",title:o("summaryTitle"),onDismiss:Xt(()=>{t(te("search"))}),children:(0,q.jsx)(np,{onCopy:Lu})}),(0,q.jsx)(M.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:Xt(()=>{t(wo()),t(te("search"))}),children:(0,q.jsx)(cp,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:Au,onResetQuestion:()=>{t(wo()),i("")}})})]})},gp=$m;var Eo=require("react/jsx-runtime"),Xm=()=>{let t=C("showSearch"),e=C("isEmbedded");return(0,Eo.jsxs)(mp.Fragment,{children:[t&&(0,Eo.jsx)(gp,{}),(0,Eo.jsx)(Dc,{}),e&&(0,Eo.jsx)(zc,{})]})},fp=Xm;var Vs=require("react"),Ye=require("react-redux");function ko(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}var js=require("react");var Sp=require("interweave"),Ro=require("react"),zs=require("react-redux");var hp=require("react");function yp(t,e,o){(0,hp.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var vp={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var Ut=require("react/jsx-runtime"),Zm=["search","personal-collection-search","search-autocomplete"];function Jm(t,e,o,n={}){let s="";return Zm.includes(e)?s=El(Zr(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Zr(t,o,n),n.placeholders===!0&&(s=kl(s)),s}var Ym=()=>{},ef=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=(0,zs.useSelector)(oo),i=(0,zs.useDispatch)(),a=y("TextSuggestion",vp),l=(0,Ro.useRef)(null);(0,Ro.useEffect)(()=>{let p=setTimeout(()=>{i(qa({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),yp(l,"click",()=>{i(ut(t)),i(ke({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,Ro.useMemo)(()=>Jm(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:(0,Ut.jsxs)("div",{className:a.root,onMouseEnter:()=>i(ut(t)),children:[(0,Ut.jsx)(D,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Ym,children:(0,Ut.jsx)(Sp.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&(0,Ut.jsx)("div",{className:a.actions,children:(0,Ut.jsx)(bs,{onFeedback:()=>n(o),suggestion:o.text})})]})},_p=ef;var wi=require("react/jsx-runtime"),tf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,js.useMemo)(()=>{let r=e.map((i,a)=>(0,wi.jsx)(_p,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,wi.jsx)(js.Fragment,{children:s})},qs=tf;var xp={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var un=require("react/jsx-runtime"),of=({textSuggestions:t,selectedIndex:e})=>{let o=(0,Vs.useRef)(null),n=y("InlineSuggestionsOverlay",xp),s=(0,Ye.useSelector)(ko),r=(0,Ye.useDispatch)(),i=(0,Ye.useSelector)(ue),a=(0,Ye.useSelector)(to),l=(0,Ye.useSelector)(Ls),c=C("showTextSuggestions");return lo(()=>{r(ht({collapse:!0,skipWhenInputFocus:!0}))}),(0,Vs.useEffect)(()=>{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:(0,un.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,un.jsx)("div",{ref:o,className:n.paper,children:(0,un.jsx)(Se,{children:(0,un.jsx)(qs,{suggestions:t,selectedIndex:e})})})})},nf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),bp=(0,Ye.connect)(nf)(of);var Gs=T(require("classnames")),Io=require("react"),Be=require("react-redux");var Cp=require("react");function wp(t,e){let[o,n]=(0,Cp.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return k.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){k.error(i)}}]}var Ep=T(require("classnames")),et=require("react");var Ti={};V(Ti,{enUS:()=>sf,nlNL:()=>rf});var sf={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"}]}]},rf={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 Tp={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var vt=require("react/jsx-runtime"),Ei=(t,e,o)=>n=>(0,vt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),af=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=E(Ti),i=xe(),a=y("Login",Tp),l=C("productName"),c=(0,et.useCallback)(v=>{v.preventDefault(),n&&n(parseInt(v.target.value,10))},[]),p=(0,et.useCallback)(v=>{v.preventDefault(),i.send(_o,!0)},[e]),d=(0,et.useMemo)(()=>v=>(0,vt.jsx)("a",{onClick:h=>{h.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:v},"login"),[e]),u=(0,et.useCallback)(v=>(0,vt.jsx)("button",{type:"button",className:a.anchorButton,onClick:p,children:v},"prompt"),[p]),{min:g,hour:f,day:m}=(0,et.useMemo)(()=>({min:Ei(a,60*10,c),hour:Ei(a,60*60,c),day:Ei(a,60*60*12,c)}),[]);return(0,vt.jsxs)("div",{className:(0,Ep.default)(t,a.root),children:[r("loginPlease",{login:o?u:d,productName:l}),n&&(0,vt.jsxs)(et.Fragment,{children:[(0,vt.jsx)("br",{}),r("snooze",{min:g,hour:f,day:m})]})]})},Ws=af;var Rp=require("react-redux");var kp={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var gn=require("react/jsx-runtime"),lf=({title:t})=>{let e=y("SearchTrigger",kp),o=(0,Rp.useDispatch)();return(0,gn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ee(!0)),children:[(0,gn.jsx)(mo,{}),(0,gn.jsx)("span",{className:e.text,children:t})]})},Ip=lf;var ki={};V(ki,{enUS:()=>cf,nlNL:()=>pf});var cf={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"}]},pf={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 Pp={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"};var H=require("react/jsx-runtime"),df=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=y("SuggestionsOverlay",Pp),s=E(ki),r=(0,Be.useSelector)(ko),i=Fa(),a=(0,Be.useDispatch)(),l=(0,Io.useRef)(null),c=C("searchTriggerKey"),p=C("productName"),d=(0,Be.useSelector)(Ls),u=(0,Be.useSelector)(ue),g=(0,Be.useSelector)(to),[f,m]=(0,Io.useState)(null),v=C("showSearch"),w=C("showTextSuggestions"),h=C("adminUrl"),x=C("isEmbedded"),[b,_]=wp("dd-snooze-until-ms",0),P=d||b>Date.now(),B=(0,Be.useSelector)(K=>K.input.text),re=t.filter(K=>K.source!=="gpt").length,O=()=>{P&&_(0),a(Cc(!P))},Y=K=>{a(X({name:"suggestion feedback",data:{text:K.text,source:"overlay",context:B},options:{includeConversationData:!0}}))},I=K=>{let Gt=Date.now()+K*1e3;_(Gt),k.info(`Snooze until: ${new Date(Gt)}`),a(ht({collapse:!0}))};return(0,Io.useEffect)(()=>{re===0&&m(null)},[t,re]),lo(()=>{a(ht({collapse:!0,skipWhenInputFocus:!0}))}),u===null||g===!1?null:u===!1?(0,H.jsxs)("div",{ref:l,className:(0,Gs.default)(n.root,{[n.isCollapsed]:P}),children:[!P&&(0,H.jsxs)("div",{className:n.triggers,children:[(0,H.jsx)("div",{style:{flex:1}}),(0,H.jsx)("div",{className:n.triggersRight,children:(0,H.jsx)(kt,{className:n.toggleButton,title:s("collapse"),onClick:O,isCollapsed:!1})})]}),(0,H.jsx)("div",{className:n.toggleButtonWrapper,children:(0,H.jsx)(kt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:O,isCollapsed:!0})}),(0,H.jsx)("div",{className:n.collapsible,children:(0,H.jsx)(Ws,{loginUrl:h,isEmbedded:x,onLogIn:o,onSnooze:I})})]}):!i||!r?null:(0,H.jsxs)("div",{ref:l,className:(0,Gs.default)(n.root,{[n.isCollapsed]:P}),children:[!P&&(0,H.jsxs)("div",{className:n.triggers,children:[(0,H.jsx)("div",{style:{flex:1},children:v&&(0,H.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(s(Cs()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>m(null),children:(0,H.jsx)(Ip,{title:s("search")})})}),(0,H.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,H.jsx)("div",{className:(0,Gs.default)(!f&&n.hintsHidden,n.hints),children:f}),(0,H.jsx)(kt,{className:n.toggleButton,title:s("collapse"),onClick:O,isCollapsed:!1})]})]}),(0,H.jsx)("div",{className:n.toggleButtonWrapper,children:(0,H.jsx)(kt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:O,isCollapsed:!0})}),re>0&&w&&(0,H.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,H.jsx)(Se,{children:(0,H.jsx)(qs,{onFeedback:Y,suggestions:t,selectedIndex:e,reverse:!0})})})]})},uf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Ap=(0,Be.connect)(uf)(df);var Lp=require("react-redux");var mn=require("react/jsx-runtime"),gf=({children:t})=>{let o=C("locale").replace("-","");return(0,mn.jsx)(zr.Provider,{value:o,children:t})},mf=({store:t,customStyles:e={},children:o})=>(0,mn.jsx)(Lp.Provider,{store:t,children:(0,mn.jsx)(gf,{children:(0,mn.jsx)(No.Provider,{value:e,children:o})})}),zt=mf;var ir=T(require("classnames")),Zp=require("interweave"),nt=require("react"),Jp=require("react-redux");var Mp=require("react"),ff=["div","span","mark","strong","b","i","u","em"];function Ri(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(ff.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,Mp.cloneElement)(n,{children:Ri(i,e,o+1)})]}return[...t,...e]}function St(t){return t.tagName.toLowerCase()==="textarea"}var Np={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"};var jp=T(require("classnames")),qp=require("interweave"),or=require("react");function Op(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function $s(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Dp(t){return t!=null}var Pi=T(require("classnames")),be=require("react");var Xs=require("react"),hf=["bottom","height","left","right","top","width"],yf=(t={},e={})=>hf.some(o=>t[o]!==e[o]),tt=new Map,Hp,Bp=()=>{let t=[],e=[];tt.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();yf(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{tt.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Hp=window.requestAnimationFrame(Bp)};function vf(t,e){return{observe(){let o=tt.size===0;if(tt.has(t)){let n=tt.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else tt.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&Bp()},unobserve(){let o=tt.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||tt.delete(t),tt.size||cancelAnimationFrame(Hp)}}}}function Ii(t){let[e,o]=(0,Xs.useState)(null);return(0,Xs.useLayoutEffect)(()=>{if(!t.current)return;let n=vf(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var Po=require("react"),Kp=require("react-dom");var Fp={root:"_root_1jq08_1"};var Up=({children:t})=>{let[e,o]=(0,Po.useState)(null),n=(0,Po.useContext)(No);return(0,Po.useLayoutEffect)(()=>{let s=document.createElement("div");return Pt(s),s.classList.add(Fp.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?(0,Kp.createPortal)(t,e):null};var Fe={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"};var Qs=require("react/jsx-runtime"),Zs=(t=!1)=>{let[e,o]=(0,be.useState)(t),n=(0,be.useCallback)(()=>o(!0),[]),s=(0,be.useCallback)(()=>o(!1),[]),r=(0,be.useCallback)(()=>o(a=>!a),[]),i=(0,be.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Ai(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 Js=({className:t,triggerRef:e,boundaryRef:o=(0,be.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=Ai,...a})=>{let l=Ii(e),c=Ii(o),p=(0,be.useMemo)(()=>i(l,c,0),[l,c]);return(0,Qs.jsx)(Up,{children:(0,Qs.jsx)("div",{className:(0,Pi.default)(Fe.ref,{[Fe.positionAbove]:n==="above",[Fe.positionBelow]:n==="below",[Fe.positionLeft]:n==="left",[Fe.positionRight]:n==="right",[Fe.alignStart]:s==="start",[Fe.alignCenter]:s==="center",[Fe.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,Qs.jsx)("div",{className:(0,Pi.default)(t,Fe.root),children:r})})})};var zp=T(require("classnames")),Ys=require("react");var Li=require("react/jsx-runtime"),er=(0,Ys.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,Ys.useRef)(null),r=y("TabCompletion",ze);return(0,Li.jsx)("div",{ref:$s([s,n]),className:(0,zp.default)(t,r.popoverContentContainer),...o,children:(0,Li.jsx)("div",{className:r.popoverContent,children:e})})});var _t=require("react/jsx-runtime"),Sf=t=>e=>{let o=Ai(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},_f=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",ze),i=Zs(),a=(0,or.useMemo)(()=>Sf(t.getBoundingClientRect()),[t]),[l,c]=ds(t);return(0,or.useEffect)(()=>{c?i.open():i.close()},[c]),(0,_t.jsxs)("span",{children:[(0,_t.jsx)("mark",{ref:$s([l,i.triggerRef]),className:(0,jp.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,_t.jsx)(Js,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,_t.jsx)(er,{style:o,children:(0,_t.jsx)("div",{className:r.hintText,children:s})})})]})},tr=class extends qp.Matcher{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${Op(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(Dp);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(0,_t.jsx)(_f,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var sr=T(require("classnames")),Xp=require("interweave"),se=require("react"),Qp=require("react-redux");var Mi=require("react/jsx-runtime"),Vp=()=>(0,Mi.jsx)("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:(0,Mi.jsx)("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});var xt=require("react"),fn=require("react-redux"),Gp=T(require("lodash.debounce"));var Wp={root:"_root_1muu8_1",content:"_content_1muu8_7"};function nr(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 Ni(t){return t.replace("https://www.","").replace("https://","")}var Ce=require("react/jsx-runtime"),xf=3,bf=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Cf=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=xf})=>{let r=y("LinkSearch",Wp),[i,a]=(0,xt.useState)(""),l=(0,fn.useDispatch)(),c=(0,fn.useSelector)(ic("url")),p=(0,fn.useSelector)(Xl("URL",bf)),[d,u]=(0,xt.useState)(p.length-1),g=C("fallbackImage"),f=h=>{let x=h.target;a(x.value)},m=(h,x)=>{h.stopPropagation(),h.preventDefault(),window.open(x,"_blank")},v=h=>{var _;let x=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&u(x),h.code==="ArrowDown"&&u(b),h.code==="Enter"&&t(((_=p[d])==null?void 0:_.text)||i)},w=(0,xt.useCallback)((0,Gp.default)(h=>{l(Dt({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,xt.useEffect)(()=>{i&&w(i)},[i]),(0,xt.useEffect)(()=>()=>{l(Es())},[]),(0,Ce.jsxs)("div",{className:r.root,children:[(0,Ce.jsx)(Se,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,x)=>(0,Ce.jsx)(D,{selected:d===x,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:(0,Ce.jsxs)(F,{children:[(0,Ce.jsx)(F.Image,{src:nr(h,"small",g||void 0),title:h.title||h.text}),(0,Ce.jsxs)(F.Content,{className:r.content,cropText:!0,children:[(0,Ce.jsx)(F.Title,{children:h.title||Ni(h.text)}),h.title&&Ni(h.text)]}),(0,Ce.jsx)(D.Actions,{children:(0,Ce.jsx)(D.ActionButton,{label:n,onClick:b=>m(b,h.text)})})]})},h.text))}),(0,Ce.jsx)(nn,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:v})]})},$p=Cf;var Oi={};V(Oi,{enUS:()=>wf,nlNL:()=>Tf});var wf={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Tf={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var ne=require("react/jsx-runtime"),Ef=(0,se.forwardRef)((t,e)=>{let o=y("TabCompletion",ze);return(0,ne.jsx)("mark",{ref:e,className:(0,sr.default)(o.matchSelection)},"selection-start")}),kf=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(Oi),i=y("TabCompletion",ze),a=(0,se.useRef)(null),l=(0,se.useRef)(null),[c,p]=(0,se.useState)(null),d=(0,Qp.useDispatch)(),u=Zs(document.activeElement===n),[g]=(0,se.useState)(()=>document.createRange());u.triggerRef.current=g,(0,se.useEffect)(()=>()=>g.detach(),[]),(0,se.useEffect)(()=>{let m=t.current,v=a.current;!m||!v||(g.setStart(m,0),g.setEnd(v,0))},[t.current,a.current]),lo(()=>{u.close()});let f=(0,se.useCallback)(m=>{let v=g.toString(),w=/^http(s?):\/\//.test(m)?m:`https://${m}`;d(Vn({text:`[${v}](${w})`,replace:"selection"}))},[]);return(0,ne.jsxs)("span",{children:[(0,ne.jsx)("mark",{ref:a,className:(0,sr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&(0,ne.jsx)(Js,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,ne.jsxs)(er,{style:o,ref:l,children:[(0,ne.jsx)("div",{className:(0,sr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,ne.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,ne.jsx)(Vp,{}),(0,ne.jsx)("span",{children:"\xA0"}),(0,ne.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,ne.jsx)($p,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},rr=class extends Xp.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,se.createRef)(),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?(0,ne.jsx)(Ef,{ref:this.startRef}):(0,ne.jsx)(kf,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var ot=require("react/jsx-runtime"),Rf=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",Np),p=C("insertLink"),d=C("showMidSentenceSuggestions"),u=C("inlineSuggestions"),g=gs(a),f=(0,nt.useRef)(null);(0,nt.useEffect)(()=>{St(a)&&g&&ms(a,g)},[g]);let m=(0,nt.useCallback)(h=>{if(!s||!o)return h;let x=[(0,ot.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,ot.jsx)("span",{"data-testid":"tab-completion",className:(0,ir.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push((0,ot.jsx)("span",{className:(0,ir.default)(c.hint,c.resetIndent),children:(0,ot.jsx)(Mn,{keyCode:"tab"},"tabHint")})),Ri(h,x)},[s,o,n]),v=(0,nt.useMemo)(()=>{let h=[];return p&&h.push(new rr("selection")),h.push(new io("placeholders")),r&&h.push(new tr("keywords")),h},[u,p,r]),w=(0,nt.useMemo)(()=>{let h=window.getComputedStyle(a);return{"--dd-color":h.color,"--dd-font-size":h.fontSize,"--dd-font-family":h.fontFamily,"--dd-font-variant":h.fontVariant}},[]);return t?(0,ot.jsxs)("div",{ref:h=>{h!=null&&h.parentElement&&(f.current=h==null?void 0:h.parentElement)},className:c.root,style:w,children:[(0,ot.jsx)(Zp.Interweave,{tagName:"span",containerTagName:"div",className:(0,ir.default)(c.container,c.agentText),disableLineBreaks:St(a),content:e||"\u200B",onAfterParse:m,matchers:v,selection:g,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!d}),(0,ot.jsx)("br",{})]}):null},If=({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??po(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:g,showStyleSuggestions:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((m=n.list)==null?void 0:m.keywordMatches)??[],enabled:g&&d!==!1}},Yp=(0,Jp.connect)(If)(Rf);var qd=T(require("classnames")),Vd=require("react"),$=require("react-redux");var bt=require("@reduxjs/toolkit");var ed={list:[],fetchState:"idle",isInitialRequest:null},od=t=>t.autoflows.list||[],td=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},st=(0,bt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Di=(0,bt.createAsyncThunk)("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(st(t.platformSessionId))}),Hi=(0,bt.createAsyncThunk)("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(st(t.platformSessionId))}),Pf=(0,bt.createSlice)({name:"autoflows",initialState:ed,reducers:{},extraReducers:t=>{t.addCase(Di.pending,(e,o)=>{let n=td(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Hi.pending,(e,o)=>{let n=td(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(st.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(st.rejected,e=>{e.fetchState="error"}),t.addCase(st.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(A,()=>ed)}}),nd=(0,bt.createAsyncThunk)("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(st(t))}),s.on("sessionCompleted",()=>{o(st(t))})}),sd=(0,bt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),rd=Pf.reducer;var Ct=require("@reduxjs/toolkit");var id={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},ad=t=>t.customMessages.list,ld=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),cd=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),pd=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),hn=(0,Ct.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),ar=(0,Ct.createAsyncThunk)("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)}),lr=(0,Ct.createAsyncThunk)("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)}),dd=(0,Ct.createSlice)({name:"customMessages",initialState:id,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(hn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(hn.rejected,e=>{e.fetchState="error"}).addCase(hn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(ar.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(ar.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(lr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(lr.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(A,()=>id)}}),ud=(0,Ct.createAsyncThunk)("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(dd.actions.onCustomMessage(r))})}),gd=(0,Ct.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),md=dd.reducer;var yn=require("@reduxjs/toolkit"),Af={token:null,accountUrl:null,interval:null},fd=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},Bi=(0,yn.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),Fi=(0,yn.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(Bi()),setInterval(()=>n(Bi()),o)}),hd=(0,yn.createSlice)({name:"passwordlessToken",initialState:Af,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Bi.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(Fi.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:yd}=hd.actions,vd=hd.reducer;function Sd(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var Rd=require("react"),Id=require("react-redux");var Td=T(require("classnames")),Ed=require("react");var xd=T(require("classnames"));var _d={root:"_root_838fd_1"};var Cd=require("react/jsx-runtime"),Lf=({className:t,children:e})=>{let o=y("Unicode",_d);return(0,Cd.jsx)("span",{className:(0,xd.default)(t,o.root),children:e})},bd=Lf;var wd={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 Ki={};V(Ki,{enUS:()=>Mf,nlNL:()=>Nf});var Mf={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"}]},Nf={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"}]};var ge=require("react/jsx-runtime"),Df=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",wd),a=E(Ki),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ge.jsxs)(D,{className:(0,Td.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,ge.jsx)(F,{children:(0,ge.jsxs)(F.Content,{children:[(0,ge.jsxs)(F.Title,{children:[e&&(0,ge.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,ge.jsx)("span",{children:n})]})}),(0,ge.jsx)(D.Actions,{fixed:e==="Started",children:(0,ge.jsx)(D.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,ge.jsxs)(Ed.Fragment,{children:[(0,ge.jsx)(bd,{children:c})," ",(0,ge.jsx)("span",{children:a(l)})]})})})]})},kd=Df;var Ui=require("react/jsx-runtime"),Hf=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Bf=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Ui.jsx)(Rd.Fragment,{children:t.map(s=>(0,Ui.jsx)(kd,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Hf(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Ff=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Kf={onStartAutoflow:Di,onStopAutoflow:Hi},Pd=(0,Id.connect)(Ff,Kf)(Bf);var cr=require("react"),Ld=require("react-redux"),qi=T(require("classnames"));var zi=require("react/jsx-runtime"),ji=()=>(0,zi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,zi.jsx)("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var Ad={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var Ke=require("react/jsx-runtime"),Uf=({entities:t})=>{let e=y("EntitiesWidgetList",Ad),[o,n]=(0,cr.useState)(void 0),s=(0,Ld.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),rn(a.text),s(X({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,cr.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Ke.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Ke.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Ke.jsx)("span",{className:e.entityText,children:a.text}),(0,Ke.jsxs)("span",{className:e.iconWrapper,children:[(0,Ke.jsx)("span",{className:(0,qi.default)(e.icon),children:(0,Ke.jsx)(ji,{})}),(0,Ke.jsx)("span",{className:(0,qi.default)(e.icon,o===l&&e.iconClicked),children:(0,Ke.jsx)(ji,{})})]})]},a.text))})},Md=Uf;var Nd=T(require("classnames")),Vi=require("react"),jt=require("react-redux");var rt={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"};var ce=require("react/jsx-runtime"),zf=({suggestion:t})=>{let e=E(Nt),o=(0,jt.useDispatch)(),n=(0,jt.useSelector)(ld(t.text)),s=(0,jt.useSelector)(cd(t.text)),r=(0,jt.useSelector)(pd(t.text)),i=(0,jt.useSelector)(Hn),{replyOptions:a}=t,l=(0,Vi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(ar({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Vi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o(lr({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return(0,ce.jsxs)(D,{onClick:l,className:(0,Nd.default)(rt.root,{[rt.isUsed]:n,[rt.hasError]:r}),children:[(0,ce.jsx)(F,{children:(0,ce.jsxs)(F.Content,{children:[(0,ce.jsxs)(F.Title,{className:rt.title,children:[t.text," ",(0,ce.jsx)(Nn,{className:rt.label,children:"analyse tool"})," ",r&&(0,ce.jsx)("span",{className:rt.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,ce.jsx)("ul",{className:rt.quickReplies,children:a.map(p=>(0,ce.jsx)("li",{className:rt.quickReply,children:p.title},p.title))})]})}),(0,ce.jsxs)(D.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,ce.jsx)(D.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,ce.jsx)(D.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,ce.jsx)(D.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Od=zf;var Wi=require("react/jsx-runtime"),Dd=()=>(0,Wi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Wi.jsx)("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});var Fd=require("react-redux");var Hd=require("react");var me=require("react/jsx-runtime"),jf=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=ks(s),i=E(Nt),a=C("showImages"),l=C("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},d=(0,Hd.useCallback)(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return(0,me.jsxs)(D,{onClick:c,"data-testid":"edit-suggestion",children:[(0,me.jsxs)(F,{children:[a&&t.image&&(0,me.jsx)(F.Image,{src:nr(t,"small",l||void 0),title:t.title}),(0,me.jsxs)(F.Content,{children:[t.title&&(0,me.jsx)(F.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,me.jsx)(D.Labels,{labels:t.searchKeywords}),(0,me.jsx)(F.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,me.jsxs)(D.Actions,{children:[r&&(0,me.jsx)(D.ActionButton,{onClick:d,label:i("visitUrl")}),(0,me.jsx)(D.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,me.jsx)(D.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Bd=jf;var vn=require("react/jsx-runtime"),qf=({contentType:t,lines:e,suggestions:o})=>{let n=xe(),s=(0,Fd.useSelector)(ho),r=a=>{n.send(mi,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Xe,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,vn.jsx)(vn.Fragment,{children:o.map(a=>(0,vn.jsx)(Bd,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Kd=qf;var Gi={};V(Gi,{enUS:()=>Vf,nlNL:()=>Wf});var Vf={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"}]},Wf={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 Ud={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"};var $i=require("react/jsx-runtime"),zd=()=>(0,$i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,$i.jsx)("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});var Xi=require("react/jsx-runtime"),jd=()=>(0,Xi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Xi.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var R=require("react/jsx-runtime"),pr=(t,e)=>{let o=(0,$.useSelector)(ue);(0,Vd.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},Gf=({onLogIn:t})=>{let e=E(Gi),o=(0,$.useDispatch)(),n=C("isEmbedded"),s=y("Widget",Ud),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=(0,$.useSelector)(To),d=(0,$.useSelector)(Us),u=(0,$.useSelector)(od),g=(0,$.useSelector)(Hs),f=(0,$.useSelector)(ad),m=(0,$.useSelector)(Bn),v=(0,$.useSelector)(to),w=(0,$.useSelector)(ue),h=(0,$.useSelector)(Hn),x=(0,$.useSelector)(Sd),b=(0,$.useSelector)(ho),_=xe(),P=(0,$.useSelector)(lc),B=(0,$.useSelector)(fd("/admin/")),re=C("adminUrl"),O=C("productName");if(pr(()=>(o(hn(h)),o(ud(h)),()=>{o(gd(h))}),[o,v,i,h]),pr(()=>(o(st(h)),o(nd(h)),()=>{o(sd(h))}),[o,v,r,h]),pr(()=>{d.forEach(({type:I})=>{o(I==="entities"?Ae():We(I))})},[o,v,m,p]),pr(()=>(o(Fi()),()=>{o(yd())}),[o]),v===!1)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("notSupported")})})},"supported");if(w===!1)return(0,R.jsx)("div",{className:s.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Ws,{isEmbedded:n,loginUrl:re,onLogIn:t})})},"login");if(!p||!h||w===null||P||x)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("waiting")})})},"waiting");let Y=c||a||l||B;return(0,R.jsx)("div",{className:(0,qd.default)(s.root),"data-testid":"widget",children:(0,R.jsxs)(On,{className:s.sectionList,children:[Y&&(0,R.jsx)(lt,{title:e("actions"),type:"shortcuts",children:(0,R.jsxs)("div",{className:s.shortcutList,children:[c&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-search",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(mo,{}),e("linkSearch")]}),a&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(jd,{}),e("linkSummary")]}),l&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(zd,{}),e("linkKnowledgeSearch")]}),B&&(0,R.jsxs)("a",{className:s.shortcut,target:"_blank",href:B,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,R.jsx)(Dd,{}),e("linkStudioLogin",{productName:O})]})]})}),i&&f.length>0&&(0,R.jsx)(lt,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(Se,{withDivider:!0,children:f.map(I=>(0,R.jsx)(Od,{suggestion:I},I.text))})}),r&&u.length>0&&(0,R.jsx)(lt,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)(Pd,{})})}),d.map(({type:I,title:K,amount:Gt,lines:$t})=>{var Tn;switch(I){case"entities":return g&&g.length>0&&(0,R.jsx)(lt,{type:I,title:K,"data-testid":`type-${I}`,children:(0,R.jsx)(Md,{entities:g})},I);default:return((Tn=b[I])==null?void 0:Tn.fetchState)==="done"&&b[I].suggestions.length>0&&(0,R.jsx)(lt,{type:I,title:K,"data-testid":`type-${I}`,children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)(Kd,{lines:$t,contentType:I,suggestions:b[I].suggestions.slice(0,Gt)||[]})})},I)}})]})})},Wd=Gf;function Ao(t){let e=new Range;return e.selectNodeContents(t),e}function Gd(t,e,o){try{return wt(t,e,o),!0}catch{return!1}}function dr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function ur(t){return"tagName"in t&&t.tagName==="BR"}var Sn=/[\u200B-\u200D\uFEFF]/g;function wt(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 u=0;u<=l.length;u++)if(d.test(l[u])||p++,p===c)return u;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(Sn,""),d=s+p.length,u=e>=s&&e<=d,g=o>=s&&o<=d;if(u){let f=i(c,e-s);f===0&&!g?n.setStartBefore(l):n.setStart(l,f)}g&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(ur(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;dr(l)&&c&&!dr(c)&&!ur(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function _n(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 u=d===o,g=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let f=d.textContent;u&&(a=c+f.substring(0,n).replace(Sn,"").length),g&&(l=c+f.substring(0,r).replace(Sn,"").length),c+=f.replace(Sn,"").length;break}case Node.ELEMENT_NODE:{let f=d.nextSibling===null;ur(d)&&!f&&c++;for(let m=0;m<d.childNodes.length;m++){let v=u&&m===n,w=g&&m===r;if(v&&(a=c),w&&(l=c),l!==void 0||((!v||!i)&&p(d.childNodes[m]),g&&m===r-1&&(l=c),l!==void 0))break}!g&&dr(d)&&!f&&c++,g&&(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 xn(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 u=p?n:0,g=d?r:void 0,f=c.textContent.replace(Sn,"");u===0&&g===void 0?a+=f:a+=f.substring(u,g);break}case Node.ELEMENT_NODE:{let u=c.nextSibling===null;i===0&&ur(c)&&!u&&(a+=`
4
4
  `);for(let g=p?n:0;g<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[g]),i!==1);g++);!d&&i===0&&dr(c)&&!u&&(a+=`
5
5
  `);break}default:break}d&&i++}return l(t),a}function $d(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var qt=class extends je{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),xn(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!$d(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!$d(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return _n(this.element,e);let o=this.lastKnownSelection;if(o&&Gd(this.element,o.start,o.end))return o;let n=Ao(this.element);return n.collapse(!1),_n(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return xn(this.element,wt(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 Xd(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 Qi=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(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Zi=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=Xd(e,`${this.targetOrigin}/v2/widget/liveengage/channel.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(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Ji=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(),k.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 Zi(e,this.deepdeskUrl,{debug:!0}):new Qi(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(k.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var r,i;k.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)}},Qd=Ji;var Lo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Yi=t=>new Promise(e=>{setTimeout(e,t)});var Mo=class extends Lo{name="ClientError"},ea=class extends Lo{name="ServerError"},Me=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:u=b=>b instanceof TypeError,retryOnResponse:g=b=>b.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 w=c,h=!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()=>(w--,a(i,v).then(async b=>g(b)&&!r.isAborted&&w>0?(await Yi(p),x()):b.status===401&&d===!0&&h===!1?(h=!0,await this.refreshToken(),x()):b).catch(async b=>{if(u(b)&&!r.isAborted&&w>0)return await Yi(p),x();throw b}));x().then(b=>b.json().catch(()=>null).then(_=>{b.status>=500?s(new ea("Server Error",_)):b.status===401?s(new Mo("Unauthorized",_)):b.status===403?s(new Mo("Forbidden",_)):b.status===404?s(new Mo("Not Found",_)):b.status>=400&&s(new Mo("Bad Request",_)),delete this.latestRequestByUrl[i],n(_)})).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 $f;(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||={})})($f||={});function gr(t){return{...L(t),tags:t.tags}}var it=class t{constructor(e,o={}){this.options=o;this.client=new Me(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(),k.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...j(e),tags:e.tags},{version:"v2"});return gr(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return L(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return L(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return L(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(),k.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 gr(r)}async isConversationSupported(e,o={}){k.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=j(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return gr(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...j(s),tags:s.tags})),{version:"v2"})).map(s=>gr(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",j({...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:j({...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)},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 k.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",j(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}`,j(o),{abortLatest:!0})).map(r=>({...L(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`,j(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 L(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",j(e),{abortLatest:!0});return L(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,j(e),{version:"v2"});return L(o)}async knowledgeAssist(e,o,n){let s=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,j({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return L(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return L(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return L(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 L(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(ka);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&k.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var bn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(ai(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,L(s))}catch{k.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 Xf;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Xf||={});var Cn=class{constructor(e,o={}){this.apiUrl=e;this.client=new Me(e,o)}client;streams={};logger=k;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return L(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,j(o));return L(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,j(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return L(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",j(e));return L(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new bn(`${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])}};var yr=require("@reduxjs/toolkit");var Jd=require("@reduxjs/toolkit");var Zd={startTime:null,stopTime:null},Yd=(0,Jd.createSlice)({name:"handlingTime",initialState:Zd,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(A,()=>Zd)}}),{handlingTimeStart:eu,handlingTimeStop:mr,handlingTimeReset:tu}=Yd.actions,ou=Yd.reducer;var nu=(t={})=>{let e={onAuthError:So(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var hr=require("@reduxjs/toolkit");var fr={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Vt=(0,hr.createAsyncThunk)("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 fr.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Qf=(0,hr.createSlice)({name:"styleSuggestions",initialState:fr,reducers:{},extraReducers:t=>{t.addCase(Vt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Vt.rejected,e=>{e.fetchState="error"}).addCase(Vt.fulfilled,(e,o)=>{e.fetchState="done",pt(e.list,o.payload)||(e.list=o.payload)}).addCase(Rt,e=>{e.list=fr.list}).addCase(A,()=>fr)}}),su=Qf.reducer;var ru=(t={})=>{let e,o=!0,n={getStyleSuggestions:Vt,debounce:500,...t};return s=>r=>i=>{var g;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(!((g=c.conversation.current)==null?void 0:g.id)||!p)return l;let{text:u}=c.input;return u===a&&!o||(clearTimeout(e),u==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:u}))},t.debounce)),l}};function Zf(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var iu=(t={})=>{let e={getTextSuggestions:We,getAutocompleteSuggestions:Jo,debounce:200,check:ko,...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:p}=l.settings,d=(m=l.conversation.current)==null?void 0:m.id,u=r.type===As.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:g}}=l;return Zf(g,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=oo(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},u?0:e.debounce)),a}};var au=Vt.fulfilled.toString();function Jf(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 lu=t=>e=>o=>n=>{var c;if(n.type!==au){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=Jf(s,i);n.type===au&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Yf=(0,yr.combineReducers)({activeSuggestion:Sc,answer:ap,auth:Mc,autoflows:rd,conversation:Oa,contentTypes:Vc,customMessages:md,passwordlessToken:vd,entities:Xc,handlingTime:ou,info:Vl,input:Ar.reducer,overlayInput:ie.reducer,settings:Aa,profile:pp,search:Zl,summary:tp,styleSuggestions:su,ui:wc,textSuggestions:gc});function cu(t){return(0,yr.configureStore)({reducer:Yf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),nu(),iu({debounce:200}),ru({debounce:500}),lu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var eh=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},th=t=>e=>o=>n=>{var a;let s=e.getState(),r=kr("inlineSuggestions")(s);switch(n.type){case Ge.toString():{let l=ac(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 So.toString():{!n.payload&&t.emit("logout",void 0);break}case ke.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:eh(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Vn.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 Bo.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Xn.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 Qe.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case X.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 Wn.toString():t.handleKeyDown(n.payload);break;case Rt.toString():t.logSendMessage(n.payload);break;case Gn.toString():t.logSendEditSuggestionMessage(n.payload);break;case $n.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Rt.toString():t.handleAfterSendMessage(n.payload);break;case Yo.toString():t.onUpdateShowTabHint(n.payload);break;case mr.toString():t.logHandlingTime();break;case ke.toString():{r&&(e.dispatch(Oe([])),e.dispatch(Ue()));break}case Oe.toString():{r&&n.payload.length>0&&e.dispatch(ut(0));break}default:break}return i},pu=th;function ta(t){return t.toISOString().replace("T"," ").replace("Z","")}function du(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:ta(o),timeStop:ta(n)}}function oa(t,e,o){var B,re,O;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:u,deletions:g,textSuggestions:f,offeredTextSuggestions:m}}=e[t],v=n.length,h=f.reduce((Y,{text:I,searchTerm:K})=>Y+I.length-(K?K.length:0),0),x=c??Date.now(),b=(Date.now()-x)/1e3+(p||0),_=s/b,P=f.reduce((Y,{searchTerm:I})=>Y+(I?I.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:u,deletions:g,lenTextTyped:s+P,lenTextTotal:v,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:_,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:m.filter(Y=>Y.source==="gpt").length}],agentId:(B=e.info.agentInfo)==null?void 0:B.agentId,agentName:(re=e.info.agentInfo)==null?void 0:re.agentName,agentEmail:(O=e.info.agentInfo)==null?void 0:O.agentEmail}}function na(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return na(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?na(s,e):null}function uu(t,e){return na(t,e)}function gu(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function oh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function vr(t){return oh(t)&&(St(t)||us(t))}var mu=(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{k.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function nh(t){return t.offsetParent!==null}function fu(t){if(!nh(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 Sr(t,e,o=100){let n=fu(t);e({isVisible:n});let s=setInterval(()=>{let r=fu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var Su=require("react-redux");var _r=require("react/jsx-runtime"),hu=({className:t})=>(0,_r.jsx)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:t,children:(0,_r.jsx)("g",{children:(0,_r.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
6
6
  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
7
7
  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
8
8
  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
9
- c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var sa=require("react/jsx-runtime"),sh={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},yu=({className:t,color:e})=>(0,sa.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,sa.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:sh[e||"pink"]})});var vu={root:"_root_bgd7a_1",text:"_text_bgd7a_18",icon:"_icon_bgd7a_33",logo:"_logo_bgd7a_38",lock:"_lock_bgd7a_43"};var ra={};V(ra,{enUS:()=>rh,nlNL:()=>ih});var rh={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"}]},ih={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"}]};var _u=require("react-redux"),Wt=require("react/jsx-runtime"),xu=({onLogIn:t})=>{let e=E(ra),o=C("productName"),n=(0,_u.useDispatch)(),s=(0,Su.useSelector)(ue),r=y("FloatingMenu",vu);if(s===null)return null;let i=()=>{s===!0?n(ee(!0)):t()};return(0,Wt.jsxs)("button",{className:r.root,onClick:i,children:[(0,Wt.jsx)("div",{className:r.text,children:e(s?"search":"signin",{productName:o})}),(0,Wt.jsxs)("div",{className:r.icon,children:[(0,Wt.jsx)(yu,{className:r.logo,color:"pink"}),s===!1&&(0,Wt.jsx)(hu,{className:r.lock})]})]})};async function xr(t){let o=await new Me(t).get("/platform/config/",{version:null});return L(o)}var z=require("react/jsx-runtime");var bu=mu("showTabHint",!0),wn=class t{static version="10.9.1";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 it(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[pu({emit:(d,u,g)=>this.emit(d,u,g),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=>bu.update(d),sendEvent:(d,u)=>this.deepdeskApi.sendEvent(d,u)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new Cn(o)}),this.store=cu(p),this.broadcastEvents=new Qd({debug:!0,deepdeskUrl:c,eventMap:Nc(this.store),createCustomChannel:l}),this.store.dispatch(Ho),this.store.dispatch(Yo(bu.value())),this.store.dispatch(Ho({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?(k.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(k.warn("Profile has not been loaded (yet)"),!0):(k.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(So(null)),this.store.dispatch($e()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ue(n)&&kc(n)!=="loading"&&e()});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch($e())).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){k.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(Ir({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Fn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Kn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Pr(e))).payload}async postMessages(e){return(await this.store.dispatch(zn(e))).payload}async updateConversation(e){return(await this.store.dispatch(Un(e))).payload}resetConversation(){this.store.dispatch(A()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Qe());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Ho(e))}setVisitorInfo(e){this.store.dispatch(ql(e))}async setAgentInfo(e){await this.store.dispatch($o(e))}async setAgentSettings(e){await this.store.dispatch(li(e))}async getAgentSettings(){return(await this.store.dispatch(ci())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(As()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch($n(e))}notifyKeyDown(e){this.store.dispatch(Wn(e))}notifyPaste(e,o){this.store.dispatch($a({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Wa(e))}notifyExternalSuggestion(e){this.store.dispatch(ke(e)),this.store.dispatch(Ue())}notifyEditSuggestion(e){this.store.dispatch(dc(e.contentType,e.suggestions)),this.store.dispatch(Ge({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(ht({collapse:!1})),this.inputMediator&&this.store.dispatch(Ka({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Oe([])))}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(Ga(qn(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(ja()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Va());let{selectedSuggestionIndex:d}=this.state.input;e.preventDefault(),!i&&(d===-1?this.store.dispatch(Bo()):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(ut(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(ut(-1)),this.store.dispatch(Bo()),e.preventDefault()):o||(this.store.dispatch(ht({collapse:!0})),this.store.dispatch(bc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,u=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:g}=this.state.input;this.store.dispatch(Yo(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&g&&g.text.startsWith(u)&&(this.store.dispatch(ke({text:g.text,suggestion:g,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Ue())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Xa()),this.store.dispatch(Oe([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(eu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(mr()))}logSendMessage(e){let o=oa("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=oa("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(za(this.state.overlayInput.metrics))}logHandlingTime(){let e=du(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(tu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(Ue()),this.store.dispatch(Rt(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(ke({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){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.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]=At(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(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]=At(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Pt(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(()=>{(0,we.unmountComponentAtNode)(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),k.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()?(k.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Za(n.metrics))):k.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(!vr(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:u,insertLink:g,inputMediator:f,closestScrollSelector:m,appendOverlayTo:v,inlineSuggestions:w,floatingMenu:h}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:d,inlineSuggestions:w,floatingMenu:h}),o.automaticHandlingTime&&this.setupHandlingTime(e),Pt(e),this.inputMediator=f||(St(e)?new qe(e):new qt(e)),this.inputMediator.on("change",({plainText:_})=>{this.notifyInputChanged(_)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Qa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",_=>{this.notifyKeyDown(_)}),this.inputMediator.on("paste",({pastedText:_,selectionText:P})=>{this.notifyPaste(_,P)}),this.inputMediator.on("cut",({selectionText:_})=>{this.notifyCut(_)});let x=m&&uu(e,m)||void 0;if(w){let{customStyles:_,appendOverlayTo:P}=o;if(St(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let B=this.createInlineContainer(e,"deepdesk-caret");(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:_,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(bp,{})})}),B),this.inputMediator.on("caret",O=>{this.store.dispatch(Oe([])),O?(B.style.display="block",B.style.top=`${O.top}px`,B.style.left=`${O.left}px`):B.style.display="none"});let re=this.overlayContainerFactory("floating-menu",x||e,{appendTo:P});(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:_,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(xu,{onLogIn:()=>this.loginViaPopup()})})}),re)}else{let _=this.overlayContainerFactory("deepdesk-tab-completion",x||e,{appendTo:v,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),P=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||e,{appendTo:v},n==null?void 0:n.suggestionsRootNode);(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:n,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(Yp,{inputElement:e})})}),_),(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:n,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(Ap,{onLogIn:()=>this.loginViaPopup()})})}),P)}(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:n,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(fp,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",_=>{clearTimeout(b),_===null?b=setTimeout(()=>{_!==null&&this.store.dispatch(Lr(_))},500):this.store.dispatch(Lr(_))}),this.inputMediator.on("disabled",()=>{var _;(_=this.inputMediator)==null||_.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{u&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(yo(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(yo(!0))),this.store.dispatch(Ua({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(Ue()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var _;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((_=this.state.conversation.current)==null?void 0:_.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&&k.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}),(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:n,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(Wd,{onLogIn:()=>this.loginViaPopup()})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&(0,we.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Sr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){gu(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(dn());let e=To(this.state);e&&this.store.dispatch(Ho({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeAssistForAgents,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async loginViaPopup(){let e=this.state.settings.adminUrl,o=new URL(e),n=await xr(o.origin);return new Promise((s,r)=>{let i=new MessageChannel,a=i.port1,l=new URL(n.config.platform.hasSso?`${e}/platform/sso/`:`${e}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let c=!1,p=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",u),clearInterval(g)};a.onmessage=async f=>{var m,v;if((m=f.data)!=null&&m.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((v=f.data)==null?void 0:v.jwt),await this.isLoggedIn(),this.broadcastEvents.send(on),p(),c=!0,i.port1.close(),s()}catch(w){r(w)}};let d=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&r(new Error("Popup blocked by browser"));let u=async f=>{var m;if(f.origin===l.origin)switch((m=f.data)==null?void 0:m.type){case"deepdesk-popup-loaded":{d==null||d.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[i.port2]);break}case"deepdesk-popup-error":{p(),f.data.message==="Timeout"&&k.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(f.data.message));break}}};window.addEventListener("message",u);let g=setInterval(()=>{d&&!d.closed||(p(),c||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(p)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(k.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;k.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=Us(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Ae()):this.store.dispatch(We(n))})}catch(n){this.handleError(n)}}};async function Cu(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 wu(t,e,o={}){let n=o.replace?wt(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(`
9
+ c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var sa=require("react/jsx-runtime"),sh={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},yu=({className:t,color:e})=>(0,sa.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,sa.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:sh[e||"pink"]})});var vu={root:"_root_bgd7a_1",text:"_text_bgd7a_18",icon:"_icon_bgd7a_33",logo:"_logo_bgd7a_38",lock:"_lock_bgd7a_43"};var ra={};V(ra,{enUS:()=>rh,nlNL:()=>ih});var rh={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"}]},ih={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"}]};var _u=require("react-redux"),Wt=require("react/jsx-runtime"),xu=({onLogIn:t})=>{let e=E(ra),o=C("productName"),n=(0,_u.useDispatch)(),s=(0,Su.useSelector)(ue),r=y("FloatingMenu",vu);if(s===null)return null;let i=()=>{s===!0?n(ee(!0)):t()};return(0,Wt.jsxs)("button",{className:r.root,onClick:i,children:[(0,Wt.jsx)("div",{className:r.text,children:e(s?"search":"signin",{productName:o})}),(0,Wt.jsxs)("div",{className:r.icon,children:[(0,Wt.jsx)(yu,{className:r.logo,color:"pink"}),s===!1&&(0,Wt.jsx)(hu,{className:r.lock})]})]})};async function xr(t){let o=await new Me(t).get("/platform/config/",{version:null});return L(o)}var z=require("react/jsx-runtime");var bu=mu("showTabHint",!0),wn=class t{static version="10.9.2";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 it(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[pu({emit:(d,u,g)=>this.emit(d,u,g),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=>bu.update(d),sendEvent:(d,u)=>this.deepdeskApi.sendEvent(d,u)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new Cn(o)}),this.store=cu(p),this.broadcastEvents=new Qd({debug:!0,deepdeskUrl:c,eventMap:Nc(this.store),createCustomChannel:l}),this.store.dispatch(Ho),this.store.dispatch(Yo(bu.value())),this.store.dispatch(Ho({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?(k.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(k.warn("Profile has not been loaded (yet)"),!0):(k.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(So(null)),this.store.dispatch($e()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ue(n)&&kc(n)!=="loading"&&e()});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch($e())).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){k.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(Ir({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Fn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Kn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Pr(e))).payload}async postMessages(e){return(await this.store.dispatch(zn(e))).payload}async updateConversation(e){return(await this.store.dispatch(Un(e))).payload}resetConversation(){this.store.dispatch(A()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Qe());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Ho(e))}setVisitorInfo(e){this.store.dispatch(ql(e))}async setAgentInfo(e){await this.store.dispatch($o(e))}async setAgentSettings(e){await this.store.dispatch(li(e))}async getAgentSettings(){return(await this.store.dispatch(ci())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(As()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch($n(e))}notifyKeyDown(e){this.store.dispatch(Wn(e))}notifyPaste(e,o){this.store.dispatch($a({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Wa(e))}notifyExternalSuggestion(e){this.store.dispatch(ke(e)),this.store.dispatch(Ue())}notifyEditSuggestion(e){this.store.dispatch(dc(e.contentType,e.suggestions)),this.store.dispatch(Ge({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(ht({collapse:!1})),this.inputMediator&&this.store.dispatch(Ka({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Oe([])))}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(Ga(qn(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(ja()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Va());let{selectedSuggestionIndex:d}=this.state.input;e.preventDefault(),!i&&(d===-1?this.store.dispatch(Bo()):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(ut(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(ut(-1)),this.store.dispatch(Bo()),e.preventDefault()):o||(this.store.dispatch(ht({collapse:!0})),this.store.dispatch(bc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,u=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:g}=this.state.input;this.store.dispatch(Yo(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&g&&g.text.startsWith(u)&&(this.store.dispatch(ke({text:g.text,suggestion:g,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Ue())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Xa()),this.store.dispatch(Oe([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(eu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(mr()))}logSendMessage(e){let o=oa("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=oa("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(za(this.state.overlayInput.metrics))}logHandlingTime(){let e=du(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(tu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(Ue()),this.store.dispatch(Rt(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(ke({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){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.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]=At(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(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]=At(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Pt(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(()=>{(0,we.unmountComponentAtNode)(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),k.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()?(k.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Za(n.metrics))):k.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(!vr(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:u,insertLink:g,inputMediator:f,closestScrollSelector:m,appendOverlayTo:v,inlineSuggestions:w,floatingMenu:h}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:d,inlineSuggestions:w,floatingMenu:h}),o.automaticHandlingTime&&this.setupHandlingTime(e),Pt(e),this.inputMediator=f||(St(e)?new qe(e):new qt(e)),this.inputMediator.on("change",({plainText:_})=>{this.notifyInputChanged(_)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Qa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",_=>{this.notifyKeyDown(_)}),this.inputMediator.on("paste",({pastedText:_,selectionText:P})=>{this.notifyPaste(_,P)}),this.inputMediator.on("cut",({selectionText:_})=>{this.notifyCut(_)});let x=m&&uu(e,m)||void 0;if(w){let{customStyles:_,appendOverlayTo:P}=o;if(St(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let B=this.createInlineContainer(e,"deepdesk-caret");(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:_,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(bp,{})})}),B),this.inputMediator.on("caret",O=>{this.store.dispatch(Oe([])),O?(B.style.display="block",B.style.top=`${O.top}px`,B.style.left=`${O.left}px`):B.style.display="none"});let re=this.overlayContainerFactory("floating-menu",x||e,{appendTo:P});(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:_,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(xu,{onLogIn:()=>this.loginViaPopup()})})}),re)}else{let _=this.overlayContainerFactory("deepdesk-tab-completion",x||e,{appendTo:v,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),P=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||e,{appendTo:v},n==null?void 0:n.suggestionsRootNode);(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:n,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(Yp,{inputElement:e})})}),_),(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:n,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(Ap,{onLogIn:()=>this.loginViaPopup()})})}),P)}(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:n,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(fp,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",_=>{clearTimeout(b),_===null?b=setTimeout(()=>{_!==null&&this.store.dispatch(Lr(_))},500):this.store.dispatch(Lr(_))}),this.inputMediator.on("disabled",()=>{var _;(_=this.inputMediator)==null||_.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{u&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(yo(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(yo(!0))),this.store.dispatch(Ua({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(Ue()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var _;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((_=this.state.conversation.current)==null?void 0:_.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&&k.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}),(0,we.render)((0,z.jsx)(zt,{store:this.store,customStyles:n,children:(0,z.jsx)(Ft,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(Wd,{onLogIn:()=>this.loginViaPopup()})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&(0,we.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Sr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){gu(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(dn());let e=To(this.state);e&&this.store.dispatch(Ho({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeAssistForAgents,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async loginViaPopup(){let e=this.state.settings.adminUrl,o=new URL(e),n=await xr(o.origin);return new Promise((s,r)=>{let i=new MessageChannel,a=i.port1,l=new URL(n.config.platform.hasSso?`${e}/platform/sso/`:`${e}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let c=!1,p=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",u),clearInterval(g)};a.onmessage=async f=>{var m,v;if((m=f.data)!=null&&m.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((v=f.data)==null?void 0:v.jwt),await this.isLoggedIn(),this.broadcastEvents.send(on),p(),c=!0,i.port1.close(),s()}catch(w){r(w)}};let d=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&r(new Error("Popup blocked by browser"));let u=async f=>{var m;if(f.origin===l.origin)switch((m=f.data)==null?void 0:m.type){case"deepdesk-popup-loaded":{d==null||d.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[i.port2]);break}case"deepdesk-popup-error":{p(),f.data.message==="Timeout"&&k.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(f.data.message));break}}};window.addEventListener("message",u);let g=setInterval(()=>{d&&!d.closed||(p(),c||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(p)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(k.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;k.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=Us(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Ae()):this.store.dispatch(We(n))})}catch(n){this.handleError(n)}}};async function Cu(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 wu(t,e,o={}){let n=o.replace?wt(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
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?wt(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()}})}async function Tu(t,e){let o;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let n=()=>{let s=t.ownerDocument.defaultView??window,r=s.getSelection();if((!r||r.rangeCount===0)&&(t.focus(),r=s.getSelection()),!r||r.rangeCount===0)return;let i=r.getRangeAt(0);i&&(i.deleteContents(),o=document.createElement("span"),i.insertNode(o),e.split(`
11
11
  `).reverse().forEach((a,l)=>{l>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(a))}),i.collapse(!1))};return Promise.resolve(n()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!o)try{o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}function Eu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function ku(t,e,o){await new it(t).authenticateWithKey(e,o)}async function ah(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 Ru(t,e){let o=await ah(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}}0&&(module.exports={Card,ContentEditableInput,DeepdeskAPI,DeepdeskSDK,HTTPClient,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createFullRange,createOverlayContainer,createRangeFromOffsets,escapeHTML,fetchPlatformConfig,formatTextMarkup,getRangeOffsets,getRangeText,insertCKEditor,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});