@deepdesk/deepdesk-sdk 10.4.1-beta.1 → 10.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dialogs.css +1 -1
- package/dist/index.cjs.js +6 -6
- package/dist/index.d.mts +59 -50
- package/dist/index.d.ts +59 -50
- package/dist/index.esm.js +6 -6
- package/dist/index.iife.js +13 -13
- package/input.css +1 -1
- package/package.json +1 -1
- package/styles/index.js +1 -1
- package/styles.css +1 -1
- package/widget.css +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var du=Object.create;var _n=Object.defineProperty;var uu=Object.getOwnPropertyDescriptor;var gu=Object.getOwnPropertyNames;var mu=Object.getPrototypeOf,fu=Object.prototype.hasOwnProperty;var V=(t,e)=>{for(var o in e)_n(t,o,{get:e[o],enumerable:!0})},ji=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of gu(e))!fu.call(t,s)&&s!==o&&_n(t,s,{get:()=>e[s],enumerable:!(n=uu(e,s))||n.enumerable});return t};var T=(t,e,o)=>(o=t!=null?du(mu(t)):{},ji(e||!t||!t.__esModule?_n(o,"default",{value:t,enumerable:!0}):o,t)),hu=t=>ji(_n({},"__esModule",{value:!0}),t);var Tf={};V(Tf,{Card:()=>D,ContentEditableInput:()=>Ft,DeepdeskAPI:()=>nt,DeepdeskSDK:()=>Sn,HTTPClient:()=>Pe,InputMediator:()=>Ke,InputType:()=>it,KeyboardHint:()=>En,Label:()=>kn,Locale:()=>Po,Section:()=>rt,SectionList:()=>Rn,Sources:()=>_e,Suggestion:()=>O,SuggestionList:()=>ge,TextAreaInput:()=>Ue,ToggleButton:()=>Et,attachFile:()=>eu,authenticateWithKey:()=>Jd,createFullRange:()=>To,createOverlayContainer:()=>At,createRangeFromOffsets:()=>bt,escapeHTML:()=>_o,fetchPlatformConfig:()=>Yd,formatTextMarkup:()=>Zd,getRangeOffsets:()=>mn,getRangeText:()=>fn,insertCKEditor:()=>Qd,isSupportedInputElement:()=>ir,updateContentEditable:()=>Xd,updateTextArea:()=>$d,useStyles:()=>S,waitForElementVisibilityChange:()=>ar});module.exports=hu(Tf);var Cn=T(require("classnames")),pe=T(require("react"));var xn=T(require("react")),qi=T(require("classnames")),Ro=xn.default.createContext({});function S(t,e){let{debug:o,...n}=(0,xn.useContext)(Ro),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,qi.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var Vi={root:"_root_vr71j_1"};var wt=require("react/jsx-runtime"),bn=()=>(0,wt.jsxs)("svg",{className:Vi.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,wt.jsx)("defs",{children:(0,wt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,wt.jsx)("title",{children:"Failed loading image"}),(0,wt.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 dr={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};var Tt=require("react/jsx-runtime"),wn=(0,pe.createContext)(dr),yu=({title:t,src:e})=>{let o=(0,pe.useContext)(wn),[n,s]=(0,pe.useState)(!1);return(0,pe.useEffect)(()=>{s(!1)},[e]),(0,Tt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,Tt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,Tt.jsx)(bn,{})})},Su=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,pe.useContext)(wn);return(0,Tt.jsx)("div",{className:(0,Cn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},vu=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,pe.useContext)(wn);return pe.default.createElement(t,{className:(0,Cn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Tn=({children:t})=>{let e=S("Card",dr);return(0,Tt.jsx)("div",{className:(0,Cn.default)(e.root),children:(0,Tt.jsx)(wn.Provider,{value:e,children:t})})};Tn.Image=yu;Tn.Content=Su;Tn.Title=vu;var D=Tn;var Gi=T(require("classnames"));var Wi={root:"_root_cq1yq_1"};var $i=require("react/jsx-runtime");var _u={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},xu=({className:t,keyCode:e,...o})=>{let n=S("KeyboardHint",Wi);return(0,$i.jsx)("span",{"data-key":_u[e],className:(0,Gi.default)(t,n.root),...o})},En=xu;var Qi=T(require("classnames"));var Xi={root:"_root_4a08n_1"};var Zi=require("react/jsx-runtime"),bu=({className:t,children:e,...o})=>{let n=S("Label",Xi);return(0,Zi.jsx)("span",{...o,className:(0,Qi.default)(t,n.root),children:e})},kn=bu;var Ji={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var jt=require("react/jsx-runtime"),Cu=({title:t,children:e,type:o,...n})=>{let s=S("Section",Ji);return(0,jt.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,jt.jsx)("div",{className:s.subTitleContainer,children:(0,jt.jsx)("span",{className:s.subtitle,children:t})}),(0,jt.jsx)("div",{className:s.suggestions,children:e})]})},rt=Cu;var ea=T(require("classnames")),ta=T(require("react"));var Yi={root:"_root_19wxp_1"};var oa=require("react/jsx-runtime"),wu=ta.default.forwardRef(({className:t,children:e},o)=>{let n=S("SectionList",Yi);return(0,oa.jsx)("div",{ref:o,className:(0,ea.default)(n.root,t),children:e})}),Rn=wu;var Io=T(require("classnames")),ue=T(require("react"));var ur={root:"_root_fsa1k_10",fadein:"_fadein_fsa1k_1",isClickable:"_isClickable_fsa1k_45",isSelected:"_isSelected_fsa1k_50",actions:"_actions_fsa1k_74",actionsIsFixed:"_actionsIsFixed_fsa1k_96",actionButton:"_actionButton_fsa1k_104",dropdownList:"_dropdownList_fsa1k_125",dropdownButton:"_dropdownButton_fsa1k_140",dropdownItem:"_dropdownItem_fsa1k_150",dropdownItemButton:"_dropdownItemButton_fsa1k_159",actionButtonIsPrimary:"_actionButtonIsPrimary_fsa1k_173",actionButtonIsDisabled:"_actionButtonIsDisabled_fsa1k_177",labels:"_labels_fsa1k_185",label:"_label_fsa1k_185"};var de=require("react/jsx-runtime"),qt=(0,ue.createContext)(ur),Tu=({fixed:t,children:e,...o})=>{let n=(0,ue.useContext)(qt);return(0,de.jsx)("div",{...o,className:(0,Io.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Eu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,ue.useContext)(qt);return(0,de.jsxs)("div",{className:(0,Io.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,de.jsx)("ul",{className:r.dropdownList,children:s})]})},ku=({index:t,label:e,onClick:o})=>{let n=(0,ue.useContext)(qt);return(0,de.jsx)("li",{className:n.dropdownItem,children:(0,de.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Ru=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,ue.useContext)(qt);return(0,de.jsx)("button",{type:"button",className:(0,Io.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},gr=({labels:t})=>{let e=(0,ue.useContext)(qt);return(0,de.jsx)("div",{className:e.labels,children:t.map(o=>(0,de.jsx)("span",{className:e.label,children:o},o))})},Vt=ue.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=S("Suggestion",ur),l=(0,ue.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,de.jsx)(s,{...r,ref:i,className:(0,Io.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,de.jsx)(qt.Provider,{value:a,children:n})})});Vt.Labels=gr;Vt.Actions=Tu;Vt.ActionButton=Ru;Vt.DropdownButton=Eu;Vt.DropdownItem=ku;var O=Vt;var sa=T(require("classnames"));var na={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var ra=require("react/jsx-runtime"),Iu=({withDivider:t,children:e})=>{let o=S("SuggestionList",na);return(0,ra.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,sa.default)(o.root,{[o.isWithDivider]:t}),children:e})},ge=Iu;var aa=T(require("classnames"));var ia={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var In=require("react/jsx-runtime"),Pu=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=S("ToggleButton",ia);return(0,In.jsx)("button",{type:"button",className:(0,aa.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,In.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,In.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Et=Pu;var la=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,Wt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ca=/x-deepdesk-(([a-z0-9\-_])+-version)/,_e=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(_e||{}),it=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(it||{});var Ae=require("react-dom");var jc=require("react");var pa=require("@reduxjs/toolkit"),da=require("react-redux");var Po=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Po||{});var Au={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showPersonalCollectionLink:!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,adminUrl:void 0,productName:"Deepdesk"},ua=(0,pa.createSlice)({name:"settings",initialState:Au,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Ao}=ua.actions,mr=t=>e=>e.settings[t],b=t=>(0,da.useSelector)(mr(t)),ga=ua.reducer;var pc=require("react"),go=require("react-redux");var Me=require("@reduxjs/toolkit"),Sa=require("diff"),va=require("react-redux");function ma(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function at(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)=>at(r,e[i],o-1)):ma(t)&&ma(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>at(t[i],e[i],o-1)):!1}function Lu(t){return Math.max(...t.map(e=>e.length))}function Mu(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 fa(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Lu(n);s++){let r=Mu(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 Ou=2;function fr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=fa(t,Ou);return o&&o.text!==e?o:t[0]}var xe=require("@reduxjs/toolkit"),ha={current:null,isSupported:null},P=(0,xe.createAction)("resetConversation"),Pn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},An=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Gt=t=>t.conversation.isSupported,hr=(0,xe.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Ln=(0,xe.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Mn=(0,xe.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),On=(0,xe.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=An(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),yr=(0,xe.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})})}),Nn=(0,xe.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=An(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Nu=[Ln.rejected,Mn.rejected,On.rejected,Nn.rejected].map(t=>t==null?void 0:t.toString()),Du=(0,xe.createSlice)({name:"conversation",initialState:ha,reducers:{},extraReducers:t=>{t.addCase(hr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Ln.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Mn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(yr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(On.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Nn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(P,()=>ha).addMatcher(e=>Nu.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),ya=Du.reducer;var lt={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 Hn(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 Bn=(0,Me.createAction)("input/replaceText"),Fn=(0,Me.createAction)("input/keyDown"),kt=(0,Me.createAction)("input/sendMessage"),Kn=(0,Me.createAction)("input/sendEditSuggestionMessage"),Un=(0,Me.createAction)("input/uiInputChange"),zn=(0,Me.createAction)("input/applyImageSuggestion"),re=(0,Me.createAction)("input/sendEvent");function Dn(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,d=o==="search"||o==="personal-collection-search",u=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(u=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(u=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:u,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:d?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var _a=t=>(0,Me.createSlice)({name:t,initialState:lt,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,{...lt,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=fr(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(at(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Dn(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:u,metaKey:m,altKey:f}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=e,{text:x}=o.payload,w=(0,Sa.diffChars)(g,x);g.length-x.length>1&&e.metrics.deletions.push(...w.filter(h=>h.removed).map(h=>h.value)),e.metrics.numCharsDeleted+=g.length-x.length;break}case"C":case"V":case"X":if(!u&&!m){e.metrics.numCharsTyped+=1;let g=((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;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}break;case"Shift":break;default:if(!u&&!m&&!f){e.metrics.numCharsTyped+=1;let g=((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;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=lt.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Dn(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"&&Dn(e)},commitSuggestion(e){Dn(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=fr(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)}},extraReducers:e=>{e.addCase(P,o=>{o.tabCompletionSuggestion=lt.tabCompletionSuggestion,o.previousKeyDownEvent=lt.previousKeyDownEvent,o.textSuggestions=lt.textSuggestions,o.selectedSuggestionIndex=lt.selectedSuggestionIndex,o.metrics=lt.metrics})}}),Sr=_a("input"),$t=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Hu=t=>t.input.selection,xa=()=>(0,va.useSelector)(Hu),{userInput:ba,changeSelection:vr,initialInput:Ca,mergeMetrics:wa,nextTextSuggestionIndex:Ta,offeredTextSuggestion:Ea,previousTextSuggestionIndex:ka,registerCut:Ra,registerKeyDown:Ia,registerPaste:Pa,reset:Aa,resetToCommitted:Lo,platformInput:La,setSelectedTextSuggestionIndex:Rt,setTextSuggestions:Oe,stageSuggestion:be,commitSuggestion:ct}=Sr.actions,Y=_a("overlay");var Xt=require("react");var Ma={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var _r=require("react/jsx-runtime"),Bu=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,Xt.useRef)(null),l=(0,Xt.useRef)(null),c=S("Dialog",Ma);return(0,Xt.useEffect)(()=>{var u,m;let p=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},d=f=>{let g=window.getSelection();g!=null&&g.toString()||f.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(m=a.current)==null||m.addEventListener("keyup",p),()=>{var f,g;(f=a.current)==null||f.removeEventListener("click",d),(g=a.current)==null||g.removeEventListener("keyup",p)}},[a,l,s,n]),(0,Xt.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,_r.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,_r.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},Qt=Bu;var Gr=require("react"),Ss=require("react-redux");var xr={};V(xr,{enUS:()=>Fu,nlNL:()=>Ku});var Fu={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?"}]},Ku={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 Oa={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};var os=require("react");var br=function(t,e){return br=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])},br(t,e)};function Mo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");br(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var ie=function(){return ie=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},ie.apply(this,arguments)};function Na(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 jn(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 qn;(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"})(qn||(qn={}));var Vn=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Ce;(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"})(Ce||(Ce={}));var Wn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Wn||(Wn={}));function Cr(t){return t.type===Ce.literal}function Da(t){return t.type===Ce.argument}function Gn(t){return t.type===Ce.number}function $n(t){return t.type===Ce.date}function Xn(t){return t.type===Ce.time}function Qn(t){return t.type===Ce.select}function Zn(t){return t.type===Ce.plural}function Ha(t){return t.type===Ce.pound}function Jn(t){return t.type===Ce.tag}function Yn(t){return!!(t&&typeof t=="object"&&t.type===Wn.number)}function Oo(t){return!!(t&&typeof t=="object"&&t.type===Wn.dateTime)}function wr(t){t.forEach(function(e){if(delete e.location,Qn(e)||Zn(e))for(var o in e.options)delete e.options[o].location,wr(e.options[o].value);else Gn(e)&&Yn(e.style)||($n(e)||Xn(e))&&Oo(e.style)?delete e.style.location:Jn(e)&&wr(e.children)})}function Ba(t,e){e===void 0&&(e={}),e=ie({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Vn(t,e).parse();if(o.err){var n=SyntaxError(qn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||wr(o.val),o.val}function es(t,e){var o=e&&e.cache?e.cache:Wu,n=e&&e.serializer?e.serializer:Vu,s=e&&e.strategy?e.strategy:zu;return s(t,{cache:o,serializer:n})}function Uu(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Fa(t,e,o,n){var s=Uu(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Ka(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 Tr(t,e,o,n,s){return o.bind(e,t,n,s)}function zu(t,e){var o=t.length===1?Fa:Ka;return Tr(t,this,o,e.cache.create(),e.serializer)}function ju(t,e){return Tr(t,this,Ka,e.cache.create(),e.serializer)}function qu(t,e){return Tr(t,this,Fa,e.cache.create(),e.serializer)}var Vu=function(){return JSON.stringify(arguments)};function Er(){this.cache=Object.create(null)}Er.prototype.get=function(t){return this.cache[t]};Er.prototype.set=function(t,e){this.cache[t]=e};var Wu={create:function(){return new Er}},ts={variadic:ju,monadic:qu};var It;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(It||(It={}));var No=function(t){Mo(e,t);function e(o,n,s){var r=t.call(this,o)||this;return r.code=n,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var kr=function(t){Mo(e,t);function e(o,n,s,r){return t.call(this,'Invalid values for "'.concat(o,'": "').concat(n,'". Options are "').concat(Object.keys(s).join('", "'),'"'),It.INVALID_VALUE,r)||this}return e}(No);var Ua=function(t){Mo(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),It.INVALID_VALUE,s)||this}return e}(No);var za=function(t){Mo(e,t);function e(o,n){return t.call(this,'The intl string context variable "'.concat(o,'" was not provided to the string "').concat(n,'"'),It.MISSING_VALUE,n)||this}return e}(No);var W;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(W||(W={}));function Gu(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==W.literal||o.type!==W.literal?e.push(o):n.value+=o.value,e},[])}function $u(t){return typeof t=="function"}function Do(t,e,o,n,s,r,i){if(t.length===1&&Cr(t[0]))return[{type:W.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Cr(p)){a.push({type:W.literal,value:p.value});continue}if(Ha(p)){typeof r=="number"&&a.push({type:W.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new za(d,i);var u=s[d];if(Da(p)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?W.literal:W.object,value:u});continue}if($n(p)){var m=typeof p.style=="string"?n.date[p.style]:Oo(p.style)?p.style.parsedOptions:void 0;a.push({type:W.literal,value:o.getDateTimeFormat(e,m).format(u)});continue}if(Xn(p)){var m=typeof p.style=="string"?n.time[p.style]:Oo(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:W.literal,value:o.getDateTimeFormat(e,m).format(u)});continue}if(Gn(p)){var m=typeof p.style=="string"?n.number[p.style]:Yn(p.style)?p.style.parsedOptions:void 0;m&&m.scale&&(u=u*(m.scale||1)),a.push({type:W.literal,value:o.getNumberFormat(e,m).format(u)});continue}if(Jn(p)){var f=p.children,g=p.value,x=s[g];if(!$u(x))throw new Ua(g,"function",i);var w=Do(f,e,o,n,s,r),h=x(w.map(function(C){return C.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(C){return{type:typeof C=="string"?W.literal:W.object,value:C}}))}if(Qn(p)){var y=p.options[u]||p.options.other;if(!y)throw new kr(p.value,u,Object.keys(p.options),i);a.push.apply(a,Do(y.value,e,o,n,s));continue}if(Zn(p)){var y=p.options["=".concat(u)];if(!y){if(!Intl.PluralRules)throw new No(`Intl.PluralRules is not available in this environment.
|
|
1
|
+
"use strict";var Cd=Object.create;var Cn=Object.defineProperty;var wd=Object.getOwnPropertyDescriptor;var Td=Object.getOwnPropertyNames;var Ed=Object.getPrototypeOf,kd=Object.prototype.hasOwnProperty;var G=(t,e)=>{for(var o in e)Cn(t,o,{get:e[o],enumerable:!0})},Qi=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Td(e))!kd.call(t,s)&&s!==o&&Cn(t,s,{get:()=>e[s],enumerable:!(n=wd(e,s))||n.enumerable});return t};var w=(t,e,o)=>(o=t!=null?Cd(Ed(t)):{},Qi(e||!t||!t.__esModule?Cn(o,"default",{value:t,enumerable:!0}):o,t)),Rd=t=>Qi(Cn({},"__esModule",{value:!0}),t);var jf={};G(jf,{Card:()=>H,ContentEditableInput:()=>jt,DeepdeskAPI:()=>st,DeepdeskSDK:()=>xn,HTTPClient:()=>Le,InputMediator:()=>ze,InputType:()=>at,KeyboardHint:()=>In,Label:()=>Pn,Locale:()=>Oo,Section:()=>it,SectionList:()=>An,Sources:()=>Ce,Suggestion:()=>O,SuggestionList:()=>Se,TextAreaInput:()=>je,ToggleButton:()=>Rt,attachFile:()=>ud,authenticateWithKey:()=>cd,createFullRange:()=>Io,createOverlayContainer:()=>Lt,createRangeFromOffsets:()=>wt,escapeHTML:()=>wo,fetchPlatformConfig:()=>pd,formatTextMarkup:()=>ld,getRangeOffsets:()=>yn,getRangeText:()=>Sn,insertCKEditor:()=>ad,isSupportedInputElement:()=>ur,updateContentEditable:()=>id,updateTextArea:()=>rd,useStyles:()=>S,waitForElementVisibilityChange:()=>dr});module.exports=Rd(jf);var En=w(require("classnames")),fe=w(require("react"));var wn=w(require("react")),Zi=w(require("classnames")),Lo=wn.default.createContext({});function S(t,e){let{debug:o,...n}=(0,wn.useContext)(Lo),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,Zi.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var Ji={root:"_root_vr71j_1"};var Et=require("react/jsx-runtime"),Tn=()=>(0,Et.jsxs)("svg",{className:Ji.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Et.jsx)("defs",{children:(0,Et.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Et.jsx)("title",{children:"Failed loading image"}),(0,Et.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 hr={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};var kt=require("react/jsx-runtime"),kn=(0,fe.createContext)(hr),Id=({title:t,src:e})=>{let o=(0,fe.useContext)(kn),[n,s]=(0,fe.useState)(!1);return(0,fe.useEffect)(()=>{s(!1)},[e]),(0,kt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,kt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,kt.jsx)(Tn,{})})},Pd=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,fe.useContext)(kn);return(0,kt.jsx)("div",{className:(0,En.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Ad=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,fe.useContext)(kn);return fe.default.createElement(t,{className:(0,En.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Rn=({children:t})=>{let e=S("Card",hr);return(0,kt.jsx)("div",{className:(0,En.default)(e.root),children:(0,kt.jsx)(kn.Provider,{value:e,children:t})})};Rn.Image=Id;Rn.Content=Pd;Rn.Title=Ad;var H=Rn;var ea=w(require("classnames"));var Yi={root:"_root_cq1yq_1"};var ta=require("react/jsx-runtime");var Ld={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Md=({className:t,keyCode:e,...o})=>{let n=S("KeyboardHint",Yi);return(0,ta.jsx)("span",{"data-key":Ld[e],className:(0,ea.default)(t,n.root),...o})},In=Md;var na=w(require("classnames"));var oa={root:"_root_4a08n_1"};var sa=require("react/jsx-runtime"),Od=({className:t,children:e,...o})=>{let n=S("Label",oa);return(0,sa.jsx)("span",{...o,className:(0,na.default)(t,n.root),children:e})},Pn=Od;var ra={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var Gt=require("react/jsx-runtime"),Nd=({title:t,children:e,type:o,...n})=>{let s=S("Section",ra);return(0,Gt.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,Gt.jsx)("div",{className:s.subTitleContainer,children:(0,Gt.jsx)("span",{className:s.subtitle,children:t})}),(0,Gt.jsx)("div",{className:s.suggestions,children:e})]})},it=Nd;var aa=w(require("classnames")),la=w(require("react"));var ia={root:"_root_19wxp_1"};var ca=require("react/jsx-runtime"),Dd=la.default.forwardRef(({className:t,children:e},o)=>{let n=S("SectionList",ia);return(0,ca.jsx)("div",{ref:o,className:(0,aa.default)(n.root,t),children:e})}),An=Dd;var Mo=w(require("classnames")),ye=w(require("react"));var yr={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 he=require("react/jsx-runtime"),$t=(0,ye.createContext)(yr),Hd=({fixed:t,children:e,...o})=>{let n=(0,ye.useContext)($t);return(0,he.jsx)("div",{...o,className:(0,Mo.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Bd=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,ye.useContext)($t);return(0,he.jsxs)("div",{className:(0,Mo.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,he.jsx)("ul",{className:r.dropdownList,children:s})]})},Fd=({index:t,label:e,onClick:o})=>{let n=(0,ye.useContext)($t);return(0,he.jsx)("li",{className:n.dropdownItem,children:(0,he.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Kd=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,ye.useContext)($t);return(0,he.jsx)("button",{type:"button",className:(0,Mo.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Sr=({labels:t})=>{let e=(0,ye.useContext)($t);return(0,he.jsx)("div",{className:e.labels,children:t.map(o=>(0,he.jsx)("span",{className:e.label,children:o},o))})},Xt=ye.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=S("Suggestion",yr),l=(0,ye.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,he.jsx)(s,{...r,ref:i,className:(0,Mo.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,he.jsx)($t.Provider,{value:a,children:n})})});Xt.Labels=Sr;Xt.Actions=Hd;Xt.ActionButton=Kd;Xt.DropdownButton=Bd;Xt.DropdownItem=Fd;var O=Xt;var ua=w(require("classnames"));var pa={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var da=require("react/jsx-runtime"),Ud=({withDivider:t,children:e})=>{let o=S("SuggestionList",pa);return(0,da.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,ua.default)(o.root,{[o.isWithDivider]:t}),children:e})},Se=Ud;var ma=w(require("classnames"));var ga={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Ln=require("react/jsx-runtime"),zd=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=S("ToggleButton",ga);return(0,Ln.jsx)("button",{type:"button",className:(0,ma.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,Ln.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Ln.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Rt=zd;var fa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,Qt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ha=/x-deepdesk-(([a-z0-9\-_])+-version)/,Ce=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(Ce||{}),at=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(at||{});var Me=require("react-dom");var ep=require("react");var ya=require("@reduxjs/toolkit"),Sa=require("react-redux");var Oo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Oo||{});var jd={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showPersonalCollectionLink:!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,adminUrl:void 0,productName:"Deepdesk"},va=(0,ya.createSlice)({name:"settings",initialState:jd,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:No}=va.actions,vr=t=>e=>e.settings[t],b=t=>(0,Sa.useSelector)(vr(t)),_a=va.reducer;var xc=require("react"),yo=require("react-redux");var Oe=require("@reduxjs/toolkit"),Ta=require("diff"),Ea=require("react-redux");function xa(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function lt(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)=>lt(r,e[i],o-1)):xa(t)&&xa(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>lt(t[i],e[i],o-1)):!1}function qd(t){return Math.max(...t.map(e=>e.length))}function Vd(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 ba(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<qd(n);s++){let r=Vd(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 Wd=2;function _r(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=ba(t,Wd);return o&&o.text!==e?o:t[0]}var we=require("@reduxjs/toolkit"),Ca={current:null,isSupported:null},P=(0,we.createAction)("resetConversation"),Mn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},On=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Zt=t=>t.conversation.isSupported,xr=(0,we.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Nn=(0,we.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Dn=(0,we.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Hn=(0,we.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=On(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),br=(0,we.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})})}),Bn=(0,we.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=On(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Gd=[Nn.rejected,Dn.rejected,Hn.rejected,Bn.rejected].map(t=>t==null?void 0:t.toString()),$d=(0,we.createSlice)({name:"conversation",initialState:Ca,reducers:{},extraReducers:t=>{t.addCase(xr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Nn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Dn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(br.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Hn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Bn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(P,()=>Ca).addMatcher(e=>Gd.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),wa=$d.reducer;var ct={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 Kn(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 Un=(0,Oe.createAction)("input/replaceText"),zn=(0,Oe.createAction)("input/keyDown"),It=(0,Oe.createAction)("input/sendMessage"),jn=(0,Oe.createAction)("input/sendEditSuggestionMessage"),qn=(0,Oe.createAction)("input/uiInputChange"),Vn=(0,Oe.createAction)("input/applyImageSuggestion"),$=(0,Oe.createAction)("input/sendEvent");function Fn(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,u=o==="search"||o==="personal-collection-search",d=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(u||p==="selection")&&(d=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(d=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:d,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:u?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var ka=t=>(0,Oe.createSlice)({name:t,initialState:ct,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,{...ct,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=_r(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(lt(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Fn(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:u,ctrlKey:d,metaKey:m,altKey:f}=e.previousKeyDownEvent;switch(p){case"Enter":u&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=e,{text:v}=o.payload,T=(0,Ta.diffChars)(g,v);g.length-v.length>1&&e.metrics.deletions.push(...T.filter(h=>h.removed).map(h=>h.value)),e.metrics.numCharsDeleted+=g.length-v.length;break}case"C":case"V":case"X":if(!d&&!m){e.metrics.numCharsTyped+=1;let g=((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;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}break;case"Shift":break;default:if(!d&&!m&&!f){e.metrics.numCharsTyped+=1;let g=((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;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=ct.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Fn(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"&&Fn(e)},commitSuggestion(e){Fn(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=_r(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)}},extraReducers:e=>{e.addCase(P,o=>{o.tabCompletionSuggestion=ct.tabCompletionSuggestion,o.previousKeyDownEvent=ct.previousKeyDownEvent,o.textSuggestions=ct.textSuggestions,o.selectedSuggestionIndex=ct.selectedSuggestionIndex,o.metrics=ct.metrics})}}),Cr=ka("input"),Jt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Xd=t=>t.input.selection,Ra=()=>(0,Ea.useSelector)(Xd),{userInput:Ia,changeSelection:wr,initialInput:Pa,mergeMetrics:Aa,nextTextSuggestionIndex:La,offeredTextSuggestion:Ma,previousTextSuggestionIndex:Oa,registerCut:Na,registerKeyDown:Da,registerPaste:Ha,reset:Ba,resetToCommitted:Do,platformInput:Fa,setSelectedTextSuggestionIndex:pt,setTextSuggestions:Ne,stageSuggestion:Te,commitSuggestion:ut}=Cr.actions,ne=ka("overlay");var Yt=require("react");var Ka={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var Tr=require("react/jsx-runtime"),Qd=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,Yt.useRef)(null),l=(0,Yt.useRef)(null),c=S("Dialog",Ka);return(0,Yt.useEffect)(()=>{var d,m;let p=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},u=f=>{let g=window.getSelection();g!=null&&g.toString()||f.target===a.current&&t&&n()};return(d=a.current)==null||d.addEventListener("click",u),(m=a.current)==null||m.addEventListener("keyup",p),()=>{var f,g;(f=a.current)==null||f.removeEventListener("click",u),(g=a.current)==null||g.removeEventListener("keyup",p)}},[a,l,s,n]),(0,Yt.useEffect)(()=>{var p,u;!a.current||!t||!e||(u=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||u.focus()},[t,e,a]),t?(0,Tr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,Tr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},eo=Qd;var ti=require("react"),Cs=require("react-redux");var Er={};G(Er,{enUS:()=>Zd,nlNL:()=>Jd});var Zd={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?"}]},Jd={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 Ua={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};var rs=require("react");var kr=function(t,e){return kr=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])},kr(t,e)};function Ho(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");kr(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var ce=function(){return ce=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},ce.apply(this,arguments)};function za(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 Wn(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 Gn;(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"})(Gn||(Gn={}));var $n=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Ee;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(Ee||(Ee={}));var Xn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Xn||(Xn={}));function Rr(t){return t.type===Ee.literal}function ja(t){return t.type===Ee.argument}function Qn(t){return t.type===Ee.number}function Zn(t){return t.type===Ee.date}function Jn(t){return t.type===Ee.time}function Yn(t){return t.type===Ee.select}function es(t){return t.type===Ee.plural}function qa(t){return t.type===Ee.pound}function ts(t){return t.type===Ee.tag}function os(t){return!!(t&&typeof t=="object"&&t.type===Xn.number)}function Bo(t){return!!(t&&typeof t=="object"&&t.type===Xn.dateTime)}function Ir(t){t.forEach(function(e){if(delete e.location,Yn(e)||es(e))for(var o in e.options)delete e.options[o].location,Ir(e.options[o].value);else Qn(e)&&os(e.style)||(Zn(e)||Jn(e))&&Bo(e.style)?delete e.style.location:ts(e)&&Ir(e.children)})}function Va(t,e){e===void 0&&(e={}),e=ce({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new $n(t,e).parse();if(o.err){var n=SyntaxError(Gn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Ir(o.val),o.val}function ns(t,e){var o=e&&e.cache?e.cache:sg,n=e&&e.serializer?e.serializer:ng,s=e&&e.strategy?e.strategy:eg;return s(t,{cache:o,serializer:n})}function Yd(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Wa(t,e,o,n){var s=Yd(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Ga(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 Pr(t,e,o,n,s){return o.bind(e,t,n,s)}function eg(t,e){var o=t.length===1?Wa:Ga;return Pr(t,this,o,e.cache.create(),e.serializer)}function tg(t,e){return Pr(t,this,Ga,e.cache.create(),e.serializer)}function og(t,e){return Pr(t,this,Wa,e.cache.create(),e.serializer)}var ng=function(){return JSON.stringify(arguments)};function Ar(){this.cache=Object.create(null)}Ar.prototype.get=function(t){return this.cache[t]};Ar.prototype.set=function(t,e){this.cache[t]=e};var sg={create:function(){return new Ar}},ss={variadic:tg,monadic:og};var Pt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Pt||(Pt={}));var Fo=function(t){Ho(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 Lr=function(t){Ho(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('", "'),'"'),Pt.INVALID_VALUE,r)||this}return e}(Fo);var $a=function(t){Ho(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Pt.INVALID_VALUE,s)||this}return e}(Fo);var Xa=function(t){Ho(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,'"'),Pt.MISSING_VALUE,n)||this}return e}(Fo);var X;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(X||(X={}));function rg(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==X.literal||o.type!==X.literal?e.push(o):n.value+=o.value,e},[])}function ig(t){return typeof t=="function"}function Ko(t,e,o,n,s,r,i){if(t.length===1&&Rr(t[0]))return[{type:X.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Rr(p)){a.push({type:X.literal,value:p.value});continue}if(qa(p)){typeof r=="number"&&a.push({type:X.literal,value:o.getNumberFormat(e).format(r)});continue}var u=p.value;if(!(s&&u in s))throw new Xa(u,i);var d=s[u];if(ja(p)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?X.literal:X.object,value:d});continue}if(Zn(p)){var m=typeof p.style=="string"?n.date[p.style]:Bo(p.style)?p.style.parsedOptions:void 0;a.push({type:X.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(Jn(p)){var m=typeof p.style=="string"?n.time[p.style]:Bo(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:X.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(Qn(p)){var m=typeof p.style=="string"?n.number[p.style]:os(p.style)?p.style.parsedOptions:void 0;m&&m.scale&&(d=d*(m.scale||1)),a.push({type:X.literal,value:o.getNumberFormat(e,m).format(d)});continue}if(ts(p)){var f=p.children,g=p.value,v=s[g];if(!ig(v))throw new $a(g,"function",i);var T=Ko(f,e,o,n,s,r),h=v(T.map(function(C){return C.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(C){return{type:typeof C=="string"?X.literal:X.object,value:C}}))}if(Yn(p)){var y=p.options[d]||p.options.other;if(!y)throw new Lr(p.value,d,Object.keys(p.options),i);a.push.apply(a,Ko(y.value,e,o,n,s));continue}if(es(p)){var y=p.options["=".concat(d)];if(!y){if(!Intl.PluralRules)throw new Fo(`Intl.PluralRules is not available in this environment.
|
|
2
2
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
3
|
-
`,It.MISSING_INTL_API,i);var v=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));y=p.options[v]||p.options.other}if(!y)throw new kr(p.value,u,Object.keys(p.options),i);a.push.apply(a,Do(y.value,e,o,n,s,u-(p.offset||0)));continue}}return Gu(a)}function Xu(t,e){return e?ie(ie(ie({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=ie(ie({},t[n]),e[n]||{}),o},{})):t}function Qu(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Xu(t[n],e[n]),o},ie({},t)):t}function Rr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Zu(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:es(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,jn([void 0],o,!1)))},{cache:Rr(t.number),strategy:ts.variadic}),getDateTimeFormat:es(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,jn([void 0],o,!1)))},{cache:Rr(t.dateTime),strategy:ts.variadic}),getPluralRules:es(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,jn([void 0],o,!1)))},{cache:Rr(t.pluralRules),strategy:ts.variadic})}}var ja=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var d=p.reduce(function(u,m){return!u.length||m.type!==W.literal||typeof u[u.length-1]!="string"?u.push(m.value):u[u.length-1]+=m.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Do(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=Na(i,["formatters"]);this.ast=t.__parse(e,ie(ie({},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=Qu(t.formats,n),this.formatters=s&&s.formatters||Zu(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=Ba,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 Ju(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Yu="dummy",Ir=(0,os.createContext)(null);function E(t){let e=(0,os.useContext)(Ir);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=Ju(o,n);return r?new ja(r).format(s):(e!==Yu&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var Ho=require("react/jsx-runtime"),ns=()=>(0,Ho.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Ho.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Ho.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 Bo=require("react/jsx-runtime"),qa=()=>(0,Bo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,Bo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,Bo.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 me=require("react"),al=require("react-redux"),ll=require("interweave"),Fr=T(require("classnames"));var Pr={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var Wa=require("interweave"),Ga=T(require("classnames"));var Zt=require("react");function Va(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function ss(t){let e=(0,Zt.useRef)(null),[o,n]=(0,Zt.useState)(!1);return(0,Zt.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Va((p,d)=>{let u=e.current;if(!u)return;let m=p/r,f=d/r,g=u.getBoundingClientRect(),x=m>g.x&&m<g.x+g.width&&f>g.y&&f<g.y+g.height;x&&!s?(s=!0,n(!0)):!x&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=Va(()=>{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 Fe={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 Ar=require("react/jsx-runtime"),eg=({inputElement:t,children:e})=>{let o=S("TabCompletion",Fe),[n,s]=ss(t);return(0,Ar.jsx)("mark",{ref:n,className:(0,Ga.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},Jt=class extends Wa.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,Ar.jsx)(eg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Yt=require("react");function rs(t){return t.contentEditable==="true"}function tg(t){let e=0,o=0,n=window.getSelection();if(n.rangeCount!==0){let s=n.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),o=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:o}}function $a(t){let{selectionStart:e,selectionEnd:o}=rs(t)?tg(t):t;return[e,o]}function is(t){let[,e]=(0,Yt.useState)(),o=(0,Yt.useRef)(null);return o.current=$a(t),(0,Yt.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=$a(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 as(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(Wt);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 Xa=require("react");function eo(t){(0,Xa.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Pt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Qa,Ne=new Map,og=["bottom","height","left","right","top","width"],ng=(t={},e={})=>og.some(o=>t[o]!==e[o]);function Za(t){var o,n;let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...Za(e)]:[]}function Ja(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var Lr=!1,Ya=()=>{Lr=!0;let t=[];Ne.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Ne.delete(o);return}let n=o.getBoundingClientRect();ng(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(Ja,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),Ne.size!==0&&(Qa=window.requestAnimationFrame(Ya))};function Mr(t,e){let o=Za(t),n=[],s=o.map((r,i)=>Mr(r,a=>{n[i]=a;let l=Ne.get(t);if(!l)return;let c=n.reduce(Ja,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Ne.has(t)){let i=Ne.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Ne.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!Lr&&Ya()},unobserve(){s.forEach(i=>i.unobserve());let r=Ne.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Ne.delete(t),Ne.size||(cancelAnimationFrame(Qa),Lr=!1)}}}}var el,De=new Map,tl=()=>{De.forEach((t,e)=>{if(!e.isConnected){De.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)))}),De.size!==0&&(el=window.requestAnimationFrame(tl))};function ol(t,e){return{observe(){let o=De.size===0;De.has(t)?De.get(t).callbacks.push(e):De.set(t,{visible:void 0,callbacks:[e]}),o&&tl()},unobserve(){let o=De.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||De.delete(t),De.size||cancelAnimationFrame(el)}}}}var Or=["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 Nr(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function to(t){return parseFloat(t)}function ls(t){return Math.round(t*1e6)}function nl(t){return t/1e6}function Dr(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=to(t.width),r=to(t.borderLeftWidth),i=to(t.borderRightWidth),a=to(t.paddingRight),l=nl(ls(s)-ls(r)-ls(i)),c=nl(ls(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function At(t,e={}){var l;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Pt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Nr(n,o,Or),Dr(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=ol(t,()=>{Nr(n,o,Or),Dr(n,t,o),r(),setTimeout(r,0)}),a=Mr(t,c=>{if(c===null){e.onRemove&&e.onRemove(),o.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Nr(n,o,Or),Dr(n,t,o),r(),o.style.top=`${c.top}px`,o.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),d=window.getComputedStyle(e.closestScrollElement),u=to(d.borderTopWidth),m=to(d.borderBottomWidth),f=p.top+u-c.top,g=c.top+c.height+-(p.top+p.height-m);o.style.clipPath=`inset(${f}px 0px ${g}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var Hr={};V(Hr,{enUS:()=>sg,nlNL:()=>rg});var sg={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"}]},rg={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 Fo=require("react/jsx-runtime"),sl=()=>(0,Fo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Fo.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Fo.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 Br=require("react/jsx-runtime"),rl=()=>(0,Br.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Br.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});function ig(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function cs(t){return t?t instanceof ShadowRoot?cs(t.host):t===t.ownerDocument.body?t.ownerDocument:ig(t)?t:cs(t.parentNode):document.body}var il=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(il||{}),Ke=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();at(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(il).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()});let o=cs(this.element);if(o){let n=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};o.addEventListener("scroll",n),this.disposeHandlers.push(()=>{o.removeEventListener("scroll",n)})}this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var Ue=class extends Ke{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 ee=require("react/jsx-runtime"),ag=({value:t,onUse:e,...o})=>{var p;let n=E(Hr),s=(0,al.useDispatch)(),r=S("EditSuggestionTextInput",Pr),[i,a]=(0,me.useState)(null),l=(0,me.useRef)(null),c=((p=t.match(Wt))==null?void 0:p.length)||0;return(0,me.useEffect)(()=>{let d;return l.current&&(a(l.current),d=new Ue(l.current),d.on("change",({plainText:u})=>{s(Y.actions.userInput({text:u,selection:d.getSelection()}))}),d.on("keydown",u=>{s(Y.actions.registerKeyDown(Hn(u))),u.code==="Enter"&&u.shiftKey&&e(d.getText())}),d.on("paste",({pastedText:u,selectionText:m})=>{s(Y.actions.registerPaste({text:u,selectionText:m}))}),d.on("cut",({selectionText:u})=>{s(Y.actions.registerCut(u))})),()=>{s(Y.actions.reset()),d.dispose(),d.deactivate()}},[l]),(0,me.useEffect)(()=>{t&&l.current&&(l.current.value=t)},[t,l]),(0,me.useEffect)(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let d=l.current.value.length;l.current.setSelectionRange(d,d),l.current.focus()},0)},[l]),(0,ee.jsxs)("div",{className:r.textInputWrapper,children:[(0,ee.jsx)("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&(0,ee.jsx)(lg,{inputElement:l.current,value:t}),(0,ee.jsxs)("div",{className:(0,Fr.default)(r.alert,c===0?r.success:r.warning),children:[(0,ee.jsx)("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?(0,ee.jsx)(sl,{}):(0,ee.jsx)(rl,{})]})]})},lg=({inputElement:t,value:e})=>{let o=S("EditSuggestionTextInput",Pr),n=(0,me.useRef)(null),s=is(t);return(0,me.useEffect)(()=>{as(t,s)},[s,t]),(0,ee.jsx)(cg,{inputElement:t,children:(0,ee.jsxs)("div",{ref:n,className:(0,Fr.default)(o.root,o.agentText),children:[(0,ee.jsx)(ll.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new Jt("placeholders")],inputElement:t,boundaryRef:n}),(0,ee.jsx)("br",{})]})})},cg=({inputElement:t,children:e})=>{let o=(0,me.useRef)(null);return(0,me.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=At(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,ee.jsx)("div",{ref:o,children:e})},cl=ag;var ro=require("react");var pl=require("react"),ps=T(require("classnames"));var te={root:"_root_185k9_1",list:"_list_185k9_2",listWrapper:"_listWrapper_185k9_6",listHorizontal:"_listHorizontal_185k9_10",page:"_page_185k9_19",search:"_search_185k9_25",pageNav:"_pageNav_185k9_33",pageTitle:"_pageTitle_185k9_41",pageBackButton:"_pageBackButton_185k9_48",listHeading:"_listHeading_185k9_62",listItem:"_listItem_185k9_70",listItemContent:"_listItemContent_185k9_79",listItemText:"_listItemText_185k9_97",listItemDescription:"_listItemDescription_185k9_105",truncate:"_truncate_185k9_112",lineClamp:"_lineClamp_185k9_118",listItemTitle:"_listItemTitle_185k9_125",listItemAction:"_listItemAction_185k9_132",listItemPrimaryAction:"_listItemPrimaryAction_185k9_146",listItemSelected:"_listItemSelected_185k9_151",sources:"_sources_185k9_155",sourcesTitle:"_sourcesTitle_185k9_162",source:"_source_185k9_155",icon:"_icon_185k9_177",searchIcon:"_searchIcon_185k9_194",searchInputWrapper:"_searchInputWrapper_185k9_199",searchInput:"_searchInput_185k9_199",select:"_select_185k9_220",selectType:"_selectType_185k9_237",selectWrapper:"_selectWrapper_185k9_241",image:"_image_185k9_271",imageSrc:"_imageSrc_185k9_278",imageSrcHidden:"_imageSrcHidden_185k9_289",imageSrcStatus:"_imageSrcStatus_185k9_293",imageTitle:"_imageTitle_185k9_303",actions:"_actions_185k9_308",actionsWrapper:"_actionsWrapper_185k9_312",actionsBar:"_actionsBar_185k9_318",actionButton:"_actionButton_185k9_327",actionShortcut:"_actionShortcut_185k9_345",actionShortcutFixKerning:"_actionShortcutFixKerning_185k9_352"};var Lt={};V(Lt,{enUS:()=>pg,nlNL:()=>dg});var pg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},dg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var pt=require("react/jsx-runtime"),ug=({src:t,title:e})=>{let o=S("CommandPalette",te),[n,s]=(0,pl.useState)("loading"),r=E(Lt);return(0,pt.jsxs)("div",{className:o.image,children:[(0,pt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,ps.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,pt.jsx)("span",{className:(0,ps.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,pt.jsx)("span",{className:(0,ps.default)(o.imageSrc,o.imageSrcStatus),children:(0,pt.jsx)(bn,{})}),e&&(0,pt.jsx)("span",{className:o.imageTitle,children:e})]})},dl=ug;var ul=T(require("react")),gl=T(require("classnames"));var Ko=require("react/jsx-runtime");function Kr({children:t,heading:e,orientation:o}){let n=S("CommandPalette",te);return ul.default.Children.count(t)===0?null:(0,Ko.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,Ko.jsx)("h4",{className:n.listHeading,children:e}),(0,Ko.jsx)("div",{className:(0,gl.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var Uo=T(require("classnames"));var ds=T(require("react")),hl=require("react/jsx-runtime"),ml=ds.default.createContext(void 0);function dt(){let t=ds.default.useContext(ml);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var fl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=ds.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,hl.jsx)(ml.Provider,{value:i,children:t})};var we=require("react/jsx-runtime");function Ur({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onSourceClick:s,index:r,description:i,sources:a,styles:l,...c}){let{selected:p,onChangeOpen:d}=dt(),u=S("CommandPalette",te);function m(f){n(f),t&&d(!1)}return(0,we.jsxs)("div",{className:(0,Uo.default)(u.listItem,p===r&&u.listItemSelected),children:[(0,we.jsx)("button",{type:"button",className:(0,Uo.default)("command-palette-list-item",u.listItemAction,u.listItemPrimaryAction),"aria-disabled":c.disabled??!1,onClick:m,...c,children:(0,we.jsxs)("div",{className:u.listItemContent,children:[typeof o=="string"?(0,we.jsx)("p",{className:(0,Uo.default)(u.listItemText,u.truncate,l==null?void 0:l.title),children:o}):o,i&&(0,we.jsx)("p",{className:(0,Uo.default)(u.listItemDescription,l==null?void 0:l.description,e?u.lineClamp:u.truncate),children:i})]})}),a&&(0,we.jsxs)("div",{className:u.sources,children:[(0,we.jsx)("span",{className:u.sourcesTitle,children:"Sources"}),a.map(f=>f.url?(0,we.jsx)("a",{className:u.source,href:f.url,target:"_blank",title:f.url,rel:"noopener noreferrer",onClick:()=>s&&s(f),children:f.name},f.url):(0,we.jsx)("span",{className:u.source,children:f.name},f.name))]})]})}var Mt=require("react/jsx-runtime");function zr({children:t,title:e,id:o,onDismiss:n}){let s=E(Lt),r=S("CommandPalette",te),{page:i}=dt();return i!==o?null:(0,Mt.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,Mt.jsxs)("div",{className:r.pageNav,children:[(0,Mt.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,Mt.jsx)(ns,{}),s("back")]}),e&&(0,Mt.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var ut=require("react");var us=()=>/Mac/i.test(navigator.platform);var ms=require("@reduxjs/toolkit");var gg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=gg;var oo=require("@reduxjs/toolkit");function mg(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function M(t){return Array.isArray(t)?t.map(M):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[mg(o)]:M(t[o])}),{}):t}function jr(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function U(t){return Array.isArray(t)?t.map(U):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[jr(o)]:U(t[o])}),{}):t}var fg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},jo=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)||""}},zo=(0,oo.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?M(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),M(n))}),qr=(0,oo.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}),Vr=(0,oo.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),yl=t=>t.info.agentInfo,Sl=(0,oo.createSlice)({name:"info",initialState:fg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(zo.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(zo.rejected,e=>{e.fetchState="error"}).addCase(zo.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(qr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(Vr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(P,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:vl}=Sl.actions,_l=Sl.reducer;var gs={list:[],fetchState:"idle",isOpen:!1,page:"search"},xl=t=>t.search.isOpen,bl=t=>t.search.page,Cl=t=>t.search.list;function wl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Ot=(0,ms.createAsyncThunk)("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:jo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),Tl=(0,ms.createSlice)({name:"search",initialState:gs,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=gs.fetchState,t.list=gs.list}},extraReducers:t=>{t.addCase(Ot.pending,e=>{e.fetchState="loading"}).addCase(Ot.rejected,(e,o)=>{e.fetchState="error",k.error(o.error)}).addCase(Ot.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(P,()=>gs)}}),{resetSearch:fs,setIsOpen:ae,setPage:X}=Tl.actions,El=Tl.reducer;var hg=/(https?:\/\/[^\s]+)/,hs=t=>t.split(" ").find(e=>hg.test(e));var Wr=T(require("classnames"));var ys=require("react/jsx-runtime"),yg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=S("CommandPalette",te);return(0,ys.jsxs)("button",{type:"button",...n,onClick:t,className:(0,Wr.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,ys.jsx)("span",{className:(0,Wr.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},no=yg;var ze=require("react/jsx-runtime"),Sg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=S("CommandPalette",te),a=E(Lt),{selected:l,setSelected:c}=dt(),p=r[l],d=p&&typeof p.text=="string"&&hs(p.text),u=(0,ut.useRef)(null);function m(y){if(!u.current)return;let v=u.current.querySelectorAll(".command-palette-list-item"),C=0,K=0;y==="down"?(v.forEach((Le,B)=>{B===l&&(C=B)}),K=C===v.length-1?0:C+1):y==="up"?(v.forEach((Le,B)=>{B===l&&(C=B)}),K=C?C-1:v.length-1):c(0);let H=v[K];H&&typeof K=="number"&&(c(K),H.scrollIntoView&&H.scrollIntoView({behavior:"smooth",block:K?"center":"end"}))}function f(){if(!u.current)return;let y=u.current.querySelectorAll(".command-palette-list-item"),v=0;y.forEach((K,H)=>{H===l&&(v=H)});let C=y[v];C&&C.click()}let g=()=>{d&&window.open(d,"_blank")},x=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=(0,ut.useCallback)(y=>{if(y.key==="Enter"&&y.altKey&&d){g();return}if(y.key==="Enter"&&y.shiftKey){w();return}if(y.key==="ArrowDown"){y.preventDefault(),y.stopPropagation(),m("down");return}if(y.key==="ArrowUp"){y.preventDefault(),y.stopPropagation(),m("up");return}y.key==="Enter"&&l!==-1&&(y.preventDefault(),y.stopPropagation(),f())},[l]);return(0,ut.useEffect)(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),(0,ze.jsxs)("div",{className:i.actions,children:[(0,ze.jsx)("div",{className:i.actionsWrapper,ref:u,children:t}),(0,ze.jsxs)("div",{className:i.actionsBar,children:[d&&(0,ze.jsx)(no,{onClick:g,shortKeys:[us()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,ze.jsxs)(ut.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,ze.jsx)(no,{onClick:w,shortKeys:[8679,8629],children:o}),(0,ze.jsx)(no,{onClick:x,shortKeys:[8629],children:e})]})]})]})},Rl=Sg;var Il=require("react");var qo=require("react/jsx-runtime"),so=()=>(0,qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,qo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,qo.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});var Te=require("react/jsx-runtime");function vg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=S("CommandPalette",te);return(0,Te.jsxs)("div",{className:l.search,children:[(0,Te.jsx)("div",{className:l.searchIcon,children:(0,Te.jsx)(so,{})}),(0,Te.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Te.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,Te.jsx)("div",{className:l.selectWrapper,children:(0,Te.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,Te.jsx)("option",{children:n}),s.map(c=>(0,Te.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Pl=(0,Il.forwardRef)(vg);var Vo=require("react/jsx-runtime");function Nt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:d,search:u}){let[m,f]=(0,ro.useState)(0),g=(0,ro.useRef)(null),x=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var h;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(h=g.current)==null||h.focus();return}if(u.length>0){r("");return}a(!1)};return(0,ro.useEffect)(()=>{f(0)},[u,n]),(0,Vo.jsx)(Qt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:x,children:(0,Vo.jsxs)(fl,{selected:m,setSelected:f,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,Vo.jsx)(Pl,{ref:g,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}Nt.Page=zr;Nt.List=Kr;Nt.Image=dl;Nt.ListItem=Ur;Nt.ActionsBar=Rl;Nt.Button=no;var A=Nt;var G=require("react/jsx-runtime"),_g=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=S("EditSuggestionForm",Oa),l=(0,Ss.useDispatch)(),c=E(xr),p=(0,Ss.useSelector)(f=>f.overlayInput.text);(0,Gr.useEffect)(()=>{t&&(l(Y.actions.reset()),l(Y.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Y.actions.commitSuggestion()))},[t]);let d=f=>{f.preventDefault(),u(p)},u=f=>{l(Kn(f)),e(f)},m=f=>g=>{p!==i?window.confirm(c("warning"))&&f(g):f(g)};return(0,Gr.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,G.jsxs)("div",{className:a.root,children:[(0,G.jsxs)("div",{className:a.content,children:[t.title&&(0,G.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,G.jsx)(gr,{labels:t.searchKeywords}),(0,G.jsx)(cl,{onUse:u,value:p})]}),(0,G.jsxs)("form",{className:a.actions,onSubmit:d,children:[(0,G.jsxs)("div",{children:[(0,G.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&m(r),children:(0,G.jsx)(ns,{})}),(0,G.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&m(s),children:(0,G.jsx)(qa,{})})]}),(0,G.jsxs)("div",{className:a.primaryButtons,children:[(0,G.jsx)(A.Button,{onClick:m(o),shortKeys:["esc"],children:c("dismiss")}),(0,G.jsx)(A.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},vs=_g;var Dt=require("@reduxjs/toolkit");var xg=["{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}"],bg=new RegExp(xg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Al(t,e){let o=t.split(bg),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let d=a.charAt(0),u=0;do c=d?e.indexOf(d,c+1):-1,u+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&u>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function Ll(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Ol={suggestions:[],fetchState:"idle",isInitialRequest:null},Ml={default:Ol},Nl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},Dl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},Hl=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")},io=t=>t.textSuggestions,Bl=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},_s=(0,Dt.createAction)("textSuggestions/refresh"),je=(0,Dt.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=$t(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,jo(n),t);if(t==="default"){let p=i?l.filter(Bl(a)):l;e.dispatch(Oe(p.slice(0,r)))}return l}),Wo=(0,Dt.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,{...jo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Bl(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Al(p.text,t):p.text}))),l=Ll(l,r),e.dispatch(Oe(l)),l}),Fl=(0,Dt.createSlice)({name:"textSuggestions",initialState:Ml,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(je.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Ol;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(je.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(je.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Wo.pending,e=>{e.default.fetchState="loading"}).addCase(Wo.rejected,e=>{e.default.fetchState="error"}).addCase(Wo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(P,()=>Ml)}}),{setTextSuggestions:Kl,setSuggestionState:Ul}=Fl.actions,zl=Fl.reducer;var ql=require("@reduxjs/toolkit");var jl={contentType:null,suggestion:null},Vl=t=>t.activeSuggestion.suggestion,Wl=t=>t.activeSuggestion.contentType,Gl=(0,ql.createSlice)({name:"activeSuggestion",initialState:jl,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(P,()=>jl)}}),{setActiveSuggestion:qe,resetActiveSuggestion:$r}=Gl.actions,$l=Gl.reducer;var Xr={};V(Xr,{enUS:()=>Cg,nlNL:()=>wg});var Cg={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"}]},wg={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 Xl=require("@reduxjs/toolkit"),Tg={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var xs=({ui:t})=>t.overlayCollapsed;var Ql=(0,Xl.createSlice)({name:"ui",initialState:Tg,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:Go,setInputHasFocus:ao,setOverlayCollapsed:gt,setOpenOverlayWhenTyping:Zl,setOverlayCollapsedUserOverwrite:Jl}=Ql.actions,Yl=Ql.reducer;var $o=T(require("react")),tc=require("react/jsx-runtime"),ec=$o.default.createContext(null),lo=({broadcastEvents:t,children:e})=>{let o=$o.default.useMemo(()=>t,[]);return(0,tc.jsx)(ec.Provider,{value:o,children:e})},fe=()=>{let t=(0,$o.useContext)(ec);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var co=require("@reduxjs/toolkit");var Eg={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Ee=t=>t.auth.isLoggedIn,oc=t=>t.auth.loginFetchState,nc=t=>t.auth.verifyFetchState,sc=t=>t.auth.showLoginOverlay,mt=(0,co.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),rc=(0,co.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Xo=(0,co.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),ic=(0,co.createSlice)({name:"auth",initialState:Eg,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(mt.pending,e=>{e.loginFetchState="loading"}),t.addCase(mt.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(mt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Xo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Xo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Xo.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:po,setShowLoginOverlay:ac}=ic.actions,lc=ic.reducer;var Qr="SetActiveSuggestion",uo="ShowLoginOverlay",Zr="UserLoggedIn",kg="UserLoggedOut",Ve="ApplySuggestion",Jr="ApplyImageSuggestion",Rg="ShowCommandPalette",Ig=t=>({[Qr]:e=>{t.dispatch(Ul(e.state)),t.dispatch(qe({contentType:e.contentType,suggestion:e.suggestion}))},[Rg]:e=>{t.dispatch(ae(e.isOpen)),e.page&&t.dispatch(X(e.page))},[uo]:e=>{t.dispatch(ac(e))},[Zr]:()=>{t.dispatch(mt())},[kg]:()=>{t.dispatch(mt())},[Jr]:e=>{t.dispatch(zn({suggestion:e.suggestion}))},[Ve]:e=>{t.dispatch(be({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(ct())}}),cc=Ig;var Yr=require("react/jsx-runtime"),Pg=()=>{var f;let[t,e]=(0,pc.useState)(!1),o=(0,go.useSelector)(Vl),n=(0,go.useSelector)(Wl),s=(0,go.useSelector)(io),r=(0,go.useDispatch)(),i=fe(),a=E(Xr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r($r()),r(ao(!0)),r(Y.actions.reset())},p=(g,x)=>{r($r()),r(ao(!0)),i.send(Ve,{text:g,suggestion:{...x,source:`${x.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(f=s[n])==null?void 0:f.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r(qe({contentType:n,suggestion:s[n].suggestions[d-1]})),m=d===s[n].suggestions.length-1||d===null?void 0:()=>r(qe({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,Yr.jsx)(Qt,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Yr.jsx)(vs,{onTouched:e,onDismiss:c,onUse:g=>p(g,o),suggestion:o,onNext:m,onPrevious:u})})},dc=Pg;var ti=require("react-redux");var bs=T(require("classnames")),ke=require("react"),Cs=require("react-redux");var gc=T(require("classnames"));var uc={root:"_root_1ukx5_1"};var mc=require("react/jsx-runtime"),Ag=({className:t,value:e,...o})=>{let n=S("TextInput",uc);return(0,mc.jsx)("input",{className:(0,gc.default)(t,n.root),type:"text",value:e,...o})},Qo=Ag;var ei={};V(ei,{enUS:()=>Lg,nlNL:()=>Mg});var Lg={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"}]},Mg={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 fc={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 F=require("react/jsx-runtime");var Og=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Ng=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(ei),i=S("LoginTokenDialog",fc),a=(0,Cs.useSelector)(nc),l=(0,Cs.useDispatch)(),c=b("productName"),[p,d]=(0,ke.useState)(t||""),[u,m]=(0,ke.useState)(0),[f,g]=(0,ke.useState)(""),x=(0,ke.useCallback)(async v=>{v.preventDefault(),l(rc({email:p})),m(1)},[o,p]),w=()=>{g(""),m(0)},h=(0,ke.useCallback)(async v=>{v.preventDefault();let C=Og(v.target.elements.token.value);if(!C){g(r("verifyCodeError",{login:y}));return}l(Xo({token:C}))},[o]),y=(0,ke.useMemo)(()=>v=>(0,F.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:v},"back-button"),[]);return(0,ke.useEffect)(()=>{a==="error"&&g(r("verifyCodeError",{login:y})),a==="done"&&n()},[a]),(0,F.jsx)(Qt,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,F.jsxs)("div",{className:i.root,children:[(0,F.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),u===0&&(0,F.jsxs)("form",{onSubmit:x,children:[(0,F.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,F.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,F.jsx)(Qo,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:v=>d(v.target.value)}),(0,F.jsx)("div",{className:i.actions,children:(0,F.jsx)("button",{type:"submit",className:(0,bs.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&(0,F.jsxs)("form",{onSubmit:h,children:[(0,F.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,F.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,F.jsx)(Qo,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&(0,F.jsx)("div",{className:i.errorMessage,children:f}),(0,F.jsxs)("div",{className:i.actions,children:[(0,F.jsx)("button",{type:"button",className:(0,bs.default)(i.button),onClick:w,children:r("back")}),(0,F.jsx)("button",{type:"submit",className:(0,bs.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},hc=Ng;var Sc=require("react/jsx-runtime"),Dg=()=>{let t=(0,ti.useSelector)(sc),e=(0,ti.useSelector)(yl),o=b("adminUrl"),n=fe(),s=()=>n.send(uo,!1),r=()=>{n.send(uo,!1),n.send(Zr)};return(0,Sc.jsx)(hc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},yc=Dg;var Uc=T(require("lodash.debounce")),ne=require("react"),$e=require("react-redux");var ws=require("@reduxjs/toolkit");var Hg={data:null,fetchState:"idle"},vc=t=>t.contentTypes.data,Zo=(0,ws.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Bg=(0,ws.createSlice)({name:"contentTypes",initialState:Hg,reducers:{},extraReducers:t=>{t.addCase(Zo.pending,e=>{e.fetchState="loading"}).addCase(Zo.rejected,e=>{e.fetchState="error"}).addCase(Zo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),_c=Bg.reducer;function Jo(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 xc=require("react");function bc(t,e){(0,xc.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 Yo=require("react"),ks=require("react-redux");var Ts=require("@reduxjs/toolkit");var Cc={data:null,fetchState:"idle"},Es=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},Re=(0,Ts.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)}),Fg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Kg=(0,Ts.createSlice)({name:"entities",initialState:Cc,reducers:{},extraReducers:t=>{t.addCase(Re.pending,e=>{e.fetchState="loading"}).addCase(Re.rejected,e=>{e.fetchState="error"}).addCase(Re.fulfilled,(e,o)=>{e.fetchState="done",e.data=Fg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(P,()=>Cc)}}),wc=Kg.reducer;var oi={};V(oi,{enUS:()=>Ug,nlNL:()=>zg});var Ug={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},zg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Tc={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Ht=require("react/jsx-runtime"),jg=({onCopy:t,onUse:e})=>{let o=(0,Yo.useRef)(null),n=S("EntitiesList",Tc),s=E(oi),r=(0,ks.useSelector)(Es),i=(0,ks.useDispatch)();return(0,Yo.useEffect)(()=>{i(Re())},[]),(0,Yo.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,Ht.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,Ht.jsx)(A.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,Ht.jsx)(A.List,{children:r.map((a,l)=>(0,Ht.jsx)(A.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,Ht.jsx)("p",{className:n.empty,children:s("noResults")})]})},Ec=jg;var Ie=require("react"),en=require("react-redux");var Rs=require("@reduxjs/toolkit");var kc={data:null,fetchState:"idle"},Rc=t=>t.summary.data,Ic=t=>t.summary.fetchState==="error",We=(0,Rs.createAsyncThunk)("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();return i.length===0?Promise.reject(new Error("No messages are included")):{summary:await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel})}}),qg=(0,Rs.createSlice)({name:"summary",initialState:kc,reducers:{},extraReducers:t=>{t.addCase(We.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(We.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(We.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(P,()=>kc)}}),Pc=qg.reducer;var ni={};V(ni,{enUS:()=>Vg,nlNL:()=>Wg});var Vg={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."}]},Wg={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 Ac={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 Ge=require("react/jsx-runtime"),Gg=({onCopy:t})=>{let e=(0,Ie.useRef)(null),o=S("SummaryForm",Ac),[n,s]=(0,Ie.useState)(""),r=E(ni),i=(0,en.useSelector)(Rc),a=(0,en.useSelector)(Ic),l=(0,en.useDispatch)(),c=()=>{l(re({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(re({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return(0,Ie.useEffect)(()=>{l(We())},[]),(0,Ie.useEffect)(()=>{s(i||"")},[i]),(0,Ie.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Ie.useEffect)(()=>{let d=u=>{u.key==="Enter"&&u.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),(0,Ge.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,Ge.jsx)("p",{className:o.error,children:r("error")}):(0,Ge.jsxs)(Ie.Fragment,{children:[(0,Ge.jsx)("div",{className:o.main,children:(0,Ge.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,Ge.jsx)("div",{className:o.actions,children:(0,Ge.jsx)(A.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Lc=Gg;var si={};V(si,{enUS:()=>$g,nlNL:()=>Xg});var $g={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?"}]},Xg={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 ft=T(require("react")),on=require("react-redux");var ri={};V(ri,{enUS:()=>Qg,nlNL:()=>Zg});var Qg={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},Zg={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 Mc={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 fo=require("@reduxjs/toolkit");var ii={data:[],fetchState:"idle"},Oc=t=>{var e;return(e=t.answer)==null?void 0:e.data},Nc=t=>t.answer.fetchState,ho=(0,fo.createAction)("answer/resetKnowledgeSearch"),mo=(0,fo.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(i=e.getState().conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile is not defined");let r=await o.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),Jg=(0,fo.createSlice)({name:"answer",initialState:ii,reducers:{},extraReducers:t=>{t.addCase(mo.pending,e=>{e.fetchState="loading"}).addCase(mo.rejected,e=>{e.fetchState="error"}).addCase(mo.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(P,()=>ii).addCase(ho,()=>ii)}}),Dc=Jg.reducer;var tn=require("react/jsx-runtime"),Hc=()=>(0,tn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,tn.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,tn.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 oe=require("react/jsx-runtime"),Yg=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=ft.default.useState(""),{setSelected:i}=dt(),a=(0,ft.useRef)(null),l=S("EntitiesList",Mc),c=E(ri),p=(0,on.useDispatch)(),d=(0,on.useSelector)(Oc),u=(0,on.useSelector)(Nc),m=async g=>{g.preventDefault(),g.stopPropagation(),s!==""&&p(mo({question:s,promptInstruction:n}))},f=(g,x)=>{p(re({name:"knowledge assist source viewed",data:{question:x,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return(0,ft.useEffect)(()=>{var g;o&&u==="idle"?p(mo({question:o,promptInstruction:n})):(g=a.current)==null||g.focus()},[a,u]),(0,ft.useEffect)(()=>{u==="done"&&(p(re({name:"knowledge assist question answered",data:{question:s||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),i(d.length-1),r(""))},[u,d]),(0,ft.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,d]),(0,oe.jsxs)("div",{className:l.root,children:[d.length>0&&(0,oe.jsx)("div",{className:l.alignRight,children:(0,oe.jsx)(A.Button,{onClick:e,children:c("reset")})}),(0,oe.jsxs)(A.ActionsBar,{list:d.map(({answer:g})=>({text:g.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:g=>t(g.text),children:[d.map(({question:g,answer:x},w)=>(0,oe.jsx)(A.List,{children:(0,oe.jsx)(A.ListItem,{"data-testid":"knowledge-search-answer",index:w,description:x.answer,closeOnSelect:!0,onClick:()=>t(x.answer),onSourceClick:h=>f(h,g),sources:x.sources,styles:{title:l.question,description:l.answer},children:g})},`${x.answer}_${w}`)),u==="loading"&&(0,oe.jsx)("p",{className:l.status,children:c("loading")}),u==="error"&&(0,oe.jsx)("p",{className:l.status,children:c("error")}),(0,oe.jsxs)("form",{className:l.form,onSubmit:m,children:[(0,oe.jsx)("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:g=>{i(-1),r(g.target.value)}}),(0,oe.jsx)("button",{type:"submit",className:l.submit,children:(0,oe.jsx)(Hc,{})})]})]})]})},Bc=Yg;var Is=require("@reduxjs/toolkit");var em={data:null,fetchState:"idle"},yo=t=>t.profile.data,Ps=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],nn=(0,Is.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)}),tm=(0,Is.createSlice)({name:"profile",initialState:em,reducers:{},extraReducers:t=>{t.addCase(nn.pending,e=>{e.fetchState="loading"}).addCase(nn.rejected,e=>{e.fetchState="error"}).addCase(nn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Fc=tm.reducer;var z=require("react/jsx-runtime"),om=200,nm=5,sm=4,rm=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Kc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),im=()=>{let t=(0,$e.useDispatch)(),e=fe(),o=E(si),[n,s]=(0,ne.useState)(!1),[r,i]=(0,ne.useState)(""),a=(0,$e.useSelector)(bl),l=(0,$e.useSelector)(yo),[c,p]=(0,ne.useState)(null),[d,u]=(0,ne.useState)([]),[m,f]=(0,ne.useState)(),g=(0,$e.useSelector)(Ee),x=b("showSearch"),w=b("showEntitiesCommand"),h=b("showSummaryCommand"),y=b("showKnowledgeSearch"),v=b("showImageSearch"),C=b("searchTriggerKey"),K=(0,$e.useSelector)(vc),H=(0,$e.useSelector)(Cl),Le=(0,$e.useSelector)(xl),B=_=>pr(H.filter(L=>L.type===_.toUpperCase()),_),I=[{value:"PERSONAL",label:o("personalSuggestions"),list:B("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:B("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:B("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:B("IMAGE"),listOrientation:"horizontal",shouldShow:v}].filter(_=>_.shouldShow),J=[{label:o("entitiesClipboard"),onClick:()=>t(X("entities")),shouldShow:w&&Kc(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(X("summary")),shouldShow:h&&Kc(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(X("knowledgeAssist")),shouldShow:y}].filter(_=>_.shouldShow),Se=(K==null?void 0:K.map(_=>({value:_.code.toUpperCase(),label:`${_.name}s`,list:B(_.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],lr=(0,ne.useCallback)((0,Uc.default)((_,L)=>{t(Ot({query:_,type:L,tags:["search-overlay"]}))},om),[]),Ct=rm([...Se,...I]),tu=(0,ne.useCallback)((_,L)=>{if(!L)return;let st=[...I,...Se].find(({value:zt})=>zt===L);st&&(t(X("edit")),p({..._,searchTerm:void 0}),u(st.list))},[t,c,Se]),cr=(0,ne.useCallback)((_,L)=>{switch(L.type){case"IMAGE":e.send(Jr,{suggestion:L});break;default:e.send(Ve,{text:_,suggestion:L})}t(ae(!1))},[t]),ou=_=>{Jo(_.text),t(re({name:"entity copied",data:{entity:_,type:"copy"}})),t(ae(!1))},nu=_=>{e.send(Ve,{text:_,suggestion:{source:"knowledge-assist",text:_}}),t(re({name:"answer used",data:{originalText:_},options:{includeConversationData:!0}})),i(""),t(X("search")),t(ho()),t(ae(!1))},su=_=>{Jo(_),t(ae(!1))},ru=_=>{e.send(Ve,{text:_.text,suggestion:{source:"entity",text:_.text}}),t(ae(!1))},iu=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),au=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function pr(_,L){return _.slice(0,m?10:L.toLowerCase()==="image"?sm:nm)}function zi(_,L,st){return L.reduce((zt,vn)=>st&&m===st?vn.length+zt:pr(vn,st).length+zt,_)}function Ut(_){return L=>{n?window.confirm(o("warning"))&&(_(L),s(!1)):_(L)}}return(0,ne.useEffect)(()=>{r?lr(r,m):t(fs())},[r,m]),(0,ne.useEffect)(()=>{a==="search"&&t(ho())},[a]),(0,ne.useEffect)(()=>{g&&t(Zo())},[g]),bc(C,()=>t(ae(!0))),!x||!l?null:(0,z.jsxs)(A,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Ut(_=>t(ae(_))),onChangeType:_=>f(_),onChangePage:Ut(_=>t(X(_))),selectedType:m,search:r,page:a,isOpen:Le,types:[...Se,...I],children:[(0,z.jsx)(A.Page,{id:"search",children:(0,z.jsxs)(A.ActionsBar,{list:[...J.map(_=>({text:_.label,type:"command"})),...Ct.map(_=>({text:_.text||_.url||_.message,type:_.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:_},L)=>cr(_,Ct[L]),onSecondary:(_,L)=>{tu(Ct[L-J.length],Ct[L-J.length].type)},children:[J.length>0&&(0,z.jsx)(A.List,{heading:o("commands"),children:J.map((_,L)=>(0,z.jsx)(A.ListItem,{index:zi(L,[],"commands"),closeOnSelect:!1,onClick:_.onClick,children:_.label},_.label))}),[...Se,...I].map(({value:_,label:L,list:st,lineClamp:zt,listOrientation:vn},lu)=>(0,z.jsx)(A.List,{heading:L,orientation:vn==="horizontal"?"horizontal":"vertical",children:pr(st,_).map((ve,cu)=>(0,z.jsx)(A.ListItem,{index:zi(J.length+cu,[...Se,...I].slice(0,lu).map(({list:pu})=>pu),_),closeOnSelect:!1,lineClamp:zt,onClick:()=>cr(ve.text,ve),description:_!=="IMAGE"?ve.title&&ve.text:void 0,children:_==="IMAGE"?(0,z.jsx)(A.Image,{title:ve.title||ve.text,src:ve.image}):ve.title||ve.text},`${ve.id}-${ve.text}`))},_))]})}),(0,z.jsx)(A.Page,{id:"edit",onDismiss:Ut(()=>{t(X("search")),p(null)}),children:c&&(0,z.jsx)(vs,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(X("search")),p(null),u([])},onNext:au,onPrevious:iu,onUse:_=>{t(X("search")),cr(_,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(ae(!1)),u([]),p(null)}})}),(0,z.jsx)(A.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:Ut(()=>{t(X("search"))}),children:(0,z.jsx)(Ec,{onUse:ru,onCopy:ou})}),(0,z.jsx)(A.Page,{id:"summary",title:o("summaryTitle"),onDismiss:Ut(()=>{t(X("search"))}),children:(0,z.jsx)(Lc,{onCopy:su})}),(0,z.jsx)(A.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:Ut(()=>{t(ho()),t(X("search"))}),children:(0,z.jsx)(Bc,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:nu,onResetQuestion:()=>{t(ho()),i("")}})})]})},zc=im;var So=require("react/jsx-runtime"),am=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,So.jsxs)(jc.Fragment,{children:[t&&(0,So.jsx)(zc,{}),(0,So.jsx)(dc,{}),e&&(0,So.jsx)(yc,{})]})},qc=am;var Xe=require("react-redux");function vo(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 Ls=require("react");var Qc=require("interweave"),xo=require("react"),As=require("react-redux");var Vc=require("react");function Wc(t,e,o){(0,Vc.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var lm=/[.*+?^${}()|[\]\\]/g,cm=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function pm(t){return t.replace(lm,"\\$&")}function dm(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function um(t){return t.search(cm)}function Gc(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${pm(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function $c(t){return t.replace(Wt,'<mark data-type="placeholder">$1</mark>')}function _o(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function gm(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=dm(e.toLowerCase(),t.toLowerCase()),s=_o(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=um(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(la).length>3||e.length>30?gm(e.trim(),n):0;return`${`${i>0?"\u2026":""}${_o(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var Xc={badge:"_badge_1syy2_1",formattedText:"_formattedText_1syy2_5"};var li=require("react/jsx-runtime"),fm=["search","personal-collection-search","search-autocomplete"];function hm(t,e,o,n={}){let s="";return fm.includes(e)?s=Gc(ai(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ai(t,o,n),n.placeholders===!0&&(s=$c(s)),s}var ym=()=>{},Sm=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=(0,As.useSelector)($t),r=(0,As.useDispatch)(),i=S("TextSuggestion",Xc),a=(0,xo.useRef)(null);(0,xo.useEffect)(()=>{let c=setTimeout(()=>{r(Ea({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),Wc(a,"click",()=>{r(Rt(t)),r(be({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,xo.useMemo)(()=>hm(o.text,o.source,s,{stripAgentPart:n,placeholders:!0,searchKeywords:o.searchKeywords}),[n,o.text,o.source,s,o.searchKeywords]);return o.source==="gpt"&&!n?null:(0,li.jsx)(O,{ref:a,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:ym,children:(0,li.jsx)(Qc.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},Zc=Sm;var ci=require("react/jsx-runtime"),vm=({suggestions:t,selectedIndex:e,reverse:o})=>{let n=(0,Ls.useMemo)(()=>{let s=t.map((r,i)=>(0,ci.jsx)(Zc,{index:i,selected:i===e,suggestion:r},`${r.text}-${r.source}`));return o?s.reverse():s},[t,e,o]);return(0,ci.jsx)(Ls.Fragment,{children:n})},Ms=vm;var Jc={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var sn=require("react/jsx-runtime"),_m=({textSuggestions:t,selectedIndex:e})=>{let o=S("InlineSuggestionsOverlay",Jc),n=(0,Xe.useSelector)(vo),s=(0,Xe.useDispatch)(),r=(0,Xe.useSelector)(Ee),i=(0,Xe.useSelector)(Gt),a=(0,Xe.useSelector)(xs),l=b("showTextSuggestions");return eo(()=>{s(gt({collapse:!0,skipWhenInputFocus:!0}))}),a||!n||!l||t.length===0||r!==!0||i===!1?null:(0,sn.jsx)("div",{className:o.root,"data-variant":"inline",children:(0,sn.jsx)("div",{className:o.paper,children:(0,sn.jsx)(ge,{children:(0,sn.jsx)(Ms,{suggestions:t,selectedIndex:e})})})})},xm=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Yc=(0,Xe.connect)(xm)(_m);var Ns=T(require("classnames")),bo=require("react"),Ze=require("react-redux");var ep=require("react");function tp(t,e){let[o,n]=(0,ep.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return k.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){k.error(i)}}]}var np=T(require("classnames")),Qe=require("react");var pi={};V(pi,{enUS:()=>bm,nlNL:()=>Cm});var bm={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"}]}]},Cm={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 op={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var ht=require("react/jsx-runtime"),di=(t,e,o)=>n=>(0,ht.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),wm=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=E(pi),r=fe(),i=S("Login",op),a=b("productName"),l=(0,Qe.useCallback)(g=>{g.preventDefault(),n&&n(parseInt(g.target.value,10))},[]),c=(0,Qe.useCallback)(g=>{g.preventDefault(),r.send(uo,!0)},[e]),p=(0,Qe.useMemo)(()=>g=>(0,ht.jsx)("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),d=(0,Qe.useCallback)(g=>(0,ht.jsx)("button",{type:"button",className:i.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:u,hour:m,day:f}=(0,Qe.useMemo)(()=>({min:di(i,60*10,l),hour:di(i,60*60,l),day:di(i,60*60*12,l)}),[]);return(0,ht.jsxs)("div",{className:(0,np.default)(t,i.root),children:[s("loginPlease",{login:o?d:p,productName:a}),n&&(0,ht.jsxs)(Qe.Fragment,{children:[(0,ht.jsx)("br",{}),s("snooze",{min:u,hour:m,day:f})]})]})},Os=wm;var rp=require("react-redux");var sp={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var rn=require("react/jsx-runtime"),Tm=({title:t})=>{let e=S("SearchTrigger",sp),o=(0,rp.useDispatch)();return(0,rn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ae(!0)),children:[(0,rn.jsx)(so,{}),(0,rn.jsx)("span",{className:e.text,children:t})]})},ip=Tm;var ui={};V(ui,{enUS:()=>Em,nlNL:()=>km});var Em={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"}]},km={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 ap={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 N=require("react/jsx-runtime"),Rm=({textSuggestions:t,selectedIndex:e})=>{let o=S("SuggestionsOverlay",ap),n=E(ui),s=(0,Ze.useSelector)(vo),r=xa(),i=(0,Ze.useDispatch)(),a=(0,bo.useRef)(null),l=b("searchTriggerKey"),c=b("productName"),p=(0,Ze.useSelector)(xs),d=(0,Ze.useSelector)(Ee),u=(0,Ze.useSelector)(Gt),[m,f]=(0,bo.useState)(null),g=b("showSearch"),x=b("showTextSuggestions"),w=b("adminUrl"),h=b("isEmbedded"),[y,v]=tp("dd-snooze-until-ms",0),C=p||y>Date.now(),K=t.filter(B=>B.source!=="gpt").length,H=()=>{C&&v(0),i(Jl(!C))},Le=B=>{let I=Date.now()+B*1e3;v(I),k.info(`Snooze until: ${new Date(I)}`),i(gt({collapse:!0}))};return(0,bo.useEffect)(()=>{K===0&&f(null)},[t,K]),eo(()=>{i(gt({collapse:!0,skipWhenInputFocus:!0}))}),d===null||u===!1?null:d===!1?(0,N.jsxs)("div",{ref:a,className:(0,Ns.default)(o.root,{[o.isCollapsed]:C}),children:[!C&&(0,N.jsxs)("div",{className:o.triggers,children:[(0,N.jsx)("div",{style:{flex:1}}),(0,N.jsx)("div",{className:o.triggersRight,children:(0,N.jsx)(Et,{className:o.toggleButton,title:n("collapse"),onClick:H,isCollapsed:!1})})]}),(0,N.jsx)("div",{className:o.toggleButtonWrapper,children:(0,N.jsx)(Et,{className:o.toggleButton,title:n("open",{productName:c}),onClick:H,isCollapsed:!0})}),(0,N.jsx)("div",{className:o.collapsible,children:(0,N.jsx)(Os,{loginUrl:w,isEmbedded:h,onSnooze:Le})})]}):!r||!s?null:(0,N.jsxs)("div",{ref:a,className:(0,Ns.default)(o.root,{[o.isCollapsed]:C}),children:[!C&&(0,N.jsxs)("div",{className:o.triggers,children:[(0,N.jsx)("div",{style:{flex:1},children:g&&(0,N.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(n(us()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,N.jsx)(ip,{title:n("search")})})}),(0,N.jsxs)("div",{className:o.triggersRight,onFocus:()=>{},children:[(0,N.jsx)("div",{className:(0,Ns.default)(!m&&o.hintsHidden,o.hints),children:m}),(0,N.jsx)(Et,{className:o.toggleButton,title:n("collapse"),onClick:H,isCollapsed:!1})]})]}),(0,N.jsx)("div",{className:o.toggleButtonWrapper,children:(0,N.jsx)(Et,{className:o.toggleButton,title:n("open",{productName:c}),onClick:H,isCollapsed:!0})}),K>0&&x&&(0,N.jsx)("div",{className:o.collapsible,onFocus:()=>{},children:(0,N.jsx)(ge,{children:(0,N.jsx)(Ms,{suggestions:t,selectedIndex:e,reverse:!0})})})]})},Im=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),lp=(0,Ze.connect)(Im)(Rm);var cp=require("react-redux");var an=require("react/jsx-runtime"),Pm=({children:t})=>{let o=b("locale").replace("-","");return(0,an.jsx)(Ir.Provider,{value:o,children:t})},Am=({store:t,customStyles:e={},children:o})=>(0,an.jsx)(cp.Provider,{store:t,children:(0,an.jsx)(Pm,{children:(0,an.jsx)(Ro.Provider,{value:e,children:o})})}),Co=Am;var $s=T(require("classnames")),Rp=require("interweave"),et=require("react"),Ip=require("react-redux");var pp=require("react"),Lm=["div","span","mark","strong","b","i","u","em"];function gi(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(Lm.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,pp.cloneElement)(n,{children:gi(i,e,o+1)})]}return[...t,...e]}function yt(t){return t.tagName.toLowerCase()==="textarea"}var dp={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 _p=T(require("classnames")),xp=require("interweave"),qs=require("react");function up(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Ds(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function gp(t){return t!=null}var fi=T(require("classnames")),he=require("react");var Hs=require("react"),Mm=["bottom","height","left","right","top","width"],Om=(t={},e={})=>Mm.some(o=>t[o]!==e[o]),Je=new Map,mp,fp=()=>{let t=[],e=[];Je.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Om(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Je.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),mp=window.requestAnimationFrame(fp)};function Nm(t,e){return{observe(){let o=Je.size===0;if(Je.has(t)){let n=Je.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Je.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&fp()},unobserve(){let o=Je.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Je.delete(t),Je.size||cancelAnimationFrame(mp)}}}}function mi(t){let[e,o]=(0,Hs.useState)(null);return(0,Hs.useLayoutEffect)(()=>{if(!t.current)return;let n=Nm(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var wo=require("react"),yp=require("react-dom");var hp={root:"_root_1jq08_1"};var Sp=({children:t})=>{let[e,o]=(0,wo.useState)(null),n=(0,wo.useContext)(Ro);return(0,wo.useLayoutEffect)(()=>{let s=document.createElement("div");return Pt(s),s.classList.add(hp.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,yp.createPortal)(t,e):null};var He={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 Bs=require("react/jsx-runtime"),Fs=(t=!1)=>{let[e,o]=(0,he.useState)(t),n=(0,he.useCallback)(()=>o(!0),[]),s=(0,he.useCallback)(()=>o(!1),[]),r=(0,he.useCallback)(()=>o(a=>!a),[]),i=(0,he.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function hi(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 Ks=({className:t,triggerRef:e,boundaryRef:o=(0,he.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=hi,...a})=>{let l=mi(e),c=mi(o),p=(0,he.useMemo)(()=>i(l,c,0),[l,c]);return(0,Bs.jsx)(Sp,{children:(0,Bs.jsx)("div",{className:(0,fi.default)(He.ref,{[He.positionAbove]:n==="above",[He.positionBelow]:n==="below",[He.positionLeft]:n==="left",[He.positionRight]:n==="right",[He.alignStart]:s==="start",[He.alignCenter]:s==="center",[He.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,Bs.jsx)("div",{className:(0,fi.default)(t,He.root),children:r})})})};var vp=T(require("classnames")),Us=require("react");var yi=require("react/jsx-runtime"),zs=(0,Us.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,Us.useRef)(null),r=S("TabCompletion",Fe);return(0,yi.jsx)("div",{ref:Ds([s,n]),className:(0,vp.default)(t,r.popoverContentContainer),...o,children:(0,yi.jsx)("div",{className:r.popoverContent,children:e})})});var St=require("react/jsx-runtime"),Dm=t=>e=>{let o=hi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Hm=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=S("TabCompletion",Fe),i=Fs(),a=(0,qs.useMemo)(()=>Dm(t.getBoundingClientRect()),[t]),[l,c]=ss(t);return(0,qs.useEffect)(()=>{c?i.open():i.close()},[c]),(0,St.jsxs)("span",{children:[(0,St.jsx)("mark",{ref:Ds([l,i.triggerRef]),className:(0,_p.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,St.jsx)(Ks,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,St.jsx)(zs,{style:o,children:(0,St.jsx)("div",{className:r.hintText,children:s})})})]})},js=class extends xp.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${up(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(gp);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,St.jsx)(Hm,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Ws=T(require("classnames")),Ep=require("interweave"),Z=require("react"),kp=require("react-redux");var Si=require("react/jsx-runtime"),bp=()=>(0,Si.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,Si.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 vt=require("react"),ln=require("react-redux"),wp=T(require("lodash.debounce"));var Cp={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Vs(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 vi(t){return t.replace("https://www.","").replace("https://","")}var ye=require("react/jsx-runtime"),Bm=3,Fm=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Km=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Bm})=>{let r=S("LinkSearch",Cp),[i,a]=(0,vt.useState)(""),l=(0,ln.useDispatch)(),c=(0,ln.useSelector)(Nl("url")),p=(0,ln.useSelector)(wl("URL",Fm)),[d,u]=(0,vt.useState)(p.length-1),m=b("fallbackImage"),f=h=>{let y=h.target;a(y.value)},g=(h,y)=>{h.stopPropagation(),h.preventDefault(),window.open(y,"_blank")},x=h=>{var C;let y=d-1<0?p.length-1:d-1,v=d+1===p.length?0:d+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&u(y),h.code==="ArrowDown"&&u(v),h.code==="Enter"&&t(((C=p[d])==null?void 0:C.text)||i)},w=(0,vt.useCallback)((0,wp.default)(h=>{l(Ot({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,vt.useEffect)(()=>{i&&w(i)},[i]),(0,vt.useEffect)(()=>()=>{l(fs())},[]),(0,ye.jsxs)("div",{className:r.root,children:[(0,ye.jsx)(ge,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,y)=>(0,ye.jsx)(O,{selected:d===y,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:(0,ye.jsxs)(D,{children:[(0,ye.jsx)(D.Image,{src:Vs(h,"small",m||void 0),title:h.title||h.text}),(0,ye.jsxs)(D.Content,{className:r.content,cropText:!0,children:[(0,ye.jsx)(D.Title,{children:h.title||vi(h.text)}),h.title&&vi(h.text)]}),(0,ye.jsx)(O.Actions,{children:(0,ye.jsx)(O.ActionButton,{label:n,onClick:v=>g(v,h.text)})})]})},h.text))}),(0,ye.jsx)(Qo,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:x})]})},Tp=Km;var _i={};V(_i,{enUS:()=>Um,nlNL:()=>zm});var Um={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},zm={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Q=require("react/jsx-runtime"),jm=(0,Z.forwardRef)((t,e)=>{let o=S("TabCompletion",Fe);return(0,Q.jsx)("mark",{ref:e,className:(0,Ws.default)(o.matchSelection)},"selection-start")}),qm=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(_i),i=S("TabCompletion",Fe),a=(0,Z.useRef)(null),l=(0,Z.useRef)(null),[c,p]=(0,Z.useState)(null),d=(0,kp.useDispatch)(),u=Fs(document.activeElement===n),[m]=(0,Z.useState)(()=>document.createRange());u.triggerRef.current=m,(0,Z.useEffect)(()=>()=>m.detach(),[]),(0,Z.useEffect)(()=>{let g=t.current,x=a.current;!g||!x||(m.setStart(g,0),m.setEnd(x,0))},[t.current,a.current]),eo(()=>{u.close()});let f=(0,Z.useCallback)(g=>{let x=m.toString(),w=/^http(s?):\/\//.test(g)?g:`https://${g}`;d(Bn({text:`[${x}](${w})`,replace:"selection"}))},[]);return(0,Q.jsxs)("span",{children:[(0,Q.jsx)("mark",{ref:a,className:(0,Ws.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&(0,Q.jsx)(Ks,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,Q.jsxs)(zs,{style:o,ref:l,children:[(0,Q.jsx)("div",{className:(0,Ws.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,Q.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,Q.jsx)(bp,{}),(0,Q.jsx)("span",{children:"\xA0"}),(0,Q.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,Q.jsx)(Tp,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},Gs=class extends Ep.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,Z.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,Q.jsx)(jm,{ref:this.startRef}):(0,Q.jsx)(qm,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Ye=require("react/jsx-runtime"),Vm=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=S("TabCompletion",dp),p=b("insertLink"),d=b("showMidSentenceSuggestions"),u=b("inlineSuggestions"),m=is(a),f=(0,et.useRef)(null);(0,et.useEffect)(()=>{yt(a)&&m&&as(a,m)},[m]);let g=(0,et.useCallback)(h=>{if(!s||!o)return h;let y=[(0,Ye.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,Ye.jsx)("span",{"data-testid":"tab-completion",className:(0,$s.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&y.push((0,Ye.jsx)("span",{className:(0,$s.default)(c.hint,c.resetIndent),children:(0,Ye.jsx)(En,{keyCode:"tab"},"tabHint")})),gi(h,y)},[s,o,n]),x=(0,et.useMemo)(()=>{let h=[];return p&&h.push(new Gs("selection")),h.push(new Jt("placeholders")),r&&h.push(new js("keywords")),h},[u,p,r]),w=(0,et.useMemo)(()=>{let h=window.getComputedStyle(a);return{"--dd-color":h.color,"--dd-font-size":h.fontSize,"--dd-font-family":h.fontFamily,"--dd-font-variant":h.fontVariant}},[]);return t?(0,Ye.jsxs)("div",{ref:h=>{h!=null&&h.parentElement&&(f.current=h==null?void 0:h.parentElement)},className:c.root,style:w,children:[(0,Ye.jsx)(Rp.Interweave,{tagName:"span",containerTagName:"div",className:(0,$s.default)(c.container,c.agentText),disableLineBreaks:yt(a),content:e||"\u200B",onAfterParse:g,matchers:x,selection:m,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!d}),(0,Ye.jsx)("br",{})]}):null},Wm=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var g;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??_o(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:m,showStyleSuggestions:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((g=n.list)==null?void 0:g.keywordMatches)??[],enabled:m&&d!==!1}},Pp=(0,Ip.connect)(Wm)(Vm);var xd=T(require("classnames")),bd=require("react"),q=require("react-redux");var _t=require("@reduxjs/toolkit");var Ap={list:[],fetchState:"idle",isInitialRequest:null},Mp=t=>t.autoflows.list||[],Lp=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},tt=(0,_t.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,_t.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(tt(t.platformSessionId))}),bi=(0,_t.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(tt(t.platformSessionId))}),Gm=(0,_t.createSlice)({name:"autoflows",initialState:Ap,reducers:{},extraReducers:t=>{t.addCase(xi.pending,(e,o)=>{let n=Lp(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(bi.pending,(e,o)=>{let n=Lp(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(tt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(tt.rejected,e=>{e.fetchState="error"}),t.addCase(tt.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(P,()=>Ap)}}),Op=(0,_t.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(tt(t))}),s.on("sessionCompleted",()=>{o(tt(t))})}),Np=(0,_t.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Dp=Gm.reducer;var xt=require("@reduxjs/toolkit");var Hp={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Bp=t=>t.customMessages.list,Fp=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Kp=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Up=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),cn=(0,xt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Xs=(0,xt.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)}),Qs=(0,xt.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)}),zp=(0,xt.createSlice)({name:"customMessages",initialState:Hp,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(cn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(cn.rejected,e=>{e.fetchState="error"}).addCase(cn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Xs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Xs.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Qs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Qs.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(P,()=>Hp)}}),jp=(0,xt.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(zp.actions.onCustomMessage(r))})}),qp=(0,xt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Vp=zp.reducer;var pn=require("@reduxjs/toolkit"),$m={jwt:null,accountUrl:null,interval:null},Wp=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},Ci=(0,pn.createAsyncThunk)("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),wi=(0,pn.createAsyncThunk)("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(Ci()),setInterval(()=>n(Ci()),o)}),Gp=(0,pn.createSlice)({name:"exchangeToken",initialState:$m,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Ci.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(wi.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:$p}=Gp.actions,Xp=Gp.reducer;function Qp(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var rd=require("react"),id=require("react-redux");var od=T(require("classnames")),nd=require("react");var Jp=T(require("classnames"));var Zp={root:"_root_838fd_1"};var ed=require("react/jsx-runtime"),Xm=({className:t,children:e})=>{let o=S("Unicode",Zp);return(0,ed.jsx)("span",{className:(0,Jp.default)(t,o.root),children:e})},Yp=Xm;var td={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 Ti={};V(Ti,{enUS:()=>Qm,nlNL:()=>Zm});var Qm={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"}]},Zm={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 le=require("react/jsx-runtime"),Ym=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=S("Autoflow",td),a=E(Ti),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,le.jsxs)(O,{className:(0,od.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,le.jsx)(D,{children:(0,le.jsxs)(D.Content,{children:[(0,le.jsxs)(D.Title,{children:[e&&(0,le.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,le.jsx)("span",{children:n})]})}),(0,le.jsx)(O.Actions,{fixed:e==="Started",children:(0,le.jsx)(O.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,le.jsxs)(nd.Fragment,{children:[(0,le.jsx)(Yp,{children:c})," ",(0,le.jsx)("span",{children:a(l)})]})})})]})},sd=Ym;var Ei=require("react/jsx-runtime"),ef=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},tf=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Ei.jsx)(rd.Fragment,{children:t.map(s=>(0,Ei.jsx)(sd,{displayName:s.displayName,description:s.description,disabled:s.isBusy||ef(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),of=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},nf={onStartAutoflow:xi,onStopAutoflow:bi},ad=(0,id.connect)(of,nf)(tf);var Zs=require("react"),cd=require("react-redux"),Ii=T(require("classnames"));var ki=require("react/jsx-runtime"),Ri=()=>(0,ki.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,ki.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 ld={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 Be=require("react/jsx-runtime"),sf=({entities:t})=>{let e=S("EntitiesWidgetList",ld),[o,n]=(0,Zs.useState)(void 0),s=(0,cd.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Jo(a.text),s(re({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Zs.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Be.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Be.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Be.jsx)("span",{className:e.entityText,children:a.text}),(0,Be.jsxs)("span",{className:e.iconWrapper,children:[(0,Be.jsx)("span",{className:(0,Ii.default)(e.icon),children:(0,Be.jsx)(Ri,{})}),(0,Be.jsx)("span",{className:(0,Ii.default)(e.icon,o===l&&e.iconClicked),children:(0,Be.jsx)(Ri,{})})]})]},a.text))})},pd=sf;var dd=T(require("classnames")),Pi=require("react"),Bt=require("react-redux");var dn={};V(dn,{enUS:()=>rf,nlNL:()=>af});var rf={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"}],answer:[{type:0,value:"Answer"}]},af={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"}],answer:[{type:0,value:"Antwoord"}]};var ot={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 se=require("react/jsx-runtime"),lf=({suggestion:t})=>{let e=E(dn),o=(0,Bt.useDispatch)(),n=(0,Bt.useSelector)(Fp(t.text)),s=(0,Bt.useSelector)(Kp(t.text)),r=(0,Bt.useSelector)(Up(t.text)),i=(0,Bt.useSelector)(Pn),{replyOptions:a}=t,l=(0,Pi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Xs({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Pi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o(Qs({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return(0,se.jsxs)(O,{onClick:l,className:(0,dd.default)(ot.root,{[ot.isUsed]:n,[ot.hasError]:r}),children:[(0,se.jsx)(D,{children:(0,se.jsxs)(D.Content,{children:[(0,se.jsxs)(D.Title,{className:ot.title,children:[t.text," ",(0,se.jsx)(kn,{className:ot.label,children:"analyse tool"})," ",r&&(0,se.jsx)("span",{className:ot.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,se.jsx)("ul",{className:ot.quickReplies,children:a.map(p=>(0,se.jsx)("li",{className:ot.quickReply,children:p.title},p.title))})]})}),(0,se.jsxs)(O.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,se.jsx)(O.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,se.jsx)(O.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,se.jsx)(O.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},ud=lf;var Ai=require("react/jsx-runtime"),gd=()=>(0,Ai.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Ai.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 hd=require("react-redux");var md=require("react");var ce=require("react/jsx-runtime"),cf=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=hs(s),i=E(dn),a=b("showImages"),l=b("fallbackImage"),c=m=>{m.preventDefault(),m.stopPropagation(),n(s)},p=m=>{m.preventDefault(),m.stopPropagation(),o(t)},d=(0,md.useCallback)(m=>{window.open(r,"_blank"),m.stopPropagation(),m.preventDefault()},[r]);return(0,ce.jsxs)(O,{onClick:c,"data-testid":"edit-suggestion",children:[(0,ce.jsxs)(D,{children:[a&&t.image&&(0,ce.jsx)(D.Image,{src:Vs(t,"small",l||void 0),title:t.title}),(0,ce.jsxs)(D.Content,{children:[t.title&&(0,ce.jsx)(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,ce.jsx)(O.Labels,{labels:t.searchKeywords}),(0,ce.jsx)(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,ce.jsxs)(O.Actions,{children:[r&&(0,ce.jsx)(O.ActionButton,{onClick:d,label:i("visitUrl")}),(0,ce.jsx)(O.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,ce.jsx)(O.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},fd=cf;var un=require("react/jsx-runtime"),pf=({contentType:t,lines:e,suggestions:o})=>{let n=fe(),s=(0,hd.useSelector)(io),r=a=>{n.send(Qr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Ve,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,un.jsx)(un.Fragment,{children:o.map(a=>(0,un.jsx)(fd,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},yd=pf;var Li={};V(Li,{enUS:()=>df,nlNL:()=>uf});var df={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},uf={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Sd={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 Mi=require("react/jsx-runtime"),vd=()=>(0,Mi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Mi.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 Oi=require("react/jsx-runtime"),_d=()=>(0,Oi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Oi.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var R=require("react/jsx-runtime"),Js=(t,e)=>{let o=(0,q.useSelector)(Ee);(0,bd.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},gf=()=>{let t=E(Li),e=(0,q.useDispatch)(),o=b("isEmbedded"),n=S("Widget",Sd),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=(0,q.useSelector)(yo),d=(0,q.useSelector)(Ps),u=(0,q.useSelector)(Mp),m=(0,q.useSelector)(Es),f=(0,q.useSelector)(Bp),g=(0,q.useSelector)(An),x=(0,q.useSelector)(Gt),w=(0,q.useSelector)(Ee),h=(0,q.useSelector)(Pn),y=(0,q.useSelector)(Qp),v=(0,q.useSelector)(io),C=fe(),K=(0,q.useSelector)(Hl),H=(0,q.useSelector)(Wp("/admin/personal-collection")),Le=b("adminUrl");if(Js(()=>(e(cn(h)),e(jp(h)),()=>{e(qp(h))}),[e,x,r,h]),Js(()=>(e(tt(h)),e(Op(h)),()=>{e(Np(h))}),[e,x,s,h]),Js(()=>{d.forEach(({type:I})=>{e(I==="entities"?Re():je(I))})},[e,x,g,p]),Js(()=>(e(wi()),()=>{e($p())}),[e,x,i,g]),x===!1)return(0,R.jsx)("div",{className:n.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("notSupported")})})},"supported");if(w===!1)return(0,R.jsx)("div",{className:n.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Os,{isEmbedded:o,loginUrl:Le})})},"login");if(!p||!h||w===null||K||y)return(0,R.jsx)("div",{className:n.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("waiting")})})},"waiting");let B=c||a||l||H;return(0,R.jsx)("div",{className:(0,xd.default)(n.root),"data-testid":"widget",children:(0,R.jsxs)(Rn,{className:n.sectionList,children:[B&&(0,R.jsx)(rt,{title:t("actions"),type:"shortcuts",children:(0,R.jsxs)("div",{className:n.shortcutList,children:[c&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-search",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(so,{}),t("linkSearch")]}),a&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-summary",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(_d,{}),t("linkSummary")]}),l&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(vd,{}),t("linkKnowledgeSearch")]}),H&&(0,R.jsxs)("a",{className:n.shortcut,target:"_blank",href:H,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[(0,R.jsx)(gd,{}),t("linkPersonalcollection")]})]})}),r&&f.length>0&&(0,R.jsx)(rt,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(ge,{withDivider:!0,children:f.map(I=>(0,R.jsx)(ud,{suggestion:I},I.text))})}),s&&u.length>0&&(0,R.jsx)(rt,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(ge,{withDivider:!0,children:(0,R.jsx)(ad,{})})}),d.map(({type:I,title:J,amount:Se,lines:lr})=>{var Ct;switch(I){case"entities":return m&&m.length>0&&(0,R.jsx)(rt,{type:I,title:J,"data-testid":`type-${I}`,children:(0,R.jsx)(pd,{entities:m})},I);default:return((Ct=v[I])==null?void 0:Ct.fetchState)==="done"&&v[I].suggestions.length>0&&(0,R.jsx)(rt,{type:I,title:J,"data-testid":`type-${I}`,children:(0,R.jsx)(ge,{withDivider:!0,children:(0,R.jsx)(yd,{lines:lr,contentType:I,suggestions:v[I].suggestions.slice(0,Se)||[]})})},I)}})]})})},Cd=gf;function To(t){let e=new Range;return e.selectNodeContents(t),e}function wd(t,e,o){try{return bt(t,e,o),!0}catch{return!1}}function Ys(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function er(t){return"tagName"in t&&t.tagName==="BR"}var gn=/[\u200B-\u200D\uFEFF]/g;function bt(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let u=0;u<=l.length;u++)if(d.test(l[u])||p++,p===c)return u;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(gn,""),d=s+p.length,u=e>=s&&e<=d,m=o>=s&&o<=d;if(u){let f=i(c,e-s);f===0&&!m?n.setStartBefore(l):n.setStart(l,f)}m&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(er(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;Ys(l)&&c&&!Ys(c)&&!er(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}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,collapsed:i}=e,a,l,c=0;function p(d){let u=d===o,m=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let f=d.textContent;u&&(a=c+f.substring(0,n).replace(gn,"").length),m&&(l=c+f.substring(0,r).replace(gn,"").length),c+=f.replace(gn,"").length;break}case Node.ELEMENT_NODE:{let f=d.nextSibling===null;er(d)&&!f&&c++;for(let g=0;g<d.childNodes.length;g++){let x=u&&g===n,w=m&&g===r;if(x&&(a=c),w&&(l=c),l!==void 0||((!x||!i)&&p(d.childNodes[g]),m&&g===r-1&&(l=c),l!==void 0))break}!m&&Ys(d)&&!f&&c++,m&&(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 fn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let u=p?n:0,m=d?r:void 0,f=c.textContent.replace(gn,"");u===0&&m===void 0?a+=f:a+=f.substring(u,m);break}case Node.ELEMENT_NODE:{let u=c.nextSibling===null;i===0&&er(c)&&!u&&(a+=`
|
|
4
|
-
`);for(let m=p?n:0;m<(
|
|
5
|
-
`);break}default:break}d&&i++}return l(t),a}function Td(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Ft=class extends Ke{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),fn(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!Td(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Td(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return mn(this.element,e);let o=this.lastKnownSelection;if(o&&wd(this.element,o.start,o.end))return o;let n=To(this.element);return n.collapse(!1),mn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return fn(this.element,bt(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var Ni=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Di=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=this.createIframe(),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];createIframe(){let e=`deepdesk-iframe-${this.name}`,o=document.getElementById(e);if(o)return o;let n=document.createElement("iframe"),s=`${this.targetOrigin}/v2/widget/liveengage/channel.html`,r=new URLSearchParams({channel:this.name,host:window.location.origin});return this.options.debug&&r.set("debug","1"),n.style.position="absolute",n.style.left="-999em",n.style.width="0px",n.style.height="0px",n.tabIndex=-1,n.id=e,n.title=`iframe-${this.name}`,n.src=`${s}?${r.toString()}`,n}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Hi=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),k.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Di(e,this.deepdeskUrl,{debug:!0}):new Ni(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(k.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var s,r,i;if(!this.sessionId)return;k.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(r=(s=this.eventMap)[e])==null||r.call(s,o),(i=this.channel)==null||i.postMessage({...n,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Ed=Hi;var Eo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Bi=t=>new Promise(e=>{setTimeout(e,t)});var ko=class extends Eo{name="ClientError"},Fi=class extends Eo{name="ServerError"},Pe=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:d=!0,retryOnError:u=v=>v instanceof TypeError,retryOnResponse:m=v=>v.status>=500,version:f="v1",...g}=o,x={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(x.headers={...x.headers,"X-CSRFToken":this.csrfToken}),typeof f=="string"&&(x.headers={...x.headers,"X-Deepdesk-API-Version":f});let w=c,h=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let y=async()=>(w--,a(i,x).then(async v=>m(v)&&!r.isAborted&&w>0?(await Bi(p),y()):v.status===401&&d===!0&&h===!1?(h=!0,await this.refreshToken(),y()):v).catch(async v=>{if(u(v)&&!r.isAborted&&w>0)return await Bi(p),y();throw v}));y().then(v=>v.json().catch(()=>null).then(C=>{v.status>=500?s(new Fi("Server Error",C)):v.status===401?s(new ko("Unauthorized",C)):v.status===403?s(new ko("Forbidden",C)):v.status===404?s(new ko("Not Found",C)):v.status>=400&&s(new ko("Bad Request",C)),delete this.latestRequestByUrl[i],n(C)})).catch(v=>{s(v)})})}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 mf;(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||={})})(mf||={});function tr(t){return{...M(t),tags:t.tags}}var nt=class t{constructor(e,o={}){this.options=o;this.client=new Pe(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),k.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...U(e),tags:e.tags},{version:"v2"});return tr(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return M(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return M(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return M(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),k.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return tr(r)}async isConversationSupported(e,o={}){k.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=U(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return tr(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...U(s),tags:s.tags})),{version:"v2"})).map(s=>tr(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",U({...r,...s,data:n,name:e}),{version:"v2"})}async sendEventV1(e,o){let n=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[r,i])=>({...s,[r]:i}),{});return this.client.post("/api/events",{event:e,data:U({...o,...n})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(n=>n.text)})).entities}async getSummary(e,o={}){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source)},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw k.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",U(o),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,o={},n){return n==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${n}`,U(o),{abortLatest:!0})).map(r=>({...M(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,o){return(await this.client.post(`/api/conversations/${e}/autocomplete`,U(o),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let o=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return M(o).map(n=>({...n,text:n.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let o=await this.client.post("/api/style-suggestions",U(e),{abortLatest:!0});return M(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,U(e),{version:"v2"});return M(o)}async knowledgeAssist(e,o,n){let s=await this.client.post("/api/knowledge-search/search",U({question:e.question,promptInstruction:e.promptInstruction,profile:n,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return M(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return M(o)}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 M(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(ca);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&k.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var hn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(jr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,M(s))}catch{k.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var ff;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(ff||={});var yn=class{constructor(e,o={}){this.apiUrl=e;this.client=new Pe(e,o)}client;streams={};logger=k;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return M(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,U(o));return M(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,U(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return M(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",U(e));return M(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new hn(`${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 rr=require("@reduxjs/toolkit");var Rd=require("@reduxjs/toolkit");var kd={startTime:null,stopTime:null},Id=(0,Rd.createSlice)({name:"handlingTime",initialState:kd,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(P,()=>kd)}}),{handlingTimeStart:Pd,handlingTimeStop:or,handlingTimeReset:Ad}=Id.actions,Ld=Id.reducer;var Md=(t={})=>{let e={onAuthError:po(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var sr=require("@reduxjs/toolkit");var nr={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Kt=(0,sr.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 nr.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),hf=(0,sr.createSlice)({name:"styleSuggestions",initialState:nr,reducers:{},extraReducers:t=>{t.addCase(Kt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Kt.rejected,e=>{e.fetchState="error"}).addCase(Kt.fulfilled,(e,o)=>{e.fetchState="done",at(e.list,o.payload)||(e.list=o.payload)}).addCase(kt,e=>{e.list=nr.list}).addCase(P,()=>nr)}}),Od=hf.reducer;var Nd=(t={})=>{let e,o=!0,n={getStyleSuggestions:Kt,debounce:500,...t};return s=>r=>i=>{var m;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(!((m=c.conversation.current)==null?void 0:m.id)||!p)return l;let{text:u}=c.input;return u===a&&!o||(clearTimeout(e),u==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:u}))},t.debounce)),l}};function yf(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Dd=(t={})=>{let e={getTextSuggestions:je,getAutocompleteSuggestions:Wo,debounce:200,check:vo,...t},o;return n=>s=>r=>{var g;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=(g=l.conversation.current)==null?void 0:g.id,u=r.type===_s.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:m}}=l;return yf(m,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let x=$t(l);x===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(x))},u?0:e.debounce)),a}};var Hd=Kt.fulfilled.toString();function Sf(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 Bd=t=>e=>o=>n=>{var c;if(n.type!==Hd){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=Sf(s,i);n.type===Hd&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var vf=(0,rr.combineReducers)({activeSuggestion:$l,answer:Dc,auth:lc,autoflows:Dp,conversation:ya,contentTypes:_c,customMessages:Vp,exchangeToken:Xp,entities:wc,handlingTime:Ld,info:_l,input:Sr.reducer,overlayInput:Y.reducer,settings:ga,profile:Fc,search:El,summary:Pc,styleSuggestions:Od,ui:Yl,textSuggestions:zl});function Fd(t){return(0,rr.configureStore)({reducer:vf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Md(),Dd({debounce:200}),Nd({debounce:500}),Bd(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var _f=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},xf=t=>e=>o=>n=>{var a;let s=e.getState(),r=mr("inlineSuggestions")(s);switch(n.type){case qe.toString():{let l=Dl(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 po.toString():{!n.payload&&t.emit("logout",void 0);break}case be.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:_f(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Bn.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 Lo.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case zn.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 Re.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case We.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case re.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 Fn.toString():t.handleKeyDown(n.payload);break;case kt.toString():t.logSendMessage(n.payload);break;case Kn.toString():t.logSendEditSuggestionMessage(n.payload);break;case Un.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case kt.toString():t.handleAfterSendMessage(n.payload);break;case Go.toString():t.onUpdateShowTabHint(n.payload);break;case or.toString():t.logHandlingTime();break;case be.toString():{r&&(e.dispatch(Oe([])),e.dispatch(ct()));break}case Oe.toString():{r&&n.payload.length>0&&e.dispatch(Rt(0));break}default:break}return i},Kd=xf;function Ki(t){return t.toISOString().replace("T"," ").replace("Z","")}function Ud(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:Ki(o),timeStop:Ki(n)}}function Ui(t,e,o){var H,Le,B;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:u,deletions:m,textSuggestions:f,offeredTextSuggestions:g}}=e[t],x=n.length,h=f.reduce((I,{text:J,searchTerm:Se})=>I+J.length-(Se?Se.length:0),0),y=c??Date.now(),v=(Date.now()-y)/1e3+(p||0),C=s/v,K=f.reduce((I,{searchTerm:J})=>I+(J?J.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:u,deletions:m,lenTextTyped:s+K,lenTextTotal:x,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:v,charsPerSecond:C,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:g.filter(I=>I.source==="gpt").length}],agentId:(H=e.info.agentInfo)==null?void 0:H.agentId,agentName:(Le=e.info.agentInfo)==null?void 0:Le.agentName,agentEmail:(B=e.info.agentInfo)==null?void 0:B.agentEmail}}function zd(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?zd(n,e):null}function jd(t,e){return zd(t,e)}function qd(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function bf(t){return typeof t=="object"&&t!==null&&"tagName"in t}function ir(t){return bf(t)&&(yt(t)||rs(t))}var Vd=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{k.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Cf(t){return t.offsetParent!==null}function Wd(t){if(!Cf(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 ar(t,e,o=100){let n=Wd(t);e({isVisible:n});let s=setInterval(()=>{let r=Wd(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var $=require("react/jsx-runtime"),Gd=Vd("showTabHint",!0),Sn=class t{static version="10.4.1-beta.1";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new nt(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Kd({emit:(d,u,m)=>this.emit(d,u,m),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=>Gd.update(d),sendEvent:(d,u)=>this.deepdeskApi.sendEvent(d,u)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new yn(o)}),this.store=Fd(p),this.broadcastEvents=new Ed({debug:!0,deepdeskUrl:c,eventMap:cc(this.store),createCustomChannel:l}),this.store.dispatch(Ao),this.store.dispatch(Go(Gd.value())),this.store.dispatch(Ao({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(k.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(k.warn("Profile has not been loaded (yet)"),!0):(k.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(po(null)),this.store.dispatch(mt()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();Ee(n)&&oc(n)!=="loading"&&e()});this.unmountHandlers.push(()=>{o()})})}isLoggedIn(){return this.deepdeskApi.isLoggedIn()}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){k.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(hr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Ln(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Mn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(yr(e))).payload}async postMessages(e){return(await this.store.dispatch(Nn(e))).payload}async updateConversation(e){return(await this.store.dispatch(On(e))).payload}resetConversation(){this.store.dispatch(P()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(We());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Ao(e))}setVisitorInfo(e){this.store.dispatch(vl(e))}async setAgentInfo(e){await this.store.dispatch(zo(e))}async setAgentSettings(e){await this.store.dispatch(qr(e))}async getAgentSettings(){return(await this.store.dispatch(Vr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(_s()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Un(e))}notifyKeyDown(e){this.store.dispatch(Fn(e))}notifyPaste(e,o){this.store.dispatch(Pa({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ra(e))}notifyExternalSuggestion(e){this.store.dispatch(be(e)),this.store.dispatch(ct())}notifyEditSuggestion(e){this.store.dispatch(Kl(e.contentType,e.suggestions)),this.store.dispatch(qe({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(gt({collapse:!1})),this.inputMediator&&this.store.dispatch(ba({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Oe([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(Ia(Hn(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Ta()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(ka());let{selectedSuggestionIndex:d}=this.state.input;e.preventDefault(),!i&&(d===-1?this.store.dispatch(Lo()):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(Rt(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Rt(-1)),this.store.dispatch(Lo()),e.preventDefault()):o||(this.store.dispatch(gt({collapse:!0})),this.store.dispatch(Zl(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,u=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:m}=this.state.input;this.store.dispatch(Go(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&m&&m.text.startsWith(u)&&(this.store.dispatch(be({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(ct())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Aa()),this.store.dispatch(Oe([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(Pd()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(or()))}logSendMessage(e){let o=Ui("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=Ui("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(wa(this.state.overlayInput.metrics))}logHandlingTime(){let e=Ud(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Ad())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(ct()),this.store.dispatch(kt(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(be({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=At(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,Ae.unmountComponentAtNode)(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=At(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,Ae.unmountComponentAtNode)(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Pt(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,s.setAttribute("translate","no"),o.appendChild(s),this.unmountHandlers.push(()=>{(0,Ae.unmountComponentAtNode)(s),s.remove()}),s}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!ir(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:d,detectSubmit:u,insertLink:m,inputMediator:f,closestScrollSelector:g,appendOverlayTo:x,inlineSuggestions:w}=o;if(this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:m,isEmbedded:d,inlineSuggestions:w}),o.automaticHandlingTime&&this.setupHandlingTime(e),Pt(e),this.inputMediator=f||(yt(e)?new Ue(e):new Ft(e)),this.inputMediator.on("change",({plainText:y})=>{this.notifyInputChanged(y)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(La({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",y=>{this.notifyKeyDown(y)}),this.inputMediator.on("paste",({pastedText:y,selectionText:v})=>{this.notifyPaste(y,v)}),this.inputMediator.on("cut",({selectionText:y})=>{this.notifyCut(y)}),w){if(yt(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let y=this.createInlineContainer(e,"deepdesk-caret");(0,Ae.render)((0,$.jsx)(Co,{store:this.store,customStyles:n,children:(0,$.jsx)(lo,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(Yc,{})})}),y),this.inputMediator.on("caret",v=>{this.store.dispatch(Oe([])),v?(y.style.display="block",y.style.top=`${v.top}px`,y.style.left=`${v.left}px`):y.style.display="none"})}else{let y=g&&jd(e,g)||void 0,v=this.overlayContainerFactory("deepdesk-tab-completion",y||e,{appendTo:x,closestScrollElement:y,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",y||e,{appendTo:x},n==null?void 0:n.suggestionsRootNode);(0,Ae.render)((0,$.jsx)(Co,{store:this.store,customStyles:n,children:(0,$.jsx)(lo,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(Pp,{inputElement:e})})}),v),(0,Ae.render)((0,$.jsx)(Co,{store:this.store,customStyles:n,children:(0,$.jsx)(lo,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(lp,{})})}),C)}(0,Ae.render)((0,$.jsx)(Co,{store:this.store,customStyles:n,children:(0,$.jsx)(lo,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(qc,{})})}),this.createContainer("deepdesk-overlays"));let h;this.inputMediator.on("selection",y=>{clearTimeout(h),y===null?h=setTimeout(()=>{y!==null&&this.store.dispatch(vr(y))},500):this.store.dispatch(vr(y))}),this.inputMediator.on("disabled",()=>{var y;(y=this.inputMediator)==null||y.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{u&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(ao(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(ao(!0))),this.store.dispatch(Ca({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var y;this.refresh(),this.broadcastEvents.setSessionId((y=this.state.conversation.current)==null?void 0:y.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&k.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,showPersonalCollectionLink:r,isEmbedded:i}=o;this.widgetRoot=e,this.configure({showImages:s,showPersonalCollectionLink:r,isEmbedded:i}),(0,Ae.render)((0,$.jsx)(Co,{store:this.store,customStyles:n,children:(0,$.jsx)(lo,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(Cd,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Ae.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=ar(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){qd(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(nn());let e=yo(this.state);e&&this.store.dispatch(Ao({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeAssistForAgents,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(k.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;k.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=Ps(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Re()):this.store.dispatch(je(n))})}catch(n){this.handleError(n)}}};async function $d(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 Xd(t,e,o={}){let n=o.replace?bt(t,o.replace.start,o.replace.end):To(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(`
|
|
6
|
-
`).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?
|
|
7
|
-
`).reverse().forEach((a,l)=>{l>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(a))}),i.collapse(!1))};return Promise.resolve(n()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!o)try{o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}function
|
|
3
|
+
`,Pt.MISSING_INTL_API,i);var x=o.getPluralRules(e,{type:p.pluralType}).select(d-(p.offset||0));y=p.options[x]||p.options.other}if(!y)throw new Lr(p.value,d,Object.keys(p.options),i);a.push.apply(a,Ko(y.value,e,o,n,s,d-(p.offset||0)));continue}}return rg(a)}function ag(t,e){return e?ce(ce(ce({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=ce(ce({},t[n]),e[n]||{}),o},{})):t}function lg(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=ag(t[n],e[n]),o},ce({},t)):t}function Mr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function cg(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:ns(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Wn([void 0],o,!1)))},{cache:Mr(t.number),strategy:ss.variadic}),getDateTimeFormat:ns(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Wn([void 0],o,!1)))},{cache:Mr(t.dateTime),strategy:ss.variadic}),getPluralRules:ns(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Wn([void 0],o,!1)))},{cache:Mr(t.pluralRules),strategy:ss.variadic})}}var Qa=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 u=p.reduce(function(d,m){return!d.length||m.type!==X.literal||typeof d[d.length-1]!="string"?d.push(m.value):d[d.length-1]+=m.value,d},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(c){return Ko(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=za(i,["formatters"]);this.ast=t.__parse(e,ce(ce({},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=lg(t.formats,n),this.formatters=s&&s.formatters||cg(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=Va,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 pg(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var ug="dummy",Or=(0,rs.createContext)(null);function E(t){let e=(0,rs.useContext)(Or);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=pg(o,n);return r?new Qa(r).format(s):(e!==ug&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var Uo=require("react/jsx-runtime"),is=()=>(0,Uo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Uo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Uo.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 zo=require("react/jsx-runtime"),Za=()=>(0,zo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,zo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,zo.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 ve=require("react"),ml=require("react-redux"),fl=require("interweave"),qr=w(require("classnames"));var Nr={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var Ya=require("interweave"),el=w(require("classnames"));var to=require("react");function Ja(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function as(t){let e=(0,to.useRef)(null),[o,n]=(0,to.useState)(!1);return(0,to.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Ja((p,u)=>{let d=e.current;if(!d)return;let m=p/r,f=u/r,g=d.getBoundingClientRect(),v=m>g.x&&m<g.x+g.width&&f>g.y&&f<g.y+g.height;v&&!s?(s=!0,n(!0)):!v&&s&&(s=!1,n(!1))},({clientX:p,clientY:u})=>[p,u]),[l,c]=Ja(()=>{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 Ue={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 Dr=require("react/jsx-runtime"),dg=({inputElement:t,children:e})=>{let o=S("TabCompletion",Ue),[n,s]=as(t);return(0,Dr.jsx)("mark",{ref:n,className:(0,el.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},oo=class extends Ya.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,Dr.jsx)(dg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var no=require("react");function ls(t){return t.contentEditable==="true"}function gg(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 tl(t){let{selectionStart:e,selectionEnd:o}=ls(t)?gg(t):t;return[e,o]}function cs(t){let[,e]=(0,no.useState)(),o=(0,no.useRef)(null);return o.current=tl(t),(0,no.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=tl(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 ps(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(Qt);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 ol=require("react");function so(t){(0,ol.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function At(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var nl,De=new Map,mg=["bottom","height","left","right","top","width"],fg=(t={},e={})=>mg.some(o=>t[o]!==e[o]);function sl(t){var o,n;let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...sl(e)]:[]}function rl(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var Hr=!1,il=()=>{Hr=!0;let t=[];De.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),De.delete(o);return}let n=o.getBoundingClientRect();fg(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(rl,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),De.size!==0&&(nl=window.requestAnimationFrame(il))};function Br(t,e){let o=sl(t),n=[],s=o.map((r,i)=>Br(r,a=>{n[i]=a;let l=De.get(t);if(!l)return;let c=n.reduce(rl,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),De.has(t)){let i=De.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else De.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!Hr&&il()},unobserve(){s.forEach(i=>i.unobserve());let r=De.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||De.delete(t),De.size||(cancelAnimationFrame(nl),Hr=!1)}}}}var al,He=new Map,ll=()=>{He.forEach((t,e)=>{if(!e.isConnected){He.delete(e);return}let{clientHeight:o,scrollHeight:n}=e,s=n>o;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),He.size!==0&&(al=window.requestAnimationFrame(ll))};function cl(t,e){return{observe(){let o=He.size===0;He.has(t)?He.get(t).callbacks.push(e):He.set(t,{visible:void 0,callbacks:[e]}),o&&ll()},unobserve(){let o=He.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||He.delete(t),He.size||cancelAnimationFrame(al)}}}}var Fr=["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","borderStyle","boxSizing","color","overflowWrap","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontWeight","fontKerning","lineHeight","letterSpacing","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","textIndent","whiteSpace","wordBreak","wordSpacing","wordWrap"];function Kr(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function ro(t){return parseFloat(t)}function us(t){return Math.round(t*1e6)}function pl(t){return t/1e6}function Ur(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=ro(t.width),r=ro(t.borderLeftWidth),i=ro(t.borderRightWidth),a=ro(t.paddingRight),l=pl(us(s)-us(r)-us(i)),c=pl(us(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Lt(t,e={}){var l;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",At(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Kr(n,o,Fr),Ur(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=cl(t,()=>{Kr(n,o,Fr),Ur(n,t,o),r(),setTimeout(r,0)}),a=Br(t,c=>{if(c===null){e.onRemove&&e.onRemove(),o.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Kr(n,o,Fr),Ur(n,t,o),r(),o.style.top=`${c.top}px`,o.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),d=ro(u.borderTopWidth),m=ro(u.borderBottomWidth),f=p.top+d-c.top,g=c.top+c.height+-(p.top+p.height-m);o.style.clipPath=`inset(${f}px 0px ${g}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var zr={};G(zr,{enUS:()=>hg,nlNL:()=>yg});var hg={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"}]},yg={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 jo=require("react/jsx-runtime"),ul=()=>(0,jo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,jo.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,jo.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 jr=require("react/jsx-runtime"),dl=()=>(0,jr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,jr.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});function Sg(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function ds(t){return t?t instanceof ShadowRoot?ds(t.host):t===t.ownerDocument.body?t.ownerDocument:Sg(t)?t:ds(t.parentNode):document.body}var gl=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(gl||{}),ze=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();lt(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(gl).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()});let o=ds(this.element);if(o){let n=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};o.addEventListener("scroll",n),this.disposeHandlers.push(()=>{o.removeEventListener("scroll",n)})}this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var je=class extends ze{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 se=require("react/jsx-runtime"),vg=({value:t,onUse:e,...o})=>{var p;let n=E(zr),s=(0,ml.useDispatch)(),r=S("EditSuggestionTextInput",Nr),[i,a]=(0,ve.useState)(null),l=(0,ve.useRef)(null),c=((p=t.match(Qt))==null?void 0:p.length)||0;return(0,ve.useEffect)(()=>{let u;return l.current&&(a(l.current),u=new je(l.current),u.on("change",({plainText:d})=>{s(ne.actions.userInput({text:d,selection:u.getSelection()}))}),u.on("keydown",d=>{s(ne.actions.registerKeyDown(Kn(d))),d.code==="Enter"&&d.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:d,selectionText:m})=>{s(ne.actions.registerPaste({text:d,selectionText:m}))}),u.on("cut",({selectionText:d})=>{s(ne.actions.registerCut(d))})),()=>{s(ne.actions.reset()),u.dispose(),u.deactivate()}},[l]),(0,ve.useEffect)(()=>{t&&l.current&&(l.current.value=t)},[t,l]),(0,ve.useEffect)(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let u=l.current.value.length;l.current.setSelectionRange(u,u),l.current.focus()},0)},[l]),(0,se.jsxs)("div",{className:r.textInputWrapper,children:[(0,se.jsx)("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&(0,se.jsx)(_g,{inputElement:l.current,value:t}),(0,se.jsxs)("div",{className:(0,qr.default)(r.alert,c===0?r.success:r.warning),children:[(0,se.jsx)("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?(0,se.jsx)(ul,{}):(0,se.jsx)(dl,{})]})]})},_g=({inputElement:t,value:e})=>{let o=S("EditSuggestionTextInput",Nr),n=(0,ve.useRef)(null),s=cs(t);return(0,ve.useEffect)(()=>{ps(t,s)},[s,t]),(0,se.jsx)(xg,{inputElement:t,children:(0,se.jsxs)("div",{ref:n,className:(0,qr.default)(o.root,o.agentText),children:[(0,se.jsx)(fl.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new oo("placeholders")],inputElement:t,boundaryRef:n}),(0,se.jsx)("br",{})]})})},xg=({inputElement:t,children:e})=>{let o=(0,ve.useRef)(null);return(0,ve.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=Lt(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,se.jsx)("div",{ref:o,children:e})},hl=vg;var co=require("react");var yl=require("react"),gs=w(require("classnames"));var re={root:"_root_pc5uy_1",list:"_list_pc5uy_2",listWrapper:"_listWrapper_pc5uy_6",listHorizontal:"_listHorizontal_pc5uy_10",page:"_page_pc5uy_19",search:"_search_pc5uy_25",pageNav:"_pageNav_pc5uy_33",pageTitle:"_pageTitle_pc5uy_41",pageBackButton:"_pageBackButton_pc5uy_48",listHeading:"_listHeading_pc5uy_62",listItem:"_listItem_pc5uy_70",listItemContent:"_listItemContent_pc5uy_79",listItemText:"_listItemText_pc5uy_97",listItemDescription:"_listItemDescription_pc5uy_105",listItemActions:"_listItemActions_pc5uy_112",truncate:"_truncate_pc5uy_123",lineClamp:"_lineClamp_pc5uy_129",listItemTitle:"_listItemTitle_pc5uy_136",listItemAction:"_listItemAction_pc5uy_112",listItemPrimaryAction:"_listItemPrimaryAction_pc5uy_157",listItemSelected:"_listItemSelected_pc5uy_162",sources:"_sources_pc5uy_166",sourcesTitle:"_sourcesTitle_pc5uy_173",source:"_source_pc5uy_166",icon:"_icon_pc5uy_188",searchIcon:"_searchIcon_pc5uy_205",searchInputWrapper:"_searchInputWrapper_pc5uy_210",searchInput:"_searchInput_pc5uy_210",select:"_select_pc5uy_231",selectType:"_selectType_pc5uy_248",selectWrapper:"_selectWrapper_pc5uy_252",image:"_image_pc5uy_282",imageSrc:"_imageSrc_pc5uy_289",imageSrcHidden:"_imageSrcHidden_pc5uy_300",imageSrcStatus:"_imageSrcStatus_pc5uy_304",imageTitle:"_imageTitle_pc5uy_314",actions:"_actions_pc5uy_319",actionsWrapper:"_actionsWrapper_pc5uy_323",actionsBar:"_actionsBar_pc5uy_329",actionButton:"_actionButton_pc5uy_338",actionShortcut:"_actionShortcut_pc5uy_356",actionShortcutFixKerning:"_actionShortcutFixKerning_pc5uy_363"};var Mt={};G(Mt,{enUS:()=>bg,nlNL:()=>Cg});var bg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},Cg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var dt=require("react/jsx-runtime"),wg=({src:t,title:e})=>{let o=S("CommandPalette",re),[n,s]=(0,yl.useState)("loading"),r=E(Mt);return(0,dt.jsxs)("div",{className:o.image,children:[(0,dt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,gs.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,dt.jsx)("span",{className:(0,gs.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,dt.jsx)("span",{className:(0,gs.default)(o.imageSrc,o.imageSrcStatus),children:(0,dt.jsx)(Tn,{})}),e&&(0,dt.jsx)("span",{className:o.imageTitle,children:e})]})},Sl=wg;var vl=w(require("react")),_l=w(require("classnames"));var qo=require("react/jsx-runtime");function Vr({children:t,heading:e,orientation:o}){let n=S("CommandPalette",re);return vl.default.Children.count(t)===0?null:(0,qo.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,qo.jsx)("h4",{className:n.listHeading,children:e}),(0,qo.jsx)("div",{className:(0,_l.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var Vo=w(require("classnames"));var ms=w(require("react")),Cl=require("react/jsx-runtime"),xl=ms.default.createContext(void 0);function gt(){let t=ms.default.useContext(xl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var bl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=ms.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,Cl.jsx)(xl.Provider,{value:i,children:t})};var V=w(require("react")),wl=w(require("classnames"));var Wr={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 Ot=require("react/jsx-runtime"),Tg=0,Tl=V.default.createContext(null),Eg=()=>{let t=(0,V.useContext)(Tl);if(!t)throw new Error("Invalid DropdownContext");return t},El=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,V.useMemo)(()=>++Tg,[]),s=(0,V.useRef)(null),r=(0,V.useRef)(null),i=S("Dropdown",Wr),[a,l]=(0,V.useState)(!1),[c,p]=(0,V.useState)(o),u=m=>{m.preventDefault(),m.stopPropagation(),l(!a)},d=(0,V.useCallback)(([m])=>{!m.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return(0,V.useEffect)(()=>{let m=f=>{s.current&&!s.current.contains(f.target)&&l(!1)};return document.addEventListener("click",m),()=>{document.removeEventListener("click",m)}},[]),(0,V.useEffect)(()=>{if(!r.current&&!a)return()=>{};let m=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return r.current&&m.observe(r.current),()=>{r.current&&m.unobserve(r.current)}},[r,a]),(0,Ot.jsx)(Tl.Provider,{value:{setIsOpen:l},children:(0,Ot.jsxs)("div",{ref:s,className:i.root,children:[(0,Ot.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:u,children:t}),(0,Ot.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,wl.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function kg({as:t,children:e,onClick:o,...n}){let s=t||"button",r=S("Dropdown",Wr),{setIsOpen:i}=Eg(),a=l=>{i(!1),o(l),l.stopPropagation()};return(0,Ot.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}El.Item=kg;var Gr=El;var $r=require("react/jsx-runtime"),kl=t=>(0,$r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,$r.jsx)("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})});var Nt={};G(Nt,{enUS:()=>Rg,nlNL:()=>Ig});var Rg={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"}]},Ig={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 fs=require("react/jsx-runtime"),Pg="%0d%0a%0d%0a%0d%0a",Ag=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Pg)}`},Lg=({suggestion:t,onFeedback:e})=>{let o=E(Nt),n=b("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,fs.jsx)(Gr,{trigger:(0,fs.jsx)(kl,{"data-testid":"feedback-dropdown-trigger"}),children:(0,fs.jsx)(Gr.Item,{as:"a",href:Ag(n,t),onClick:e,children:o("giveFeedback")})})},hs=Lg;var pe=require("react/jsx-runtime");function Xr({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,index:i,description:a,sources:l,styles:c,...p}){let{selected:u,setSelected:d,onChangeOpen:m}=gt(),f=S("CommandPalette",re);function g(v){n(v),t&&m(!1)}return(0,pe.jsxs)("div",{className:(0,Vo.default)(f.listItem,u===i&&f.listItemSelected),children:[(0,pe.jsx)("button",{onMouseEnter:()=>d(i),type:"button",className:(0,Vo.default)("command-palette-list-item",f.listItemAction,f.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:g,...p,children:(0,pe.jsxs)("div",{className:f.listItemContent,children:[typeof o=="string"?(0,pe.jsx)("p",{className:(0,Vo.default)(f.listItemText,f.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,pe.jsx)("p",{className:(0,Vo.default)(f.listItemDescription,c==null?void 0:c.description,e?f.lineClamp:f.truncate),children:a})]})}),s&&u===i&&(0,pe.jsx)("div",{className:f.listItemActions,children:(0,pe.jsx)(hs,{suggestion:String(o),onFeedback:s})}),l&&(0,pe.jsxs)("div",{className:f.sources,children:[(0,pe.jsx)("span",{className:f.sourcesTitle,children:"Sources"}),l.map(v=>v.url?(0,pe.jsx)("a",{className:f.source,href:v.url,target:"_blank",title:v.url,rel:"noopener noreferrer",onClick:()=>r&&r(v),children:v.name},v.url):(0,pe.jsx)("span",{className:f.source,children:v.name},v.name))]})]})}var Dt=require("react/jsx-runtime");function Qr({children:t,title:e,id:o,onDismiss:n}){let s=E(Mt),r=S("CommandPalette",re),{page:i}=gt();return i!==o?null:(0,Dt.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,Dt.jsxs)("div",{className:r.pageNav,children:[(0,Dt.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,Dt.jsx)(is,{}),s("back")]}),e&&(0,Dt.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var mt=require("react");var ys=()=>/Mac/i.test(navigator.platform);var vs=require("@reduxjs/toolkit");var Mg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=Mg;var io=require("@reduxjs/toolkit");function Og(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function M(t){return Array.isArray(t)?t.map(M):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Og(o)]:M(t[o])}),{}):t}function Zr(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function U(t){return Array.isArray(t)?t.map(U):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Zr(o)]:U(t[o])}),{}):t}var Ng={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Go=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)||""}},Wo=(0,io.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?M(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),M(n))}),Jr=(0,io.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}),Yr=(0,io.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Rl=t=>t.info.agentInfo,Il=(0,io.createSlice)({name:"info",initialState:Ng,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Wo.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Wo.rejected,e=>{e.fetchState="error"}).addCase(Wo.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(Jr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(Yr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(P,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Pl}=Il.actions,Al=Il.reducer;var Ss={list:[],fetchState:"idle",isOpen:!1,page:"search"},Ll=t=>t.search.isOpen,Ml=t=>t.search.page,Ol=t=>t.search.list;function Nl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Ht=(0,vs.createAsyncThunk)("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:Go(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),Dl=(0,vs.createSlice)({name:"search",initialState:Ss,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=Ss.fetchState,t.list=Ss.list}},extraReducers:t=>{t.addCase(Ht.pending,e=>{e.fetchState="loading"}).addCase(Ht.rejected,(e,o)=>{e.fetchState="error",k.error(o.error)}).addCase(Ht.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(P,()=>Ss)}}),{resetSearch:_s,setIsOpen:ue,setPage:J}=Dl.actions,Hl=Dl.reducer;var Dg=/(https?:\/\/[^\s]+)/,xs=t=>t.split(" ").find(e=>Dg.test(e));var ei=w(require("classnames"));var bs=require("react/jsx-runtime"),Hg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=S("CommandPalette",re);return(0,bs.jsxs)("button",{type:"button",...n,onClick:t,className:(0,ei.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,bs.jsx)("span",{className:(0,ei.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},ao=Hg;var qe=require("react/jsx-runtime"),Bg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=S("CommandPalette",re),a=E(Mt),{selected:l,setSelected:c}=gt(),p=r[l],u=p&&typeof p.text=="string"&&xs(p.text),d=(0,mt.useRef)(null);function m(y){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),C=0,j=0;y==="down"?(x.forEach((le,K)=>{K===l&&(C=K)}),j=C===x.length-1?0:C+1):y==="up"?(x.forEach((le,K)=>{K===l&&(C=K)}),j=C?C-1:x.length-1):c(0);let F=x[j];F&&typeof j=="number"&&(c(j),F.scrollIntoView&&F.scrollIntoView({behavior:"smooth",block:j?"center":"end"}))}function f(){if(!d.current)return;let y=d.current.querySelectorAll(".command-palette-list-item"),x=0;y.forEach((j,F)=>{F===l&&(x=F)});let C=y[x];C&&C.click()}let g=()=>{u&&window.open(u,"_blank")},v=()=>{p&&n(p,l)},T=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=(0,mt.useCallback)(y=>{if(y.key==="Enter"&&y.altKey&&u){g();return}if(y.key==="Enter"&&y.shiftKey){T();return}if(y.key==="ArrowDown"){y.preventDefault(),y.stopPropagation(),m("down");return}if(y.key==="ArrowUp"){y.preventDefault(),y.stopPropagation(),m("up");return}y.key==="Enter"&&l!==-1&&(y.preventDefault(),y.stopPropagation(),f())},[l]);return(0,mt.useEffect)(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),(0,qe.jsxs)("div",{className:i.actions,children:[(0,qe.jsx)("div",{className:i.actionsWrapper,ref:d,children:t}),(0,qe.jsxs)("div",{className:i.actionsBar,children:[u&&(0,qe.jsx)(ao,{onClick:g,shortKeys:[ys()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,qe.jsxs)(mt.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,qe.jsx)(ao,{onClick:T,shortKeys:[8679,8629],children:o}),(0,qe.jsx)(ao,{onClick:v,shortKeys:[8629],children:e})]})]})]})},Fl=Bg;var Kl=require("react");var $o=require("react/jsx-runtime"),lo=()=>(0,$o.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,$o.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,$o.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 ke=require("react/jsx-runtime");function Fg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=S("CommandPalette",re);return(0,ke.jsxs)("div",{className:l.search,children:[(0,ke.jsx)("div",{className:l.searchIcon,children:(0,ke.jsx)(lo,{})}),(0,ke.jsxs)("div",{className:l.searchInputWrapper,children:[(0,ke.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,ke.jsx)("div",{className:l.selectWrapper,children:(0,ke.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,ke.jsx)("option",{children:n}),s.map(c=>(0,ke.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Ul=(0,Kl.forwardRef)(Fg);var Xo=require("react/jsx-runtime");function Bt({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:u,search:d}){let[m,f]=(0,co.useState)(0),g=(0,co.useRef)(null),v=()=>{s&&s(o),i(void 0),r(""),a(!1)},T=()=>{var h;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(h=g.current)==null||h.focus();return}if(d.length>0){r("");return}a(!1)};return(0,co.useEffect)(()=>{f(0)},[d,n]),(0,Xo.jsx)(eo,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:T,onClose:v,children:(0,Xo.jsxs)(bl,{selected:m,setSelected:f,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&(0,Xo.jsx)(Ul,{ref:g,onChange:r,onChangeType:i,placeholder:t,value:d,selectedType:l,types:c,typePlaceholder:e}),p]})})}Bt.Page=Qr;Bt.List=Vr;Bt.Image=Sl;Bt.ListItem=Xr;Bt.ActionsBar=Fl;Bt.Button=ao;var A=Bt;var Q=require("react/jsx-runtime"),Kg=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=S("EditSuggestionForm",Ua),l=(0,Cs.useDispatch)(),c=E(Er),p=(0,Cs.useSelector)(f=>f.overlayInput.text);(0,ti.useEffect)(()=>{t&&(l(ne.actions.reset()),l(ne.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(ne.actions.commitSuggestion()))},[t]);let u=f=>{f.preventDefault(),d(p)},d=f=>{l(jn(f)),e(f)},m=f=>g=>{p!==i?window.confirm(c("warning"))&&f(g):f(g)};return(0,ti.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,Q.jsxs)("div",{className:a.root,children:[(0,Q.jsxs)("div",{className:a.content,children:[t.title&&(0,Q.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,Q.jsx)(Sr,{labels:t.searchKeywords}),(0,Q.jsx)(hl,{onUse:d,value:p})]}),(0,Q.jsxs)("form",{className:a.actions,onSubmit:u,children:[(0,Q.jsxs)("div",{children:[(0,Q.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&m(r),children:(0,Q.jsx)(is,{})}),(0,Q.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&m(s),children:(0,Q.jsx)(Za,{})})]}),(0,Q.jsxs)("div",{className:a.primaryButtons,children:[(0,Q.jsx)(A.Button,{onClick:m(o),shortKeys:["esc"],children:c("dismiss")}),(0,Q.jsx)(A.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},ws=Kg;var Ft=require("@reduxjs/toolkit");var Ug=["{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}"],zg=new RegExp(Ug.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function zl(t,e){let o=t.split(zg),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 u=a.charAt(0),d=0;do c=u?e.indexOf(u,c+1):-1,d+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&d>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 jl(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Vl={suggestions:[],fetchState:"idle",isInitialRequest:null},ql={default:Vl},Wl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},Gl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},$l=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")},po=t=>t.textSuggestions,Xl=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},Ts=(0,Ft.createAction)("textSuggestions/refresh"),Ve=(0,Ft.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=Jt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Go(n),t);if(t==="default"){let p=i?l.filter(Xl(a)):l;e.dispatch(Ne(p.slice(0,r)))}return l}),Qo=(0,Ft.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,{...Go(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Xl(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?zl(p.text,t):p.text}))),l=jl(l,r),e.dispatch(Ne(l)),l}),Ql=(0,Ft.createSlice)({name:"textSuggestions",initialState:ql,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(Ve.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Vl;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Ve.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Ve.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Qo.pending,e=>{e.default.fetchState="loading"}).addCase(Qo.rejected,e=>{e.default.fetchState="error"}).addCase(Qo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(P,()=>ql)}}),{setTextSuggestions:Zl,setSuggestionState:Jl}=Ql.actions,Yl=Ql.reducer;var tc=require("@reduxjs/toolkit");var ec={contentType:null,suggestion:null},oc=t=>t.activeSuggestion.suggestion,nc=t=>t.activeSuggestion.contentType,sc=(0,tc.createSlice)({name:"activeSuggestion",initialState:ec,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(P,()=>ec)}}),{setActiveSuggestion:We,resetActiveSuggestion:oi}=sc.actions,rc=sc.reducer;var ni={};G(ni,{enUS:()=>jg,nlNL:()=>qg});var jg={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"}]},qg={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 ic=require("@reduxjs/toolkit"),Vg={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Es=({ui:t})=>t.overlayCollapsed;var ac=(0,ic.createSlice)({name:"ui",initialState:Vg,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:Zo,setInputHasFocus:uo,setOverlayCollapsed:ft,setOpenOverlayWhenTyping:lc,setOverlayCollapsedUserOverwrite:cc}=ac.actions,pc=ac.reducer;var Jo=w(require("react")),dc=require("react/jsx-runtime"),uc=Jo.default.createContext(null),go=({broadcastEvents:t,children:e})=>{let o=Jo.default.useMemo(()=>t,[]);return(0,dc.jsx)(uc.Provider,{value:o,children:e})},_e=()=>{let t=(0,Jo.useContext)(uc);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var mo=require("@reduxjs/toolkit");var Wg={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Re=t=>t.auth.isLoggedIn,gc=t=>t.auth.loginFetchState,mc=t=>t.auth.verifyFetchState,fc=t=>t.auth.showLoginOverlay,ht=(0,mo.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),hc=(0,mo.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Yo=(0,mo.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),yc=(0,mo.createSlice)({name:"auth",initialState:Wg,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(ht.pending,e=>{e.loginFetchState="loading"}),t.addCase(ht.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(ht.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Yo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Yo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Yo.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:fo,setShowLoginOverlay:Sc}=yc.actions,vc=yc.reducer;var si="SetActiveSuggestion",ho="ShowLoginOverlay",ri="UserLoggedIn",Gg="UserLoggedOut",Ge="ApplySuggestion",ii="ApplyImageSuggestion",$g="ShowCommandPalette",Xg=t=>({[si]:e=>{t.dispatch(Jl(e.state)),t.dispatch(We({contentType:e.contentType,suggestion:e.suggestion}))},[$g]:e=>{t.dispatch(ue(e.isOpen)),e.page&&t.dispatch(J(e.page))},[ho]:e=>{t.dispatch(Sc(e))},[ri]:()=>{t.dispatch(ht())},[Gg]:()=>{t.dispatch(ht())},[ii]:e=>{t.dispatch(Vn({suggestion:e.suggestion}))},[Ge]:e=>{t.dispatch(Te({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(ut())}}),_c=Xg;var ai=require("react/jsx-runtime"),Qg=()=>{var f;let[t,e]=(0,xc.useState)(!1),o=(0,yo.useSelector)(oc),n=(0,yo.useSelector)(nc),s=(0,yo.useSelector)(po),r=(0,yo.useDispatch)(),i=_e(),a=E(ni),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(oi()),r(uo(!0)),r(ne.actions.reset())},p=(g,v)=>{r(oi()),r(uo(!0)),i.send(Ge,{text:g,suggestion:{...v,source:`${v.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let u=(f=s[n])==null?void 0:f.suggestions.indexOf(o),d=u===0||u===null?void 0:()=>r(We({contentType:n,suggestion:s[n].suggestions[u-1]})),m=u===s[n].suggestions.length-1||u===null?void 0:()=>r(We({contentType:n,suggestion:s[n].suggestions[u+1]}));return(0,ai.jsx)(eo,{autoFocus:!0,isOpen:u!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,ai.jsx)(ws,{onTouched:e,onDismiss:c,onUse:g=>p(g,o),suggestion:o,onNext:m,onPrevious:d})})},bc=Qg;var ci=require("react-redux");var ks=w(require("classnames")),Ie=require("react"),Rs=require("react-redux");var wc=w(require("classnames"));var Cc={root:"_root_1ukx5_1"};var Tc=require("react/jsx-runtime"),Zg=({className:t,value:e,...o})=>{let n=S("TextInput",Cc);return(0,Tc.jsx)("input",{className:(0,wc.default)(t,n.root),type:"text",value:e,...o})},en=Zg;var li={};G(li,{enUS:()=>Jg,nlNL:()=>Yg});var Jg={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"}]},Yg={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 Ec={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 B=require("react/jsx-runtime");var em=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},tm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(li),i=S("LoginTokenDialog",Ec),a=(0,Rs.useSelector)(mc),l=(0,Rs.useDispatch)(),c=b("productName"),[p,u]=(0,Ie.useState)(t||""),[d,m]=(0,Ie.useState)(0),[f,g]=(0,Ie.useState)(""),v=(0,Ie.useCallback)(async x=>{x.preventDefault(),l(hc({email:p})),m(1)},[o,p]),T=()=>{g(""),m(0)},h=(0,Ie.useCallback)(async x=>{x.preventDefault();let C=em(x.target.elements.token.value);if(!C){g(r("verifyCodeError",{login:y}));return}l(Yo({token:C}))},[o]),y=(0,Ie.useMemo)(()=>x=>(0,B.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:T,children:x},"back-button"),[]);return(0,Ie.useEffect)(()=>{a==="error"&&g(r("verifyCodeError",{login:y})),a==="done"&&n()},[a]),(0,B.jsx)(eo,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,B.jsxs)("div",{className:i.root,children:[(0,B.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),d===0&&(0,B.jsxs)("form",{onSubmit:v,children:[(0,B.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,B.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,B.jsx)(en,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:x=>u(x.target.value)}),(0,B.jsx)("div",{className:i.actions,children:(0,B.jsx)("button",{type:"submit",className:(0,ks.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),d===1&&(0,B.jsxs)("form",{onSubmit:h,children:[(0,B.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,B.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,B.jsx)(en,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&(0,B.jsx)("div",{className:i.errorMessage,children:f}),(0,B.jsxs)("div",{className:i.actions,children:[(0,B.jsx)("button",{type:"button",className:(0,ks.default)(i.button),onClick:T,children:r("back")}),(0,B.jsx)("button",{type:"submit",className:(0,ks.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},kc=tm;var Ic=require("react/jsx-runtime"),om=()=>{let t=(0,ci.useSelector)(fc),e=(0,ci.useSelector)(Rl),o=b("adminUrl"),n=_e(),s=()=>n.send(ho,!1),r=()=>{n.send(ho,!1),n.send(ri)};return(0,Ic.jsx)(kc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Rc=om;var Jc=w(require("lodash.debounce")),Y=require("react"),Qe=require("react-redux");var Is=require("@reduxjs/toolkit");var nm={data:null,fetchState:"idle"},Pc=t=>t.contentTypes.data,tn=(0,Is.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),sm=(0,Is.createSlice)({name:"contentTypes",initialState:nm,reducers:{},extraReducers:t=>{t.addCase(tn.pending,e=>{e.fetchState="loading"}).addCase(tn.rejected,e=>{e.fetchState="error"}).addCase(tn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Ac=sm.reducer;function on(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 Lc=require("react");function Mc(t,e){(0,Lc.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 nn=require("react"),Ls=require("react-redux");var Ps=require("@reduxjs/toolkit");var Oc={data:null,fetchState:"idle"},As=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},Pe=(0,Ps.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)}),rm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),im=(0,Ps.createSlice)({name:"entities",initialState:Oc,reducers:{},extraReducers:t=>{t.addCase(Pe.pending,e=>{e.fetchState="loading"}).addCase(Pe.rejected,e=>{e.fetchState="error"}).addCase(Pe.fulfilled,(e,o)=>{e.fetchState="done",e.data=rm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(P,()=>Oc)}}),Nc=im.reducer;var pi={};G(pi,{enUS:()=>am,nlNL:()=>lm});var am={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},lm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Dc={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Kt=require("react/jsx-runtime"),cm=({onCopy:t,onUse:e})=>{let o=(0,nn.useRef)(null),n=S("EntitiesList",Dc),s=E(pi),r=(0,Ls.useSelector)(As),i=(0,Ls.useDispatch)();return(0,nn.useEffect)(()=>{i(Pe())},[]),(0,nn.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,Kt.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,Kt.jsx)(A.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:(0,Kt.jsx)(A.List,{children:r.map((a,l)=>(0,Kt.jsx)(A.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,Kt.jsx)("p",{className:n.empty,children:s("noResults")})]})},Hc=cm;var Ae=require("react"),sn=require("react-redux");var Ms=require("@reduxjs/toolkit");var Bc={data:null,fetchState:"idle"},Fc=t=>t.summary.data,Kc=t=>t.summary.fetchState==="error",$e=(0,Ms.createAsyncThunk)("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();return i.length===0?Promise.reject(new Error("No messages are included")):{summary:await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel})}}),pm=(0,Ms.createSlice)({name:"summary",initialState:Bc,reducers:{},extraReducers:t=>{t.addCase($e.pending,e=>{e.data=null,e.fetchState="loading"}).addCase($e.rejected,e=>{e.data=null,e.fetchState="error"}).addCase($e.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(P,()=>Bc)}}),Uc=pm.reducer;var ui={};G(ui,{enUS:()=>um,nlNL:()=>dm});var um={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."}]},dm={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 zc={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 Xe=require("react/jsx-runtime"),gm=({onCopy:t})=>{let e=(0,Ae.useRef)(null),o=S("SummaryForm",zc),[n,s]=(0,Ae.useState)(""),r=E(ui),i=(0,sn.useSelector)(Fc),a=(0,sn.useSelector)(Kc),l=(0,sn.useDispatch)(),c=()=>{l($({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let u=document.getSelection();u&&l($({name:"summary copied to clipboard",data:{originalText:i,finalText:u==null?void 0:u.toString()},options:{includeConversationData:!0}}))};return(0,Ae.useEffect)(()=>{l($e())},[]),(0,Ae.useEffect)(()=>{s(i||"")},[i]),(0,Ae.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Ae.useEffect)(()=>{let u=d=>{d.key==="Enter"&&d.shiftKey&&c()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[n]),(0,Xe.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,Xe.jsx)("p",{className:o.error,children:r("error")}):(0,Xe.jsxs)(Ae.Fragment,{children:[(0,Xe.jsx)("div",{className:o.main,children:(0,Xe.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:u=>s(u.target.value)})}),(0,Xe.jsx)("div",{className:o.actions,children:(0,Xe.jsx)(A.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},jc=gm;var di={};G(di,{enUS:()=>mm,nlNL:()=>fm});var mm={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?"}]},fm={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var yt=w(require("react")),an=require("react-redux");var gi={};G(gi,{enUS:()=>hm,nlNL:()=>ym});var hm={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"}]},ym={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 qc={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 vo=require("@reduxjs/toolkit");var mi={data:[],fetchState:"idle"},Vc=t=>{var e;return(e=t.answer)==null?void 0:e.data},Wc=t=>t.answer.fetchState,_o=(0,vo.createAction)("answer/resetKnowledgeSearch"),So=(0,vo.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(i=e.getState().conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile is not defined");let r=await o.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),Sm=(0,vo.createSlice)({name:"answer",initialState:mi,reducers:{},extraReducers:t=>{t.addCase(So.pending,e=>{e.fetchState="loading"}).addCase(So.rejected,e=>{e.fetchState="error"}).addCase(So.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(P,()=>mi).addCase(_o,()=>mi)}}),Gc=Sm.reducer;var rn=require("react/jsx-runtime"),$c=()=>(0,rn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,rn.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,rn.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 ie=require("react/jsx-runtime"),vm=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=yt.default.useState(""),{setSelected:i}=gt(),a=(0,yt.useRef)(null),l=S("EntitiesList",qc),c=E(gi),p=(0,an.useDispatch)(),u=(0,an.useSelector)(Vc),d=(0,an.useSelector)(Wc),m=async g=>{g.preventDefault(),g.stopPropagation(),s!==""&&p(So({question:s,promptInstruction:n}))},f=(g,v)=>{p($({name:"knowledge assist source viewed",data:{question:v,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return(0,yt.useEffect)(()=>{var g;o&&d==="idle"?p(So({question:o,promptInstruction:n})):(g=a.current)==null||g.focus()},[a,d]),(0,yt.useEffect)(()=>{d==="done"&&(p($({name:"knowledge assist question answered",data:{question:s||o,sources:u[u.length-1].answer.sources,answer:u[u.length-1].answer.answer,isFollowUpQuestion:u.length>1},options:{includeConversationData:!0}})),i(u.length-1),r(""))},[d,u]),(0,yt.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,u]),(0,ie.jsxs)("div",{className:l.root,children:[u.length>0&&(0,ie.jsx)("div",{className:l.alignRight,children:(0,ie.jsx)(A.Button,{onClick:e,children:c("reset")})}),(0,ie.jsxs)(A.ActionsBar,{list:u.map(({answer:g})=>({text:g.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:g=>t(g.text),children:[u.map(({question:g,answer:v},T)=>(0,ie.jsx)(A.List,{children:(0,ie.jsx)(A.ListItem,{"data-testid":"knowledge-search-answer",index:T,description:v.answer,closeOnSelect:!0,onClick:()=>t(v.answer),onSourceClick:h=>f(h,g),sources:v.sources,styles:{title:l.question,description:l.answer},children:g})},`${v.answer}_${T}`)),d==="loading"&&(0,ie.jsx)("p",{className:l.status,children:c("loading")}),d==="error"&&(0,ie.jsx)("p",{className:l.status,children:c("error")}),(0,ie.jsxs)("form",{className:l.form,onSubmit:m,children:[(0,ie.jsx)("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:g=>{i(-1),r(g.target.value)}}),(0,ie.jsx)("button",{type:"submit",className:l.submit,children:(0,ie.jsx)($c,{})})]})]})]})},Xc=vm;var Os=require("@reduxjs/toolkit");var _m={data:null,fetchState:"idle"},xo=t=>t.profile.data,Ns=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],ln=(0,Os.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)}),xm=(0,Os.createSlice)({name:"profile",initialState:_m,reducers:{},extraReducers:t=>{t.addCase(ln.pending,e=>{e.fetchState="loading"}).addCase(ln.rejected,e=>{e.fetchState="error"}).addCase(ln.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Qc=xm.reducer;var z=require("react/jsx-runtime"),bm=200,Cm=5,wm=4,Tm=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Zc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Em=()=>{let t=(0,Qe.useDispatch)(),e=_e(),o=E(di),[n,s]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(""),a=(0,Qe.useSelector)(Ml),l=(0,Qe.useSelector)(xo),[c,p]=(0,Y.useState)(null),[u,d]=(0,Y.useState)([]),[m,f]=(0,Y.useState)(),g=(0,Qe.useSelector)(Re),v=b("showSearch"),T=b("showEntitiesCommand"),h=b("showSummaryCommand"),y=b("showKnowledgeSearch"),x=b("showImageSearch"),C=b("searchTriggerKey"),j=(0,Qe.useSelector)(Pc),F=(0,Qe.useSelector)(Ol),le=(0,Qe.useSelector)(Ll),K=_=>fr(F.filter(L=>L.type===_.toUpperCase()),_),I=[{value:"PERSONAL",label:o("personalSuggestions"),list:K("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:K("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:K("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:K("IMAGE"),listOrientation:"horizontal",shouldShow:x}].filter(_=>_.shouldShow),D=[{label:o("entitiesClipboard"),onClick:()=>t(J("entities")),shouldShow:T&&Zc(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(J("summary")),shouldShow:h&&Zc(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(J("knowledgeAssist")),shouldShow:y}].filter(_=>_.shouldShow),oe=(j==null?void 0:j.map(_=>({value:_.code.toUpperCase(),label:`${_.name}s`,list:K(_.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],gr=(0,Y.useCallback)((0,Jc.default)((_,L)=>{t(Ht({query:_,type:L,tags:["search-overlay"]}))},bm),[]),Tt=Tm([...oe,...I]),dd=(0,Y.useCallback)((_,L)=>{if(!L)return;let rt=[...I,...oe].find(({value:Wt})=>Wt===L);rt&&(t(J("edit")),p({..._,searchTerm:void 0}),d(rt.list))},[t,c,oe]),mr=(0,Y.useCallback)((_,L)=>{switch(L.type){case"IMAGE":e.send(ii,{suggestion:L});break;default:e.send(Ge,{text:_,suggestion:L})}t(ue(!1))},[t]),gd=_=>{on(_.text),t($({name:"entity copied",data:{entity:_,type:"copy"}})),t(ue(!1))},md=(0,Y.useCallback)(_=>{t($({name:"suggestion feedback",data:{text:_.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),fd=_=>{e.send(Ge,{text:_,suggestion:{source:"knowledge-assist",text:_}}),t($({name:"answer used",data:{originalText:_},options:{includeConversationData:!0}})),i(""),t(J("search")),t(_o()),t(ue(!1))},hd=_=>{on(_),t(ue(!1))},yd=_=>{e.send(Ge,{text:_.text,suggestion:{source:"entity",text:_.text}}),t(ue(!1))},Sd=c===null||u.indexOf(c)-1<0?void 0:()=>p(u[u.indexOf(c)-1]),vd=c===null||u.indexOf(c)===u.length-1?void 0:()=>p(u[u.indexOf(c)+1]);function fr(_,L){return _.slice(0,m?10:L.toLowerCase()==="image"?wm:Cm)}function Xi(_,L,rt){return L.reduce((Wt,bn)=>rt&&m===rt?bn.length+Wt:fr(bn,rt).length+Wt,_)}function Vt(_){return L=>{n?window.confirm(o("warning"))&&(_(L),s(!1)):_(L)}}return(0,Y.useEffect)(()=>{r?gr(r,m):t(_s())},[r,m]),(0,Y.useEffect)(()=>{a==="search"&&t(_o())},[a]),(0,Y.useEffect)(()=>{g&&t(tn())},[g]),Mc(C,()=>t(ue(!0))),!v||!l?null:(0,z.jsxs)(A,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Vt(_=>t(ue(_))),onChangeType:_=>f(_),onChangePage:Vt(_=>t(J(_))),selectedType:m,search:r,page:a,isOpen:le,types:[...oe,...I],children:[(0,z.jsx)(A.Page,{id:"search",children:(0,z.jsxs)(A.ActionsBar,{list:[...D.map(_=>({text:_.label,type:"command"})),...Tt.map(_=>({text:_.text||_.url||_.message,type:_.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:_},L)=>mr(_,Tt[L]),onSecondary:(_,L)=>{dd(Tt[L-D.length],Tt[L-D.length].type)},children:[D.length>0&&(0,z.jsx)(A.List,{heading:o("commands"),children:D.map((_,L)=>(0,z.jsx)(A.ListItem,{index:Xi(L,[],"commands"),closeOnSelect:!1,onClick:_.onClick,children:_.label},_.label))}),[...oe,...I].map(({value:_,label:L,list:rt,lineClamp:Wt,listOrientation:bn},_d)=>(0,z.jsx)(A.List,{heading:L,orientation:bn==="horizontal"?"horizontal":"vertical",children:fr(rt,_).map((me,xd)=>(0,z.jsx)(A.ListItem,{index:Xi(D.length+xd,[...oe,...I].slice(0,_d).map(({list:bd})=>bd),_),closeOnSelect:!1,lineClamp:Wt,onClick:()=>mr(me.text,me),description:_!=="IMAGE"?me.title&&me.text:void 0,onFeedback:_!=="IMAGE"?()=>md(me):void 0,children:_==="IMAGE"?(0,z.jsx)(A.Image,{title:me.title||me.text,src:me.image}):me.title||me.text},`${me.id}-${me.text}`))},_))]})}),(0,z.jsx)(A.Page,{id:"edit",onDismiss:Vt(()=>{t(J("search")),p(null)}),children:c&&(0,z.jsx)(ws,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(J("search")),p(null),d([])},onNext:vd,onPrevious:Sd,onUse:_=>{t(J("search")),mr(_,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(ue(!1)),d([]),p(null)}})}),(0,z.jsx)(A.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:Vt(()=>{t(J("search"))}),children:(0,z.jsx)(Hc,{onUse:yd,onCopy:gd})}),(0,z.jsx)(A.Page,{id:"summary",title:o("summaryTitle"),onDismiss:Vt(()=>{t(J("search"))}),children:(0,z.jsx)(jc,{onCopy:hd})}),(0,z.jsx)(A.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:Vt(()=>{t(_o()),t(J("search"))}),children:(0,z.jsx)(Xc,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:fd,onResetQuestion:()=>{t(_o()),i("")}})})]})},Yc=Em;var bo=require("react/jsx-runtime"),km=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,bo.jsxs)(ep.Fragment,{children:[t&&(0,bo.jsx)(Yc,{}),(0,bo.jsx)(bc,{}),e&&(0,bo.jsx)(Rc,{})]})},tp=km;var Ze=require("react-redux");function Co(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 Hs=require("react");var ap=require("interweave"),To=require("react"),Ds=require("react-redux");var op=require("react");function np(t,e,o){(0,op.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var Rm=/[.*+?^${}()|[\]\\]/g,Im=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Pm(t){return t.replace(Rm,"\\$&")}function Am(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function Lm(t){return t.search(Im)}function sp(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${Pm(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function rp(t){return t.replace(Qt,'<mark data-type="placeholder">$1</mark>')}function wo(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Mm(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 fi(t,e,o={}){if(e){let n=Am(e.toLowerCase(),t.toLowerCase()),s=wo(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=Lm(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(fa).length>3||e.length>30?Mm(e.trim(),n):0;return`${`${i>0?"\u2026":""}${wo(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var ip={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var Ut=require("react/jsx-runtime"),Nm=["search","personal-collection-search","search-autocomplete"];function Dm(t,e,o,n={}){let s="";return Nm.includes(e)?s=sp(fi(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=fi(t,o,n),n.placeholders===!0&&(s=rp(s)),s}var Hm=()=>{},Bm=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=b("inlineSuggestions"),r=(0,Ds.useSelector)(Jt),i=(0,Ds.useDispatch)(),a=S("TextSuggestion",ip),l=(0,To.useRef)(null);(0,To.useEffect)(()=>{let p=setTimeout(()=>{i(Ma({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),np(l,"click",()=>{i(pt(t)),i(Te({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,To.useMemo)(()=>Dm(o.text,o.source,r,{stripAgentPart:s,placeholders:!0,searchKeywords:o.searchKeywords}),[s,o.text,o.source,r,o.searchKeywords]);return o.source==="gpt"&&!s?null:(0,Ut.jsxs)("div",{className:a.root,onMouseEnter:()=>i(pt(t)),children:[(0,Ut.jsx)(O,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Hm,children:(0,Ut.jsx)(ap.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&(0,Ut.jsx)("div",{className:a.actions,children:(0,Ut.jsx)(hs,{onFeedback:()=>n(o),suggestion:o.text})})]})},lp=Bm;var hi=require("react/jsx-runtime"),Fm=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,Hs.useMemo)(()=>{let r=e.map((i,a)=>(0,hi.jsx)(lp,{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)(Hs.Fragment,{children:s})},Bs=Fm;var cp={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var cn=require("react/jsx-runtime"),Km=({textSuggestions:t,selectedIndex:e})=>{let o=S("InlineSuggestionsOverlay",cp),n=(0,Ze.useSelector)(Co),s=(0,Ze.useDispatch)(),r=(0,Ze.useSelector)(Re),i=(0,Ze.useSelector)(Zt),a=(0,Ze.useSelector)(Es),l=b("showTextSuggestions");return so(()=>{s(ft({collapse:!0,skipWhenInputFocus:!0}))}),a||!n||!l||t.length===0||r!==!0||i===!1?null:(0,cn.jsx)("div",{className:o.root,"data-variant":"inline",children:(0,cn.jsx)("div",{className:o.paper,children:(0,cn.jsx)(Se,{children:(0,cn.jsx)(Bs,{suggestions:t,selectedIndex:e})})})})},Um=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),pp=(0,Ze.connect)(Um)(Km);var Ks=w(require("classnames")),Eo=require("react"),Be=require("react-redux");var up=require("react");function dp(t,e){let[o,n]=(0,up.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return k.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){k.error(i)}}]}var mp=w(require("classnames")),Je=require("react");var yi={};G(yi,{enUS:()=>zm,nlNL:()=>jm});var zm={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"}]}]},jm={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 gp={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var St=require("react/jsx-runtime"),Si=(t,e,o)=>n=>(0,St.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),qm=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=E(yi),r=_e(),i=S("Login",gp),a=b("productName"),l=(0,Je.useCallback)(g=>{g.preventDefault(),n&&n(parseInt(g.target.value,10))},[]),c=(0,Je.useCallback)(g=>{g.preventDefault(),r.send(ho,!0)},[e]),p=(0,Je.useMemo)(()=>g=>(0,St.jsx)("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),u=(0,Je.useCallback)(g=>(0,St.jsx)("button",{type:"button",className:i.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:d,hour:m,day:f}=(0,Je.useMemo)(()=>({min:Si(i,60*10,l),hour:Si(i,60*60,l),day:Si(i,60*60*12,l)}),[]);return(0,St.jsxs)("div",{className:(0,mp.default)(t,i.root),children:[s("loginPlease",{login:o?u:p,productName:a}),n&&(0,St.jsxs)(Je.Fragment,{children:[(0,St.jsx)("br",{}),s("snooze",{min:d,hour:m,day:f})]})]})},Fs=qm;var hp=require("react-redux");var fp={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var pn=require("react/jsx-runtime"),Vm=({title:t})=>{let e=S("SearchTrigger",fp),o=(0,hp.useDispatch)();return(0,pn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ue(!0)),children:[(0,pn.jsx)(lo,{}),(0,pn.jsx)("span",{className:e.text,children:t})]})},yp=Vm;var vi={};G(vi,{enUS:()=>Wm,nlNL:()=>Gm});var Wm={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"}]},Gm={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 Sp={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 N=require("react/jsx-runtime"),$m=({textSuggestions:t,selectedIndex:e})=>{let o=S("SuggestionsOverlay",Sp),n=E(vi),s=(0,Be.useSelector)(Co),r=Ra(),i=(0,Be.useDispatch)(),a=(0,Eo.useRef)(null),l=b("searchTriggerKey"),c=b("productName"),p=(0,Be.useSelector)(Es),u=(0,Be.useSelector)(Re),d=(0,Be.useSelector)(Zt),[m,f]=(0,Eo.useState)(null),g=b("showSearch"),v=b("showTextSuggestions"),T=b("adminUrl"),h=b("isEmbedded"),[y,x]=dp("dd-snooze-until-ms",0),C=p||y>Date.now(),j=(0,Be.useSelector)(D=>D.input.text),F=t.filter(D=>D.source!=="gpt").length,le=()=>{C&&x(0),i(cc(!C))},K=D=>{i($({name:"suggestion feedback",data:{text:D.text,source:"overlay",context:j},options:{includeConversationData:!0}}))},I=D=>{let oe=Date.now()+D*1e3;x(oe),k.info(`Snooze until: ${new Date(oe)}`),i(ft({collapse:!0}))};return(0,Eo.useEffect)(()=>{F===0&&f(null)},[t,F]),so(()=>{i(ft({collapse:!0,skipWhenInputFocus:!0}))}),u===null||d===!1?null:u===!1?(0,N.jsxs)("div",{ref:a,className:(0,Ks.default)(o.root,{[o.isCollapsed]:C}),children:[!C&&(0,N.jsxs)("div",{className:o.triggers,children:[(0,N.jsx)("div",{style:{flex:1}}),(0,N.jsx)("div",{className:o.triggersRight,children:(0,N.jsx)(Rt,{className:o.toggleButton,title:n("collapse"),onClick:le,isCollapsed:!1})})]}),(0,N.jsx)("div",{className:o.toggleButtonWrapper,children:(0,N.jsx)(Rt,{className:o.toggleButton,title:n("open",{productName:c}),onClick:le,isCollapsed:!0})}),(0,N.jsx)("div",{className:o.collapsible,children:(0,N.jsx)(Fs,{loginUrl:T,isEmbedded:h,onSnooze:I})})]}):!r||!s?null:(0,N.jsxs)("div",{ref:a,className:(0,Ks.default)(o.root,{[o.isCollapsed]:C}),children:[!C&&(0,N.jsxs)("div",{className:o.triggers,children:[(0,N.jsx)("div",{style:{flex:1},children:g&&(0,N.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(n(ys()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,N.jsx)(yp,{title:n("search")})})}),(0,N.jsxs)("div",{className:o.triggersRight,onFocus:()=>{},children:[(0,N.jsx)("div",{className:(0,Ks.default)(!m&&o.hintsHidden,o.hints),children:m}),(0,N.jsx)(Rt,{className:o.toggleButton,title:n("collapse"),onClick:le,isCollapsed:!1})]})]}),(0,N.jsx)("div",{className:o.toggleButtonWrapper,children:(0,N.jsx)(Rt,{className:o.toggleButton,title:n("open",{productName:c}),onClick:le,isCollapsed:!0})}),F>0&&v&&(0,N.jsx)("div",{className:o.collapsible,onFocus:()=>{},children:(0,N.jsx)(Se,{children:(0,N.jsx)(Bs,{onFeedback:K,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Xm=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),vp=(0,Be.connect)(Xm)($m);var _p=require("react-redux");var un=require("react/jsx-runtime"),Qm=({children:t})=>{let o=b("locale").replace("-","");return(0,un.jsx)(Or.Provider,{value:o,children:t})},Zm=({store:t,customStyles:e={},children:o})=>(0,un.jsx)(_p.Provider,{store:t,children:(0,un.jsx)(Qm,{children:(0,un.jsx)(Lo.Provider,{value:e,children:o})})}),ko=Zm;var Ys=w(require("classnames")),Fp=require("interweave"),tt=require("react"),Kp=require("react-redux");var xp=require("react"),Jm=["div","span","mark","strong","b","i","u","em"];function _i(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(Jm.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,xp.cloneElement)(n,{children:_i(i,e,o+1)})]}return[...t,...e]}function vt(t){return t.tagName.toLowerCase()==="textarea"}var bp={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 Ap=w(require("classnames")),Lp=require("interweave"),Xs=require("react");function Cp(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Us(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function wp(t){return t!=null}var bi=w(require("classnames")),xe=require("react");var zs=require("react"),Ym=["bottom","height","left","right","top","width"],ef=(t={},e={})=>Ym.some(o=>t[o]!==e[o]),Ye=new Map,Tp,Ep=()=>{let t=[],e=[];Ye.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();ef(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Ye.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Tp=window.requestAnimationFrame(Ep)};function tf(t,e){return{observe(){let o=Ye.size===0;if(Ye.has(t)){let n=Ye.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Ye.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&Ep()},unobserve(){let o=Ye.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ye.delete(t),Ye.size||cancelAnimationFrame(Tp)}}}}function xi(t){let[e,o]=(0,zs.useState)(null);return(0,zs.useLayoutEffect)(()=>{if(!t.current)return;let n=tf(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var Ro=require("react"),Rp=require("react-dom");var kp={root:"_root_1jq08_1"};var Ip=({children:t})=>{let[e,o]=(0,Ro.useState)(null),n=(0,Ro.useContext)(Lo);return(0,Ro.useLayoutEffect)(()=>{let s=document.createElement("div");return At(s),s.classList.add(kp.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,Rp.createPortal)(t,e):null};var Fe={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};var js=require("react/jsx-runtime"),qs=(t=!1)=>{let[e,o]=(0,xe.useState)(t),n=(0,xe.useCallback)(()=>o(!0),[]),s=(0,xe.useCallback)(()=>o(!1),[]),r=(0,xe.useCallback)(()=>o(a=>!a),[]),i=(0,xe.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Ci(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 Vs=({className:t,triggerRef:e,boundaryRef:o=(0,xe.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=Ci,...a})=>{let l=xi(e),c=xi(o),p=(0,xe.useMemo)(()=>i(l,c,0),[l,c]);return(0,js.jsx)(Ip,{children:(0,js.jsx)("div",{className:(0,bi.default)(Fe.ref,{[Fe.positionAbove]:n==="above",[Fe.positionBelow]:n==="below",[Fe.positionLeft]:n==="left",[Fe.positionRight]:n==="right",[Fe.alignStart]:s==="start",[Fe.alignCenter]:s==="center",[Fe.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,js.jsx)("div",{className:(0,bi.default)(t,Fe.root),children:r})})})};var Pp=w(require("classnames")),Ws=require("react");var wi=require("react/jsx-runtime"),Gs=(0,Ws.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,Ws.useRef)(null),r=S("TabCompletion",Ue);return(0,wi.jsx)("div",{ref:Us([s,n]),className:(0,Pp.default)(t,r.popoverContentContainer),...o,children:(0,wi.jsx)("div",{className:r.popoverContent,children:e})})});var _t=require("react/jsx-runtime"),of=t=>e=>{let o=Ci(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},nf=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=S("TabCompletion",Ue),i=qs(),a=(0,Xs.useMemo)(()=>of(t.getBoundingClientRect()),[t]),[l,c]=as(t);return(0,Xs.useEffect)(()=>{c?i.open():i.close()},[c]),(0,_t.jsxs)("span",{children:[(0,_t.jsx)("mark",{ref:Us([l,i.triggerRef]),className:(0,Ap.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,_t.jsx)(Vs,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,_t.jsx)(Gs,{style:o,children:(0,_t.jsx)("div",{className:r.hintText,children:s})})})]})},$s=class extends Lp.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${Cp(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(wp);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return(0,_t.jsx)(nf,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Zs=w(require("classnames")),Hp=require("interweave"),te=require("react"),Bp=require("react-redux");var Ti=require("react/jsx-runtime"),Mp=()=>(0,Ti.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,Ti.jsx)("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});var xt=require("react"),dn=require("react-redux"),Np=w(require("lodash.debounce"));var Op={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Qs(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 Ei(t){return t.replace("https://www.","").replace("https://","")}var be=require("react/jsx-runtime"),sf=3,rf=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),af=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=sf})=>{let r=S("LinkSearch",Op),[i,a]=(0,xt.useState)(""),l=(0,dn.useDispatch)(),c=(0,dn.useSelector)(Wl("url")),p=(0,dn.useSelector)(Nl("URL",rf)),[u,d]=(0,xt.useState)(p.length-1),m=b("fallbackImage"),f=h=>{let y=h.target;a(y.value)},g=(h,y)=>{h.stopPropagation(),h.preventDefault(),window.open(y,"_blank")},v=h=>{var C;let y=u-1<0?p.length-1:u-1,x=u+1===p.length?0:u+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&d(y),h.code==="ArrowDown"&&d(x),h.code==="Enter"&&t(((C=p[u])==null?void 0:C.text)||i)},T=(0,xt.useCallback)((0,Np.default)(h=>{l(Ht({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,xt.useEffect)(()=>{i&&T(i)},[i]),(0,xt.useEffect)(()=>()=>{l(_s())},[]),(0,be.jsxs)("div",{className:r.root,children:[(0,be.jsx)(Se,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,y)=>(0,be.jsx)(O,{selected:u===y,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:(0,be.jsxs)(H,{children:[(0,be.jsx)(H.Image,{src:Qs(h,"small",m||void 0),title:h.title||h.text}),(0,be.jsxs)(H.Content,{className:r.content,cropText:!0,children:[(0,be.jsx)(H.Title,{children:h.title||Ei(h.text)}),h.title&&Ei(h.text)]}),(0,be.jsx)(O.Actions,{children:(0,be.jsx)(O.ActionButton,{label:n,onClick:x=>g(x,h.text)})})]})},h.text))}),(0,be.jsx)(en,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:v})]})},Dp=af;var ki={};G(ki,{enUS:()=>lf,nlNL:()=>cf});var lf={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},cf={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var ee=require("react/jsx-runtime"),pf=(0,te.forwardRef)((t,e)=>{let o=S("TabCompletion",Ue);return(0,ee.jsx)("mark",{ref:e,className:(0,Zs.default)(o.matchSelection)},"selection-start")}),uf=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(ki),i=S("TabCompletion",Ue),a=(0,te.useRef)(null),l=(0,te.useRef)(null),[c,p]=(0,te.useState)(null),u=(0,Bp.useDispatch)(),d=qs(document.activeElement===n),[m]=(0,te.useState)(()=>document.createRange());d.triggerRef.current=m,(0,te.useEffect)(()=>()=>m.detach(),[]),(0,te.useEffect)(()=>{let g=t.current,v=a.current;!g||!v||(m.setStart(g,0),m.setEnd(v,0))},[t.current,a.current]),so(()=>{d.close()});let f=(0,te.useCallback)(g=>{let v=m.toString(),T=/^http(s?):\/\//.test(g)?g:`https://${g}`;u(Un({text:`[${v}](${T})`,replace:"selection"}))},[]);return(0,ee.jsxs)("span",{children:[(0,ee.jsx)("mark",{ref:a,className:(0,Zs.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:s}),d.opened&&(0,ee.jsx)(Vs,{className:i.popoverRoot,triggerRef:d.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,ee.jsxs)(Gs,{style:o,ref:l,children:[(0,ee.jsx)("div",{className:(0,Zs.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,ee.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,ee.jsx)(Mp,{}),(0,ee.jsx)("span",{children:"\xA0"}),(0,ee.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,ee.jsx)(Dp,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),d.close()}})]})})]},"selection-end")},Js=class extends Hp.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,te.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,ee.jsx)(pf,{ref:this.startRef}):(0,ee.jsx)(uf,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var et=require("react/jsx-runtime"),df=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=S("TabCompletion",bp),p=b("insertLink"),u=b("showMidSentenceSuggestions"),d=b("inlineSuggestions"),m=cs(a),f=(0,tt.useRef)(null);(0,tt.useEffect)(()=>{vt(a)&&m&&ps(a,m)},[m]);let g=(0,tt.useCallback)(h=>{if(!s||!o)return h;let y=[(0,et.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,et.jsx)("span",{"data-testid":"tab-completion",className:(0,Ys.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&y.push((0,et.jsx)("span",{className:(0,Ys.default)(c.hint,c.resetIndent),children:(0,et.jsx)(In,{keyCode:"tab"},"tabHint")})),_i(h,y)},[s,o,n]),v=(0,tt.useMemo)(()=>{let h=[];return p&&h.push(new Js("selection")),h.push(new oo("placeholders")),r&&h.push(new $s("keywords")),h},[d,p,r]),T=(0,tt.useMemo)(()=>{let h=window.getComputedStyle(a);return{"--dd-color":h.color,"--dd-font-size":h.fontSize,"--dd-font-family":h.fontFamily,"--dd-font-variant":h.fontVariant}},[]);return t?(0,et.jsxs)("div",{ref:h=>{h!=null&&h.parentElement&&(f.current=h==null?void 0:h.parentElement)},className:c.root,style:T,children:[(0,et.jsx)(Fp.Interweave,{tagName:"span",containerTagName:"div",className:(0,Ys.default)(c.container,c.agentText),disableLineBreaks:vt(a),content:e||"\u200B",onAfterParse:g,matchers:v,selection:m,keywordMatches:i,inputElement:a,inputStyle:T,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!u}),(0,et.jsx)("br",{})]}):null},gf=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var g;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??wo(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:u}=s,{showTabCompletion:d,visible:m,showStyleSuggestions:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:d,content:l,tabText:c,source:a,keywordMatches:((g=n.list)==null?void 0:g.keywordMatches)??[],enabled:m&&u!==!1}},Up=(0,Kp.connect)(gf)(df);var Lu=w(require("classnames")),Mu=require("react"),W=require("react-redux");var bt=require("@reduxjs/toolkit");var zp={list:[],fetchState:"idle",isInitialRequest:null},qp=t=>t.autoflows.list||[],jp=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},ot=(0,bt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Ri=(0,bt.createAsyncThunk)("autoflows/start",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.startAutoflowSession(t),await o(ot(t.platformSessionId))}),Ii=(0,bt.createAsyncThunk)("autoflows/stop",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.stopAutoflowSession(t.platformSessionId),await o(ot(t.platformSessionId))}),mf=(0,bt.createSlice)({name:"autoflows",initialState:zp,reducers:{},extraReducers:t=>{t.addCase(Ri.pending,(e,o)=>{let n=jp(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Ii.pending,(e,o)=>{let n=jp(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(ot.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(ot.rejected,e=>{e.fetchState="error"}),t.addCase(ot.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(P,()=>zp)}}),Vp=(0,bt.createAsyncThunk)("autoflows/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");let s=n.openStream(t);s.on("sessionAborted",()=>{o(ot(t))}),s.on("sessionCompleted",()=>{o(ot(t))})}),Wp=(0,bt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Gp=mf.reducer;var Ct=require("@reduxjs/toolkit");var $p={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Xp=t=>t.customMessages.list,Qp=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Zp=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Jp=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),gn=(0,Ct.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),er=(0,Ct.createAsyncThunk)("customMessages/send",async(t,e)=>{let{platformSessionId:o,suggestion:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.sendCustomMessage(o,n)}),tr=(0,Ct.createAsyncThunk)("customMessages/answer",async(t,e)=>{let{platformSessionId:o,reply:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.answerCustomMessage(o,n)}),Yp=(0,Ct.createSlice)({name:"customMessages",initialState:$p,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(gn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(gn.rejected,e=>{e.fetchState="error"}).addCase(gn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(er.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(er.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(tr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(tr.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(P,()=>$p)}}),eu=(0,Ct.createAsyncThunk)("customMessages/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.openStream(t).on("customMessageSuggestion",r=>{o(Yp.actions.onCustomMessage(r))})}),tu=(0,Ct.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),ou=Yp.reducer;var mn=require("@reduxjs/toolkit"),ff={jwt:null,accountUrl:null,interval:null},nu=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},Pi=(0,mn.createAsyncThunk)("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),Ai=(0,mn.createAsyncThunk)("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(Pi()),setInterval(()=>n(Pi()),o)}),su=(0,mn.createSlice)({name:"exchangeToken",initialState:ff,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Pi.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(Ai.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:ru}=su.actions,iu=su.reducer;function au(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var hu=require("react"),yu=require("react-redux");var gu=w(require("classnames")),mu=require("react");var cu=w(require("classnames"));var lu={root:"_root_838fd_1"};var uu=require("react/jsx-runtime"),hf=({className:t,children:e})=>{let o=S("Unicode",lu);return(0,uu.jsx)("span",{className:(0,cu.default)(t,o.root),children:e})},pu=hf;var du={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 Li={};G(Li,{enUS:()=>yf,nlNL:()=>Sf});var yf={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"}]},Sf={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 de=require("react/jsx-runtime"),_f=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=S("Autoflow",du),a=E(Li),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,de.jsxs)(O,{className:(0,gu.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,de.jsx)(H,{children:(0,de.jsxs)(H.Content,{children:[(0,de.jsxs)(H.Title,{children:[e&&(0,de.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,de.jsx)("span",{children:n})]})}),(0,de.jsx)(O.Actions,{fixed:e==="Started",children:(0,de.jsx)(O.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,de.jsxs)(mu.Fragment,{children:[(0,de.jsx)(pu,{children:c})," ",(0,de.jsx)("span",{children:a(l)})]})})})]})},fu=_f;var Mi=require("react/jsx-runtime"),xf=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},bf=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Mi.jsx)(hu.Fragment,{children:t.map(s=>(0,Mi.jsx)(fu,{displayName:s.displayName,description:s.description,disabled:s.isBusy||xf(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Cf=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},wf={onStartAutoflow:Ri,onStopAutoflow:Ii},Su=(0,yu.connect)(Cf,wf)(bf);var or=require("react"),_u=require("react-redux"),Di=w(require("classnames"));var Oi=require("react/jsx-runtime"),Ni=()=>(0,Oi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,Oi.jsx)("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var vu={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var Ke=require("react/jsx-runtime"),Tf=({entities:t})=>{let e=S("EntitiesWidgetList",vu),[o,n]=(0,or.useState)(void 0),s=(0,_u.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),on(a.text),s($({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,or.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Ke.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Ke.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Ke.jsx)("span",{className:e.entityText,children:a.text}),(0,Ke.jsxs)("span",{className:e.iconWrapper,children:[(0,Ke.jsx)("span",{className:(0,Di.default)(e.icon),children:(0,Ke.jsx)(Ni,{})}),(0,Ke.jsx)("span",{className:(0,Di.default)(e.icon,o===l&&e.iconClicked),children:(0,Ke.jsx)(Ni,{})})]})]},a.text))})},xu=Tf;var bu=w(require("classnames")),Hi=require("react"),zt=require("react-redux");var nt={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 ae=require("react/jsx-runtime"),Ef=({suggestion:t})=>{let e=E(Nt),o=(0,zt.useDispatch)(),n=(0,zt.useSelector)(Qp(t.text)),s=(0,zt.useSelector)(Zp(t.text)),r=(0,zt.useSelector)(Jp(t.text)),i=(0,zt.useSelector)(Mn),{replyOptions:a}=t,l=(0,Hi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(er({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Hi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let u=parseInt(p.target.dataset.index,10),d=a[u];o(tr({platformSessionId:i,reply:d,suggestion:t}))},[t,n,o,i]);return(0,ae.jsxs)(O,{onClick:l,className:(0,bu.default)(nt.root,{[nt.isUsed]:n,[nt.hasError]:r}),children:[(0,ae.jsx)(H,{children:(0,ae.jsxs)(H.Content,{children:[(0,ae.jsxs)(H.Title,{className:nt.title,children:[t.text," ",(0,ae.jsx)(Pn,{className:nt.label,children:"analyse tool"})," ",r&&(0,ae.jsx)("span",{className:nt.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,ae.jsx)("ul",{className:nt.quickReplies,children:a.map(p=>(0,ae.jsx)("li",{className:nt.quickReply,children:p.title},p.title))})]})}),(0,ae.jsxs)(O.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,ae.jsx)(O.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,u)=>(0,ae.jsx)(O.DropdownItem,{index:u,label:p.title,onClick:c},p.title))}),(0,ae.jsx)(O.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Cu=Ef;var Bi=require("react/jsx-runtime"),wu=()=>(0,Bi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Bi.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 ku=require("react-redux");var Tu=require("react");var ge=require("react/jsx-runtime"),kf=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var d;let s=t.text||t.url||t.message,r=xs(s),i=E(Nt),a=b("showImages"),l=b("fallbackImage"),c=m=>{m.preventDefault(),m.stopPropagation(),n(s)},p=m=>{m.preventDefault(),m.stopPropagation(),o(t)},u=(0,Tu.useCallback)(m=>{window.open(r,"_blank"),m.stopPropagation(),m.preventDefault()},[r]);return(0,ge.jsxs)(O,{onClick:c,"data-testid":"edit-suggestion",children:[(0,ge.jsxs)(H,{children:[a&&t.image&&(0,ge.jsx)(H.Image,{src:Qs(t,"small",l||void 0),title:t.title}),(0,ge.jsxs)(H.Content,{children:[t.title&&(0,ge.jsx)(H.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&(0,ge.jsx)(O.Labels,{labels:t.searchKeywords}),(0,ge.jsx)(H.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,ge.jsxs)(O.Actions,{children:[r&&(0,ge.jsx)(O.ActionButton,{onClick:u,label:i("visitUrl")}),(0,ge.jsx)(O.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,ge.jsx)(O.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Eu=kf;var fn=require("react/jsx-runtime"),Rf=({contentType:t,lines:e,suggestions:o})=>{let n=_e(),s=(0,ku.useSelector)(po),r=a=>{n.send(si,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Ge,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,fn.jsx)(fn.Fragment,{children:o.map(a=>(0,fn.jsx)(Eu,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Ru=Rf;var Fi={};G(Fi,{enUS:()=>If,nlNL:()=>Pf});var If={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},Pf={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Iu={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 Ki=require("react/jsx-runtime"),Pu=()=>(0,Ki.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ki.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 Ui=require("react/jsx-runtime"),Au=()=>(0,Ui.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ui.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var R=require("react/jsx-runtime"),nr=(t,e)=>{let o=(0,W.useSelector)(Re);(0,Mu.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},Af=()=>{let t=E(Fi),e=(0,W.useDispatch)(),o=b("isEmbedded"),n=S("Widget",Iu),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=(0,W.useSelector)(xo),u=(0,W.useSelector)(Ns),d=(0,W.useSelector)(qp),m=(0,W.useSelector)(As),f=(0,W.useSelector)(Xp),g=(0,W.useSelector)(On),v=(0,W.useSelector)(Zt),T=(0,W.useSelector)(Re),h=(0,W.useSelector)(Mn),y=(0,W.useSelector)(au),x=(0,W.useSelector)(po),C=_e(),j=(0,W.useSelector)($l),F=(0,W.useSelector)(nu("/admin/personal-collection")),le=b("adminUrl");if(nr(()=>(e(gn(h)),e(eu(h)),()=>{e(tu(h))}),[e,v,r,h]),nr(()=>(e(ot(h)),e(Vp(h)),()=>{e(Wp(h))}),[e,v,s,h]),nr(()=>{u.forEach(({type:I})=>{e(I==="entities"?Pe():Ve(I))})},[e,v,g,p]),nr(()=>(e(Ai()),()=>{e(ru())}),[e,v,i,g]),v===!1)return(0,R.jsx)("div",{className:n.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("notSupported")})})},"supported");if(T===!1)return(0,R.jsx)("div",{className:n.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Fs,{isEmbedded:o,loginUrl:le})})},"login");if(!p||!h||T===null||j||y)return(0,R.jsx)("div",{className:n.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("waiting")})})},"waiting");let K=c||a||l||F;return(0,R.jsx)("div",{className:(0,Lu.default)(n.root),"data-testid":"widget",children:(0,R.jsxs)(An,{className:n.sectionList,children:[K&&(0,R.jsx)(it,{title:t("actions"),type:"shortcuts",children:(0,R.jsxs)("div",{className:n.shortcutList,children:[c&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-search",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(lo,{}),t("linkSearch")]}),a&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-summary",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(Au,{}),t("linkSummary")]}),l&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(Pu,{}),t("linkKnowledgeSearch")]}),F&&(0,R.jsxs)("a",{className:n.shortcut,target:"_blank",href:F,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[(0,R.jsx)(wu,{}),t("linkPersonalcollection")]})]})}),r&&f.length>0&&(0,R.jsx)(it,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(Se,{withDivider:!0,children:f.map(I=>(0,R.jsx)(Cu,{suggestion:I},I.text))})}),s&&d.length>0&&(0,R.jsx)(it,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)(Su,{})})}),u.map(({type:I,title:D,amount:oe,lines:gr})=>{var Tt;switch(I){case"entities":return m&&m.length>0&&(0,R.jsx)(it,{type:I,title:D,"data-testid":`type-${I}`,children:(0,R.jsx)(xu,{entities:m})},I);default:return((Tt=x[I])==null?void 0:Tt.fetchState)==="done"&&x[I].suggestions.length>0&&(0,R.jsx)(it,{type:I,title:D,"data-testid":`type-${I}`,children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)(Ru,{lines:gr,contentType:I,suggestions:x[I].suggestions.slice(0,oe)||[]})})},I)}})]})})},Ou=Af;function Io(t){let e=new Range;return e.selectNodeContents(t),e}function Nu(t,e,o){try{return wt(t,e,o),!0}catch{return!1}}function sr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function rr(t){return"tagName"in t&&t.tagName==="BR"}var hn=/[\u200B-\u200D\uFEFF]/g;function wt(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(l))return c;for(let d=0;d<=l.length;d++)if(u.test(l[d])||p++,p===c)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(hn,""),u=s+p.length,d=e>=s&&e<=u,m=o>=s&&o<=u;if(d){let f=i(c,e-s);f===0&&!m?n.setStartBefore(l):n.setStart(l,f)}m&&(n.setEnd(l,i(c,o-s)),r=!0),s=u;break}case Node.ELEMENT_NODE:{if(rr(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;sr(l)&&c&&!sr(c)&&!rr(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function yn(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(u){let d=u===o,m=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let f=u.textContent;d&&(a=c+f.substring(0,n).replace(hn,"").length),m&&(l=c+f.substring(0,r).replace(hn,"").length),c+=f.replace(hn,"").length;break}case Node.ELEMENT_NODE:{let f=u.nextSibling===null;rr(u)&&!f&&c++;for(let g=0;g<u.childNodes.length;g++){let v=d&&g===n,T=m&&g===r;if(v&&(a=c),T&&(l=c),l!==void 0||((!v||!i)&&p(u.childNodes[g]),m&&g===r-1&&(l=c),l!==void 0))break}!m&&sr(u)&&!f&&c++,m&&(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 Sn(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,u=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let d=p?n:0,m=u?r:void 0,f=c.textContent.replace(hn,"");d===0&&m===void 0?a+=f:a+=f.substring(d,m);break}case Node.ELEMENT_NODE:{let d=c.nextSibling===null;i===0&&rr(c)&&!d&&(a+=`
|
|
4
|
+
`);for(let m=p?n:0;m<(u?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[m]),i!==1);m++);!u&&i===0&&sr(c)&&!d&&(a+=`
|
|
5
|
+
`);break}default:break}u&&i++}return l(t),a}function Du(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var jt=class extends ze{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),Sn(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!Du(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Du(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return yn(this.element,e);let o=this.lastKnownSelection;if(o&&Nu(this.element,o.start,o.end))return o;let n=Io(this.element);return n.collapse(!1),yn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return Sn(this.element,wt(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var zi=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},ji=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=this.createIframe(),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];createIframe(){let e=`deepdesk-iframe-${this.name}`,o=document.getElementById(e);if(o)return o;let n=document.createElement("iframe"),s=`${this.targetOrigin}/v2/widget/liveengage/channel.html`,r=new URLSearchParams({channel:this.name,host:window.location.origin});return this.options.debug&&r.set("debug","1"),n.style.position="absolute",n.style.left="-999em",n.style.width="0px",n.style.height="0px",n.tabIndex=-1,n.id=e,n.title=`iframe-${this.name}`,n.src=`${s}?${r.toString()}`,n}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},qi=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),k.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new ji(e,this.deepdeskUrl,{debug:!0}):new zi(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(k.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var s,r,i;if(!this.sessionId)return;k.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(r=(s=this.eventMap)[e])==null||r.call(s,o),(i=this.channel)==null||i.postMessage({...n,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Hu=qi;var Po=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Vi=t=>new Promise(e=>{setTimeout(e,t)});var Ao=class extends Po{name="ClientError"},Wi=class extends Po{name="ServerError"},Le=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:u=!0,retryOnError:d=x=>x instanceof TypeError,retryOnResponse:m=x=>x.status>=500,version:f="v1",...g}=o,v={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(v.headers={...v.headers,"X-CSRFToken":this.csrfToken}),typeof f=="string"&&(v.headers={...v.headers,"X-Deepdesk-API-Version":f});let T=c,h=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let y=async()=>(T--,a(i,v).then(async x=>m(x)&&!r.isAborted&&T>0?(await Vi(p),y()):x.status===401&&u===!0&&h===!1?(h=!0,await this.refreshToken(),y()):x).catch(async x=>{if(d(x)&&!r.isAborted&&T>0)return await Vi(p),y();throw x}));y().then(x=>x.json().catch(()=>null).then(C=>{x.status>=500?s(new Wi("Server Error",C)):x.status===401?s(new Ao("Unauthorized",C)):x.status===403?s(new Ao("Forbidden",C)):x.status===404?s(new Ao("Not Found",C)):x.status>=400&&s(new Ao("Bad Request",C)),delete this.latestRequestByUrl[i],n(C)})).catch(x=>{s(x)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var Lf;(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||={})})(Lf||={});function ir(t){return{...M(t),tags:t.tags}}var st=class t{constructor(e,o={}){this.options=o;this.client=new Le(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),k.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...U(e),tags:e.tags},{version:"v2"});return ir(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return M(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return M(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return M(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),k.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return ir(r)}async isConversationSupported(e,o={}){k.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=U(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return ir(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...U(s),tags:s.tags})),{version:"v2"})).map(s=>ir(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",U({...r,...s,data:n,name:e}),{version:"v2"})}async sendEventV1(e,o){let n=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[r,i])=>({...s,[r]:i}),{});return this.client.post("/api/events",{event:e,data:U({...o,...n})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(n=>n.text)})).entities}async getSummary(e,o={}){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source)},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw k.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",U(o),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,o={},n){return n==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${n}`,U(o),{abortLatest:!0})).map(r=>({...M(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,o){return(await this.client.post(`/api/conversations/${e}/autocomplete`,U(o),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let o=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return M(o).map(n=>({...n,text:n.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let o=await this.client.post("/api/style-suggestions",U(e),{abortLatest:!0});return M(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,U(e),{version:"v2"});return M(o)}async knowledgeAssist(e,o,n){let s=await this.client.post("/api/knowledge-search/search",U({question:e.question,promptInstruction:e.promptInstruction,profile:n,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return M(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return M(o)}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 M(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(ha);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&k.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var vn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Zr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,M(s))}catch{k.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var Mf;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Mf||={});var _n=class{constructor(e,o={}){this.apiUrl=e;this.client=new Le(e,o)}client;streams={};logger=k;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return M(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,U(o));return M(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,U(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return M(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",U(e));return M(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new vn(`${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 Fu=require("@reduxjs/toolkit");var Bu={startTime:null,stopTime:null},Ku=(0,Fu.createSlice)({name:"handlingTime",initialState:Bu,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(P,()=>Bu)}}),{handlingTimeStart:Uu,handlingTimeStop:ar,handlingTimeReset:zu}=Ku.actions,ju=Ku.reducer;var qu=(t={})=>{let e={onAuthError:fo(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var cr=require("@reduxjs/toolkit");var lr={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var qt=(0,cr.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 lr.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Of=(0,cr.createSlice)({name:"styleSuggestions",initialState:lr,reducers:{},extraReducers:t=>{t.addCase(qt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(qt.rejected,e=>{e.fetchState="error"}).addCase(qt.fulfilled,(e,o)=>{e.fetchState="done",lt(e.list,o.payload)||(e.list=o.payload)}).addCase(It,e=>{e.list=lr.list}).addCase(P,()=>lr)}}),Vu=Of.reducer;var Wu=(t={})=>{let e,o=!0,n={getStyleSuggestions:qt,debounce:500,...t};return s=>r=>i=>{var m;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(!((m=c.conversation.current)==null?void 0:m.id)||!p)return l;let{text:d}=c.input;return d===a&&!o||(clearTimeout(e),d==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:d}))},t.debounce)),l}};function Nf(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Gu=(t={})=>{let e={getTextSuggestions:Ve,getAutocompleteSuggestions:Qo,debounce:200,check:Co,...t},o;return n=>s=>r=>{var g;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,u=(g=l.conversation.current)==null?void 0:g.id,d=r.type===Ts.toString();if(!u||!c&&!p)return a;let{input:{userCommitted:m}}=l;return Nf(m,i)&&!d||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=Jt(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},d?0:e.debounce)),a}};var $u=qt.fulfilled.toString();function Df(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 Xu=t=>e=>o=>n=>{var c;if(n.type!==$u){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=Df(s,i);n.type===$u&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Hf=(0,pr.combineReducers)({activeSuggestion:rc,answer:Gc,auth:vc,autoflows:Gp,conversation:wa,contentTypes:Ac,customMessages:ou,exchangeToken:iu,entities:Nc,handlingTime:ju,info:Al,input:Cr.reducer,overlayInput:ne.reducer,settings:_a,profile:Qc,search:Hl,summary:Uc,styleSuggestions:Vu,ui:pc,textSuggestions:Yl});function Qu(t){return(0,pr.configureStore)({reducer:Hf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),qu(),Gu({debounce:200}),Wu({debounce:500}),Xu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Bf=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Ff=t=>e=>o=>n=>{var a;let s=e.getState(),r=vr("inlineSuggestions")(s);switch(n.type){case We.toString():{let l=Gl(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 fo.toString():{!n.payload&&t.emit("logout",void 0);break}case Te.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:Bf(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Un.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 Do.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Vn.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 Pe.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case $e.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case $.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case zn.toString():t.handleKeyDown(n.payload);break;case It.toString():t.logSendMessage(n.payload);break;case jn.toString():t.logSendEditSuggestionMessage(n.payload);break;case qn.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case It.toString():t.handleAfterSendMessage(n.payload);break;case Zo.toString():t.onUpdateShowTabHint(n.payload);break;case ar.toString():t.logHandlingTime();break;case Te.toString():{r&&(e.dispatch(Ne([])),e.dispatch(ut()));break}case Ne.toString():{r&&n.payload.length>0&&e.dispatch(pt(0));break}default:break}return i},Zu=Ff;function Gi(t){return t.toISOString().replace("T"," ").replace("Z","")}function Ju(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:Gi(o),timeStop:Gi(n)}}function $i(t,e,o){var F,le,K;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:u,cuts:d,deletions:m,textSuggestions:f,offeredTextSuggestions:g}}=e[t],v=n.length,h=f.reduce((I,{text:D,searchTerm:oe})=>I+D.length-(oe?oe.length:0),0),y=c??Date.now(),x=(Date.now()-y)/1e3+(p||0),C=s/x,j=f.reduce((I,{searchTerm:D})=>I+(D?D.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:u,cuts:d,deletions:m,lenTextTyped:s+j,lenTextTotal:v,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:x,charsPerSecond:C,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:g.filter(I=>I.source==="gpt").length}],agentId:(F=e.info.agentInfo)==null?void 0:F.agentId,agentName:(le=e.info.agentInfo)==null?void 0:le.agentName,agentEmail:(K=e.info.agentInfo)==null?void 0:K.agentEmail}}function Yu(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?Yu(n,e):null}function ed(t,e){return Yu(t,e)}function td(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Kf(t){return typeof t=="object"&&t!==null&&"tagName"in t}function ur(t){return Kf(t)&&(vt(t)||ls(t))}var od=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{k.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Uf(t){return t.offsetParent!==null}function nd(t){if(!Uf(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 dr(t,e,o=100){let n=nd(t);e({isVisible:n});let s=setInterval(()=>{let r=nd(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var Z=require("react/jsx-runtime"),sd=od("showTabHint",!0),xn=class t{static version="10.5.0";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new st(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Zu({emit:(u,d,m)=>this.emit(u,d,m),handleAfterSendMessage:u=>this.handleAfterSendMessage(u),handleInputChanged:u=>this.handleInputChanged(u),handleKeyDown:u=>this.handleKeyDown(u),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:u=>this.logSendMessage(u),logSendEditSuggestionMessage:u=>this.logSendEditMessage(u),onUpdateShowTabHint:u=>sd.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new _n(o)}),this.store=Qu(p),this.broadcastEvents=new Hu({debug:!0,deepdeskUrl:c,eventMap:_c(this.store),createCustomChannel:l}),this.store.dispatch(No),this.store.dispatch(Zo(sd.value())),this.store.dispatch(No({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(k.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(k.warn("Profile has not been loaded (yet)"),!0):(k.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(fo(null)),this.store.dispatch(ht()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();Re(n)&&gc(n)!=="loading"&&e()});this.unmountHandlers.push(()=>{o()})})}isLoggedIn(){return this.deepdeskApi.isLoggedIn()}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){k.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(xr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Nn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Dn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(br(e))).payload}async postMessages(e){return(await this.store.dispatch(Bn(e))).payload}async updateConversation(e){return(await this.store.dispatch(Hn(e))).payload}resetConversation(){this.store.dispatch(P()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch($e());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(No(e))}setVisitorInfo(e){this.store.dispatch(Pl(e))}async setAgentInfo(e){await this.store.dispatch(Wo(e))}async setAgentSettings(e){await this.store.dispatch(Jr(e))}async getAgentSettings(){return(await this.store.dispatch(Yr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(Ts()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(qn(e))}notifyKeyDown(e){this.store.dispatch(zn(e))}notifyPaste(e,o){this.store.dispatch(Ha({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Na(e))}notifyExternalSuggestion(e){this.store.dispatch(Te(e)),this.store.dispatch(ut())}notifyEditSuggestion(e){this.store.dispatch(Zl(e.contentType,e.suggestions)),this.store.dispatch(We({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(ft({collapse:!1})),this.inputMediator&&this.store.dispatch(Ia({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Ne([])))}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(Da(Kn(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(La()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Oa());let{selectedSuggestionIndex:u}=this.state.input;e.preventDefault(),!i&&(u===-1?this.store.dispatch(Do()):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(pt(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(pt(-1)),this.store.dispatch(Do()),e.preventDefault()):o||(this.store.dispatch(ft({collapse:!0})),this.store.dispatch(lc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:u}=this.state.input,d=u.text.substring(0,u.selection.end),{tabCompletionSuggestion:m}=this.state.input;this.store.dispatch(Zo(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&m&&m.text.startsWith(d)&&(this.store.dispatch(Te({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(ut())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ba()),this.store.dispatch(Ne([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(Uu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(ar()))}logSendMessage(e){let o=$i("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=$i("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Aa(this.state.overlayInput.metrics))}logHandlingTime(){let e=Ju(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(zu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(ut()),this.store.dispatch(It(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(Te({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=Lt(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,Me.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]=Lt(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,Me.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 At(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,Me.unmountComponentAtNode)(s),s.remove()}),s}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!ur(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:u,detectSubmit:d,insertLink:m,inputMediator:f,closestScrollSelector:g,appendOverlayTo:v,inlineSuggestions:T}=o;if(this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:m,isEmbedded:u,inlineSuggestions:T}),o.automaticHandlingTime&&this.setupHandlingTime(e),At(e),this.inputMediator=f||(vt(e)?new je(e):new jt(e)),this.inputMediator.on("change",({plainText:y})=>{this.notifyInputChanged(y)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Fa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",y=>{this.notifyKeyDown(y)}),this.inputMediator.on("paste",({pastedText:y,selectionText:x})=>{this.notifyPaste(y,x)}),this.inputMediator.on("cut",({selectionText:y})=>{this.notifyCut(y)}),T){if(vt(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let y=this.createInlineContainer(e,"deepdesk-caret");(0,Me.render)((0,Z.jsx)(ko,{store:this.store,customStyles:n,children:(0,Z.jsx)(go,{broadcastEvents:this.broadcastEvents,children:(0,Z.jsx)(pp,{})})}),y),this.inputMediator.on("caret",x=>{this.store.dispatch(Ne([])),x?(y.style.display="block",y.style.top=`${x.top}px`,y.style.left=`${x.left}px`):y.style.display="none"})}else{let y=g&&ed(e,g)||void 0,x=this.overlayContainerFactory("deepdesk-tab-completion",y||e,{appendTo:v,closestScrollElement:y,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",y||e,{appendTo:v},n==null?void 0:n.suggestionsRootNode);(0,Me.render)((0,Z.jsx)(ko,{store:this.store,customStyles:n,children:(0,Z.jsx)(go,{broadcastEvents:this.broadcastEvents,children:(0,Z.jsx)(Up,{inputElement:e})})}),x),(0,Me.render)((0,Z.jsx)(ko,{store:this.store,customStyles:n,children:(0,Z.jsx)(go,{broadcastEvents:this.broadcastEvents,children:(0,Z.jsx)(vp,{})})}),C)}(0,Me.render)((0,Z.jsx)(ko,{store:this.store,customStyles:n,children:(0,Z.jsx)(go,{broadcastEvents:this.broadcastEvents,children:(0,Z.jsx)(tp,{})})}),this.createContainer("deepdesk-overlays"));let h;this.inputMediator.on("selection",y=>{clearTimeout(h),y===null?h=setTimeout(()=>{y!==null&&this.store.dispatch(wr(y))},500):this.store.dispatch(wr(y))}),this.inputMediator.on("disabled",()=>{var y;(y=this.inputMediator)==null||y.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(uo(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(uo(!0))),this.store.dispatch(Pa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var y;this.refresh(),this.broadcastEvents.setSessionId((y=this.state.conversation.current)==null?void 0:y.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&k.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,showPersonalCollectionLink:r,isEmbedded:i}=o;this.widgetRoot=e,this.configure({showImages:s,showPersonalCollectionLink:r,isEmbedded:i}),(0,Me.render)((0,Z.jsx)(ko,{store:this.store,customStyles:n,children:(0,Z.jsx)(go,{broadcastEvents:this.broadcastEvents,children:(0,Z.jsx)(Ou,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Me.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=dr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){td(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(ln());let e=xo(this.state);e&&this.store.dispatch(No({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeAssistForAgents,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(k.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;k.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=Ns(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Pe()):this.store.dispatch(Ve(n))})}catch(n){this.handleError(n)}}};async function rd(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 id(t,e,o={}){let n=o.replace?wt(t,o.replace.start,o.replace.end):Io(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(`
|
|
6
|
+
`).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}):n.insertNode(document.createTextNode(e))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?wt(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}async function ad(t,e){let o;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let n=()=>{let r=(t.ownerDocument.defaultView??window).getSelection();if(!r)return;let i=r.getRangeAt(0);i&&(i.deleteContents(),o=document.createElement("span"),i.insertNode(o),e.split(`
|
|
7
|
+
`).reverse().forEach((a,l)=>{l>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(a))}),i.collapse(!1))};return Promise.resolve(n()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!o)try{o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}function ld(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function cd(t,e,o){await new st(t).authenticateWithKey(e,o)}async function pd(t){let o=await new Le(t).get("/platform/config/",{version:null});return M(o)}async function zf(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 ud(t,e){let o=await zf(e),n=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[o]}),t.dispatchEvent(n)}finally{Object.hasOwn(t,"files")&&delete t.files}}0&&(module.exports={Card,ContentEditableInput,DeepdeskAPI,DeepdeskSDK,HTTPClient,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createFullRange,createOverlayContainer,createRangeFromOffsets,escapeHTML,fetchPlatformConfig,formatTextMarkup,getRangeOffsets,getRangeText,insertCKEditor,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});
|