@deepdesk/deepdesk-sdk 10.12.1-beta.4 → 10.12.1-beta.5

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
- "use strict";var mg=Object.create;var Kn=Object.defineProperty;var fg=Object.getOwnPropertyDescriptor;var hg=Object.getOwnPropertyNames;var yg=Object.getPrototypeOf,vg=Object.prototype.hasOwnProperty;var $=(t,e)=>{for(var o in e)Kn(t,o,{get:e[o],enumerable:!0})},Sa=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of hg(e))!vg.call(t,s)&&s!==o&&Kn(t,s,{get:()=>e[s],enumerable:!(n=fg(e,s))||n.enumerable});return t};var k=(t,e,o)=>(o=t!=null?mg(yg(t)):{},Sa(e||!t||!t.__esModule?Kn(o,"default",{value:t,enumerable:!0}):o,t)),Sg=t=>Sa(Kn({},"__esModule",{value:!0}),t);var Zh={};$(Zh,{Card:()=>D,ContentEditableInput:()=>Yt,DeepdeskAPI:()=>gt,DeepdeskSDK:()=>Dn,HTTPClient:()=>De,InputMediator:()=>Xe,InputType:()=>mt,KeyboardHint:()=>Vn,Label:()=>qn,Locale:()=>Wo,Section:()=>We,SectionList:()=>Wn,Sources:()=>ke,Suggestion:()=>L,SuggestionList:()=>ue,TextAreaInput:()=>Ze,ToggleButton:()=>Mt,attachFile:()=>ng,authenticateWithKey:()=>tg,createFullRange:()=>Do,createOverlayContainer:()=>Ht,createRangeFromOffsets:()=>At,escapeHTML:()=>yo,fetchPlatformConfig:()=>og,formatTextMarkup:()=>eg,getRangeOffsets:()=>Ln,getRangeText:()=>Mn,insertCKEditor:()=>Yu,isHTML:()=>Bt,isSupportedInputElement:()=>Ar,updateContentEditable:()=>Qu,updateTextArea:()=>Zu,useStyles:()=>y,waitForElementVisibilityChange:()=>Lr});module.exports=Sg(Zh);var jn=k(require("classnames")),de=k(require("react"));var Un=k(require("react")),_a=k(require("classnames")),Uo=Un.default.createContext({});function y(t,e){let{debug:o,...n}=(0,Un.useContext)(Uo),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,_a.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var zo=require("react/jsx-runtime"),xa=({className:t})=>(0,zo.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,zo.jsx)("line",{x1:"1",y1:"11",x2:"11",y2:"1",stroke:"black",strokeWidth:"2"}),(0,zo.jsx)("line",{x1:"1",y1:"1",x2:"11",y2:"11",stroke:"black",strokeWidth:"2"})]});var ba={root:"_root_vr71j_1"};var Lt=require("react/jsx-runtime"),zn=()=>(0,Lt.jsxs)("svg",{className:ba.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Lt.jsx)("defs",{children:(0,Lt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Lt.jsx)("title",{children:"Failed loading image"}),(0,Lt.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 Nr={root:"_root_15d2a_1",imageWrapper:"_imageWrapper_15d2a_7",image:"_image_15d2a_7",content:"_content_15d2a_24",title:"_title_15d2a_35",contentIsCropped:"_contentIsCropped_15d2a_45",lineClamp:"_lineClamp_15d2a_51",closeIcon:"_closeIcon_15d2a_58"};var qe=require("react/jsx-runtime"),jo=(0,de.createContext)(Nr),_g=({title:t,src:e})=>{let o=(0,de.useContext)(jo),[n,s]=(0,de.useState)(!1);return(0,de.useEffect)(()=>{s(!1)},[e]),(0,qe.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,qe.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,qe.jsx)(zn,{})})},xg=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,de.useContext)(jo);return(0,qe.jsx)("div",{className:(0,jn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},bg=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,de.useContext)(jo);return de.default.createElement(t,{className:(0,jn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Cg=({className:t,title:e,...o})=>{let n=(0,de.useContext)(jo);return(0,qe.jsx)("div",{className:(0,jn.default)(n.closeIcon,t),title:e,role:"button","aria-label":e,...o,children:(0,qe.jsx)(xa,{})})},Vo=({children:t})=>{let e=y("Card",Nr);return(0,qe.jsx)("div",{className:e.root,children:(0,qe.jsx)(jo.Provider,{value:e,children:t})})};Vo.Image=_g;Vo.Content=xg;Vo.Title=bg;Vo.CloseIcon=Cg;var D=Vo;var wa=k(require("classnames"));var Ca={root:"_root_cq1yq_1"};var Ta=require("react/jsx-runtime");var wg={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Tg=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",Ca);return(0,Ta.jsx)("span",{"data-key":wg[e],className:(0,wa.default)(t,n.root),...o})},Vn=Tg;var ka=k(require("classnames"));var Ea={root:"_root_4a08n_1"};var Ia=require("react/jsx-runtime"),Eg=({className:t,children:e,...o})=>{let n=y("Label",Ea);return(0,Ia.jsx)("span",{...o,className:(0,ka.default)(t,n.root),children:e})},qn=Eg;var Ra={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var no=require("react/jsx-runtime"),kg=({title:t,children:e,type:o,...n})=>{let s=y("Section",Ra);return(0,no.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,no.jsx)("div",{className:s.subTitleContainer,children:(0,no.jsx)("span",{className:s.subtitle,children:t})}),(0,no.jsx)("div",{className:s.suggestions,children:e})]})},We=kg;var Aa=k(require("classnames")),La=k(require("react"));var Pa={root:"_root_19wxp_1"};var Ma=require("react/jsx-runtime"),Ig=La.default.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",Pa);return(0,Ma.jsx)("div",{ref:o,className:(0,Aa.default)(n.root,t),children:e})}),Wn=Ig;var qo=k(require("classnames")),_e=k(require("react"));var Or={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 Se=require("react/jsx-runtime"),so=(0,_e.createContext)(Or),Rg=({fixed:t,children:e,...o})=>{let n=(0,_e.useContext)(so);return(0,Se.jsx)("div",{...o,className:(0,qo.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Pg=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,_e.useContext)(so);return(0,Se.jsxs)("div",{className:(0,qo.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,Se.jsx)("ul",{className:r.dropdownList,children:s})]})},Ag=({index:t,label:e,onClick:o})=>{let n=(0,_e.useContext)(so);return(0,Se.jsx)("li",{className:n.dropdownItem,children:(0,Se.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Lg=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,_e.useContext)(so);return(0,Se.jsx)("button",{type:"button",className:(0,qo.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Dr=({labels:t})=>{let e=(0,_e.useContext)(so);return(0,Se.jsx)("div",{className:e.labels,children:t.map(o=>(0,Se.jsx)("span",{className:e.label,children:o},o))})},ro=_e.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",Or),l=(0,_e.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,Se.jsx)(s,{...r,ref:i,className:(0,qo.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,Se.jsx)(so.Provider,{value:a,children:n})})});ro.Labels=Dr;ro.Actions=Rg;ro.ActionButton=Lg;ro.DropdownButton=Pg;ro.DropdownItem=Ag;var L=ro;var Oa=k(require("classnames"));var Na={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var Da=require("react/jsx-runtime"),Mg=({withDivider:t,children:e})=>{let o=y("SuggestionList",Na);return(0,Da.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Oa.default)(o.root,{[o.isWithDivider]:t}),children:e})},ue=Mg;var Ba=k(require("classnames"));var Ha={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var $n=require("react/jsx-runtime"),Ng=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",Ha);return(0,$n.jsx)("button",{type:"button",className:(0,Ba.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,$n.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,$n.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Mt=Ng;var Fa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,io=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Ka=/x-deepdesk-(([a-z0-9\-_])+-version)/,ke=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(ke||{}),mt=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(mt||{});var Te=require("react-dom");var Hp=require("react");var Ua=require("@reduxjs/toolkit"),za=require("react-redux");var Wo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Wo||{});var Og={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"},ja=(0,Ua.createSlice)({name:"settings",initialState:Og,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:$o}=ja.actions,Hr=t=>e=>e.settings[t],C=t=>(0,za.useSelector)(Hr(t)),Va=ja.reducer;var Yc=require("react"),ko=require("react-redux");var He=require("@reduxjs/toolkit"),Xa=require("diff"),Za=require("react-redux");function qa(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function ft(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)=>ft(r,e[i],o-1)):qa(t)&&qa(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>ft(t[i],e[i],o-1)):!1}function Dg(t){return Math.max(...t.map(e=>e.length))}function Hg(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 Wa(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Dg(n);s++){let r=Hg(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 Bg=2;function Br(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Wa(t,Bg);return o&&o.text!==e?o:t[0]}var Ie=require("@reduxjs/toolkit");var Fg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},w=Fg;var $a={current:null,isSupported:null},M=(0,Ie.createAction)("resetConversation"),Gn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Xn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},ao=t=>t.conversation.isSupported,Fr=(0,Ie.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Zn=(0,Ie.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Qn=(0,Ie.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Jn=(0,Ie.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Xn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Kr=(0,Ie.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})})}),Yn=(0,Ie.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Xn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Kg=[Zn.rejected,Qn.rejected,Jn.rejected,Yn.rejected].map(t=>t==null?void 0:t.toString()),Ug=(0,Ie.createSlice)({name:"conversation",initialState:$a,reducers:{},extraReducers:t=>{t.addCase(Fr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Zn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Qn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Kr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Jn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Yn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(M,()=>$a).addMatcher(e=>Kg.includes(e.type),(e,o)=>{var n;throw w.info("Conversation action rejected",o.type,((n=o.error)==null?void 0:n.message)||"No message"),new Error(o.error.message)})}}),Ga=Ug.reducer;var ht={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 ts(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 os=(0,He.createAction)("input/replaceText"),ns=(0,He.createAction)("input/keyDown"),Nt=(0,He.createAction)("input/sendMessage"),ss=(0,He.createAction)("input/sendEditSuggestionMessage"),rs=(0,He.createAction)("input/uiInputChange"),is=(0,He.createAction)("input/applyImageSuggestion"),Q=(0,He.createAction)("input/sendEvent");function es(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,d=o==="search"||o==="personal-collection-search",g=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(g=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(g=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:g,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:d?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var Qa=t=>(0,He.createSlice)({name:t,initialState:ht,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,{...ht,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=Br(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(ft(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&es(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:g,metaKey:u,altKey:m}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=e,{text:h}=o.payload,E=(0,Xa.diffChars)(f,h);f.length-h.length>1&&e.metrics.deletions.push(...E.filter(x=>x.removed).map(x=>x.value)),e.metrics.numCharsDeleted+=f.length-h.length;break}case"C":case"V":case"X":if(!g&&!u){e.metrics.numCharsTyped+=1;let f=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}break;case"Shift":break;default:if(!g&&!u&&!m){e.metrics.numCharsTyped+=1;let f=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=ht.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&es(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"&&es(e)},commitSuggestion(e){es(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=Br(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(M,o=>{o.tabCompletionSuggestion=ht.tabCompletionSuggestion,o.previousKeyDownEvent=ht.previousKeyDownEvent,o.textSuggestions=ht.textSuggestions,o.selectedSuggestionIndex=ht.selectedSuggestionIndex,o.metrics=ht.metrics})}}),Ur=Qa("input"),lo=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),zg=t=>t.input.selection,Ja=()=>(0,Za.useSelector)(zg),{userInput:Ya,changeSelection:zr,initialInput:el,mergeMetrics:tl,nextTextSuggestionIndex:ol,offeredTextSuggestion:nl,previousTextSuggestionIndex:sl,registerCut:rl,registerKeyDown:il,registerPaste:al,reset:ll,resetToCommitted:Go,platformInput:cl,setSelectedTextSuggestionIndex:yt,setTextSuggestions:Be,stageSuggestion:Re,commitSuggestion:$e,setMetrics:pl}=Ur.actions,ae=Qa("overlay");var co=require("react");var dl={root:"_root_1h19b_1",content:"_content_1h19b_24"};var jr=require("react/jsx-runtime"),jg=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,co.useRef)(null),l=(0,co.useRef)(null),c=y("Dialog",dl);return(0,co.useEffect)(()=>{var g,u;let p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),s())},d=m=>{let f=window.getSelection();f!=null&&f.toString()||m.target===a.current&&t&&n()};return(g=a.current)==null||g.addEventListener("click",d),(u=a.current)==null||u.addEventListener("keyup",p),()=>{var m,f;(m=a.current)==null||m.removeEventListener("click",d),(f=a.current)==null||f.removeEventListener("keyup",p)}},[a,l,s,n]),(0,co.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,jr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,jr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},po=jg;var _i=require("react"),Bs=require("react-redux");var Vr={};$(Vr,{enUS:()=>Vg,nlNL:()=>qg});var Vg={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?"}]},qg={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 ul={root:"_root_jcr8j_1",content:"_content_jcr8j_3",title:"_title_jcr8j_7",actions:"_actions_jcr8j_15",pagination:"_pagination_jcr8j_19",primaryButton:"_primaryButton_jcr8j_50",primaryButtons:"_primaryButtons_jcr8j_54"};var _s=require("react");var qr=function(t,e){return qr=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])},qr(t,e)};function Xo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");qr(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var ge=function(){return ge=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},ge.apply(this,arguments)};function gl(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 as(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 ls;(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"})(ls||(ls={}));var cs=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Pe;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(Pe||(Pe={}));var ps;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(ps||(ps={}));function Wr(t){return t.type===Pe.literal}function ml(t){return t.type===Pe.argument}function ds(t){return t.type===Pe.number}function us(t){return t.type===Pe.date}function gs(t){return t.type===Pe.time}function ms(t){return t.type===Pe.select}function fs(t){return t.type===Pe.plural}function fl(t){return t.type===Pe.pound}function hs(t){return t.type===Pe.tag}function ys(t){return!!(t&&typeof t=="object"&&t.type===ps.number)}function Zo(t){return!!(t&&typeof t=="object"&&t.type===ps.dateTime)}function $r(t){t.forEach(function(e){if(delete e.location,ms(e)||fs(e))for(var o in e.options)delete e.options[o].location,$r(e.options[o].value);else ds(e)&&ys(e.style)||(us(e)||gs(e))&&Zo(e.style)?delete e.style.location:hs(e)&&$r(e.children)})}function hl(t,e){e===void 0&&(e={}),e=ge({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new cs(t,e).parse();if(o.err){var n=SyntaxError(ls[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||$r(o.val),o.val}function vs(t,e){var o=e&&e.cache?e.cache:Qg,n=e&&e.serializer?e.serializer:Zg,s=e&&e.strategy?e.strategy:$g;return s(t,{cache:o,serializer:n})}function Wg(t){return t==null||typeof t=="number"||typeof t=="boolean"}function yl(t,e,o,n){var s=Wg(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function vl(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 Gr(t,e,o,n,s){return o.bind(e,t,n,s)}function $g(t,e){var o=t.length===1?yl:vl;return Gr(t,this,o,e.cache.create(),e.serializer)}function Gg(t,e){return Gr(t,this,vl,e.cache.create(),e.serializer)}function Xg(t,e){return Gr(t,this,yl,e.cache.create(),e.serializer)}var Zg=function(){return JSON.stringify(arguments)};function Xr(){this.cache=Object.create(null)}Xr.prototype.get=function(t){return this.cache[t]};Xr.prototype.set=function(t,e){this.cache[t]=e};var Qg={create:function(){return new Xr}},Ss={variadic:Gg,monadic:Xg};var Ot;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Ot||(Ot={}));var Qo=function(t){Xo(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 Zr=function(t){Xo(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('", "'),'"'),Ot.INVALID_VALUE,r)||this}return e}(Qo);var Sl=function(t){Xo(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Ot.INVALID_VALUE,s)||this}return e}(Qo);var _l=function(t){Xo(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,'"'),Ot.MISSING_VALUE,n)||this}return e}(Qo);var J;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(J||(J={}));function Jg(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==J.literal||o.type!==J.literal?e.push(o):n.value+=o.value,e},[])}function Yg(t){return typeof t=="function"}function Jo(t,e,o,n,s,r,i){if(t.length===1&&Wr(t[0]))return[{type:J.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Wr(p)){a.push({type:J.literal,value:p.value});continue}if(fl(p)){typeof r=="number"&&a.push({type:J.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new _l(d,i);var g=s[d];if(ml(p)){(!g||typeof g=="string"||typeof g=="number")&&(g=typeof g=="string"||typeof g=="number"?String(g):""),a.push({type:typeof g=="string"?J.literal:J.object,value:g});continue}if(us(p)){var u=typeof p.style=="string"?n.date[p.style]:Zo(p.style)?p.style.parsedOptions:void 0;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(gs(p)){var u=typeof p.style=="string"?n.time[p.style]:Zo(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(ds(p)){var u=typeof p.style=="string"?n.number[p.style]:ys(p.style)?p.style.parsedOptions:void 0;u&&u.scale&&(g=g*(u.scale||1)),a.push({type:J.literal,value:o.getNumberFormat(e,u).format(g)});continue}if(hs(p)){var m=p.children,f=p.value,h=s[f];if(!Yg(h))throw new Sl(f,"function",i);var E=Jo(m,e,o,n,s,r),x=h(E.map(function(v){return v.value}));Array.isArray(x)||(x=[x]),a.push.apply(a,x.map(function(v){return{type:typeof v=="string"?J.literal:J.object,value:v}}))}if(ms(p)){var _=p.options[g]||p.options.other;if(!_)throw new Zr(p.value,g,Object.keys(p.options),i);a.push.apply(a,Jo(_.value,e,o,n,s));continue}if(fs(p)){var _=p.options["=".concat(g)];if(!_){if(!Intl.PluralRules)throw new Qo(`Intl.PluralRules is not available in this environment.
1
+ "use strict";var mg=Object.create;var Fn=Object.defineProperty;var fg=Object.getOwnPropertyDescriptor;var hg=Object.getOwnPropertyNames;var yg=Object.getPrototypeOf,vg=Object.prototype.hasOwnProperty;var $=(t,e)=>{for(var o in e)Fn(t,o,{get:e[o],enumerable:!0})},Sa=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of hg(e))!vg.call(t,s)&&s!==o&&Fn(t,s,{get:()=>e[s],enumerable:!(n=fg(e,s))||n.enumerable});return t};var k=(t,e,o)=>(o=t!=null?mg(yg(t)):{},Sa(e||!t||!t.__esModule?Fn(o,"default",{value:t,enumerable:!0}):o,t)),Sg=t=>Sa(Fn({},"__esModule",{value:!0}),t);var Zh={};$(Zh,{Card:()=>D,ContentEditableInput:()=>Yt,DeepdeskAPI:()=>gt,DeepdeskSDK:()=>On,HTTPClient:()=>De,InputMediator:()=>Xe,InputType:()=>mt,KeyboardHint:()=>jn,Label:()=>Vn,Locale:()=>Wo,Section:()=>We,SectionList:()=>qn,Sources:()=>ke,Suggestion:()=>L,SuggestionList:()=>ue,TextAreaInput:()=>Ze,ToggleButton:()=>Mt,attachFile:()=>ng,authenticateWithKey:()=>tg,createFullRange:()=>Do,createOverlayContainer:()=>Ht,createRangeFromOffsets:()=>At,escapeHTML:()=>yo,fetchPlatformConfig:()=>og,formatTextMarkup:()=>eg,getRangeOffsets:()=>An,getRangeText:()=>Ln,insertCKEditor:()=>Yu,isHTML:()=>Bt,isSupportedInputElement:()=>Ar,updateContentEditable:()=>Qu,updateTextArea:()=>Zu,useStyles:()=>y,waitForElementVisibilityChange:()=>Lr});module.exports=Sg(Zh);var zn=k(require("classnames")),de=k(require("react"));var Kn=k(require("react")),_a=k(require("classnames")),Uo=Kn.default.createContext({});function y(t,e){let{debug:o,...n}=(0,Kn.useContext)(Uo),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,_a.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var zo=require("react/jsx-runtime"),xa=({className:t})=>(0,zo.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,zo.jsx)("line",{x1:"1",y1:"11",x2:"11",y2:"1",stroke:"black",strokeWidth:"2"}),(0,zo.jsx)("line",{x1:"1",y1:"1",x2:"11",y2:"11",stroke:"black",strokeWidth:"2"})]});var ba={root:"_root_vr71j_1"};var Lt=require("react/jsx-runtime"),Un=()=>(0,Lt.jsxs)("svg",{className:ba.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Lt.jsx)("defs",{children:(0,Lt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Lt.jsx)("title",{children:"Failed loading image"}),(0,Lt.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 Nr={root:"_root_15d2a_1",imageWrapper:"_imageWrapper_15d2a_7",image:"_image_15d2a_7",content:"_content_15d2a_24",title:"_title_15d2a_35",contentIsCropped:"_contentIsCropped_15d2a_45",lineClamp:"_lineClamp_15d2a_51",closeIcon:"_closeIcon_15d2a_58"};var qe=require("react/jsx-runtime"),jo=(0,de.createContext)(Nr),_g=({title:t,src:e})=>{let o=(0,de.useContext)(jo),[n,s]=(0,de.useState)(!1);return(0,de.useEffect)(()=>{s(!1)},[e]),(0,qe.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,qe.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,qe.jsx)(Un,{})})},xg=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,de.useContext)(jo);return(0,qe.jsx)("div",{className:(0,zn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},bg=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,de.useContext)(jo);return de.default.createElement(t,{className:(0,zn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Cg=({className:t,title:e,...o})=>{let n=(0,de.useContext)(jo);return(0,qe.jsx)("div",{className:(0,zn.default)(n.closeIcon,t),title:e,role:"button","aria-label":e,...o,children:(0,qe.jsx)(xa,{})})},Vo=({children:t})=>{let e=y("Card",Nr);return(0,qe.jsx)("div",{className:e.root,children:(0,qe.jsx)(jo.Provider,{value:e,children:t})})};Vo.Image=_g;Vo.Content=xg;Vo.Title=bg;Vo.CloseIcon=Cg;var D=Vo;var wa=k(require("classnames"));var Ca={root:"_root_cq1yq_1"};var Ta=require("react/jsx-runtime");var wg={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Tg=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",Ca);return(0,Ta.jsx)("span",{"data-key":wg[e],className:(0,wa.default)(t,n.root),...o})},jn=Tg;var ka=k(require("classnames"));var Ea={root:"_root_4a08n_1"};var Ia=require("react/jsx-runtime"),Eg=({className:t,children:e,...o})=>{let n=y("Label",Ea);return(0,Ia.jsx)("span",{...o,className:(0,ka.default)(t,n.root),children:e})},Vn=Eg;var Ra={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var no=require("react/jsx-runtime"),kg=({title:t,children:e,type:o,...n})=>{let s=y("Section",Ra);return(0,no.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,no.jsx)("div",{className:s.subTitleContainer,children:(0,no.jsx)("span",{className:s.subtitle,children:t})}),(0,no.jsx)("div",{className:s.suggestions,children:e})]})},We=kg;var Aa=k(require("classnames")),La=k(require("react"));var Pa={root:"_root_19wxp_1"};var Ma=require("react/jsx-runtime"),Ig=La.default.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",Pa);return(0,Ma.jsx)("div",{ref:o,className:(0,Aa.default)(n.root,t),children:e})}),qn=Ig;var qo=k(require("classnames")),_e=k(require("react"));var Or={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 Se=require("react/jsx-runtime"),so=(0,_e.createContext)(Or),Rg=({fixed:t,children:e,...o})=>{let n=(0,_e.useContext)(so);return(0,Se.jsx)("div",{...o,className:(0,qo.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Pg=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,_e.useContext)(so);return(0,Se.jsxs)("div",{className:(0,qo.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,Se.jsx)("ul",{className:r.dropdownList,children:s})]})},Ag=({index:t,label:e,onClick:o})=>{let n=(0,_e.useContext)(so);return(0,Se.jsx)("li",{className:n.dropdownItem,children:(0,Se.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Lg=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,_e.useContext)(so);return(0,Se.jsx)("button",{type:"button",className:(0,qo.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Dr=({labels:t})=>{let e=(0,_e.useContext)(so);return(0,Se.jsx)("div",{className:e.labels,children:t.map(o=>(0,Se.jsx)("span",{className:e.label,children:o},o))})},ro=_e.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",Or),l=(0,_e.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,Se.jsx)(s,{...r,ref:i,className:(0,qo.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,Se.jsx)(so.Provider,{value:a,children:n})})});ro.Labels=Dr;ro.Actions=Rg;ro.ActionButton=Lg;ro.DropdownButton=Pg;ro.DropdownItem=Ag;var L=ro;var Oa=k(require("classnames"));var Na={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var Da=require("react/jsx-runtime"),Mg=({withDivider:t,children:e})=>{let o=y("SuggestionList",Na);return(0,Da.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Oa.default)(o.root,{[o.isWithDivider]:t}),children:e})},ue=Mg;var Ba=k(require("classnames"));var Ha={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Wn=require("react/jsx-runtime"),Ng=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",Ha);return(0,Wn.jsx)("button",{type:"button",className:(0,Ba.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,Wn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Wn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Mt=Ng;var Fa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,io=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Ka=/x-deepdesk-(([a-z0-9\-_])+-version)/,ke=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(ke||{}),mt=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(mt||{});var Te=require("react-dom");var Hp=require("react");var Ua=require("@reduxjs/toolkit"),za=require("react-redux");var Wo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Wo||{});var Og={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"},ja=(0,Ua.createSlice)({name:"settings",initialState:Og,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:$n}=ja.actions,Hr=t=>e=>e.settings[t],C=t=>(0,za.useSelector)(Hr(t)),Va=ja.reducer;var Yc=require("react"),ko=require("react-redux");var He=require("@reduxjs/toolkit"),Xa=require("diff"),Za=require("react-redux");function qa(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function ft(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)=>ft(r,e[i],o-1)):qa(t)&&qa(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>ft(t[i],e[i],o-1)):!1}function Dg(t){return Math.max(...t.map(e=>e.length))}function Hg(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 Wa(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Dg(n);s++){let r=Hg(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 Bg=2;function Br(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Wa(t,Bg);return o&&o.text!==e?o:t[0]}var Ie=require("@reduxjs/toolkit");var Fg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},w=Fg;var $a={current:null,isSupported:null},M=(0,Ie.createAction)("resetConversation"),Gn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Xn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},ao=t=>t.conversation.isSupported,Fr=(0,Ie.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Zn=(0,Ie.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Qn=(0,Ie.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Jn=(0,Ie.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Xn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Kr=(0,Ie.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})})}),Yn=(0,Ie.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Xn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Kg=[Zn.rejected,Qn.rejected,Jn.rejected,Yn.rejected].map(t=>t==null?void 0:t.toString()),Ug=(0,Ie.createSlice)({name:"conversation",initialState:$a,reducers:{},extraReducers:t=>{t.addCase(Fr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Zn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Qn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Kr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Jn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Yn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(M,()=>$a).addMatcher(e=>Kg.includes(e.type),(e,o)=>{var n;throw w.info("Conversation action rejected",o.type,((n=o.error)==null?void 0:n.message)||"No message"),new Error(o.error.message)})}}),Ga=Ug.reducer;var ht={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 ts(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 os=(0,He.createAction)("input/replaceText"),ns=(0,He.createAction)("input/keyDown"),Nt=(0,He.createAction)("input/sendMessage"),ss=(0,He.createAction)("input/sendEditSuggestionMessage"),rs=(0,He.createAction)("input/uiInputChange"),is=(0,He.createAction)("input/applyImageSuggestion"),Q=(0,He.createAction)("input/sendEvent");function es(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,d=o==="search"||o==="personal-collection-search",g=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(g=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(g=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:g,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:d?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var Qa=t=>(0,He.createSlice)({name:t,initialState:ht,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,{...ht,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=Br(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(ft(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&es(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:g,metaKey:u,altKey:m}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=e,{text:h}=o.payload,E=(0,Xa.diffChars)(f,h);f.length-h.length>1&&e.metrics.deletions.push(...E.filter(x=>x.removed).map(x=>x.value)),e.metrics.numCharsDeleted+=f.length-h.length;break}case"C":case"V":case"X":if(!g&&!u){e.metrics.numCharsTyped+=1;let f=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}break;case"Shift":break;default:if(!g&&!u&&!m){e.metrics.numCharsTyped+=1;let f=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=ht.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&es(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"&&es(e)},commitSuggestion(e){es(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=Br(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(M,o=>{o.tabCompletionSuggestion=ht.tabCompletionSuggestion,o.previousKeyDownEvent=ht.previousKeyDownEvent,o.textSuggestions=ht.textSuggestions,o.selectedSuggestionIndex=ht.selectedSuggestionIndex,o.metrics=ht.metrics})}}),Ur=Qa("input"),lo=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),zg=t=>t.input.selection,Ja=()=>(0,Za.useSelector)(zg),{userInput:Ya,changeSelection:zr,initialInput:el,mergeMetrics:tl,nextTextSuggestionIndex:ol,offeredTextSuggestion:nl,previousTextSuggestionIndex:sl,registerCut:rl,registerKeyDown:il,registerPaste:al,reset:ll,resetToCommitted:$o,platformInput:cl,setSelectedTextSuggestionIndex:yt,setTextSuggestions:Be,stageSuggestion:Re,commitSuggestion:$e,setMetrics:pl}=Ur.actions,ae=Qa("overlay");var co=require("react");var dl={root:"_root_1h19b_1",content:"_content_1h19b_24"};var jr=require("react/jsx-runtime"),jg=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,co.useRef)(null),l=(0,co.useRef)(null),c=y("Dialog",dl);return(0,co.useEffect)(()=>{var g,u;let p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),s())},d=m=>{let f=window.getSelection();f!=null&&f.toString()||m.target===a.current&&t&&n()};return(g=a.current)==null||g.addEventListener("click",d),(u=a.current)==null||u.addEventListener("keyup",p),()=>{var m,f;(m=a.current)==null||m.removeEventListener("click",d),(f=a.current)==null||f.removeEventListener("keyup",p)}},[a,l,s,n]),(0,co.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,jr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,jr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},po=jg;var _i=require("react"),Bs=require("react-redux");var Vr={};$(Vr,{enUS:()=>Vg,nlNL:()=>qg});var Vg={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?"}]},qg={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 ul={root:"_root_jcr8j_1",content:"_content_jcr8j_3",title:"_title_jcr8j_7",actions:"_actions_jcr8j_15",pagination:"_pagination_jcr8j_19",primaryButton:"_primaryButton_jcr8j_50",primaryButtons:"_primaryButtons_jcr8j_54"};var _s=require("react");var qr=function(t,e){return qr=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])},qr(t,e)};function Go(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");qr(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var ge=function(){return ge=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},ge.apply(this,arguments)};function gl(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 as(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 ls;(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"})(ls||(ls={}));var cs=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Pe;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(Pe||(Pe={}));var ps;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(ps||(ps={}));function Wr(t){return t.type===Pe.literal}function ml(t){return t.type===Pe.argument}function ds(t){return t.type===Pe.number}function us(t){return t.type===Pe.date}function gs(t){return t.type===Pe.time}function ms(t){return t.type===Pe.select}function fs(t){return t.type===Pe.plural}function fl(t){return t.type===Pe.pound}function hs(t){return t.type===Pe.tag}function ys(t){return!!(t&&typeof t=="object"&&t.type===ps.number)}function Xo(t){return!!(t&&typeof t=="object"&&t.type===ps.dateTime)}function $r(t){t.forEach(function(e){if(delete e.location,ms(e)||fs(e))for(var o in e.options)delete e.options[o].location,$r(e.options[o].value);else ds(e)&&ys(e.style)||(us(e)||gs(e))&&Xo(e.style)?delete e.style.location:hs(e)&&$r(e.children)})}function hl(t,e){e===void 0&&(e={}),e=ge({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new cs(t,e).parse();if(o.err){var n=SyntaxError(ls[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||$r(o.val),o.val}function vs(t,e){var o=e&&e.cache?e.cache:Qg,n=e&&e.serializer?e.serializer:Zg,s=e&&e.strategy?e.strategy:$g;return s(t,{cache:o,serializer:n})}function Wg(t){return t==null||typeof t=="number"||typeof t=="boolean"}function yl(t,e,o,n){var s=Wg(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function vl(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 Gr(t,e,o,n,s){return o.bind(e,t,n,s)}function $g(t,e){var o=t.length===1?yl:vl;return Gr(t,this,o,e.cache.create(),e.serializer)}function Gg(t,e){return Gr(t,this,vl,e.cache.create(),e.serializer)}function Xg(t,e){return Gr(t,this,yl,e.cache.create(),e.serializer)}var Zg=function(){return JSON.stringify(arguments)};function Xr(){this.cache=Object.create(null)}Xr.prototype.get=function(t){return this.cache[t]};Xr.prototype.set=function(t,e){this.cache[t]=e};var Qg={create:function(){return new Xr}},Ss={variadic:Gg,monadic:Xg};var Ot;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Ot||(Ot={}));var Zo=function(t){Go(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 Zr=function(t){Go(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('", "'),'"'),Ot.INVALID_VALUE,r)||this}return e}(Zo);var Sl=function(t){Go(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Ot.INVALID_VALUE,s)||this}return e}(Zo);var _l=function(t){Go(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,'"'),Ot.MISSING_VALUE,n)||this}return e}(Zo);var J;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(J||(J={}));function Jg(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==J.literal||o.type!==J.literal?e.push(o):n.value+=o.value,e},[])}function Yg(t){return typeof t=="function"}function Qo(t,e,o,n,s,r,i){if(t.length===1&&Wr(t[0]))return[{type:J.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Wr(p)){a.push({type:J.literal,value:p.value});continue}if(fl(p)){typeof r=="number"&&a.push({type:J.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new _l(d,i);var g=s[d];if(ml(p)){(!g||typeof g=="string"||typeof g=="number")&&(g=typeof g=="string"||typeof g=="number"?String(g):""),a.push({type:typeof g=="string"?J.literal:J.object,value:g});continue}if(us(p)){var u=typeof p.style=="string"?n.date[p.style]:Xo(p.style)?p.style.parsedOptions:void 0;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(gs(p)){var u=typeof p.style=="string"?n.time[p.style]:Xo(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(ds(p)){var u=typeof p.style=="string"?n.number[p.style]:ys(p.style)?p.style.parsedOptions:void 0;u&&u.scale&&(g=g*(u.scale||1)),a.push({type:J.literal,value:o.getNumberFormat(e,u).format(g)});continue}if(hs(p)){var m=p.children,f=p.value,h=s[f];if(!Yg(h))throw new Sl(f,"function",i);var E=Qo(m,e,o,n,s,r),x=h(E.map(function(v){return v.value}));Array.isArray(x)||(x=[x]),a.push.apply(a,x.map(function(v){return{type:typeof v=="string"?J.literal:J.object,value:v}}))}if(ms(p)){var _=p.options[g]||p.options.other;if(!_)throw new Zr(p.value,g,Object.keys(p.options),i);a.push.apply(a,Qo(_.value,e,o,n,s));continue}if(fs(p)){var _=p.options["=".concat(g)];if(!_){if(!Intl.PluralRules)throw new Zo(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,Ot.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(g-(p.offset||0));_=p.options[b]||p.options.other}if(!_)throw new Zr(p.value,g,Object.keys(p.options),i);a.push.apply(a,Jo(_.value,e,o,n,s,g-(p.offset||0)));continue}}return Jg(a)}function em(t,e){return e?ge(ge(ge({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=ge(ge({},t[n]),e[n]||{}),o},{})):t}function tm(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=em(t[n],e[n]),o},ge({},t)):t}function Qr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function om(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:vs(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,as([void 0],o,!1)))},{cache:Qr(t.number),strategy:Ss.variadic}),getDateTimeFormat:vs(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,as([void 0],o,!1)))},{cache:Qr(t.dateTime),strategy:Ss.variadic}),getPluralRules:vs(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,as([void 0],o,!1)))},{cache:Qr(t.pluralRules),strategy:Ss.variadic})}}var xl=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var d=p.reduce(function(g,u){return!g.length||u.type!==J.literal||typeof g[g.length-1]!="string"?g.push(u.value):g[g.length-1]+=u.value,g},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Jo(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=gl(i,["formatters"]);this.ast=t.__parse(e,ge(ge({},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=tm(t.formats,n),this.formatters=s&&s.formatters||om(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=hl,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 nm(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var sm="dummy",Jr=(0,_s.createContext)(null);function T(t){let e=(0,_s.useContext)(Jr);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=nm(o,n);return r?new xl(r).format(s):(e!==sm&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var Yo=require("react/jsx-runtime"),xs=()=>(0,Yo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Yo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Yo.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 en=require("react/jsx-runtime"),bl=()=>(0,en.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,en.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,en.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 xe=require("react"),jl=require("react-redux"),li=require("interweave"),ci=k(require("classnames"));var Yr={root:"_root_smoda_1",agentText:"_agentText_smoda_3",textInput:"_textInput_smoda_8",textInputWrapper:"_textInputWrapper_smoda_27",alert:"_alert_smoda_31",alertText:"_alertText_smoda_50",warning:"_warning_smoda_60",success:"_success_smoda_69"};var wl=require("interweave"),Tl=k(require("classnames"));var uo=require("react");function Cl(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function bs(t){let e=(0,uo.useRef)(null),[o,n]=(0,uo.useState)(!1);return(0,uo.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Cl((p,d)=>{let g=e.current;if(!g)return;let u=p/r,m=d/r,f=g.getBoundingClientRect(),h=u>f.x&&u<f.x+f.width&&m>f.y&&m<f.y+f.height;h&&!s?(s=!0,n(!0)):!h&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=Cl(()=>{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 Ge={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 ei=require("react/jsx-runtime"),rm=({inputElement:t,children:e})=>{let o=y("TabCompletion",Ge),[n,s]=bs(t);return(0,ei.jsx)("mark",{ref:n,className:(0,Tl.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},go=class extends wl.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,ei.jsx)(rm,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var mo=require("react");function Cs(t){return t.contentEditable==="true"}function im(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 El(t){let{selectionStart:e,selectionEnd:o}=Cs(t)?im(t):t;return[e,o]}function ws(t){let[,e]=(0,mo.useState)(),o=(0,mo.useRef)(null);return o.current=El(t),(0,mo.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=El(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 Ts(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(io);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 kl=require("react");function fo(t){(0,kl.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Dt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Il,Fe=new Map,am=["bottom","height","left","right","top","width"],lm=(t={},e={})=>am.some(o=>t[o]!==e[o]);function Rl(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,...Rl(e)]:[]}function Pl(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var Es=!1,Al=()=>{Es=!0;let t=[];if(Fe.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Fe.delete(o);return}let n=o.getBoundingClientRect();lm(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(Pl,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),Fe.size===0){Es=!1;return}Il=window.requestAnimationFrame(Al)};function ti(t,e){let o=Rl(t),n=[],s=o.map((r,i)=>ti(r,a=>{n[i]=a;let l=Fe.get(t);if(!l)return;let c=n.reduce(Pl,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Fe.has(t)){let i=Fe.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Fe.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!Es&&Al()},unobserve(){s.forEach(i=>i.unobserve());let r=Fe.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Fe.delete(t),Fe.size||(cancelAnimationFrame(Il),Es=!1)}}}}var Ll,Ke=new Map,Ml=()=>{Ke.forEach((t,e)=>{if(!e.isConnected){Ke.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)))}),Ke.size!==0&&(Ll=window.requestAnimationFrame(Ml))};function Nl(t,e){return{observe(){let o=Ke.size===0;Ke.has(t)?Ke.get(t).callbacks.push(e):Ke.set(t,{visible:void 0,callbacks:[e]}),o&&Ml()},unobserve(){let o=Ke.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ke.delete(t),Ke.size||cancelAnimationFrame(Ll)}}}}var oi=["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 ni(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function ho(t){return parseFloat(t)}function ks(t){return Math.round(t*1e6)}function Ol(t){return t/1e6}function si(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=ho(t.width),r=ho(t.borderLeftWidth),i=ho(t.borderRightWidth),a=ho(t.paddingRight),l=Ol(ks(s)-ks(r)-ks(i)),c=Ol(ks(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Ht(t,e={}){var p;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Dt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};ni(n,o,oi),si(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=Nl(t,()=>{ni(n,o,oi),si(n,t,o),r(),setTimeout(r,0)}),a,l=!0,c=ti(t,d=>{if(d===null){e.onRemove&&e.onRemove(),o.remove();return}if(!l&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(ni(n,o,oi),si(n,t,o),r(),o.style.top=`${d.top}px`,o.style.left=`${d.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let g=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),m=ho(u.borderTopWidth),f=ho(u.borderBottomWidth),h=g.top+m-d.top,E=d.top+d.height+-(g.top+g.height-f);o.style.clipPath=`inset(${h}px 0px ${E}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(p=t.parentElement)==null||p.appendChild(o),c.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),c.unobserve(),i.unobserve()}]}var ri={};$(ri,{enUS:()=>cm,nlNL:()=>pm});var cm={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"}]},pm={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 tn=require("react/jsx-runtime"),Dl=()=>(0,tn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,tn.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,tn.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 ii=require("react/jsx-runtime"),Hl=()=>(0,ii.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,ii.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var Bl=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Bl||{}),Xe=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();ft(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(Bl).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",o=>this.handlePaste(o)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var Ze=class extends Xe{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 dm=/[.*+?^${}()|[\]\\]/g,um=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function gm(t){return t.replace(dm,"\\$&")}function mm(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function fm(t){return t.search(um)}function Fl(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${gm(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function Kl(t){return t.replace(io,'<mark data-type="placeholder">$1</mark>')}function yo(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function hm(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 ai(t,e,o={}){if(e){let n=mm(e.toLowerCase(),t.toLowerCase()),s=yo(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=fm(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Fa).length>3||e.length>30?hm(e.trim(),n):0;return`${`${i>0?"\u2026":""}${yo(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var ym=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function Bt(t){return ym.test(t)}function Ul(t){if(Bt(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}function zl(t){let e=document.createElement("template");return e.innerHTML=t,e.content.textContent??""}var Y=require("react/jsx-runtime"),vm=({value:t,onUse:e,...o})=>{var d;let n=T(ri),s=(0,jl.useDispatch)(),r=Bt(t),i=y("EditSuggestionTextInput",Yr),[a,l]=(0,xe.useState)(null),c=(0,xe.useRef)(null),p=((d=t.match(io))==null?void 0:d.length)||0;return(0,xe.useEffect)(()=>{let g;return c.current&&(l(c.current),g=new Ze(c.current),g.on("change",({plainText:u})=>{s(ae.actions.userInput({text:u,selection:g.getSelection()}))}),g.on("keydown",u=>{s(ae.actions.registerKeyDown(ts(u))),u.code==="Enter"&&u.shiftKey&&e(g.getText())}),g.on("paste",({pastedText:u,selectionText:m})=>{s(ae.actions.registerPaste({text:u,selectionText:m}))}),g.on("cut",({selectionText:u})=>{s(ae.actions.registerCut(u))})),()=>{s(ae.actions.reset()),g.dispose(),g.deactivate()}},[c]),(0,xe.useEffect)(()=>{t&&c.current&&(c.current.value=t)},[t,c]),(0,xe.useEffect)(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let g=c.current.value.length;c.current.setSelectionRange(g,g),c.current.focus()},0)},[c]),r?(0,Y.jsx)("div",{className:i.textInputWrapper,children:(0,Y.jsx)(li.Interweave,{className:i.textInput,tagName:"div",content:t})}):(0,Y.jsxs)("div",{className:i.textInputWrapper,children:[(0,Y.jsx)("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&(0,Y.jsx)(Sm,{inputElement:c.current,value:t}),(0,Y.jsxs)("div",{className:(0,ci.default)(i.alert,p===0?i.success:i.warning),children:[(0,Y.jsx)("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?(0,Y.jsx)(Dl,{}):(0,Y.jsx)(Hl,{})]})]})},Sm=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",Yr),n=(0,xe.useRef)(null),s=ws(t);return(0,xe.useEffect)(()=>{Ts(t,s)},[s,t]),(0,Y.jsx)(_m,{inputElement:t,children:(0,Y.jsxs)("div",{ref:n,className:(0,ci.default)(o.root,o.agentText),children:[(0,Y.jsx)(li.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new go("placeholders")],inputElement:t,boundaryRef:n}),(0,Y.jsx)("br",{})]})})},_m=({inputElement:t,children:e})=>{let o=(0,xe.useRef)(null);return(0,xe.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=Ht(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,Y.jsx)("div",{ref:o,children:e})},Vl=vm;var xo=require("react");var ql=require("react"),Is=k(require("classnames"));var le={root:"_root_1xflk_1",list:"_list_1xflk_2",listWrapper:"_listWrapper_1xflk_6",listHorizontal:"_listHorizontal_1xflk_10",page:"_page_1xflk_19",search:"_search_1xflk_25",pageNav:"_pageNav_1xflk_33",pageTitle:"_pageTitle_1xflk_41",pageBackButton:"_pageBackButton_1xflk_48",listHeader:"_listHeader_1xflk_62",listHeading:"_listHeading_1xflk_68",listMoreButton:"_listMoreButton_1xflk_76",listItem:"_listItem_1xflk_87",listItemContent:"_listItemContent_1xflk_96",listItemText:"_listItemText_1xflk_114",listItemDescription:"_listItemDescription_1xflk_122",listItemActions:"_listItemActions_1xflk_129",truncate:"_truncate_1xflk_140",lineClamp:"_lineClamp_1xflk_146",listItemTitle:"_listItemTitle_1xflk_153",listItemAction:"_listItemAction_1xflk_129",listItemPrimaryAction:"_listItemPrimaryAction_1xflk_174",listItemSelected:"_listItemSelected_1xflk_179",sources:"_sources_1xflk_183",sourcesTitle:"_sourcesTitle_1xflk_190",source:"_source_1xflk_183",icon:"_icon_1xflk_205",searchIcon:"_searchIcon_1xflk_222",searchInputWrapper:"_searchInputWrapper_1xflk_227",searchInput:"_searchInput_1xflk_227",select:"_select_1xflk_248",selectType:"_selectType_1xflk_265",selectWrapper:"_selectWrapper_1xflk_269",image:"_image_1xflk_299",imageSrc:"_imageSrc_1xflk_306",imageSrcHidden:"_imageSrcHidden_1xflk_317",imageSrcStatus:"_imageSrcStatus_1xflk_321",imageTitle:"_imageTitle_1xflk_331",actions:"_actions_1xflk_336",actionsWrapper:"_actionsWrapper_1xflk_340",actionsBar:"_actionsBar_1xflk_346",actionButton:"_actionButton_1xflk_355",hasShortKeys:"_hasShortKeys_1xflk_368",actionShortcut:"_actionShortcut_1xflk_377",actionShortcutFixKerning:"_actionShortcutFixKerning_1xflk_384"};var Qe={};$(Qe,{enUS:()=>xm,nlNL:()=>bm});var xm={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}]},bm={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}]};var vt=require("react/jsx-runtime"),Cm=({src:t,title:e})=>{let o=y("CommandPalette",le),[n,s]=(0,ql.useState)("loading"),r=T(Qe);return(0,vt.jsxs)("div",{className:o.image,children:[(0,vt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,Is.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,vt.jsx)("span",{className:(0,Is.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,vt.jsx)("span",{className:(0,Is.default)(o.imageSrc,o.imageSrcStatus),children:(0,vt.jsx)(zn,{})}),e&&(0,vt.jsx)("span",{className:o.imageTitle,children:e})]})},Wl=Cm;var $l=k(require("react")),Gl=k(require("classnames"));var Ft=require("react/jsx-runtime");function pi({children:t,heading:e,orientation:o,hasMore:n,onShowAll:s}){let r=T(Qe),i=y("CommandPalette",le);return $l.default.Children.count(t)===0?null:(0,Ft.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||n)&&(0,Ft.jsxs)("div",{className:i.listHeader,children:[e&&(0,Ft.jsx)("h4",{className:i.listHeading,children:e}),n&&s&&(0,Ft.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,Ft.jsx)("div",{className:(0,Gl.default)(i.listWrapper,o==="horizontal"&&i.listHorizontal),children:t})]})}var on=k(require("classnames")),oc=require("interweave");var Z=k(require("react")),Xl=k(require("classnames"));var di={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 Kt=require("react/jsx-runtime"),wm=0,Zl=Z.default.createContext(null),Tm=()=>{let t=(0,Z.useContext)(Zl);if(!t)throw new Error("Invalid DropdownContext");return t},Ql=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,Z.useMemo)(()=>++wm,[]),s=(0,Z.useRef)(null),r=(0,Z.useRef)(null),i=y("Dropdown",di),[a,l]=(0,Z.useState)(!1),[c,p]=(0,Z.useState)(o),d=u=>{u.preventDefault(),u.stopPropagation(),l(!a)},g=(0,Z.useCallback)(([u])=>{!u.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return(0,Z.useEffect)(()=>{let u=m=>{s.current&&!s.current.contains(m.target)&&l(!1)};return document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}},[]),(0,Z.useEffect)(()=>{if(!r.current&&!a)return()=>{};let u=new IntersectionObserver(g,{root:null,rootMargin:"0px",threshold:1});return r.current&&u.observe(r.current),()=>{r.current&&u.unobserve(r.current)}},[r,a]),(0,Kt.jsx)(Zl.Provider,{value:{setIsOpen:l},children:(0,Kt.jsxs)("div",{ref:s,className:i.root,children:[(0,Kt.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,Kt.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,Xl.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Em({as:t,children:e,onClick:o,...n}){let s=t||"button",r=y("Dropdown",di),{setIsOpen:i}=Tm(),a=l=>{i(!1),o(l),l.stopPropagation()};return(0,Kt.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Ql.Item=Em;var ui=Ql;var gi=require("react/jsx-runtime"),Jl=t=>(0,gi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,gi.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 Ut={};$(Ut,{enUS:()=>km,nlNL:()=>Im});var km={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"}]},Im={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 Rs=require("react/jsx-runtime"),Rm="%0d%0a%0d%0a%0d%0a",Pm=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Rm)}`},Am=({suggestion:t,onFeedback:e})=>{let o=T(Ut),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,Rs.jsx)(ui,{trigger:(0,Rs.jsx)(Jl,{"data-testid":"feedback-dropdown-trigger"}),children:(0,Rs.jsx)(ui.Item,{as:"a",href:Pm(n,t),onClick:e,children:o("giveFeedback")})})},Ps=Am;var As=k(require("react")),tc=require("react/jsx-runtime"),Yl=As.default.createContext(void 0);function St(){let t=As.default.useContext(Yl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var ec=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=As.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,tc.jsx)(Yl.Provider,{value:i,children:t})};var me=require("react/jsx-runtime");function mi({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,index:i,description:a,sources:l,styles:c,...p}){let{selected:d,setSelected:g,onChangeOpen:u}=St(),m=y("CommandPalette",le);function f(h){n(h),t&&u(!1)}return(0,me.jsxs)("div",{className:(0,on.default)(m.listItem,d===i&&m.listItemSelected),children:[(0,me.jsx)("button",{onMouseEnter:()=>g(i),type:"button",className:(0,on.default)("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:(0,me.jsxs)("div",{className:m.listItemContent,children:[typeof o=="string"?(0,me.jsx)("p",{className:(0,on.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,me.jsx)(oc.Interweave,{tagName:"p",allowList:[],content:Bt(a)?zl(a):a,className:(0,on.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate)})]})}),s&&d===i&&(0,me.jsx)("div",{className:m.listItemActions,children:(0,me.jsx)(Ps,{suggestion:String(o),onFeedback:s})}),l&&(0,me.jsxs)("div",{className:m.sources,children:[(0,me.jsx)("span",{className:m.sourcesTitle,children:"Sources"}),l.map(h=>h.url?(0,me.jsx)("a",{className:m.source,href:h.url,target:"_blank",title:h.url,rel:"noopener noreferrer",onClick:()=>r&&r(h),children:h.name},h.url):(0,me.jsx)("span",{className:m.source,children:h.name},h.name))]})]})}var zt=require("react/jsx-runtime");function fi({children:t,title:e,id:o,onDismiss:n}){let s=T(Qe),r=y("CommandPalette",le),{page:i}=St();return i!==o?null:(0,zt.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,zt.jsxs)("div",{className:r.pageNav,children:[(0,zt.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,zt.jsx)(xs,{}),s("back")]}),e&&(0,zt.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var _t=require("react");var Ms=require("@reduxjs/toolkit");var vo=require("@reduxjs/toolkit");function Lm(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function N(t){return Array.isArray(t)?t.map(N):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Lm(o)]:N(t[o])}),{}):t}function hi(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function G(t){return Array.isArray(t)?t.map(G):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[hi(o)]:G(t[o])}),{}):t}var Mm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},sn=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)||""}},nn=(0,vo.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?N(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),N(n))}),yi=(0,vo.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}),vi=(0,vo.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),nc=t=>t.info.agentInfo,sc=(0,vo.createSlice)({name:"info",initialState:Mm,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(nn.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(nn.rejected,e=>{e.fetchState="error"}).addCase(nn.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(yi.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(vi.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(M,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:rc}=sc.actions,ic=sc.reducer;var Ls={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},ac=t=>t.search.isOpen,lc=t=>t.search.page,cc=t=>t.search.list,pc=t=>t.search.aggregates;function dc(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var jt=(0,Ms.createAsyncThunk)("search/getAll",async(t,e)=>{var a;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(a=n.conversation.current)==null?void 0:a.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r,aggregates:i}=await o.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:sn(n)});return{results:r.map(l=>({...l,source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:i}}),uc=(0,Ms.createSlice)({name:"search",initialState:Ls,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=Ls.fetchState,t.list=Ls.list}},extraReducers:t=>{t.addCase(jt.pending,e=>{e.fetchState="loading"}).addCase(jt.rejected,(e,o)=>{e.fetchState="error",w.error(o.error)}).addCase(jt.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload.results,e.aggregates=o.payload.aggregates||{}}).addCase(M,()=>Ls)}}),{resetSearch:Ns,setIsOpen:te,setPage:oe}=uc.actions,gc=uc.reducer;var Nm=/(https?:\/\/[^\s]+)/,Os=t=>t.split(" ").find(e=>Nm.test(e));var Ds=()=>/Mac/i.test(navigator.platform);var Si=k(require("classnames"));var Hs=require("react/jsx-runtime"),Om=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",le);return(0,Hs.jsxs)("button",{type:"button",...n,onClick:t,className:(0,Si.default)(s.actionButton,n.className,{[s.hasShortKeys]:e&&e.length>0}),children:[o,e&&e.map(r=>(0,Hs.jsx)("span",{className:(0,Si.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},So=Om;var Je=require("react/jsx-runtime"),Dm=["url","URL"],Hm=["default","pinned-message","DEFAULT","STICKYMESSAGE"],Bm=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",le),a=T(Qe),{selected:l,setSelected:c}=St(),p=r[l],d=p&&p.type&&Dm.includes(p.type),g=p&&p.type&&Hm.includes(p.type)||p&&"secondaryAction"in p,u=d?Os(p.text):null,m=(0,_t.useRef)(null);function f(v){if(!m.current)return;let A=m.current.querySelectorAll(".command-palette-list-item"),O=0,K=0;v==="down"?(A.forEach((W,z)=>{z===l&&(O=z)}),K=O===A.length-1?0:O+1):v==="up"?(A.forEach((W,z)=>{z===l&&(O=z)}),K=O?O-1:A.length-1):c(0);let H=A[K];H&&typeof K=="number"&&(c(K),H.scrollIntoView&&H.scrollIntoView({behavior:"smooth",block:K?"center":"end"}))}function h(){if(!m.current)return;let v=m.current.querySelectorAll(".command-palette-list-item"),A=0;v.forEach((K,H)=>{H===l&&(A=H)});let O=v[A];O&&O.click()}let E=()=>{u&&window.open(u,"_blank")},x=()=>{p&&n(p,l)},_=()=>{!s||!g||s(p,l)},b=(0,_t.useCallback)(v=>{if(v.key==="Enter"&&v.altKey&&u){E();return}if(v.key==="Enter"&&v.shiftKey){_();return}if(v.key==="ArrowDown"){v.preventDefault(),v.stopPropagation(),f("down");return}if(v.key==="ArrowUp"){v.preventDefault(),v.stopPropagation(),f("up");return}v.key==="Enter"&&l!==-1&&(v.preventDefault(),v.stopPropagation(),h())},[l]);return(0,_t.useEffect)(()=>(window.addEventListener("keyup",b),()=>{window.removeEventListener("keyup",b)}),[b]),(0,Je.jsxs)("div",{className:i.actions,children:[(0,Je.jsx)("div",{className:i.actionsWrapper,ref:m,children:t}),(0,Je.jsxs)("div",{className:i.actionsBar,children:[u&&(0,Je.jsx)(So,{onClick:E,shortKeys:[Ds()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Je.jsxs)(_t.Fragment,{children:[s&&g&&(0,Je.jsx)(So,{onClick:_,shortKeys:[8679,8629],children:o}),(0,Je.jsx)(So,{onClick:x,shortKeys:[8629],children:e})]})]})]})},fc=Bm;var hc=require("react");var rn=require("react/jsx-runtime"),_o=()=>(0,rn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,rn.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,rn.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 Ae=require("react/jsx-runtime");function Fm({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",le);return(0,Ae.jsxs)("div",{className:l.search,children:[(0,Ae.jsx)("div",{className:l.searchIcon,children:(0,Ae.jsx)(_o,{})}),(0,Ae.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Ae.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,Ae.jsx)("div",{className:l.selectWrapper,children:(0,Ae.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,Ae.jsx)("option",{children:n}),s.map(c=>(0,Ae.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var yc=(0,hc.forwardRef)(Fm);var an=require("react/jsx-runtime");function Vt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:d,search:g}){let[u,m]=(0,xo.useState)(0),f=(0,xo.useRef)(null),h=()=>{s&&s(o),i(void 0),r(""),a(!1)},E=()=>{var x;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(x=f.current)==null||x.focus();return}if(g.length>0){r("");return}a(!1)};return(0,xo.useEffect)(()=>{m(0)},[g,n]),(0,an.jsx)(po,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:E,onClose:h,children:(0,an.jsxs)(ec,{selected:u,setSelected:m,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,an.jsx)(yc,{ref:f,onChange:r,onChangeType:i,placeholder:t,value:g,selectedType:l,types:c,typePlaceholder:e}),p]})})}Vt.Page=fi;Vt.List=pi;Vt.Image=Wl;Vt.ListItem=mi;Vt.ActionsBar=fc;Vt.Button=So;var P=Vt;var ee=require("react/jsx-runtime"),Km=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",ul),l=(0,Bs.useDispatch)(),c=T(Vr),p=(0,Bs.useSelector)(m=>m.overlayInput.text);(0,_i.useEffect)(()=>{t&&(l(ae.actions.reset()),l(ae.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(ae.actions.commitSuggestion()))},[t]);let d=m=>{m.preventDefault(),g(p)},g=m=>{l(ss(m)),e(m)},u=m=>f=>{p!==i?window.confirm(c("warning"))&&m(f):m(f)};return(0,_i.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,ee.jsxs)("div",{className:a.root,children:[(0,ee.jsxs)("div",{className:a.content,children:[t.title&&(0,ee.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,ee.jsx)(Dr,{labels:t.searchKeywords}),(0,ee.jsx)(Vl,{onUse:g,value:Ul(p)})]}),(0,ee.jsxs)("form",{className:a.actions,onSubmit:d,children:[(0,ee.jsxs)("div",{children:[(0,ee.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&u(r),children:(0,ee.jsx)(xs,{})}),(0,ee.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&u(s),children:(0,ee.jsx)(bl,{})})]}),(0,ee.jsxs)("div",{className:a.primaryButtons,children:[(0,ee.jsx)(P.Button,{onClick:u(o),shortKeys:["esc"],children:c("dismiss")}),(0,ee.jsx)(P.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},Fs=Km;var qt=require("@reduxjs/toolkit");var Um=["{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}"],zm=new RegExp(Um.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function vc(t,e){let o=t.split(zm),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let d=a.charAt(0),g=0;do c=d?e.indexOf(d,c+1):-1,g+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&g>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function Sc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var xc={suggestions:[],fetchState:"idle",isInitialRequest:null},_c={default:xc},Ks=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},bc=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")},xt=t=>t.textSuggestions,Cc=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},Us=(0,qt.createAction)("textSuggestions/refresh"),Le=(0,qt.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=lo(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,sn(n),t);if(t==="default"){let p=i?l.filter(Cc(a)):l;e.dispatch(Be(p.slice(0,r)))}return l}),ln=(0,qt.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,{...sn(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"?vc(p.text,t):p.text}))),l=Sc(l,r),e.dispatch(Be(l)),l}),wc=(0,qt.createSlice)({name:"textSuggestions",initialState:_c,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:o}=e.payload;t[o].fetchState="done",t[o].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}},setSuggestionState(t,e){return e.payload}},extraReducers:t=>{t.addCase(Le.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||xc;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Le.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Le.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(ln.pending,e=>{e.default.fetchState="loading"}).addCase(ln.rejected,e=>{e.default.fetchState="error"}).addCase(ln.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(M,()=>_c)}}),{setTextSuggestions:Tc,setSuggestionState:Ec}=wc.actions,kc=wc.reducer;var Rc=require("@reduxjs/toolkit");var Ic={contentType:null,suggestion:null},Pc=t=>t.activeSuggestion.suggestion,Ac=t=>t.activeSuggestion.contentType,Lc=(0,Rc.createSlice)({name:"activeSuggestion",initialState:Ic,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(M,()=>Ic)}}),{setActiveSuggestion:Ye,resetActiveSuggestion:xi}=Lc.actions,Mc=Lc.reducer;var bi={};$(bi,{enUS:()=>jm,nlNL:()=>Vm});var jm={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"}]},Vm={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 Nc=require("@reduxjs/toolkit"),qm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var zs=({ui:t})=>t.overlayCollapsed;var Oc=(0,Nc.createSlice)({name:"ui",initialState:qm,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:cn,setInputHasFocus:bo,setOverlayCollapsed:bt,setOpenOverlayWhenTyping:Dc,setOverlayCollapsedUserOverwrite:Hc}=Oc.actions,Bc=Oc.reducer;var pn=k(require("react")),Kc=require("react/jsx-runtime"),Fc=pn.default.createContext(null),Wt=({broadcastEvents:t,children:e})=>{let o=pn.default.useMemo(()=>t,[]);return(0,Kc.jsx)(Fc.Provider,{value:o,children:e})},be=()=>{let t=(0,pn.useContext)(Fc);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var Co=require("@reduxjs/toolkit");var Wm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ne=t=>t.auth.isLoggedIn,Uc=t=>t.auth.loginFetchState,zc=t=>t.auth.verifyFetchState,jc=t=>t.auth.showLoginOverlay,et=(0,Co.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Vc=(0,Co.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),dn=(0,Co.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),qc=(0,Co.createSlice)({name:"auth",initialState:Wm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(et.pending,e=>{e.loginFetchState="loading"}),t.addCase(et.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(et.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(dn.pending,e=>{e.verifyFetchState="loading"}),t.addCase(dn.rejected,e=>{e.verifyFetchState="error"}),t.addCase(dn.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:wo,setShowLoginOverlay:Wc}=qc.actions,$c=qc.reducer;var To=require("@reduxjs/toolkit");var Ci={cues:[],fetchState:"idle"},Gc=t=>{var e;return(e=t.rules)==null?void 0:e.cues},$m=(0,To.createAction)("rules/resetCues"),tt=(0,To.createAsyncThunk)("rules/evaluate",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=(r=e.getState().conversation.current)==null?void 0:r.id;if(!n)throw new Error("No current conversation to evaulate rules");return await o.evaluateRule(t.label,n,t.params)}),Xc=(0,To.createSlice)({name:"answer",initialState:Ci,reducers:{removeCue(t,e){t.cues=t.cues.filter(o=>o.id!==e.payload.id)}},extraReducers:t=>{t.addCase(tt.pending,e=>{e.fetchState="loading"}).addCase(tt.rejected,e=>{e.fetchState="error"}).addCase(tt.fulfilled,(e,o)=>{let n=Date.now(),s=o.payload.map(a=>({id:a.id||a.text,timestamp:n,...a})),r=s.map(a=>a.id),i=e.cues.filter(a=>!r.includes(a.id));e.fetchState="done",e.cues=[...s,...i]}).addCase(M,()=>Ci).addCase($m.toString(),()=>Ci)}}),{removeCue:Zc}=Xc.actions,Qc=Xc.reducer;var wi="SetActiveSuggestion",Ti="SetCues",Eo="ShowLoginOverlay",un="UserLoggedIn",Gm="UserLoggedOut",ot="ApplySuggestion",Ei="ApplyImageSuggestion",Xm="ShowCommandPalette",Zm=t=>({[wi]:e=>{t.dispatch(Ec(e.state)),t.dispatch(Ye({contentType:e.contentType,suggestion:e.suggestion}))},[Ti]:e=>{t.dispatch({type:tt.fulfilled,payload:e})},[Xm]:e=>{t.dispatch(te(e.isOpen)),e.page&&t.dispatch(oe(e.page))},[Eo]:e=>{t.dispatch(Wc(e))},[un]:()=>{t.dispatch(et())},[Gm]:()=>{t.dispatch(et())},[Ei]:e=>{t.dispatch(is({suggestion:e.suggestion}))},[ot]:e=>{t.dispatch(Re({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch($e())}}),Jc=Zm;var ki=require("react/jsx-runtime"),Qm=()=>{var m;let[t,e]=(0,Yc.useState)(!1),o=(0,ko.useSelector)(Pc),n=(0,ko.useSelector)(Ac),s=(0,ko.useSelector)(xt),r=(0,ko.useDispatch)(),i=be(),a=T(bi),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(xi()),r(bo(!0)),r(ae.actions.reset())},p=(f,h)=>{r(xi()),r(bo(!0)),i.send(ot,{text:f,suggestion:{...h,source:`${h.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(m=s[n])==null?void 0:m.suggestions.indexOf(o),g=d===0||d===null?void 0:()=>r(Ye({contentType:n,suggestion:s[n].suggestions[d-1]})),u=d===s[n].suggestions.length-1||d===null?void 0:()=>r(Ye({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,ki.jsx)(po,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,ki.jsx)(Fs,{onTouched:e,onDismiss:c,onUse:f=>p(f,o),suggestion:o,onNext:u,onPrevious:g})})},ep=Qm;var Ri=require("react-redux");var js=k(require("classnames")),Me=require("react"),Vs=require("react-redux");var op=k(require("classnames"));var tp={root:"_root_1ukx5_1"};var np=require("react/jsx-runtime"),Jm=({className:t,value:e,...o})=>{let n=y("TextInput",tp);return(0,np.jsx)("input",{className:(0,op.default)(t,n.root),type:"text",value:e,...o})},gn=Jm;var Ii={};$(Ii,{enUS:()=>Ym,nlNL:()=>ef});var Ym={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"}]},ef={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 sp={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 tf=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},of=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(Ii),i=y("LoginTokenDialog",sp),a=(0,Vs.useSelector)(zc),l=(0,Vs.useDispatch)(),c=C("productName"),[p,d]=(0,Me.useState)(t||""),[g,u]=(0,Me.useState)(0),[m,f]=(0,Me.useState)(""),h=(0,Me.useCallback)(async b=>{b.preventDefault(),l(Vc({email:p})),u(1)},[o,p]),E=()=>{f(""),u(0)},x=(0,Me.useCallback)(async b=>{b.preventDefault();let v=tf(b.target.elements.token.value);if(!v){f(r("verifyCodeError",{login:_}));return}l(dn({token:v}))},[o]),_=(0,Me.useMemo)(()=>b=>(0,U.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:E,children:b},"back-button"),[]);return(0,Me.useEffect)(()=>{a==="error"&&f(r("verifyCodeError",{login:_})),a==="done"&&n()},[a]),(0,U.jsx)(po,{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})}),g===0&&(0,U.jsxs)("form",{onSubmit:h,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)(gn,{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,js.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),g===1&&(0,U.jsxs)("form",{onSubmit:x,children:[(0,U.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,U.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,U.jsx)(gn,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&(0,U.jsx)("div",{className:i.errorMessage,children:m}),(0,U.jsxs)("div",{className:i.actions,children:[(0,U.jsx)("button",{type:"button",className:(0,js.default)(i.button),onClick:E,children:r("back")}),(0,U.jsx)("button",{type:"submit",className:(0,js.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},rp=of;var ap=require("react/jsx-runtime"),nf=()=>{let t=(0,Ri.useSelector)(jc),e=(0,Ri.useSelector)(nc),o=C("adminUrl"),n=be(),s=()=>n.send(Eo,!1),r=()=>{n.send(Eo,!1),n.send(un)};return(0,ap.jsx)(rp,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},ip=nf;var Op=k(require("lodash.debounce")),se=require("react"),Ue=require("react-redux");var qs=require("@reduxjs/toolkit");var sf={data:null,fetchState:"idle"},lp=t=>t.contentTypes.data,mn=(0,qs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),rf=(0,qs.createSlice)({name:"contentTypes",initialState:sf,reducers:{},extraReducers:t=>{t.addCase(mn.pending,e=>{e.fetchState="loading"}).addCase(mn.rejected,e=>{e.fetchState="error"}).addCase(mn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),cp=rf.reducer;function fn(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 pp=require("react");function dp(t,e){(0,pp.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 hn=require("react"),Gs=require("react-redux");var Ws=require("@reduxjs/toolkit");var up={data:null,fetchState:"idle"},$s=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},Ne=(0,Ws.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)}),af=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),lf=(0,Ws.createSlice)({name:"entities",initialState:up,reducers:{},extraReducers:t=>{t.addCase(Ne.pending,e=>{e.fetchState="loading"}).addCase(Ne.rejected,e=>{e.fetchState="error"}).addCase(Ne.fulfilled,(e,o)=>{e.fetchState="done",e.data=af(e.data?[...e.data,...o.payload]:o.payload)}).addCase(M,()=>up)}}),gp=lf.reducer;var Pi={};$(Pi,{enUS:()=>cf,nlNL:()=>pf});var cf={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},pf={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var mp={root:"_root_17kae_1",empty:"_empty_17kae_5"};var $t=require("react/jsx-runtime"),df=({onCopy:t,onUse:e})=>{let o=(0,hn.useRef)(null),n=y("EntitiesList",mp),s=T(Pi),r=(0,Gs.useSelector)($s),i=(0,Gs.useDispatch)();return(0,hn.useEffect)(()=>{i(Ne())},[]),(0,hn.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,$t.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,$t.jsx)(P.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,$t.jsx)(P.List,{children:r.map((a,l)=>(0,$t.jsx)(P.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,$t.jsx)("p",{className:n.empty,children:s("noResults")})]})},fp=df;var Oe=require("react"),yn=require("react-redux");var Xs=require("@reduxjs/toolkit");var hp={data:null,fetchState:"idle"},yp=t=>t.summary.data,vp=t=>t.summary.fetchState==="error",nt=(0,Xs.createAsyncThunk)("summary/getSummary",async(t,e)=>{var p,d,g;let o=e.getState().profile.data,n=(p=e.getState().conversation.current)==null?void 0:p.sessionId,s=(g=(d=e.getState().info)==null?void 0:d.agentInfo)==null?void 0:g.agentId;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:i}=e.extra;if(!i.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let a=i.conversationQuery,l=await a();if(l.length===0)return Promise.reject(new Error("No messages are included"));let c=await r.getSummary(l,{externalConversationId:n,agentId:s,promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return c?{summary:c}:Promise.reject(new Error("Summary is not provided"))}),uf=(0,Xs.createSlice)({name:"summary",initialState:hp,reducers:{},extraReducers:t=>{t.addCase(nt.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(nt.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(nt.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(M,()=>hp)}}),Sp=uf.reducer;var Ai={};$(Ai,{enUS:()=>gf,nlNL:()=>mf});var gf={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."}]},mf={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 _p={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 st=require("react/jsx-runtime"),ff=({onCopy:t})=>{let e=(0,Oe.useRef)(null),o=y("SummaryForm",_p),[n,s]=(0,Oe.useState)(""),r=T(Ai),i=(0,yn.useSelector)(yp),a=(0,yn.useSelector)(vp),l=(0,yn.useDispatch)(),c=()=>{l(Q({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(Q({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return(0,Oe.useEffect)(()=>{l(nt())},[]),(0,Oe.useEffect)(()=>{s(i||"")},[i]),(0,Oe.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Oe.useEffect)(()=>{let d=g=>{g.key==="Enter"&&g.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),(0,st.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,st.jsx)("p",{className:o.error,children:r("error")}):(0,st.jsxs)(Oe.Fragment,{children:[(0,st.jsx)("div",{className:o.main,children:(0,st.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,st.jsx)("div",{className:o.actions,children:(0,st.jsx)(P.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},xp=ff;var vn={};$(vn,{enUS:()=>hf,nlNL:()=>yf});var hf={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?"}]},yf={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 Ct=k(require("react")),xn=require("react-redux");var Li={};$(Li,{enUS:()=>vf,nlNL:()=>Sf});var vf={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"}]},Sf={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 bp={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 Ro=require("@reduxjs/toolkit");var Zs=require("@reduxjs/toolkit");var _f={data:null,fetchState:"idle"},Cp=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},Sn=(0,Zs.createAsyncThunk)("knowledgeAssistant/getKnowledgeAssistant",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=(i=n.profile.data)==null?void 0:i.knowledgeAssistant;return r?o.getKnowledgeAssistant(r):null}),xf=(0,Zs.createSlice)({name:"knowledgeAssistant",initialState:_f,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})}}),wp=xf.reducer;var Mi={data:[],fetchState:"idle"},Tp=t=>{var e;return(e=t.answer)==null?void 0:e.data},Ep=t=>t.answer.fetchState,Po=(0,Ro.createAction)("answer/resetKnowledgeSearch"),Io=(0,Ro.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var l,c,p;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=Cp(e.getState()),r=(l=e.getState().conversation.current)==null?void 0:l.sessionId,i=(p=(c=e.getState().info)==null?void 0:c.agentInfo)==null?void 0:p.agentId;if(!s)throw new Error("KnowledgeAssistant is not defined");let a=await o.knowledgeAssist({promptInstruction:s.prompt,question:t},n,s.code,{agentId:i,conversationId:r});return{question:t,answer:a}}),bf=(0,Ro.createSlice)({name:"answer",initialState:Mi,reducers:{},extraReducers:t=>{t.addCase(Io.pending,e=>{e.fetchState="loading"}).addCase(Io.rejected,e=>{e.fetchState="error"}).addCase(Io.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(M,()=>Mi).addCase(Po,()=>Mi)}}),kp=bf.reducer;var _n=require("react/jsx-runtime"),Ip=()=>(0,_n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,_n.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,_n.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 ce=require("react/jsx-runtime"),Cf=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=Ct.default.useState(""),{setSelected:r}=St(),i=(0,Ct.useRef)(null),a=y("EntitiesList",bp),l=T(Li),c=(0,xn.useDispatch)(),p=(0,xn.useSelector)(Tp),d=(0,xn.useSelector)(Ep),g=async m=>{m.preventDefault(),m.stopPropagation(),n!==""&&c(Io(n))},u=(m,f)=>{c(Q({name:"knowledge assist source viewed",data:{question:f,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,Ct.useEffect)(()=>{var m;o&&d==="idle"?c(Io(o)):(m=i.current)==null||m.focus()},[i,d]),(0,Ct.useEffect)(()=>{d==="done"&&(c(Q({name:"knowledge assist question answered",data:{question:n||o,sources:p[p.length-1].answer.sources,answer:p[p.length-1].answer.answer,isFollowUpQuestion:p.length>1},options:{includeConversationData:!0}})),r(p.length-1),s(""))},[d,p]),(0,Ct.useEffect)(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,p]),(0,ce.jsxs)("div",{className:a.root,children:[p.length>0&&(0,ce.jsx)("div",{className:a.alignRight,children:(0,ce.jsx)(P.Button,{onClick:e,children:l("reset")})}),(0,ce.jsxs)(P.ActionsBar,{list:p.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:l("use"),onPrimary:m=>t(m.text),children:[p.map(({question:m,answer:f},h)=>(0,ce.jsx)(P.List,{children:(0,ce.jsx)(P.ListItem,{"data-testid":"knowledge-search-answer",index:h,description:f.answer,closeOnSelect:!0,onClick:()=>t(f.answer),onSourceClick:E=>u(E,m),sources:f.sources,styles:{title:a.question,description:a.answer},children:m})},`${f.answer}_${h}`)),d==="loading"&&(0,ce.jsx)("p",{className:a.status,children:l("loading")}),d==="error"&&(0,ce.jsx)("p",{className:a.status,children:l("error")}),(0,ce.jsxs)("form",{className:a.form,onSubmit:g,children:[(0,ce.jsx)("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(-1)},onChange:m=>{r(-1),s(m.target.value)}}),(0,ce.jsx)("button",{type:"submit",className:a.submit,children:(0,ce.jsx)(Ip,{})})]})]})]})},Rp=Cf;var Qs=require("@reduxjs/toolkit");var wf={data:null,fetchState:"idle"},wt=t=>t.profile.data,Js=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],bn=(0,Qs.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)}),Tf=(0,Qs.createSlice)({name:"profile",initialState:wf,reducers:{},extraReducers:t=>{t.addCase(bn.pending,e=>{e.fetchState="loading"}).addCase(bn.rejected,e=>{e.fetchState="error"}).addCase(bn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Pp=Tf.reducer;var Ap=require("react");var Lp=require("react-redux");var Ni=require("react-redux");var Gt=require("react/jsx-runtime"),Ef=({commands:t,onClick:e,onEdit:o})=>{var p,d,g;let n=(0,Lp.useDispatch)(),s=T(vn),r=(0,Ni.useSelector)(wt),i=(0,Ni.useSelector)(xt),a=((g=(d=(p=r==null?void 0:r.uiConfig)==null?void 0:p.search)==null?void 0:d.initialTypes)==null?void 0:g.filter(({isActive:u})=>u))||[],l=0,c=a.map(({type:u})=>{var m;return(m=i[u])==null?void 0:m.suggestions.map(f=>({text:f.text||f.url||f.message,type:u}))}).flat(1);return(0,Ap.useEffect)(()=>{a.forEach(({type:u})=>{(!i[u]||i[u].suggestions.length===0)&&n(Le(u))})},[]),(0,Gt.jsxs)(P.ActionsBar,{list:[...t.map(u=>({text:u.label,type:"command"})),...c],primaryLabel:s("use"),secondaryLabel:s("preview"),onPrimary:({text:u},m)=>e(u,c[m]),onSecondary:(u,m)=>{let f=m-t.length;o(c[f],i[c[f].type].suggestions)},children:[t.length>0&&(0,Gt.jsx)(P.List,{heading:s("commands"),children:t.map((u,m)=>(0,Gt.jsx)(P.ListItem,{index:m,closeOnSelect:!1,onClick:u.onClick,children:u.label},u.label))}),a.map(({type:u,title:m})=>{var f;return(0,Gt.jsx)(P.List,{heading:m,orientation:"vertical",children:(f=i[u])==null?void 0:f.suggestions.map(h=>(l++,(0,Gt.jsx)(P.ListItem,{index:l+t.length-1,closeOnSelect:!1,description:h.text,onClick:()=>e(h.text,h),"data-testid":"search-overlay-suggestion",children:h.title},`${h.id}-${h.text}`)))},u)})]})},Mp=Ef;var V=require("react/jsx-runtime"),kf=200,If=5,Rf=4,Pf=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Np=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Af=()=>{let t=(0,Ue.useDispatch)(),e=be(),o=T(vn),[n,s]=(0,se.useState)(!1),[r,i]=(0,se.useState)(""),a=(0,Ue.useSelector)(lc),l=(0,Ue.useSelector)(wt),[c,p]=(0,se.useState)(null),[d,g]=(0,se.useState)([]),[u,m]=(0,se.useState)(),f=(0,Ue.useSelector)(ne),h=C("showSearch"),E=C("showEntitiesCommand"),x=C("showSummaryCommand"),_=C("showKnowledgeSearch"),b=C("showImageSearch"),v=C("searchTriggerKey"),A=(0,Ue.useSelector)(lp),O=(0,Ue.useSelector)(cc),K=(0,Ue.useSelector)(pc),H=(0,Ue.useSelector)(ac),W=S=>Hn(O.filter(B=>B.type===S.toUpperCase()),S),z=[{value:"PERSONAL",label:o("personalSuggestions"),list:W("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:W("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:W("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:W("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(S=>S.shouldShow),I=[{label:o("entitiesClipboard"),onClick:()=>t(oe("entities")),shouldShow:E&&Np(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(oe("summary")),shouldShow:x&&Np(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(oe("knowledgeAssist")),shouldShow:_}].filter(S=>S.shouldShow),ye=(A==null?void 0:A.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:W(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Mr=(0,se.useCallback)((0,Op.default)((S,B)=>{t(jt({query:S,type:B,tags:["search-overlay"],size:u?50:20}))},kf),[u]),Fo=Pf([...ye,...z]),Ko=(0,se.useCallback)((S,B)=>{t(oe("edit")),p({...S,searchTerm:void 0}),g(B)},[t,c,ye]),to=(0,se.useCallback)((S,B)=>{switch(B.type){case"IMAGE":e.send(Ei,{suggestion:B});break;default:e.send(ot,{text:S,suggestion:B})}t(te(!1))},[t]),sg=S=>{fn(S.text),t(Q({name:"entity copied",data:{entity:S,type:"copy"}})),t(te(!1))},rg=(0,se.useCallback)(S=>{t(Q({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),ig=S=>{e.send(ot,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(Q({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(oe("search")),t(Po()),t(te(!1))},ag=S=>{fn(S),t(te(!1))},lg=S=>{e.send(ot,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(te(!1))},cg=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),pg=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function Hn(S,B){return S.slice(0,u?10:B.toLowerCase()==="image"?Rf:If)}function va(S,B,Ee){return B.reduce((Bn,Fn)=>Ee&&u===Ee?Fn.length+Bn:Hn(Fn,Ee).length+Bn,S)}function oo(S){return B=>{n?window.confirm(o("warning"))&&(S(B),s(!1)):S(B)}}return(0,se.useEffect)(()=>{r?Mr(r,u):t(Ns())},[r,u]),(0,se.useEffect)(()=>{a==="search"&&t(Po())},[a]),(0,se.useEffect)(()=>{f&&t(mn())},[f]),dp(v,()=>t(te(!0))),!h||!l?null:(0,V.jsxs)(P,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:oo(S=>t(te(S))),onChangeType:S=>m(S),onChangePage:oo(S=>t(oe(S))),selectedType:u,search:r,page:a,isOpen:H,types:[...ye,...z],children:[(0,V.jsxs)(P.Page,{id:"search",children:[r.length===0&&(0,V.jsx)(Mp,{commands:I,onClick:to,onEdit:Ko}),r.length>0&&(0,V.jsxs)(P.ActionsBar,{list:[...I.map(S=>({text:S.label,type:"command"})),...Fo.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},B)=>to(S,Fo[B]),onSecondary:(S,B)=>{let Ee=Fo[B-I.length];!Ee||!Ee.type||Ko(Ee,W(Ee.type))},children:[I.length>0&&(0,V.jsx)(P.List,{heading:o("commands"),children:I.map((S,B)=>(0,V.jsx)(P.ListItem,{index:va(B,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...ye,...z].map(({value:S,label:B,list:Ee,lineClamp:Bn,listOrientation:Fn},dg)=>(0,V.jsx)(P.List,{heading:B,orientation:Fn==="horizontal"?"horizontal":"vertical",onShowAll:()=>m(S),hasMore:!u&&K[S.toLowerCase()]>Hn(Ee,S).length,children:Hn(Ee,S).map((ve,ug)=>(0,V.jsx)(P.ListItem,{index:va(I.length+ug,[...ye,...z].slice(0,dg).map(({list:gg})=>gg),S),closeOnSelect:!1,lineClamp:Bn,onClick:()=>to(ve.text,ve),description:S!=="IMAGE"?ve.title&&ve.text:void 0,onFeedback:S!=="IMAGE"?()=>rg(ve):void 0,children:S==="IMAGE"?(0,V.jsx)(P.Image,{title:ve.title||ve.text,src:ve.image}):ve.title||ve.text},`${ve.id}-${ve.text}`))},S))]})]}),(0,V.jsx)(P.Page,{id:"edit",onDismiss:oo(()=>{t(oe("search")),p(null)}),children:c&&(0,V.jsx)(Fs,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(oe("search")),p(null),g([])},onNext:pg,onPrevious:cg,onUse:S=>{t(oe("search")),to(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(te(!1)),g([]),p(null)}})}),(0,V.jsx)(P.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:oo(()=>{t(oe("search"))}),children:(0,V.jsx)(fp,{onUse:lg,onCopy:sg})}),(0,V.jsx)(P.Page,{id:"summary",title:o("summaryTitle"),onDismiss:oo(()=>{t(oe("search"))}),children:(0,V.jsx)(xp,{onCopy:ag})}),(0,V.jsx)(P.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:oo(()=>{t(Po()),t(oe("search"))}),children:(0,V.jsx)(Rp,{question:r,onUse:ig,onResetQuestion:()=>{t(Po()),i("")}})})]})},Dp=Af;var Ao=require("react/jsx-runtime"),Lf=()=>{let t=C("showSearch"),e=C("isEmbedded");return(0,Ao.jsxs)(Hp.Fragment,{children:[t&&(0,Ao.jsx)(Dp,{}),(0,Ao.jsx)(ep,{}),e&&(0,Ao.jsx)(ip,{})]})},Bp=Lf;var zp=k(require("classnames")),jp=require("react-redux");var Ys=require("react/jsx-runtime"),Fp=({className:t})=>(0,Ys.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,Ys.jsx)("g",{children:(0,Ys.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
3
+ `,Ot.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(g-(p.offset||0));_=p.options[b]||p.options.other}if(!_)throw new Zr(p.value,g,Object.keys(p.options),i);a.push.apply(a,Qo(_.value,e,o,n,s,g-(p.offset||0)));continue}}return Jg(a)}function em(t,e){return e?ge(ge(ge({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=ge(ge({},t[n]),e[n]||{}),o},{})):t}function tm(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=em(t[n],e[n]),o},ge({},t)):t}function Qr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function om(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:vs(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,as([void 0],o,!1)))},{cache:Qr(t.number),strategy:Ss.variadic}),getDateTimeFormat:vs(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,as([void 0],o,!1)))},{cache:Qr(t.dateTime),strategy:Ss.variadic}),getPluralRules:vs(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,as([void 0],o,!1)))},{cache:Qr(t.pluralRules),strategy:Ss.variadic})}}var xl=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var d=p.reduce(function(g,u){return!g.length||u.type!==J.literal||typeof g[g.length-1]!="string"?g.push(u.value):g[g.length-1]+=u.value,g},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Qo(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=gl(i,["formatters"]);this.ast=t.__parse(e,ge(ge({},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=tm(t.formats,n),this.formatters=s&&s.formatters||om(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=hl,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 nm(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var sm="dummy",Jr=(0,_s.createContext)(null);function T(t){let e=(0,_s.useContext)(Jr);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=nm(o,n);return r?new xl(r).format(s):(e!==sm&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var Jo=require("react/jsx-runtime"),xs=()=>(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 Yo=require("react/jsx-runtime"),bl=()=>(0,Yo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,Yo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,Yo.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 xe=require("react"),jl=require("react-redux"),li=require("interweave"),ci=k(require("classnames"));var Yr={root:"_root_smoda_1",agentText:"_agentText_smoda_3",textInput:"_textInput_smoda_8",textInputWrapper:"_textInputWrapper_smoda_27",alert:"_alert_smoda_31",alertText:"_alertText_smoda_50",warning:"_warning_smoda_60",success:"_success_smoda_69"};var wl=require("interweave"),Tl=k(require("classnames"));var uo=require("react");function Cl(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function bs(t){let e=(0,uo.useRef)(null),[o,n]=(0,uo.useState)(!1);return(0,uo.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Cl((p,d)=>{let g=e.current;if(!g)return;let u=p/r,m=d/r,f=g.getBoundingClientRect(),h=u>f.x&&u<f.x+f.width&&m>f.y&&m<f.y+f.height;h&&!s?(s=!0,n(!0)):!h&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=Cl(()=>{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 Ge={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 ei=require("react/jsx-runtime"),rm=({inputElement:t,children:e})=>{let o=y("TabCompletion",Ge),[n,s]=bs(t);return(0,ei.jsx)("mark",{ref:n,className:(0,Tl.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},go=class extends wl.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,ei.jsx)(rm,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var mo=require("react");function Cs(t){return t.contentEditable==="true"}function im(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 El(t){let{selectionStart:e,selectionEnd:o}=Cs(t)?im(t):t;return[e,o]}function ws(t){let[,e]=(0,mo.useState)(),o=(0,mo.useRef)(null);return o.current=El(t),(0,mo.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=El(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 Ts(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(io);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 kl=require("react");function fo(t){(0,kl.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Dt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Il,Fe=new Map,am=["bottom","height","left","right","top","width"],lm=(t={},e={})=>am.some(o=>t[o]!==e[o]);function Rl(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,...Rl(e)]:[]}function Pl(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var Es=!1,Al=()=>{Es=!0;let t=[];if(Fe.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Fe.delete(o);return}let n=o.getBoundingClientRect();lm(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(Pl,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),Fe.size===0){Es=!1;return}Il=window.requestAnimationFrame(Al)};function ti(t,e){let o=Rl(t),n=[],s=o.map((r,i)=>ti(r,a=>{n[i]=a;let l=Fe.get(t);if(!l)return;let c=n.reduce(Pl,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Fe.has(t)){let i=Fe.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Fe.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!Es&&Al()},unobserve(){s.forEach(i=>i.unobserve());let r=Fe.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Fe.delete(t),Fe.size||(cancelAnimationFrame(Il),Es=!1)}}}}var Ll,Ke=new Map,Ml=()=>{Ke.forEach((t,e)=>{if(!e.isConnected){Ke.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)))}),Ke.size!==0&&(Ll=window.requestAnimationFrame(Ml))};function Nl(t,e){return{observe(){let o=Ke.size===0;Ke.has(t)?Ke.get(t).callbacks.push(e):Ke.set(t,{visible:void 0,callbacks:[e]}),o&&Ml()},unobserve(){let o=Ke.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ke.delete(t),Ke.size||cancelAnimationFrame(Ll)}}}}var oi=["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 ni(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function ho(t){return parseFloat(t)}function ks(t){return Math.round(t*1e6)}function Ol(t){return t/1e6}function si(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=ho(t.width),r=ho(t.borderLeftWidth),i=ho(t.borderRightWidth),a=ho(t.paddingRight),l=Ol(ks(s)-ks(r)-ks(i)),c=Ol(ks(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Ht(t,e={}){var p;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Dt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};ni(n,o,oi),si(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=Nl(t,()=>{ni(n,o,oi),si(n,t,o),r(),setTimeout(r,0)}),a,l=!0,c=ti(t,d=>{if(d===null){e.onRemove&&e.onRemove(),o.remove();return}if(!l&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(ni(n,o,oi),si(n,t,o),r(),o.style.top=`${d.top}px`,o.style.left=`${d.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let g=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),m=ho(u.borderTopWidth),f=ho(u.borderBottomWidth),h=g.top+m-d.top,E=d.top+d.height+-(g.top+g.height-f);o.style.clipPath=`inset(${h}px 0px ${E}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(p=t.parentElement)==null||p.appendChild(o),c.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),c.unobserve(),i.unobserve()}]}var ri={};$(ri,{enUS:()=>cm,nlNL:()=>pm});var cm={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"}]},pm={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 en=require("react/jsx-runtime"),Dl=()=>(0,en.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,en.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,en.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 ii=require("react/jsx-runtime"),Hl=()=>(0,ii.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,ii.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var Bl=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Bl||{}),Xe=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();ft(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(Bl).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",o=>this.handlePaste(o)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var Ze=class extends Xe{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 dm=/[.*+?^${}()|[\]\\]/g,um=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function gm(t){return t.replace(dm,"\\$&")}function mm(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function fm(t){return t.search(um)}function Fl(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${gm(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function Kl(t){return t.replace(io,'<mark data-type="placeholder">$1</mark>')}function yo(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function hm(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 ai(t,e,o={}){if(e){let n=mm(e.toLowerCase(),t.toLowerCase()),s=yo(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=fm(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Fa).length>3||e.length>30?hm(e.trim(),n):0;return`${`${i>0?"\u2026":""}${yo(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var ym=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function Bt(t){return ym.test(t)}function Ul(t){if(Bt(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}function zl(t){let e=document.createElement("template");return e.innerHTML=t,e.content.textContent??""}var Y=require("react/jsx-runtime"),vm=({value:t,onUse:e,...o})=>{var d;let n=T(ri),s=(0,jl.useDispatch)(),r=Bt(t),i=y("EditSuggestionTextInput",Yr),[a,l]=(0,xe.useState)(null),c=(0,xe.useRef)(null),p=((d=t.match(io))==null?void 0:d.length)||0;return(0,xe.useEffect)(()=>{let g;return c.current&&(l(c.current),g=new Ze(c.current),g.on("change",({plainText:u})=>{s(ae.actions.userInput({text:u,selection:g.getSelection()}))}),g.on("keydown",u=>{s(ae.actions.registerKeyDown(ts(u))),u.code==="Enter"&&u.shiftKey&&e(g.getText())}),g.on("paste",({pastedText:u,selectionText:m})=>{s(ae.actions.registerPaste({text:u,selectionText:m}))}),g.on("cut",({selectionText:u})=>{s(ae.actions.registerCut(u))})),()=>{s(ae.actions.reset()),g.dispose(),g.deactivate()}},[c]),(0,xe.useEffect)(()=>{t&&c.current&&(c.current.value=t)},[t,c]),(0,xe.useEffect)(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let g=c.current.value.length;c.current.setSelectionRange(g,g),c.current.focus()},0)},[c]),r?(0,Y.jsx)("div",{className:i.textInputWrapper,children:(0,Y.jsx)(li.Interweave,{className:i.textInput,tagName:"div",content:t})}):(0,Y.jsxs)("div",{className:i.textInputWrapper,children:[(0,Y.jsx)("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&(0,Y.jsx)(Sm,{inputElement:c.current,value:t}),(0,Y.jsxs)("div",{className:(0,ci.default)(i.alert,p===0?i.success:i.warning),children:[(0,Y.jsx)("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?(0,Y.jsx)(Dl,{}):(0,Y.jsx)(Hl,{})]})]})},Sm=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",Yr),n=(0,xe.useRef)(null),s=ws(t);return(0,xe.useEffect)(()=>{Ts(t,s)},[s,t]),(0,Y.jsx)(_m,{inputElement:t,children:(0,Y.jsxs)("div",{ref:n,className:(0,ci.default)(o.root,o.agentText),children:[(0,Y.jsx)(li.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new go("placeholders")],inputElement:t,boundaryRef:n}),(0,Y.jsx)("br",{})]})})},_m=({inputElement:t,children:e})=>{let o=(0,xe.useRef)(null);return(0,xe.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=Ht(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,Y.jsx)("div",{ref:o,children:e})},Vl=vm;var xo=require("react");var ql=require("react"),Is=k(require("classnames"));var le={root:"_root_1xflk_1",list:"_list_1xflk_2",listWrapper:"_listWrapper_1xflk_6",listHorizontal:"_listHorizontal_1xflk_10",page:"_page_1xflk_19",search:"_search_1xflk_25",pageNav:"_pageNav_1xflk_33",pageTitle:"_pageTitle_1xflk_41",pageBackButton:"_pageBackButton_1xflk_48",listHeader:"_listHeader_1xflk_62",listHeading:"_listHeading_1xflk_68",listMoreButton:"_listMoreButton_1xflk_76",listItem:"_listItem_1xflk_87",listItemContent:"_listItemContent_1xflk_96",listItemText:"_listItemText_1xflk_114",listItemDescription:"_listItemDescription_1xflk_122",listItemActions:"_listItemActions_1xflk_129",truncate:"_truncate_1xflk_140",lineClamp:"_lineClamp_1xflk_146",listItemTitle:"_listItemTitle_1xflk_153",listItemAction:"_listItemAction_1xflk_129",listItemPrimaryAction:"_listItemPrimaryAction_1xflk_174",listItemSelected:"_listItemSelected_1xflk_179",sources:"_sources_1xflk_183",sourcesTitle:"_sourcesTitle_1xflk_190",source:"_source_1xflk_183",icon:"_icon_1xflk_205",searchIcon:"_searchIcon_1xflk_222",searchInputWrapper:"_searchInputWrapper_1xflk_227",searchInput:"_searchInput_1xflk_227",select:"_select_1xflk_248",selectType:"_selectType_1xflk_265",selectWrapper:"_selectWrapper_1xflk_269",image:"_image_1xflk_299",imageSrc:"_imageSrc_1xflk_306",imageSrcHidden:"_imageSrcHidden_1xflk_317",imageSrcStatus:"_imageSrcStatus_1xflk_321",imageTitle:"_imageTitle_1xflk_331",actions:"_actions_1xflk_336",actionsWrapper:"_actionsWrapper_1xflk_340",actionsBar:"_actionsBar_1xflk_346",actionButton:"_actionButton_1xflk_355",hasShortKeys:"_hasShortKeys_1xflk_368",actionShortcut:"_actionShortcut_1xflk_377",actionShortcutFixKerning:"_actionShortcutFixKerning_1xflk_384"};var Qe={};$(Qe,{enUS:()=>xm,nlNL:()=>bm});var xm={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}]},bm={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}]};var vt=require("react/jsx-runtime"),Cm=({src:t,title:e})=>{let o=y("CommandPalette",le),[n,s]=(0,ql.useState)("loading"),r=T(Qe);return(0,vt.jsxs)("div",{className:o.image,children:[(0,vt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,Is.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,vt.jsx)("span",{className:(0,Is.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,vt.jsx)("span",{className:(0,Is.default)(o.imageSrc,o.imageSrcStatus),children:(0,vt.jsx)(Un,{})}),e&&(0,vt.jsx)("span",{className:o.imageTitle,children:e})]})},Wl=Cm;var $l=k(require("react")),Gl=k(require("classnames"));var Ft=require("react/jsx-runtime");function pi({children:t,heading:e,orientation:o,hasMore:n,onShowAll:s}){let r=T(Qe),i=y("CommandPalette",le);return $l.default.Children.count(t)===0?null:(0,Ft.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||n)&&(0,Ft.jsxs)("div",{className:i.listHeader,children:[e&&(0,Ft.jsx)("h4",{className:i.listHeading,children:e}),n&&s&&(0,Ft.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,Ft.jsx)("div",{className:(0,Gl.default)(i.listWrapper,o==="horizontal"&&i.listHorizontal),children:t})]})}var tn=k(require("classnames")),oc=require("interweave");var Z=k(require("react")),Xl=k(require("classnames"));var di={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 Kt=require("react/jsx-runtime"),wm=0,Zl=Z.default.createContext(null),Tm=()=>{let t=(0,Z.useContext)(Zl);if(!t)throw new Error("Invalid DropdownContext");return t},Ql=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,Z.useMemo)(()=>++wm,[]),s=(0,Z.useRef)(null),r=(0,Z.useRef)(null),i=y("Dropdown",di),[a,l]=(0,Z.useState)(!1),[c,p]=(0,Z.useState)(o),d=u=>{u.preventDefault(),u.stopPropagation(),l(!a)},g=(0,Z.useCallback)(([u])=>{!u.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return(0,Z.useEffect)(()=>{let u=m=>{s.current&&!s.current.contains(m.target)&&l(!1)};return document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}},[]),(0,Z.useEffect)(()=>{if(!r.current&&!a)return()=>{};let u=new IntersectionObserver(g,{root:null,rootMargin:"0px",threshold:1});return r.current&&u.observe(r.current),()=>{r.current&&u.unobserve(r.current)}},[r,a]),(0,Kt.jsx)(Zl.Provider,{value:{setIsOpen:l},children:(0,Kt.jsxs)("div",{ref:s,className:i.root,children:[(0,Kt.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,Kt.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,Xl.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Em({as:t,children:e,onClick:o,...n}){let s=t||"button",r=y("Dropdown",di),{setIsOpen:i}=Tm(),a=l=>{i(!1),o(l),l.stopPropagation()};return(0,Kt.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Ql.Item=Em;var ui=Ql;var gi=require("react/jsx-runtime"),Jl=t=>(0,gi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,gi.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 Ut={};$(Ut,{enUS:()=>km,nlNL:()=>Im});var km={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"}]},Im={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 Rs=require("react/jsx-runtime"),Rm="%0d%0a%0d%0a%0d%0a",Pm=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Rm)}`},Am=({suggestion:t,onFeedback:e})=>{let o=T(Ut),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,Rs.jsx)(ui,{trigger:(0,Rs.jsx)(Jl,{"data-testid":"feedback-dropdown-trigger"}),children:(0,Rs.jsx)(ui.Item,{as:"a",href:Pm(n,t),onClick:e,children:o("giveFeedback")})})},Ps=Am;var As=k(require("react")),tc=require("react/jsx-runtime"),Yl=As.default.createContext(void 0);function St(){let t=As.default.useContext(Yl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var ec=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=As.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,tc.jsx)(Yl.Provider,{value:i,children:t})};var me=require("react/jsx-runtime");function mi({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,index:i,description:a,sources:l,styles:c,...p}){let{selected:d,setSelected:g,onChangeOpen:u}=St(),m=y("CommandPalette",le);function f(h){n(h),t&&u(!1)}return(0,me.jsxs)("div",{className:(0,tn.default)(m.listItem,d===i&&m.listItemSelected),children:[(0,me.jsx)("button",{onMouseEnter:()=>g(i),type:"button",className:(0,tn.default)("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:(0,me.jsxs)("div",{className:m.listItemContent,children:[typeof o=="string"?(0,me.jsx)("p",{className:(0,tn.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,me.jsx)(oc.Interweave,{tagName:"p",allowList:[],content:Bt(a)?zl(a):a,className:(0,tn.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate)})]})}),s&&d===i&&(0,me.jsx)("div",{className:m.listItemActions,children:(0,me.jsx)(Ps,{suggestion:String(o),onFeedback:s})}),l&&(0,me.jsxs)("div",{className:m.sources,children:[(0,me.jsx)("span",{className:m.sourcesTitle,children:"Sources"}),l.map(h=>h.url?(0,me.jsx)("a",{className:m.source,href:h.url,target:"_blank",title:h.url,rel:"noopener noreferrer",onClick:()=>r&&r(h),children:h.name},h.url):(0,me.jsx)("span",{className:m.source,children:h.name},h.name))]})]})}var zt=require("react/jsx-runtime");function fi({children:t,title:e,id:o,onDismiss:n}){let s=T(Qe),r=y("CommandPalette",le),{page:i}=St();return i!==o?null:(0,zt.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,zt.jsxs)("div",{className:r.pageNav,children:[(0,zt.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,zt.jsx)(xs,{}),s("back")]}),e&&(0,zt.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var _t=require("react");var Ms=require("@reduxjs/toolkit");var vo=require("@reduxjs/toolkit");function Lm(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function N(t){return Array.isArray(t)?t.map(N):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Lm(o)]:N(t[o])}),{}):t}function hi(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function G(t){return Array.isArray(t)?t.map(G):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[hi(o)]:G(t[o])}),{}):t}var Mm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},nn=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)||""}},on=(0,vo.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?N(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),N(n))}),yi=(0,vo.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}),vi=(0,vo.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),nc=t=>t.info.agentInfo,sc=(0,vo.createSlice)({name:"info",initialState:Mm,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(on.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(on.rejected,e=>{e.fetchState="error"}).addCase(on.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(yi.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(vi.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(M,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:rc}=sc.actions,ic=sc.reducer;var Ls={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},ac=t=>t.search.isOpen,lc=t=>t.search.page,cc=t=>t.search.list,pc=t=>t.search.aggregates;function dc(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var jt=(0,Ms.createAsyncThunk)("search/getAll",async(t,e)=>{var a;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(a=n.conversation.current)==null?void 0:a.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r,aggregates:i}=await o.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:nn(n)});return{results:r.map(l=>({...l,source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:i}}),uc=(0,Ms.createSlice)({name:"search",initialState:Ls,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=Ls.fetchState,t.list=Ls.list}},extraReducers:t=>{t.addCase(jt.pending,e=>{e.fetchState="loading"}).addCase(jt.rejected,(e,o)=>{e.fetchState="error",w.error(o.error)}).addCase(jt.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload.results,e.aggregates=o.payload.aggregates||{}}).addCase(M,()=>Ls)}}),{resetSearch:Ns,setIsOpen:te,setPage:oe}=uc.actions,gc=uc.reducer;var Nm=/(https?:\/\/[^\s]+)/,Os=t=>t.split(" ").find(e=>Nm.test(e));var Ds=()=>/Mac/i.test(navigator.platform);var Si=k(require("classnames"));var Hs=require("react/jsx-runtime"),Om=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",le);return(0,Hs.jsxs)("button",{type:"button",...n,onClick:t,className:(0,Si.default)(s.actionButton,n.className,{[s.hasShortKeys]:e&&e.length>0}),children:[o,e&&e.map(r=>(0,Hs.jsx)("span",{className:(0,Si.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},So=Om;var Je=require("react/jsx-runtime"),Dm=["url","URL"],Hm=["default","pinned-message","DEFAULT","STICKYMESSAGE"],Bm=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",le),a=T(Qe),{selected:l,setSelected:c}=St(),p=r[l],d=p&&p.type&&Dm.includes(p.type),g=p&&p.type&&Hm.includes(p.type)||p&&"secondaryAction"in p,u=d?Os(p.text):null,m=(0,_t.useRef)(null);function f(v){if(!m.current)return;let A=m.current.querySelectorAll(".command-palette-list-item"),O=0,K=0;v==="down"?(A.forEach((W,z)=>{z===l&&(O=z)}),K=O===A.length-1?0:O+1):v==="up"?(A.forEach((W,z)=>{z===l&&(O=z)}),K=O?O-1:A.length-1):c(0);let H=A[K];H&&typeof K=="number"&&(c(K),H.scrollIntoView&&H.scrollIntoView({behavior:"smooth",block:K?"center":"end"}))}function h(){if(!m.current)return;let v=m.current.querySelectorAll(".command-palette-list-item"),A=0;v.forEach((K,H)=>{H===l&&(A=H)});let O=v[A];O&&O.click()}let E=()=>{u&&window.open(u,"_blank")},x=()=>{p&&n(p,l)},_=()=>{!s||!g||s(p,l)},b=(0,_t.useCallback)(v=>{if(v.key==="Enter"&&v.altKey&&u){E();return}if(v.key==="Enter"&&v.shiftKey){_();return}if(v.key==="ArrowDown"){v.preventDefault(),v.stopPropagation(),f("down");return}if(v.key==="ArrowUp"){v.preventDefault(),v.stopPropagation(),f("up");return}v.key==="Enter"&&l!==-1&&(v.preventDefault(),v.stopPropagation(),h())},[l]);return(0,_t.useEffect)(()=>(window.addEventListener("keyup",b),()=>{window.removeEventListener("keyup",b)}),[b]),(0,Je.jsxs)("div",{className:i.actions,children:[(0,Je.jsx)("div",{className:i.actionsWrapper,ref:m,children:t}),(0,Je.jsxs)("div",{className:i.actionsBar,children:[u&&(0,Je.jsx)(So,{onClick:E,shortKeys:[Ds()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Je.jsxs)(_t.Fragment,{children:[s&&g&&(0,Je.jsx)(So,{onClick:_,shortKeys:[8679,8629],children:o}),(0,Je.jsx)(So,{onClick:x,shortKeys:[8629],children:e})]})]})]})},fc=Bm;var hc=require("react");var sn=require("react/jsx-runtime"),_o=()=>(0,sn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,sn.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,sn.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 Ae=require("react/jsx-runtime");function Fm({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",le);return(0,Ae.jsxs)("div",{className:l.search,children:[(0,Ae.jsx)("div",{className:l.searchIcon,children:(0,Ae.jsx)(_o,{})}),(0,Ae.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Ae.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,Ae.jsx)("div",{className:l.selectWrapper,children:(0,Ae.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,Ae.jsx)("option",{children:n}),s.map(c=>(0,Ae.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var yc=(0,hc.forwardRef)(Fm);var rn=require("react/jsx-runtime");function Vt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:d,search:g}){let[u,m]=(0,xo.useState)(0),f=(0,xo.useRef)(null),h=()=>{s&&s(o),i(void 0),r(""),a(!1)},E=()=>{var x;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(x=f.current)==null||x.focus();return}if(g.length>0){r("");return}a(!1)};return(0,xo.useEffect)(()=>{m(0)},[g,n]),(0,rn.jsx)(po,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:E,onClose:h,children:(0,rn.jsxs)(ec,{selected:u,setSelected:m,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,rn.jsx)(yc,{ref:f,onChange:r,onChangeType:i,placeholder:t,value:g,selectedType:l,types:c,typePlaceholder:e}),p]})})}Vt.Page=fi;Vt.List=pi;Vt.Image=Wl;Vt.ListItem=mi;Vt.ActionsBar=fc;Vt.Button=So;var P=Vt;var ee=require("react/jsx-runtime"),Km=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",ul),l=(0,Bs.useDispatch)(),c=T(Vr),p=(0,Bs.useSelector)(m=>m.overlayInput.text);(0,_i.useEffect)(()=>{t&&(l(ae.actions.reset()),l(ae.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(ae.actions.commitSuggestion()))},[t]);let d=m=>{m.preventDefault(),g(p)},g=m=>{l(ss(m)),e(m)},u=m=>f=>{p!==i?window.confirm(c("warning"))&&m(f):m(f)};return(0,_i.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,ee.jsxs)("div",{className:a.root,children:[(0,ee.jsxs)("div",{className:a.content,children:[t.title&&(0,ee.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,ee.jsx)(Dr,{labels:t.searchKeywords}),(0,ee.jsx)(Vl,{onUse:g,value:Ul(p)})]}),(0,ee.jsxs)("form",{className:a.actions,onSubmit:d,children:[(0,ee.jsxs)("div",{children:[(0,ee.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&u(r),children:(0,ee.jsx)(xs,{})}),(0,ee.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&u(s),children:(0,ee.jsx)(bl,{})})]}),(0,ee.jsxs)("div",{className:a.primaryButtons,children:[(0,ee.jsx)(P.Button,{onClick:u(o),shortKeys:["esc"],children:c("dismiss")}),(0,ee.jsx)(P.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},Fs=Km;var qt=require("@reduxjs/toolkit");var Um=["{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}"],zm=new RegExp(Um.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function vc(t,e){let o=t.split(zm),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let d=a.charAt(0),g=0;do c=d?e.indexOf(d,c+1):-1,g+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&g>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function Sc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var xc={suggestions:[],fetchState:"idle",isInitialRequest:null},_c={default:xc},Ks=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},bc=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")},xt=t=>t.textSuggestions,Cc=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},Us=(0,qt.createAction)("textSuggestions/refresh"),Le=(0,qt.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=lo(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,nn(n),t);if(t==="default"){let p=i?l.filter(Cc(a)):l;e.dispatch(Be(p.slice(0,r)))}return l}),an=(0,qt.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,{...nn(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"?vc(p.text,t):p.text}))),l=Sc(l,r),e.dispatch(Be(l)),l}),wc=(0,qt.createSlice)({name:"textSuggestions",initialState:_c,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:o}=e.payload;t[o].fetchState="done",t[o].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}},setSuggestionState(t,e){return e.payload}},extraReducers:t=>{t.addCase(Le.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||xc;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Le.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Le.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(an.pending,e=>{e.default.fetchState="loading"}).addCase(an.rejected,e=>{e.default.fetchState="error"}).addCase(an.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(M,()=>_c)}}),{setTextSuggestions:Tc,setSuggestionState:Ec}=wc.actions,kc=wc.reducer;var Rc=require("@reduxjs/toolkit");var Ic={contentType:null,suggestion:null},Pc=t=>t.activeSuggestion.suggestion,Ac=t=>t.activeSuggestion.contentType,Lc=(0,Rc.createSlice)({name:"activeSuggestion",initialState:Ic,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(M,()=>Ic)}}),{setActiveSuggestion:Ye,resetActiveSuggestion:xi}=Lc.actions,Mc=Lc.reducer;var bi={};$(bi,{enUS:()=>jm,nlNL:()=>Vm});var jm={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"}]},Vm={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 Nc=require("@reduxjs/toolkit"),qm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var zs=({ui:t})=>t.overlayCollapsed;var Oc=(0,Nc.createSlice)({name:"ui",initialState:qm,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:ln,setInputHasFocus:bo,setOverlayCollapsed:bt,setOpenOverlayWhenTyping:Dc,setOverlayCollapsedUserOverwrite:Hc}=Oc.actions,Bc=Oc.reducer;var cn=k(require("react")),Kc=require("react/jsx-runtime"),Fc=cn.default.createContext(null),Wt=({broadcastEvents:t,children:e})=>{let o=cn.default.useMemo(()=>t,[]);return(0,Kc.jsx)(Fc.Provider,{value:o,children:e})},be=()=>{let t=(0,cn.useContext)(Fc);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var Co=require("@reduxjs/toolkit");var Wm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ne=t=>t.auth.isLoggedIn,Uc=t=>t.auth.loginFetchState,zc=t=>t.auth.verifyFetchState,jc=t=>t.auth.showLoginOverlay,et=(0,Co.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Vc=(0,Co.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),pn=(0,Co.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),qc=(0,Co.createSlice)({name:"auth",initialState:Wm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(et.pending,e=>{e.loginFetchState="loading"}),t.addCase(et.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(et.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(pn.pending,e=>{e.verifyFetchState="loading"}),t.addCase(pn.rejected,e=>{e.verifyFetchState="error"}),t.addCase(pn.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:wo,setShowLoginOverlay:Wc}=qc.actions,$c=qc.reducer;var To=require("@reduxjs/toolkit");var Ci={cues:[],fetchState:"idle"},Gc=t=>{var e;return(e=t.rules)==null?void 0:e.cues},$m=(0,To.createAction)("rules/resetCues"),tt=(0,To.createAsyncThunk)("rules/evaluate",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=(r=e.getState().conversation.current)==null?void 0:r.id;if(!n)throw new Error("No current conversation to evaulate rules");return await o.evaluateRule(t.label,n,t.params)}),Xc=(0,To.createSlice)({name:"answer",initialState:Ci,reducers:{removeCue(t,e){t.cues=t.cues.filter(o=>o.id!==e.payload.id)}},extraReducers:t=>{t.addCase(tt.pending,e=>{e.fetchState="loading"}).addCase(tt.rejected,e=>{e.fetchState="error"}).addCase(tt.fulfilled,(e,o)=>{let n=Date.now(),s=o.payload.map(a=>({id:a.id||a.text,timestamp:n,...a})),r=s.map(a=>a.id),i=e.cues.filter(a=>!r.includes(a.id));e.fetchState="done",e.cues=[...s,...i]}).addCase(M,()=>Ci).addCase($m.toString(),()=>Ci)}}),{removeCue:Zc}=Xc.actions,Qc=Xc.reducer;var wi="SetActiveSuggestion",Ti="SetCues",Eo="ShowLoginOverlay",dn="UserLoggedIn",Gm="UserLoggedOut",ot="ApplySuggestion",Ei="ApplyImageSuggestion",Xm="ShowCommandPalette",Zm=t=>({[wi]:e=>{t.dispatch(Ec(e.state)),t.dispatch(Ye({contentType:e.contentType,suggestion:e.suggestion}))},[Ti]:e=>{t.dispatch({type:tt.fulfilled,payload:e})},[Xm]:e=>{t.dispatch(te(e.isOpen)),e.page&&t.dispatch(oe(e.page))},[Eo]:e=>{t.dispatch(Wc(e))},[dn]:()=>{t.dispatch(et())},[Gm]:()=>{t.dispatch(et())},[Ei]:e=>{t.dispatch(is({suggestion:e.suggestion}))},[ot]:e=>{t.dispatch(Re({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch($e())}}),Jc=Zm;var ki=require("react/jsx-runtime"),Qm=()=>{var m;let[t,e]=(0,Yc.useState)(!1),o=(0,ko.useSelector)(Pc),n=(0,ko.useSelector)(Ac),s=(0,ko.useSelector)(xt),r=(0,ko.useDispatch)(),i=be(),a=T(bi),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(xi()),r(bo(!0)),r(ae.actions.reset())},p=(f,h)=>{r(xi()),r(bo(!0)),i.send(ot,{text:f,suggestion:{...h,source:`${h.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(m=s[n])==null?void 0:m.suggestions.indexOf(o),g=d===0||d===null?void 0:()=>r(Ye({contentType:n,suggestion:s[n].suggestions[d-1]})),u=d===s[n].suggestions.length-1||d===null?void 0:()=>r(Ye({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,ki.jsx)(po,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,ki.jsx)(Fs,{onTouched:e,onDismiss:c,onUse:f=>p(f,o),suggestion:o,onNext:u,onPrevious:g})})},ep=Qm;var Ri=require("react-redux");var js=k(require("classnames")),Me=require("react"),Vs=require("react-redux");var op=k(require("classnames"));var tp={root:"_root_1ukx5_1"};var np=require("react/jsx-runtime"),Jm=({className:t,value:e,...o})=>{let n=y("TextInput",tp);return(0,np.jsx)("input",{className:(0,op.default)(t,n.root),type:"text",value:e,...o})},un=Jm;var Ii={};$(Ii,{enUS:()=>Ym,nlNL:()=>ef});var Ym={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"}]},ef={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 sp={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 tf=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},of=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(Ii),i=y("LoginTokenDialog",sp),a=(0,Vs.useSelector)(zc),l=(0,Vs.useDispatch)(),c=C("productName"),[p,d]=(0,Me.useState)(t||""),[g,u]=(0,Me.useState)(0),[m,f]=(0,Me.useState)(""),h=(0,Me.useCallback)(async b=>{b.preventDefault(),l(Vc({email:p})),u(1)},[o,p]),E=()=>{f(""),u(0)},x=(0,Me.useCallback)(async b=>{b.preventDefault();let v=tf(b.target.elements.token.value);if(!v){f(r("verifyCodeError",{login:_}));return}l(pn({token:v}))},[o]),_=(0,Me.useMemo)(()=>b=>(0,U.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:E,children:b},"back-button"),[]);return(0,Me.useEffect)(()=>{a==="error"&&f(r("verifyCodeError",{login:_})),a==="done"&&n()},[a]),(0,U.jsx)(po,{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})}),g===0&&(0,U.jsxs)("form",{onSubmit:h,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)(un,{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,js.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),g===1&&(0,U.jsxs)("form",{onSubmit:x,children:[(0,U.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,U.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,U.jsx)(un,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&(0,U.jsx)("div",{className:i.errorMessage,children:m}),(0,U.jsxs)("div",{className:i.actions,children:[(0,U.jsx)("button",{type:"button",className:(0,js.default)(i.button),onClick:E,children:r("back")}),(0,U.jsx)("button",{type:"submit",className:(0,js.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},rp=of;var ap=require("react/jsx-runtime"),nf=()=>{let t=(0,Ri.useSelector)(jc),e=(0,Ri.useSelector)(nc),o=C("adminUrl"),n=be(),s=()=>n.send(Eo,!1),r=()=>{n.send(Eo,!1),n.send(dn)};return(0,ap.jsx)(rp,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},ip=nf;var Op=k(require("lodash.debounce")),se=require("react"),Ue=require("react-redux");var qs=require("@reduxjs/toolkit");var sf={data:null,fetchState:"idle"},lp=t=>t.contentTypes.data,gn=(0,qs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),rf=(0,qs.createSlice)({name:"contentTypes",initialState:sf,reducers:{},extraReducers:t=>{t.addCase(gn.pending,e=>{e.fetchState="loading"}).addCase(gn.rejected,e=>{e.fetchState="error"}).addCase(gn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),cp=rf.reducer;function mn(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 pp=require("react");function dp(t,e){(0,pp.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 fn=require("react"),Gs=require("react-redux");var Ws=require("@reduxjs/toolkit");var up={data:null,fetchState:"idle"},$s=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},Ne=(0,Ws.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)}),af=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),lf=(0,Ws.createSlice)({name:"entities",initialState:up,reducers:{},extraReducers:t=>{t.addCase(Ne.pending,e=>{e.fetchState="loading"}).addCase(Ne.rejected,e=>{e.fetchState="error"}).addCase(Ne.fulfilled,(e,o)=>{e.fetchState="done",e.data=af(e.data?[...e.data,...o.payload]:o.payload)}).addCase(M,()=>up)}}),gp=lf.reducer;var Pi={};$(Pi,{enUS:()=>cf,nlNL:()=>pf});var cf={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},pf={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var mp={root:"_root_17kae_1",empty:"_empty_17kae_5"};var $t=require("react/jsx-runtime"),df=({onCopy:t,onUse:e})=>{let o=(0,fn.useRef)(null),n=y("EntitiesList",mp),s=T(Pi),r=(0,Gs.useSelector)($s),i=(0,Gs.useDispatch)();return(0,fn.useEffect)(()=>{i(Ne())},[]),(0,fn.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,$t.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,$t.jsx)(P.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,$t.jsx)(P.List,{children:r.map((a,l)=>(0,$t.jsx)(P.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,$t.jsx)("p",{className:n.empty,children:s("noResults")})]})},fp=df;var Oe=require("react"),hn=require("react-redux");var Xs=require("@reduxjs/toolkit");var hp={data:null,fetchState:"idle"},yp=t=>t.summary.data,vp=t=>t.summary.fetchState==="error",nt=(0,Xs.createAsyncThunk)("summary/getSummary",async(t,e)=>{var p,d,g;let o=e.getState().profile.data,n=(p=e.getState().conversation.current)==null?void 0:p.sessionId,s=(g=(d=e.getState().info)==null?void 0:d.agentInfo)==null?void 0:g.agentId;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:i}=e.extra;if(!i.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let a=i.conversationQuery,l=await a();if(l.length===0)return Promise.reject(new Error("No messages are included"));let c=await r.getSummary(l,{externalConversationId:n,agentId:s,promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return c?{summary:c}:Promise.reject(new Error("Summary is not provided"))}),uf=(0,Xs.createSlice)({name:"summary",initialState:hp,reducers:{},extraReducers:t=>{t.addCase(nt.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(nt.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(nt.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(M,()=>hp)}}),Sp=uf.reducer;var Ai={};$(Ai,{enUS:()=>gf,nlNL:()=>mf});var gf={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."}]},mf={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 _p={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 st=require("react/jsx-runtime"),ff=({onCopy:t})=>{let e=(0,Oe.useRef)(null),o=y("SummaryForm",_p),[n,s]=(0,Oe.useState)(""),r=T(Ai),i=(0,hn.useSelector)(yp),a=(0,hn.useSelector)(vp),l=(0,hn.useDispatch)(),c=()=>{l(Q({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(Q({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return(0,Oe.useEffect)(()=>{l(nt())},[]),(0,Oe.useEffect)(()=>{s(i||"")},[i]),(0,Oe.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Oe.useEffect)(()=>{let d=g=>{g.key==="Enter"&&g.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),(0,st.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,st.jsx)("p",{className:o.error,children:r("error")}):(0,st.jsxs)(Oe.Fragment,{children:[(0,st.jsx)("div",{className:o.main,children:(0,st.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,st.jsx)("div",{className:o.actions,children:(0,st.jsx)(P.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},xp=ff;var yn={};$(yn,{enUS:()=>hf,nlNL:()=>yf});var hf={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?"}]},yf={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 Ct=k(require("react")),_n=require("react-redux");var Li={};$(Li,{enUS:()=>vf,nlNL:()=>Sf});var vf={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"}]},Sf={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 bp={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 Ro=require("@reduxjs/toolkit");var Zs=require("@reduxjs/toolkit");var _f={data:null,fetchState:"idle"},Cp=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},vn=(0,Zs.createAsyncThunk)("knowledgeAssistant/getKnowledgeAssistant",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=(i=n.profile.data)==null?void 0:i.knowledgeAssistant;return r?o.getKnowledgeAssistant(r):null}),xf=(0,Zs.createSlice)({name:"knowledgeAssistant",initialState:_f,reducers:{},extraReducers:t=>{t.addCase(vn.pending,e=>{e.fetchState="loading"}).addCase(vn.rejected,e=>{e.fetchState="error"}).addCase(vn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),wp=xf.reducer;var Mi={data:[],fetchState:"idle"},Tp=t=>{var e;return(e=t.answer)==null?void 0:e.data},Ep=t=>t.answer.fetchState,Po=(0,Ro.createAction)("answer/resetKnowledgeSearch"),Io=(0,Ro.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var l,c,p;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=Cp(e.getState()),r=(l=e.getState().conversation.current)==null?void 0:l.sessionId,i=(p=(c=e.getState().info)==null?void 0:c.agentInfo)==null?void 0:p.agentId;if(!s)throw new Error("KnowledgeAssistant is not defined");let a=await o.knowledgeAssist({promptInstruction:s.prompt,question:t},n,s.code,{agentId:i,conversationId:r});return{question:t,answer:a}}),bf=(0,Ro.createSlice)({name:"answer",initialState:Mi,reducers:{},extraReducers:t=>{t.addCase(Io.pending,e=>{e.fetchState="loading"}).addCase(Io.rejected,e=>{e.fetchState="error"}).addCase(Io.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(M,()=>Mi).addCase(Po,()=>Mi)}}),kp=bf.reducer;var Sn=require("react/jsx-runtime"),Ip=()=>(0,Sn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Sn.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Sn.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 ce=require("react/jsx-runtime"),Cf=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=Ct.default.useState(""),{setSelected:r}=St(),i=(0,Ct.useRef)(null),a=y("EntitiesList",bp),l=T(Li),c=(0,_n.useDispatch)(),p=(0,_n.useSelector)(Tp),d=(0,_n.useSelector)(Ep),g=async m=>{m.preventDefault(),m.stopPropagation(),n!==""&&c(Io(n))},u=(m,f)=>{c(Q({name:"knowledge assist source viewed",data:{question:f,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,Ct.useEffect)(()=>{var m;o&&d==="idle"?c(Io(o)):(m=i.current)==null||m.focus()},[i,d]),(0,Ct.useEffect)(()=>{d==="done"&&(c(Q({name:"knowledge assist question answered",data:{question:n||o,sources:p[p.length-1].answer.sources,answer:p[p.length-1].answer.answer,isFollowUpQuestion:p.length>1},options:{includeConversationData:!0}})),r(p.length-1),s(""))},[d,p]),(0,Ct.useEffect)(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,p]),(0,ce.jsxs)("div",{className:a.root,children:[p.length>0&&(0,ce.jsx)("div",{className:a.alignRight,children:(0,ce.jsx)(P.Button,{onClick:e,children:l("reset")})}),(0,ce.jsxs)(P.ActionsBar,{list:p.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:l("use"),onPrimary:m=>t(m.text),children:[p.map(({question:m,answer:f},h)=>(0,ce.jsx)(P.List,{children:(0,ce.jsx)(P.ListItem,{"data-testid":"knowledge-search-answer",index:h,description:f.answer,closeOnSelect:!0,onClick:()=>t(f.answer),onSourceClick:E=>u(E,m),sources:f.sources,styles:{title:a.question,description:a.answer},children:m})},`${f.answer}_${h}`)),d==="loading"&&(0,ce.jsx)("p",{className:a.status,children:l("loading")}),d==="error"&&(0,ce.jsx)("p",{className:a.status,children:l("error")}),(0,ce.jsxs)("form",{className:a.form,onSubmit:g,children:[(0,ce.jsx)("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(-1)},onChange:m=>{r(-1),s(m.target.value)}}),(0,ce.jsx)("button",{type:"submit",className:a.submit,children:(0,ce.jsx)(Ip,{})})]})]})]})},Rp=Cf;var Qs=require("@reduxjs/toolkit");var wf={data:null,fetchState:"idle"},wt=t=>t.profile.data,Js=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],xn=(0,Qs.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)}),Tf=(0,Qs.createSlice)({name:"profile",initialState:wf,reducers:{},extraReducers:t=>{t.addCase(xn.pending,e=>{e.fetchState="loading"}).addCase(xn.rejected,e=>{e.fetchState="error"}).addCase(xn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Pp=Tf.reducer;var Ap=require("react");var Lp=require("react-redux");var Ni=require("react-redux");var Gt=require("react/jsx-runtime"),Ef=({commands:t,onClick:e,onEdit:o})=>{var p,d,g;let n=(0,Lp.useDispatch)(),s=T(yn),r=(0,Ni.useSelector)(wt),i=(0,Ni.useSelector)(xt),a=((g=(d=(p=r==null?void 0:r.uiConfig)==null?void 0:p.search)==null?void 0:d.initialTypes)==null?void 0:g.filter(({isActive:u})=>u))||[],l=0,c=a.map(({type:u})=>{var m;return(m=i[u])==null?void 0:m.suggestions.map(f=>({text:f.text||f.url||f.message,type:u}))}).flat(1);return(0,Ap.useEffect)(()=>{a.forEach(({type:u})=>{(!i[u]||i[u].suggestions.length===0)&&n(Le(u))})},[]),(0,Gt.jsxs)(P.ActionsBar,{list:[...t.map(u=>({text:u.label,type:"command"})),...c],primaryLabel:s("use"),secondaryLabel:s("preview"),onPrimary:({text:u},m)=>e(u,c[m]),onSecondary:(u,m)=>{let f=m-t.length;o(c[f],i[c[f].type].suggestions)},children:[t.length>0&&(0,Gt.jsx)(P.List,{heading:s("commands"),children:t.map((u,m)=>(0,Gt.jsx)(P.ListItem,{index:m,closeOnSelect:!1,onClick:u.onClick,children:u.label},u.label))}),a.map(({type:u,title:m})=>{var f;return(0,Gt.jsx)(P.List,{heading:m,orientation:"vertical",children:(f=i[u])==null?void 0:f.suggestions.map(h=>(l++,(0,Gt.jsx)(P.ListItem,{index:l+t.length-1,closeOnSelect:!1,description:h.text,onClick:()=>e(h.text,h),"data-testid":"search-overlay-suggestion",children:h.title},`${h.id}-${h.text}`)))},u)})]})},Mp=Ef;var V=require("react/jsx-runtime"),kf=200,If=5,Rf=4,Pf=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Np=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Af=()=>{let t=(0,Ue.useDispatch)(),e=be(),o=T(yn),[n,s]=(0,se.useState)(!1),[r,i]=(0,se.useState)(""),a=(0,Ue.useSelector)(lc),l=(0,Ue.useSelector)(wt),[c,p]=(0,se.useState)(null),[d,g]=(0,se.useState)([]),[u,m]=(0,se.useState)(),f=(0,Ue.useSelector)(ne),h=C("showSearch"),E=C("showEntitiesCommand"),x=C("showSummaryCommand"),_=C("showKnowledgeSearch"),b=C("showImageSearch"),v=C("searchTriggerKey"),A=(0,Ue.useSelector)(lp),O=(0,Ue.useSelector)(cc),K=(0,Ue.useSelector)(pc),H=(0,Ue.useSelector)(ac),W=S=>Dn(O.filter(B=>B.type===S.toUpperCase()),S),z=[{value:"PERSONAL",label:o("personalSuggestions"),list:W("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:W("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:W("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:W("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(S=>S.shouldShow),I=[{label:o("entitiesClipboard"),onClick:()=>t(oe("entities")),shouldShow:E&&Np(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(oe("summary")),shouldShow:x&&Np(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(oe("knowledgeAssist")),shouldShow:_}].filter(S=>S.shouldShow),ye=(A==null?void 0:A.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:W(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Mr=(0,se.useCallback)((0,Op.default)((S,B)=>{t(jt({query:S,type:B,tags:["search-overlay"],size:u?50:20}))},kf),[u]),Fo=Pf([...ye,...z]),Ko=(0,se.useCallback)((S,B)=>{t(oe("edit")),p({...S,searchTerm:void 0}),g(B)},[t,c,ye]),to=(0,se.useCallback)((S,B)=>{switch(B.type){case"IMAGE":e.send(Ei,{suggestion:B});break;default:e.send(ot,{text:S,suggestion:B})}t(te(!1))},[t]),sg=S=>{mn(S.text),t(Q({name:"entity copied",data:{entity:S,type:"copy"}})),t(te(!1))},rg=(0,se.useCallback)(S=>{t(Q({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),ig=S=>{e.send(ot,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(Q({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(oe("search")),t(Po()),t(te(!1))},ag=S=>{mn(S),t(te(!1))},lg=S=>{e.send(ot,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(te(!1))},cg=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),pg=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function Dn(S,B){return S.slice(0,u?10:B.toLowerCase()==="image"?Rf:If)}function va(S,B,Ee){return B.reduce((Hn,Bn)=>Ee&&u===Ee?Bn.length+Hn:Dn(Bn,Ee).length+Hn,S)}function oo(S){return B=>{n?window.confirm(o("warning"))&&(S(B),s(!1)):S(B)}}return(0,se.useEffect)(()=>{r?Mr(r,u):t(Ns())},[r,u]),(0,se.useEffect)(()=>{a==="search"&&t(Po())},[a]),(0,se.useEffect)(()=>{f&&t(gn())},[f]),dp(v,()=>t(te(!0))),!h||!l?null:(0,V.jsxs)(P,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:oo(S=>t(te(S))),onChangeType:S=>m(S),onChangePage:oo(S=>t(oe(S))),selectedType:u,search:r,page:a,isOpen:H,types:[...ye,...z],children:[(0,V.jsxs)(P.Page,{id:"search",children:[r.length===0&&(0,V.jsx)(Mp,{commands:I,onClick:to,onEdit:Ko}),r.length>0&&(0,V.jsxs)(P.ActionsBar,{list:[...I.map(S=>({text:S.label,type:"command"})),...Fo.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},B)=>to(S,Fo[B]),onSecondary:(S,B)=>{let Ee=Fo[B-I.length];!Ee||!Ee.type||Ko(Ee,W(Ee.type))},children:[I.length>0&&(0,V.jsx)(P.List,{heading:o("commands"),children:I.map((S,B)=>(0,V.jsx)(P.ListItem,{index:va(B,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...ye,...z].map(({value:S,label:B,list:Ee,lineClamp:Hn,listOrientation:Bn},dg)=>(0,V.jsx)(P.List,{heading:B,orientation:Bn==="horizontal"?"horizontal":"vertical",onShowAll:()=>m(S),hasMore:!u&&K[S.toLowerCase()]>Dn(Ee,S).length,children:Dn(Ee,S).map((ve,ug)=>(0,V.jsx)(P.ListItem,{index:va(I.length+ug,[...ye,...z].slice(0,dg).map(({list:gg})=>gg),S),closeOnSelect:!1,lineClamp:Hn,onClick:()=>to(ve.text,ve),description:S!=="IMAGE"?ve.title&&ve.text:void 0,onFeedback:S!=="IMAGE"?()=>rg(ve):void 0,children:S==="IMAGE"?(0,V.jsx)(P.Image,{title:ve.title||ve.text,src:ve.image}):ve.title||ve.text},`${ve.id}-${ve.text}`))},S))]})]}),(0,V.jsx)(P.Page,{id:"edit",onDismiss:oo(()=>{t(oe("search")),p(null)}),children:c&&(0,V.jsx)(Fs,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(oe("search")),p(null),g([])},onNext:pg,onPrevious:cg,onUse:S=>{t(oe("search")),to(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(te(!1)),g([]),p(null)}})}),(0,V.jsx)(P.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:oo(()=>{t(oe("search"))}),children:(0,V.jsx)(fp,{onUse:lg,onCopy:sg})}),(0,V.jsx)(P.Page,{id:"summary",title:o("summaryTitle"),onDismiss:oo(()=>{t(oe("search"))}),children:(0,V.jsx)(xp,{onCopy:ag})}),(0,V.jsx)(P.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:oo(()=>{t(Po()),t(oe("search"))}),children:(0,V.jsx)(Rp,{question:r,onUse:ig,onResetQuestion:()=>{t(Po()),i("")}})})]})},Dp=Af;var Ao=require("react/jsx-runtime"),Lf=()=>{let t=C("showSearch"),e=C("isEmbedded");return(0,Ao.jsxs)(Hp.Fragment,{children:[t&&(0,Ao.jsx)(Dp,{}),(0,Ao.jsx)(ep,{}),e&&(0,Ao.jsx)(ip,{})]})},Bp=Lf;var zp=k(require("classnames")),jp=require("react-redux");var Ys=require("react/jsx-runtime"),Fp=({className:t})=>(0,Ys.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,Ys.jsx)("g",{children:(0,Ys.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
4
4
  c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
5
5
  c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
6
6
  c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
7
- c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Oi=require("react/jsx-runtime"),Mf={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Kp=({className:t,color:e})=>(0,Oi.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Oi.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:Mf[e||"pink"]})});var Up={root:"_root_1tvv4_1",text:"_text_1tvv4_18",isLoggedIn:"_isLoggedIn_1tvv4_25",isLoggedOut:"_isLoggedOut_1tvv4_29",icon:"_icon_1tvv4_39",logo:"_logo_1tvv4_44",lock:"_lock_1tvv4_49"};var Di={};$(Di,{enUS:()=>Nf,nlNL:()=>Of});var Nf={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Of={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Vp=require("react-redux"),Xt=require("react/jsx-runtime"),qp=({onLogIn:t})=>{let e=T(Di),o=C("floatingMenu"),n=C("productName"),s=(0,Vp.useDispatch)(),r=(0,jp.useSelector)(ne),i=y("FloatingMenu",Up);if(r===null||o===!1)return null;let a=()=>{r===!0?s(te(!0)):t()};return(0,Xt.jsxs)("button",{className:(0,zp.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,Xt.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:n})}),(0,Xt.jsxs)("div",{className:i.icon,children:[(0,Xt.jsx)(Kp,{className:i.logo,color:"pink"}),r===!1&&(0,Xt.jsx)(Fp,{className:i.lock})]})]})};var nr=require("react"),rt=require("react-redux");function Lo(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 tr=require("react");var Xp=require("interweave"),Mo=require("react"),er=require("react-redux");var Wp=require("react");function $p(t,e,o){(0,Wp.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var Gp={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var Zt=require("react/jsx-runtime"),Hf=["search","personal-collection-search","search-autocomplete"];function Bf(t,e,o,n={}){let s="";return Hf.includes(e)?s=Fl(ai(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ai(t,o,n),n.placeholders===!0&&(s=Kl(s)),s}var Ff=()=>{},Kf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=(0,er.useSelector)(lo),i=(0,er.useDispatch)(),a=y("TextSuggestion",Gp),l=(0,Mo.useRef)(null);(0,Mo.useEffect)(()=>{let p=setTimeout(()=>{i(nl({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),$p(l,"click",()=>{i(yt(t)),i(Re({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,Mo.useMemo)(()=>Bf(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,Zt.jsxs)("div",{className:a.root,onMouseEnter:()=>i(yt(t)),children:[(0,Zt.jsx)(L,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Ff,children:(0,Zt.jsx)(Xp.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&(0,Zt.jsx)("div",{className:a.actions,children:(0,Zt.jsx)(Ps,{onFeedback:()=>n(o),suggestion:o.text})})]})},Zp=Kf;var Hi=require("react/jsx-runtime"),Uf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,tr.useMemo)(()=>{let r=e.map((i,a)=>(0,Hi.jsx)(Zp,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,Hi.jsx)(tr.Fragment,{children:s})},or=Uf;var Qp={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var Cn=require("react/jsx-runtime"),zf=({textSuggestions:t,selectedIndex:e})=>{let o=(0,nr.useRef)(null),n=y("InlineSuggestionsOverlay",Qp),s=(0,rt.useSelector)(Lo),r=(0,rt.useDispatch)(),i=(0,rt.useSelector)(ne),a=(0,rt.useSelector)(ao),l=(0,rt.useSelector)(zs),c=C("showTextSuggestions");return fo(()=>{setTimeout(()=>{r(bt({collapse:!0,skipWhenInputFocus:!0}))})}),(0,nr.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,Cn.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,Cn.jsx)("div",{ref:o,className:n.paper,children:(0,Cn.jsx)(ue,{children:(0,Cn.jsx)(or,{suggestions:t,selectedIndex:e})})})})},jf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Jp=(0,rt.connect)(jf)(zf);var Yp=require("react-redux");var wn=require("react/jsx-runtime"),Vf=({children:t})=>{let o=C("locale").replace("-","");return(0,wn.jsx)(Jr.Provider,{value:o,children:t})},qf=({store:t,customStyles:e={},children:o})=>(0,wn.jsx)(Yp.Provider,{store:t,children:(0,wn.jsx)(Vf,{children:(0,wn.jsx)(Uo.Provider,{value:e,children:o})})}),Qt=qf;var rr=k(require("classnames")),No=require("react"),ze=require("react-redux");var ed=require("react");function td(t,e){let[o,n]=(0,ed.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return w.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){w.error(i)}}]}var nd=k(require("classnames")),it=require("react");var Bi={};$(Bi,{enUS:()=>Wf,nlNL:()=>$f});var Wf={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Sign in"}]},{type:0,value:" to enable "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze for "},{type:8,value:"min",children:[{type:0,value:"10 minutes"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 hour"}]},{type:0,value:" or "},{type:8,value:"day",children:[{type:0,value:"1 day"}]}]},$f={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 od={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var Tt=require("react/jsx-runtime"),Fi=(t,e,o)=>n=>(0,Tt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Gf=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=T(Bi),i=be(),a=y("Login",od),l=C("productName"),c=(0,it.useCallback)(h=>{h.preventDefault(),n&&n(parseInt(h.target.value,10))},[]),p=(0,it.useCallback)(h=>{h.preventDefault(),i.send(Eo,!0)},[e]),d=(0,it.useMemo)(()=>h=>(0,Tt.jsx)("a",{onClick:x=>{x.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),g=(0,it.useCallback)(h=>(0,Tt.jsx)("button",{type:"button",className:a.anchorButton,onClick:p,children:h},"prompt"),[p]),{min:u,hour:m,day:f}=(0,it.useMemo)(()=>({min:Fi(a,60*10,c),hour:Fi(a,60*60,c),day:Fi(a,60*60*12,c)}),[]);return(0,Tt.jsxs)("div",{className:(0,nd.default)(t,a.root),children:[r("loginPlease",{login:o?g:d,productName:l}),n&&(0,Tt.jsxs)(it.Fragment,{children:[(0,Tt.jsx)("br",{}),r("snooze",{min:u,hour:m,day:f})]})]})},sr=Gf;var rd=require("react-redux");var sd={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var Tn=require("react/jsx-runtime"),Xf=({title:t})=>{let e=y("SearchTrigger",sd),o=(0,rd.useDispatch)();return(0,Tn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(te(!0)),children:[(0,Tn.jsx)(_o,{}),(0,Tn.jsx)("span",{className:e.text,children:t})]})},id=Xf;var Ki={};$(Ki,{enUS:()=>Zf,nlNL:()=>Qf});var Zf={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"}]},Qf={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 ad={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 F=require("react/jsx-runtime"),Jf=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=y("SuggestionsOverlay",ad),s=T(Ki),r=(0,ze.useSelector)(Lo),i=Ja(),a=(0,ze.useDispatch)(),l=(0,No.useRef)(null),c=C("searchTriggerKey"),p=C("productName"),d=(0,ze.useSelector)(zs),g=(0,ze.useSelector)(ne),u=(0,ze.useSelector)(ao),[m,f]=(0,No.useState)(null),h=C("showSearch"),E=C("showTextSuggestions"),x=C("adminUrl"),_=C("isEmbedded"),[b,v]=td("dd-snooze-until-ms",0),A=d||b>Date.now(),O=(0,ze.useSelector)(I=>I.input.text),K=t.filter(I=>I.source!=="gpt").length,H=()=>{A&&v(0),a(Hc(!A))},W=I=>{a(Q({name:"suggestion feedback",data:{text:I.text,source:"overlay",context:O},options:{includeConversationData:!0}}))},z=I=>{let ye=Date.now()+I*1e3;v(ye),w.info(`Snooze until: ${new Date(ye)}`),a(bt({collapse:!0}))};return(0,No.useEffect)(()=>{K===0&&f(null)},[t,K]),fo(()=>{a(bt({collapse:!0,skipWhenInputFocus:!0}))}),g===null||u===!1?null:g===!1?(0,F.jsxs)("div",{ref:l,className:(0,rr.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1}}),(0,F.jsx)("div",{className:n.triggersRight,children:(0,F.jsx)(Mt,{className:n.toggleButton,title:s("collapse"),onClick:H,isCollapsed:!1})})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(Mt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:H,isCollapsed:!0})}),(0,F.jsx)("div",{className:n.collapsible,children:(0,F.jsx)(sr,{loginUrl:x,isEmbedded:_,onLogIn:o,onSnooze:z})})]}):!i||!r?null:(0,F.jsxs)("div",{ref:l,className:(0,rr.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1},children:h&&(0,F.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(s(Ds()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,F.jsx)(id,{title:s("search")})})}),(0,F.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,F.jsx)("div",{className:(0,rr.default)(!m&&n.hintsHidden,n.hints),children:m}),(0,F.jsx)(Mt,{className:n.toggleButton,title:s("collapse"),onClick:H,isCollapsed:!1})]})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(Mt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:H,isCollapsed:!0})}),K>0&&E&&(0,F.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,F.jsx)(ue,{children:(0,F.jsx)(or,{onFeedback:W,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Yf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),ld=(0,ze.connect)(Yf)(Jf);var vr=k(require("classnames")),kd=require("interweave"),ct=require("react"),Id=require("react-redux");var cd=require("react"),eh=["div","span","mark","strong","b","i","u","em"];function Ui(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(eh.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,cd.cloneElement)(n,{children:Ui(i,e,o+1)})]}return[...t,...e]}function Et(t){return t.tagName.toLowerCase()==="textarea"}var pd={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 Sd=k(require("classnames")),_d=require("interweave"),mr=require("react");function dd(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function ir(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function ud(t){return t!=null}var ji=k(require("classnames")),Ce=require("react");var ar=require("react"),th=["bottom","height","left","right","top","width"],oh=(t={},e={})=>th.some(o=>t[o]!==e[o]),at=new Map,gd,md=()=>{let t=[],e=[];at.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();oh(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{at.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),gd=window.requestAnimationFrame(md)};function nh(t,e){return{observe(){let o=at.size===0;if(at.has(t)){let n=at.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else at.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&md()},unobserve(){let o=at.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||at.delete(t),at.size||cancelAnimationFrame(gd)}}}}function zi(t){let[e,o]=(0,ar.useState)(null);return(0,ar.useLayoutEffect)(()=>{if(!t.current)return;let n=nh(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var Oo=require("react"),hd=require("react-dom");var fd={root:"_root_1jq08_1"};var yd=({children:t})=>{let[e,o]=(0,Oo.useState)(null),n=(0,Oo.useContext)(Uo);return(0,Oo.useLayoutEffect)(()=>{let s=document.createElement("div");return Dt(s),s.classList.add(fd.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,hd.createPortal)(t,e):null};var je={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 lr=require("react/jsx-runtime"),cr=(t=!1)=>{let[e,o]=(0,Ce.useState)(t),n=(0,Ce.useCallback)(()=>o(!0),[]),s=(0,Ce.useCallback)(()=>o(!1),[]),r=(0,Ce.useCallback)(()=>o(a=>!a),[]),i=(0,Ce.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Vi(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 pr=({className:t,triggerRef:e,boundaryRef:o=(0,Ce.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=Vi,...a})=>{let l=zi(e),c=zi(o),p=(0,Ce.useMemo)(()=>i(l,c,0),[l,c]);return(0,lr.jsx)(yd,{children:(0,lr.jsx)("div",{className:(0,ji.default)(je.ref,{[je.positionAbove]:n==="above",[je.positionBelow]:n==="below",[je.positionLeft]:n==="left",[je.positionRight]:n==="right",[je.alignStart]:s==="start",[je.alignCenter]:s==="center",[je.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,lr.jsx)("div",{className:(0,ji.default)(t,je.root),children:r})})})};var vd=k(require("classnames")),dr=require("react");var qi=require("react/jsx-runtime"),ur=(0,dr.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,dr.useRef)(null),r=y("TabCompletion",Ge);return(0,qi.jsx)("div",{ref:ir([s,n]),className:(0,vd.default)(t,r.popoverContentContainer),...o,children:(0,qi.jsx)("div",{className:r.popoverContent,children:e})})});var kt=require("react/jsx-runtime"),sh=t=>e=>{let o=Vi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},rh=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",Ge),i=cr(),a=(0,mr.useMemo)(()=>sh(t.getBoundingClientRect()),[t]),[l,c]=bs(t);return(0,mr.useEffect)(()=>{c?i.open():i.close()},[c]),(0,kt.jsxs)("span",{children:[(0,kt.jsx)("mark",{ref:ir([l,i.triggerRef]),className:(0,Sd.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,kt.jsx)(pr,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,kt.jsx)(ur,{style:o,children:(0,kt.jsx)("div",{className:r.hintText,children:s})})})]})},gr=class extends _d.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${dd(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(ud);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,kt.jsx)(rh,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var hr=k(require("classnames")),Td=require("interweave"),ie=require("react"),Ed=require("react-redux");var Wi=require("react/jsx-runtime"),xd=()=>(0,Wi.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,Wi.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 It=require("react"),En=require("react-redux"),Cd=k(require("lodash.debounce"));var bd={root:"_root_1muu8_1",content:"_content_1muu8_7"};function fr(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 $i(t){return t.replace("https://www.","").replace("https://","")}var we=require("react/jsx-runtime"),ih=3,ah=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),lh=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=ih})=>{let r=y("LinkSearch",bd),[i,a]=(0,It.useState)(""),l=(0,En.useDispatch)(),c=(0,En.useSelector)(Ks("url")),p=(0,En.useSelector)(dc("URL",ah)),[d,g]=(0,It.useState)(p.length-1),u=C("fallbackImage"),m=x=>{let _=x.target;a(_.value)},f=(x,_)=>{x.stopPropagation(),x.preventDefault(),window.open(_,"_blank")},h=x=>{var v;let _=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;x.code==="Escape"&&(a(""),e()),x.code==="ArrowUp"&&g(_),x.code==="ArrowDown"&&g(b),x.code==="Enter"&&t(((v=p[d])==null?void 0:v.text)||i)},E=(0,It.useCallback)((0,Cd.default)(x=>{l(jt({query:x,type:"URL",tags:["link-search"]}))},300),[]);return(0,It.useEffect)(()=>{i&&E(i)},[i]),(0,It.useEffect)(()=>()=>{l(Ns())},[]),(0,we.jsxs)("div",{className:r.root,children:[(0,we.jsx)(ue,{withDivider:!0,children:(i?p:c).slice(0,s).map((x,_)=>(0,we.jsx)(L,{selected:d===_,onClick:()=>t(x.text),"data-testid":"linksearch-suggestion",children:(0,we.jsxs)(D,{children:[(0,we.jsx)(D.Image,{src:fr(x,"small",u||void 0),title:x.title||x.text}),(0,we.jsxs)(D.Content,{className:r.content,cropText:!0,children:[(0,we.jsx)(D.Title,{children:x.title||$i(x.text)}),x.title&&$i(x.text)]}),(0,we.jsx)(L.Actions,{children:(0,we.jsx)(L.ActionButton,{label:n,onClick:b=>f(b,x.text)})})]})},x.text))}),(0,we.jsx)(gn,{value:i,onChange:m,autoFocus:!0,placeholder:o,onKeyUp:h})]})},wd=lh;var Gi={};$(Gi,{enUS:()=>ch,nlNL:()=>ph});var ch={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},ph={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var re=require("react/jsx-runtime"),dh=(0,ie.forwardRef)((t,e)=>{let o=y("TabCompletion",Ge);return(0,re.jsx)("mark",{ref:e,className:(0,hr.default)(o.matchSelection)},"selection-start")}),uh=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(Gi),i=y("TabCompletion",Ge),a=(0,ie.useRef)(null),l=(0,ie.useRef)(null),[c,p]=(0,ie.useState)(null),d=(0,Ed.useDispatch)(),g=cr(document.activeElement===n),[u]=(0,ie.useState)(()=>document.createRange());g.triggerRef.current=u,(0,ie.useEffect)(()=>()=>u.detach(),[]),(0,ie.useEffect)(()=>{let f=t.current,h=a.current;!f||!h||(u.setStart(f,0),u.setEnd(h,0))},[t.current,a.current]),fo(()=>{g.close()});let m=(0,ie.useCallback)(f=>{let h=u.toString(),E=/^http(s?):\/\//.test(f)?f:`https://${f}`;d(os({text:`[${h}](${E})`,replace:"selection"}))},[]);return(0,re.jsxs)("span",{children:[(0,re.jsx)("mark",{ref:a,className:(0,hr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":g.opened?"true":"false",children:s}),g.opened&&(0,re.jsx)(pr,{className:i.popoverRoot,triggerRef:g.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,re.jsxs)(ur,{style:o,ref:l,children:[(0,re.jsx)("div",{className:(0,hr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,re.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,re.jsx)(xd,{}),(0,re.jsx)("span",{children:"\xA0"}),(0,re.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,re.jsx)(wd,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:m,onDismiss:()=>{p(null),g.close()}})]})})]},"selection-end")},yr=class extends Td.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,ie.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,re.jsx)(dh,{ref:this.startRef}):(0,re.jsx)(uh,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Rd=require("react-redux");var lt=require("react/jsx-runtime"),gh=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",pd),p=C("insertLink"),d=C("showMidSentenceSuggestions"),g=C("inlineSuggestions"),u=ws(a),m=(0,ct.useRef)(null),f=(0,Rd.useSelector)(ne);(0,ct.useEffect)(()=>{Et(a)&&u&&Ts(a,u)},[u]);let h=(0,ct.useCallback)(_=>{if(!s||!o)return _;let b=[(0,lt.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,lt.jsx)("span",{"data-testid":"tab-completion",className:(0,vr.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&b.push((0,lt.jsx)("span",{className:(0,vr.default)(c.hint,c.resetIndent),children:(0,lt.jsx)(Vn,{keyCode:"tab"},"tabHint")})),Ui(_,b)},[s,o,n]),E=(0,ct.useMemo)(()=>{let _=[];return p&&_.push(new yr("selection")),_.push(new go("placeholders")),r&&_.push(new gr("keywords")),_},[g,p,r]),x=(0,ct.useMemo)(()=>{let _=window.getComputedStyle(a);return{"--dd-color":_.color,"--dd-font-size":_.fontSize,"--dd-font-family":_.fontFamily,"--dd-font-variant":_.fontVariant}},[]);return!t||!f?null:(0,lt.jsxs)("div",{ref:_=>{_!=null&&_.parentElement&&(m.current=_==null?void 0:_.parentElement)},className:c.root,style:x,children:[(0,lt.jsx)(kd.Interweave,{tagName:"span",containerTagName:"div",className:(0,vr.default)(c.container,c.agentText),disableLineBreaks:Et(a),content:e||"\u200B",onAfterParse:h,matchers:E,selection:u,keywordMatches:i,inputElement:a,inputStyle:x,boundaryRef:m,inlineSuggestionsOnlyAtEnd:!d}),(0,lt.jsx)("br",{})]})},mh=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var f;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??yo(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:g,visible:u,showStyleSuggestions:m}=o;return{showTabHint:p,showStyleSuggestions:m,showTabCompletion:g,content:l,tabText:c,source:a,keywordMatches:((f=n.list)==null?void 0:f.keywordMatches)??[],enabled:u&&d!==!1}},Pd=(0,Id.connect)(mh)(gh);var Cu=k(require("classnames")),wu=require("react"),X=require("react-redux");var Rt=require("@reduxjs/toolkit");var Ad={list:[],fetchState:"idle",isInitialRequest:null},Md=t=>t.autoflows.list||[],Ld=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},pt=(0,Rt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Xi=(0,Rt.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(pt(t.platformSessionId))}),Zi=(0,Rt.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(pt(t.platformSessionId))}),fh=(0,Rt.createSlice)({name:"autoflows",initialState:Ad,reducers:{},extraReducers:t=>{t.addCase(Xi.pending,(e,o)=>{let n=Ld(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Zi.pending,(e,o)=>{let n=Ld(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(pt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(pt.rejected,e=>{e.fetchState="error"}),t.addCase(pt.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(M,()=>Ad)}}),Nd=(0,Rt.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(pt(t))}),s.on("sessionCompleted",()=>{o(pt(t))})}),Od=(0,Rt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Dd=fh.reducer;var Pt=require("@reduxjs/toolkit");var Hd={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Bd=t=>t.customMessages.list,Fd=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Kd=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Ud=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),kn=(0,Pt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Sr=(0,Pt.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)}),_r=(0,Pt.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)}),zd=(0,Pt.createSlice)({name:"customMessages",initialState:Hd,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(kn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(kn.rejected,e=>{e.fetchState="error"}).addCase(kn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Sr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Sr.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(_r.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(_r.rejected,(e,o)=>{let n=e.answeredSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1)),e.answeredSuggestions.splice(n,1)}).addCase(M,()=>Hd)}}),jd=(0,Pt.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(zd.actions.onCustomMessage(r))})}),Vd=(0,Pt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),qd=zd.reducer;var In=require("@reduxjs/toolkit"),hh={token:null,accountUrl:null,interval:null},Wd=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},Qi=(0,In.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),Ji=(0,In.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(Qi()),setInterval(()=>n(Qi()),o)}),$d=(0,In.createSlice)({name:"passwordlessToken",initialState:hh,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Qi.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(Ji.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:Gd}=$d.actions,Xd=$d.reducer;function Zd(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var ru=require("react"),iu=require("react-redux");var ou=k(require("classnames")),nu=require("react");var Jd=k(require("classnames"));var Qd={root:"_root_838fd_1"};var eu=require("react/jsx-runtime"),yh=({className:t,children:e})=>{let o=y("Unicode",Qd);return(0,eu.jsx)("span",{className:(0,Jd.default)(t,o.root),children:e})},Yd=yh;var tu={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 Yi={};$(Yi,{enUS:()=>vh,nlNL:()=>Sh});var vh={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"}]},Sh={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 fe=require("react/jsx-runtime"),xh=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",tu),a=T(Yi),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,fe.jsxs)(L,{className:(0,ou.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,fe.jsx)(D,{children:(0,fe.jsxs)(D.Content,{children:[(0,fe.jsxs)(D.Title,{children:[e&&(0,fe.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,fe.jsx)("span",{children:n})]})}),(0,fe.jsx)(L.Actions,{fixed:e==="Started",children:(0,fe.jsx)(L.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,fe.jsxs)(nu.Fragment,{children:[(0,fe.jsx)(Yd,{children:c})," ",(0,fe.jsx)("span",{children:a(l)})]})})})]})},su=xh;var ea=require("react/jsx-runtime"),bh=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Ch=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,ea.jsx)(ru.Fragment,{children:t.map(s=>(0,ea.jsx)(su,{displayName:s.displayName,description:s.description,disabled:s.isBusy||bh(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),wh=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Th={onStartAutoflow:Xi,onStopAutoflow:Zi},au=(0,iu.connect)(wh,Th)(Ch);var lu=k(require("classnames")),ta=require("react"),Jt=require("react-redux");var dt={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 pe=require("react/jsx-runtime"),Eh=({suggestion:t})=>{let e=T(Ut),o=(0,Jt.useDispatch)(),n=(0,Jt.useSelector)(Fd(t.text)),s=(0,Jt.useSelector)(Kd(t.text)),r=(0,Jt.useSelector)(Ud(t.text)),i=(0,Jt.useSelector)(Gn),{replyOptions:a}=t,l=(0,ta.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Sr({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,ta.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),g=a[d];o(_r({platformSessionId:i,reply:g,suggestion:t}))},[t,n,o,i]);return(0,pe.jsxs)(L,{onClick:l,className:(0,lu.default)(dt.root,{[dt.isUsed]:n,[dt.hasError]:r}),children:[(0,pe.jsx)(D,{children:(0,pe.jsxs)(D.Content,{children:[(0,pe.jsxs)(D.Title,{className:dt.title,children:[t.text," ",(0,pe.jsx)(qn,{className:dt.label,children:"analyse tool"})," ",r&&(0,pe.jsx)("span",{className:dt.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,pe.jsx)("ul",{className:dt.quickReplies,children:a.map(p=>(0,pe.jsx)("li",{className:dt.quickReply,children:p.title},p.title))})]})}),(0,pe.jsxs)(L.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,pe.jsx)(L.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,pe.jsx)(L.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,pe.jsx)(L.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},cu=Eh;var xr=require("react"),du=require("react-redux"),sa=k(require("classnames"));var oa=require("react/jsx-runtime"),na=()=>(0,oa.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,oa.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 pu={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 Ve=require("react/jsx-runtime"),kh=({entities:t})=>{let e=y("EntitiesWidgetList",pu),[o,n]=(0,xr.useState)(void 0),s=(0,du.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),fn(a.text),s(Q({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,xr.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Ve.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Ve.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Ve.jsx)("span",{className:e.entityText,children:a.text}),(0,Ve.jsxs)("span",{className:e.iconWrapper,children:[(0,Ve.jsx)("span",{className:(0,sa.default)(e.icon),children:(0,Ve.jsx)(na,{})}),(0,Ve.jsx)("span",{className:(0,sa.default)(e.icon,o===l&&e.iconClicked),children:(0,Ve.jsx)(na,{})})]})]},a.text))})},uu=kh;var ra=require("react/jsx-runtime"),gu=()=>(0,ra.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,ra.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 ia=require("react/jsx-runtime"),mu=()=>(0,ia.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ia.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 aa=require("react/jsx-runtime"),fu=()=>(0,aa.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,aa.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 br=require("react");var la={};$(la,{enUS:()=>Ih,nlNL:()=>Rh});var Ih={copyCue:[{type:0,value:"Copy"}],copiedCue:[{type:0,value:"Copied!"}],removeCue:[{type:0,value:"Close"}]},Rh={copyCue:[{type:0,value:"Kopieer"}],copiedCue:[{type:0,value:"Gekopieerd!"}],removeCue:[{type:0,value:"Sluiten"}]};var ut=require("react/jsx-runtime"),Ph=({cue:t,onRemove:e,onCopy:o})=>{let n=T(la),[s,r]=(0,br.useState)(!1),i=l=>{l.preventDefault(),l.stopPropagation(),o&&(o(t.text),r(!0))},a=l=>{l.preventDefault(),l.stopPropagation(),e&&e(t.id)};return(0,br.useEffect)(()=>{if(!s)return;let l=setTimeout(()=>{r(!1)},1e3);return()=>{clearTimeout(l)}},[s]),(0,ut.jsx)(L,{"data-testid":"cue",children:(0,ut.jsxs)(D,{children:[(0,ut.jsxs)(D.Content,{children:[t.title&&(0,ut.jsx)(D.Title,{"data-testid":"widget-cue-title",children:t.title}),t.text]}),(0,ut.jsx)(L.Actions,{children:o&&(0,ut.jsx)(L.ActionButton,{primary:!0,onClick:i,label:n(s?"copiedCue":"copyCue")})}),(0,ut.jsx)(D.CloseIcon,{title:n("removeCue"),onClick:a})]})})},hu=Ph;var Rn=require("react/jsx-runtime"),Ah=({cues:t,onCopyCue:e,onRemoveCue:o})=>(0,Rn.jsx)(Rn.Fragment,{children:t.map(n=>(0,Rn.jsx)(hu,{cue:n,onRemove:o,onCopy:e},`${n.id}_${n.timestamp}`))}),yu=Ah;var _u=require("react-redux");var vu=require("react");var he=require("react/jsx-runtime"),Lh=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var g;let s=t.text||t.url||t.message,r=Os(s),i=T(Ut),a=C("showImages"),l=C("fallbackImage"),c=u=>{u.preventDefault(),u.stopPropagation(),n(s)},p=u=>{u.preventDefault(),u.stopPropagation(),o(t)},d=(0,vu.useCallback)(u=>{window.open(r,"_blank"),u.stopPropagation(),u.preventDefault()},[r]);return(0,he.jsxs)(L,{onClick:c,"data-testid":"edit-suggestion",children:[(0,he.jsxs)(D,{children:[a&&t.image&&(0,he.jsx)(D.Image,{src:fr(t,"small",l||void 0),title:t.title}),(0,he.jsxs)(D.Content,{children:[t.title&&(0,he.jsx)(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((g=t.searchKeywords)==null?void 0:g.length)>0&&(0,he.jsx)(L.Labels,{labels:t.searchKeywords}),(0,he.jsx)(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,he.jsxs)(L.Actions,{children:[r&&(0,he.jsx)(L.ActionButton,{onClick:d,label:i("visitUrl")}),(0,he.jsx)(L.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,he.jsx)(L.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Su=Lh;var Pn=require("react/jsx-runtime"),Mh=({contentType:t,lines:e,suggestions:o})=>{let n=be(),s=(0,_u.useSelector)(xt),r=a=>{n.send(wi,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(ot,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,Pn.jsx)(Pn.Fragment,{children:o.map(a=>(0,Pn.jsx)(Su,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},xu=Mh;var ca={};$(ca,{enUS:()=>Nh,nlNL:()=>Oh});var Nh={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},Oh={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var bu={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 R=require("react/jsx-runtime"),Cr=(t,e)=>{let o=(0,X.useSelector)(ne);(0,wu.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},Dh=({onLogIn:t})=>{let e=T(ca),o=(0,X.useDispatch)(),n=C("isEmbedded"),s=y("Widget",bu),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=(0,X.useSelector)(wt),d=(0,X.useSelector)(Js),g=(0,X.useSelector)(Md),u=(0,X.useSelector)(Gc),m=(0,X.useSelector)($s),f=(0,X.useSelector)(Bd),h=(0,X.useSelector)(Xn),E=(0,X.useSelector)(ao),x=(0,X.useSelector)(ne),_=(0,X.useSelector)(Gn),b=(0,X.useSelector)(Zd),v=(0,X.useSelector)(xt),A=be(),O=(0,X.useSelector)(bc),K=(0,X.useSelector)(Wd("/admin/")),H=C("adminUrl"),W=C("productName");if(Cr(()=>(o(kn(_)),o(jd(_)),()=>{o(Vd(_))}),[o,E,i,_]),Cr(()=>(o(pt(_)),o(Nd(_)),()=>{o(Od(_))}),[o,E,r,_]),Cr(()=>{d.forEach(({type:I})=>{o(I==="entities"?Ne():Le(I))})},[o,E,h,p]),Cr(()=>(o(Ji()),()=>{o(Gd())}),[o]),E===!1)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("notSupported")})})},"supported");if(x===!1)return(0,R.jsx)("div",{className:s.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(sr,{isEmbedded:n,loginUrl:H,onLogIn:t})})},"login");if(!p||!_||x===null||O||b)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("waiting")})})},"waiting");let z=c||a||l||K;return(0,R.jsx)("div",{className:(0,Cu.default)(s.root),"data-testid":"widget",children:(0,R.jsxs)(Wn,{className:s.sectionList,children:[z&&(0,R.jsx)(We,{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:()=>A.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(_o,{}),e("linkSearch")]}),a&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>A.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(fu,{}),e("linkSummary")]}),l&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>A.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(mu,{}),e("linkKnowledgeSearch")]}),K&&(0,R.jsxs)("a",{className:s.shortcut,target:"_blank",href:K,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,R.jsx)(gu,{}),e("linkStudioLogin",{productName:W})]})]})}),i&&f.length>0&&(0,R.jsx)(We,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(ue,{withDivider:!0,children:f.map(I=>(0,R.jsx)(cu,{suggestion:I},I.text))})}),r&&g.length>0&&(0,R.jsx)(We,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(ue,{withDivider:!0,children:(0,R.jsx)(au,{})})}),d.map(({type:I,title:ye,amount:Mr,lines:Fo})=>{var Ko;switch(I){case"entities":return m&&m.length>0&&(0,R.jsx)(We,{type:I,title:ye,"data-testid":`type-${I}`,children:(0,R.jsx)(uu,{entities:m})},I);case"cues":return u&&u.length>0&&(0,R.jsx)(We,{type:I,title:ye,"data-testid":`type-${I}`,children:(0,R.jsx)(ue,{withDivider:!0,children:(0,R.jsx)(yu,{cues:u,onRemoveCue:to=>o(Zc({id:to}))})})},I);default:return((Ko=v[I])==null?void 0:Ko.fetchState)==="done"&&v[I].suggestions.length>0&&(0,R.jsx)(We,{type:I,title:ye,"data-testid":`type-${I}`,children:(0,R.jsx)(ue,{withDivider:!0,children:(0,R.jsx)(xu,{lines:Fo,contentType:I,suggestions:v[I].suggestions.slice(0,Mr)||[]})})},I)}})]})})},Tu=Dh;function Do(t){let e=new Range;return e.selectNodeContents(t),e}function Eu(t,e,o){try{return At(t,e,o),!0}catch{return!1}}function wr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Tr(t){return"tagName"in t&&t.tagName==="BR"}var An=/[\u200B-\u200D\uFEFF]/g;function At(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let g=0;g<=l.length;g++)if(d.test(l[g])||p++,p===c)return g;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(An,""),d=s+p.length,g=e>=s&&e<=d,u=o>=s&&o<=d;if(g){let m=i(c,e-s);m===0&&!u?n.setStartBefore(l):n.setStart(l,m)}u&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(Tr(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;wr(l)&&c&&!wr(c)&&!Tr(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function Ln(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(d){let g=d===o,u=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let m=d.textContent;g&&(a=c+m.substring(0,n).replace(An,"").length),u&&(l=c+m.substring(0,r).replace(An,"").length),c+=m.replace(An,"").length;break}case Node.ELEMENT_NODE:{let m=d.nextSibling===null;Tr(d)&&!m&&c++;for(let f=0;f<d.childNodes.length;f++){let h=g&&f===n,E=u&&f===r;if(h&&(a=c),E&&(l=c),l!==void 0||((!h||!i)&&p(d.childNodes[f]),u&&f===r-1&&(l=c),l!==void 0))break}!u&&wr(d)&&!m&&c++,u&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function Mn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let g=p?n:0,u=d?r:void 0,m=c.textContent.replace(An,"");g===0&&u===void 0?a+=m:a+=m.substring(g,u);break}case Node.ELEMENT_NODE:{let g=c.nextSibling===null;i===0&&Tr(c)&&!g&&(a+=`
7
+ c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Oi=require("react/jsx-runtime"),Mf={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Kp=({className:t,color:e})=>(0,Oi.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Oi.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:Mf[e||"pink"]})});var Up={root:"_root_1tvv4_1",text:"_text_1tvv4_18",isLoggedIn:"_isLoggedIn_1tvv4_25",isLoggedOut:"_isLoggedOut_1tvv4_29",icon:"_icon_1tvv4_39",logo:"_logo_1tvv4_44",lock:"_lock_1tvv4_49"};var Di={};$(Di,{enUS:()=>Nf,nlNL:()=>Of});var Nf={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Of={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Vp=require("react-redux"),Xt=require("react/jsx-runtime"),qp=({onLogIn:t})=>{let e=T(Di),o=C("floatingMenu"),n=C("productName"),s=(0,Vp.useDispatch)(),r=(0,jp.useSelector)(ne),i=y("FloatingMenu",Up);if(r===null||o===!1)return null;let a=()=>{r===!0?s(te(!0)):t()};return(0,Xt.jsxs)("button",{className:(0,zp.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,Xt.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:n})}),(0,Xt.jsxs)("div",{className:i.icon,children:[(0,Xt.jsx)(Kp,{className:i.logo,color:"pink"}),r===!1&&(0,Xt.jsx)(Fp,{className:i.lock})]})]})};var nr=require("react"),rt=require("react-redux");function Lo(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 tr=require("react");var Xp=require("interweave"),Mo=require("react"),er=require("react-redux");var Wp=require("react");function $p(t,e,o){(0,Wp.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var Gp={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var Zt=require("react/jsx-runtime"),Hf=["search","personal-collection-search","search-autocomplete"];function Bf(t,e,o,n={}){let s="";return Hf.includes(e)?s=Fl(ai(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ai(t,o,n),n.placeholders===!0&&(s=Kl(s)),s}var Ff=()=>{},Kf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=(0,er.useSelector)(lo),i=(0,er.useDispatch)(),a=y("TextSuggestion",Gp),l=(0,Mo.useRef)(null);(0,Mo.useEffect)(()=>{let p=setTimeout(()=>{i(nl({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),$p(l,"click",()=>{i(yt(t)),i(Re({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,Mo.useMemo)(()=>Bf(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,Zt.jsxs)("div",{className:a.root,onMouseEnter:()=>i(yt(t)),children:[(0,Zt.jsx)(L,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Ff,children:(0,Zt.jsx)(Xp.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&(0,Zt.jsx)("div",{className:a.actions,children:(0,Zt.jsx)(Ps,{onFeedback:()=>n(o),suggestion:o.text})})]})},Zp=Kf;var Hi=require("react/jsx-runtime"),Uf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,tr.useMemo)(()=>{let r=e.map((i,a)=>(0,Hi.jsx)(Zp,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,Hi.jsx)(tr.Fragment,{children:s})},or=Uf;var Qp={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var bn=require("react/jsx-runtime"),zf=({textSuggestions:t,selectedIndex:e})=>{let o=(0,nr.useRef)(null),n=y("InlineSuggestionsOverlay",Qp),s=(0,rt.useSelector)(Lo),r=(0,rt.useDispatch)(),i=(0,rt.useSelector)(ne),a=(0,rt.useSelector)(ao),l=(0,rt.useSelector)(zs),c=C("showTextSuggestions");return fo(()=>{setTimeout(()=>{r(bt({collapse:!0,skipWhenInputFocus:!0}))})}),(0,nr.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,bn.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,bn.jsx)("div",{ref:o,className:n.paper,children:(0,bn.jsx)(ue,{children:(0,bn.jsx)(or,{suggestions:t,selectedIndex:e})})})})},jf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Jp=(0,rt.connect)(jf)(zf);var Yp=require("react-redux");var Cn=require("react/jsx-runtime"),Vf=({children:t})=>{let o=C("locale").replace("-","");return(0,Cn.jsx)(Jr.Provider,{value:o,children:t})},qf=({store:t,customStyles:e={},children:o})=>(0,Cn.jsx)(Yp.Provider,{store:t,children:(0,Cn.jsx)(Vf,{children:(0,Cn.jsx)(Uo.Provider,{value:e,children:o})})}),Qt=qf;var rr=k(require("classnames")),No=require("react"),ze=require("react-redux");var ed=require("react");function td(t,e){let[o,n]=(0,ed.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return w.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){w.error(i)}}]}var nd=k(require("classnames")),it=require("react");var Bi={};$(Bi,{enUS:()=>Wf,nlNL:()=>$f});var Wf={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Sign in"}]},{type:0,value:" to enable "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze for "},{type:8,value:"min",children:[{type:0,value:"10 minutes"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 hour"}]},{type:0,value:" or "},{type:8,value:"day",children:[{type:0,value:"1 day"}]}]},$f={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 od={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var Tt=require("react/jsx-runtime"),Fi=(t,e,o)=>n=>(0,Tt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Gf=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=T(Bi),i=be(),a=y("Login",od),l=C("productName"),c=(0,it.useCallback)(h=>{h.preventDefault(),n&&n(parseInt(h.target.value,10))},[]),p=(0,it.useCallback)(h=>{h.preventDefault(),i.send(Eo,!0)},[e]),d=(0,it.useMemo)(()=>h=>(0,Tt.jsx)("a",{onClick:x=>{x.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),g=(0,it.useCallback)(h=>(0,Tt.jsx)("button",{type:"button",className:a.anchorButton,onClick:p,children:h},"prompt"),[p]),{min:u,hour:m,day:f}=(0,it.useMemo)(()=>({min:Fi(a,60*10,c),hour:Fi(a,60*60,c),day:Fi(a,60*60*12,c)}),[]);return(0,Tt.jsxs)("div",{className:(0,nd.default)(t,a.root),children:[r("loginPlease",{login:o?g:d,productName:l}),n&&(0,Tt.jsxs)(it.Fragment,{children:[(0,Tt.jsx)("br",{}),r("snooze",{min:u,hour:m,day:f})]})]})},sr=Gf;var rd=require("react-redux");var sd={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var wn=require("react/jsx-runtime"),Xf=({title:t})=>{let e=y("SearchTrigger",sd),o=(0,rd.useDispatch)();return(0,wn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(te(!0)),children:[(0,wn.jsx)(_o,{}),(0,wn.jsx)("span",{className:e.text,children:t})]})},id=Xf;var Ki={};$(Ki,{enUS:()=>Zf,nlNL:()=>Qf});var Zf={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"}]},Qf={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 ad={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 F=require("react/jsx-runtime"),Jf=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=y("SuggestionsOverlay",ad),s=T(Ki),r=(0,ze.useSelector)(Lo),i=Ja(),a=(0,ze.useDispatch)(),l=(0,No.useRef)(null),c=C("searchTriggerKey"),p=C("productName"),d=(0,ze.useSelector)(zs),g=(0,ze.useSelector)(ne),u=(0,ze.useSelector)(ao),[m,f]=(0,No.useState)(null),h=C("showSearch"),E=C("showTextSuggestions"),x=C("adminUrl"),_=C("isEmbedded"),[b,v]=td("dd-snooze-until-ms",0),A=d||b>Date.now(),O=(0,ze.useSelector)(I=>I.input.text),K=t.filter(I=>I.source!=="gpt").length,H=()=>{A&&v(0),a(Hc(!A))},W=I=>{a(Q({name:"suggestion feedback",data:{text:I.text,source:"overlay",context:O},options:{includeConversationData:!0}}))},z=I=>{let ye=Date.now()+I*1e3;v(ye),w.info(`Snooze until: ${new Date(ye)}`),a(bt({collapse:!0}))};return(0,No.useEffect)(()=>{K===0&&f(null)},[t,K]),fo(()=>{a(bt({collapse:!0,skipWhenInputFocus:!0}))}),g===null||u===!1?null:g===!1?(0,F.jsxs)("div",{ref:l,className:(0,rr.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1}}),(0,F.jsx)("div",{className:n.triggersRight,children:(0,F.jsx)(Mt,{className:n.toggleButton,title:s("collapse"),onClick:H,isCollapsed:!1})})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(Mt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:H,isCollapsed:!0})}),(0,F.jsx)("div",{className:n.collapsible,children:(0,F.jsx)(sr,{loginUrl:x,isEmbedded:_,onLogIn:o,onSnooze:z})})]}):!i||!r?null:(0,F.jsxs)("div",{ref:l,className:(0,rr.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1},children:h&&(0,F.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(s(Ds()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,F.jsx)(id,{title:s("search")})})}),(0,F.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,F.jsx)("div",{className:(0,rr.default)(!m&&n.hintsHidden,n.hints),children:m}),(0,F.jsx)(Mt,{className:n.toggleButton,title:s("collapse"),onClick:H,isCollapsed:!1})]})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(Mt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:H,isCollapsed:!0})}),K>0&&E&&(0,F.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,F.jsx)(ue,{children:(0,F.jsx)(or,{onFeedback:W,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Yf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),ld=(0,ze.connect)(Yf)(Jf);var vr=k(require("classnames")),kd=require("interweave"),ct=require("react"),Id=require("react-redux");var cd=require("react"),eh=["div","span","mark","strong","b","i","u","em"];function Ui(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(eh.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,cd.cloneElement)(n,{children:Ui(i,e,o+1)})]}return[...t,...e]}function Et(t){return t.tagName.toLowerCase()==="textarea"}var pd={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 Sd=k(require("classnames")),_d=require("interweave"),mr=require("react");function dd(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function ir(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function ud(t){return t!=null}var ji=k(require("classnames")),Ce=require("react");var ar=require("react"),th=["bottom","height","left","right","top","width"],oh=(t={},e={})=>th.some(o=>t[o]!==e[o]),at=new Map,gd,md=()=>{let t=[],e=[];at.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();oh(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{at.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),gd=window.requestAnimationFrame(md)};function nh(t,e){return{observe(){let o=at.size===0;if(at.has(t)){let n=at.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else at.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&md()},unobserve(){let o=at.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||at.delete(t),at.size||cancelAnimationFrame(gd)}}}}function zi(t){let[e,o]=(0,ar.useState)(null);return(0,ar.useLayoutEffect)(()=>{if(!t.current)return;let n=nh(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var Oo=require("react"),hd=require("react-dom");var fd={root:"_root_1jq08_1"};var yd=({children:t})=>{let[e,o]=(0,Oo.useState)(null),n=(0,Oo.useContext)(Uo);return(0,Oo.useLayoutEffect)(()=>{let s=document.createElement("div");return Dt(s),s.classList.add(fd.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,hd.createPortal)(t,e):null};var je={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 lr=require("react/jsx-runtime"),cr=(t=!1)=>{let[e,o]=(0,Ce.useState)(t),n=(0,Ce.useCallback)(()=>o(!0),[]),s=(0,Ce.useCallback)(()=>o(!1),[]),r=(0,Ce.useCallback)(()=>o(a=>!a),[]),i=(0,Ce.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Vi(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 pr=({className:t,triggerRef:e,boundaryRef:o=(0,Ce.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=Vi,...a})=>{let l=zi(e),c=zi(o),p=(0,Ce.useMemo)(()=>i(l,c,0),[l,c]);return(0,lr.jsx)(yd,{children:(0,lr.jsx)("div",{className:(0,ji.default)(je.ref,{[je.positionAbove]:n==="above",[je.positionBelow]:n==="below",[je.positionLeft]:n==="left",[je.positionRight]:n==="right",[je.alignStart]:s==="start",[je.alignCenter]:s==="center",[je.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,lr.jsx)("div",{className:(0,ji.default)(t,je.root),children:r})})})};var vd=k(require("classnames")),dr=require("react");var qi=require("react/jsx-runtime"),ur=(0,dr.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,dr.useRef)(null),r=y("TabCompletion",Ge);return(0,qi.jsx)("div",{ref:ir([s,n]),className:(0,vd.default)(t,r.popoverContentContainer),...o,children:(0,qi.jsx)("div",{className:r.popoverContent,children:e})})});var kt=require("react/jsx-runtime"),sh=t=>e=>{let o=Vi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},rh=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",Ge),i=cr(),a=(0,mr.useMemo)(()=>sh(t.getBoundingClientRect()),[t]),[l,c]=bs(t);return(0,mr.useEffect)(()=>{c?i.open():i.close()},[c]),(0,kt.jsxs)("span",{children:[(0,kt.jsx)("mark",{ref:ir([l,i.triggerRef]),className:(0,Sd.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,kt.jsx)(pr,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,kt.jsx)(ur,{style:o,children:(0,kt.jsx)("div",{className:r.hintText,children:s})})})]})},gr=class extends _d.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${dd(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(ud);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,kt.jsx)(rh,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var hr=k(require("classnames")),Td=require("interweave"),ie=require("react"),Ed=require("react-redux");var Wi=require("react/jsx-runtime"),xd=()=>(0,Wi.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,Wi.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 It=require("react"),Tn=require("react-redux"),Cd=k(require("lodash.debounce"));var bd={root:"_root_1muu8_1",content:"_content_1muu8_7"};function fr(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 $i(t){return t.replace("https://www.","").replace("https://","")}var we=require("react/jsx-runtime"),ih=3,ah=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),lh=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=ih})=>{let r=y("LinkSearch",bd),[i,a]=(0,It.useState)(""),l=(0,Tn.useDispatch)(),c=(0,Tn.useSelector)(Ks("url")),p=(0,Tn.useSelector)(dc("URL",ah)),[d,g]=(0,It.useState)(p.length-1),u=C("fallbackImage"),m=x=>{let _=x.target;a(_.value)},f=(x,_)=>{x.stopPropagation(),x.preventDefault(),window.open(_,"_blank")},h=x=>{var v;let _=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;x.code==="Escape"&&(a(""),e()),x.code==="ArrowUp"&&g(_),x.code==="ArrowDown"&&g(b),x.code==="Enter"&&t(((v=p[d])==null?void 0:v.text)||i)},E=(0,It.useCallback)((0,Cd.default)(x=>{l(jt({query:x,type:"URL",tags:["link-search"]}))},300),[]);return(0,It.useEffect)(()=>{i&&E(i)},[i]),(0,It.useEffect)(()=>()=>{l(Ns())},[]),(0,we.jsxs)("div",{className:r.root,children:[(0,we.jsx)(ue,{withDivider:!0,children:(i?p:c).slice(0,s).map((x,_)=>(0,we.jsx)(L,{selected:d===_,onClick:()=>t(x.text),"data-testid":"linksearch-suggestion",children:(0,we.jsxs)(D,{children:[(0,we.jsx)(D.Image,{src:fr(x,"small",u||void 0),title:x.title||x.text}),(0,we.jsxs)(D.Content,{className:r.content,cropText:!0,children:[(0,we.jsx)(D.Title,{children:x.title||$i(x.text)}),x.title&&$i(x.text)]}),(0,we.jsx)(L.Actions,{children:(0,we.jsx)(L.ActionButton,{label:n,onClick:b=>f(b,x.text)})})]})},x.text))}),(0,we.jsx)(un,{value:i,onChange:m,autoFocus:!0,placeholder:o,onKeyUp:h})]})},wd=lh;var Gi={};$(Gi,{enUS:()=>ch,nlNL:()=>ph});var ch={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},ph={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var re=require("react/jsx-runtime"),dh=(0,ie.forwardRef)((t,e)=>{let o=y("TabCompletion",Ge);return(0,re.jsx)("mark",{ref:e,className:(0,hr.default)(o.matchSelection)},"selection-start")}),uh=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(Gi),i=y("TabCompletion",Ge),a=(0,ie.useRef)(null),l=(0,ie.useRef)(null),[c,p]=(0,ie.useState)(null),d=(0,Ed.useDispatch)(),g=cr(document.activeElement===n),[u]=(0,ie.useState)(()=>document.createRange());g.triggerRef.current=u,(0,ie.useEffect)(()=>()=>u.detach(),[]),(0,ie.useEffect)(()=>{let f=t.current,h=a.current;!f||!h||(u.setStart(f,0),u.setEnd(h,0))},[t.current,a.current]),fo(()=>{g.close()});let m=(0,ie.useCallback)(f=>{let h=u.toString(),E=/^http(s?):\/\//.test(f)?f:`https://${f}`;d(os({text:`[${h}](${E})`,replace:"selection"}))},[]);return(0,re.jsxs)("span",{children:[(0,re.jsx)("mark",{ref:a,className:(0,hr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":g.opened?"true":"false",children:s}),g.opened&&(0,re.jsx)(pr,{className:i.popoverRoot,triggerRef:g.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,re.jsxs)(ur,{style:o,ref:l,children:[(0,re.jsx)("div",{className:(0,hr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,re.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,re.jsx)(xd,{}),(0,re.jsx)("span",{children:"\xA0"}),(0,re.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,re.jsx)(wd,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:m,onDismiss:()=>{p(null),g.close()}})]})})]},"selection-end")},yr=class extends Td.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,ie.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,re.jsx)(dh,{ref:this.startRef}):(0,re.jsx)(uh,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Rd=require("react-redux");var lt=require("react/jsx-runtime"),gh=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",pd),p=C("insertLink"),d=C("showMidSentenceSuggestions"),g=C("inlineSuggestions"),u=ws(a),m=(0,ct.useRef)(null),f=(0,Rd.useSelector)(ne);(0,ct.useEffect)(()=>{Et(a)&&u&&Ts(a,u)},[u]);let h=(0,ct.useCallback)(_=>{if(!s||!o)return _;let b=[(0,lt.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,lt.jsx)("span",{"data-testid":"tab-completion",className:(0,vr.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&b.push((0,lt.jsx)("span",{className:(0,vr.default)(c.hint,c.resetIndent),children:(0,lt.jsx)(jn,{keyCode:"tab"},"tabHint")})),Ui(_,b)},[s,o,n]),E=(0,ct.useMemo)(()=>{let _=[];return p&&_.push(new yr("selection")),_.push(new go("placeholders")),r&&_.push(new gr("keywords")),_},[g,p,r]),x=(0,ct.useMemo)(()=>{let _=window.getComputedStyle(a);return{"--dd-color":_.color,"--dd-font-size":_.fontSize,"--dd-font-family":_.fontFamily,"--dd-font-variant":_.fontVariant}},[]);return!t||!f?null:(0,lt.jsxs)("div",{ref:_=>{_!=null&&_.parentElement&&(m.current=_==null?void 0:_.parentElement)},className:c.root,style:x,children:[(0,lt.jsx)(kd.Interweave,{tagName:"span",containerTagName:"div",className:(0,vr.default)(c.container,c.agentText),disableLineBreaks:Et(a),content:e||"\u200B",onAfterParse:h,matchers:E,selection:u,keywordMatches:i,inputElement:a,inputStyle:x,boundaryRef:m,inlineSuggestionsOnlyAtEnd:!d}),(0,lt.jsx)("br",{})]})},mh=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var f;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??yo(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:g,visible:u,showStyleSuggestions:m}=o;return{showTabHint:p,showStyleSuggestions:m,showTabCompletion:g,content:l,tabText:c,source:a,keywordMatches:((f=n.list)==null?void 0:f.keywordMatches)??[],enabled:u&&d!==!1}},Pd=(0,Id.connect)(mh)(gh);var Cu=k(require("classnames")),wu=require("react"),X=require("react-redux");var Rt=require("@reduxjs/toolkit");var Ad={list:[],fetchState:"idle",isInitialRequest:null},Md=t=>t.autoflows.list||[],Ld=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},pt=(0,Rt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Xi=(0,Rt.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(pt(t.platformSessionId))}),Zi=(0,Rt.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(pt(t.platformSessionId))}),fh=(0,Rt.createSlice)({name:"autoflows",initialState:Ad,reducers:{},extraReducers:t=>{t.addCase(Xi.pending,(e,o)=>{let n=Ld(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Zi.pending,(e,o)=>{let n=Ld(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(pt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(pt.rejected,e=>{e.fetchState="error"}),t.addCase(pt.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(M,()=>Ad)}}),Nd=(0,Rt.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(pt(t))}),s.on("sessionCompleted",()=>{o(pt(t))})}),Od=(0,Rt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Dd=fh.reducer;var Pt=require("@reduxjs/toolkit");var Hd={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Bd=t=>t.customMessages.list,Fd=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Kd=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Ud=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),En=(0,Pt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Sr=(0,Pt.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)}),_r=(0,Pt.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)}),zd=(0,Pt.createSlice)({name:"customMessages",initialState:Hd,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(En.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(En.rejected,e=>{e.fetchState="error"}).addCase(En.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Sr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Sr.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(_r.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(_r.rejected,(e,o)=>{let n=e.answeredSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1)),e.answeredSuggestions.splice(n,1)}).addCase(M,()=>Hd)}}),jd=(0,Pt.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(zd.actions.onCustomMessage(r))})}),Vd=(0,Pt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),qd=zd.reducer;var kn=require("@reduxjs/toolkit"),hh={token:null,accountUrl:null,interval:null},Wd=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},Qi=(0,kn.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),Ji=(0,kn.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(Qi()),setInterval(()=>n(Qi()),o)}),$d=(0,kn.createSlice)({name:"passwordlessToken",initialState:hh,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Qi.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(Ji.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:Gd}=$d.actions,Xd=$d.reducer;function Zd(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var ru=require("react"),iu=require("react-redux");var ou=k(require("classnames")),nu=require("react");var Jd=k(require("classnames"));var Qd={root:"_root_838fd_1"};var eu=require("react/jsx-runtime"),yh=({className:t,children:e})=>{let o=y("Unicode",Qd);return(0,eu.jsx)("span",{className:(0,Jd.default)(t,o.root),children:e})},Yd=yh;var tu={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 Yi={};$(Yi,{enUS:()=>vh,nlNL:()=>Sh});var vh={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"}]},Sh={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 fe=require("react/jsx-runtime"),xh=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",tu),a=T(Yi),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,fe.jsxs)(L,{className:(0,ou.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,fe.jsx)(D,{children:(0,fe.jsxs)(D.Content,{children:[(0,fe.jsxs)(D.Title,{children:[e&&(0,fe.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,fe.jsx)("span",{children:n})]})}),(0,fe.jsx)(L.Actions,{fixed:e==="Started",children:(0,fe.jsx)(L.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,fe.jsxs)(nu.Fragment,{children:[(0,fe.jsx)(Yd,{children:c})," ",(0,fe.jsx)("span",{children:a(l)})]})})})]})},su=xh;var ea=require("react/jsx-runtime"),bh=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Ch=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,ea.jsx)(ru.Fragment,{children:t.map(s=>(0,ea.jsx)(su,{displayName:s.displayName,description:s.description,disabled:s.isBusy||bh(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),wh=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Th={onStartAutoflow:Xi,onStopAutoflow:Zi},au=(0,iu.connect)(wh,Th)(Ch);var lu=k(require("classnames")),ta=require("react"),Jt=require("react-redux");var dt={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 pe=require("react/jsx-runtime"),Eh=({suggestion:t})=>{let e=T(Ut),o=(0,Jt.useDispatch)(),n=(0,Jt.useSelector)(Fd(t.text)),s=(0,Jt.useSelector)(Kd(t.text)),r=(0,Jt.useSelector)(Ud(t.text)),i=(0,Jt.useSelector)(Gn),{replyOptions:a}=t,l=(0,ta.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Sr({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,ta.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),g=a[d];o(_r({platformSessionId:i,reply:g,suggestion:t}))},[t,n,o,i]);return(0,pe.jsxs)(L,{onClick:l,className:(0,lu.default)(dt.root,{[dt.isUsed]:n,[dt.hasError]:r}),children:[(0,pe.jsx)(D,{children:(0,pe.jsxs)(D.Content,{children:[(0,pe.jsxs)(D.Title,{className:dt.title,children:[t.text," ",(0,pe.jsx)(Vn,{className:dt.label,children:"analyse tool"})," ",r&&(0,pe.jsx)("span",{className:dt.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,pe.jsx)("ul",{className:dt.quickReplies,children:a.map(p=>(0,pe.jsx)("li",{className:dt.quickReply,children:p.title},p.title))})]})}),(0,pe.jsxs)(L.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,pe.jsx)(L.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,pe.jsx)(L.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,pe.jsx)(L.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},cu=Eh;var xr=require("react"),du=require("react-redux"),sa=k(require("classnames"));var oa=require("react/jsx-runtime"),na=()=>(0,oa.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,oa.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 pu={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 Ve=require("react/jsx-runtime"),kh=({entities:t})=>{let e=y("EntitiesWidgetList",pu),[o,n]=(0,xr.useState)(void 0),s=(0,du.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),mn(a.text),s(Q({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,xr.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Ve.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Ve.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Ve.jsx)("span",{className:e.entityText,children:a.text}),(0,Ve.jsxs)("span",{className:e.iconWrapper,children:[(0,Ve.jsx)("span",{className:(0,sa.default)(e.icon),children:(0,Ve.jsx)(na,{})}),(0,Ve.jsx)("span",{className:(0,sa.default)(e.icon,o===l&&e.iconClicked),children:(0,Ve.jsx)(na,{})})]})]},a.text))})},uu=kh;var ra=require("react/jsx-runtime"),gu=()=>(0,ra.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,ra.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 ia=require("react/jsx-runtime"),mu=()=>(0,ia.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ia.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 aa=require("react/jsx-runtime"),fu=()=>(0,aa.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,aa.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 br=require("react");var la={};$(la,{enUS:()=>Ih,nlNL:()=>Rh});var Ih={copyCue:[{type:0,value:"Copy"}],copiedCue:[{type:0,value:"Copied!"}],removeCue:[{type:0,value:"Close"}]},Rh={copyCue:[{type:0,value:"Kopieer"}],copiedCue:[{type:0,value:"Gekopieerd!"}],removeCue:[{type:0,value:"Sluiten"}]};var ut=require("react/jsx-runtime"),Ph=({cue:t,onRemove:e,onCopy:o})=>{let n=T(la),[s,r]=(0,br.useState)(!1),i=l=>{l.preventDefault(),l.stopPropagation(),o&&(o(t.text),r(!0))},a=l=>{l.preventDefault(),l.stopPropagation(),e&&e(t.id)};return(0,br.useEffect)(()=>{if(!s)return;let l=setTimeout(()=>{r(!1)},1e3);return()=>{clearTimeout(l)}},[s]),(0,ut.jsx)(L,{"data-testid":"cue",children:(0,ut.jsxs)(D,{children:[(0,ut.jsxs)(D.Content,{children:[t.title&&(0,ut.jsx)(D.Title,{"data-testid":"widget-cue-title",children:t.title}),t.text]}),(0,ut.jsx)(L.Actions,{children:o&&(0,ut.jsx)(L.ActionButton,{primary:!0,onClick:i,label:n(s?"copiedCue":"copyCue")})}),(0,ut.jsx)(D.CloseIcon,{title:n("removeCue"),onClick:a})]})})},hu=Ph;var In=require("react/jsx-runtime"),Ah=({cues:t,onCopyCue:e,onRemoveCue:o})=>(0,In.jsx)(In.Fragment,{children:t.map(n=>(0,In.jsx)(hu,{cue:n,onRemove:o,onCopy:e},`${n.id}_${n.timestamp}`))}),yu=Ah;var _u=require("react-redux");var vu=require("react");var he=require("react/jsx-runtime"),Lh=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var g;let s=t.text||t.url||t.message,r=Os(s),i=T(Ut),a=C("showImages"),l=C("fallbackImage"),c=u=>{u.preventDefault(),u.stopPropagation(),n(s)},p=u=>{u.preventDefault(),u.stopPropagation(),o(t)},d=(0,vu.useCallback)(u=>{window.open(r,"_blank"),u.stopPropagation(),u.preventDefault()},[r]);return(0,he.jsxs)(L,{onClick:c,"data-testid":"edit-suggestion",children:[(0,he.jsxs)(D,{children:[a&&t.image&&(0,he.jsx)(D.Image,{src:fr(t,"small",l||void 0),title:t.title}),(0,he.jsxs)(D.Content,{children:[t.title&&(0,he.jsx)(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((g=t.searchKeywords)==null?void 0:g.length)>0&&(0,he.jsx)(L.Labels,{labels:t.searchKeywords}),(0,he.jsx)(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,he.jsxs)(L.Actions,{children:[r&&(0,he.jsx)(L.ActionButton,{onClick:d,label:i("visitUrl")}),(0,he.jsx)(L.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,he.jsx)(L.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Su=Lh;var Rn=require("react/jsx-runtime"),Mh=({contentType:t,lines:e,suggestions:o})=>{let n=be(),s=(0,_u.useSelector)(xt),r=a=>{n.send(wi,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(ot,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,Rn.jsx)(Rn.Fragment,{children:o.map(a=>(0,Rn.jsx)(Su,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},xu=Mh;var ca={};$(ca,{enUS:()=>Nh,nlNL:()=>Oh});var Nh={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},Oh={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var bu={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 R=require("react/jsx-runtime"),Cr=(t,e)=>{let o=(0,X.useSelector)(ne);(0,wu.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},Dh=({onLogIn:t})=>{let e=T(ca),o=(0,X.useDispatch)(),n=C("isEmbedded"),s=y("Widget",bu),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=(0,X.useSelector)(wt),d=(0,X.useSelector)(Js),g=(0,X.useSelector)(Md),u=(0,X.useSelector)(Gc),m=(0,X.useSelector)($s),f=(0,X.useSelector)(Bd),h=(0,X.useSelector)(Xn),E=(0,X.useSelector)(ao),x=(0,X.useSelector)(ne),_=(0,X.useSelector)(Gn),b=(0,X.useSelector)(Zd),v=(0,X.useSelector)(xt),A=be(),O=(0,X.useSelector)(bc),K=(0,X.useSelector)(Wd("/admin/")),H=C("adminUrl"),W=C("productName");if(Cr(()=>(o(En(_)),o(jd(_)),()=>{o(Vd(_))}),[o,E,i,_]),Cr(()=>(o(pt(_)),o(Nd(_)),()=>{o(Od(_))}),[o,E,r,_]),Cr(()=>{d.forEach(({type:I})=>{o(I==="entities"?Ne():Le(I))})},[o,E,h,p]),Cr(()=>(o(Ji()),()=>{o(Gd())}),[o]),E===!1)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("notSupported")})})},"supported");if(x===!1)return(0,R.jsx)("div",{className:s.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(sr,{isEmbedded:n,loginUrl:H,onLogIn:t})})},"login");if(!p||!_||x===null||O||b)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("waiting")})})},"waiting");let z=c||a||l||K;return(0,R.jsx)("div",{className:(0,Cu.default)(s.root),"data-testid":"widget",children:(0,R.jsxs)(qn,{className:s.sectionList,children:[z&&(0,R.jsx)(We,{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:()=>A.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(_o,{}),e("linkSearch")]}),a&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>A.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(fu,{}),e("linkSummary")]}),l&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>A.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(mu,{}),e("linkKnowledgeSearch")]}),K&&(0,R.jsxs)("a",{className:s.shortcut,target:"_blank",href:K,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,R.jsx)(gu,{}),e("linkStudioLogin",{productName:W})]})]})}),i&&f.length>0&&(0,R.jsx)(We,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(ue,{withDivider:!0,children:f.map(I=>(0,R.jsx)(cu,{suggestion:I},I.text))})}),r&&g.length>0&&(0,R.jsx)(We,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(ue,{withDivider:!0,children:(0,R.jsx)(au,{})})}),d.map(({type:I,title:ye,amount:Mr,lines:Fo})=>{var Ko;switch(I){case"entities":return m&&m.length>0&&(0,R.jsx)(We,{type:I,title:ye,"data-testid":`type-${I}`,children:(0,R.jsx)(uu,{entities:m})},I);case"cues":return u&&u.length>0&&(0,R.jsx)(We,{type:I,title:ye,"data-testid":`type-${I}`,children:(0,R.jsx)(ue,{withDivider:!0,children:(0,R.jsx)(yu,{cues:u,onRemoveCue:to=>o(Zc({id:to}))})})},I);default:return((Ko=v[I])==null?void 0:Ko.fetchState)==="done"&&v[I].suggestions.length>0&&(0,R.jsx)(We,{type:I,title:ye,"data-testid":`type-${I}`,children:(0,R.jsx)(ue,{withDivider:!0,children:(0,R.jsx)(xu,{lines:Fo,contentType:I,suggestions:v[I].suggestions.slice(0,Mr)||[]})})},I)}})]})})},Tu=Dh;function Do(t){let e=new Range;return e.selectNodeContents(t),e}function Eu(t,e,o){try{return At(t,e,o),!0}catch{return!1}}function wr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Tr(t){return"tagName"in t&&t.tagName==="BR"}var Pn=/[\u200B-\u200D\uFEFF]/g;function At(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let g=0;g<=l.length;g++)if(d.test(l[g])||p++,p===c)return g;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(Pn,""),d=s+p.length,g=e>=s&&e<=d,u=o>=s&&o<=d;if(g){let m=i(c,e-s);m===0&&!u?n.setStartBefore(l):n.setStart(l,m)}u&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(Tr(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;wr(l)&&c&&!wr(c)&&!Tr(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function An(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(d){let g=d===o,u=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let m=d.textContent;g&&(a=c+m.substring(0,n).replace(Pn,"").length),u&&(l=c+m.substring(0,r).replace(Pn,"").length),c+=m.replace(Pn,"").length;break}case Node.ELEMENT_NODE:{let m=d.nextSibling===null;Tr(d)&&!m&&c++;for(let f=0;f<d.childNodes.length;f++){let h=g&&f===n,E=u&&f===r;if(h&&(a=c),E&&(l=c),l!==void 0||((!h||!i)&&p(d.childNodes[f]),u&&f===r-1&&(l=c),l!==void 0))break}!u&&wr(d)&&!m&&c++,u&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function Ln(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let g=p?n:0,u=d?r:void 0,m=c.textContent.replace(Pn,"");g===0&&u===void 0?a+=m:a+=m.substring(g,u);break}case Node.ELEMENT_NODE:{let g=c.nextSibling===null;i===0&&Tr(c)&&!g&&(a+=`
8
8
  `);for(let u=p?n:0;u<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[u]),i!==1);u++);!d&&i===0&&wr(c)&&!g&&(a+=`
9
- `);break}default:break}d&&i++}return l(t),a}function ku(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Yt=class extends Xe{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),Mn(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!ku(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!ku(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return Ln(this.element,e);let o=this.lastKnownSelection;if(o&&Eu(this.element,o.start,o.end))return o;let n=Do(this.element);return n.collapse(!1),Ln(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return Mn(this.element,At(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};function Iu(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 pa=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(JSON.stringify(e))}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},da=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=Iu(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},ua=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(),w.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 da(e,this.deepdeskUrl,{debug:!0}):new pa(e),n=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=typeof s.data=="string"?JSON.parse(s.data):s.data;r.type==="event"&&r.channel===e&&(w.info("Received broadcast event",this.sessionId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return o.onMessage(n),o}send(e,o,n){var i,a;w.info("Broadcast event",{sessionId:this.sessionId,name:e,payload:o});let s={type:"event",name:e,payload:o};n!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,o));let r=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage({...s,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Ru=ua;var Ho=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var ga=t=>new Promise(e=>{setTimeout(e,t)});var Bo=class extends Ho{name="ClientError"},ma=class extends Ho{name="ServerError"},De=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:d=!0,retryOnError:g=b=>b instanceof TypeError,retryOnResponse:u=b=>b.status>=500,version:m="v1",...f}=o,h={credentials:"include",...f,headers:{"Content-Type":"application/json",...f.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof m=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":m});let E=c,x=!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 _=async()=>(E--,a(i,h).then(async b=>u(b)&&!r.isAborted&&E>0?(await ga(p),_()):b.status===401&&d===!0&&x===!1?(x=!0,await this.refreshToken(),_()):b).catch(async b=>{if(g(b)&&!r.isAborted&&E>0)return await ga(p),_();throw b}));_().then(b=>b.json().catch(()=>null).then(v=>{b.status>=500?s(new ma("Server Error",v)):b.status===401?s(new Bo("Unauthorized",v)):b.status===403?s(new Bo("Forbidden",v)):b.status===404?s(new Bo("Not Found",v)):b.status>=400&&s(new Bo("Bad Request",v)),delete this.latestRequestByUrl[i],n(v)})).catch(b=>{s(b)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var Hh;(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||={})})(Hh||={});function Er(t){return{...N(t),tags:t.tags}}var gt=class t{constructor(e,o={}){this.options=o;this.client=new De(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(),w.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...G(e),tags:e.tags},{version:"v2"});return Er(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return N(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return N(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return N(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return N(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(),w.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 w.info(`Successfully retrieved conversation ${r.id} for session ${e}`),Er(r)}async isConversationSupported(e,o={}){w.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=G(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Er(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...G(s),tags:s.tags})),{version:"v2"})).map(s=>Er(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",G({...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:G({...o,...n})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(n=>n.text)})).entities}async getSummary(e,o={}){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source),agent_id:o.agentId,id:o.externalConversationId},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw w.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",G(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}`,G(o),{abortLatest:!0})).map(r=>({...N(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`,G(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 N(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",G(e),{abortLatest:!0});return N(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,G(e),{version:"v2"});return N(o)}async knowledgeAssist(e,o,n,s={}){let r=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,G({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(i=>({question:i.question,answer:i.answer.answer})),agentId:s.agentId,conversationId:s.conversationId}),{version:"v2"});return N(r)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return N(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return N(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 N(o)}async evaluateRule(e,o,n,s={}){let r=new URLSearchParams;s.raiseForFailingConditions&&r.set("raise_for_failing_conditions","true");let i=await this.client.post(`/api/conversations/${o}/rules/${e}/evaluate?${r.toString()}`,n,{version:"v2"});return N(i.cues)}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&&w.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var Nn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(hi(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,N(s))}catch{w.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 Bh;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Bh||={});var On=class{constructor(e,o={}){this.apiUrl=e;this.client=new De(e,o)}client;streams={};logger=w;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return N(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,G(o));return N(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,G(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return N(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",G(e));return N(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new Nn(`${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 Pr=require("@reduxjs/toolkit");var Au=require("@reduxjs/toolkit");var Pu={startTime:null,stopTime:null},Lu=(0,Au.createSlice)({name:"handlingTime",initialState:Pu,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(M,()=>Pu)}}),{handlingTimeStart:Mu,handlingTimeStop:kr,handlingTimeReset:Nu}=Lu.actions,Ou=Lu.reducer;var Du=(t={})=>{let e={onAuthError:wo(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var Rr=require("@reduxjs/toolkit");var Ir={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var eo=(0,Rr.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 Ir.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Fh=(0,Rr.createSlice)({name:"styleSuggestions",initialState:Ir,reducers:{},extraReducers:t=>{t.addCase(eo.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(eo.rejected,e=>{e.fetchState="error"}).addCase(eo.fulfilled,(e,o)=>{e.fetchState="done",ft(e.list,o.payload)||(e.list=o.payload)}).addCase(Nt,e=>{e.list=Ir.list}).addCase(M,()=>Ir)}}),Hu=Fh.reducer;var Bu=(t={})=>{let e,o=!0,n={getStyleSuggestions:eo,debounce:500,...t};return s=>r=>i=>{var u;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((u=c.conversation.current)==null?void 0:u.id)||!p)return l;let{text:g}=c.input;return g===a&&!o||(clearTimeout(e),g==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:g}))},t.debounce)),l}};function Kh(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Fu=(t={})=>{let e={getTextSuggestions:Le,getAutocompleteSuggestions:ln,debounce:200,check:Lo,...t},o;return n=>s=>r=>{var f;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(f=l.conversation.current)==null?void 0:f.id,g=r.type===Us.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:u}}=l;return Kh(u,i)&&!g||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let h=lo(l);h===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(h))},g?0:e.debounce)),a}};var Ku=eo.fulfilled.toString();function Uh(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 Uu=t=>e=>o=>n=>{var c;if(n.type!==Ku){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=Uh(s,i);n.type===Ku&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var zh=(0,Pr.combineReducers)({activeSuggestion:Mc,answer:kp,auth:$c,autoflows:Dd,conversation:Ga,contentTypes:cp,customMessages:qd,passwordlessToken:Xd,entities:gp,knowledgeAssistant:wp,handlingTime:Ou,info:ic,input:Ur.reducer,overlayInput:ae.reducer,settings:Va,profile:Pp,search:gc,summary:Sp,styleSuggestions:Hu,ui:Bc,rules:Qc,textSuggestions:kc});function zu(t){return(0,Pr.configureStore)({reducer:zh,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Du(),Fu({debounce:200}),Bu({debounce:500}),Uu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var jh=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Vh=t=>e=>o=>n=>{var a;let s=e.getState(),r=Hr("inlineSuggestions")(s);switch(n.type){case Ye.toString():{let l=Ks(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 wo.toString():{!n.payload&&t.emit("logout",void 0);break}case Re.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:jh(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case os.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 Go.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case is.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 Ne.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case nt.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case Q.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 ns.toString():t.handleKeyDown(n.payload);break;case Nt.toString():t.logSendMessage(n.payload);break;case ss.toString():t.logSendEditSuggestionMessage(n.payload);break;case rs.toString():t.handleInputChanged(n.payload);break;case tt.fulfilled.toString():t.broadcast(Ti,n.payload,!1),t.emit("cues",n.payload);break;default:break}let i=o(n);switch(n.type){case Nt.toString():t.handleAfterSendMessage(n.payload);break;case cn.toString():t.onUpdateShowTabHint(n.payload);break;case kr.toString():t.logHandlingTime();break;case Re.toString():{r&&(e.dispatch(Be([])),e.dispatch($e()));break}case Be.toString():{r&&n.payload.length>0&&e.dispatch(yt(0));break}default:break}return i},ju=Vh;function fa(t){return t.toISOString().replace("T"," ").replace("Z","")}function Vu(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:fa(o),timeStop:fa(n)}}function ha(t,e,o){var O,K,H;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:g,deletions:u,textSuggestions:m,offeredTextSuggestions:f}}=e[t],h=n.length,x=m.reduce((W,{text:z,searchTerm:I})=>W+z.length-(I?I.length:0),0),_=c??Date.now(),b=(Date.now()-_)/1e3+(p||0),v=s/b,A=m.reduce((W,{searchTerm:z})=>W+(z?z.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:g,deletions:u,lenTextTyped:s+A,lenTextTotal:h,lenTextAssisted:x,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:v,numPastes:l,textSuggestionsV2:m,suggestionsCounters:[{source:"gpt",countOffered:f.filter(W=>W.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(K=e.info.agentInfo)==null?void 0:K.agentName,agentEmail:(H=e.info.agentInfo)==null?void 0:H.agentEmail}}function ya(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return ya(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?ya(s,e):null}function qu(t,e){return ya(t,e)}function Wu(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function qh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Ar(t){return qh(t)&&(Et(t)||Cs(t))}var $u=(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{w.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Wh(t){return t.offsetParent!==null}function Gu(t){if(!Wh(t))return!1;let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function Lr(t,e,o=100){let n=Gu(t);e({isVisible:n});let s=setInterval(()=>{let r=Gu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var q=require("react/jsx-runtime");var Xu=$u("showTabHint",!0),Dn=class t{static version="10.12.1-beta.4";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 gt(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[ju({broadcast:(d,g,u)=>{this.broadcastEvents.send(d,g,u)},emit:(d,g,u)=>this.emit(d,g,u),handleAfterSendMessage:d=>this.handleAfterSendMessage(d),handleInputChanged:d=>this.handleInputChanged(d),handleKeyDown:d=>this.handleKeyDown(d),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:d=>this.logSendMessage(d),logSendEditSuggestionMessage:d=>this.logSendEditMessage(d),onUpdateShowTabHint:d=>Xu.update(d),sendEvent:(d,g)=>this.deepdeskApi.sendEvent(d,g)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new On(o)}),this.store=zu(p),this.broadcastEvents=new Ru({debug:!0,deepdeskUrl:c,eventMap:Jc(this.store),createCustomChannel:l}),this.store.dispatch($o),this.store.dispatch(cn(Xu.value())),this.store.dispatch($o({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?(w.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(w.warn("Profile has not been loaded (yet)"),!0):(w.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(wo(null)),this.store.dispatch(et()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ne(n)&&Uc(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(et())).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){w.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(Fr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Zn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Qn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Kr(e))).payload}async postMessages(e){return(await this.store.dispatch(Yn(e))).payload}async updateConversation(e){return(await this.store.dispatch(Jn(e))).payload}resetConversation(){this.store.dispatch(M()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(nt());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch($o(e))}setVisitorInfo(e){this.store.dispatch(rc(e))}async setAgentInfo(e){await this.store.dispatch(nn(e))}async setAgentSettings(e){await this.store.dispatch(yi(e))}async getAgentSettings(){return(await this.store.dispatch(vi())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(Us()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(rs(e))}notifyKeyDown(e){this.store.dispatch(ns(e))}notifyPaste(e,o){this.store.dispatch(al({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(rl(e))}notifyExternalSuggestion(e){this.store.dispatch(Re(e)),this.store.dispatch($e())}notifyEditSuggestion(e){this.store.dispatch(Tc(e.contentType,e.suggestions)),this.store.dispatch(Ye({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}async evaluateRule(e,o={}){let{payload:n,error:s}=await this.store.dispatch(tt({label:e,params:o}));if(s)throw s;return n}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(bt({collapse:!1})),this.inputMediator&&this.store.dispatch(Ya({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Be([])))}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(il(ts(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(ol()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{o||!a||i&&s<=0||r&&(e.shiftKey||(this.store.dispatch(sl()),e.preventDefault(),!i&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(Go()):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(yt(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(yt(-1)),this.store.dispatch(Go()),e.preventDefault()):o||(this.store.dispatch(bt({collapse:!0})),this.store.dispatch(Dc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,g=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:u}=this.state.input;this.store.dispatch(cn(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&u&&u.text.startsWith(g)&&(this.store.dispatch(Re({text:u.text,suggestion:u,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch($e())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(ll()),this.store.dispatch(Be([]))}handlingTimeStart(){this.state.handlingTime.startTime||(w.info("Start handling time"),this.store.dispatch(Mu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(w.info("Stop handling time"),this.store.dispatch(kr()))}logSendMessage(e){let o=ha("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=ha("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(tl(this.state.overlayInput.metrics))}logHandlingTime(){let e=Vu(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Nu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch($e()),this.store.dispatch(Nt(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(Re({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){w.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),w.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]=Ht(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,Te.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]=Ht(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,Te.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 Dt(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,Te.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),w.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()?(w.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(pl(n.metrics))):w.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(!Ar(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:d,detectSubmit:g,insertLink:u,inputMediator:m,closestScrollSelector:f,appendOverlayTo:h,inlineSuggestions:E,floatingMenu:x}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:u,isEmbedded:d,inlineSuggestions:E,floatingMenu:!!x}),o.automaticHandlingTime&&this.setupHandlingTime(e),Dt(e),this.inputMediator=m||(Et(e)?new Ze(e):new Yt(e)),this.inputMediator.on("change",({plainText:v})=>{this.notifyInputChanged(v)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(cl({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",v=>{this.notifyKeyDown(v)}),this.inputMediator.on("paste",({pastedText:v,selectionText:A})=>{this.notifyPaste(v,A)}),this.inputMediator.on("cut",({selectionText:v})=>{this.notifyCut(v)});let _=f&&qu(e,f)||void 0;if(E){let{customStyles:v,appendOverlayTo:A}=o;if(Et(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let O=this.createInlineContainer(e,"deepdesk-caret");(0,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:v,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(Jp,{})})}),O),this.inputMediator.on("caret",H=>{this.store.dispatch(Be([])),H?(O.style.display="block",O.style.top=`${H.top}px`,O.style.left=`${H.left}px`):O.style.display="none"});let K=this.overlayContainerFactory("floating-menu",_||e,{appendTo:typeof x=="object"&&"appendOverlayTo"in x?x.appendOverlayTo:A},v==null?void 0:v.floatingMenuRootNode);(0,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:v,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(qp,{onLogIn:()=>this.loginViaPopup().catch(H=>w.warn(H.message))})})}),K)}else{let v=this.overlayContainerFactory("deepdesk-tab-completion",_||e,{appendTo:h,closestScrollElement:_,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),A=this.overlayContainerFactory("deepdesk-suggestions-overlay",_||e,{appendTo:h},n==null?void 0:n.suggestionsRootNode);(0,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(Pd,{inputElement:e})})}),v),(0,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(ld,{onLogIn:()=>this.loginViaPopup().catch(O=>w.warn(O.message))})})}),A)}(0,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(Bp,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",v=>{clearTimeout(b),v===null?b=setTimeout(()=>{v!==null&&this.store.dispatch(zr(v))},500):this.store.dispatch(zr(v))}),this.inputMediator.on("disabled",()=>{var v;(v=this.inputMediator)==null||v.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{g&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(bo(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(bo(!0))),this.store.dispatch(el({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch($e()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var v;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((v=this.state.conversation.current)==null?void 0:v.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&w.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,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(Tu,{onLogIn:()=>this.loginViaPopup().catch(i=>w.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Te.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Lr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Wu(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(bn());let e=wt(this.state);e&&(await this.store.dispatch(Sn()),this.store.dispatch($o({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(e){return new Promise((o,n)=>{let s=new MessageChannel,r=s.port1,i=this.state.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,c=()=>{p&&!p.closed&&p.close(),window.removeEventListener("message",d),clearInterval(g)};r.onmessage=async u=>{var m,f;if((m=u.data)!=null&&m.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((f=u.data)==null?void 0:f.jwt),await this.isLoggedIn(),this.broadcastEvents.send(un),l=!0,s.port1.close(),o()}catch(h){console.error(h),n(h)}finally{l=!0,c()}};let p=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");p===null&&n(new Error("Popup blocked by browser"));let d=async u=>{var m;if(u.origin===a.origin)switch((m=u.data)==null?void 0:m.type){case"deepdesk-popup-loaded":{try{let f=JSON.stringify({type:"deepdesk-popup-create-channel"});p==null||p.postMessage(f,a.origin,[s.port2])}catch(f){w.error("Error posting message to popup",f),n(f)}break}case"deepdesk-popup-error":{c(),u.data.message==="Timeout"&&w.warn("Popup timed out. Check if the account's platform url is configured correctly."),n(new Error(u.data.message));break}}};window.addEventListener("message",d);let g=setInterval(()=>{p&&!p.closed||(c(),l||n(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(w.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;w.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=Js(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Ne()):this.store.dispatch(Le(n))})}catch(n){this.handleError(n)}}};async function Zu(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 Qu(t,e,o={}){let n=o.replace?At(t,o.replace.start,o.replace.end):Do(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
+ `);break}default:break}d&&i++}return l(t),a}function ku(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Yt=class extends Xe{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),Ln(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!ku(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!ku(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return An(this.element,e);let o=this.lastKnownSelection;if(o&&Eu(this.element,o.start,o.end))return o;let n=Do(this.element);return n.collapse(!1),An(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return Ln(this.element,At(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};function Iu(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 pa=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(JSON.stringify(e))}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},da=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=Iu(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},ua=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(),w.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 da(e,this.deepdeskUrl,{debug:!0}):new pa(e),n=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=typeof s.data=="string"?JSON.parse(s.data):s.data;r.type==="event"&&r.channel===e&&(w.info("Received broadcast event",this.sessionId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return o.onMessage(n),o}send(e,o,n){var i,a;w.info("Broadcast event",{sessionId:this.sessionId,name:e,payload:o});let s={type:"event",name:e,payload:o};n!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,o));let r=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage({...s,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Ru=ua;var Ho=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var ga=t=>new Promise(e=>{setTimeout(e,t)});var Bo=class extends Ho{name="ClientError"},ma=class extends Ho{name="ServerError"},De=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:d=!0,retryOnError:g=b=>b instanceof TypeError,retryOnResponse:u=b=>b.status>=500,version:m="v1",...f}=o,h={credentials:"include",...f,headers:{"Content-Type":"application/json",...f.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof m=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":m});let E=c,x=!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 _=async()=>(E--,a(i,h).then(async b=>u(b)&&!r.isAborted&&E>0?(await ga(p),_()):b.status===401&&d===!0&&x===!1?(x=!0,await this.refreshToken(),_()):b).catch(async b=>{if(g(b)&&!r.isAborted&&E>0)return await ga(p),_();throw b}));_().then(b=>b.json().catch(()=>null).then(v=>{b.status>=500?s(new ma("Server Error",v)):b.status===401?s(new Bo("Unauthorized",v)):b.status===403?s(new Bo("Forbidden",v)):b.status===404?s(new Bo("Not Found",v)):b.status>=400&&s(new Bo("Bad Request",v)),delete this.latestRequestByUrl[i],n(v)})).catch(b=>{s(b)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var Hh;(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||={})})(Hh||={});function Er(t){return{...N(t),tags:t.tags}}var gt=class t{constructor(e,o={}){this.options=o;this.client=new De(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(),w.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...G(e),tags:e.tags},{version:"v2"});return Er(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return N(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return N(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return N(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return N(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(),w.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 w.info(`Successfully retrieved conversation ${r.id} for session ${e}`),Er(r)}async isConversationSupported(e,o={}){w.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=G(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Er(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...G(s),tags:s.tags})),{version:"v2"})).map(s=>Er(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",G({...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:G({...o,...n})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(n=>n.text)})).entities}async getSummary(e,o={}){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source),agent_id:o.agentId,id:o.externalConversationId},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw w.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",G(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}`,G(o),{abortLatest:!0})).map(r=>({...N(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`,G(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 N(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",G(e),{abortLatest:!0});return N(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,G(e),{version:"v2"});return N(o)}async knowledgeAssist(e,o,n,s={}){let r=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,G({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(i=>({question:i.question,answer:i.answer.answer})),agentId:s.agentId,conversationId:s.conversationId}),{version:"v2"});return N(r)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return N(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return N(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 N(o)}async evaluateRule(e,o,n,s={}){let r=new URLSearchParams;s.raiseForFailingConditions&&r.set("raise_for_failing_conditions","true");let i=await this.client.post(`/api/conversations/${o}/rules/${e}/evaluate?${r.toString()}`,n,{version:"v2"});return N(i.cues)}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&&w.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var Mn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(hi(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,N(s))}catch{w.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 Bh;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Bh||={});var Nn=class{constructor(e,o={}){this.apiUrl=e;this.client=new De(e,o)}client;streams={};logger=w;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return N(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,G(o));return N(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,G(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return N(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",G(e));return N(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new Mn(`${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 Pr=require("@reduxjs/toolkit");var Au=require("@reduxjs/toolkit");var Pu={startTime:null,stopTime:null},Lu=(0,Au.createSlice)({name:"handlingTime",initialState:Pu,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(M,()=>Pu)}}),{handlingTimeStart:Mu,handlingTimeStop:kr,handlingTimeReset:Nu}=Lu.actions,Ou=Lu.reducer;var Du=(t={})=>{let e={onAuthError:wo(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var Rr=require("@reduxjs/toolkit");var Ir={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var eo=(0,Rr.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 Ir.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Fh=(0,Rr.createSlice)({name:"styleSuggestions",initialState:Ir,reducers:{},extraReducers:t=>{t.addCase(eo.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(eo.rejected,e=>{e.fetchState="error"}).addCase(eo.fulfilled,(e,o)=>{e.fetchState="done",ft(e.list,o.payload)||(e.list=o.payload)}).addCase(Nt,e=>{e.list=Ir.list}).addCase(M,()=>Ir)}}),Hu=Fh.reducer;var Bu=(t={})=>{let e,o=!0,n={getStyleSuggestions:eo,debounce:500,...t};return s=>r=>i=>{var u;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((u=c.conversation.current)==null?void 0:u.id)||!p)return l;let{text:g}=c.input;return g===a&&!o||(clearTimeout(e),g==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:g}))},t.debounce)),l}};function Kh(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Fu=(t={})=>{let e={getTextSuggestions:Le,getAutocompleteSuggestions:an,debounce:200,check:Lo,...t},o;return n=>s=>r=>{var f;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(f=l.conversation.current)==null?void 0:f.id,g=r.type===Us.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:u}}=l;return Kh(u,i)&&!g||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let h=lo(l);h===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(h))},g?0:e.debounce)),a}};var Ku=eo.fulfilled.toString();function Uh(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 Uu=t=>e=>o=>n=>{var c;if(n.type!==Ku){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=Uh(s,i);n.type===Ku&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var zh=(0,Pr.combineReducers)({activeSuggestion:Mc,answer:kp,auth:$c,autoflows:Dd,conversation:Ga,contentTypes:cp,customMessages:qd,passwordlessToken:Xd,entities:gp,knowledgeAssistant:wp,handlingTime:Ou,info:ic,input:Ur.reducer,overlayInput:ae.reducer,settings:Va,profile:Pp,search:gc,summary:Sp,styleSuggestions:Hu,ui:Bc,rules:Qc,textSuggestions:kc});function zu(t){return(0,Pr.configureStore)({reducer:zh,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Du(),Fu({debounce:200}),Bu({debounce:500}),Uu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var jh=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Vh=t=>e=>o=>n=>{var a;let s=e.getState(),r=Hr("inlineSuggestions")(s);switch(n.type){case Ye.toString():{let l=Ks(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 wo.toString():{!n.payload&&t.emit("logout",void 0);break}case Re.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:jh(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case os.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 $o.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case is.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 Ne.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case nt.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case Q.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 ns.toString():t.handleKeyDown(n.payload);break;case Nt.toString():t.logSendMessage(n.payload);break;case ss.toString():t.logSendEditSuggestionMessage(n.payload);break;case rs.toString():t.handleInputChanged(n.payload);break;case tt.fulfilled.toString():t.broadcast(Ti,n.payload,!1),t.emit("cues",n.payload);break;default:break}let i=o(n);switch(n.type){case Nt.toString():t.handleAfterSendMessage(n.payload);break;case ln.toString():t.onUpdateShowTabHint(n.payload);break;case kr.toString():t.logHandlingTime();break;case Re.toString():{r&&(e.dispatch(Be([])),e.dispatch($e()));break}case Be.toString():{r&&n.payload.length>0&&e.dispatch(yt(0));break}default:break}return i},ju=Vh;function fa(t){return t.toISOString().replace("T"," ").replace("Z","")}function Vu(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:fa(o),timeStop:fa(n)}}function ha(t,e,o){var O,K,H;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:g,deletions:u,textSuggestions:m,offeredTextSuggestions:f}}=e[t],h=n.length,x=m.reduce((W,{text:z,searchTerm:I})=>W+z.length-(I?I.length:0),0),_=c??Date.now(),b=(Date.now()-_)/1e3+(p||0),v=s/b,A=m.reduce((W,{searchTerm:z})=>W+(z?z.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:g,deletions:u,lenTextTyped:s+A,lenTextTotal:h,lenTextAssisted:x,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:v,numPastes:l,textSuggestionsV2:m,suggestionsCounters:[{source:"gpt",countOffered:f.filter(W=>W.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(K=e.info.agentInfo)==null?void 0:K.agentName,agentEmail:(H=e.info.agentInfo)==null?void 0:H.agentEmail}}function ya(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return ya(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?ya(s,e):null}function qu(t,e){return ya(t,e)}function Wu(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function qh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Ar(t){return qh(t)&&(Et(t)||Cs(t))}var $u=(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{w.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Wh(t){return t.offsetParent!==null}function Gu(t){if(!Wh(t))return!1;let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function Lr(t,e,o=100){let n=Gu(t);e({isVisible:n});let s=setInterval(()=>{let r=Gu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var q=require("react/jsx-runtime");var Xu=$u("showTabHint",!0),On=class t{static version="10.12.1-beta.5";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 gt(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[ju({broadcast:(d,g,u)=>{this.broadcastEvents.send(d,g,u)},emit:(d,g,u)=>this.emit(d,g,u),handleAfterSendMessage:d=>this.handleAfterSendMessage(d),handleInputChanged:d=>this.handleInputChanged(d),handleKeyDown:d=>this.handleKeyDown(d),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:d=>this.logSendMessage(d),logSendEditSuggestionMessage:d=>this.logSendEditMessage(d),onUpdateShowTabHint:d=>Xu.update(d),sendEvent:(d,g)=>this.deepdeskApi.sendEvent(d,g)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new Nn(o)}),this.store=zu(p),this.broadcastEvents=new Ru({debug:!0,deepdeskUrl:c,eventMap:Jc(this.store),createCustomChannel:l}),this.store.dispatch(ln(Xu.value())),this.store.dispatch($n({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?(w.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(w.warn("Profile has not been loaded (yet)"),!0):(w.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(wo(null)),this.store.dispatch(et()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ne(n)&&Uc(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(et())).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){w.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(Fr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Zn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Qn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Kr(e))).payload}async postMessages(e){return(await this.store.dispatch(Yn(e))).payload}async updateConversation(e){return(await this.store.dispatch(Jn(e))).payload}resetConversation(){this.store.dispatch(M()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(nt());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch($n(e))}setVisitorInfo(e){this.store.dispatch(rc(e))}async setAgentInfo(e){await this.store.dispatch(on(e))}async setAgentSettings(e){await this.store.dispatch(yi(e))}async getAgentSettings(){return(await this.store.dispatch(vi())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(Us()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(rs(e))}notifyKeyDown(e){this.store.dispatch(ns(e))}notifyPaste(e,o){this.store.dispatch(al({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(rl(e))}notifyExternalSuggestion(e){this.store.dispatch(Re(e)),this.store.dispatch($e())}notifyEditSuggestion(e){this.store.dispatch(Tc(e.contentType,e.suggestions)),this.store.dispatch(Ye({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}async evaluateRule(e,o={}){let{payload:n,error:s}=await this.store.dispatch(tt({label:e,params:o}));if(s)throw s;return n}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(bt({collapse:!1})),this.inputMediator&&this.store.dispatch(Ya({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Be([])))}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(il(ts(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(ol()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{o||!a||i&&s<=0||r&&(e.shiftKey||(this.store.dispatch(sl()),e.preventDefault(),!i&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch($o()):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(yt(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(yt(-1)),this.store.dispatch($o()),e.preventDefault()):o||(this.store.dispatch(bt({collapse:!0})),this.store.dispatch(Dc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,g=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:u}=this.state.input;this.store.dispatch(ln(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&u&&u.text.startsWith(g)&&(this.store.dispatch(Re({text:u.text,suggestion:u,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch($e())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(ll()),this.store.dispatch(Be([]))}handlingTimeStart(){this.state.handlingTime.startTime||(w.info("Start handling time"),this.store.dispatch(Mu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(w.info("Stop handling time"),this.store.dispatch(kr()))}logSendMessage(e){let o=ha("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=ha("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(tl(this.state.overlayInput.metrics))}logHandlingTime(){let e=Vu(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Nu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch($e()),this.store.dispatch(Nt(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(Re({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){w.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),w.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]=Ht(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,Te.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]=Ht(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,Te.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 Dt(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,Te.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),w.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()?(w.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(pl(n.metrics))):w.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(!Ar(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:d,detectSubmit:g,insertLink:u,inputMediator:m,closestScrollSelector:f,appendOverlayTo:h,inlineSuggestions:E,floatingMenu:x}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:u,isEmbedded:d,inlineSuggestions:E,floatingMenu:!!x}),o.automaticHandlingTime&&this.setupHandlingTime(e),Dt(e),this.inputMediator=m||(Et(e)?new Ze(e):new Yt(e)),this.inputMediator.on("change",({plainText:v})=>{this.notifyInputChanged(v)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(cl({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",v=>{this.notifyKeyDown(v)}),this.inputMediator.on("paste",({pastedText:v,selectionText:A})=>{this.notifyPaste(v,A)}),this.inputMediator.on("cut",({selectionText:v})=>{this.notifyCut(v)});let _=f&&qu(e,f)||void 0;if(E){let{customStyles:v,appendOverlayTo:A}=o;if(Et(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let O=this.createInlineContainer(e,"deepdesk-caret");(0,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:v,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(Jp,{})})}),O),this.inputMediator.on("caret",H=>{this.store.dispatch(Be([])),H?(O.style.display="block",O.style.top=`${H.top}px`,O.style.left=`${H.left}px`):O.style.display="none"});let K=this.overlayContainerFactory("floating-menu",_||e,{appendTo:typeof x=="object"&&"appendOverlayTo"in x?x.appendOverlayTo:A},v==null?void 0:v.floatingMenuRootNode);(0,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:v,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(qp,{onLogIn:()=>this.loginViaPopup().catch(H=>w.warn(H.message))})})}),K)}else{let v=this.overlayContainerFactory("deepdesk-tab-completion",_||e,{appendTo:h,closestScrollElement:_,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),A=this.overlayContainerFactory("deepdesk-suggestions-overlay",_||e,{appendTo:h},n==null?void 0:n.suggestionsRootNode);(0,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(Pd,{inputElement:e})})}),v),(0,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(ld,{onLogIn:()=>this.loginViaPopup().catch(O=>w.warn(O.message))})})}),A)}(0,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(Bp,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",v=>{clearTimeout(b),v===null?b=setTimeout(()=>{v!==null&&this.store.dispatch(zr(v))},500):this.store.dispatch(zr(v))}),this.inputMediator.on("disabled",()=>{var v;(v=this.inputMediator)==null||v.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{g&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(bo(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(bo(!0))),this.store.dispatch(el({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch($e()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var v;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((v=this.state.conversation.current)==null?void 0:v.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&w.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,Te.render)((0,q.jsx)(Qt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(Tu,{onLogIn:()=>this.loginViaPopup().catch(i=>w.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Te.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Lr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Wu(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(xn());let e=wt(this.state);e&&(await this.store.dispatch(vn()),this.store.dispatch($n({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(e){return new Promise((o,n)=>{let s=new MessageChannel,r=s.port1,i=this.state.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,c=()=>{p&&!p.closed&&p.close(),window.removeEventListener("message",d),clearInterval(g)};r.onmessage=async u=>{var m,f;if((m=u.data)!=null&&m.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((f=u.data)==null?void 0:f.jwt),await this.isLoggedIn(),this.broadcastEvents.send(dn),l=!0,s.port1.close(),o()}catch(h){console.error(h),n(h)}finally{l=!0,c()}};let p=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");p===null&&n(new Error("Popup blocked by browser"));let d=async u=>{var m;if(u.origin===a.origin)switch((m=u.data)==null?void 0:m.type){case"deepdesk-popup-loaded":{try{let f=JSON.stringify({type:"deepdesk-popup-create-channel"});p==null||p.postMessage(f,a.origin,[s.port2])}catch(f){w.error("Error posting message to popup",f),n(f)}break}case"deepdesk-popup-error":{c(),u.data.message==="Timeout"&&w.warn("Popup timed out. Check if the account's platform url is configured correctly."),n(new Error(u.data.message));break}}};window.addEventListener("message",d);let g=setInterval(()=>{p&&!p.closed||(c(),l||n(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(w.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;w.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=Js(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Ne()):this.store.dispatch(Le(n))})}catch(n){this.handleError(n)}}};async function Zu(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 Qu(t,e,o={}){let n=o.replace?At(t,o.replace.start,o.replace.end):Do(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?At(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function $h(t){let e=document.createElement("template");return e.innerHTML=t.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),e.content}function Gh(t){let e=document.createDocumentFragment();return t.split(`
11
11
  `).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=o.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(o.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(o.slice(r)))}),e}function Ju(t,e){return!t.contains(e)||e===t?null:e.parentNode===t?e:Ju(t,e.parentNode)}async function Yu(t,e,{isBlock:o,isHTML:n}={}){let s;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let r=()=>{let i=t.ownerDocument.defaultView??window,a=i.getSelection();if((!a||a.rangeCount===0)&&(t.focus(),a=i.getSelection()),!a||a.rangeCount===0)return;let l=a.getRangeAt(0);if(!l)return;s=document.createElement("span"),l.insertNode(s);let c=n?$h(e):Gh(e);if(o){let p=l.startContainer===t?t.childNodes[l.startOffset]:l.startContainer,d=Ju(t,p)??t.firstChild;t.insertBefore(c,(d==null?void 0:d.nextSibling)??null)}else l.insertNode(c),l.collapse(!1)};return Promise.resolve(r()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function eg(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function tg(t,e,o){await new gt(t).authenticateWithKey(e,o)}async function og(t){let o=await new De(t).get("/platform/config/",{version:null});return N(o)}async function Xh(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 ng(t,e){let o=await Xh(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,isHTML,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});