@deepdesk/deepdesk-sdk 11.3.0 → 11.3.1-beta.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/dist/index.cjs.js +6 -6
- package/dist/index.esm.js +6 -6
- package/dist/index.iife.js +12 -12
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var Dp=Object.create;var bn=Object.defineProperty;var Hp=Object.getOwnPropertyDescriptor;var Fp=Object.getOwnPropertyNames;var Bp=Object.getPrototypeOf,Kp=Object.prototype.hasOwnProperty;var Z=(t,e)=>{for(var o in e)bn(t,o,{get:e[o],enumerable:!0})},qi=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Fp(e))!Kp.call(t,s)&&s!==o&&bn(t,s,{get:()=>e[s],enumerable:!(n=Hp(e,s))||n.enumerable});return t};var T=(t,e,o)=>(o=t!=null?Dp(Bp(t)):{},qi(e||!t||!t.__esModule?bn(o,"default",{value:t,enumerable:!0}):o,t)),Up=t=>qi(bn({},"__esModule",{value:!0}),t);var Yh={};Z(Yh,{Card:()=>D,ContentEditableInput:()=>jt,DeepdeskAPI:()=>rt,DeepdeskSDK:()=>xn,HTTPClient:()=>Ae,InputMediator:()=>st,InputType:()=>Rt,KeyboardHint:()=>kn,Label:()=>Rn,Locale:()=>Lo,Section:()=>Ue,SectionList:()=>Pn,Sources:()=>ze,Suggestion:()=>M,SuggestionList:()=>le,TextAreaInput:()=>qt,ToggleButton:()=>kt,attachFile:()=>Ap,authenticateWithKey:()=>Ip,createFullRange:()=>To,createOverlayContainer:()=>Sn,createRangeFromOffsets:()=>bt,escapeHTML:()=>ro,fetchPlatformConfig:()=>Lp,formatTextMarkup:()=>Pp,getRangeOffsets:()=>fn,getRangeText:()=>hn,insertCKEditor:()=>Rp,isHTML:()=>us,isSupportedInputElement:()=>dr,updateContentEditable:()=>Ep,updateTextArea:()=>Tp,useStyles:()=>h,waitForElementVisibilityChange:()=>mr});module.exports=Up(Yh);var hr=T(require("classnames")),fe=T(require("react"));var Cn=T(require("react")),Xi=T(require("classnames")),Io=Cn.default.createContext({});function h(t,e){let{debug:o,...n}=(0,Cn.useContext)(Io),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let c=s[i];return{...r,[i]:(0,Xi.default)(a,c,o?`${t}__${i}`:!1)}},{}):e}var Zi={root:"qo"};var Ct=require("react/jsx-runtime"),wn=()=>(0,Ct.jsxs)("svg",{className:Zi.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Ct.jsx)("defs",{children:(0,Ct.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Ct.jsx)("title",{children:"Failed loading image"}),(0,Ct.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 fr={root:"Co",imageWrapper:"L",image:"So",content:"m",title:"Eo",contentIsCropped:"Go",lineClamp:"No"};var wt=require("react/jsx-runtime"),Tn=(0,fe.createContext)(fr),$p=({title:t,src:e})=>{let o=(0,fe.useContext)(Tn),[n,s]=(0,fe.useState)(!1);return(0,fe.useEffect)(()=>{s(!1)},[e]),(0,wt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,wt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,wt.jsx)(wn,{})})},Wp=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,fe.useContext)(Tn);return(0,wt.jsx)("div",{className:(0,hr.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Gp=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,fe.useContext)(Tn);return fe.default.createElement(t,{className:(0,hr.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},En=({children:t})=>{let e=h("Card",fr);return(0,wt.jsx)("div",{className:e.root,children:(0,wt.jsx)(Tn.Provider,{value:e,children:t})})};En.Image=$p;En.Content=Wp;En.Title=Gp;var D=En;var Ji=T(require("classnames"));var Qi={root:"M"};var Yi=require("react/jsx-runtime");var qp={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Xp=({className:t,keyCode:e,...o})=>{let n=h("KeyboardHint",Qi);return(0,Yi.jsx)("span",{"data-key":qp[e],className:(0,Ji.default)(t,n.root),...o})},kn=Xp;var ta=T(require("classnames"));var ea={root:"Ao"};var oa=require("react/jsx-runtime"),Qp=({className:t,children:e,...o})=>{let n=h("Label",ea);return(0,oa.jsx)("span",{...o,className:(0,ta.default)(t,n.root),children:e})},Rn=Qp;var na={root:"Fo",subTitleContainer:"Ho",subtitle:"Lo",suggestions:"Mo"};var Zt=require("react/jsx-runtime"),Yp=({title:t,children:e,type:o,...n})=>{let s=h("Section",na);return(0,Zt.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,Zt.jsx)("div",{className:s.subTitleContainer,children:(0,Zt.jsx)("span",{className:s.subtitle,children:t})}),(0,Zt.jsx)("div",{className:s.suggestions,children:e})]})},Ue=Yp;var ra=T(require("classnames")),ia=T(require("react"));var sa={root:"Ro"};var aa=require("react/jsx-runtime"),tm=ia.default.forwardRef(({className:t,children:e},o)=>{let n=h("SectionList",sa);return(0,aa.jsx)("div",{ref:o,className:(0,ra.default)(n.root,t),children:e})}),Pn=tm;var Qt=T(require("classnames")),Y=T(require("react"));var yr={fadein:"R",root:"e",isClickable:"T",isSelected:"To",actions:"U",actionsIsFixed:"Uo",actionButton:"t",dropdownList:"B",dropdownButton:"D",dropdownItem:"I",dropdownItemButton:"O",actionButtonIsPrimary:"Bo",actionButtonIsDisabled:"Do",labels:"Io",label:"Oo",iconButtons:"Xo",iconButton:"n"};var se=require("react/jsx-runtime"),Tt=(0,Y.createContext)(yr),nm=({fixed:t,children:e,...o})=>{let n=(0,Y.useContext)(Tt);return(0,se.jsx)("div",{...o,className:(0,Qt.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})};function la(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type===ca}var ca=({className:t,icon:e,title:o,...n})=>{let s=(0,Y.useContext)(Tt);return(0,se.jsx)("button",{type:"button",className:(0,Qt.default)(s.iconButton,t),title:o,"aria-label":o,...n,children:e})},sm=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,Y.useContext)(Tt);return(0,se.jsxs)("div",{className:(0,Qt.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,se.jsx)("ul",{className:r.dropdownList,children:s})]})},rm=({index:t,label:e,onClick:o})=>{let n=(0,Y.useContext)(Tt);return(0,se.jsx)("li",{className:n.dropdownItem,children:(0,se.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},im=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,Y.useContext)(Tt);return(0,se.jsx)("button",{type:"button",className:(0,Qt.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},am=({labels:t})=>{let e=(0,Y.useContext)(Tt);return(0,se.jsx)("div",{className:e.labels,children:t.map(o=>(0,se.jsx)("span",{className:e.label,children:o},o))})},Et=Y.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=h("Suggestion",yr),c=(0,Y.useCallback)(u=>{u.preventDefault(),o&&o(u)},[o]),l=Y.default.Children.toArray(n).filter(la),d=Y.default.Children.toArray(n).filter(u=>!la(u));return(0,se.jsx)(s,{...r,ref:i,className:(0,Qt.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:c,children:(0,se.jsxs)(Tt.Provider,{value:a,children:[d,(0,se.jsx)("div",{className:a.iconButtons,children:l})]})})});Et.Labels=am;Et.Actions=nm;Et.ActionButton=im;Et.DropdownButton=sm;Et.DropdownItem=rm;Et.IconButton=ca;var M=Et;var ua=T(require("classnames"));var da={root:"Jo",isWithDivider:"Ko"};var pa=require("react/jsx-runtime"),cm=({withDivider:t,children:e})=>{let o=h("SuggestionList",da);return(0,pa.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,ua.default)(o.root,{[o.isWithDivider]:t}),children:e})},le=cm;var ga=T(require("classnames"));var ma={root:"u",isCollapsed:"X"};var In=require("react/jsx-runtime"),um=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=h("ToggleButton",ma);return(0,In.jsx)("button",{type:"button",className:(0,ga.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"})})})},kt=um;var fa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,Ln=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ha=/x-deepdesk-(([a-z0-9\-_])+-version)/,ze=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(ze||{}),Rt=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(Rt||{});var be=require("react-dom");var Oc=require("react");var ya=require("@reduxjs/toolkit"),va=require("react-redux");var Lo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Lo||{});var pm={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,floatingMenu:!1,adminUrl:void 0,productName:"Deepdesk"},Sa=(0,ya.createSlice)({name:"settings",initialState:pm,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:An}=Sa.actions,vr=t=>e=>e.settings[t],b=t=>(0,va.useSelector)(vr(t)),xa=Sa.reducer;var Fr=require("react-redux");var Jt=require("@reduxjs/toolkit");var mm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ee=t=>t.auth.isLoggedIn,ba=t=>t.auth.loginFetchState,Ca=t=>t.auth.verifyFetchState,wa=t=>t.auth.showLoginOverlay,Ve=(0,Jt.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Ta=(0,Jt.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Ao=(0,Jt.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Ea=(0,Jt.createSlice)({name:"auth",initialState:mm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Ve.pending,e=>{e.loginFetchState="loading"}),t.addCase(Ve.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Ve.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Ao.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Ao.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Ao.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Yt,setShowLoginOverlay:ka}=Ea.actions,Ra=Ea.reducer;var $e=require("@reduxjs/toolkit"),Ma=require("diff"),Na=require("react-redux");function Pa(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function it(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)=>it(r,e[i],o-1)):Pa(t)&&Pa(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>it(t[i],e[i],o-1)):!1}function gm(t){return Math.max(...t.map(e=>e.length))}function fm(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 Ia(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<gm(n);s++){let r=fm(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 hm=2;function Sr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Ia(t,hm);return o&&o.text!==e?o:t[0]}var Ce=require("@reduxjs/toolkit");var ym={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},w=ym;var La={current:null,isSupported:null},N=(0,Ce.createAction)("resetConversation"),eo=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Mn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},to=t=>t.conversation.isSupported,xr=(0,Ce.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Nn=(0,Ce.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),On=(0,Ce.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),_n=(0,Ce.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Mn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),br=(0,Ce.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:c}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:c})})}),Dn=(0,Ce.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Mn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),vm=[Nn.rejected,On.rejected,_n.rejected,Dn.rejected].map(t=>t==null?void 0:t.toString()),Sm=(0,Ce.createSlice)({name:"conversation",initialState:La,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(On.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(_n.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)=>{e.current&&(e.current.messages=o.payload)}).addCase(N,()=>La).addMatcher(e=>vm.includes(e.type),(e,o)=>{var n;throw w.info("Conversation action rejected",o.type,((n=o.error)==null?void 0:n.message)||"No message"),new Error(o.error.message)})}}),Aa=Sm.reducer;var at={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 Oa(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 Fn=(0,$e.createAction)("input/replaceText"),Bn=(0,$e.createAction)("input/keyDown"),Pt=(0,$e.createAction)("input/sendMessage"),Kn=(0,$e.createAction)("input/uiInputChange"),Un=(0,$e.createAction)("input/applyImageSuggestion"),Q=(0,$e.createAction)("input/sendEvent");function Hn(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:c},eventMetrics:{inputType:l},replace:d}=t.stagedSuggestion,u=o==="search"||o==="personal-collection-search",p=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(u||d==="selection")&&(p=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(p=c),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:p,source:o,abVariant:n,abTestName:s,inputType:l,sourceText:i,trainingJobs:r||[],searchTerm:u?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var _a=(0,$e.createSlice)({name:"input",initialState:at,reducers:{initialInput(t,e){let{text:o,selection:n,html:s}=e.payload;t.text=o,t.selection.start=(n==null?void 0:n.start)??o.length,t.selection.end=(n==null?void 0:n.end)??o.length,t.userCommitted.text=o,t.userCommitted.selection.start=(n==null?void 0:n.start)??o.length,t.userCommitted.selection.end=(n==null?void 0:n.end)??o.length,t.html=s||null},reset(t){Object.assign(t,{...at,selection:t.selection})},resetToCommitted(t){t.text=t.userCommitted.text,t.selection=t.userCommitted.selection,t.stagedSuggestion=null,t.tabCompletionSuggestion=Sr(t.textSuggestions,t.userCommitted.text)},changeSelection(t,e){e.payload&&(it(t.selection,e.payload)||(t.selection=e.payload,t.userCommitted.selection=t.selection,t.stagedSuggestion&&Hn(t)))},platformInput(t,e){let{text:o,html:n,selection:s}=e.payload;s&&(t.selection.start=s.start,t.selection.end=s.end),t.text=o,t.html=n||null},userInput(t,e){var r,i,a,c;if(t.previousKeyDownEvent){let{key:l,shiftKey:d,ctrlKey:u,metaKey:p,altKey:m}=t.previousKeyDownEvent;switch(l){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=t,{text:f}=e.payload,y=(0,Ma.diffChars)(g,f);g.length-f.length>1&&t.metrics.deletions.push(...y.filter(P=>P.removed).map(P=>P.value)),t.metrics.numCharsDeleted+=g.length-f.length;break}case"C":case"V":case"X":if(!u&&!p){t.metrics.numCharsTyped+=1;let g=((r=t.selection)==null?void 0:r.start)!==void 0&&((i=t.selection)==null?void 0:i.end)!==void 0?t.text.substring(t.selection.start,t.selection.end):null;g&&g.length>0&&(t.metrics.numCharsDeleted+=g.length,t.metrics.deletions.push(g))}break;case"Shift":break;default:if(!u&&!p&&!m){t.metrics.numCharsTyped+=1;let g=((a=t.selection)==null?void 0:a.start)!==void 0&&((c=t.selection)==null?void 0:c.end)!==void 0?t.text.substring(t.selection.start,t.selection.end):null;g&&g.length>0&&(t.metrics.numCharsDeleted+=g.length,t.metrics.deletions.push(g))}}}!t.metrics.agentStartedTypingTimestamp&&e.payload.text!==t.text&&(t.metrics.agentStartedTypingTimestamp=Date.now()),e.payload.text===""&&(t.metrics=at.metrics,t.textSuggestions=[],t.stagedSuggestion=null),t.text!==e.payload.text&&Hn(t);let{text:o,html:n,selection:s}=e.payload;s&&(t.selection.start=s.start,t.selection.end=s.end,t.userCommitted.selection.start=s.start,t.userCommitted.selection.end=s.end),t.text=o,t.html=n||null,t.userCommitted.text=o,t.previousKeyDownEvent=null},stageSuggestion(t,e){let{text:o}=e.payload;switch(t.stagedSuggestion=e.payload,t.tabCompletionSuggestion=void 0,e.payload.replace){case"selection":t.text=`${t.text.slice(0,t.selection.start)}${o}${t.text.slice(t.selection.end)}`,t.selection.end=t.selection.start+o.length,t.selection.start+=o.length;break;case"until-selection-end":t.text=`${o}${t.text.slice(t.selection.end)}`,t.selection.start=o.length,t.selection.end=o.length;break;default:throw new Error(`Unknown replace ${e.payload.replace}`)}e.payload.eventMetrics.inputType==="tab"&&Hn(t)},commitSuggestion(t){Hn(t)},offeredTextSuggestion(t,e){let{text:o,suggestion:{source:n}}=e.payload;t.metrics.offeredTextSuggestions.find(r=>r.text===o)||t.metrics.offeredTextSuggestions.push({text:o,source:n})},registerCut(t,e){let{metrics:o}=t,n=e.payload;t.metrics={...t.metrics,numCharsCut:o.numCharsCut+n.length,cuts:[...o.cuts,n]}},registerPaste(t,e){let{metrics:o}=t,{text:n,selectionText:s}=e.payload,r=o.numCharsDeleted+(s&&s.length?s.length:0),i=s&&s.length?[...o.deletions,s]:o.deletions;t.metrics={...t.metrics,numCharsDeleted:r,deletions:i,numCharsPasted:o.numCharsPasted+n.length,numPaste:o.numPaste+1,pastes:[...o.pastes,n]}},registerKeyDown(t,e){t.previousKeyDownEvent=e.payload},nextTextSuggestionIndex(t){let e=t.textSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},previousTextSuggestionIndex(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0)return;let o=t.userCommitted.text.substring(0,t.userCommitted.selection.end),n=Sr(e.payload,o);t.tabCompletionSuggestion=n!=null&&n.text.includes(o)?n:void 0},setSelectedTextSuggestionIndex(t,e){t.selectedSuggestionIndex=e.payload},setMetrics(t,{payload:e}){t.metrics=e}},extraReducers:t=>{t.addCase(N,e=>{e.tabCompletionSuggestion=at.tabCompletionSuggestion,e.previousKeyDownEvent=at.previousKeyDownEvent,e.textSuggestions=at.textSuggestions,e.selectedSuggestionIndex=at.selectedSuggestionIndex,e.metrics=at.metrics})}}),oo=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),xm=t=>t.input.selection,Da=()=>(0,Na.useSelector)(xm),{userInput:Ha,changeSelection:Cr,initialInput:Fa,nextTextSuggestionIndex:Ba,offeredTextSuggestion:Ka,previousTextSuggestionIndex:Ua,registerCut:za,registerKeyDown:Va,registerPaste:$a,reset:Wa,resetToCommitted:Mo,platformInput:Ga,setSelectedTextSuggestionIndex:lt,setTextSuggestions:Me,stageSuggestion:Ne,commitSuggestion:We,setMetrics:ja}=_a.actions,qa=_a.reducer;var Vn=require("@reduxjs/toolkit");var no=require("@reduxjs/toolkit");function bm(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function A(t){return Array.isArray(t)?t.map(A):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[bm(o)]:A(t[o])}),{}):t}function wr(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,[wr(o)]:U(t[o])}),{}):t}var Cm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Oo=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)||""}},No=(0,no.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?A(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),A(n))}),Tr=(0,no.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}),Er=(0,no.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Xa=t=>t.info.agentInfo,Za=(0,no.createSlice)({name:"info",initialState:Cm,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(No.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(No.rejected,e=>{e.fetchState="error"}).addCase(No.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(Tr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(Er.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(N,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Qa}=Za.actions,Ja=Za.reducer;var zn={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},Ya=t=>t.search.isOpen,el=t=>t.search.page,tl=t=>t.search.list,ol=t=>t.search.aggregates;function nl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var It=(0,Vn.createAsyncThunk)("search/getAll",async(t,e)=>{var a;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(a=n.conversation.current)==null?void 0:a.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r,aggregates:i}=await o.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:Oo(n)});return{results:r.map(c=>({...c,source:`search-${c.type.toLowerCase()}`,searchTerm:t.query})),aggregates:i}}),sl=(0,Vn.createSlice)({name:"search",initialState:zn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=zn.fetchState,t.list=zn.list}},extraReducers:t=>{t.addCase(It.pending,e=>{e.fetchState="loading"}).addCase(It.rejected,(e,o)=>{e.fetchState="error",w.error(o.error)}).addCase(It.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload.results,e.aggregates=o.payload.aggregates||{}}).addCase(N,()=>zn)}}),{resetSearch:$n,setIsOpen:ce,setPage:we}=sl.actions,rl=sl.reducer;var kr="SetCues",so="ShowLoginOverlay",_o="UserLoggedIn",wm="UserLoggedOut",ct="ApplySuggestion",Rr="ApplyImageSuggestion",Tm="ShowCommandPalette",Em=t=>({[kr]:e=>{t.dispatch({...e,isBroadcasted:!0})},[Tm]:e=>{t.dispatch(ce(e.isOpen)),e.page&&t.dispatch(we(e.page))},[so]:e=>{t.dispatch(ka(e))},[_o]:()=>{t.dispatch(Ve())},[wm]:()=>{t.dispatch(Ve())},[Rr]:e=>{t.dispatch(Un({suggestion:e.suggestion}))},[ct]:e=>{t.dispatch(Ne({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(We())}}),il=Em;var Do=T(require("react")),ll=require("react/jsx-runtime"),al=Do.default.createContext(null),Lt=({broadcastEvents:t,children:e})=>{let o=Do.default.useMemo(()=>t,[]);return(0,ll.jsx)(al.Provider,{value:o,children:e})},he=()=>{let t=(0,Do.useContext)(al);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var as=T(require("classnames")),Ee=require("react"),ls=require("react-redux");var ss=require("react");var Pr=function(t,e){return Pr=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])},Pr(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");Pr(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var de=function(){return de=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},de.apply(this,arguments)};function cl(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 jn=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Te;(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"})(Te||(Te={}));var qn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(qn||(qn={}));function Ir(t){return t.type===Te.literal}function dl(t){return t.type===Te.argument}function Xn(t){return t.type===Te.number}function Zn(t){return t.type===Te.date}function Qn(t){return t.type===Te.time}function Jn(t){return t.type===Te.select}function Yn(t){return t.type===Te.plural}function ul(t){return t.type===Te.pound}function es(t){return t.type===Te.tag}function ts(t){return!!(t&&typeof t=="object"&&t.type===qn.number)}function Fo(t){return!!(t&&typeof t=="object"&&t.type===qn.dateTime)}function Lr(t){t.forEach(function(e){if(delete e.location,Jn(e)||Yn(e))for(var o in e.options)delete e.options[o].location,Lr(e.options[o].value);else Xn(e)&&ts(e.style)||(Zn(e)||Qn(e))&&Fo(e.style)?delete e.style.location:es(e)&&Lr(e.children)})}function pl(t,e){e===void 0&&(e={}),e=de({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new jn(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||Lr(o.val),o.val}function os(t,e){var o=e&&e.cache?e.cache:Am,n=e&&e.serializer?e.serializer:Lm,s=e&&e.strategy?e.strategy:Rm;return s(t,{cache:o,serializer:n})}function km(t){return t==null||typeof t=="number"||typeof t=="boolean"}function ml(t,e,o,n){var s=km(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function gl(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 Ar(t,e,o,n,s){return o.bind(e,t,n,s)}function Rm(t,e){var o=t.length===1?ml:gl;return Ar(t,this,o,e.cache.create(),e.serializer)}function Pm(t,e){return Ar(t,this,gl,e.cache.create(),e.serializer)}function Im(t,e){return Ar(t,this,ml,e.cache.create(),e.serializer)}var Lm=function(){return JSON.stringify(arguments)};function Mr(){this.cache=Object.create(null)}Mr.prototype.get=function(t){return this.cache[t]};Mr.prototype.set=function(t,e){this.cache[t]=e};var Am={create:function(){return new Mr}},ns={variadic:Pm,monadic:Im};var At;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(At||(At={}));var Bo=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 Nr=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('", "'),'"'),At.INVALID_VALUE,r)||this}return e}(Bo);var fl=function(t){Ho(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),At.INVALID_VALUE,s)||this}return e}(Bo);var hl=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,'"'),At.MISSING_VALUE,n)||this}return e}(Bo);var J;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(J||(J={}));function Mm(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==J.literal||o.type!==J.literal?e.push(o):n.value+=o.value,e},[])}function Nm(t){return typeof t=="function"}function Ko(t,e,o,n,s,r,i){if(t.length===1&&Ir(t[0]))return[{type:J.literal,value:t[0].value}];for(var a=[],c=0,l=t;c<l.length;c++){var d=l[c];if(Ir(d)){a.push({type:J.literal,value:d.value});continue}if(ul(d)){typeof r=="number"&&a.push({type:J.literal,value:o.getNumberFormat(e).format(r)});continue}var u=d.value;if(!(s&&u in s))throw new hl(u,i);var p=s[u];if(dl(d)){(!p||typeof p=="string"||typeof p=="number")&&(p=typeof p=="string"||typeof p=="number"?String(p):""),a.push({type:typeof p=="string"?J.literal:J.object,value:p});continue}if(Zn(d)){var m=typeof d.style=="string"?n.date[d.style]:Fo(d.style)?d.style.parsedOptions:void 0;a.push({type:J.literal,value:o.getDateTimeFormat(e,m).format(p)});continue}if(Qn(d)){var m=typeof d.style=="string"?n.time[d.style]:Fo(d.style)?d.style.parsedOptions:n.time.medium;a.push({type:J.literal,value:o.getDateTimeFormat(e,m).format(p)});continue}if(Xn(d)){var m=typeof d.style=="string"?n.number[d.style]:ts(d.style)?d.style.parsedOptions:void 0;m&&m.scale&&(p=p*(m.scale||1)),a.push({type:J.literal,value:o.getNumberFormat(e,m).format(p)});continue}if(es(d)){var g=d.children,f=d.value,y=s[f];if(!Nm(y))throw new fl(f,"function",i);var P=Ko(g,e,o,n,s,r),v=y(P.map(function(x){return x.value}));Array.isArray(v)||(v=[v]),a.push.apply(a,v.map(function(x){return{type:typeof x=="string"?J.literal:J.object,value:x}}))}if(Jn(d)){var S=d.options[p]||d.options.other;if(!S)throw new Nr(d.value,p,Object.keys(d.options),i);a.push.apply(a,Ko(S.value,e,o,n,s));continue}if(Yn(d)){var S=d.options["=".concat(p)];if(!S){if(!Intl.PluralRules)throw new Bo(`Intl.PluralRules is not available in this environment.
|
|
1
|
+
"use strict";var Hp=Object.create;var bn=Object.defineProperty;var Fp=Object.getOwnPropertyDescriptor;var Bp=Object.getOwnPropertyNames;var Kp=Object.getPrototypeOf,Up=Object.prototype.hasOwnProperty;var Z=(t,e)=>{for(var o in e)bn(t,o,{get:e[o],enumerable:!0})},qi=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Bp(e))!Up.call(t,s)&&s!==o&&bn(t,s,{get:()=>e[s],enumerable:!(n=Fp(e,s))||n.enumerable});return t};var T=(t,e,o)=>(o=t!=null?Hp(Kp(t)):{},qi(e||!t||!t.__esModule?bn(o,"default",{value:t,enumerable:!0}):o,t)),zp=t=>qi(bn({},"__esModule",{value:!0}),t);var Yh={};Z(Yh,{Card:()=>D,ContentEditableInput:()=>jt,DeepdeskAPI:()=>rt,DeepdeskSDK:()=>xn,HTTPClient:()=>Ae,InputMediator:()=>st,InputType:()=>Rt,KeyboardHint:()=>kn,Label:()=>Rn,Locale:()=>Lo,Section:()=>Ue,SectionList:()=>Pn,Sources:()=>ze,Suggestion:()=>M,SuggestionList:()=>le,TextAreaInput:()=>qt,ToggleButton:()=>kt,attachFile:()=>Mp,authenticateWithKey:()=>Lp,createFullRange:()=>To,createOverlayContainer:()=>Sn,createRangeFromOffsets:()=>bt,escapeHTML:()=>ro,fetchPlatformConfig:()=>Ap,formatTextMarkup:()=>Ip,getRangeOffsets:()=>fn,getRangeText:()=>hn,insertCKEditor:()=>Pp,isHTML:()=>us,isSupportedInputElement:()=>dr,updateContentEditable:()=>kp,updateTextArea:()=>Ep,useStyles:()=>h,waitForElementVisibilityChange:()=>mr});module.exports=zp(Yh);var hr=T(require("classnames")),fe=T(require("react"));var Cn=T(require("react")),Xi=T(require("classnames")),Io=Cn.default.createContext({});function h(t,e){let{debug:o,...n}=(0,Cn.useContext)(Io),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let c=s[i];return{...r,[i]:(0,Xi.default)(a,c,o?`${t}__${i}`:!1)}},{}):e}var Zi={root:"qo"};var Ct=require("react/jsx-runtime"),wn=()=>(0,Ct.jsxs)("svg",{className:Zi.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Ct.jsx)("defs",{children:(0,Ct.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Ct.jsx)("title",{children:"Failed loading image"}),(0,Ct.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 fr={root:"Co",imageWrapper:"L",image:"So",content:"m",title:"Eo",contentIsCropped:"Go",lineClamp:"No"};var wt=require("react/jsx-runtime"),Tn=(0,fe.createContext)(fr),Wp=({title:t,src:e})=>{let o=(0,fe.useContext)(Tn),[n,s]=(0,fe.useState)(!1);return(0,fe.useEffect)(()=>{s(!1)},[e]),(0,wt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,wt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,wt.jsx)(wn,{})})},Gp=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,fe.useContext)(Tn);return(0,wt.jsx)("div",{className:(0,hr.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},jp=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,fe.useContext)(Tn);return fe.default.createElement(t,{className:(0,hr.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},En=({children:t})=>{let e=h("Card",fr);return(0,wt.jsx)("div",{className:e.root,children:(0,wt.jsx)(Tn.Provider,{value:e,children:t})})};En.Image=Wp;En.Content=Gp;En.Title=jp;var D=En;var Ji=T(require("classnames"));var Qi={root:"M"};var Yi=require("react/jsx-runtime");var Xp={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Zp=({className:t,keyCode:e,...o})=>{let n=h("KeyboardHint",Qi);return(0,Yi.jsx)("span",{"data-key":Xp[e],className:(0,Ji.default)(t,n.root),...o})},kn=Zp;var ta=T(require("classnames"));var ea={root:"Ao"};var oa=require("react/jsx-runtime"),Jp=({className:t,children:e,...o})=>{let n=h("Label",ea);return(0,oa.jsx)("span",{...o,className:(0,ta.default)(t,n.root),children:e})},Rn=Jp;var na={root:"Fo",subTitleContainer:"Ho",subtitle:"Lo",suggestions:"Mo"};var Zt=require("react/jsx-runtime"),em=({title:t,children:e,type:o,...n})=>{let s=h("Section",na);return(0,Zt.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,Zt.jsx)("div",{className:s.subTitleContainer,children:(0,Zt.jsx)("span",{className:s.subtitle,children:t})}),(0,Zt.jsx)("div",{className:s.suggestions,children:e})]})},Ue=em;var ra=T(require("classnames")),ia=T(require("react"));var sa={root:"Ro"};var aa=require("react/jsx-runtime"),om=ia.default.forwardRef(({className:t,children:e},o)=>{let n=h("SectionList",sa);return(0,aa.jsx)("div",{ref:o,className:(0,ra.default)(n.root,t),children:e})}),Pn=om;var Qt=T(require("classnames")),Y=T(require("react"));var yr={fadein:"R",root:"e",isClickable:"T",isSelected:"To",actions:"U",actionsIsFixed:"Uo",actionButton:"t",dropdownList:"B",dropdownButton:"D",dropdownItem:"I",dropdownItemButton:"O",actionButtonIsPrimary:"Bo",actionButtonIsDisabled:"Do",labels:"Io",label:"Oo",iconButtons:"Xo",iconButton:"n"};var se=require("react/jsx-runtime"),Tt=(0,Y.createContext)(yr),sm=({fixed:t,children:e,...o})=>{let n=(0,Y.useContext)(Tt);return(0,se.jsx)("div",{...o,className:(0,Qt.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})};function la(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type===ca}var ca=({className:t,icon:e,title:o,...n})=>{let s=(0,Y.useContext)(Tt);return(0,se.jsx)("button",{type:"button",className:(0,Qt.default)(s.iconButton,t),title:o,"aria-label":o,...n,children:e})},rm=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,Y.useContext)(Tt);return(0,se.jsxs)("div",{className:(0,Qt.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,se.jsx)("ul",{className:r.dropdownList,children:s})]})},im=({index:t,label:e,onClick:o})=>{let n=(0,Y.useContext)(Tt);return(0,se.jsx)("li",{className:n.dropdownItem,children:(0,se.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},am=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,Y.useContext)(Tt);return(0,se.jsx)("button",{type:"button",className:(0,Qt.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},lm=({labels:t})=>{let e=(0,Y.useContext)(Tt);return(0,se.jsx)("div",{className:e.labels,children:t.map(o=>(0,se.jsx)("span",{className:e.label,children:o},o))})},Et=Y.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=h("Suggestion",yr),c=(0,Y.useCallback)(u=>{u.preventDefault(),o&&o(u)},[o]),l=Y.default.Children.toArray(n).filter(la),d=Y.default.Children.toArray(n).filter(u=>!la(u));return(0,se.jsx)(s,{...r,ref:i,className:(0,Qt.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:c,children:(0,se.jsxs)(Tt.Provider,{value:a,children:[d,(0,se.jsx)("div",{className:a.iconButtons,children:l})]})})});Et.Labels=lm;Et.Actions=sm;Et.ActionButton=am;Et.DropdownButton=rm;Et.DropdownItem=im;Et.IconButton=ca;var M=Et;var ua=T(require("classnames"));var da={root:"Jo",isWithDivider:"Ko"};var pa=require("react/jsx-runtime"),dm=({withDivider:t,children:e})=>{let o=h("SuggestionList",da);return(0,pa.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,ua.default)(o.root,{[o.isWithDivider]:t}),children:e})},le=dm;var ga=T(require("classnames"));var ma={root:"u",isCollapsed:"X"};var In=require("react/jsx-runtime"),pm=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=h("ToggleButton",ma);return(0,In.jsx)("button",{type:"button",className:(0,ga.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"})})})},kt=pm;var fa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,Ln=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ha=/x-deepdesk-(([a-z0-9\-_])+-version)/,ze=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(ze||{}),Rt=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(Rt||{});var be=require("react-dom");var Oc=require("react");var ya=require("@reduxjs/toolkit"),va=require("react-redux");var Lo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Lo||{});var mm={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,floatingMenu:!1,adminUrl:void 0,productName:"Deepdesk"},Sa=(0,ya.createSlice)({name:"settings",initialState:mm,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:An}=Sa.actions,vr=t=>e=>e.settings[t],b=t=>(0,va.useSelector)(vr(t)),xa=Sa.reducer;var Fr=require("react-redux");var Jt=require("@reduxjs/toolkit");var gm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ee=t=>t.auth.isLoggedIn,ba=t=>t.auth.loginFetchState,Ca=t=>t.auth.verifyFetchState,wa=t=>t.auth.showLoginOverlay,Ve=(0,Jt.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Ta=(0,Jt.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Ao=(0,Jt.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Ea=(0,Jt.createSlice)({name:"auth",initialState:gm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Ve.pending,e=>{e.loginFetchState="loading"}),t.addCase(Ve.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Ve.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Ao.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Ao.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Ao.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Yt,setShowLoginOverlay:ka}=Ea.actions,Ra=Ea.reducer;var $e=require("@reduxjs/toolkit"),Ma=require("diff"),Na=require("react-redux");function Pa(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function it(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)=>it(r,e[i],o-1)):Pa(t)&&Pa(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>it(t[i],e[i],o-1)):!1}function fm(t){return Math.max(...t.map(e=>e.length))}function hm(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 Ia(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<fm(n);s++){let r=hm(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 ym=2;function Sr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Ia(t,ym);return o&&o.text!==e?o:t[0]}var Ce=require("@reduxjs/toolkit");var vm={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},w=vm;var La={current:null,isSupported:null},N=(0,Ce.createAction)("resetConversation"),eo=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Mn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},to=t=>t.conversation.isSupported,xr=(0,Ce.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Nn=(0,Ce.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),On=(0,Ce.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),_n=(0,Ce.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Mn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),br=(0,Ce.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:c}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:c})})}),Dn=(0,Ce.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Mn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Sm=[Nn.rejected,On.rejected,_n.rejected,Dn.rejected].map(t=>t==null?void 0:t.toString()),xm=(0,Ce.createSlice)({name:"conversation",initialState:La,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(On.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(_n.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)=>{e.current&&(e.current.messages=o.payload)}).addCase(N,()=>La).addMatcher(e=>Sm.includes(e.type),(e,o)=>{var n;throw w.info("Conversation action rejected",o.type,((n=o.error)==null?void 0:n.message)||"No message"),new Error(o.error.message)})}}),Aa=xm.reducer;var at={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 Oa(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 Fn=(0,$e.createAction)("input/replaceText"),Bn=(0,$e.createAction)("input/keyDown"),Pt=(0,$e.createAction)("input/sendMessage"),Kn=(0,$e.createAction)("input/uiInputChange"),Un=(0,$e.createAction)("input/applyImageSuggestion"),Q=(0,$e.createAction)("input/sendEvent");function Hn(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:c},eventMetrics:{inputType:l},replace:d}=t.stagedSuggestion,u=o==="search"||o==="personal-collection-search",p=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(u||d==="selection")&&(p=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(p=c),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:p,source:o,abVariant:n,abTestName:s,inputType:l,sourceText:i,trainingJobs:r||[],searchTerm:u?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var _a=(0,$e.createSlice)({name:"input",initialState:at,reducers:{initialInput(t,e){let{text:o,selection:n,html:s}=e.payload;t.text=o,t.selection.start=(n==null?void 0:n.start)??o.length,t.selection.end=(n==null?void 0:n.end)??o.length,t.userCommitted.text=o,t.userCommitted.selection.start=(n==null?void 0:n.start)??o.length,t.userCommitted.selection.end=(n==null?void 0:n.end)??o.length,t.html=s||null},reset(t){Object.assign(t,{...at,selection:t.selection})},resetToCommitted(t){t.text=t.userCommitted.text,t.selection=t.userCommitted.selection,t.stagedSuggestion=null,t.tabCompletionSuggestion=Sr(t.textSuggestions,t.userCommitted.text)},changeSelection(t,e){e.payload&&(it(t.selection,e.payload)||(t.selection=e.payload,t.userCommitted.selection=t.selection,t.stagedSuggestion&&Hn(t)))},platformInput(t,e){let{text:o,html:n,selection:s}=e.payload;s&&(t.selection.start=s.start,t.selection.end=s.end),t.text=o,t.html=n||null},userInput(t,e){var r,i,a,c;if(t.previousKeyDownEvent){let{key:l,shiftKey:d,ctrlKey:u,metaKey:p,altKey:m}=t.previousKeyDownEvent;switch(l){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=t,{text:f}=e.payload,y=(0,Ma.diffChars)(g,f);g.length-f.length>1&&t.metrics.deletions.push(...y.filter(P=>P.removed).map(P=>P.value)),t.metrics.numCharsDeleted+=g.length-f.length;break}case"C":case"V":case"X":if(!u&&!p){t.metrics.numCharsTyped+=1;let g=((r=t.selection)==null?void 0:r.start)!==void 0&&((i=t.selection)==null?void 0:i.end)!==void 0?t.text.substring(t.selection.start,t.selection.end):null;g&&g.length>0&&(t.metrics.numCharsDeleted+=g.length,t.metrics.deletions.push(g))}break;case"Shift":break;default:if(!u&&!p&&!m){t.metrics.numCharsTyped+=1;let g=((a=t.selection)==null?void 0:a.start)!==void 0&&((c=t.selection)==null?void 0:c.end)!==void 0?t.text.substring(t.selection.start,t.selection.end):null;g&&g.length>0&&(t.metrics.numCharsDeleted+=g.length,t.metrics.deletions.push(g))}}}!t.metrics.agentStartedTypingTimestamp&&e.payload.text!==t.text&&(t.metrics.agentStartedTypingTimestamp=Date.now()),e.payload.text===""&&(t.metrics=at.metrics,t.textSuggestions=[],t.stagedSuggestion=null),t.text!==e.payload.text&&Hn(t);let{text:o,html:n,selection:s}=e.payload;s&&(t.selection.start=s.start,t.selection.end=s.end,t.userCommitted.selection.start=s.start,t.userCommitted.selection.end=s.end),t.text=o,t.html=n||null,t.userCommitted.text=o,t.previousKeyDownEvent=null},stageSuggestion(t,e){let{text:o}=e.payload;switch(t.stagedSuggestion=e.payload,t.tabCompletionSuggestion=void 0,e.payload.replace){case"selection":t.text=`${t.text.slice(0,t.selection.start)}${o}${t.text.slice(t.selection.end)}`,t.selection.end=t.selection.start+o.length,t.selection.start+=o.length;break;case"until-selection-end":t.text=`${o}${t.text.slice(t.selection.end)}`,t.selection.start=o.length,t.selection.end=o.length;break;default:throw new Error(`Unknown replace ${e.payload.replace}`)}e.payload.eventMetrics.inputType==="tab"&&Hn(t)},commitSuggestion(t){Hn(t)},offeredTextSuggestion(t,e){let{text:o,suggestion:{source:n}}=e.payload;t.metrics.offeredTextSuggestions.find(r=>r.text===o)||t.metrics.offeredTextSuggestions.push({text:o,source:n})},registerCut(t,e){let{metrics:o}=t,n=e.payload;t.metrics={...t.metrics,numCharsCut:o.numCharsCut+n.length,cuts:[...o.cuts,n]}},registerPaste(t,e){let{metrics:o}=t,{text:n,selectionText:s}=e.payload,r=o.numCharsDeleted+(s&&s.length?s.length:0),i=s&&s.length?[...o.deletions,s]:o.deletions;t.metrics={...t.metrics,numCharsDeleted:r,deletions:i,numCharsPasted:o.numCharsPasted+n.length,numPaste:o.numPaste+1,pastes:[...o.pastes,n]}},registerKeyDown(t,e){t.previousKeyDownEvent=e.payload},nextTextSuggestionIndex(t){let e=t.textSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},previousTextSuggestionIndex(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0){t.tabCompletionSuggestion=void 0;return}let o=t.userCommitted.text.substring(0,t.userCommitted.selection.end),n=Sr(e.payload,o);t.tabCompletionSuggestion=n!=null&&n.text.includes(o)?n:void 0},setSelectedTextSuggestionIndex(t,e){t.selectedSuggestionIndex=e.payload},setMetrics(t,{payload:e}){t.metrics=e}},extraReducers:t=>{t.addCase(N,e=>{e.tabCompletionSuggestion=at.tabCompletionSuggestion,e.previousKeyDownEvent=at.previousKeyDownEvent,e.textSuggestions=at.textSuggestions,e.selectedSuggestionIndex=at.selectedSuggestionIndex,e.metrics=at.metrics})}}),oo=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),bm=t=>t.input.selection,Da=()=>(0,Na.useSelector)(bm),{userInput:Ha,changeSelection:Cr,initialInput:Fa,nextTextSuggestionIndex:Ba,offeredTextSuggestion:Ka,previousTextSuggestionIndex:Ua,registerCut:za,registerKeyDown:Va,registerPaste:$a,reset:Wa,resetToCommitted:Mo,platformInput:Ga,setSelectedTextSuggestionIndex:lt,setTextSuggestions:Me,stageSuggestion:Ne,commitSuggestion:We,setMetrics:ja}=_a.actions,qa=_a.reducer;var Vn=require("@reduxjs/toolkit");var no=require("@reduxjs/toolkit");function Cm(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function A(t){return Array.isArray(t)?t.map(A):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Cm(o)]:A(t[o])}),{}):t}function wr(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,[wr(o)]:U(t[o])}),{}):t}var wm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Oo=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)||""}},No=(0,no.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?A(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),A(n))}),Tr=(0,no.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}),Er=(0,no.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Xa=t=>t.info.agentInfo,Za=(0,no.createSlice)({name:"info",initialState:wm,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(No.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(No.rejected,e=>{e.fetchState="error"}).addCase(No.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(Tr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(Er.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(N,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Qa}=Za.actions,Ja=Za.reducer;var zn={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},Ya=t=>t.search.isOpen,el=t=>t.search.page,tl=t=>t.search.list,ol=t=>t.search.aggregates;function nl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var It=(0,Vn.createAsyncThunk)("search/getAll",async(t,e)=>{var a;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(a=n.conversation.current)==null?void 0:a.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r,aggregates:i}=await o.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:Oo(n)});return{results:r.map(c=>({...c,source:`search-${c.type.toLowerCase()}`,searchTerm:t.query})),aggregates:i}}),sl=(0,Vn.createSlice)({name:"search",initialState:zn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=zn.fetchState,t.list=zn.list}},extraReducers:t=>{t.addCase(It.pending,e=>{e.fetchState="loading"}).addCase(It.rejected,(e,o)=>{e.fetchState="error",w.error(o.error)}).addCase(It.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload.results,e.aggregates=o.payload.aggregates||{}}).addCase(N,()=>zn)}}),{resetSearch:$n,setIsOpen:ce,setPage:we}=sl.actions,rl=sl.reducer;var kr="SetCues",so="ShowLoginOverlay",_o="UserLoggedIn",Tm="UserLoggedOut",ct="ApplySuggestion",Rr="ApplyImageSuggestion",Em="ShowCommandPalette",km=t=>({[kr]:e=>{t.dispatch({...e,isBroadcasted:!0})},[Em]:e=>{t.dispatch(ce(e.isOpen)),e.page&&t.dispatch(we(e.page))},[so]:e=>{t.dispatch(ka(e))},[_o]:()=>{t.dispatch(Ve())},[Tm]:()=>{t.dispatch(Ve())},[Rr]:e=>{t.dispatch(Un({suggestion:e.suggestion}))},[ct]:e=>{t.dispatch(Ne({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(We())}}),il=km;var Do=T(require("react")),ll=require("react/jsx-runtime"),al=Do.default.createContext(null),Lt=({broadcastEvents:t,children:e})=>{let o=Do.default.useMemo(()=>t,[]);return(0,ll.jsx)(al.Provider,{value:o,children:e})},he=()=>{let t=(0,Do.useContext)(al);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var as=T(require("classnames")),Ee=require("react"),ls=require("react-redux");var ss=require("react");var Pr=function(t,e){return Pr=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])},Pr(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");Pr(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var de=function(){return de=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},de.apply(this,arguments)};function cl(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 jn=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Te;(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"})(Te||(Te={}));var qn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(qn||(qn={}));function Ir(t){return t.type===Te.literal}function dl(t){return t.type===Te.argument}function Xn(t){return t.type===Te.number}function Zn(t){return t.type===Te.date}function Qn(t){return t.type===Te.time}function Jn(t){return t.type===Te.select}function Yn(t){return t.type===Te.plural}function ul(t){return t.type===Te.pound}function es(t){return t.type===Te.tag}function ts(t){return!!(t&&typeof t=="object"&&t.type===qn.number)}function Fo(t){return!!(t&&typeof t=="object"&&t.type===qn.dateTime)}function Lr(t){t.forEach(function(e){if(delete e.location,Jn(e)||Yn(e))for(var o in e.options)delete e.options[o].location,Lr(e.options[o].value);else Xn(e)&&ts(e.style)||(Zn(e)||Qn(e))&&Fo(e.style)?delete e.style.location:es(e)&&Lr(e.children)})}function pl(t,e){e===void 0&&(e={}),e=de({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new jn(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||Lr(o.val),o.val}function os(t,e){var o=e&&e.cache?e.cache:Mm,n=e&&e.serializer?e.serializer:Am,s=e&&e.strategy?e.strategy:Pm;return s(t,{cache:o,serializer:n})}function Rm(t){return t==null||typeof t=="number"||typeof t=="boolean"}function ml(t,e,o,n){var s=Rm(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function gl(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 Ar(t,e,o,n,s){return o.bind(e,t,n,s)}function Pm(t,e){var o=t.length===1?ml:gl;return Ar(t,this,o,e.cache.create(),e.serializer)}function Im(t,e){return Ar(t,this,gl,e.cache.create(),e.serializer)}function Lm(t,e){return Ar(t,this,ml,e.cache.create(),e.serializer)}var Am=function(){return JSON.stringify(arguments)};function Mr(){this.cache=Object.create(null)}Mr.prototype.get=function(t){return this.cache[t]};Mr.prototype.set=function(t,e){this.cache[t]=e};var Mm={create:function(){return new Mr}},ns={variadic:Im,monadic:Lm};var At;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(At||(At={}));var Bo=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 Nr=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('", "'),'"'),At.INVALID_VALUE,r)||this}return e}(Bo);var fl=function(t){Ho(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),At.INVALID_VALUE,s)||this}return e}(Bo);var hl=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,'"'),At.MISSING_VALUE,n)||this}return e}(Bo);var J;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(J||(J={}));function Nm(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==J.literal||o.type!==J.literal?e.push(o):n.value+=o.value,e},[])}function Om(t){return typeof t=="function"}function Ko(t,e,o,n,s,r,i){if(t.length===1&&Ir(t[0]))return[{type:J.literal,value:t[0].value}];for(var a=[],c=0,l=t;c<l.length;c++){var d=l[c];if(Ir(d)){a.push({type:J.literal,value:d.value});continue}if(ul(d)){typeof r=="number"&&a.push({type:J.literal,value:o.getNumberFormat(e).format(r)});continue}var u=d.value;if(!(s&&u in s))throw new hl(u,i);var p=s[u];if(dl(d)){(!p||typeof p=="string"||typeof p=="number")&&(p=typeof p=="string"||typeof p=="number"?String(p):""),a.push({type:typeof p=="string"?J.literal:J.object,value:p});continue}if(Zn(d)){var m=typeof d.style=="string"?n.date[d.style]:Fo(d.style)?d.style.parsedOptions:void 0;a.push({type:J.literal,value:o.getDateTimeFormat(e,m).format(p)});continue}if(Qn(d)){var m=typeof d.style=="string"?n.time[d.style]:Fo(d.style)?d.style.parsedOptions:n.time.medium;a.push({type:J.literal,value:o.getDateTimeFormat(e,m).format(p)});continue}if(Xn(d)){var m=typeof d.style=="string"?n.number[d.style]:ts(d.style)?d.style.parsedOptions:void 0;m&&m.scale&&(p=p*(m.scale||1)),a.push({type:J.literal,value:o.getNumberFormat(e,m).format(p)});continue}if(es(d)){var g=d.children,f=d.value,y=s[f];if(!Om(y))throw new fl(f,"function",i);var P=Ko(g,e,o,n,s,r),v=y(P.map(function(x){return x.value}));Array.isArray(v)||(v=[v]),a.push.apply(a,v.map(function(x){return{type:typeof x=="string"?J.literal:J.object,value:x}}))}if(Jn(d)){var S=d.options[p]||d.options.other;if(!S)throw new Nr(d.value,p,Object.keys(d.options),i);a.push.apply(a,Ko(S.value,e,o,n,s));continue}if(Yn(d)){var S=d.options["=".concat(p)];if(!S){if(!Intl.PluralRules)throw new Bo(`Intl.PluralRules is not available in this environment.
|
|
2
2
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
3
|
-
`,At.MISSING_INTL_API,i);var I=o.getPluralRules(e,{type:d.pluralType}).select(p-(d.offset||0));S=d.options[I]||d.options.other}if(!S)throw new Nr(d.value,p,Object.keys(d.options),i);a.push.apply(a,Ko(S.value,e,o,n,s,p-(d.offset||0)));continue}}return Mm(a)}function Om(t,e){return e?de(de(de({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=de(de({},t[n]),e[n]||{}),o},{})):t}function _m(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Om(t[n],e[n]),o},de({},t)):t}function Or(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Dm(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:os(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:Or(t.number),strategy:ns.variadic}),getDateTimeFormat:os(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:Or(t.dateTime),strategy:ns.variadic}),getPluralRules:os(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:Or(t.pluralRules),strategy:ns.variadic})}}var yl=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(l){var d=r.formatToParts(l);if(d.length===1)return d[0].value;var u=d.reduce(function(p,m){return!p.length||m.type!==J.literal||typeof p[p.length-1]!="string"?p.push(m.value):p[p.length-1]+=m.value,p},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(l){return Ko(r.ast,r.locales,r.formatters,r.formats,l,void 0,r.message)},this.resolvedOptions=function(){var l;return{locale:((l=r.resolvedLocale)===null||l===void 0?void 0:l.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,c=cl(i,["formatters"]);this.ast=t.__parse(e,de(de({},c),{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=_m(t.formats,n),this.formatters=s&&s.formatters||Dm(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=pl,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 Hm(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Fm="dummy",_r=(0,ss.createContext)(null);function k(t){let e=(0,ss.useContext)(_r);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=Hm(o,n);return r?new yl(r).format(s):(e!==Fm&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var rs=require("react");var vl={root:"J",content:"Po"};var Dr=require("react/jsx-runtime"),Km=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,onKeyDown:r,overlayAriaLabel:i,contentAriaLabel:a})=>{let c=(0,rs.useRef)(null),l=h("Dialog",vl),d=p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),s();return}r&&r(p)},u=p=>{p.target===c.current&&t&&n()};return(0,rs.useEffect)(()=>{var p,m;!c.current||!t||!e||(m=(p=c.current)==null?void 0:p.querySelector("input, textarea"))==null||m.focus()},[t,e,c]),t?(0,Dr.jsx)("div",{role:"dialog","data-testid":"dialog",className:l.root,"aria-label":i,ref:c,onKeyDown:d,onMouseDown:u,children:(0,Dr.jsx)("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:o})}):null},is=Km;var xl=T(require("classnames"));var Sl={root:"y"};var bl=require("react/jsx-runtime"),zm=({className:t,value:e,...o})=>{let n=h("TextInput",Sl);return(0,bl.jsx)("input",{className:(0,xl.default)(t,n.root),type:"text",value:e,...o})},Uo=zm;var Hr={};Z(Hr,{enUS:()=>Vm,nlNL:()=>$m});var Vm={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"}]},$m={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 Cl={root:"Qo",anchorButton:"Vo",errorMessage:"Wo",title:"Zo",subtitle:"_o",text:"oe",input:"ee",actions:"ie",button:"w",primaryButton:"re"};var K=require("react/jsx-runtime");var Gm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},jm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=k(Hr),i=h("LoginTokenDialog",Cl),a=(0,ls.useSelector)(Ca),c=(0,ls.useDispatch)(),l=b("productName"),[d,u]=(0,Ee.useState)(t||""),[p,m]=(0,Ee.useState)(0),[g,f]=(0,Ee.useState)(""),y=(0,Ee.useCallback)(async I=>{I.preventDefault(),c(Ta({email:d})),m(1)},[o,d]),P=()=>{f(""),m(0)},v=(0,Ee.useCallback)(async I=>{I.preventDefault();let x=Gm(I.target.elements.token.value);if(!x){f(r("verifyCodeError",{login:S}));return}c(Ao({token:x}))},[o]),S=(0,Ee.useMemo)(()=>I=>(0,K.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:P,children:I},"back-button"),[]);return(0,Ee.useEffect)(()=>{a==="error"&&f(r("verifyCodeError",{login:S})),a==="done"&&n()},[a]),(0,K.jsx)(is,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:l}),overlayAriaLabel:r("promptTitle",{productName:l}),onClose:s,onBack:s,children:(0,K.jsxs)("div",{className:i.root,children:[(0,K.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:l})}),p===0&&(0,K.jsxs)("form",{onSubmit:y,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:l})}),(0,K.jsx)(Uo,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:d,onChange:I=>u(I.target.value)}),(0,K.jsx)("div",{className:i.actions,children:(0,K.jsx)("button",{type:"submit",className:(0,as.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),p===1&&(0,K.jsxs)("form",{onSubmit:v,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,K.jsx)(Uo,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),g&&(0,K.jsx)("div",{className:i.errorMessage,children:g}),(0,K.jsxs)("div",{className:i.actions,children:[(0,K.jsx)("button",{type:"button",className:(0,as.default)(i.button),onClick:P,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,as.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},wl=jm;var El=require("react/jsx-runtime"),qm=()=>{let t=(0,Fr.useSelector)(wa),e=(0,Fr.useSelector)(Xa),o=b("adminUrl"),n=he(),s=()=>n.send(so,!1),r=()=>{n.send(so,!1),n.send(_o)};return(0,El.jsx)(wl,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Tl=qm;var Mc=T(require("lodash.debounce")),re=require("react"),_e=require("react-redux");var cs=require("@reduxjs/toolkit");var Xm={data:null,fetchState:"idle"},kl=t=>t.contentTypes.data,zo=(0,cs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Zm=(0,cs.createSlice)({name:"contentTypes",initialState:Xm,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})}}),Rl=Zm.reducer;function Mt(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 Ge=require("react");var Pl=require("react"),ds=T(require("classnames"));var ye={root:"te",list:"ne",listWrapper:"ae",listHorizontal:"K",page:"v",search:"P",pageNav:"pe",pageTitle:"de",pageBackButton:"Q",listHeader:"le",listHeading:"se",listMoreButton:"ce",listItem:"V",listItemContent:"a",listItemText:"xe",listItemDescription:"fe",listItemActions:"W",truncate:"ge",lineClamp:"be",listItemTitle:"he",listItemAction:"me",listItemPrimaryAction:"ue",listItemSelected:"ye",sources:"we",sourcesTitle:"ve",source:"ke",icon:"Z",searchIcon:"ze",searchInputWrapper:"je",searchInput:"k",select:"Ye",selectType:"qe",selectWrapper:"z",image:"Ce",imageSrc:"Se",imageSrcHidden:"Ee",imageSrcStatus:"Ge",imageTitle:"Ne",actions:"Ae",actionsWrapper:"Fe",actionsBar:"He",actionButton:"_",hasShortKeys:"Le",actionShortcut:"Me",actionShortcutFixKerning:"Re"};var Nt={};Z(Nt,{enUS:()=>Jm,nlNL:()=>Ym});var Jm={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}]},Ym={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}]};var dt=require("react/jsx-runtime"),eg=({src:t,title:e})=>{let o=h("CommandPalette",ye),[n,s]=(0,Pl.useState)("loading"),r=k(Nt);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,ds.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,dt.jsx)("span",{className:(0,ds.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,dt.jsx)("span",{className:(0,ds.default)(o.imageSrc,o.imageSrcStatus),children:(0,dt.jsx)(wn,{})}),e&&(0,dt.jsx)("span",{className:o.imageTitle,children:e})]})},Il=eg;var Ll=T(require("react")),Al=T(require("classnames"));var Ot=require("react/jsx-runtime");function Br({children:t,heading:e,orientation:o,hasMore:n,onShowAll:s}){let r=k(Nt),i=h("CommandPalette",ye);return Ll.default.Children.count(t)===0?null:(0,Ot.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||n)&&(0,Ot.jsxs)("div",{className:i.listHeader,children:[e&&(0,Ot.jsx)("h4",{className:i.listHeading,children:e}),n&&s&&(0,Ot.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,Ot.jsx)("div",{className:(0,Al.default)(i.listWrapper,o==="horizontal"&&i.listHorizontal),children:t})]})}var Vo=T(require("classnames")),zl=require("interweave");var tg=/[.*+?^${}()|[\]\\]/g,og=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function ng(t){return t.replace(tg,"\\$&")}function sg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function rg(t){return t.search(og)}function Ml(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${ng(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function Nl(t){return t.replace(Ln,'<mark data-type="placeholder">$1</mark>')}function ro(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ig(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 Kr(t,e,o={}){if(e){let n=sg(e.toLowerCase(),t.toLowerCase()),s=ro(t.substring(n,t.length));if(o.stripAgentPart){let c=t.substring(0,n),l=rg(c);return`<span style="opacity: 0.5">${c.substring(l+1)}</span>${s}`}let i=e.split(fa).length>3||e.length>30?ig(e.trim(),n):0;return`${`${i>0?"\u2026":""}${ro(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var ag=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function us(t){return ag.test(t)}function Ol(t){let e=document.createElement("template");return e.innerHTML=t,e.content.textContent??""}var W=T(require("react")),_l=T(require("classnames"));var Ur={root:"Te",trigger:"oo",content:"Ue",contentOpen:"Be",contentTop:"De",contentBottom:"Ie",item:"eo"};var _t=require("react/jsx-runtime"),cg=0,Dl=W.default.createContext(null),dg=()=>{let t=(0,W.useContext)(Dl);if(!t)throw new Error("Invalid DropdownContext");return t},Hl=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,W.useMemo)(()=>++cg,[]),s=(0,W.useRef)(null),r=(0,W.useRef)(null),i=h("Dropdown",Ur),[a,c]=(0,W.useState)(!1),[l,d]=(0,W.useState)(o),u=m=>{m.preventDefault(),m.stopPropagation(),c(!a)},p=(0,W.useCallback)(([m])=>{!m.isIntersecting&&a&&d(l==="top"?"bottom":"top")},[a]);return(0,W.useEffect)(()=>{let m=g=>{s.current&&!s.current.contains(g.target)&&c(!1)};return document.addEventListener("click",m),()=>{document.removeEventListener("click",m)}},[]),(0,W.useEffect)(()=>{if(!r.current&&!a)return()=>{};let m=new IntersectionObserver(p,{root:null,rootMargin:"0px",threshold:1});return r.current&&m.observe(r.current),()=>{r.current&&m.unobserve(r.current)}},[r,a]),(0,_t.jsx)(Dl.Provider,{value:{setIsOpen:c},children:(0,_t.jsxs)("div",{ref:s,className:i.root,children:[(0,_t.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,_t.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,_l.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:l==="top",[i.contentBottom]:l==="bottom"}),children:e})]})})};function ug({as:t,children:e,onClick:o,...n}){let s=t||"button",r=h("Dropdown",Ur),{setIsOpen:i}=dg(),a=c=>{i(!1),o(c),c.stopPropagation()};return(0,_t.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Hl.Item=ug;var zr=Hl;var Vr=require("react/jsx-runtime"),Fl=t=>(0,Vr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,Vr.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 Dt={};Z(Dt,{enUS:()=>pg,nlNL:()=>mg});var pg={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"}]},mg={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 ps=require("react/jsx-runtime"),gg="%0d%0a%0d%0a%0d%0a",fg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(gg)}`},hg=({suggestion:t,onFeedback:e})=>{let o=k(Dt),n=b("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,ps.jsx)(zr,{trigger:(0,ps.jsx)(Fl,{"data-testid":"feedback-dropdown-trigger"}),children:(0,ps.jsx)(zr.Item,{as:"a",href:fg(n,t),onClick:e,children:o("giveFeedback")})})},ms=hg;var gs=T(require("react")),Ul=require("react/jsx-runtime"),Bl=gs.default.createContext(void 0);function ut(){let t=gs.default.useContext(Bl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Kl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=gs.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,Ul.jsx)(Bl.Provider,{value:i,children:t})};var ue=require("react/jsx-runtime");function $r({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,extra:r,onSourceClick:i,description:a,sources:c,id:l,styles:d,...u}){let{selected:p,onChangeOpen:m}=ut(),g=h("CommandPalette",ye);function f(y){n(y),t&&m(!1)}return(0,ue.jsxs)("div",{className:(0,Vo.default)(g.listItem,l===p&&g.listItemSelected),children:[(0,ue.jsx)("button",{type:"button",className:(0,Vo.default)(g.listItemAction,g.listItemPrimaryAction),"aria-disabled":u.disabled??!1,onClick:f,"data-command-palette-item":!0,"data-item-id":l,...u,children:(0,ue.jsxs)("div",{className:g.listItemContent,children:[typeof o=="string"?(0,ue.jsx)("p",{className:(0,Vo.default)(g.listItemText,g.truncate,d==null?void 0:d.title),children:o}):o,a&&(0,ue.jsx)(zl.Interweave,{tagName:"p",allowList:[],content:us(a)?Ol(a):a,className:(0,Vo.default)(g.listItemDescription,d==null?void 0:d.description,e?g.lineClamp:g.truncate)})]})}),r,s&&(0,ue.jsx)("div",{className:g.listItemActions,children:(0,ue.jsx)(ms,{suggestion:String(o),onFeedback:s})}),c&&c.length>0&&(0,ue.jsxs)("div",{className:g.sources,children:[(0,ue.jsx)("span",{className:g.sourcesTitle,children:"Sources"}),c.map(y=>y.url?(0,ue.jsx)("a",{className:g.source,href:y.url,target:"_blank",title:y.url,rel:"noopener noreferrer",onClick:()=>i&&i(y),children:y.name},y.url):(0,ue.jsx)("span",{className:g.source,children:y.name},y.name))]})]})}var $o=require("react/jsx-runtime"),Vl=()=>(0,$o.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,$o.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,$o.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 Ht=require("react/jsx-runtime");function Wr({children:t,title:e,id:o,onDismiss:n}){let s=k(Nt),r=h("CommandPalette",ye),{page:i}=ut();return i!==o?null:(0,Ht.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,Ht.jsxs)("div",{className:r.pageNav,children:[(0,Ht.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,Ht.jsx)(Vl,{}),s("back")]}),e&&(0,Ht.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var $l=require("react");var Wo=require("react/jsx-runtime"),io=()=>(0,Wo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Wo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Wo.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});var ke=require("react/jsx-runtime");function yg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let c=h("CommandPalette",ye);return(0,ke.jsxs)("div",{className:c.search,children:[(0,ke.jsx)("div",{className:c.searchIcon,children:(0,ke.jsx)(io,{})}),(0,ke.jsxs)("div",{className:c.searchInputWrapper,children:[(0,ke.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:l=>{t(l.currentTarget.value)},onFocus:l=>{l.currentTarget.select()},className:c.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&(0,ke.jsx)("div",{className:c.selectWrapper,children:(0,ke.jsxs)("select",{"data-testid":"command-palette-type-select",className:c.select,onChange:l=>e(l.target.value===n?void 0:l.target.value),value:i||n,children:[n&&(0,ke.jsx)("option",{children:n}),s.map(l=>(0,ke.jsx)("option",{value:l.value,children:l.label},l.value))]})})]})]})}var Wl=(0,$l.forwardRef)(yg);var Gr=T(require("classnames"));var fs=require("react/jsx-runtime"),vg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=h("CommandPalette",ye);return(0,fs.jsxs)("button",{type:"button",...n,onClick:t,className:(0,Gr.default)(s.actionButton,n.className,{[s.hasShortKeys]:e&&e.length>0}),children:[o,e&&e.map(r=>(0,fs.jsx)("span",{className:(0,Gr.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},Gl=vg;var Go=require("react/jsx-runtime"),Sg="[data-command-palette-item]";function ao({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:c,types:l,children:d,isOpen:u,search:p}){let[m,g]=(0,Ge.useState)(),f=(0,Ge.useRef)(null),y=()=>{s&&s(o),i(void 0),r(""),a(!1)},P=()=>{var L;if(n!==o&&s){s(o);return}if(c&&i){i(void 0),(L=f.current)==null||L.focus();return}if(p.length>0){r("");return}a(!1)},v=()=>{let L=S();L.length!==0&&g(L[0].dataset.itemId)},S=()=>Array.from(document.querySelectorAll(Sg)||[]),I=L=>document.querySelector(`[data-item-id=${L}]`),x=L=>{let _=I(L);_&&g(_.dataset.itemId)},E=L=>{let _=I(L);_&&_.scrollIntoView({behavior:"smooth"})},O=()=>{if(!m)return;let L=S(),_=I(m);if(!_)return;let q=L.indexOf(_),ge=L[q+1];ge&&ge.dataset.itemId?x(ge.dataset.itemId):v()},j=()=>{if(!m)return;let L=S(),_=I(m);if(!_)return;let q=L.indexOf(_),ge=L[q-1];ge&&ge.dataset.itemId?x(ge.dataset.itemId):x(L[L.length-1].dataset.itemId)},V=(0,Ge.useCallback)(L=>{switch(L.key){case"ArrowDown":{L.preventDefault(),O();break}case"ArrowUp":{L.preventDefault(),j();break}case"Enter":{if(m){let _=I(m);_==null||_.click()}break}}},[m]);return(0,Ge.useEffect)(()=>{v()},[p,n,c,u]),(0,Ge.useEffect)(()=>{m&&E(m)},[m]),(0,Go.jsx)(is,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:P,onClose:y,onKeyDown:V,children:(0,Go.jsxs)(Kl,{selected:m,setSelected:g,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&(0,Go.jsx)(Wl,{ref:f,onChange:r,onChangeType:i,placeholder:t,value:p,selectedType:c,types:l,typePlaceholder:e}),d]})})}ao.Page=Wr;ao.List=Br;ao.Image=Il;ao.ListItem=$r;ao.Button=Gl;var H=ao;var jl=require("react");function ql(t,e){(0,jl.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 jo=require("react"),vs=require("react-redux");var hs=require("@reduxjs/toolkit");var Xl={data:null,fetchState:"idle"},ys=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,hs.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)}),xg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),bg=(0,hs.createSlice)({name:"entities",initialState:Xl,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=xg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(N,()=>Xl)}}),Zl=bg.reducer;var jr={};Z(jr,{enUS:()=>Cg,nlNL:()=>wg});var Cg={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},wg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Ql={root:"Oe",empty:"Xe"};var lo=require("react/jsx-runtime"),Eg=({onCopy:t})=>{let e=(0,jo.useRef)(null),o=h("EntitiesList",Ql),n=(0,vs.useSelector)(ys),{setSelected:s}=ut(),r=k(jr),i=(0,vs.useDispatch)();return(0,jo.useEffect)(()=>{i(Re())},[]),(0,jo.useEffect)(()=>{e.current&&(e.current.focus(),s("entity-0"))},[e]),(0,lo.jsxs)("div",{className:o.root,ref:e,tabIndex:-1,children:[n&&n.length>0&&(0,lo.jsx)(H.List,{children:n.map((a,c)=>(0,lo.jsx)(H.ListItem,{id:`entity-${c}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),n&&n.length===0&&(0,lo.jsx)("p",{className:o.empty,children:r("noResults")})]})},Jl=Eg;var Pe=require("react"),uo=require("react-redux");var Ss=require("@reduxjs/toolkit");var Yl={data:null,fetchState:"idle"},ec=t=>t.summary.data,tc=t=>t.summary.fetchState==="error",oc=t=>t.summary.model,je=(0,Ss.createAsyncThunk)("summary/getSummary",async(t,e)=>{var d,u,p;let o=e.getState().profile.data,n=(d=e.getState().conversation.current)==null?void 0:d.sessionId,s=(p=(u=e.getState().info)==null?void 0:u.agentInfo)==null?void 0:p.agentId;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:i}=e.extra;if(!i.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let a=i.conversationQuery,c=await a();if(c.length===0)return Promise.reject(new Error("No messages are included"));let l=await r.getSummary(c,{externalConversationId:n,agentId:s,promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return l.summary?l:Promise.reject(new Error("Summary is not provided"))}),kg=(0,Ss.createSlice)({name:"summary",initialState:Yl,reducers:{},extraReducers:t=>{t.addCase(je.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(je.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(je.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary,e.model=o.payload.model)}).addCase(N,()=>Yl)}}),nc=kg.reducer;var qr={};Z(qr,{enUS:()=>Rg,nlNL:()=>Pg});var Rg={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."}]},Pg={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 sc={root:"Je",actions:"Ke",main:"Pe",textInput:"io",loading:"Qe",error:"Ve"};var Jr=T(require("classnames")),cc=require("react");var Xr=require("react/jsx-runtime"),xs=t=>(0,Xr.jsx)("svg",{width:"16",height:"16",fill:"#000000",...t,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Xr.jsx)("path",{fillRule:"evenodd",d:"M6.57086468,14.9173453 C6.38997052,14.9711236 6.19835748,15 6,15 L4,15 C2.8954305,15 2,14.1045695 2,13 L2,4 C2,2.8954305 2.8954305,2 4,2 L6,2 C6.68685475,2 7.29284112,2.34623869 7.65294381,2.87370078 C7.95642355,2.67736738 8.29504785,2.51351337 8.66312366,2.3818197 C9.50544052,2.08044754 10.3408482,1.9879107 10.9989281,1.99971266 C11.0150698,2.00005426 13.3487605,2.00015005 18,2 C20.7551411,2 22,6.05643086 22,12 C22,13.6824804 20.8695981,15 19,15 L15.9269768,15 C15.9359266,15.0245465 15.9451954,15.0497804 15.9547911,15.0757271 C16.007193,15.2174219 16.2391583,15.8256341 16.2970775,15.9810953 C16.4872151,16.4914441 16.6259612,16.9026411 16.7382242,17.3098712 C16.9079007,17.9253665 17,18.4798886 17,19 C17,20.4720069 16.091867,21.3862822 14.748281,21.777514 C14.1422801,21.9539723 13.6147967,22.0000922 13.0076976,22.0000008 L12.5204954,22 L12.2202699,21.6261158 C11.2556275,20.4248034 7.64562469,16.4822788 6.57086468,14.9173453 Z M8,13 C8,13.2401953 8.04443154,13.4528921 8.14171093,13.6800176 C8.40663864,14.2985643 11.914268,18.1371493 13.4599624,19.9848695 C13.7113931,19.9660111 13.9483736,19.9273712 14.1891338,19.8572655 C14.7621788,19.6904035 15,19.4509737 15,19 C15,18.6834183 14.9359344,18.2976852 14.8101464,17.8413935 C14.7161494,17.500423 14.5944107,17.1396301 14.4229225,16.6793379 C14.3689242,16.5344009 14.1358033,15.923159 14.0789589,15.7694517 C13.9489218,15.4178313 13.8632547,15.1589343 13.8046536,14.9236885 C13.5555377,13.9236468 13.8054549,13 15,13 L19,13 C19.6912225,13 20,12.6401099 20,12 C20,7.20925475 19.015127,4 18,4 C15.9322103,4 15.9322103,4 10.9655994,3.99940813 C10.5253746,3.99154158 9.91062406,4.05963657 9.33687634,4.2649175 C8.45196659,4.58152894 8,5.09776992 8,6 L8,13 Z M4,4 L4,13 L6,13 L6,4 L4,4 Z"})});var Zr=require("react/jsx-runtime"),bs=t=>(0,Zr.jsx)("svg",{width:"16",height:"16",fill:"#000000",...t,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Zr.jsx)("path",{fillRule:"evenodd",d:"M7.65336736,21.1256786 C7.2933164,21.6534897 6.68712411,22 6,22 L4,22 C2.8954305,22 2,21.1045695 2,20 L2,11 C2,9.8954305 2.8954305,9 4,9 L6,9 C6.198171,9 6.38961023,9.02882212 6.57035446,9.08250314 C7.6444817,7.51807482 11.2554748,3.57449216 12.2202699,2.37298955 L12.5204954,1.99910538 L13,1.99910538 C13.6147967,1.99901314 14.1422801,2.04513312 14.748281,2.22159137 C16.091867,2.61282321 17,3.52709845 17,4.99910538 C17,5.51921677 16.9079007,6.07373891 16.7382242,6.68923415 C16.6259612,7.09646424 16.4872151,7.50766133 16.2970775,8.01801005 C16.2391583,8.17347129 16.007193,8.78168345 15.9547911,8.92337824 C15.9451954,8.94932503 15.9359266,8.9745589 15.9269768,8.99910538 L19,8.99910538 C20.8695981,8.99910538 22,10.316625 22,11.9991054 C22,17.9426745 20.7551411,21.9991054 18,21.9991054 L11.0344006,21.9985135 C10.3408482,22.0111947 9.50544052,21.9186578 8.66312366,21.6172857 C8.29521907,21.4856533 7.9567386,21.3218904 7.65336736,21.1256786 Z M8,17.9991054 C8,18.9013355 8.45196659,19.4175764 9.33687634,19.7341879 C9.91062406,19.9394688 10.5253746,20.0075638 10.963066,19.9997143 C10.9703499,19.9995545 10.9703499,19.9995545 11,19.9991054 L18,19.9991054 C19.015127,19.9991054 20,16.7898506 20,11.9991054 C20,11.3589955 19.6912225,10.9991054 19,10.9991054 L15,10.9991054 C13.8054549,10.9991054 13.5555377,10.0754586 13.8046536,9.07541689 C13.8632547,8.84017106 13.9489218,8.5812741 14.0789589,8.22965366 C14.1358033,8.07594642 14.3689242,7.46470447 14.4229225,7.31976744 C14.5944107,6.85947528 14.7161494,6.4986824 14.8101464,6.1577119 C14.9359344,5.70142019 15,5.31568707 15,4.99910538 C15,4.54813166 14.7621788,4.30870189 14.1891338,4.1418399 C13.9483736,4.07173418 13.7113931,4.0330943 13.4599624,4.01423587 C11.914268,5.86195611 8.40663864,9.70054105 8.14171093,10.3190878 C8.04443154,10.5462133 8,10.7589101 8,10.9991054 L8,17.9991054 Z M4,11 L4,20 L6,20 L6,11 L4,11 Z"})});function qe(t,e){var n;let o=t.cloneNode(!0);o.style.top=`${t.offsetTop}px`,o.style.left=`${t.offsetLeft}px`,o.style.position="absolute",o.classList.add(e),o.addEventListener("animationend",()=>o.remove()),(n=t.parentElement)==null||n.appendChild(o)}var Qr={};Z(Qr,{enUS:()=>Lg,nlNL:()=>Ag});var Lg={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},Ag={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var ac=require("react-redux");var rc=require("@reduxjs/toolkit");function ic(t){return(0,rc.createAsyncThunk)("analytics/logEvent",(e,o)=>{var r,i,a;let n=(i=(r=o.getState())==null?void 0:r.conversation.current)==null?void 0:i.id,s=(a=o.getState())==null?void 0:a.info.agentInfo;return o.extra.deepdeskAPI.sendEvent(e.name,{conversationId:n,...s,data:e.data})})(t)}function co(){let t=(0,ac.useDispatch)();return async(e,o)=>{await t(ic({name:e,data:o}))}}var lc={fadeup:"j",fadedown:"Y",thumbs:"We",selected:"ro",thumbsUp:"Ze",thumbsDown:"_e"};var Ft=require("react/jsx-runtime"),Ng=({eventName:t,eventData:e})=>{let o=h("FeedbackThumbs",lc),n=k(Qr),s=co(),[r,i]=(0,cc.useState)(null),a=l=>{l.preventDefault(),l.stopPropagation(),qe(l.target,o.fadeup),i("up"),s(t,{...e,rating:"up"})},c=l=>{l.preventDefault(),l.stopPropagation(),qe(l.target,o.fadedown),i("down"),s(t,{...e,rating:"down"})};return(0,Ft.jsxs)("div",{className:o.thumbs,children:[(0,Ft.jsx)(M.IconButton,{title:n("thumbsUp"),onClick:a,icon:(0,Ft.jsx)(bs,{}),className:(0,Jr.default)(o.thumbsUp,r==="up"&&o.selected),disabled:!!r}),(0,Ft.jsx)(M.IconButton,{title:n("thumbsDown"),onClick:c,icon:(0,Ft.jsx)(xs,{}),className:(0,Jr.default)(o.thumbsDown,r==="down"&&o.selected),disabled:!!r})]})},Cs=Ng;var Oe=require("react/jsx-runtime"),Og=({onCopy:t})=>{let e=(0,Pe.useRef)(null),o=h("SummaryForm",sc),[n,s]=(0,Pe.useState)(""),r=k(qr),i=(0,uo.useSelector)(oc),a=(0,uo.useSelector)(ec),c=(0,uo.useSelector)(tc),l=(0,uo.useDispatch)(),d=()=>{l(Q({name:"summary copied to clipboard",data:{originalText:a,finalText:n,model:i},options:{includeConversationData:!0}})),t(n)},u=()=>{let p=document.getSelection();p&&l(Q({name:"summary copied to clipboard",data:{originalText:a,finalText:p==null?void 0:p.toString(),model:i},options:{includeConversationData:!0}}))};return(0,Pe.useEffect)(()=>{l(je())},[]),(0,Pe.useEffect)(()=>{s(a||"")},[a]),(0,Pe.useEffect)(()=>{e.current&&a&&e.current.focus()},[e,a]),(0,Pe.useEffect)(()=>{let p=m=>{m.key==="Enter"&&m.shiftKey&&d()};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[n]),(0,Oe.jsx)("div",{className:o.root,tabIndex:-1,children:c?(0,Oe.jsx)("p",{className:o.error,children:r("error")}):(0,Oe.jsxs)(Pe.Fragment,{children:[(0,Oe.jsx)("div",{className:o.main,children:(0,Oe.jsx)("textarea",{placeholder:a?void 0:r("loading"),disabled:!a,className:o.textInput,ref:e,value:n,onCopy:u,onChange:p=>s(p.target.value)})}),(0,Oe.jsxs)("div",{className:o.actions,children:[(0,Oe.jsx)(Cs,{eventName:"summary feedback",eventData:{summary:a}}),(0,Oe.jsx)(H.Button,{shortKeys:[8679,8629],onClick:d,children:r("copy")})]})]})})},dc=Og;var qo={};Z(qo,{enUS:()=>_g,nlNL:()=>Dg});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?"}]},Dg={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 pt=T(require("react")),Qo=require("react-redux");var Yr={};Z(Yr,{enUS:()=>Hg,nlNL:()=>Fg});var Hg={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"}]},Fg={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 uc={root:"to",title:"oi",empty:"ei",status:"ii",form:"no",input:"ao",submit:"ri",question:"ti",answer:"ni",alignRight:"ai",listItemFeedback:"pi"};var mo=require("@reduxjs/toolkit");var ws=require("@reduxjs/toolkit");var Kg={data:null,fetchState:"idle"},pc=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},Xo=(0,ws.createAsyncThunk)("knowledgeAssistant/getKnowledgeAssistant",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=(i=n.profile.data)==null?void 0:i.knowledgeAssistant;return r?o.getKnowledgeAssistant(r):null}),Ug=(0,ws.createSlice)({name:"knowledgeAssistant",initialState:Kg,reducers:{},extraReducers:t=>{t.addCase(Xo.pending,e=>{e.fetchState="loading"}).addCase(Xo.rejected,e=>{e.fetchState="error"}).addCase(Xo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),mc=Ug.reducer;var ei={data:[],fetchState:"idle"},gc=t=>{var e;return(e=t.answer)==null?void 0:e.data},fc=t=>t.answer.fetchState,go=(0,mo.createAction)("answer/resetKnowledgeSearch"),po=(0,mo.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var c,l,d;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=pc(e.getState()),r=(c=e.getState().conversation.current)==null?void 0:c.sessionId,i=(d=(l=e.getState().info)==null?void 0:l.agentInfo)==null?void 0:d.agentId;if(!s)throw new Error("KnowledgeAssistant is not defined");let a=await o.knowledgeAssist({customerInstruction:s.customerInstruction,doNotKnowAnswer:s.doNotKnowAnswer,question:t},n,s.code,{agentId:i,conversationId:r});return{question:t,answer:a}}),zg=(0,mo.createSlice)({name:"answer",initialState:ei,reducers:{},extraReducers:t=>{t.addCase(po.pending,e=>{e.fetchState="loading"}).addCase(po.rejected,e=>{e.fetchState="error"}).addCase(po.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(N,()=>ei).addCase(go,()=>ei)}}),hc=zg.reducer;var Zo=require("react/jsx-runtime"),yc=()=>(0,Zo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Zo.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Zo.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 te=require("react/jsx-runtime"),Vg=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=pt.default.useState(""),{setSelected:r}=ut(),i=(0,pt.useRef)(null),a=h("KnowledgeSearchStyles",uc),c=k(Yr),l=(0,Qo.useDispatch)(),d=(0,Qo.useSelector)(gc),u=(0,Qo.useSelector)(fc),p=async g=>{g.preventDefault(),g.stopPropagation(),n!==""&&l(po(n))},m=(g,f)=>{l(Q({name:"knowledge assist source viewed",data:{question:f,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return(0,pt.useEffect)(()=>{var g;o&&u==="idle"?l(po(o)):(g=i.current)==null||g.focus()},[i,u]),(0,pt.useEffect)(()=>{u==="done"&&(l(Q({name:"knowledge assist question answered",data:{question:n||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),r(`knowledge-assist-${d.length-1}`),s(""))},[u,d]),(0,pt.useEffect)(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,d]),(0,te.jsxs)("div",{className:a.root,children:[d.length>0&&(0,te.jsx)("div",{className:a.alignRight,children:(0,te.jsx)(H.Button,{onClick:e,children:c("reset")})}),d.map(({question:g,answer:f},y)=>(0,te.jsx)(H.List,{children:(0,te.jsx)(H.ListItem,{id:`knowledge-assist-${y}`,"data-testid":"knowledge-search-answer",description:f.answer,closeOnSelect:!0,onClick:()=>t(f.answer),onSourceClick:P=>m(P,g),sources:f.sources,styles:{title:a.question,description:a.answer},extra:(0,te.jsx)("div",{className:a.listItemFeedback,children:(0,te.jsx)(Cs,{eventName:"knowledge assist feedback",eventData:{question:g,isAgent:o!==g,isFollowUpQuestion:d.length>1,...f}})}),children:g})},`${f.answer}_${y}`)),u==="loading"&&(0,te.jsx)("p",{className:a.status,children:c("loading")}),u==="error"&&(0,te.jsx)("p",{className:a.status,children:c("error")}),(0,te.jsxs)("form",{className:a.form,onSubmit:p,children:[(0,te.jsx)("input",{ref:i,placeholder:c("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(void 0)},onChange:g=>{r(void 0),s(g.target.value)}}),(0,te.jsx)("button",{type:"submit",className:a.submit,children:(0,te.jsx)(yc,{})})]})]})},vc=Vg;var Ts=require("@reduxjs/toolkit");var $g={data:null,fetchState:"idle"},Xe=t=>t.profile.data,Es=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],Jo=(0,Ts.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)}),Wg=(0,Ts.createSlice)({name:"profile",initialState:$g,reducers:{},extraReducers:t=>{t.addCase(Jo.pending,e=>{e.fetchState="loading"}).addCase(Jo.rejected,e=>{e.fetchState="error"}).addCase(Jo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Sc=Wg.reducer;var Pc=require("react");var Ic=require("react-redux");var Bt=require("@reduxjs/toolkit");var Gg=["{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}"],jg=new RegExp(Gg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function xc(t,e){let o=t.split(jg),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],c=r===o.length-2;n+=i.length;let l=n;if(c){let u=a.charAt(0),p=0;do l=u?e.indexOf(u,l+1):-1,p+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&p>2)return t}else l=a&&a!==""?e.indexOf(a,n):-1;let d=l===-1?e.slice(n):e.slice(n,l);s.push(d),n=l}return s.join("")}function bc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var wc={suggestions:[],fetchState:"idle"},Cc={default:wc},Tc=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},ks=t=>t.textSuggestions,Ec=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},Rs=(0,Bt.createAction)("textSuggestions/refresh"),Ie=(0,Bt.createAsyncThunk)("textSuggestions/recommendations",async(t,e)=>{var l;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(l=n.conversation.current)==null?void 0:l.id,{textSuggestionsCount:r,inlineSuggestions:i}=n.settings,a=oo(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let c=await o.getTextSuggestions(s,Oo(n),t);if(t==="default"){let d=i?c.filter(Ec(a)):c;e.dispatch(Me(d.slice(0,r)))}return c}),Yo=(0,Bt.createAsyncThunk)("textSuggestions/autocompletions",async(t,e)=>{var l;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(l=n.conversation.current)==null?void 0:l.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let c=await o.getAutocompleteSuggestions(s,{...Oo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(c=c.filter(Ec(t))),i&&(c=c.map(d=>({...d,text:d.source!=="trie-with-typos"?xc(d.text,t):d.text}))),c=bc(c,r),e.dispatch(Me(c)),c}),kc=(0,Bt.createSlice)({name:"textSuggestions",initialState:Cc,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(Ie.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||wc;return{...e,[n]:{...s,fetchState:"loading"}}}).addCase(Ie.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Ie.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Yo.pending,e=>{e.default.fetchState="loading"}).addCase(Yo.rejected,e=>{e.default.fetchState="error"}).addCase(Yo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(N,()=>Cc)}}),{setTextSuggestions:mb,setSuggestionState:gb}=kc.actions,Rc=kc.reducer;var ti=require("react-redux");var Kt=require("react/jsx-runtime"),qg=({commands:t,onClick:e})=>{var a,c,l;let o=(0,Ic.useDispatch)(),n=k(qo),s=(0,ti.useSelector)(Xe),r=(0,ti.useSelector)(ks),i=((l=(c=(a=s==null?void 0:s.uiConfig)==null?void 0:a.search)==null?void 0:c.initialTypes)==null?void 0:l.filter(({isActive:d})=>d))||[];return(0,Pc.useEffect)(()=>{i.forEach(({type:d})=>{(!r[d]||r[d].suggestions.length===0)&&o(Ie(d))})},[]),(0,Kt.jsxs)("div",{children:[t.length>0&&(0,Kt.jsx)(H.List,{heading:n("commands"),children:t.map((d,u)=>(0,Kt.jsx)(H.ListItem,{id:`command-${u}`,closeOnSelect:!1,onClick:d.onClick,children:d.label},d.label))}),i.map(({type:d,title:u})=>{var p;return(0,Kt.jsx)(H.List,{heading:u,orientation:"vertical",children:(p=r[d])==null?void 0:p.suggestions.map((m,g)=>(0,Kt.jsx)(H.ListItem,{id:`${d}-${g}`,closeOnSelect:!1,description:m.text,onClick:()=>e(m.text,m),"data-testid":"search-overlay-suggestion",children:m.title},`${m.id}-${m.text}`))},d)})]})},Lc=qg;var G=require("react/jsx-runtime"),Zg=200,Qg=5,Jg=4,Ac=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Yg=()=>{let t=(0,_e.useDispatch)(),e=he(),o=k(qo),[n,s]=(0,re.useState)(!1),[r,i]=(0,re.useState)(""),a=(0,_e.useSelector)(el),c=(0,_e.useSelector)(Xe),[l,d]=(0,re.useState)(),u=(0,_e.useSelector)(ee),p=b("showSearch"),m=b("showEntitiesCommand"),g=b("showSummaryCommand"),f=b("showKnowledgeSearch"),y=b("showImageSearch"),P=b("searchTriggerKey"),v=(0,_e.useSelector)(kl),S=(0,_e.useSelector)(tl),I=(0,_e.useSelector)(ol),x=(0,_e.useSelector)(Ya),E=C=>gr(S.filter(X=>X.type===C.toUpperCase()),C),O=[{value:"PERSONAL",label:o("personalSuggestions"),list:E("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:E("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:E("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:E("IMAGE"),listOrientation:"horizontal",shouldShow:y}].filter(C=>C.shouldShow),j=[{label:o("entitiesClipboard"),onClick:()=>t(we("entities")),shouldShow:m&&Ac(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(we("summary")),shouldShow:g&&Ac(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(we("knowledgeAssist")),shouldShow:f}].filter(C=>C.shouldShow),V=(v==null?void 0:v.map(C=>({value:C.code.toUpperCase(),label:`${C.name}s`,list:E(C.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],L=(0,re.useCallback)((0,Mc.default)((C,X)=>{t(It({query:C,type:X,tags:["search-overlay"],size:l?50:20}))},Zg),[l]),_=(0,re.useCallback)((C,X)=>{switch(X.type){case"IMAGE":e.send(Rr,{suggestion:X});break;default:e.send(ct,{text:C,suggestion:X})}t(ce(!1))},[t]),q=C=>{Mt(C.text),t(Q({name:"entity copied",data:{entity:C,type:"copy"}})),t(ce(!1))},ge=(0,re.useCallback)(C=>{t(Q({name:"suggestion feedback",data:{text:C.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),Mp=C=>{e.send(ct,{text:C,suggestion:{source:"knowledge-assist",text:C}}),t(Q({name:"answer used",data:{originalText:C},options:{includeConversationData:!0}})),i(""),t(we("search")),t(go()),t(ce(!1))},Np=C=>{Mt(C),t(ce(!1))};function gr(C,X){return C.slice(0,l?10:X.toLowerCase()==="image"?Jg:Qg)}function Po(C){return X=>{n?window.confirm(o("warning"))&&(C(X),s(!1)):C(X)}}return(0,re.useEffect)(()=>{r?L(r,l):t($n())},[r,l]),(0,re.useEffect)(()=>{a==="search"&&t(go())},[a]),(0,re.useEffect)(()=>{u&&t(zo())},[u]),ql(P,()=>t(ce(!0))),!p||!c?null:(0,G.jsxs)(H,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Po(C=>t(ce(C))),onChangeType:C=>d(C),onChangePage:Po(C=>t(we(C))),selectedType:l,search:r,page:a,isOpen:x,types:[...V,...O],children:[(0,G.jsxs)(H.Page,{id:"search",children:[r.length===0&&(0,G.jsx)(Lc,{commands:j,onClick:_}),r.length>0&&(0,G.jsxs)(re.Fragment,{children:[j.length>0&&(0,G.jsx)(H.List,{heading:o("commands"),children:j.map((C,X)=>(0,G.jsx)(H.ListItem,{closeOnSelect:!1,onClick:C.onClick,id:`commands-${X}`,children:C.label},C.label))}),[...V,...O].map(({value:C,label:X,list:ji,lineClamp:Op,listOrientation:_p})=>(0,G.jsx)(H.List,{heading:X,orientation:_p==="horizontal"?"horizontal":"vertical",onShowAll:()=>d(C),hasMore:!l&&I[C.toLowerCase()]>gr(ji,C).length,children:gr(ji,C).map(ae=>(0,G.jsx)(H.ListItem,{id:`${C}-${ae.id}`,closeOnSelect:!1,lineClamp:Op,onClick:()=>_(ae.text,ae),description:C!=="IMAGE"?ae.title&&ae.text:void 0,onFeedback:C!=="IMAGE"?()=>ge(ae):void 0,children:C==="IMAGE"?(0,G.jsx)(H.Image,{title:ae.title||ae.text,src:ae.image}):ae.title||ae.text},`${ae.id}-${ae.text}`))},C))]})]}),(0,G.jsx)(H.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:Po(()=>{t(we("search"))}),children:(0,G.jsx)(Jl,{onCopy:q})}),(0,G.jsx)(H.Page,{id:"summary",title:o("summaryTitle"),onDismiss:Po(()=>{t(we("search"))}),children:(0,G.jsx)(dc,{onCopy:Np})}),(0,G.jsx)(H.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:Po(()=>{t(go()),t(we("search"))}),children:(0,G.jsx)(vc,{question:r,onUse:Mp,onResetQuestion:()=>{t(go()),i("")}})})]})},Nc=Yg;var en=require("react/jsx-runtime"),ef=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,en.jsxs)(Oc.Fragment,{children:[t&&(0,en.jsx)(Nc,{}),e&&(0,en.jsx)(Tl,{})]})},_c=ef;var Bc=T(require("classnames")),Kc=require("react-redux");var Ps=require("react/jsx-runtime"),Dc=({className:t})=>(0,Ps.jsx)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:t,children:(0,Ps.jsx)("g",{children:(0,Ps.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
3
|
+
`,At.MISSING_INTL_API,i);var I=o.getPluralRules(e,{type:d.pluralType}).select(p-(d.offset||0));S=d.options[I]||d.options.other}if(!S)throw new Nr(d.value,p,Object.keys(d.options),i);a.push.apply(a,Ko(S.value,e,o,n,s,p-(d.offset||0)));continue}}return Nm(a)}function _m(t,e){return e?de(de(de({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=de(de({},t[n]),e[n]||{}),o},{})):t}function Dm(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=_m(t[n],e[n]),o},de({},t)):t}function Or(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Hm(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:os(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:Or(t.number),strategy:ns.variadic}),getDateTimeFormat:os(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:Or(t.dateTime),strategy:ns.variadic}),getPluralRules:os(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:Or(t.pluralRules),strategy:ns.variadic})}}var yl=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(l){var d=r.formatToParts(l);if(d.length===1)return d[0].value;var u=d.reduce(function(p,m){return!p.length||m.type!==J.literal||typeof p[p.length-1]!="string"?p.push(m.value):p[p.length-1]+=m.value,p},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(l){return Ko(r.ast,r.locales,r.formatters,r.formats,l,void 0,r.message)},this.resolvedOptions=function(){var l;return{locale:((l=r.resolvedLocale)===null||l===void 0?void 0:l.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,c=cl(i,["formatters"]);this.ast=t.__parse(e,de(de({},c),{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=Dm(t.formats,n),this.formatters=s&&s.formatters||Hm(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=pl,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 Fm(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Bm="dummy",_r=(0,ss.createContext)(null);function k(t){let e=(0,ss.useContext)(_r);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=Fm(o,n);return r?new yl(r).format(s):(e!==Bm&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var rs=require("react");var vl={root:"J",content:"Po"};var Dr=require("react/jsx-runtime"),Um=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,onKeyDown:r,overlayAriaLabel:i,contentAriaLabel:a})=>{let c=(0,rs.useRef)(null),l=h("Dialog",vl),d=p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),s();return}r&&r(p)},u=p=>{p.target===c.current&&t&&n()};return(0,rs.useEffect)(()=>{var p,m;!c.current||!t||!e||(m=(p=c.current)==null?void 0:p.querySelector("input, textarea"))==null||m.focus()},[t,e,c]),t?(0,Dr.jsx)("div",{role:"dialog","data-testid":"dialog",className:l.root,"aria-label":i,ref:c,onKeyDown:d,onMouseDown:u,children:(0,Dr.jsx)("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:o})}):null},is=Um;var xl=T(require("classnames"));var Sl={root:"y"};var bl=require("react/jsx-runtime"),Vm=({className:t,value:e,...o})=>{let n=h("TextInput",Sl);return(0,bl.jsx)("input",{className:(0,xl.default)(t,n.root),type:"text",value:e,...o})},Uo=Vm;var Hr={};Z(Hr,{enUS:()=>$m,nlNL:()=>Wm});var $m={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},Wm={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 Cl={root:"Qo",anchorButton:"Vo",errorMessage:"Wo",title:"Zo",subtitle:"_o",text:"oe",input:"ee",actions:"ie",button:"w",primaryButton:"re"};var K=require("react/jsx-runtime");var jm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},qm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=k(Hr),i=h("LoginTokenDialog",Cl),a=(0,ls.useSelector)(Ca),c=(0,ls.useDispatch)(),l=b("productName"),[d,u]=(0,Ee.useState)(t||""),[p,m]=(0,Ee.useState)(0),[g,f]=(0,Ee.useState)(""),y=(0,Ee.useCallback)(async I=>{I.preventDefault(),c(Ta({email:d})),m(1)},[o,d]),P=()=>{f(""),m(0)},v=(0,Ee.useCallback)(async I=>{I.preventDefault();let x=jm(I.target.elements.token.value);if(!x){f(r("verifyCodeError",{login:S}));return}c(Ao({token:x}))},[o]),S=(0,Ee.useMemo)(()=>I=>(0,K.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:P,children:I},"back-button"),[]);return(0,Ee.useEffect)(()=>{a==="error"&&f(r("verifyCodeError",{login:S})),a==="done"&&n()},[a]),(0,K.jsx)(is,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:l}),overlayAriaLabel:r("promptTitle",{productName:l}),onClose:s,onBack:s,children:(0,K.jsxs)("div",{className:i.root,children:[(0,K.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:l})}),p===0&&(0,K.jsxs)("form",{onSubmit:y,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:l})}),(0,K.jsx)(Uo,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:d,onChange:I=>u(I.target.value)}),(0,K.jsx)("div",{className:i.actions,children:(0,K.jsx)("button",{type:"submit",className:(0,as.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),p===1&&(0,K.jsxs)("form",{onSubmit:v,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,K.jsx)(Uo,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),g&&(0,K.jsx)("div",{className:i.errorMessage,children:g}),(0,K.jsxs)("div",{className:i.actions,children:[(0,K.jsx)("button",{type:"button",className:(0,as.default)(i.button),onClick:P,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,as.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},wl=qm;var El=require("react/jsx-runtime"),Xm=()=>{let t=(0,Fr.useSelector)(wa),e=(0,Fr.useSelector)(Xa),o=b("adminUrl"),n=he(),s=()=>n.send(so,!1),r=()=>{n.send(so,!1),n.send(_o)};return(0,El.jsx)(wl,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Tl=Xm;var Mc=T(require("lodash.debounce")),re=require("react"),_e=require("react-redux");var cs=require("@reduxjs/toolkit");var Zm={data:null,fetchState:"idle"},kl=t=>t.contentTypes.data,zo=(0,cs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Qm=(0,cs.createSlice)({name:"contentTypes",initialState:Zm,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})}}),Rl=Qm.reducer;function Mt(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 Ge=require("react");var Pl=require("react"),ds=T(require("classnames"));var ye={root:"te",list:"ne",listWrapper:"ae",listHorizontal:"K",page:"v",search:"P",pageNav:"pe",pageTitle:"de",pageBackButton:"Q",listHeader:"le",listHeading:"se",listMoreButton:"ce",listItem:"V",listItemContent:"a",listItemText:"xe",listItemDescription:"fe",listItemActions:"W",truncate:"ge",lineClamp:"be",listItemTitle:"he",listItemAction:"me",listItemPrimaryAction:"ue",listItemSelected:"ye",sources:"we",sourcesTitle:"ve",source:"ke",icon:"Z",searchIcon:"ze",searchInputWrapper:"je",searchInput:"k",select:"Ye",selectType:"qe",selectWrapper:"z",image:"Ce",imageSrc:"Se",imageSrcHidden:"Ee",imageSrcStatus:"Ge",imageTitle:"Ne",actions:"Ae",actionsWrapper:"Fe",actionsBar:"He",actionButton:"_",hasShortKeys:"Le",actionShortcut:"Me",actionShortcutFixKerning:"Re"};var Nt={};Z(Nt,{enUS:()=>Ym,nlNL:()=>eg});var Ym={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}]},eg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}]};var dt=require("react/jsx-runtime"),tg=({src:t,title:e})=>{let o=h("CommandPalette",ye),[n,s]=(0,Pl.useState)("loading"),r=k(Nt);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,ds.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,dt.jsx)("span",{className:(0,ds.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,dt.jsx)("span",{className:(0,ds.default)(o.imageSrc,o.imageSrcStatus),children:(0,dt.jsx)(wn,{})}),e&&(0,dt.jsx)("span",{className:o.imageTitle,children:e})]})},Il=tg;var Ll=T(require("react")),Al=T(require("classnames"));var Ot=require("react/jsx-runtime");function Br({children:t,heading:e,orientation:o,hasMore:n,onShowAll:s}){let r=k(Nt),i=h("CommandPalette",ye);return Ll.default.Children.count(t)===0?null:(0,Ot.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||n)&&(0,Ot.jsxs)("div",{className:i.listHeader,children:[e&&(0,Ot.jsx)("h4",{className:i.listHeading,children:e}),n&&s&&(0,Ot.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,Ot.jsx)("div",{className:(0,Al.default)(i.listWrapper,o==="horizontal"&&i.listHorizontal),children:t})]})}var Vo=T(require("classnames")),zl=require("interweave");var og=/[.*+?^${}()|[\]\\]/g,ng=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function sg(t){return t.replace(og,"\\$&")}function rg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function ig(t){return t.search(ng)}function Ml(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${sg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function Nl(t){return t.replace(Ln,'<mark data-type="placeholder">$1</mark>')}function ro(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ag(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 Kr(t,e,o={}){if(e){let n=rg(e.toLowerCase(),t.toLowerCase()),s=ro(t.substring(n,t.length));if(o.stripAgentPart){let c=t.substring(0,n),l=ig(c);return`<span style="opacity: 0.5">${c.substring(l+1)}</span>${s}`}let i=e.split(fa).length>3||e.length>30?ag(e.trim(),n):0;return`${`${i>0?"\u2026":""}${ro(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var lg=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function us(t){return lg.test(t)}function Ol(t){let e=document.createElement("template");return e.innerHTML=t,e.content.textContent??""}var W=T(require("react")),_l=T(require("classnames"));var Ur={root:"Te",trigger:"oo",content:"Ue",contentOpen:"Be",contentTop:"De",contentBottom:"Ie",item:"eo"};var _t=require("react/jsx-runtime"),dg=0,Dl=W.default.createContext(null),ug=()=>{let t=(0,W.useContext)(Dl);if(!t)throw new Error("Invalid DropdownContext");return t},Hl=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,W.useMemo)(()=>++dg,[]),s=(0,W.useRef)(null),r=(0,W.useRef)(null),i=h("Dropdown",Ur),[a,c]=(0,W.useState)(!1),[l,d]=(0,W.useState)(o),u=m=>{m.preventDefault(),m.stopPropagation(),c(!a)},p=(0,W.useCallback)(([m])=>{!m.isIntersecting&&a&&d(l==="top"?"bottom":"top")},[a]);return(0,W.useEffect)(()=>{let m=g=>{s.current&&!s.current.contains(g.target)&&c(!1)};return document.addEventListener("click",m),()=>{document.removeEventListener("click",m)}},[]),(0,W.useEffect)(()=>{if(!r.current&&!a)return()=>{};let m=new IntersectionObserver(p,{root:null,rootMargin:"0px",threshold:1});return r.current&&m.observe(r.current),()=>{r.current&&m.unobserve(r.current)}},[r,a]),(0,_t.jsx)(Dl.Provider,{value:{setIsOpen:c},children:(0,_t.jsxs)("div",{ref:s,className:i.root,children:[(0,_t.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,_t.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,_l.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:l==="top",[i.contentBottom]:l==="bottom"}),children:e})]})})};function pg({as:t,children:e,onClick:o,...n}){let s=t||"button",r=h("Dropdown",Ur),{setIsOpen:i}=ug(),a=c=>{i(!1),o(c),c.stopPropagation()};return(0,_t.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Hl.Item=pg;var zr=Hl;var Vr=require("react/jsx-runtime"),Fl=t=>(0,Vr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,Vr.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 Dt={};Z(Dt,{enUS:()=>mg,nlNL:()=>gg});var mg={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"}]},gg={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 ps=require("react/jsx-runtime"),fg="%0d%0a%0d%0a%0d%0a",hg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(fg)}`},yg=({suggestion:t,onFeedback:e})=>{let o=k(Dt),n=b("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,ps.jsx)(zr,{trigger:(0,ps.jsx)(Fl,{"data-testid":"feedback-dropdown-trigger"}),children:(0,ps.jsx)(zr.Item,{as:"a",href:hg(n,t),onClick:e,children:o("giveFeedback")})})},ms=yg;var gs=T(require("react")),Ul=require("react/jsx-runtime"),Bl=gs.default.createContext(void 0);function ut(){let t=gs.default.useContext(Bl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Kl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=gs.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,Ul.jsx)(Bl.Provider,{value:i,children:t})};var ue=require("react/jsx-runtime");function $r({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,extra:r,onSourceClick:i,description:a,sources:c,id:l,styles:d,...u}){let{selected:p,onChangeOpen:m}=ut(),g=h("CommandPalette",ye);function f(y){n(y),t&&m(!1)}return(0,ue.jsxs)("div",{className:(0,Vo.default)(g.listItem,l===p&&g.listItemSelected),children:[(0,ue.jsx)("button",{type:"button",className:(0,Vo.default)(g.listItemAction,g.listItemPrimaryAction),"aria-disabled":u.disabled??!1,onClick:f,"data-command-palette-item":!0,"data-item-id":l,...u,children:(0,ue.jsxs)("div",{className:g.listItemContent,children:[typeof o=="string"?(0,ue.jsx)("p",{className:(0,Vo.default)(g.listItemText,g.truncate,d==null?void 0:d.title),children:o}):o,a&&(0,ue.jsx)(zl.Interweave,{tagName:"p",allowList:[],content:us(a)?Ol(a):a,className:(0,Vo.default)(g.listItemDescription,d==null?void 0:d.description,e?g.lineClamp:g.truncate)})]})}),r,s&&(0,ue.jsx)("div",{className:g.listItemActions,children:(0,ue.jsx)(ms,{suggestion:String(o),onFeedback:s})}),c&&c.length>0&&(0,ue.jsxs)("div",{className:g.sources,children:[(0,ue.jsx)("span",{className:g.sourcesTitle,children:"Sources"}),c.map(y=>y.url?(0,ue.jsx)("a",{className:g.source,href:y.url,target:"_blank",title:y.url,rel:"noopener noreferrer",onClick:()=>i&&i(y),children:y.name},y.url):(0,ue.jsx)("span",{className:g.source,children:y.name},y.name))]})]})}var $o=require("react/jsx-runtime"),Vl=()=>(0,$o.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,$o.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,$o.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 Ht=require("react/jsx-runtime");function Wr({children:t,title:e,id:o,onDismiss:n}){let s=k(Nt),r=h("CommandPalette",ye),{page:i}=ut();return i!==o?null:(0,Ht.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,Ht.jsxs)("div",{className:r.pageNav,children:[(0,Ht.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,Ht.jsx)(Vl,{}),s("back")]}),e&&(0,Ht.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var $l=require("react");var Wo=require("react/jsx-runtime"),io=()=>(0,Wo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Wo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Wo.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});var ke=require("react/jsx-runtime");function vg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let c=h("CommandPalette",ye);return(0,ke.jsxs)("div",{className:c.search,children:[(0,ke.jsx)("div",{className:c.searchIcon,children:(0,ke.jsx)(io,{})}),(0,ke.jsxs)("div",{className:c.searchInputWrapper,children:[(0,ke.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:l=>{t(l.currentTarget.value)},onFocus:l=>{l.currentTarget.select()},className:c.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&(0,ke.jsx)("div",{className:c.selectWrapper,children:(0,ke.jsxs)("select",{"data-testid":"command-palette-type-select",className:c.select,onChange:l=>e(l.target.value===n?void 0:l.target.value),value:i||n,children:[n&&(0,ke.jsx)("option",{children:n}),s.map(l=>(0,ke.jsx)("option",{value:l.value,children:l.label},l.value))]})})]})]})}var Wl=(0,$l.forwardRef)(vg);var Gr=T(require("classnames"));var fs=require("react/jsx-runtime"),Sg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=h("CommandPalette",ye);return(0,fs.jsxs)("button",{type:"button",...n,onClick:t,className:(0,Gr.default)(s.actionButton,n.className,{[s.hasShortKeys]:e&&e.length>0}),children:[o,e&&e.map(r=>(0,fs.jsx)("span",{className:(0,Gr.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},Gl=Sg;var Go=require("react/jsx-runtime"),xg="[data-command-palette-item]";function ao({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:c,types:l,children:d,isOpen:u,search:p}){let[m,g]=(0,Ge.useState)(),f=(0,Ge.useRef)(null),y=()=>{s&&s(o),i(void 0),r(""),a(!1)},P=()=>{var L;if(n!==o&&s){s(o);return}if(c&&i){i(void 0),(L=f.current)==null||L.focus();return}if(p.length>0){r("");return}a(!1)},v=()=>{let L=S();L.length!==0&&g(L[0].dataset.itemId)},S=()=>Array.from(document.querySelectorAll(xg)||[]),I=L=>document.querySelector(`[data-item-id=${L}]`),x=L=>{let _=I(L);_&&g(_.dataset.itemId)},E=L=>{let _=I(L);_&&_.scrollIntoView({behavior:"smooth"})},O=()=>{if(!m)return;let L=S(),_=I(m);if(!_)return;let q=L.indexOf(_),ge=L[q+1];ge&&ge.dataset.itemId?x(ge.dataset.itemId):v()},j=()=>{if(!m)return;let L=S(),_=I(m);if(!_)return;let q=L.indexOf(_),ge=L[q-1];ge&&ge.dataset.itemId?x(ge.dataset.itemId):x(L[L.length-1].dataset.itemId)},V=(0,Ge.useCallback)(L=>{switch(L.key){case"ArrowDown":{L.preventDefault(),O();break}case"ArrowUp":{L.preventDefault(),j();break}case"Enter":{if(m){let _=I(m);_==null||_.click()}break}}},[m]);return(0,Ge.useEffect)(()=>{v()},[p,n,c,u]),(0,Ge.useEffect)(()=>{m&&E(m)},[m]),(0,Go.jsx)(is,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:P,onClose:y,onKeyDown:V,children:(0,Go.jsxs)(Kl,{selected:m,setSelected:g,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&(0,Go.jsx)(Wl,{ref:f,onChange:r,onChangeType:i,placeholder:t,value:p,selectedType:c,types:l,typePlaceholder:e}),d]})})}ao.Page=Wr;ao.List=Br;ao.Image=Il;ao.ListItem=$r;ao.Button=Gl;var H=ao;var jl=require("react");function ql(t,e){(0,jl.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 jo=require("react"),vs=require("react-redux");var hs=require("@reduxjs/toolkit");var Xl={data:null,fetchState:"idle"},ys=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,hs.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)}),bg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Cg=(0,hs.createSlice)({name:"entities",initialState:Xl,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=bg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(N,()=>Xl)}}),Zl=Cg.reducer;var jr={};Z(jr,{enUS:()=>wg,nlNL:()=>Tg});var wg={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Tg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Ql={root:"Oe",empty:"Xe"};var lo=require("react/jsx-runtime"),kg=({onCopy:t})=>{let e=(0,jo.useRef)(null),o=h("EntitiesList",Ql),n=(0,vs.useSelector)(ys),{setSelected:s}=ut(),r=k(jr),i=(0,vs.useDispatch)();return(0,jo.useEffect)(()=>{i(Re())},[]),(0,jo.useEffect)(()=>{e.current&&(e.current.focus(),s("entity-0"))},[e]),(0,lo.jsxs)("div",{className:o.root,ref:e,tabIndex:-1,children:[n&&n.length>0&&(0,lo.jsx)(H.List,{children:n.map((a,c)=>(0,lo.jsx)(H.ListItem,{id:`entity-${c}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),n&&n.length===0&&(0,lo.jsx)("p",{className:o.empty,children:r("noResults")})]})},Jl=kg;var Pe=require("react"),uo=require("react-redux");var Ss=require("@reduxjs/toolkit");var Yl={data:null,fetchState:"idle"},ec=t=>t.summary.data,tc=t=>t.summary.fetchState==="error",oc=t=>t.summary.model,je=(0,Ss.createAsyncThunk)("summary/getSummary",async(t,e)=>{var d,u,p;let o=e.getState().profile.data,n=(d=e.getState().conversation.current)==null?void 0:d.sessionId,s=(p=(u=e.getState().info)==null?void 0:u.agentInfo)==null?void 0:p.agentId;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:i}=e.extra;if(!i.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let a=i.conversationQuery,c=await a();if(c.length===0)return Promise.reject(new Error("No messages are included"));let l=await r.getSummary(c,{externalConversationId:n,agentId:s,promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return l.summary?l:Promise.reject(new Error("Summary is not provided"))}),Rg=(0,Ss.createSlice)({name:"summary",initialState:Yl,reducers:{},extraReducers:t=>{t.addCase(je.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(je.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(je.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary,e.model=o.payload.model)}).addCase(N,()=>Yl)}}),nc=Rg.reducer;var qr={};Z(qr,{enUS:()=>Pg,nlNL:()=>Ig});var Pg={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."}]},Ig={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 sc={root:"Je",actions:"Ke",main:"Pe",textInput:"io",loading:"Qe",error:"Ve"};var Jr=T(require("classnames")),cc=require("react");var Xr=require("react/jsx-runtime"),xs=t=>(0,Xr.jsx)("svg",{width:"16",height:"16",fill:"#000000",...t,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Xr.jsx)("path",{fillRule:"evenodd",d:"M6.57086468,14.9173453 C6.38997052,14.9711236 6.19835748,15 6,15 L4,15 C2.8954305,15 2,14.1045695 2,13 L2,4 C2,2.8954305 2.8954305,2 4,2 L6,2 C6.68685475,2 7.29284112,2.34623869 7.65294381,2.87370078 C7.95642355,2.67736738 8.29504785,2.51351337 8.66312366,2.3818197 C9.50544052,2.08044754 10.3408482,1.9879107 10.9989281,1.99971266 C11.0150698,2.00005426 13.3487605,2.00015005 18,2 C20.7551411,2 22,6.05643086 22,12 C22,13.6824804 20.8695981,15 19,15 L15.9269768,15 C15.9359266,15.0245465 15.9451954,15.0497804 15.9547911,15.0757271 C16.007193,15.2174219 16.2391583,15.8256341 16.2970775,15.9810953 C16.4872151,16.4914441 16.6259612,16.9026411 16.7382242,17.3098712 C16.9079007,17.9253665 17,18.4798886 17,19 C17,20.4720069 16.091867,21.3862822 14.748281,21.777514 C14.1422801,21.9539723 13.6147967,22.0000922 13.0076976,22.0000008 L12.5204954,22 L12.2202699,21.6261158 C11.2556275,20.4248034 7.64562469,16.4822788 6.57086468,14.9173453 Z M8,13 C8,13.2401953 8.04443154,13.4528921 8.14171093,13.6800176 C8.40663864,14.2985643 11.914268,18.1371493 13.4599624,19.9848695 C13.7113931,19.9660111 13.9483736,19.9273712 14.1891338,19.8572655 C14.7621788,19.6904035 15,19.4509737 15,19 C15,18.6834183 14.9359344,18.2976852 14.8101464,17.8413935 C14.7161494,17.500423 14.5944107,17.1396301 14.4229225,16.6793379 C14.3689242,16.5344009 14.1358033,15.923159 14.0789589,15.7694517 C13.9489218,15.4178313 13.8632547,15.1589343 13.8046536,14.9236885 C13.5555377,13.9236468 13.8054549,13 15,13 L19,13 C19.6912225,13 20,12.6401099 20,12 C20,7.20925475 19.015127,4 18,4 C15.9322103,4 15.9322103,4 10.9655994,3.99940813 C10.5253746,3.99154158 9.91062406,4.05963657 9.33687634,4.2649175 C8.45196659,4.58152894 8,5.09776992 8,6 L8,13 Z M4,4 L4,13 L6,13 L6,4 L4,4 Z"})});var Zr=require("react/jsx-runtime"),bs=t=>(0,Zr.jsx)("svg",{width:"16",height:"16",fill:"#000000",...t,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Zr.jsx)("path",{fillRule:"evenodd",d:"M7.65336736,21.1256786 C7.2933164,21.6534897 6.68712411,22 6,22 L4,22 C2.8954305,22 2,21.1045695 2,20 L2,11 C2,9.8954305 2.8954305,9 4,9 L6,9 C6.198171,9 6.38961023,9.02882212 6.57035446,9.08250314 C7.6444817,7.51807482 11.2554748,3.57449216 12.2202699,2.37298955 L12.5204954,1.99910538 L13,1.99910538 C13.6147967,1.99901314 14.1422801,2.04513312 14.748281,2.22159137 C16.091867,2.61282321 17,3.52709845 17,4.99910538 C17,5.51921677 16.9079007,6.07373891 16.7382242,6.68923415 C16.6259612,7.09646424 16.4872151,7.50766133 16.2970775,8.01801005 C16.2391583,8.17347129 16.007193,8.78168345 15.9547911,8.92337824 C15.9451954,8.94932503 15.9359266,8.9745589 15.9269768,8.99910538 L19,8.99910538 C20.8695981,8.99910538 22,10.316625 22,11.9991054 C22,17.9426745 20.7551411,21.9991054 18,21.9991054 L11.0344006,21.9985135 C10.3408482,22.0111947 9.50544052,21.9186578 8.66312366,21.6172857 C8.29521907,21.4856533 7.9567386,21.3218904 7.65336736,21.1256786 Z M8,17.9991054 C8,18.9013355 8.45196659,19.4175764 9.33687634,19.7341879 C9.91062406,19.9394688 10.5253746,20.0075638 10.963066,19.9997143 C10.9703499,19.9995545 10.9703499,19.9995545 11,19.9991054 L18,19.9991054 C19.015127,19.9991054 20,16.7898506 20,11.9991054 C20,11.3589955 19.6912225,10.9991054 19,10.9991054 L15,10.9991054 C13.8054549,10.9991054 13.5555377,10.0754586 13.8046536,9.07541689 C13.8632547,8.84017106 13.9489218,8.5812741 14.0789589,8.22965366 C14.1358033,8.07594642 14.3689242,7.46470447 14.4229225,7.31976744 C14.5944107,6.85947528 14.7161494,6.4986824 14.8101464,6.1577119 C14.9359344,5.70142019 15,5.31568707 15,4.99910538 C15,4.54813166 14.7621788,4.30870189 14.1891338,4.1418399 C13.9483736,4.07173418 13.7113931,4.0330943 13.4599624,4.01423587 C11.914268,5.86195611 8.40663864,9.70054105 8.14171093,10.3190878 C8.04443154,10.5462133 8,10.7589101 8,10.9991054 L8,17.9991054 Z M4,11 L4,20 L6,20 L6,11 L4,11 Z"})});function qe(t,e){var n;let o=t.cloneNode(!0);o.style.top=`${t.offsetTop}px`,o.style.left=`${t.offsetLeft}px`,o.style.position="absolute",o.classList.add(e),o.addEventListener("animationend",()=>o.remove()),(n=t.parentElement)==null||n.appendChild(o)}var Qr={};Z(Qr,{enUS:()=>Ag,nlNL:()=>Mg});var Ag={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},Mg={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var ac=require("react-redux");var rc=require("@reduxjs/toolkit");function ic(t){return(0,rc.createAsyncThunk)("analytics/logEvent",(e,o)=>{var r,i,a;let n=(i=(r=o.getState())==null?void 0:r.conversation.current)==null?void 0:i.id,s=(a=o.getState())==null?void 0:a.info.agentInfo;return o.extra.deepdeskAPI.sendEvent(e.name,{conversationId:n,...s,data:e.data})})(t)}function co(){let t=(0,ac.useDispatch)();return async(e,o)=>{await t(ic({name:e,data:o}))}}var lc={fadeup:"j",fadedown:"Y",thumbs:"We",selected:"ro",thumbsUp:"Ze",thumbsDown:"_e"};var Ft=require("react/jsx-runtime"),Og=({eventName:t,eventData:e})=>{let o=h("FeedbackThumbs",lc),n=k(Qr),s=co(),[r,i]=(0,cc.useState)(null),a=l=>{l.preventDefault(),l.stopPropagation(),qe(l.target,o.fadeup),i("up"),s(t,{...e,rating:"up"})},c=l=>{l.preventDefault(),l.stopPropagation(),qe(l.target,o.fadedown),i("down"),s(t,{...e,rating:"down"})};return(0,Ft.jsxs)("div",{className:o.thumbs,children:[(0,Ft.jsx)(M.IconButton,{title:n("thumbsUp"),onClick:a,icon:(0,Ft.jsx)(bs,{}),className:(0,Jr.default)(o.thumbsUp,r==="up"&&o.selected),disabled:!!r}),(0,Ft.jsx)(M.IconButton,{title:n("thumbsDown"),onClick:c,icon:(0,Ft.jsx)(xs,{}),className:(0,Jr.default)(o.thumbsDown,r==="down"&&o.selected),disabled:!!r})]})},Cs=Og;var Oe=require("react/jsx-runtime"),_g=({onCopy:t})=>{let e=(0,Pe.useRef)(null),o=h("SummaryForm",sc),[n,s]=(0,Pe.useState)(""),r=k(qr),i=(0,uo.useSelector)(oc),a=(0,uo.useSelector)(ec),c=(0,uo.useSelector)(tc),l=(0,uo.useDispatch)(),d=()=>{l(Q({name:"summary copied to clipboard",data:{originalText:a,finalText:n,model:i},options:{includeConversationData:!0}})),t(n)},u=()=>{let p=document.getSelection();p&&l(Q({name:"summary copied to clipboard",data:{originalText:a,finalText:p==null?void 0:p.toString(),model:i},options:{includeConversationData:!0}}))};return(0,Pe.useEffect)(()=>{l(je())},[]),(0,Pe.useEffect)(()=>{s(a||"")},[a]),(0,Pe.useEffect)(()=>{e.current&&a&&e.current.focus()},[e,a]),(0,Pe.useEffect)(()=>{let p=m=>{m.key==="Enter"&&m.shiftKey&&d()};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[n]),(0,Oe.jsx)("div",{className:o.root,tabIndex:-1,children:c?(0,Oe.jsx)("p",{className:o.error,children:r("error")}):(0,Oe.jsxs)(Pe.Fragment,{children:[(0,Oe.jsx)("div",{className:o.main,children:(0,Oe.jsx)("textarea",{placeholder:a?void 0:r("loading"),disabled:!a,className:o.textInput,ref:e,value:n,onCopy:u,onChange:p=>s(p.target.value)})}),(0,Oe.jsxs)("div",{className:o.actions,children:[(0,Oe.jsx)(Cs,{eventName:"summary feedback",eventData:{summary:a}}),(0,Oe.jsx)(H.Button,{shortKeys:[8679,8629],onClick:d,children:r("copy")})]})]})})},dc=_g;var qo={};Z(qo,{enUS:()=>Dg,nlNL:()=>Hg});var Dg={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?"}]},Hg={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 pt=T(require("react")),Qo=require("react-redux");var Yr={};Z(Yr,{enUS:()=>Fg,nlNL:()=>Bg});var Fg={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"}]},Bg={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 uc={root:"to",title:"oi",empty:"ei",status:"ii",form:"no",input:"ao",submit:"ri",question:"ti",answer:"ni",alignRight:"ai",listItemFeedback:"pi"};var mo=require("@reduxjs/toolkit");var ws=require("@reduxjs/toolkit");var Ug={data:null,fetchState:"idle"},pc=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},Xo=(0,ws.createAsyncThunk)("knowledgeAssistant/getKnowledgeAssistant",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=(i=n.profile.data)==null?void 0:i.knowledgeAssistant;return r?o.getKnowledgeAssistant(r):null}),zg=(0,ws.createSlice)({name:"knowledgeAssistant",initialState:Ug,reducers:{},extraReducers:t=>{t.addCase(Xo.pending,e=>{e.fetchState="loading"}).addCase(Xo.rejected,e=>{e.fetchState="error"}).addCase(Xo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),mc=zg.reducer;var ei={data:[],fetchState:"idle"},gc=t=>{var e;return(e=t.answer)==null?void 0:e.data},fc=t=>t.answer.fetchState,go=(0,mo.createAction)("answer/resetKnowledgeSearch"),po=(0,mo.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var c,l,d;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=pc(e.getState()),r=(c=e.getState().conversation.current)==null?void 0:c.sessionId,i=(d=(l=e.getState().info)==null?void 0:l.agentInfo)==null?void 0:d.agentId;if(!s)throw new Error("KnowledgeAssistant is not defined");let a=await o.knowledgeAssist({customerInstruction:s.customerInstruction,doNotKnowAnswer:s.doNotKnowAnswer,question:t},n,s.code,{agentId:i,conversationId:r});return{question:t,answer:a}}),Vg=(0,mo.createSlice)({name:"answer",initialState:ei,reducers:{},extraReducers:t=>{t.addCase(po.pending,e=>{e.fetchState="loading"}).addCase(po.rejected,e=>{e.fetchState="error"}).addCase(po.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(N,()=>ei).addCase(go,()=>ei)}}),hc=Vg.reducer;var Zo=require("react/jsx-runtime"),yc=()=>(0,Zo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Zo.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Zo.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 te=require("react/jsx-runtime"),$g=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=pt.default.useState(""),{setSelected:r}=ut(),i=(0,pt.useRef)(null),a=h("KnowledgeSearchStyles",uc),c=k(Yr),l=(0,Qo.useDispatch)(),d=(0,Qo.useSelector)(gc),u=(0,Qo.useSelector)(fc),p=async g=>{g.preventDefault(),g.stopPropagation(),n!==""&&l(po(n))},m=(g,f)=>{l(Q({name:"knowledge assist source viewed",data:{question:f,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return(0,pt.useEffect)(()=>{var g;o&&u==="idle"?l(po(o)):(g=i.current)==null||g.focus()},[i,u]),(0,pt.useEffect)(()=>{u==="done"&&(l(Q({name:"knowledge assist question answered",data:{question:n||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),r(`knowledge-assist-${d.length-1}`),s(""))},[u,d]),(0,pt.useEffect)(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,d]),(0,te.jsxs)("div",{className:a.root,children:[d.length>0&&(0,te.jsx)("div",{className:a.alignRight,children:(0,te.jsx)(H.Button,{onClick:e,children:c("reset")})}),d.map(({question:g,answer:f},y)=>(0,te.jsx)(H.List,{children:(0,te.jsx)(H.ListItem,{id:`knowledge-assist-${y}`,"data-testid":"knowledge-search-answer",description:f.answer,closeOnSelect:!0,onClick:()=>t(f.answer),onSourceClick:P=>m(P,g),sources:f.sources,styles:{title:a.question,description:a.answer},extra:(0,te.jsx)("div",{className:a.listItemFeedback,children:(0,te.jsx)(Cs,{eventName:"knowledge assist feedback",eventData:{question:g,isAgent:o!==g,isFollowUpQuestion:d.length>1,...f}})}),children:g})},`${f.answer}_${y}`)),u==="loading"&&(0,te.jsx)("p",{className:a.status,children:c("loading")}),u==="error"&&(0,te.jsx)("p",{className:a.status,children:c("error")}),(0,te.jsxs)("form",{className:a.form,onSubmit:p,children:[(0,te.jsx)("input",{ref:i,placeholder:c("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(void 0)},onChange:g=>{r(void 0),s(g.target.value)}}),(0,te.jsx)("button",{type:"submit",className:a.submit,children:(0,te.jsx)(yc,{})})]})]})},vc=$g;var Ts=require("@reduxjs/toolkit");var Wg={data:null,fetchState:"idle"},Xe=t=>t.profile.data,Es=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],Jo=(0,Ts.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)}),Gg=(0,Ts.createSlice)({name:"profile",initialState:Wg,reducers:{},extraReducers:t=>{t.addCase(Jo.pending,e=>{e.fetchState="loading"}).addCase(Jo.rejected,e=>{e.fetchState="error"}).addCase(Jo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Sc=Gg.reducer;var Pc=require("react");var Ic=require("react-redux");var Bt=require("@reduxjs/toolkit");var jg=["{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}"],qg=new RegExp(jg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function xc(t,e){let o=t.split(qg),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],c=r===o.length-2;n+=i.length;let l=n;if(c){let u=a.charAt(0),p=0;do l=u?e.indexOf(u,l+1):-1,p+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&p>2)return t}else l=a&&a!==""?e.indexOf(a,n):-1;let d=l===-1?e.slice(n):e.slice(n,l);s.push(d),n=l}return s.join("")}function bc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var wc={suggestions:[],fetchState:"idle"},Cc={default:wc},Tc=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},ks=t=>t.textSuggestions,Ec=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},Rs=(0,Bt.createAction)("textSuggestions/refresh"),Ie=(0,Bt.createAsyncThunk)("textSuggestions/recommendations",async(t,e)=>{var l;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(l=n.conversation.current)==null?void 0:l.id,{textSuggestionsCount:r,inlineSuggestions:i}=n.settings,a=oo(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let c=await o.getTextSuggestions(s,Oo(n),t);if(t==="default"){let d=i?c.filter(Ec(a)):c;e.dispatch(Me(d.slice(0,r)))}return c}),Yo=(0,Bt.createAsyncThunk)("textSuggestions/autocompletions",async(t,e)=>{var l;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(l=n.conversation.current)==null?void 0:l.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let c=await o.getAutocompleteSuggestions(s,{...Oo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(c=c.filter(Ec(t))),i&&(c=c.map(d=>({...d,text:d.source!=="trie-with-typos"?xc(d.text,t):d.text}))),c=bc(c,r),e.dispatch(Me(c)),c}),kc=(0,Bt.createSlice)({name:"textSuggestions",initialState:Cc,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(Ie.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||wc;return{...e,[n]:{...s,fetchState:"loading"}}}).addCase(Ie.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Ie.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Yo.pending,e=>{e.default.fetchState="loading"}).addCase(Yo.rejected,e=>{e.default.fetchState="error"}).addCase(Yo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(N,()=>Cc)}}),{setTextSuggestions:mb,setSuggestionState:gb}=kc.actions,Rc=kc.reducer;var ti=require("react-redux");var Kt=require("react/jsx-runtime"),Xg=({commands:t,onClick:e})=>{var a,c,l;let o=(0,Ic.useDispatch)(),n=k(qo),s=(0,ti.useSelector)(Xe),r=(0,ti.useSelector)(ks),i=((l=(c=(a=s==null?void 0:s.uiConfig)==null?void 0:a.search)==null?void 0:c.initialTypes)==null?void 0:l.filter(({isActive:d})=>d))||[];return(0,Pc.useEffect)(()=>{i.forEach(({type:d})=>{(!r[d]||r[d].suggestions.length===0)&&o(Ie(d))})},[]),(0,Kt.jsxs)("div",{children:[t.length>0&&(0,Kt.jsx)(H.List,{heading:n("commands"),children:t.map((d,u)=>(0,Kt.jsx)(H.ListItem,{id:`command-${u}`,closeOnSelect:!1,onClick:d.onClick,children:d.label},d.label))}),i.map(({type:d,title:u})=>{var p;return(0,Kt.jsx)(H.List,{heading:u,orientation:"vertical",children:(p=r[d])==null?void 0:p.suggestions.map((m,g)=>(0,Kt.jsx)(H.ListItem,{id:`${d}-${g}`,closeOnSelect:!1,description:m.text,onClick:()=>e(m.text,m),"data-testid":"search-overlay-suggestion",children:m.title},`${m.id}-${m.text}`))},d)})]})},Lc=Xg;var G=require("react/jsx-runtime"),Qg=200,Jg=5,Yg=4,Ac=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),ef=()=>{let t=(0,_e.useDispatch)(),e=he(),o=k(qo),[n,s]=(0,re.useState)(!1),[r,i]=(0,re.useState)(""),a=(0,_e.useSelector)(el),c=(0,_e.useSelector)(Xe),[l,d]=(0,re.useState)(),u=(0,_e.useSelector)(ee),p=b("showSearch"),m=b("showEntitiesCommand"),g=b("showSummaryCommand"),f=b("showKnowledgeSearch"),y=b("showImageSearch"),P=b("searchTriggerKey"),v=(0,_e.useSelector)(kl),S=(0,_e.useSelector)(tl),I=(0,_e.useSelector)(ol),x=(0,_e.useSelector)(Ya),E=C=>gr(S.filter(X=>X.type===C.toUpperCase()),C),O=[{value:"PERSONAL",label:o("personalSuggestions"),list:E("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:E("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:E("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:E("IMAGE"),listOrientation:"horizontal",shouldShow:y}].filter(C=>C.shouldShow),j=[{label:o("entitiesClipboard"),onClick:()=>t(we("entities")),shouldShow:m&&Ac(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(we("summary")),shouldShow:g&&Ac(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(we("knowledgeAssist")),shouldShow:f}].filter(C=>C.shouldShow),V=(v==null?void 0:v.map(C=>({value:C.code.toUpperCase(),label:`${C.name}s`,list:E(C.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],L=(0,re.useCallback)((0,Mc.default)((C,X)=>{t(It({query:C,type:X,tags:["search-overlay"],size:l?50:20}))},Qg),[l]),_=(0,re.useCallback)((C,X)=>{switch(X.type){case"IMAGE":e.send(Rr,{suggestion:X});break;default:e.send(ct,{text:C,suggestion:X})}t(ce(!1))},[t]),q=C=>{Mt(C.text),t(Q({name:"entity copied",data:{entity:C,type:"copy"}})),t(ce(!1))},ge=(0,re.useCallback)(C=>{t(Q({name:"suggestion feedback",data:{text:C.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),Np=C=>{e.send(ct,{text:C,suggestion:{source:"knowledge-assist",text:C}}),t(Q({name:"answer used",data:{originalText:C},options:{includeConversationData:!0}})),i(""),t(we("search")),t(go()),t(ce(!1))},Op=C=>{Mt(C),t(ce(!1))};function gr(C,X){return C.slice(0,l?10:X.toLowerCase()==="image"?Yg:Jg)}function Po(C){return X=>{n?window.confirm(o("warning"))&&(C(X),s(!1)):C(X)}}return(0,re.useEffect)(()=>{r?L(r,l):t($n())},[r,l]),(0,re.useEffect)(()=>{a==="search"&&t(go())},[a]),(0,re.useEffect)(()=>{u&&t(zo())},[u]),ql(P,()=>t(ce(!0))),!p||!c?null:(0,G.jsxs)(H,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Po(C=>t(ce(C))),onChangeType:C=>d(C),onChangePage:Po(C=>t(we(C))),selectedType:l,search:r,page:a,isOpen:x,types:[...V,...O],children:[(0,G.jsxs)(H.Page,{id:"search",children:[r.length===0&&(0,G.jsx)(Lc,{commands:j,onClick:_}),r.length>0&&(0,G.jsxs)(re.Fragment,{children:[j.length>0&&(0,G.jsx)(H.List,{heading:o("commands"),children:j.map((C,X)=>(0,G.jsx)(H.ListItem,{closeOnSelect:!1,onClick:C.onClick,id:`commands-${X}`,children:C.label},C.label))}),[...V,...O].map(({value:C,label:X,list:ji,lineClamp:_p,listOrientation:Dp})=>(0,G.jsx)(H.List,{heading:X,orientation:Dp==="horizontal"?"horizontal":"vertical",onShowAll:()=>d(C),hasMore:!l&&I[C.toLowerCase()]>gr(ji,C).length,children:gr(ji,C).map(ae=>(0,G.jsx)(H.ListItem,{id:`${C}-${ae.id}`,closeOnSelect:!1,lineClamp:_p,onClick:()=>_(ae.text,ae),description:C!=="IMAGE"?ae.title&&ae.text:void 0,onFeedback:C!=="IMAGE"?()=>ge(ae):void 0,children:C==="IMAGE"?(0,G.jsx)(H.Image,{title:ae.title||ae.text,src:ae.image}):ae.title||ae.text},`${ae.id}-${ae.text}`))},C))]})]}),(0,G.jsx)(H.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:Po(()=>{t(we("search"))}),children:(0,G.jsx)(Jl,{onCopy:q})}),(0,G.jsx)(H.Page,{id:"summary",title:o("summaryTitle"),onDismiss:Po(()=>{t(we("search"))}),children:(0,G.jsx)(dc,{onCopy:Op})}),(0,G.jsx)(H.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:Po(()=>{t(go()),t(we("search"))}),children:(0,G.jsx)(vc,{question:r,onUse:Np,onResetQuestion:()=>{t(go()),i("")}})})]})},Nc=ef;var en=require("react/jsx-runtime"),tf=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,en.jsxs)(Oc.Fragment,{children:[t&&(0,en.jsx)(Nc,{}),e&&(0,en.jsx)(Tl,{})]})},_c=tf;var Bc=T(require("classnames")),Kc=require("react-redux");var Ps=require("react/jsx-runtime"),Dc=({className:t})=>(0,Ps.jsx)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:t,children:(0,Ps.jsx)("g",{children:(0,Ps.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
4
4
|
c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
|
|
5
5
|
c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
|
|
6
6
|
c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
|
|
7
|
-
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var oi=require("react/jsx-runtime"),tf={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Hc=({className:t,color:e})=>(0,oi.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,oi.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:tf[e||"pink"]})});var Fc={root:"q",text:"C",isLoggedIn:"di",isLoggedOut:"po",icon:"li",logo:"si",lock:"ci"};var ni={};Z(ni,{enUS:()=>nf,nlNL:()=>sf});var nf={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},sf={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Uc=require("react-redux"),Ut=require("react/jsx-runtime"),zc=({onLogIn:t})=>{let e=k(ni),o=b("floatingMenu"),n=b("productName"),s=(0,Uc.useDispatch)(),r=(0,Kc.useSelector)(ee),i=h("FloatingMenu",Fc);if(r===null||o===!1)return null;let a=()=>{r===!0?s(ce(!0)):t()};return(0,Ut.jsxs)("button",{className:(0,Bc.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,Ut.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:n})}),(0,Ut.jsxs)("div",{className:i.icon,children:[(0,Ut.jsx)(Hc,{className:i.logo,color:"pink"}),r===!1&&(0,Ut.jsx)(Dc,{className:i.lock})]})]})};var Ns=require("react"),Ze=require("react-redux");var Vc=require("react");function fo(t){(0,Vc.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function zt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}function ho(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 $c=require("@reduxjs/toolkit"),rf={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Is=({ui:t})=>t.overlayCollapsed;var Wc=(0,$c.createSlice)({name:"ui",initialState:rf,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:tn,setInputHasFocus:si,setOverlayCollapsed:mt,setOpenOverlayWhenTyping:Gc,setOverlayCollapsedUserOverwrite:jc}=Wc.actions,qc=Wc.reducer;var As=require("react");var Jc=require("interweave"),yo=require("react"),Ls=require("react-redux");var Xc=require("react");function Zc(t,e,o){(0,Xc.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var Qc={root:"xi",actions:"fi",badge:"gi",formattedText:"do"};var Vt=require("react/jsx-runtime"),cf=["search","personal-collection-search","search-autocomplete"];function df(t,e,o,n={}){let s="";return cf.includes(e)?s=Ml(Kr(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Kr(t,o,n),n.placeholders===!0&&(s=Nl(s)),s}var uf=()=>{},pf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=b("inlineSuggestions"),r=(0,Ls.useSelector)(oo),i=(0,Ls.useDispatch)(),a=h("TextSuggestion",Qc),c=(0,yo.useRef)(null);(0,yo.useEffect)(()=>{let d=setTimeout(()=>{i(Ka({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(d)}},[o]),Zc(c,"click",()=>{i(lt(t)),i(Ne({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,yo.useMemo)(()=>df(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,Vt.jsxs)("div",{className:a.root,onMouseEnter:()=>i(lt(t)),children:[(0,Vt.jsx)(M,{ref:c,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:uf,children:(0,Vt.jsx)(Jc.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:l})}),e&&n&&(0,Vt.jsx)("div",{className:a.actions,children:(0,Vt.jsx)(ms,{onFeedback:()=>n(o),suggestion:o.text})})]})},Yc=pf;var ri=require("react/jsx-runtime"),mf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,As.useMemo)(()=>{let r=e.map((i,a)=>(0,ri.jsx)(Yc,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,ri.jsx)(As.Fragment,{children:s})},Ms=mf;var ed={root:"bi",paper:"hi"};var on=require("react/jsx-runtime"),ff=({textSuggestions:t,selectedIndex:e})=>{let o=(0,Ns.useRef)(null),n=h("InlineSuggestionsOverlay",ed),s=(0,Ze.useSelector)(ho),r=(0,Ze.useDispatch)(),i=(0,Ze.useSelector)(ee),a=(0,Ze.useSelector)(to),c=(0,Ze.useSelector)(Is),l=b("showTextSuggestions");return fo(()=>{setTimeout(()=>{r(mt({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Ns.useEffect)(()=>{let d=o.current;if(!d||!d.parentElement)return;d.parentElement.style.left="0px";let u=d.getBoundingClientRect();d.parentElement.style.left=`${Math.min(window.innerWidth-4-u.right,0)}px`}),c||!s||!l||t.length===0||i!==!0||a===!1?null:(0,on.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,on.jsx)("div",{ref:o,className:n.paper,children:(0,on.jsx)(le,{children:(0,on.jsx)(Ms,{suggestions:t,selectedIndex:e})})})})},hf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),td=(0,Ze.connect)(hf)(ff);var od=require("react-redux");var nn=require("react/jsx-runtime"),yf=({children:t})=>{let o=b("locale").replace("-","");return(0,nn.jsx)(_r.Provider,{value:o,children:t})},vf=({store:t,customStyles:e={},children:o})=>(0,nn.jsx)(od.Provider,{store:t,children:(0,nn.jsx)(yf,{children:(0,nn.jsx)(Io.Provider,{value:e,children:o})})}),$t=vf;var _s=T(require("classnames")),vo=require("react"),De=require("react-redux");var nd=require("react");function sd(t,e){let[o,n]=(0,nd.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return w.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){w.error(i)}}]}var rd=()=>/Mac/i.test(navigator.platform);var ad=T(require("classnames")),Qe=require("react");var ii={};Z(ii,{enUS:()=>Sf,nlNL:()=>xf});var Sf={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Sign in"}]},{type:0,value:" to enable "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze for "},{type:8,value:"min",children:[{type:0,value:"10 minutes"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 hour"}]},{type:0,value:" or "},{type:8,value:"day",children:[{type:0,value:"1 day"}]}]},xf={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 id={root:"mi",anchor:"ui",anchorButton:"yi"};var gt=require("react/jsx-runtime"),ai=(t,e,o)=>n=>(0,gt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Cf=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=k(ii),i=he(),a=h("Login",id),c=b("productName"),l=(0,Qe.useCallback)(y=>{y.preventDefault(),n&&n(parseInt(y.target.value,10))},[]),d=(0,Qe.useCallback)(y=>{y.preventDefault(),i.send(so,!0)},[e]),u=(0,Qe.useMemo)(()=>y=>(0,gt.jsx)("a",{onClick:v=>{v.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:y},"login"),[e]),p=(0,Qe.useCallback)(y=>(0,gt.jsx)("button",{type:"button",className:a.anchorButton,onClick:d,children:y},"prompt"),[d]),{min:m,hour:g,day:f}=(0,Qe.useMemo)(()=>({min:ai(a,60*10,l),hour:ai(a,60*60,l),day:ai(a,60*60*12,l)}),[]);return(0,gt.jsxs)("div",{className:(0,ad.default)(t,a.root),children:[r("loginPlease",{login:o?p:u,productName:c}),n&&(0,gt.jsxs)(Qe.Fragment,{children:[(0,gt.jsx)("br",{}),r("snooze",{min:m,hour:g,day:f})]})]})},Os=Cf;var cd=require("react-redux");var ld={root:"lo",text:"wi"};var sn=require("react/jsx-runtime"),Tf=({title:t})=>{let e=h("SearchTrigger",ld),o=(0,cd.useDispatch)();return(0,sn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ce(!0)),children:[(0,sn.jsx)(io,{}),(0,sn.jsx)("span",{className:e.text,children:t})]})},dd=Tf;var li={};Z(li,{enUS:()=>Ef,nlNL:()=>kf});var Ef={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"}]},kf={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 ud={root:"vi",isInline:"S",toggleButton:"ki",toggleButtonWrapper:"E",toggleButtonWrapperHidden:"zi",isCollapsed:"so",collapsible:"ji",hints:"co",hintsHidden:"Yi",triggers:"xo",triggersRight:"qi"};var F=require("react/jsx-runtime"),Pf=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=h("SuggestionsOverlay",ud),s=k(li),r=(0,De.useSelector)(ho),i=Da(),a=(0,De.useDispatch)(),c=(0,vo.useRef)(null),l=b("searchTriggerKey"),d=b("productName"),u=(0,De.useSelector)(Is),p=(0,De.useSelector)(ee),m=(0,De.useSelector)(to),[g,f]=(0,vo.useState)(null),y=b("showSearch"),P=b("showTextSuggestions"),v=b("adminUrl"),S=b("isEmbedded"),[I,x]=sd("dd-snooze-until-ms",0),E=u||I>Date.now(),O=(0,De.useSelector)(q=>q.input.text),j=t.filter(q=>q.source!=="gpt").length,V=()=>{E&&x(0),a(jc(!E))},L=q=>{a(Q({name:"suggestion feedback",data:{text:q.text,source:"overlay",context:O},options:{includeConversationData:!0}}))},_=q=>{let ge=Date.now()+q*1e3;x(ge),w.info(`Snooze until: ${new Date(ge)}`),a(mt({collapse:!0}))};return(0,vo.useEffect)(()=>{j===0&&f(null)},[t,j]),fo(()=>{a(mt({collapse:!0,skipWhenInputFocus:!0}))}),p===null||m===!1?null:p===!1?(0,F.jsxs)("div",{ref:c,className:(0,_s.default)(n.root,{[n.isCollapsed]:E}),children:[!E&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1}}),(0,F.jsx)("div",{className:n.triggersRight,children:(0,F.jsx)(kt,{className:n.toggleButton,title:s("collapse"),onClick:V,isCollapsed:!1})})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(kt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:V,isCollapsed:!0})}),(0,F.jsx)("div",{className:n.collapsible,children:(0,F.jsx)(Os,{loginUrl:v,isEmbedded:S,onLogIn:o,onSnooze:_})})]}):!i||!r?null:(0,F.jsxs)("div",{ref:c,className:(0,_s.default)(n.root,{[n.isCollapsed]:E}),children:[!E&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1},children:y&&(0,F.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(s(rd()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,F.jsx)(dd,{title:s("search")})})}),(0,F.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,F.jsx)("div",{className:(0,_s.default)(!g&&n.hintsHidden,n.hints),children:g}),(0,F.jsx)(kt,{className:n.toggleButton,title:s("collapse"),onClick:V,isCollapsed:!1})]})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(kt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:V,isCollapsed:!0})}),j>0&&P&&(0,F.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,F.jsx)(le,{children:(0,F.jsx)(Ms,{onFeedback:L,suggestions:t,selectedIndex:e,reverse:!0})})})]})},If=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),pd=(0,De.connect)(If)(Pf);var Zs=T(require("classnames")),Dd=require("interweave"),et=require("react"),Hd=require("react-redux");var So=require("react");function Ds(t){return t.contentEditable==="true"}function Lf(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 md(t){let{selectionStart:e,selectionEnd:o}=Ds(t)?Lf(t):t;return[e,o]}function gd(t){let[,e]=(0,So.useState)(),o=(0,So.useRef)(null);return o.current=md(t),(0,So.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=md(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 fd(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(Ln);if(!i||i.length===0)return;let a=0;i.find(c=>{let l=n.indexOf(c,a);return s>l&&r<l+c.length?(o.selectionStart=l,o.selectionEnd=l+c.length,!0):(a=l+c.length,!1)})}var hd=require("react"),Af=["div","span","mark","strong","b","i","u","em"];function ci(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(Af.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,hd.cloneElement)(n,{children:ci(i,e,o+1)})]}return[...t,...e]}function ft(t){return t.tagName.toLowerCase()==="textarea"}var Le={root:"Ci",container:"Si",agentText:"fo",tabText:"go",hint:"G",matchSelection:"bo",focus:"Ei",resetIndent:"Gi",matchKeyword:"p",matchPlaceholder:"d",hover:"ho",hintText:"Ni",popover:"Ai",popoverRoot:"Fi",popoverContentContainer:"mo",popoverContent:"Hi",selectionOptions:"Li",selectionOptionsIsHidden:"Mi",selectionOptionsButton:"Ri",caret:"Ti",popoverSuggestionsRoot:"Ui",suggestionsOverlayInputStyles:"Bi"};var kd=T(require("classnames")),Rd=require("interweave"),Ws=require("react");var xo=require("react");function yd(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function Hs(t){let e=(0,xo.useRef)(null),[o,n]=(0,xo.useState)(!1);return(0,xo.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=yd((d,u)=>{let p=e.current;if(!p)return;let m=d/r,g=u/r,f=p.getBoundingClientRect(),y=m>f.x&&m<f.x+f.width&&g>f.y&&g<f.y+f.height;y&&!s?(s=!0,n(!0)):!y&&s&&(s=!1,n(!1))},({clientX:d,clientY:u})=>[d,u]),[c,l]=yd(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",c),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",c)}},[e]),[e,o]}function vd(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Fs(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Sd(t){return t!=null}var ui=T(require("classnames")),ve=require("react");var Bs=require("react"),Nf=["bottom","height","left","right","top","width"],Of=(t={},e={})=>Nf.some(o=>t[o]!==e[o]),Je=new Map,xd,bd=()=>{let t=[],e=[];Je.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Of(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))}),xd=window.requestAnimationFrame(bd)};function _f(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&&bd()},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(xd)}}}}function di(t){let[e,o]=(0,Bs.useState)(null);return(0,Bs.useLayoutEffect)(()=>{if(!t.current)return;let n=_f(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var bo=require("react"),wd=require("react-dom");var Cd={root:"Di"};var Td=({children:t,parentNode:e})=>{let[o,n]=(0,bo.useState)(null),s=(0,bo.useContext)(Io);return(0,bo.useLayoutEffect)(()=>{let r=document.createElement("div");return zt(r),r.classList.add(Cd.root),s!=null&&s.portalRootNode&&r.classList.add(s==null?void 0:s.portalRootNode),(e||document.body).appendChild(r),n(r),()=>{r.isConnected&&r.remove()}},[]),o?(0,wd.createPortal)(t,o):null};var He={ref:"Ii",root:"o",positionAbove:"l",positionBelow:"s",positionLeft:"c",positionRight:"x",alignStart:"f",alignCenter:"g",alignEnd:"b"};var Ks=require("react/jsx-runtime"),Us=(t=!1)=>{let[e,o]=(0,ve.useState)(t),n=(0,ve.useCallback)(()=>o(!0),[]),s=(0,ve.useCallback)(()=>o(!1),[]),r=(0,ve.useCallback)(()=>o(a=>!a),[]),i=(0,ve.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function pi(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 Co=({className:t,triggerRef:e,boundaryRef:o=(0,ve.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=pi,parentNode:a,...c})=>{let l=di(e),d=di(o),u=(0,ve.useMemo)(()=>i(l,d,0),[l,d]);return(0,Ks.jsx)(Td,{parentNode:a,children:(0,Ks.jsx)("div",{className:(0,ui.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:u,...c,role:"dialog",children:(0,Ks.jsx)("div",{className:(0,ui.default)(t,He.root),children:r})})})};var Ed=T(require("classnames")),zs=require("react");var mi=require("react/jsx-runtime"),Vs=(0,zs.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,zs.useRef)(null),r=h("TabCompletion",Le);return(0,mi.jsx)("div",{ref:Fs([s,n]),className:(0,Ed.default)(t,r.popoverContentContainer),...o,children:(0,mi.jsx)("div",{className:r.popoverContent,children:e})})});var ht=require("react/jsx-runtime"),Ff=t=>e=>{let o=pi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Bf=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=h("TabCompletion",Le),i=Us(),a=(0,Ws.useMemo)(()=>Ff(t.getBoundingClientRect()),[t]),[c,l]=Hs(t);return(0,Ws.useEffect)(()=>{l?i.open():i.close()},[l]),(0,ht.jsxs)("span",{children:[(0,ht.jsx)("mark",{ref:Fs([c,i.triggerRef]),className:(0,kd.default)(r.matchKeyword,{[r.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,ht.jsx)(Co,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,ht.jsx)(Vs,{style:o,children:(0,ht.jsx)("div",{className:r.hintText,children:s})})})]})},$s=class extends Rd.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${vd(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(Sd);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,ht.jsx)(Bf,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Pd=require("interweave"),Id=T(require("classnames"));var gi=require("react/jsx-runtime"),Kf=({inputElement:t,children:e})=>{let o=h("TabCompletion",Le),[n,s]=Hs(t);return(0,gi.jsx)("mark",{ref:n,className:(0,Id.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},Gs=class extends Pd.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,gi.jsx)(Kf,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var qs=T(require("classnames")),Od=require("interweave"),ne=require("react"),_d=require("react-redux");var fi=require("react/jsx-runtime"),Ld=()=>(0,fi.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,fi.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 yt=require("react"),rn=require("react-redux"),Md=T(require("lodash.debounce"));var Ad={root:"Oi",content:"Xi"};function js(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 hi(t){return t.replace("https://www.","").replace("https://","")}var Se=require("react/jsx-runtime"),zf=3,Vf=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),$f=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=zf})=>{let r=h("LinkSearch",Ad),[i,a]=(0,yt.useState)(""),c=(0,rn.useDispatch)(),l=(0,rn.useSelector)(Tc("url")),d=(0,rn.useSelector)(nl("URL",Vf)),[u,p]=(0,yt.useState)(d.length-1),m=b("fallbackImage"),g=v=>{let S=v.target;a(S.value)},f=(v,S)=>{v.stopPropagation(),v.preventDefault(),window.open(S,"_blank")},y=v=>{var x;let S=u-1<0?d.length-1:u-1,I=u+1===d.length?0:u+1;v.code==="Escape"&&(a(""),e()),v.code==="ArrowUp"&&p(S),v.code==="ArrowDown"&&p(I),v.code==="Enter"&&t(((x=d[u])==null?void 0:x.text)||i)},P=(0,yt.useCallback)((0,Md.default)(v=>{c(It({query:v,type:"URL",tags:["link-search"]}))},300),[]);return(0,yt.useEffect)(()=>{i&&P(i)},[i]),(0,yt.useEffect)(()=>()=>{c($n())},[]),(0,Se.jsxs)("div",{className:r.root,children:[(0,Se.jsx)(le,{withDivider:!0,children:(i?d:l).slice(0,s).map((v,S)=>(0,Se.jsx)(M,{selected:u===S,onClick:()=>t(v.text),"data-testid":"linksearch-suggestion",children:(0,Se.jsxs)(D,{children:[(0,Se.jsx)(D.Image,{src:js(v,"small",m||void 0),title:v.title||v.text}),(0,Se.jsxs)(D.Content,{className:r.content,cropText:!0,children:[(0,Se.jsx)(D.Title,{children:v.title||hi(v.text)}),v.title&&hi(v.text)]}),(0,Se.jsx)(M.Actions,{children:(0,Se.jsx)(M.ActionButton,{label:n,onClick:I=>f(I,v.text)})})]})},v.text))}),(0,Se.jsx)(Uo,{value:i,onChange:g,autoFocus:!0,placeholder:o,onKeyUp:y})]})},Nd=$f;var yi={};Z(yi,{enUS:()=>Wf,nlNL:()=>Gf});var Wf={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Gf={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var oe=require("react/jsx-runtime"),jf=(0,ne.forwardRef)((t,e)=>{let o=h("TabCompletion",Le);return(0,oe.jsx)("mark",{ref:e,className:(0,qs.default)(o.matchSelection)},"selection-start")}),qf=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=k(yi),i=h("TabCompletion",Le),a=(0,ne.useRef)(null),c=(0,ne.useRef)(null),[l,d]=(0,ne.useState)(null),u=(0,_d.useDispatch)(),p=Us(document.activeElement===n),[m]=(0,ne.useState)(()=>document.createRange());p.triggerRef.current=m,(0,ne.useEffect)(()=>()=>m.detach(),[]),(0,ne.useEffect)(()=>{let f=t.current,y=a.current;!f||!y||(m.setStart(f,0),m.setEnd(y,0))},[t.current,a.current]),fo(()=>{p.close()});let g=(0,ne.useCallback)(f=>{let y=m.toString(),P=/^http(s?):\/\//.test(f)?f:`https://${f}`;u(Fn({text:`[${y}](${P})`,replace:"selection"}))},[]);return(0,oe.jsxs)("span",{children:[(0,oe.jsx)("mark",{ref:a,className:(0,qs.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":p.opened?"true":"false",children:s}),p.opened&&(0,oe.jsx)(Co,{className:i.popoverRoot,triggerRef:p.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,oe.jsxs)(Vs,{style:o,ref:c,children:[(0,oe.jsx)("div",{className:(0,qs.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:l!==null}),children:(0,oe.jsxs)("button",{type:"button",tabIndex:l===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>d("insertLink"),children:[(0,oe.jsx)(Ld,{}),(0,oe.jsx)("span",{children:"\xA0"}),(0,oe.jsx)("span",{children:r("insertLink")})]})}),l==="insertLink"&&(0,oe.jsx)(Nd,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:g,onDismiss:()=>{d(null),p.close()}})]})})]},"selection-end")},Xs=class extends Od.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,ne.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,oe.jsx)(jf,{ref:this.startRef}):(0,oe.jsx)(qf,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Fd=require("react-redux");var Ye=require("react/jsx-runtime"),Xf=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:c})=>{let l=h("TabCompletion",Le),d=b("insertLink"),u=b("showMidSentenceSuggestions"),p=b("inlineSuggestions"),m=gd(a),g=(0,et.useRef)(null),f=(0,Fd.useSelector)(ee);(0,et.useEffect)(()=>{ft(a)&&m&&fd(a,m)},[m]);let y=(0,et.useCallback)(S=>{if(!s||!o)return S;let I=[(0,Ye.jsx)("span",{className:l.resetIndent,children:"\u200B"},"u200B"),(0,Ye.jsx)("span",{"data-testid":"tab-completion",className:(0,Zs.default)(l.tabText,l.resetIndent),"data-source":c,children:o},"tabText")];return n&&I.push((0,Ye.jsx)("span",{className:(0,Zs.default)(l.hint,l.resetIndent),children:(0,Ye.jsx)(kn,{keyCode:"tab"},"tabHint")})),ci(S,I)},[s,o,n]),P=(0,et.useMemo)(()=>{let S=[];return d&&S.push(new Xs("selection")),S.push(new Gs("placeholders")),r&&S.push(new $s("keywords")),S},[p,d,r]),v=(0,et.useMemo)(()=>{let S=window.getComputedStyle(a);return{"--dd-color":S.color,"--dd-font-size":S.fontSize,"--dd-font-family":S.fontFamily,"--dd-font-variant":S.fontVariant}},[]);return!t||!f?null:(0,Ye.jsxs)("div",{ref:S=>{S!=null&&S.parentElement&&(g.current=S==null?void 0:S.parentElement)},className:l.root,style:v,children:[(0,Ye.jsx)(Dd.Interweave,{tagName:"span",containerTagName:"div",className:(0,Zs.default)(l.container,l.agentText),disableLineBreaks:ft(a),content:e||"\u200B",onAfterParse:y,matchers:P,selection:m,keywordMatches:i,inputElement:a,inputStyle:v,boundaryRef:g,inlineSuggestionsOnlyAtEnd:!u}),(0,Ye.jsx)("br",{})]})},Zf=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var f;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",c=t.html??ro(t.text),l=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:d}=e,{isSupported:u}=s,{showTabCompletion:p,visible:m,showStyleSuggestions:g}=o;return{showTabHint:d,showStyleSuggestions:g,showTabCompletion:p,content:c,tabText:l,source:a,keywordMatches:((f=n.list)==null?void 0:f.keywordMatches)??[],enabled:m&&u!==!1}},Bd=(0,Hd.connect)(Zf)(Xf);var zu=T(require("classnames")),tr=require("react"),B=require("react-redux");var vt=require("@reduxjs/toolkit");var Kd={list:[],fetchState:"idle"},zd=t=>t.autoflows.list||[],Ud=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},tt=(0,vt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),vi=(0,vt.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))}),Si=(0,vt.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))}),Qf=(0,vt.createSlice)({name:"autoflows",initialState:Kd,reducers:{},extraReducers:t=>{t.addCase(vi.pending,(e,o)=>{let n=Ud(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Si.pending,(e,o)=>{let n=Ud(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(tt.pending,e=>{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(N,()=>Kd)}}),Vd=(0,vt.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))})}),$d=(0,vt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Wd=Qf.reducer;var St=require("@reduxjs/toolkit");var Gd={list:[],fetchState:"idle",sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},jd=t=>t.customMessages.list,qd=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Xd=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Zd=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),an=(0,St.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Qs=(0,St.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)}),Js=(0,St.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)}),Qd=(0,St.createSlice)({name:"customMessages",initialState:Gd,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(an.pending,e=>{e.fetchState="loading"}).addCase(an.rejected,e=>{e.fetchState="error"}).addCase(an.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Qs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Qs.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Js.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Js.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(N,()=>Gd)}}),Jd=(0,St.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(Qd.actions.onCustomMessage(r))})}),Yd=(0,St.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),eu=Qd.reducer;var ln=require("@reduxjs/toolkit"),Jf={token:null,accountUrl:null,interval:null},tu=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},xi=(0,ln.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),bi=(0,ln.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(xi()),setInterval(()=>n(xi()),o)}),ou=(0,ln.createSlice)({name:"passwordlessToken",initialState:Jf,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(xi.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(bi.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:nu}=ou.actions,su=ou.reducer;var wo=require("@reduxjs/toolkit");var Ci={cues:[],fetchState:"idle"},ru=t=>{var e;return(e=t.rules)==null?void 0:e.cues},Yf=(0,wo.createAction)("rules/resetCues"),Wt=(0,wo.createAsyncThunk)("rules/evaluate",async(t,e)=>{var o,n;try{let{deepdeskAPI:s}=e.extra,r=e.getState(),i=(o=r.conversation.current)==null?void 0:o.id;if(!i)throw new Error("No current conversation to evaluate rules");if(!(await s.getAccount()).ruleEngine)throw new Error("Rule engine is not enabled for this account");if(!(await s.getRules()).some(d=>d.label===t.label))throw new Error(`No rules found with label: ${t.label}`);return await s.evaluateRule(t.label,i,{tags:((n=r.conversation.current)==null?void 0:n.tags)||void 0,...t.params})}catch(s){return w.info(s.message),[]}}),iu=(0,wo.createSlice)({name:"answer",initialState:Ci,reducers:{removeCue(t,e){t.cues=t.cues.filter(o=>o.rule.id!==e.payload.id)}},extraReducers:t=>{t.addCase(Wt.pending,e=>{e.fetchState="loading"}).addCase(Wt.rejected,e=>{e.fetchState="error"}).addCase(Wt.fulfilled,(e,o)=>{let n=o.payload.map(r=>r.rule.id),s=e.cues.filter(r=>!n.includes(r.rule.id));e.fetchState="done",e.cues=[...o.payload,...s]}).addCase(N,()=>Ci).addCase(Yf.toString(),()=>Ci)}}),{removeCue:au}=iu.actions,lu=iu.reducer;var yu=require("react"),vu=require("react-redux");var gu=T(require("classnames")),fu=require("react");var du=T(require("classnames"));var cu={root:"Ji"};var pu=require("react/jsx-runtime"),th=({className:t,children:e})=>{let o=h("Unicode",cu);return(0,pu.jsx)("span",{className:(0,du.default)(t,o.root),children:e})},uu=th;var mu={isDisabled:"Ki",buttonStart:"Pi",root:"Qi",buttonStop:"uo",stateBadge:"h",isCompleted:"Vi",isStarted:"Wi",isAborted:"Zi"};var wi={};Z(wi,{enUS:()=>nh,nlNL:()=>sh});var nh={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},sh={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};var pe=require("react/jsx-runtime"),ih=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=h("Autoflow",mu),a=k(wi),c=e==="Started"?"stop":"start",l=c==="start"?"\u25B6":c==="stop"?"\u25FC":"";return(0,pe.jsxs)(M,{className:(0,gu.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,pe.jsx)(D,{children:(0,pe.jsxs)(D.Content,{children:[(0,pe.jsxs)(D.Title,{children:[e&&(0,pe.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,pe.jsx)("span",{children:n})]})}),(0,pe.jsx)(M.Actions,{fixed:e==="Started",children:(0,pe.jsx)(M.ActionButton,{primary:!0,className:c==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,pe.jsxs)(fu.Fragment,{children:[(0,pe.jsx)(uu,{children:l})," ",(0,pe.jsx)("span",{children:a(c)})]})})})]})},hu=ih;var Ti=require("react/jsx-runtime"),ah=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},lh=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Ti.jsx)(yu.Fragment,{children:t.map(s=>(0,Ti.jsx)(hu,{displayName:s.displayName,description:s.description,disabled:s.isBusy||ah(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),ch=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},dh={onStartAutoflow:vi,onStopAutoflow:Si},Su=(0,vu.connect)(ch,dh)(lh);var xu=T(require("classnames")),Ei=require("react"),Gt=require("react-redux");var ot={root:"yo",title:"wo",isUsed:"_i",quickReplies:"or",quickReply:"er",hasError:"ir",label:"rr",errorIcon:"tr"};var ie=require("react/jsx-runtime"),ph=({suggestion:t})=>{let e=k(Dt),o=(0,Gt.useDispatch)(),n=(0,Gt.useSelector)(qd(t.text)),s=(0,Gt.useSelector)(Xd(t.text)),r=(0,Gt.useSelector)(Zd(t.text)),i=(0,Gt.useSelector)(eo),{replyOptions:a}=t,c=(0,Ei.useCallback)(d=>{d.preventDefault(),d.stopPropagation(),!(n||!i)&&o(Qs({platformSessionId:i,suggestion:t}))},[t,n,o,i]),l=(0,Ei.useCallback)(d=>{if(d.preventDefault(),d.stopPropagation(),!i||!a)return;let u=parseInt(d.target.dataset.index,10),p=a[u];o(Js({platformSessionId:i,reply:p,suggestion:t}))},[t,n,o,i]);return(0,ie.jsxs)(M,{onClick:c,className:(0,xu.default)(ot.root,{[ot.isUsed]:n,[ot.hasError]:r}),children:[(0,ie.jsx)(D,{children:(0,ie.jsxs)(D.Content,{children:[(0,ie.jsxs)(D.Title,{className:ot.title,children:[t.text," ",(0,ie.jsx)(Rn,{className:ot.label,children:"analyse tool"})," ",r&&(0,ie.jsx)("span",{className:ot.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,ie.jsx)("ul",{className:ot.quickReplies,children:a.map(d=>(0,ie.jsx)("li",{className:ot.quickReply,children:d.title},d.title))})]})}),(0,ie.jsxs)(M.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,ie.jsx)(M.DropdownButton,{label:e("answer"),disabled:s,children:a.map((d,u)=>(0,ie.jsx)(M.DropdownItem,{index:u,label:d.title,onClick:l},d.title))}),(0,ie.jsx)(M.ActionButton,{primary:!0,disabled:n,onClick:c,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},bu=ph;var Ys=require("react"),wu=require("react-redux"),Pi=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 Cu={root:"nr",entity:"r",entityText:"ar",iconWrapper:"pr",icon:"dr",iconClicked:"lr"};var Fe=require("react/jsx-runtime"),gh=({entities:t})=>{let e=h("EntitiesWidgetList",Cu),[o,n]=(0,Ys.useState)(void 0),s=(0,wu.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Mt(a.text),s(Q({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Ys.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Fe.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,c)=>(0,Fe.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Fe.jsx)("span",{className:e.entityText,children:a.text}),(0,Fe.jsxs)("span",{className:e.iconWrapper,children:[(0,Fe.jsx)("span",{className:(0,Pi.default)(e.icon),children:(0,Fe.jsx)(Ri,{})}),(0,Fe.jsx)("span",{className:(0,Pi.default)(e.icon,o===c&&e.iconClicked),children:(0,Fe.jsx)(Ri,{})})]})]},a.text))})},Tu=gh;var Ii=require("react/jsx-runtime"),Eu=()=>(0,Ii.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Ii.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 Li=require("react/jsx-runtime"),ku=()=>(0,Li.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Li.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 Ai=require("react/jsx-runtime"),Ru=()=>(0,Ai.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ai.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 _u=require("react-redux");var Oi=T(require("classnames")),er=require("react");var cn=require("react/jsx-runtime"),Pu=({className:t})=>(0,cn.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,cn.jsx)("line",{x1:"2",y1:"10",x2:"10",y2:"2",stroke:"black",strokeWidth:"1"}),(0,cn.jsx)("line",{x1:"2",y1:"2",x2:"10",y2:"10",stroke:"black",strokeWidth:"1"})]});var Lu=T(require("dompurify")),xt=require("react"),Au=T(require("snarkdown"));var Iu={fadeup:"N",root:"i",popover:"sr",options:"vo",copyIcon:"A",option:"ko",divider:"cr"};var nt=require("react/jsx-runtime");function hh(t){return`<button type="button" class=${t}><svg version="1.1" x="0px" y="0px" viewBox="0 0 115.77 122.88" width="10px" height="10px" fill="black"><g><path d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"/></g></svg></button>`}function Mi(t){let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(o=>o.remove()),e.textContent??""}function yh(t){return t.replace(/\r\n/g,`
|
|
8
|
-
`)}var vh=({content:t,useLabel:e,copyLabel:o,onCopy:n,onUse:s})=>{let r=h("Markdown",Iu),i=(0,xt.useRef)(null),[a,c]=(0,xt.useState)(null),l=(0,xt.useMemo)(()=>{let g=(0,Au.default)(yh(t));return Lu.default.sanitize(g).replace(/<\/code>/g,`${hh(r.copyIcon)}</code>`)},[t]),d=g=>{var P;let f=g.target,y=!!((P=i.current)!=null&&P.querySelector("code"));a||y&&f.tagName!=="CODE"||!y&&f!==i.current||(f.addEventListener("mouseleave",()=>c(null),{once:!0}),c(f))},u=()=>{if(!a)return;c(null);let g=a.querySelector("button");g&&(qe(g,r.fadeup),n(Mi(a)))},p=g=>{g.target.tagName.toLowerCase()==="button"&&(qe(g.target,r.fadeup),n(Mi(g.target.parentElement)))},m=()=>{a&&(c(null),s(Mi(a)))};return(0,nt.jsxs)(xt.Fragment,{children:[a&&(0,nt.jsx)(Co,{triggerRef:{current:a},parentNode:a,className:r.popover,children:(0,nt.jsxs)("div",{className:r.options,children:[(0,nt.jsx)("button",{type:"button",className:r.option,onClick:u,children:o}),(0,nt.jsx)("div",{className:r.divider}),(0,nt.jsx)("button",{type:"button",className:r.option,onClick:m,children:e})]})}),(0,nt.jsx)("div",{ref:i,className:r.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:d,onClick:p})]})},Mu=vh;var Ni={};Z(Ni,{enUS:()=>Sh,nlNL:()=>xh});var Sh={useCue:[{type:0,value:"Use"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},xh={useCue:[{type:0,value:"Gebruik"}],copyCue:[{type:0,value:"Kopieer"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Nu={fadeup:"F",fadedown:"H",selected:"zo",thumbsUp:"xr",thumbsDown:"fr"};var me=require("react/jsx-runtime"),Ch=({cue:t,onRemove:e,onCopy:o,onUse:n,onThumbsUp:s,onThumbsDown:r})=>{let i=h("WidgetCue",Nu),a=k(Ni),c=co(),[l,d]=(0,er.useState)(null),u=y=>{o&&o(y,t)},p=y=>{n&&n(y,t)},m=y=>{y.preventDefault(),y.stopPropagation(),e(t)},g=y=>{y.preventDefault(),y.stopPropagation(),qe(y.target,i.fadeup),d("up"),s(t)},f=y=>{y.preventDefault(),y.stopPropagation(),qe(y.target,i.fadedown),d("down"),r(t)};return(0,er.useEffect)(()=>{c("Assistant response displayed",{name:t.rule.name,description:t.rule.description,group:t.rule.label})},[]),(0,me.jsxs)(M,{"data-testid":"cue",children:[(0,me.jsx)(D,{children:(0,me.jsxs)(D.Content,{children:[t.title&&(0,me.jsx)(D.Title,{"data-testid":"widget-cue-title",children:t.title}),(0,me.jsx)(Mu,{content:t.text,useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:u,onUse:p})]})}),(0,me.jsx)(M.IconButton,{title:a("thumbsUp"),onClick:g,icon:(0,me.jsx)(bs,{}),className:(0,Oi.default)(i.thumbsUp,l==="up"&&i.selected),disabled:!!l}),(0,me.jsx)(M.IconButton,{title:a("thumbsDown"),onClick:f,icon:(0,me.jsx)(xs,{}),className:(0,Oi.default)(i.thumbsDown,l==="down"&&i.selected),disabled:!!l}),(0,me.jsx)(M.IconButton,{title:a("removeCue"),onClick:m,icon:(0,me.jsx)(Pu,{})})]})},Ou=Ch;var dn=require("react/jsx-runtime"),wh=({cues:t})=>{let e=(0,_u.useDispatch)(),o=he(),n=co(),s=l=>{e(au({id:l.rule.id})),n("Assistant response closed",{name:l.rule.name,group:l.rule.label,description:l.rule.description})},r=(l,d)=>{Mt(l),n("Assistant response copied",{name:d.rule.name,group:d.rule.label,description:d.rule.description,copiedText:l})},i=(l,d)=>{o.send(ct,{text:l,suggestion:{source:"cue",sourceText:l}}),n("Assistant response used",{name:d.rule.name,group:d.rule.label,description:d.rule.description,usedText:l})},a=l=>{n("Assistant response feedback",{name:l.rule.name,group:l.rule.label,description:l.rule.description,thumb:"up"})},c=l=>{n("Assistant response feedback",{name:l.rule.name,group:l.rule.label,description:l.rule.description,thumb:"down"})};return(0,dn.jsx)(dn.Fragment,{children:t.map(l=>(0,dn.jsx)(Ou,{cue:l,onRemove:s,onCopy:r,onUse:i,onThumbsDown:c,onThumbsUp:a},l.rule.id))})},Du=wh;var Fu=require("react");var Th=/(https?:\/\/[^\s]+)/,Hu=t=>t.split(" ").find(e=>Th.test(e));var xe=require("react/jsx-runtime"),Eh=({suggestion:t,lines:e,onUse:o})=>{var d;let n=t.text||t.url||t.message,s=Hu(n),r=k(Dt),i=b("showImages"),a=b("fallbackImage"),c=u=>{u.preventDefault(),u.stopPropagation(),o(n)},l=(0,Fu.useCallback)(u=>{window.open(s,"_blank"),u.stopPropagation(),u.preventDefault()},[s]);return(0,xe.jsxs)(M,{onClick:c,"data-testid":"edit-suggestion",children:[(0,xe.jsxs)(D,{children:[i&&t.image&&(0,xe.jsx)(D.Image,{src:js(t,"small",a||void 0),title:t.title}),(0,xe.jsxs)(D.Content,{children:[t.title&&(0,xe.jsx)(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&(0,xe.jsx)(M.Labels,{labels:t.searchKeywords}),(0,xe.jsx)(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:n})]})]}),(0,xe.jsxs)(M.Actions,{children:[s&&(0,xe.jsx)(M.ActionButton,{onClick:l,label:r("visitUrl")}),(0,xe.jsx)(M.ActionButton,{primary:!0,onClick:c,label:r("useSuggestion")})]})]})},Bu=Eh;var un=require("react/jsx-runtime"),kh=({lines:t,suggestions:e})=>{let o=he(),n=(s,r)=>{o.send(ct,{text:s,suggestion:{...r,source:r.source,sourceText:r.text}})};return(0,un.jsx)(un.Fragment,{children:e.map(s=>(0,un.jsx)(Bu,{suggestion:s,lines:t,onUse:r=>n(r,s)},s.text||s.url||s.message))})},Ku=kh;var pn={};Z(pn,{enUS:()=>Rh,nlNL:()=>Ph});var Rh={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},Ph={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var mn={root:"gr",loginText:"br",stateText:"jo",sectionList:"hr",shortcutList:"mr",shortcut:"ur",link:"Yo"};var R=require("react/jsx-runtime"),or=(t,e)=>{let o=(0,B.useSelector)(ee);(0,tr.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},Lh=({onLogIn:t})=>{let e=h("Widget",mn),o=b("isEmbedded"),n=b("adminUrl");return(0,R.jsx)("div",{className:e.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Os,{isEmbedded:o,loginUrl:n,onLogIn:t})})},"login")},Uu=({text:t})=>{let e=h("Widget",mn);return(0,R.jsx)("div",{className:e.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t})})},"notification")},Ah=()=>{let t=k(pn),e=(0,B.useDispatch)(),o=h("Widget",mn),n=b("showSearch"),s=b("showSummaryCommand"),r=b("showKnowledgeSearch"),i=(0,B.useSelector)(tu("/admin/")),a=he(),c=b("productName"),l=n||s||r||i;return or(()=>(e(bi()),()=>{e(nu())}),[e]),l?(0,R.jsx)(Ue,{title:t("actions"),type:"shortcuts",children:(0,R.jsxs)("div",{className:o.shortcutList,children:[n&&(0,R.jsxs)("button",{type:"button",className:o.shortcut,"data-testid":"shortcut-search",title:t("linkSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(io,{}),t("linkSearch")]}),s&&(0,R.jsxs)("button",{type:"button",className:o.shortcut,"data-testid":"shortcut-summary",title:t("linkSummary"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(Ru,{}),t("linkSummary")]}),r&&(0,R.jsxs)("button",{type:"button",className:o.shortcut,"data-testid":"shortcut-knowledge-assist",title:t("linkKnowledgeSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(ku,{}),t("linkKnowledgeSearch")]}),i&&(0,R.jsxs)("a",{className:o.shortcut,target:"_blank",href:i,"data-testid":"shortcut-studio-login",title:t("linkStudioLogin",{productName:c}),rel:"noreferrer",children:[(0,R.jsx)(Eu,{}),t("linkStudioLogin",{productName:c})]})]})}):null},Mh=()=>{let t=(0,B.useDispatch)(),e=b("showCustomMessages"),o=(0,B.useSelector)(jd),n=(0,B.useSelector)(eo);return or(()=>(t(an(n)),t(Jd(n)),()=>{t(Yd(n))}),[t,e,n]),!e||o.length===0?null:(0,R.jsx)(Ue,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(le,{withDivider:!0,children:o.map(s=>(0,R.jsx)(bu,{suggestion:s},s.text))})})},Nh=()=>{let t=k(pn),e=(0,B.useDispatch)(),o=b("showAutoflows"),n=(0,B.useSelector)(zd),s=(0,B.useSelector)(eo);return or(()=>(e(tt(s)),e(Vd(s)),()=>{e($d(s))}),[e,o,s]),!o||n.length===0?null:(0,R.jsx)(Ue,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(le,{withDivider:!0,children:(0,R.jsx)(Su,{})})})},Oh=()=>{let t=(0,B.useDispatch)(),e=(0,B.useSelector)(Es),o=(0,B.useSelector)(ru),n=(0,B.useSelector)(ys),s=(0,B.useSelector)(ks),r=(0,B.useSelector)(Xe),i=(0,B.useSelector)(Mn);return or(()=>{e.forEach(({type:a})=>{a==="entities"?t(Re()):["cues"].includes(a)||t(Ie(a))})},[t,i,r]),(0,R.jsx)(tr.Fragment,{children:e.map(({type:a,title:c,amount:l,lines:d})=>{var u,p;switch(a){case"entities":return n&&n.length>0&&(0,R.jsx)(Ue,{type:a,title:c,"data-testid":`type-${a}`,children:(0,R.jsx)(Tu,{entities:n})},a);case"cues":return o&&o.length>0&&(0,R.jsx)(Ue,{type:a,title:c,"data-testid":`type-${a}`,children:(0,R.jsx)(le,{withDivider:!0,children:(0,R.jsx)(Du,{cues:o})})},a);default:return((p=(u=s[a])==null?void 0:u.suggestions)==null?void 0:p.length)>0&&(0,R.jsx)(Ue,{type:a,title:c,"data-testid":`type-${a}`,children:(0,R.jsx)(le,{withDivider:!0,children:(0,R.jsx)(Ku,{lines:d,contentType:a,suggestions:s[a].suggestions.slice(0,l)||[]})})},a)}})})},_h=({onLogIn:t})=>{let e=k(pn),o=h("Widget",mn),n=(0,B.useSelector)(to),s=(0,B.useSelector)(ee),r=(0,B.useSelector)(eo),i=(0,B.useSelector)(Xe);return n===!1?(0,R.jsx)(Uu,{text:e("notSupported")}):s===!1?(0,R.jsx)(Lh,{onLogIn:t}):!i||!r||s===null?(0,R.jsx)(Uu,{text:e("waiting")}):(0,R.jsx)("div",{className:(0,zu.default)(o.root),"data-testid":"widget",children:(0,R.jsxs)(Pn,{className:o.sectionList,children:[(0,R.jsx)(Ah,{}),(0,R.jsx)(Mh,{}),(0,R.jsx)(Nh,{}),(0,R.jsx)(Oh,{})]})})},Vu=_h;function To(t){let e=new Range;return e.selectNodeContents(t),e}function $u(t,e,o){try{return bt(t,e,o),!0}catch{return!1}}function nr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function sr(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(c,l){let d=-1,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(c))return l;for(let p=0;p<=c.length;p++)if(u.test(c[p])||d++,d===l)return p;throw new Error("Offset out of range")}function a(c){switch(c.nodeType){case Node.TEXT_NODE:{let l=c.textContent,d=l.replace(gn,""),u=s+d.length,p=e>=s&&e<=u,m=o>=s&&o<=u;if(p){let g=i(l,e-s);g===0&&!m?n.setStartBefore(c):n.setStart(c,g)}m&&(n.setEnd(c,i(l,o-s)),r=!0),s=u;break}case Node.ELEMENT_NODE:{if(sr(c)&&(s===e&&n.setStartBefore(c),s++,s===o)){n.setEndAfter(c),r=!0;return}for(let d=0;d<c.childNodes.length&&(a(c.childNodes[d]),!r);d++);let l=c.lastChild;nr(c)&&l&&!nr(l)&&!sr(l)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}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,collapsed:i}=e,a,c,l=0;function d(u){let p=u===o,m=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let g=u.textContent;p&&(a=l+g.substring(0,n).replace(gn,"").length),m&&(c=l+g.substring(0,r).replace(gn,"").length),l+=g.replace(gn,"").length;break}case Node.ELEMENT_NODE:{let g=u.nextSibling===null;sr(u)&&!g&&l++;for(let f=0;f<u.childNodes.length;f++){let y=p&&f===n,P=m&&f===r;if(y&&(a=l),P&&(c=l),c!==void 0||((!y||!i)&&d(u.childNodes[f]),m&&f===r-1&&(c=l),c!==void 0))break}!m&&nr(u)&&!g&&l++,m&&(c=l);break}default:break}}if(d(t),c===void 0)throw new Error("Could not determine start and end");return{start:a??c,end:c}}function hn(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 c(l){let d=l===o,u=l===s;switch(d&&i++,l.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let p=d?n:0,m=u?r:void 0,g=l.textContent.replace(gn,"");p===0&&m===void 0?a+=g:a+=g.substring(p,m);break}case Node.ELEMENT_NODE:{let p=l.nextSibling===null;i===0&&sr(l)&&!p&&(a+=`
|
|
7
|
+
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var oi=require("react/jsx-runtime"),of={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Hc=({className:t,color:e})=>(0,oi.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,oi.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:of[e||"pink"]})});var Fc={root:"q",text:"C",isLoggedIn:"di",isLoggedOut:"po",icon:"li",logo:"si",lock:"ci"};var ni={};Z(ni,{enUS:()=>sf,nlNL:()=>rf});var sf={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},rf={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Uc=require("react-redux"),Ut=require("react/jsx-runtime"),zc=({onLogIn:t})=>{let e=k(ni),o=b("floatingMenu"),n=b("productName"),s=(0,Uc.useDispatch)(),r=(0,Kc.useSelector)(ee),i=h("FloatingMenu",Fc);if(r===null||o===!1)return null;let a=()=>{r===!0?s(ce(!0)):t()};return(0,Ut.jsxs)("button",{className:(0,Bc.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,Ut.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:n})}),(0,Ut.jsxs)("div",{className:i.icon,children:[(0,Ut.jsx)(Hc,{className:i.logo,color:"pink"}),r===!1&&(0,Ut.jsx)(Dc,{className:i.lock})]})]})};var Ns=require("react"),Ze=require("react-redux");var Vc=require("react");function fo(t){(0,Vc.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function zt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}function ho(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 $c=require("@reduxjs/toolkit"),af={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Is=({ui:t})=>t.overlayCollapsed;var Wc=(0,$c.createSlice)({name:"ui",initialState:af,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:tn,setInputHasFocus:si,setOverlayCollapsed:mt,setOpenOverlayWhenTyping:Gc,setOverlayCollapsedUserOverwrite:jc}=Wc.actions,qc=Wc.reducer;var As=require("react");var Jc=require("interweave"),yo=require("react"),Ls=require("react-redux");var Xc=require("react");function Zc(t,e,o){(0,Xc.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var Qc={root:"xi",actions:"fi",badge:"gi",formattedText:"do"};var Vt=require("react/jsx-runtime"),df=["search","personal-collection-search","search-autocomplete"];function uf(t,e,o,n={}){let s="";return df.includes(e)?s=Ml(Kr(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Kr(t,o,n),n.placeholders===!0&&(s=Nl(s)),s}var pf=()=>{},mf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=b("inlineSuggestions"),r=(0,Ls.useSelector)(oo),i=(0,Ls.useDispatch)(),a=h("TextSuggestion",Qc),c=(0,yo.useRef)(null);(0,yo.useEffect)(()=>{let d=setTimeout(()=>{i(Ka({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(d)}},[o]),Zc(c,"click",()=>{i(lt(t)),i(Ne({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,yo.useMemo)(()=>uf(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,Vt.jsxs)("div",{className:a.root,onMouseEnter:()=>i(lt(t)),children:[(0,Vt.jsx)(M,{ref:c,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:pf,children:(0,Vt.jsx)(Jc.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:l})}),e&&n&&(0,Vt.jsx)("div",{className:a.actions,children:(0,Vt.jsx)(ms,{onFeedback:()=>n(o),suggestion:o.text})})]})},Yc=mf;var ri=require("react/jsx-runtime"),gf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,As.useMemo)(()=>{let r=e.map((i,a)=>(0,ri.jsx)(Yc,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,ri.jsx)(As.Fragment,{children:s})},Ms=gf;var ed={root:"bi",paper:"hi"};var on=require("react/jsx-runtime"),hf=({textSuggestions:t,selectedIndex:e})=>{let o=(0,Ns.useRef)(null),n=h("InlineSuggestionsOverlay",ed),s=(0,Ze.useSelector)(ho),r=(0,Ze.useDispatch)(),i=(0,Ze.useSelector)(ee),a=(0,Ze.useSelector)(to),c=(0,Ze.useSelector)(Is),l=b("showTextSuggestions");return fo(()=>{setTimeout(()=>{r(mt({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Ns.useEffect)(()=>{let d=o.current;if(!d||!d.parentElement)return;d.parentElement.style.left="0px";let u=d.getBoundingClientRect();d.parentElement.style.left=`${Math.min(window.innerWidth-4-u.right,0)}px`}),c||!s||!l||t.length===0||i!==!0||a===!1?null:(0,on.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,on.jsx)("div",{ref:o,className:n.paper,children:(0,on.jsx)(le,{children:(0,on.jsx)(Ms,{suggestions:t,selectedIndex:e})})})})},yf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),td=(0,Ze.connect)(yf)(hf);var od=require("react-redux");var nn=require("react/jsx-runtime"),vf=({children:t})=>{let o=b("locale").replace("-","");return(0,nn.jsx)(_r.Provider,{value:o,children:t})},Sf=({store:t,customStyles:e={},children:o})=>(0,nn.jsx)(od.Provider,{store:t,children:(0,nn.jsx)(vf,{children:(0,nn.jsx)(Io.Provider,{value:e,children:o})})}),$t=Sf;var _s=T(require("classnames")),vo=require("react"),De=require("react-redux");var nd=require("react");function sd(t,e){let[o,n]=(0,nd.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return w.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){w.error(i)}}]}var rd=()=>/Mac/i.test(navigator.platform);var ad=T(require("classnames")),Qe=require("react");var ii={};Z(ii,{enUS:()=>xf,nlNL:()=>bf});var xf={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"}]}]},bf={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 id={root:"mi",anchor:"ui",anchorButton:"yi"};var gt=require("react/jsx-runtime"),ai=(t,e,o)=>n=>(0,gt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),wf=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=k(ii),i=he(),a=h("Login",id),c=b("productName"),l=(0,Qe.useCallback)(y=>{y.preventDefault(),n&&n(parseInt(y.target.value,10))},[]),d=(0,Qe.useCallback)(y=>{y.preventDefault(),i.send(so,!0)},[e]),u=(0,Qe.useMemo)(()=>y=>(0,gt.jsx)("a",{onClick:v=>{v.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:y},"login"),[e]),p=(0,Qe.useCallback)(y=>(0,gt.jsx)("button",{type:"button",className:a.anchorButton,onClick:d,children:y},"prompt"),[d]),{min:m,hour:g,day:f}=(0,Qe.useMemo)(()=>({min:ai(a,60*10,l),hour:ai(a,60*60,l),day:ai(a,60*60*12,l)}),[]);return(0,gt.jsxs)("div",{className:(0,ad.default)(t,a.root),children:[r("loginPlease",{login:o?p:u,productName:c}),n&&(0,gt.jsxs)(Qe.Fragment,{children:[(0,gt.jsx)("br",{}),r("snooze",{min:m,hour:g,day:f})]})]})},Os=wf;var cd=require("react-redux");var ld={root:"lo",text:"wi"};var sn=require("react/jsx-runtime"),Ef=({title:t})=>{let e=h("SearchTrigger",ld),o=(0,cd.useDispatch)();return(0,sn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ce(!0)),children:[(0,sn.jsx)(io,{}),(0,sn.jsx)("span",{className:e.text,children:t})]})},dd=Ef;var li={};Z(li,{enUS:()=>kf,nlNL:()=>Rf});var kf={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"}]},Rf={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 ud={root:"vi",isInline:"S",toggleButton:"ki",toggleButtonWrapper:"E",toggleButtonWrapperHidden:"zi",isCollapsed:"so",collapsible:"ji",hints:"co",hintsHidden:"Yi",triggers:"xo",triggersRight:"qi"};var F=require("react/jsx-runtime"),If=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=h("SuggestionsOverlay",ud),s=k(li),r=(0,De.useSelector)(ho),i=Da(),a=(0,De.useDispatch)(),c=(0,vo.useRef)(null),l=b("searchTriggerKey"),d=b("productName"),u=(0,De.useSelector)(Is),p=(0,De.useSelector)(ee),m=(0,De.useSelector)(to),[g,f]=(0,vo.useState)(null),y=b("showSearch"),P=b("showTextSuggestions"),v=b("adminUrl"),S=b("isEmbedded"),[I,x]=sd("dd-snooze-until-ms",0),E=u||I>Date.now(),O=(0,De.useSelector)(q=>q.input.text),j=t.filter(q=>q.source!=="gpt").length,V=()=>{E&&x(0),a(jc(!E))},L=q=>{a(Q({name:"suggestion feedback",data:{text:q.text,source:"overlay",context:O},options:{includeConversationData:!0}}))},_=q=>{let ge=Date.now()+q*1e3;x(ge),w.info(`Snooze until: ${new Date(ge)}`),a(mt({collapse:!0}))};return(0,vo.useEffect)(()=>{j===0&&f(null)},[t,j]),fo(()=>{a(mt({collapse:!0,skipWhenInputFocus:!0}))}),p===null||m===!1?null:p===!1?(0,F.jsxs)("div",{ref:c,className:(0,_s.default)(n.root,{[n.isCollapsed]:E}),children:[!E&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1}}),(0,F.jsx)("div",{className:n.triggersRight,children:(0,F.jsx)(kt,{className:n.toggleButton,title:s("collapse"),onClick:V,isCollapsed:!1})})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(kt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:V,isCollapsed:!0})}),(0,F.jsx)("div",{className:n.collapsible,children:(0,F.jsx)(Os,{loginUrl:v,isEmbedded:S,onLogIn:o,onSnooze:_})})]}):!i||!r?null:(0,F.jsxs)("div",{ref:c,className:(0,_s.default)(n.root,{[n.isCollapsed]:E}),children:[!E&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1},children:y&&(0,F.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(s(rd()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,F.jsx)(dd,{title:s("search")})})}),(0,F.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,F.jsx)("div",{className:(0,_s.default)(!g&&n.hintsHidden,n.hints),children:g}),(0,F.jsx)(kt,{className:n.toggleButton,title:s("collapse"),onClick:V,isCollapsed:!1})]})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(kt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:V,isCollapsed:!0})}),j>0&&P&&(0,F.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,F.jsx)(le,{children:(0,F.jsx)(Ms,{onFeedback:L,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Lf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),pd=(0,De.connect)(Lf)(If);var Zs=T(require("classnames")),Dd=require("interweave"),et=require("react"),Hd=require("react-redux");var So=require("react");function Ds(t){return t.contentEditable==="true"}function Af(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 md(t){let{selectionStart:e,selectionEnd:o}=Ds(t)?Af(t):t;return[e,o]}function gd(t){let[,e]=(0,So.useState)(),o=(0,So.useRef)(null);return o.current=md(t),(0,So.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=md(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 fd(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(Ln);if(!i||i.length===0)return;let a=0;i.find(c=>{let l=n.indexOf(c,a);return s>l&&r<l+c.length?(o.selectionStart=l,o.selectionEnd=l+c.length,!0):(a=l+c.length,!1)})}var hd=require("react"),Mf=["div","span","mark","strong","b","i","u","em"];function ci(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(Mf.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,hd.cloneElement)(n,{children:ci(i,e,o+1)})]}return[...t,...e]}function ft(t){return t.tagName.toLowerCase()==="textarea"}var Le={root:"Ci",container:"Si",agentText:"fo",tabText:"go",hint:"G",matchSelection:"bo",focus:"Ei",resetIndent:"Gi",matchKeyword:"p",matchPlaceholder:"d",hover:"ho",hintText:"Ni",popover:"Ai",popoverRoot:"Fi",popoverContentContainer:"mo",popoverContent:"Hi",selectionOptions:"Li",selectionOptionsIsHidden:"Mi",selectionOptionsButton:"Ri",caret:"Ti",popoverSuggestionsRoot:"Ui",suggestionsOverlayInputStyles:"Bi"};var kd=T(require("classnames")),Rd=require("interweave"),Ws=require("react");var xo=require("react");function yd(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function Hs(t){let e=(0,xo.useRef)(null),[o,n]=(0,xo.useState)(!1);return(0,xo.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=yd((d,u)=>{let p=e.current;if(!p)return;let m=d/r,g=u/r,f=p.getBoundingClientRect(),y=m>f.x&&m<f.x+f.width&&g>f.y&&g<f.y+f.height;y&&!s?(s=!0,n(!0)):!y&&s&&(s=!1,n(!1))},({clientX:d,clientY:u})=>[d,u]),[c,l]=yd(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",c),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",c)}},[e]),[e,o]}function vd(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Fs(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Sd(t){return t!=null}var ui=T(require("classnames")),ve=require("react");var Bs=require("react"),Of=["bottom","height","left","right","top","width"],_f=(t={},e={})=>Of.some(o=>t[o]!==e[o]),Je=new Map,xd,bd=()=>{let t=[],e=[];Je.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();_f(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Je.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),xd=window.requestAnimationFrame(bd)};function Df(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&&bd()},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(xd)}}}}function di(t){let[e,o]=(0,Bs.useState)(null);return(0,Bs.useLayoutEffect)(()=>{if(!t.current)return;let n=Df(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var bo=require("react"),wd=require("react-dom");var Cd={root:"Di"};var Td=({children:t,parentNode:e})=>{let[o,n]=(0,bo.useState)(null),s=(0,bo.useContext)(Io);return(0,bo.useLayoutEffect)(()=>{let r=document.createElement("div");return zt(r),r.classList.add(Cd.root),s!=null&&s.portalRootNode&&r.classList.add(s==null?void 0:s.portalRootNode),(e||document.body).appendChild(r),n(r),()=>{r.isConnected&&r.remove()}},[]),o?(0,wd.createPortal)(t,o):null};var He={ref:"Ii",root:"o",positionAbove:"l",positionBelow:"s",positionLeft:"c",positionRight:"x",alignStart:"f",alignCenter:"g",alignEnd:"b"};var Ks=require("react/jsx-runtime"),Us=(t=!1)=>{let[e,o]=(0,ve.useState)(t),n=(0,ve.useCallback)(()=>o(!0),[]),s=(0,ve.useCallback)(()=>o(!1),[]),r=(0,ve.useCallback)(()=>o(a=>!a),[]),i=(0,ve.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function pi(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 Co=({className:t,triggerRef:e,boundaryRef:o=(0,ve.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=pi,parentNode:a,...c})=>{let l=di(e),d=di(o),u=(0,ve.useMemo)(()=>i(l,d,0),[l,d]);return(0,Ks.jsx)(Td,{parentNode:a,children:(0,Ks.jsx)("div",{className:(0,ui.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:u,...c,role:"dialog",children:(0,Ks.jsx)("div",{className:(0,ui.default)(t,He.root),children:r})})})};var Ed=T(require("classnames")),zs=require("react");var mi=require("react/jsx-runtime"),Vs=(0,zs.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,zs.useRef)(null),r=h("TabCompletion",Le);return(0,mi.jsx)("div",{ref:Fs([s,n]),className:(0,Ed.default)(t,r.popoverContentContainer),...o,children:(0,mi.jsx)("div",{className:r.popoverContent,children:e})})});var ht=require("react/jsx-runtime"),Bf=t=>e=>{let o=pi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Kf=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=h("TabCompletion",Le),i=Us(),a=(0,Ws.useMemo)(()=>Bf(t.getBoundingClientRect()),[t]),[c,l]=Hs(t);return(0,Ws.useEffect)(()=>{l?i.open():i.close()},[l]),(0,ht.jsxs)("span",{children:[(0,ht.jsx)("mark",{ref:Fs([c,i.triggerRef]),className:(0,kd.default)(r.matchKeyword,{[r.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,ht.jsx)(Co,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,ht.jsx)(Vs,{style:o,children:(0,ht.jsx)("div",{className:r.hintText,children:s})})})]})},$s=class extends Rd.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${vd(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(Sd);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,ht.jsx)(Kf,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Pd=require("interweave"),Id=T(require("classnames"));var gi=require("react/jsx-runtime"),Uf=({inputElement:t,children:e})=>{let o=h("TabCompletion",Le),[n,s]=Hs(t);return(0,gi.jsx)("mark",{ref:n,className:(0,Id.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},Gs=class extends Pd.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,gi.jsx)(Uf,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var qs=T(require("classnames")),Od=require("interweave"),ne=require("react"),_d=require("react-redux");var fi=require("react/jsx-runtime"),Ld=()=>(0,fi.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,fi.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 yt=require("react"),rn=require("react-redux"),Md=T(require("lodash.debounce"));var Ad={root:"Oi",content:"Xi"};function js(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 hi(t){return t.replace("https://www.","").replace("https://","")}var Se=require("react/jsx-runtime"),Vf=3,$f=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Wf=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Vf})=>{let r=h("LinkSearch",Ad),[i,a]=(0,yt.useState)(""),c=(0,rn.useDispatch)(),l=(0,rn.useSelector)(Tc("url")),d=(0,rn.useSelector)(nl("URL",$f)),[u,p]=(0,yt.useState)(d.length-1),m=b("fallbackImage"),g=v=>{let S=v.target;a(S.value)},f=(v,S)=>{v.stopPropagation(),v.preventDefault(),window.open(S,"_blank")},y=v=>{var x;let S=u-1<0?d.length-1:u-1,I=u+1===d.length?0:u+1;v.code==="Escape"&&(a(""),e()),v.code==="ArrowUp"&&p(S),v.code==="ArrowDown"&&p(I),v.code==="Enter"&&t(((x=d[u])==null?void 0:x.text)||i)},P=(0,yt.useCallback)((0,Md.default)(v=>{c(It({query:v,type:"URL",tags:["link-search"]}))},300),[]);return(0,yt.useEffect)(()=>{i&&P(i)},[i]),(0,yt.useEffect)(()=>()=>{c($n())},[]),(0,Se.jsxs)("div",{className:r.root,children:[(0,Se.jsx)(le,{withDivider:!0,children:(i?d:l).slice(0,s).map((v,S)=>(0,Se.jsx)(M,{selected:u===S,onClick:()=>t(v.text),"data-testid":"linksearch-suggestion",children:(0,Se.jsxs)(D,{children:[(0,Se.jsx)(D.Image,{src:js(v,"small",m||void 0),title:v.title||v.text}),(0,Se.jsxs)(D.Content,{className:r.content,cropText:!0,children:[(0,Se.jsx)(D.Title,{children:v.title||hi(v.text)}),v.title&&hi(v.text)]}),(0,Se.jsx)(M.Actions,{children:(0,Se.jsx)(M.ActionButton,{label:n,onClick:I=>f(I,v.text)})})]})},v.text))}),(0,Se.jsx)(Uo,{value:i,onChange:g,autoFocus:!0,placeholder:o,onKeyUp:y})]})},Nd=Wf;var yi={};Z(yi,{enUS:()=>Gf,nlNL:()=>jf});var Gf={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},jf={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var oe=require("react/jsx-runtime"),qf=(0,ne.forwardRef)((t,e)=>{let o=h("TabCompletion",Le);return(0,oe.jsx)("mark",{ref:e,className:(0,qs.default)(o.matchSelection)},"selection-start")}),Xf=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=k(yi),i=h("TabCompletion",Le),a=(0,ne.useRef)(null),c=(0,ne.useRef)(null),[l,d]=(0,ne.useState)(null),u=(0,_d.useDispatch)(),p=Us(document.activeElement===n),[m]=(0,ne.useState)(()=>document.createRange());p.triggerRef.current=m,(0,ne.useEffect)(()=>()=>m.detach(),[]),(0,ne.useEffect)(()=>{let f=t.current,y=a.current;!f||!y||(m.setStart(f,0),m.setEnd(y,0))},[t.current,a.current]),fo(()=>{p.close()});let g=(0,ne.useCallback)(f=>{let y=m.toString(),P=/^http(s?):\/\//.test(f)?f:`https://${f}`;u(Fn({text:`[${y}](${P})`,replace:"selection"}))},[]);return(0,oe.jsxs)("span",{children:[(0,oe.jsx)("mark",{ref:a,className:(0,qs.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":p.opened?"true":"false",children:s}),p.opened&&(0,oe.jsx)(Co,{className:i.popoverRoot,triggerRef:p.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,oe.jsxs)(Vs,{style:o,ref:c,children:[(0,oe.jsx)("div",{className:(0,qs.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:l!==null}),children:(0,oe.jsxs)("button",{type:"button",tabIndex:l===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>d("insertLink"),children:[(0,oe.jsx)(Ld,{}),(0,oe.jsx)("span",{children:"\xA0"}),(0,oe.jsx)("span",{children:r("insertLink")})]})}),l==="insertLink"&&(0,oe.jsx)(Nd,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:g,onDismiss:()=>{d(null),p.close()}})]})})]},"selection-end")},Xs=class extends Od.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,ne.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,oe.jsx)(qf,{ref:this.startRef}):(0,oe.jsx)(Xf,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Fd=require("react-redux");var Ye=require("react/jsx-runtime"),Zf=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:c})=>{let l=h("TabCompletion",Le),d=b("insertLink"),u=b("showMidSentenceSuggestions"),p=b("inlineSuggestions"),m=gd(a),g=(0,et.useRef)(null),f=(0,Fd.useSelector)(ee);(0,et.useEffect)(()=>{ft(a)&&m&&fd(a,m)},[m]);let y=(0,et.useCallback)(S=>{if(!s||!o)return S;let I=[(0,Ye.jsx)("span",{className:l.resetIndent,children:"\u200B"},"u200B"),(0,Ye.jsx)("span",{"data-testid":"tab-completion",className:(0,Zs.default)(l.tabText,l.resetIndent),"data-source":c,children:o},"tabText")];return n&&I.push((0,Ye.jsx)("span",{className:(0,Zs.default)(l.hint,l.resetIndent),children:(0,Ye.jsx)(kn,{keyCode:"tab"},"tabHint")})),ci(S,I)},[s,o,n]),P=(0,et.useMemo)(()=>{let S=[];return d&&S.push(new Xs("selection")),S.push(new Gs("placeholders")),r&&S.push(new $s("keywords")),S},[p,d,r]),v=(0,et.useMemo)(()=>{let S=window.getComputedStyle(a);return{"--dd-color":S.color,"--dd-font-size":S.fontSize,"--dd-font-family":S.fontFamily,"--dd-font-variant":S.fontVariant}},[]);return!t||!f?null:(0,Ye.jsxs)("div",{ref:S=>{S!=null&&S.parentElement&&(g.current=S==null?void 0:S.parentElement)},className:l.root,style:v,children:[(0,Ye.jsx)(Dd.Interweave,{tagName:"span",containerTagName:"div",className:(0,Zs.default)(l.container,l.agentText),disableLineBreaks:ft(a),content:e||"\u200B",onAfterParse:y,matchers:P,selection:m,keywordMatches:i,inputElement:a,inputStyle:v,boundaryRef:g,inlineSuggestionsOnlyAtEnd:!u}),(0,Ye.jsx)("br",{})]})},Qf=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var f;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",c=t.html??ro(t.text),l=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:d}=e,{isSupported:u}=s,{showTabCompletion:p,visible:m,showStyleSuggestions:g}=o;return{showTabHint:d,showStyleSuggestions:g,showTabCompletion:p,content:c,tabText:l,source:a,keywordMatches:((f=n.list)==null?void 0:f.keywordMatches)??[],enabled:m&&u!==!1}},Bd=(0,Hd.connect)(Qf)(Zf);var zu=T(require("classnames")),tr=require("react"),B=require("react-redux");var vt=require("@reduxjs/toolkit");var Kd={list:[],fetchState:"idle"},zd=t=>t.autoflows.list||[],Ud=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},tt=(0,vt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),vi=(0,vt.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))}),Si=(0,vt.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))}),Jf=(0,vt.createSlice)({name:"autoflows",initialState:Kd,reducers:{},extraReducers:t=>{t.addCase(vi.pending,(e,o)=>{let n=Ud(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Si.pending,(e,o)=>{let n=Ud(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(tt.pending,e=>{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(N,()=>Kd)}}),Vd=(0,vt.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))})}),$d=(0,vt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Wd=Jf.reducer;var St=require("@reduxjs/toolkit");var Gd={list:[],fetchState:"idle",sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},jd=t=>t.customMessages.list,qd=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Xd=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Zd=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),an=(0,St.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Qs=(0,St.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)}),Js=(0,St.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)}),Qd=(0,St.createSlice)({name:"customMessages",initialState:Gd,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(an.pending,e=>{e.fetchState="loading"}).addCase(an.rejected,e=>{e.fetchState="error"}).addCase(an.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Qs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Qs.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Js.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Js.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(N,()=>Gd)}}),Jd=(0,St.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(Qd.actions.onCustomMessage(r))})}),Yd=(0,St.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),eu=Qd.reducer;var ln=require("@reduxjs/toolkit"),Yf={token:null,accountUrl:null,interval:null},tu=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},xi=(0,ln.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),bi=(0,ln.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(xi()),setInterval(()=>n(xi()),o)}),ou=(0,ln.createSlice)({name:"passwordlessToken",initialState:Yf,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(xi.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(bi.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:nu}=ou.actions,su=ou.reducer;var wo=require("@reduxjs/toolkit");var Ci={cues:[],fetchState:"idle"},ru=t=>{var e;return(e=t.rules)==null?void 0:e.cues},eh=(0,wo.createAction)("rules/resetCues"),Wt=(0,wo.createAsyncThunk)("rules/evaluate",async(t,e)=>{var o,n;try{let{deepdeskAPI:s}=e.extra,r=e.getState(),i=(o=r.conversation.current)==null?void 0:o.id;if(!i)throw new Error("No current conversation to evaluate rules");if(!(await s.getAccount()).ruleEngine)throw new Error("Rule engine is not enabled for this account");if(!(await s.getRules()).some(d=>d.label===t.label))throw new Error(`No rules found with label: ${t.label}`);return await s.evaluateRule(t.label,i,{tags:((n=r.conversation.current)==null?void 0:n.tags)||void 0,...t.params})}catch(s){return w.info(s.message),[]}}),iu=(0,wo.createSlice)({name:"answer",initialState:Ci,reducers:{removeCue(t,e){t.cues=t.cues.filter(o=>o.rule.id!==e.payload.id)}},extraReducers:t=>{t.addCase(Wt.pending,e=>{e.fetchState="loading"}).addCase(Wt.rejected,e=>{e.fetchState="error"}).addCase(Wt.fulfilled,(e,o)=>{let n=o.payload.map(r=>r.rule.id),s=e.cues.filter(r=>!n.includes(r.rule.id));e.fetchState="done",e.cues=[...o.payload,...s]}).addCase(N,()=>Ci).addCase(eh.toString(),()=>Ci)}}),{removeCue:au}=iu.actions,lu=iu.reducer;var yu=require("react"),vu=require("react-redux");var gu=T(require("classnames")),fu=require("react");var du=T(require("classnames"));var cu={root:"Ji"};var pu=require("react/jsx-runtime"),oh=({className:t,children:e})=>{let o=h("Unicode",cu);return(0,pu.jsx)("span",{className:(0,du.default)(t,o.root),children:e})},uu=oh;var mu={isDisabled:"Ki",buttonStart:"Pi",root:"Qi",buttonStop:"uo",stateBadge:"h",isCompleted:"Vi",isStarted:"Wi",isAborted:"Zi"};var wi={};Z(wi,{enUS:()=>sh,nlNL:()=>rh});var sh={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},rh={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 pe=require("react/jsx-runtime"),ah=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=h("Autoflow",mu),a=k(wi),c=e==="Started"?"stop":"start",l=c==="start"?"\u25B6":c==="stop"?"\u25FC":"";return(0,pe.jsxs)(M,{className:(0,gu.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,pe.jsx)(D,{children:(0,pe.jsxs)(D.Content,{children:[(0,pe.jsxs)(D.Title,{children:[e&&(0,pe.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,pe.jsx)("span",{children:n})]})}),(0,pe.jsx)(M.Actions,{fixed:e==="Started",children:(0,pe.jsx)(M.ActionButton,{primary:!0,className:c==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,pe.jsxs)(fu.Fragment,{children:[(0,pe.jsx)(uu,{children:l})," ",(0,pe.jsx)("span",{children:a(c)})]})})})]})},hu=ah;var Ti=require("react/jsx-runtime"),lh=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},ch=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Ti.jsx)(yu.Fragment,{children:t.map(s=>(0,Ti.jsx)(hu,{displayName:s.displayName,description:s.description,disabled:s.isBusy||lh(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),dh=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},uh={onStartAutoflow:vi,onStopAutoflow:Si},Su=(0,vu.connect)(dh,uh)(ch);var xu=T(require("classnames")),Ei=require("react"),Gt=require("react-redux");var ot={root:"yo",title:"wo",isUsed:"_i",quickReplies:"or",quickReply:"er",hasError:"ir",label:"rr",errorIcon:"tr"};var ie=require("react/jsx-runtime"),mh=({suggestion:t})=>{let e=k(Dt),o=(0,Gt.useDispatch)(),n=(0,Gt.useSelector)(qd(t.text)),s=(0,Gt.useSelector)(Xd(t.text)),r=(0,Gt.useSelector)(Zd(t.text)),i=(0,Gt.useSelector)(eo),{replyOptions:a}=t,c=(0,Ei.useCallback)(d=>{d.preventDefault(),d.stopPropagation(),!(n||!i)&&o(Qs({platformSessionId:i,suggestion:t}))},[t,n,o,i]),l=(0,Ei.useCallback)(d=>{if(d.preventDefault(),d.stopPropagation(),!i||!a)return;let u=parseInt(d.target.dataset.index,10),p=a[u];o(Js({platformSessionId:i,reply:p,suggestion:t}))},[t,n,o,i]);return(0,ie.jsxs)(M,{onClick:c,className:(0,xu.default)(ot.root,{[ot.isUsed]:n,[ot.hasError]:r}),children:[(0,ie.jsx)(D,{children:(0,ie.jsxs)(D.Content,{children:[(0,ie.jsxs)(D.Title,{className:ot.title,children:[t.text," ",(0,ie.jsx)(Rn,{className:ot.label,children:"analyse tool"})," ",r&&(0,ie.jsx)("span",{className:ot.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,ie.jsx)("ul",{className:ot.quickReplies,children:a.map(d=>(0,ie.jsx)("li",{className:ot.quickReply,children:d.title},d.title))})]})}),(0,ie.jsxs)(M.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,ie.jsx)(M.DropdownButton,{label:e("answer"),disabled:s,children:a.map((d,u)=>(0,ie.jsx)(M.DropdownItem,{index:u,label:d.title,onClick:l},d.title))}),(0,ie.jsx)(M.ActionButton,{primary:!0,disabled:n,onClick:c,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},bu=mh;var Ys=require("react"),wu=require("react-redux"),Pi=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 Cu={root:"nr",entity:"r",entityText:"ar",iconWrapper:"pr",icon:"dr",iconClicked:"lr"};var Fe=require("react/jsx-runtime"),fh=({entities:t})=>{let e=h("EntitiesWidgetList",Cu),[o,n]=(0,Ys.useState)(void 0),s=(0,wu.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Mt(a.text),s(Q({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Ys.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Fe.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,c)=>(0,Fe.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Fe.jsx)("span",{className:e.entityText,children:a.text}),(0,Fe.jsxs)("span",{className:e.iconWrapper,children:[(0,Fe.jsx)("span",{className:(0,Pi.default)(e.icon),children:(0,Fe.jsx)(Ri,{})}),(0,Fe.jsx)("span",{className:(0,Pi.default)(e.icon,o===c&&e.iconClicked),children:(0,Fe.jsx)(Ri,{})})]})]},a.text))})},Tu=fh;var Ii=require("react/jsx-runtime"),Eu=()=>(0,Ii.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Ii.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 Li=require("react/jsx-runtime"),ku=()=>(0,Li.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Li.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 Ai=require("react/jsx-runtime"),Ru=()=>(0,Ai.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ai.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 _u=require("react-redux");var Oi=T(require("classnames")),er=require("react");var cn=require("react/jsx-runtime"),Pu=({className:t})=>(0,cn.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,cn.jsx)("line",{x1:"2",y1:"10",x2:"10",y2:"2",stroke:"black",strokeWidth:"1"}),(0,cn.jsx)("line",{x1:"2",y1:"2",x2:"10",y2:"10",stroke:"black",strokeWidth:"1"})]});var Lu=T(require("dompurify")),xt=require("react"),Au=T(require("snarkdown"));var Iu={fadeup:"N",root:"i",popover:"sr",options:"vo",copyIcon:"A",option:"ko",divider:"cr"};var nt=require("react/jsx-runtime");function yh(t){return`<button type="button" class=${t}><svg version="1.1" x="0px" y="0px" viewBox="0 0 115.77 122.88" width="10px" height="10px" fill="black"><g><path d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"/></g></svg></button>`}function Mi(t){let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(o=>o.remove()),e.textContent??""}function vh(t){return t.replace(/\r\n/g,`
|
|
8
|
+
`)}var Sh=({content:t,useLabel:e,copyLabel:o,onCopy:n,onUse:s})=>{let r=h("Markdown",Iu),i=(0,xt.useRef)(null),[a,c]=(0,xt.useState)(null),l=(0,xt.useMemo)(()=>{let g=(0,Au.default)(vh(t));return Lu.default.sanitize(g).replace(/<\/code>/g,`${yh(r.copyIcon)}</code>`)},[t]),d=g=>{var P;let f=g.target,y=!!((P=i.current)!=null&&P.querySelector("code"));a||y&&f.tagName!=="CODE"||!y&&f!==i.current||(f.addEventListener("mouseleave",()=>c(null),{once:!0}),c(f))},u=()=>{if(!a)return;c(null);let g=a.querySelector("button");g&&(qe(g,r.fadeup),n(Mi(a)))},p=g=>{g.target.tagName.toLowerCase()==="button"&&(qe(g.target,r.fadeup),n(Mi(g.target.parentElement)))},m=()=>{a&&(c(null),s(Mi(a)))};return(0,nt.jsxs)(xt.Fragment,{children:[a&&(0,nt.jsx)(Co,{triggerRef:{current:a},parentNode:a,className:r.popover,children:(0,nt.jsxs)("div",{className:r.options,children:[(0,nt.jsx)("button",{type:"button",className:r.option,onClick:u,children:o}),(0,nt.jsx)("div",{className:r.divider}),(0,nt.jsx)("button",{type:"button",className:r.option,onClick:m,children:e})]})}),(0,nt.jsx)("div",{ref:i,className:r.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:d,onClick:p})]})},Mu=Sh;var Ni={};Z(Ni,{enUS:()=>xh,nlNL:()=>bh});var xh={useCue:[{type:0,value:"Use"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},bh={useCue:[{type:0,value:"Gebruik"}],copyCue:[{type:0,value:"Kopieer"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Nu={fadeup:"F",fadedown:"H",selected:"zo",thumbsUp:"xr",thumbsDown:"fr"};var me=require("react/jsx-runtime"),wh=({cue:t,onRemove:e,onCopy:o,onUse:n,onThumbsUp:s,onThumbsDown:r})=>{let i=h("WidgetCue",Nu),a=k(Ni),c=co(),[l,d]=(0,er.useState)(null),u=y=>{o&&o(y,t)},p=y=>{n&&n(y,t)},m=y=>{y.preventDefault(),y.stopPropagation(),e(t)},g=y=>{y.preventDefault(),y.stopPropagation(),qe(y.target,i.fadeup),d("up"),s(t)},f=y=>{y.preventDefault(),y.stopPropagation(),qe(y.target,i.fadedown),d("down"),r(t)};return(0,er.useEffect)(()=>{c("Assistant response displayed",{name:t.rule.name,description:t.rule.description,group:t.rule.label})},[]),(0,me.jsxs)(M,{"data-testid":"cue",children:[(0,me.jsx)(D,{children:(0,me.jsxs)(D.Content,{children:[t.title&&(0,me.jsx)(D.Title,{"data-testid":"widget-cue-title",children:t.title}),(0,me.jsx)(Mu,{content:t.text,useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:u,onUse:p})]})}),(0,me.jsx)(M.IconButton,{title:a("thumbsUp"),onClick:g,icon:(0,me.jsx)(bs,{}),className:(0,Oi.default)(i.thumbsUp,l==="up"&&i.selected),disabled:!!l}),(0,me.jsx)(M.IconButton,{title:a("thumbsDown"),onClick:f,icon:(0,me.jsx)(xs,{}),className:(0,Oi.default)(i.thumbsDown,l==="down"&&i.selected),disabled:!!l}),(0,me.jsx)(M.IconButton,{title:a("removeCue"),onClick:m,icon:(0,me.jsx)(Pu,{})})]})},Ou=wh;var dn=require("react/jsx-runtime"),Th=({cues:t})=>{let e=(0,_u.useDispatch)(),o=he(),n=co(),s=l=>{e(au({id:l.rule.id})),n("Assistant response closed",{name:l.rule.name,group:l.rule.label,description:l.rule.description})},r=(l,d)=>{Mt(l),n("Assistant response copied",{name:d.rule.name,group:d.rule.label,description:d.rule.description,copiedText:l})},i=(l,d)=>{o.send(ct,{text:l,suggestion:{source:"cue",sourceText:l}}),n("Assistant response used",{name:d.rule.name,group:d.rule.label,description:d.rule.description,usedText:l})},a=l=>{n("Assistant response feedback",{name:l.rule.name,group:l.rule.label,description:l.rule.description,thumb:"up"})},c=l=>{n("Assistant response feedback",{name:l.rule.name,group:l.rule.label,description:l.rule.description,thumb:"down"})};return(0,dn.jsx)(dn.Fragment,{children:t.map(l=>(0,dn.jsx)(Ou,{cue:l,onRemove:s,onCopy:r,onUse:i,onThumbsDown:c,onThumbsUp:a},l.rule.id))})},Du=Th;var Fu=require("react");var Eh=/(https?:\/\/[^\s]+)/,Hu=t=>t.split(" ").find(e=>Eh.test(e));var xe=require("react/jsx-runtime"),kh=({suggestion:t,lines:e,onUse:o})=>{var d;let n=t.text||t.url||t.message,s=Hu(n),r=k(Dt),i=b("showImages"),a=b("fallbackImage"),c=u=>{u.preventDefault(),u.stopPropagation(),o(n)},l=(0,Fu.useCallback)(u=>{window.open(s,"_blank"),u.stopPropagation(),u.preventDefault()},[s]);return(0,xe.jsxs)(M,{onClick:c,"data-testid":"edit-suggestion",children:[(0,xe.jsxs)(D,{children:[i&&t.image&&(0,xe.jsx)(D.Image,{src:js(t,"small",a||void 0),title:t.title}),(0,xe.jsxs)(D.Content,{children:[t.title&&(0,xe.jsx)(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&(0,xe.jsx)(M.Labels,{labels:t.searchKeywords}),(0,xe.jsx)(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:n})]})]}),(0,xe.jsxs)(M.Actions,{children:[s&&(0,xe.jsx)(M.ActionButton,{onClick:l,label:r("visitUrl")}),(0,xe.jsx)(M.ActionButton,{primary:!0,onClick:c,label:r("useSuggestion")})]})]})},Bu=kh;var un=require("react/jsx-runtime"),Rh=({lines:t,suggestions:e})=>{let o=he(),n=(s,r)=>{o.send(ct,{text:s,suggestion:{...r,source:r.source,sourceText:r.text}})};return(0,un.jsx)(un.Fragment,{children:e.map(s=>(0,un.jsx)(Bu,{suggestion:s,lines:t,onUse:r=>n(r,s)},s.text||s.url||s.message))})},Ku=Rh;var pn={};Z(pn,{enUS:()=>Ph,nlNL:()=>Ih});var Ph={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},Ih={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var mn={root:"gr",loginText:"br",stateText:"jo",sectionList:"hr",shortcutList:"mr",shortcut:"ur",link:"Yo"};var R=require("react/jsx-runtime"),or=(t,e)=>{let o=(0,B.useSelector)(ee);(0,tr.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},Ah=({onLogIn:t})=>{let e=h("Widget",mn),o=b("isEmbedded"),n=b("adminUrl");return(0,R.jsx)("div",{className:e.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Os,{isEmbedded:o,loginUrl:n,onLogIn:t})})},"login")},Uu=({text:t})=>{let e=h("Widget",mn);return(0,R.jsx)("div",{className:e.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t})})},"notification")},Mh=()=>{let t=k(pn),e=(0,B.useDispatch)(),o=h("Widget",mn),n=b("showSearch"),s=b("showSummaryCommand"),r=b("showKnowledgeSearch"),i=(0,B.useSelector)(tu("/admin/")),a=he(),c=b("productName"),l=n||s||r||i;return or(()=>(e(bi()),()=>{e(nu())}),[e]),l?(0,R.jsx)(Ue,{title:t("actions"),type:"shortcuts",children:(0,R.jsxs)("div",{className:o.shortcutList,children:[n&&(0,R.jsxs)("button",{type:"button",className:o.shortcut,"data-testid":"shortcut-search",title:t("linkSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(io,{}),t("linkSearch")]}),s&&(0,R.jsxs)("button",{type:"button",className:o.shortcut,"data-testid":"shortcut-summary",title:t("linkSummary"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(Ru,{}),t("linkSummary")]}),r&&(0,R.jsxs)("button",{type:"button",className:o.shortcut,"data-testid":"shortcut-knowledge-assist",title:t("linkKnowledgeSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(ku,{}),t("linkKnowledgeSearch")]}),i&&(0,R.jsxs)("a",{className:o.shortcut,target:"_blank",href:i,"data-testid":"shortcut-studio-login",title:t("linkStudioLogin",{productName:c}),rel:"noreferrer",children:[(0,R.jsx)(Eu,{}),t("linkStudioLogin",{productName:c})]})]})}):null},Nh=()=>{let t=(0,B.useDispatch)(),e=b("showCustomMessages"),o=(0,B.useSelector)(jd),n=(0,B.useSelector)(eo);return or(()=>(t(an(n)),t(Jd(n)),()=>{t(Yd(n))}),[t,e,n]),!e||o.length===0?null:(0,R.jsx)(Ue,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(le,{withDivider:!0,children:o.map(s=>(0,R.jsx)(bu,{suggestion:s},s.text))})})},Oh=()=>{let t=k(pn),e=(0,B.useDispatch)(),o=b("showAutoflows"),n=(0,B.useSelector)(zd),s=(0,B.useSelector)(eo);return or(()=>(e(tt(s)),e(Vd(s)),()=>{e($d(s))}),[e,o,s]),!o||n.length===0?null:(0,R.jsx)(Ue,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(le,{withDivider:!0,children:(0,R.jsx)(Su,{})})})},_h=()=>{let t=(0,B.useDispatch)(),e=(0,B.useSelector)(Es),o=(0,B.useSelector)(ru),n=(0,B.useSelector)(ys),s=(0,B.useSelector)(ks),r=(0,B.useSelector)(Xe),i=(0,B.useSelector)(Mn);return or(()=>{e.forEach(({type:a})=>{a==="entities"?t(Re()):["cues"].includes(a)||t(Ie(a))})},[t,i,r]),(0,R.jsx)(tr.Fragment,{children:e.map(({type:a,title:c,amount:l,lines:d})=>{var u,p;switch(a){case"entities":return n&&n.length>0&&(0,R.jsx)(Ue,{type:a,title:c,"data-testid":`type-${a}`,children:(0,R.jsx)(Tu,{entities:n})},a);case"cues":return o&&o.length>0&&(0,R.jsx)(Ue,{type:a,title:c,"data-testid":`type-${a}`,children:(0,R.jsx)(le,{withDivider:!0,children:(0,R.jsx)(Du,{cues:o})})},a);default:return((p=(u=s[a])==null?void 0:u.suggestions)==null?void 0:p.length)>0&&(0,R.jsx)(Ue,{type:a,title:c,"data-testid":`type-${a}`,children:(0,R.jsx)(le,{withDivider:!0,children:(0,R.jsx)(Ku,{lines:d,contentType:a,suggestions:s[a].suggestions.slice(0,l)||[]})})},a)}})})},Dh=({onLogIn:t})=>{let e=k(pn),o=h("Widget",mn),n=(0,B.useSelector)(to),s=(0,B.useSelector)(ee),r=(0,B.useSelector)(eo),i=(0,B.useSelector)(Xe);return n===!1?(0,R.jsx)(Uu,{text:e("notSupported")}):s===!1?(0,R.jsx)(Ah,{onLogIn:t}):!i||!r||s===null?(0,R.jsx)(Uu,{text:e("waiting")}):(0,R.jsx)("div",{className:(0,zu.default)(o.root),"data-testid":"widget",children:(0,R.jsxs)(Pn,{className:o.sectionList,children:[(0,R.jsx)(Mh,{}),(0,R.jsx)(Nh,{}),(0,R.jsx)(Oh,{}),(0,R.jsx)(_h,{})]})})},Vu=Dh;function To(t){let e=new Range;return e.selectNodeContents(t),e}function $u(t,e,o){try{return bt(t,e,o),!0}catch{return!1}}function nr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function sr(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(c,l){let d=-1,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(c))return l;for(let p=0;p<=c.length;p++)if(u.test(c[p])||d++,d===l)return p;throw new Error("Offset out of range")}function a(c){switch(c.nodeType){case Node.TEXT_NODE:{let l=c.textContent,d=l.replace(gn,""),u=s+d.length,p=e>=s&&e<=u,m=o>=s&&o<=u;if(p){let g=i(l,e-s);g===0&&!m?n.setStartBefore(c):n.setStart(c,g)}m&&(n.setEnd(c,i(l,o-s)),r=!0),s=u;break}case Node.ELEMENT_NODE:{if(sr(c)&&(s===e&&n.setStartBefore(c),s++,s===o)){n.setEndAfter(c),r=!0;return}for(let d=0;d<c.childNodes.length&&(a(c.childNodes[d]),!r);d++);let l=c.lastChild;nr(c)&&l&&!nr(l)&&!sr(l)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}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,collapsed:i}=e,a,c,l=0;function d(u){let p=u===o,m=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let g=u.textContent;p&&(a=l+g.substring(0,n).replace(gn,"").length),m&&(c=l+g.substring(0,r).replace(gn,"").length),l+=g.replace(gn,"").length;break}case Node.ELEMENT_NODE:{let g=u.nextSibling===null;sr(u)&&!g&&l++;for(let f=0;f<u.childNodes.length;f++){let y=p&&f===n,P=m&&f===r;if(y&&(a=l),P&&(c=l),c!==void 0||((!y||!i)&&d(u.childNodes[f]),m&&f===r-1&&(c=l),c!==void 0))break}!m&&nr(u)&&!g&&l++,m&&(c=l);break}default:break}}if(d(t),c===void 0)throw new Error("Could not determine start and end");return{start:a??c,end:c}}function hn(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 c(l){let d=l===o,u=l===s;switch(d&&i++,l.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let p=d?n:0,m=u?r:void 0,g=l.textContent.replace(gn,"");p===0&&m===void 0?a+=g:a+=g.substring(p,m);break}case Node.ELEMENT_NODE:{let p=l.nextSibling===null;i===0&&sr(l)&&!p&&(a+=`
|
|
9
9
|
`);for(let m=d?n:0;m<(u?Math.min(r,l.childNodes.length):l.childNodes.length)&&(c(l.childNodes[m]),i!==1);m++);!u&&i===0&&nr(l)&&!p&&(a+=`
|
|
10
|
-
`);break}default:break}u&&i++}return c(t),a}var Wu=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Wu||{}),st=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();it(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(Wu).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(e={shouldObserve:!0}){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 o=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e!=null&&e.shouldObserve&&o.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{o.disconnect()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function Gu(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var jt=class extends st{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),hn(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!Gu(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Gu(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return fn(this.element,e);let o=this.lastKnownSelection;if(o&&$u(this.element,o.start,o.end))return o;let n=To(this.element);return n.collapse(!1),fn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return hn(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(e={shouldObserve:!0}){super.listen(e),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),e!=null&&e.shouldObserve&&this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let o=this.element.isContentEditable,n=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>n.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var qt=class extends st{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};function ju(t,e,o){let n=`deepdesk-iframe-${t}`,s=document.getElementById(n);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(o).forEach(([a,c])=>{i.searchParams.append(a,c)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=n,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}function Dh(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}var _i=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(JSON.stringify(e))}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Di=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=ju(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Hi=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),w.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Di(e,this.deepdeskUrl,{debug:!0}):new _i(e),n=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=Dh(s.data);typeof r!="object"||r.type!=="event"||r.channel!==e||(w.info("Received broadcast event",this.sessionId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return o.onMessage(n),o}send(e,o,n){var i,a;w.info("Broadcast event",{sessionId:this.sessionId,name:e,payload:o});let s={type:"event",name:e,payload:o};n!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,o));let r=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage({...s,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},qu=Hi;var Eo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Fi=t=>new Promise(e=>{setTimeout(e,t)});var ko=class extends Eo{name="ClientError"},Ki=class extends Eo{name="ServerError"},Bi=new Map;function Hh(t){return t.status===204||["0",null].includes(t.headers.get("content-length"))}var Ae=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,c=o.method===void 0||o.method.toLowerCase()==="get",{useCache:l=!1,abortLatest:d=!1,attempts:u=1,retryDelay:p=500,refreshTokenOn401:m=!0,retryOnError:g=E=>E instanceof TypeError,retryOnResponse:f=E=>E.status>=500,version:y="v1",...P}=o;if(l)if(c){if(Bi.has(i)){n(Bi.get(i));return}}else throw new Error(`Can't use 'useCache' for ${o.method}`);let v={credentials:"include",...P,headers:{"Content-Type":"application/json",...P.headers}};!c&&this.csrfToken&&(v.headers={...v.headers,"X-CSRFToken":this.csrfToken}),typeof y=="string"&&(v.headers={...v.headers,"X-Deepdesk-API-Version":y});let S=u,I=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&d&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let x=async()=>(S--,a(i,v).then(async E=>f(E)&&!r.isAborted&&S>0?(await Fi(p),x()):E.status===401&&m===!0&&I===!1?(I=!0,await this.refreshToken(),x()):E).catch(async E=>{if(g(E)&&!r.isAborted&&S>0)return await Fi(p),x();throw E}));x().then(async E=>{let O=await E.json().catch(j=>{if(Hh(E))return null;throw j});if(delete this.latestRequestByUrl[i],E.status>=500){s(new Ki("Server Error",O));return}else if(E.status===401){s(new ko("Unauthorized",O));return}else if(E.status===403){s(new ko("Forbidden",O));return}else if(E.status===404){s(new ko("Not Found",O));return}else if(E.status>=400){s(new ko("Bad Request",O));return}l&&Bi.set(i,O),n(O)}).catch(E=>{s(E)})})}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 Fh;(e=>{let t;(c=>(c.SEND_MESSAGE="Send Message",c.HANDLING_TIME="Handling Time",c.START_AUTOFLOW="Start Autoflow",c.ABORT_AUTOFLOW="Abort Autoflow",c.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",c.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(t=e.EventType||={})})(Fh||={});function rr(t){return{...A(t),tags:t.tags}}var rt=class t{constructor(e,o={}){this.options=o;this.client=new Ae(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),w.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...U(e),tags:e.tags},{version:"v2"});return rr(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null,useCache:!0});return A(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null,useCache:!0});return A(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null,useCache:!0});return A(e)}async getAccount(){let e=await this.client.get("/apis/admin/account/",{version:null,useCache:!0});return A(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null,useCache:!0});return A(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),w.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return w.info(`Successfully retrieved conversation ${r.id} for session ${e}`),rr(r)}async isConversationSupported(e,o={}){w.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=U(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return rr(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=>rr(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,c])=>({...i,[a]:c}),{});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={}){let n=await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source),agent_id:o.agentId,id:o.externalConversationId},prompt_instruction:o.promptInstruction,model:o.model});return A(n)}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw w.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.preflight(),await this.client.post("/apis/admin/session/api-key/",U(o),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,o={},n){return n==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${n}`,U(o),{abortLatest:!0})).map(r=>({...A(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(c=>c.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 A(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 A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,U(e),{version:"v2"});return A(o)}async knowledgeAssist(e,o,n,s={}){let r=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,U({question:e.question,doNotKnowAnswer:e.doNotKnowAnswer,customerInstruction:e.customerInstruction,chatHistory:o.map(i=>({question:i.question,answer:i.answer.answer})),agentId:s.agentId,conversationId:s.conversationId}),{version:"v2"});return A(r)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return A(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return A(e.token)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return A(o)}async evaluateRule(e,o,n,s={}){let r=new URLSearchParams;s.raiseForFailingConditions&&r.set("raise_for_failing_conditions","true");let i=await this.client.post(`/api/conversations/${o}/rules/${e}/evaluate?${r.toString()}`,n,{version:"v2"});return A(i.cues)}async getRules(){let e=new URLSearchParams,o=await this.client.get(`/apis/admin/rule-engine/rules/?${e.toString()}`,{version:null,useCache:!0});return A(o)}async translateMessages(e){let o=await this.client.post("/api/translate",U(e),{version:"v2"});return A(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&&w.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var yn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(wr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,A(s))}catch{w.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var Bh;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Bh||={});var vn=class{constructor(e,o={}){this.apiUrl=e;this.client=new Ae(e,o)}client;streams={};logger=w;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return A(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,U(o));return A(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 A(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",U(e));return A(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new yn(`${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 cr=require("@reduxjs/toolkit");var Zu=require("@reduxjs/toolkit");var Xu={startTime:null,stopTime:null},Qu=(0,Zu.createSlice)({name:"handlingTime",initialState:Xu,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(N,()=>Xu)}}),{handlingTimeStart:Ju,handlingTimeStop:ir,handlingTimeReset:Yu}=Qu.actions,ep=Qu.reducer;var tp=(t={})=>{let e={onAuthError:Yt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var lr=require("@reduxjs/toolkit");var ar={list:{keywordMatches:[]},fetchState:"idle"};var Xt=(0,lr.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 ar.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Kh=(0,lr.createSlice)({name:"styleSuggestions",initialState:ar,reducers:{},extraReducers:t=>{t.addCase(Xt.pending,e=>{e.fetchState="loading"}).addCase(Xt.rejected,e=>{e.fetchState="error"}).addCase(Xt.fulfilled,(e,o)=>{e.fetchState="done",it(e.list,o.payload)||(e.list=o.payload)}).addCase(Pt,e=>{e.list=ar.list}).addCase(N,()=>ar)}}),op=Kh.reducer;var np=(t={})=>{let e,o=!0,n={getStyleSuggestions:Xt,debounce:500,...t};return s=>r=>i=>{var m;let a=s.getState().input.text,c=r(i),l=s.getState();if(l.auth.isLoggedIn!==!0)return c;let{showStyleSuggestions:d}=l.settings;if(!((m=l.conversation.current)==null?void 0:m.id)||!d)return c;let{text:p}=l.input;return p===a&&!o||(clearTimeout(e),p==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:p}))},t.debounce)),c}};function Uh(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var sp=(t={})=>{let e={getTextSuggestions:Ie,getAutocompleteSuggestions:Yo,debounce:200,check:ho,...t},o;return n=>s=>r=>{var f;let{input:{userCommitted:i}}=n.getState(),a=s(r),c=n.getState();if(c.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:d}=c.settings,u=(f=c.conversation.current)==null?void 0:f.id,p=r.type===Rs.toString();if(!u||!l&&!d)return a;let{input:{userCommitted:m}}=c;return Uh(m,i)&&!p||(clearTimeout(o),!e.check(c))||(o=setTimeout(()=>{let y=oo(c);y===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(y))},p?0:e.debounce)),a}};var rp=Xt.fulfilled.toString();function zh(t,e){let o=new Set([...e.keywordMatches.map(s=>s.keyword)]),n=[];return o.forEach(s=>{let r=t.keywordMatches.filter(c=>c.keyword===s),i=e.keywordMatches.filter(c=>c.keyword===s),a=i.length-r.length;a<=0||n.push(...i.slice(0,a))}),n}var ip=t=>e=>o=>n=>{var l;if(n.type!==rp){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(l=r.conversation)==null?void 0:l.current;if(s===i)return;let c=zh(s,i);n.type===rp&&c.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:c}})};var Vh=(0,cr.combineReducers)({answer:hc,auth:Ra,autoflows:Wd,conversation:Aa,contentTypes:Rl,customMessages:eu,passwordlessToken:su,entities:Zl,knowledgeAssistant:mc,handlingTime:ep,info:Ja,input:qa,settings:xa,profile:Sc,search:rl,summary:nc,styleSuggestions:op,ui:qc,rules:lu,textSuggestions:Rc});function ap(t){return(0,cr.configureStore)({reducer:Vh,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),tp(),sp({debounce:200}),np({debounce:500}),ip(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var $h=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Wh=t=>e=>o=>n=>{var a;let s=e.getState(),r=vr("inlineSuggestions")(s);switch(n.type){case Yt.toString():{!n.payload&&t.emit("logout",void 0);break}case Re.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case Q.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case Bn.toString():t.handleKeyDown(n.payload);break;case Pt.toString():t.logSendMessage(n.payload);break;case Kn.toString():t.handleInputChanged(n.payload);break;case Wt.fulfilled.toString():n.isBroadcasted||t.broadcast(kr,n,!1),t.emit("cues",n.payload);break;default:break}let i=o(n);switch(n.type){case Pt.toString():t.handleAfterSendMessage(n.payload);break;case tn.toString():t.onUpdateShowTabHint(n.payload);break;case ir.toString():t.logHandlingTime();break;case"analytics/logEvent/fulfilled":{t.emit("event",n.meta.arg);break}case Ne.toString():{let{start:c,end:l}=s.input.selection;t.emit("select-suggestion",{type:$h(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:c,end:l}:{start:0,end:l}},{mayApplyChanges:!0}),r&&(e.dispatch(Me([])),e.dispatch(We()));break}case Fn.toString():{let{start:c,end:l}=s.input.selection;t.emit("replace",{...n.payload,replace:n.payload.replace==="selection"?{start:c,end:l}:{start:0,end:l}},{mayApplyChanges:!0});break}case Mo.toString():{let c=e.getState(),{text:l,selection:d}=c.input.userCommitted;t.emit("reset",{text:l,selectionAfter:d},{mayApplyChanges:!0});break}case Un.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 Me.toString():{r&&n.payload.length>0&&e.dispatch(lt(0));break}case je.fulfilled.toString():{t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary,model:e.getState().summary.model}});break}default:break}return i},lp=Wh;function Ui(t){return t.toISOString().replace("T"," ").replace("Z","")}function cp(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:Ui(o),timeStop:Ui(n)}}function dp(t,e,o){var O,j,V;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:c,agentStartedTypingTimestamp:l,externalTimeTotalSeconds:d,pastes:u,cuts:p,deletions:m,textSuggestions:g,offeredTextSuggestions:f}}=e[t],y=n.length,v=g.reduce((L,{text:_,searchTerm:q})=>L+_.length-(q?q.length:0),0),S=l??Date.now(),I=(Date.now()-S)/1e3+(d||0),x=s/I,E=g.reduce((L,{searchTerm:_})=>L+(_?_.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:u,cuts:p,deletions:m,lenTextTyped:s+E,lenTextTotal:y,lenTextAssisted:v,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:I,charsPerSecond:x,numPastes:c,textSuggestionsV2:g,suggestionsCounters:[{source:"gpt",countOffered:f.filter(L=>L.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(j=e.info.agentInfo)==null?void 0:j.agentName,agentEmail:(V=e.info.agentInfo)==null?void 0:V.agentEmail}}function zi(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return zi(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?zi(s,e):null}function up(t,e){return zi(t,e)}function pp(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Gh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function dr(t){return Gh(t)&&(ft(t)||Ds(t))}var mp,Be=new Map,jh=["bottom","height","left","right","top","width"],qh=(t={},e={})=>jh.some(o=>t[o]!==e[o]);function gp(t){var o,n;if(t.ownerDocument===document)return[];let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...gp(e)]:[]}function fp(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var ur=!1,hp=()=>{ur=!0;let t=[];if(Be.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Be.delete(o);return}let n=o.getBoundingClientRect();qh(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(fp,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),Be.size===0){ur=!1;return}mp=window.requestAnimationFrame(hp)};function Vi(t,e){let o=gp(t),n=[],s=o.map((r,i)=>Vi(r,a=>{n[i]=a;let c=Be.get(t);if(!c)return;let l=n.reduce(fp,c.rect);c.callbacks.forEach(d=>d(l))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Be.has(t)){let i=Be.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Be.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!ur&&hp()},unobserve(){s.forEach(i=>i.unobserve());let r=Be.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Be.delete(t),Be.size||(cancelAnimationFrame(mp),ur=!1)}}}}var yp,Ke=new Map,vp=()=>{Ke.forEach((t,e)=>{if(!e.isConnected){Ke.delete(e);return}let{clientHeight:o,scrollHeight:n}=e,s=n>o;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),Ke.size!==0&&(yp=window.requestAnimationFrame(vp))};function Sp(t,e){return{observe(){let o=Ke.size===0;Ke.has(t)?Ke.get(t).callbacks.push(e):Ke.set(t,{visible:void 0,callbacks:[e]}),o&&vp()},unobserve(){let o=Ke.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ke.delete(t),Ke.size||cancelAnimationFrame(yp)}}}}var $i=["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 Wi(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function Ro(t){return parseFloat(t)}function pr(t){return Math.round(t*1e6)}function xp(t){return t/1e6}function Gi(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),c=xp(pr(s)-pr(r)-pr(i)),l=xp(pr(n));if(c-l>2){let d=c-l;o.style.paddingRight=`${a+d}px`}}function Sn(t,e={}){var d;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",zt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Wi(n,o,$i),Gi(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=Sp(t,()=>{Wi(n,o,$i),Gi(n,t,o),r(),setTimeout(r,0)}),a,c=!0,l=Vi(t,u=>{if(u===null){e.onRemove&&e.onRemove(),o.remove();return}if(!c&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),c=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),c=!1},200),u.height===0&&u.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Wi(n,o,$i),Gi(n,t,o),r(),o.style.top=`${u.top}px`,o.style.left=`${u.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),m=window.getComputedStyle(e.closestScrollElement),g=Ro(m.borderTopWidth),f=Ro(m.borderBottomWidth),y=p.top+g-u.top,P=u.top+u.height+-(p.top+p.height-f);o.style.clipPath=`inset(${y}px 0px ${P}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(d=t.parentElement)==null||d.appendChild(o),l.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),l.unobserve(),i.unobserve()}]}var bp=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{w.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Xh(t){return t.offsetParent!==null}function Cp(t){if(!Xh(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 mr(t,e,o=100){let n=Cp(t);e({isVisible:n});let s=setInterval(()=>{let r=Cp(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var z=require("react/jsx-runtime");var wp=bp("showTabHint",!0),xn=class t{static version="11.3.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:c}){let l=e.replace(/\/api$/,"");this.deepdeskApi=new rt(l,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let d={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[lp({broadcast:(u,p,m)=>{this.broadcastEvents.send(u,p,m)},emit:(u,p,m)=>this.emit(u,p,m),handleAfterSendMessage:u=>this.handleAfterSendMessage(u),handleInputChanged:u=>this.handleInputChanged(u),handleKeyDown:u=>this.handleKeyDown(u),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:u=>this.logSendMessage(u),onUpdateShowTabHint:u=>wp.update(u),sendEvent:(u,p)=>this.deepdeskApi.sendEvent(u,p)})]};o&&Object.assign(d,{deepdeskBrokerAPI:new vn(o)}),this.store=ap(d),this.broadcastEvents=new qu({debug:!0,deepdeskUrl:l,eventMap:il(this.store),createCustomChannel:c}),this.store.dispatch(tn(wp.value())),this.store.dispatch(An({locale:s,adminUrl:l,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(w.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(w.warn("Profile has not been loaded (yet)"),!0):(w.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Yt(null)),this.store.dispatch(Ve()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ee(n)&&ba(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(Ve())).payload}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){w.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(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(On({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(Dn(e))).payload}async updateConversation(e){return(await this.store.dispatch(_n(e))).payload}resetConversation(){this.store.dispatch(N()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(je());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(An(e))}setVisitorInfo(e){this.store.dispatch(Qa(e))}async setAgentInfo(e){await this.store.dispatch(No(e))}async setAgentSettings(e){await this.store.dispatch(Tr(e))}async getAgentSettings(){return(await this.store.dispatch(Er())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(Rs()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Kn(e))}notifyKeyDown(e){this.store.dispatch(Bn(e))}notifyPaste(e,o){this.store.dispatch($a({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(za(e))}notifyExternalSuggestion(e){this.store.dispatch(Ne(e)),this.store.dispatch(We())}async evaluateRule(e,o={}){let{payload:n,error:s}=await this.store.dispatch(Wt({label:e,params:o}));if(s)throw new Error(s.message);return n}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(mt({collapse:!1})),this.inputMediator&&this.store.dispatch(Ha({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Me([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,c=s!==-1;if(this.store.dispatch(Va(Oa(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let l=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Ba()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},d=()=>{o||!a||i&&s<=0||r&&(e.shiftKey||(this.store.dispatch(Ua()),e.preventDefault(),!i&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(Mo()):this.stageSelectedSuggestion({inputType:"arrow"}))))};switch(e.key){case"Up":case"ArrowUp":i?d():l();return;case"Down":case"ArrowDown":{i?l():d();return}case"Esc":case"Escape":{i&&c&&this.store.dispatch(lt(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(lt(-1)),this.store.dispatch(Mo()),e.preventDefault()):o||(this.store.dispatch(mt({collapse:!0})),this.store.dispatch(Gc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:u}=this.state.input,p=u.text.substring(0,u.selection.end),{tabCompletionSuggestion:m}=this.state.input;this.store.dispatch(tn(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&m&&m.text.startsWith(p)&&(this.store.dispatch(Ne({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(We())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Wa()),this.store.dispatch(Me([]))}handlingTimeStart(){this.state.handlingTime.startTime||(w.info("Start handling time"),this.store.dispatch(Ju()))}handlingTimeStop(){this.state.handlingTime.startTime&&(w.info("Stop handling time"),this.store.dispatch(ir()))}logSendMessage(e){let o=dp("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logHandlingTime(){let e=cp(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Yu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(We()),this.store.dispatch(Pt(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(Ne({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){w.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),w.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=Sn(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,be.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,c]=Sn(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,be.unmountComponentAtNode)(s),c()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return zt(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,be.unmountComponentAtNode)(s),s.remove()}),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,o),w.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=window.sessionStorage.getItem(e);if(!o)return;let n=JSON.parse(o);n.text.trim()===this.state.input.text.trim()?(w.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(ja(n.metrics))):w.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch{}}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!dr(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:c,showSuggestionsBeforePattern:l,showSuggestionsAfterPattern:d,isEmbedded:u,detectSubmit:p,insertLink:m,inputMediator:g,closestScrollSelector:f,appendOverlayTo:y,inlineSuggestions:P,floatingMenu:v}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:c,showSuggestionsBeforePattern:l,showSuggestionsAfterPattern:d,showTextSuggestions:i,insertLink:m,isEmbedded:u,inlineSuggestions:P,floatingMenu:!!v}),o.automaticHandlingTime&&this.setupHandlingTime(e),zt(e),this.inputMediator=g||(ft(e)?new qt(e):new jt(e)),this.inputMediator.on("change",({plainText:x})=>{this.notifyInputChanged(x)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Ga({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",x=>{this.notifyKeyDown(x)}),this.inputMediator.on("paste",({pastedText:x,selectionText:E})=>{this.notifyPaste(x,E)}),this.inputMediator.on("cut",({selectionText:x})=>{this.notifyCut(x)});let S=f&&up(e,f)||void 0;if(P){let{customStyles:x,appendOverlayTo:E}=o;if(ft(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let O=this.createInlineContainer(e,"deepdesk-caret");(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:x,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(td,{})})}),O),this.inputMediator.on("caret",V=>{this.store.dispatch(Me([])),V?(O.style.display="block",O.style.top=`${V.top}px`,O.style.left=`${V.left}px`):O.style.display="none"});let j=this.overlayContainerFactory("floating-menu",S||e,{appendTo:typeof v=="object"&&"appendOverlayTo"in v?v.appendOverlayTo:E},x==null?void 0:x.floatingMenuRootNode);(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:x,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(zc,{onLogIn:()=>this.loginViaPopup().catch(V=>w.warn(V.message))})})}),j)}else{let x=this.overlayContainerFactory("deepdesk-tab-completion",S||e,{appendTo:y,closestScrollElement:S,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),E=this.overlayContainerFactory("deepdesk-suggestions-overlay",S||e,{appendTo:y},n==null?void 0:n.suggestionsRootNode);(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:n,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(Bd,{inputElement:e})})}),x),(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:n,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(pd,{onLogIn:()=>this.loginViaPopup().catch(O=>w.warn(O.message))})})}),E)}(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:n,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(_c,{})})}),this.createContainer("deepdesk-overlays"));let I;this.inputMediator.on("selection",x=>{clearTimeout(I),x===null?I=setTimeout(()=>{x!==null&&this.store.dispatch(Cr(x))},500):this.store.dispatch(Cr(x))}),this.inputMediator.on("disabled",()=>{var x;(x=this.inputMediator)==null||x.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{p&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(si(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(si(!0))),this.store.dispatch(Fa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(We()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var x;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((x=this.state.conversation.current)==null?void 0:x.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&w.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,isEmbedded:r}=o;this.widgetRoot=e,this.configure({showImages:s,isEmbedded:r}),(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:n,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(Vu,{onLogIn:()=>this.loginViaPopup().catch(i=>w.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&(0,be.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=mr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){pp(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(Jo());let e=Xe(this.state);e&&(await this.store.dispatch(Xo()),this.store.dispatch(An({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(e){return new Promise((o,n)=>{let s=new MessageChannel,r=s.port1,i=this.state.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let c=!1,l=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",u),clearInterval(p)};r.onmessage=async m=>{var g,f;if((g=m.data)!=null&&g.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((f=m.data)==null?void 0:f.jwt),await this.isLoggedIn(),this.broadcastEvents.send(_o),c=!0,s.port1.close(),o()}catch(y){console.error(y),n(y)}finally{c=!0,l()}};let d=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&n(new Error("Popup blocked by browser"));let u=async m=>{var g;if(m.origin===a.origin)switch((g=m.data)==null?void 0:g.type){case"deepdesk-popup-loaded":{try{let f=JSON.stringify({type:"deepdesk-popup-create-channel"});d==null||d.postMessage(f,a.origin,[s.port2])}catch(f){w.error("Error posting message to popup",f),n(f)}break}case"deepdesk-popup-error":{l(),m.data.message==="Timeout"&&w.warn("Popup timed out. Check if the account's platform url is configured correctly."),n(new Error(m.data.message));break}}};window.addEventListener("message",u);let p=setInterval(()=>{d&&!d.closed||(l(),c||n(new Error("Popup closed by user")))},200);this.unmountHandlers.push(l)})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(w.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;w.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=Es(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Re()):["cues"].includes(n)||this.store.dispatch(Ie(n))})}catch(n){this.handleError(n)}}};async function Tp(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},c=()=>{if(o.setValue)return o.setValue(i);t.value=i};return Promise.resolve(c()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function Ep(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(`
|
|
10
|
+
`);break}default:break}u&&i++}return c(t),a}var Wu=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Wu||{}),st=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();it(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(Wu).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(e={shouldObserve:!0}){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 o=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e!=null&&e.shouldObserve&&o.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{o.disconnect()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function Gu(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var jt=class extends st{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),hn(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!Gu(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Gu(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return fn(this.element,e);let o=this.lastKnownSelection;if(o&&$u(this.element,o.start,o.end))return o;let n=To(this.element);return n.collapse(!1),fn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return hn(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(e={shouldObserve:!0}){super.listen(e),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),e!=null&&e.shouldObserve&&this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let o=this.element.isContentEditable,n=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>n.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var qt=class extends st{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};function ju(t,e,o){let n=`deepdesk-iframe-${t}`,s=document.getElementById(n);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(o).forEach(([a,c])=>{i.searchParams.append(a,c)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=n,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}function Hh(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}var _i=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(JSON.stringify(e))}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Di=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=ju(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Hi=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),w.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Di(e,this.deepdeskUrl,{debug:!0}):new _i(e),n=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=Hh(s.data);typeof r!="object"||r.type!=="event"||r.channel!==e||(w.info("Received broadcast event",this.sessionId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return o.onMessage(n),o}send(e,o,n){var i,a;w.info("Broadcast event",{sessionId:this.sessionId,name:e,payload:o});let s={type:"event",name:e,payload:o};n!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,o));let r=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage({...s,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},qu=Hi;var Eo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Fi=t=>new Promise(e=>{setTimeout(e,t)});var ko=class extends Eo{name="ClientError"},Ki=class extends Eo{name="ServerError"},Bi=new Map;function Fh(t){return t.status===204||["0",null].includes(t.headers.get("content-length"))}var Ae=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,c=o.method===void 0||o.method.toLowerCase()==="get",{useCache:l=!1,abortLatest:d=!1,attempts:u=1,retryDelay:p=500,refreshTokenOn401:m=!0,retryOnError:g=E=>E instanceof TypeError,retryOnResponse:f=E=>E.status>=500,version:y="v1",...P}=o;if(l)if(c){if(Bi.has(i)){n(Bi.get(i));return}}else throw new Error(`Can't use 'useCache' for ${o.method}`);let v={credentials:"include",...P,headers:{"Content-Type":"application/json",...P.headers}};!c&&this.csrfToken&&(v.headers={...v.headers,"X-CSRFToken":this.csrfToken}),typeof y=="string"&&(v.headers={...v.headers,"X-Deepdesk-API-Version":y});let S=u,I=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&d&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let x=async()=>(S--,a(i,v).then(async E=>f(E)&&!r.isAborted&&S>0?(await Fi(p),x()):E.status===401&&m===!0&&I===!1?(I=!0,await this.refreshToken(),x()):E).catch(async E=>{if(g(E)&&!r.isAborted&&S>0)return await Fi(p),x();throw E}));x().then(async E=>{let O=await E.json().catch(j=>{if(Fh(E))return null;throw j});if(delete this.latestRequestByUrl[i],E.status>=500){s(new Ki("Server Error",O));return}else if(E.status===401){s(new ko("Unauthorized",O));return}else if(E.status===403){s(new ko("Forbidden",O));return}else if(E.status===404){s(new ko("Not Found",O));return}else if(E.status>=400){s(new ko("Bad Request",O));return}l&&Bi.set(i,O),n(O)}).catch(E=>{s(E)})})}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 Bh;(e=>{let t;(c=>(c.SEND_MESSAGE="Send Message",c.HANDLING_TIME="Handling Time",c.START_AUTOFLOW="Start Autoflow",c.ABORT_AUTOFLOW="Abort Autoflow",c.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",c.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(t=e.EventType||={})})(Bh||={});function rr(t){return{...A(t),tags:t.tags}}var rt=class t{constructor(e,o={}){this.options=o;this.client=new Ae(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),w.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...U(e),tags:e.tags},{version:"v2"});return rr(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null,useCache:!0});return A(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null,useCache:!0});return A(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null,useCache:!0});return A(e)}async getAccount(){let e=await this.client.get("/apis/admin/account/",{version:null,useCache:!0});return A(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null,useCache:!0});return A(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),w.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return w.info(`Successfully retrieved conversation ${r.id} for session ${e}`),rr(r)}async isConversationSupported(e,o={}){w.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=U(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return rr(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=>rr(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,c])=>({...i,[a]:c}),{});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={}){let n=await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source),agent_id:o.agentId,id:o.externalConversationId},prompt_instruction:o.promptInstruction,model:o.model});return A(n)}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw w.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.preflight(),await this.client.post("/apis/admin/session/api-key/",U(o),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,o={},n){return n==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${n}`,U(o),{abortLatest:!0})).map(r=>({...A(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(c=>c.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 A(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 A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,U(e),{version:"v2"});return A(o)}async knowledgeAssist(e,o,n,s={}){let r=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,U({question:e.question,doNotKnowAnswer:e.doNotKnowAnswer,customerInstruction:e.customerInstruction,chatHistory:o.map(i=>({question:i.question,answer:i.answer.answer})),agentId:s.agentId,conversationId:s.conversationId}),{version:"v2"});return A(r)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return A(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return A(e.token)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return A(o)}async evaluateRule(e,o,n,s={}){let r=new URLSearchParams;s.raiseForFailingConditions&&r.set("raise_for_failing_conditions","true");let i=await this.client.post(`/api/conversations/${o}/rules/${e}/evaluate?${r.toString()}`,n,{version:"v2"});return A(i.cues)}async getRules(){let e=new URLSearchParams,o=await this.client.get(`/apis/admin/rule-engine/rules/?${e.toString()}`,{version:null,useCache:!0});return A(o)}async translateMessages(e){let o=await this.client.post("/api/translate",U(e),{version:"v2"});return A(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&&w.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var yn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(wr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,A(s))}catch{w.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var Kh;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Kh||={});var vn=class{constructor(e,o={}){this.apiUrl=e;this.client=new Ae(e,o)}client;streams={};logger=w;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return A(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,U(o));return A(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 A(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",U(e));return A(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new yn(`${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 cr=require("@reduxjs/toolkit");var Zu=require("@reduxjs/toolkit");var Xu={startTime:null,stopTime:null},Qu=(0,Zu.createSlice)({name:"handlingTime",initialState:Xu,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(N,()=>Xu)}}),{handlingTimeStart:Ju,handlingTimeStop:ir,handlingTimeReset:Yu}=Qu.actions,ep=Qu.reducer;var tp=(t={})=>{let e={onAuthError:Yt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var lr=require("@reduxjs/toolkit");var ar={list:{keywordMatches:[]},fetchState:"idle"};var Xt=(0,lr.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 ar.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Uh=(0,lr.createSlice)({name:"styleSuggestions",initialState:ar,reducers:{},extraReducers:t=>{t.addCase(Xt.pending,e=>{e.fetchState="loading"}).addCase(Xt.rejected,e=>{e.fetchState="error"}).addCase(Xt.fulfilled,(e,o)=>{e.fetchState="done",it(e.list,o.payload)||(e.list=o.payload)}).addCase(Pt,e=>{e.list=ar.list}).addCase(N,()=>ar)}}),op=Uh.reducer;var np=(t={})=>{let e,o=!0,n={getStyleSuggestions:Xt,debounce:500,...t};return s=>r=>i=>{var m;let a=s.getState().input.text,c=r(i),l=s.getState();if(l.auth.isLoggedIn!==!0)return c;let{showStyleSuggestions:d}=l.settings;if(!((m=l.conversation.current)==null?void 0:m.id)||!d)return c;let{text:p}=l.input;return p===a&&!o||(clearTimeout(e),p==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:p}))},t.debounce)),c}};function zh(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var sp=(t={})=>{let e={getTextSuggestions:Ie,getAutocompleteSuggestions:Yo,debounce:200,check:ho,...t},o;return n=>s=>r=>{var f;let{input:{userCommitted:i}}=n.getState(),a=s(r),c=n.getState();if(c.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:d}=c.settings,u=(f=c.conversation.current)==null?void 0:f.id,p=r.type===Rs.toString();if(!u||!l&&!d)return a;let{input:{userCommitted:m}}=c;return zh(m,i)&&!p||(clearTimeout(o),!e.check(c))||(o=setTimeout(()=>{let y=oo(c);y===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(y))},p?0:e.debounce)),a}};var rp=Xt.fulfilled.toString();function Vh(t,e){let o=new Set([...e.keywordMatches.map(s=>s.keyword)]),n=[];return o.forEach(s=>{let r=t.keywordMatches.filter(c=>c.keyword===s),i=e.keywordMatches.filter(c=>c.keyword===s),a=i.length-r.length;a<=0||n.push(...i.slice(0,a))}),n}var ip=t=>e=>o=>n=>{var l;if(n.type!==rp){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(l=r.conversation)==null?void 0:l.current;if(s===i)return;let c=Vh(s,i);n.type===rp&&c.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:c}})};var $h=(0,cr.combineReducers)({answer:hc,auth:Ra,autoflows:Wd,conversation:Aa,contentTypes:Rl,customMessages:eu,passwordlessToken:su,entities:Zl,knowledgeAssistant:mc,handlingTime:ep,info:Ja,input:qa,settings:xa,profile:Sc,search:rl,summary:nc,styleSuggestions:op,ui:qc,rules:lu,textSuggestions:Rc});function ap(t){return(0,cr.configureStore)({reducer:$h,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),tp(),sp({debounce:200}),np({debounce:500}),ip(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Wh=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Gh=t=>e=>o=>n=>{var a;let s=e.getState(),r=vr("inlineSuggestions")(s);switch(n.type){case Yt.toString():{!n.payload&&t.emit("logout",void 0);break}case Re.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case Q.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case Bn.toString():t.handleKeyDown(n.payload);break;case Pt.toString():t.logSendMessage(n.payload);break;case Kn.toString():t.handleInputChanged(n.payload);break;case Wt.fulfilled.toString():n.isBroadcasted||t.broadcast(kr,n,!1),t.emit("cues",n.payload);break;default:break}let i=o(n);switch(n.type){case Pt.toString():t.handleAfterSendMessage(n.payload);break;case tn.toString():t.onUpdateShowTabHint(n.payload);break;case ir.toString():t.logHandlingTime();break;case"analytics/logEvent/fulfilled":{t.emit("event",n.meta.arg);break}case Ne.toString():{let{start:c,end:l}=s.input.selection;t.emit("select-suggestion",{type:Wh(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:c,end:l}:{start:0,end:l}},{mayApplyChanges:!0}),r&&(e.dispatch(Me([])),e.dispatch(We()));break}case Fn.toString():{let{start:c,end:l}=s.input.selection;t.emit("replace",{...n.payload,replace:n.payload.replace==="selection"?{start:c,end:l}:{start:0,end:l}},{mayApplyChanges:!0});break}case Mo.toString():{let c=e.getState(),{text:l,selection:d}=c.input.userCommitted;t.emit("reset",{text:l,selectionAfter:d},{mayApplyChanges:!0});break}case Un.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 Me.toString():{r&&n.payload.length>0&&e.dispatch(lt(0));break}case je.fulfilled.toString():{t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary,model:e.getState().summary.model}});break}default:break}return i},lp=Gh;function Ui(t){return t.toISOString().replace("T"," ").replace("Z","")}function cp(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:Ui(o),timeStop:Ui(n)}}function dp(t,e,o){var O,j,V;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:c,agentStartedTypingTimestamp:l,externalTimeTotalSeconds:d,pastes:u,cuts:p,deletions:m,textSuggestions:g,offeredTextSuggestions:f}}=e[t],y=n.length,v=g.reduce((L,{text:_,searchTerm:q})=>L+_.length-(q?q.length:0),0),S=l??Date.now(),I=(Date.now()-S)/1e3+(d||0),x=s/I,E=g.reduce((L,{searchTerm:_})=>L+(_?_.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:u,cuts:p,deletions:m,lenTextTyped:s+E,lenTextTotal:y,lenTextAssisted:v,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:I,charsPerSecond:x,numPastes:c,textSuggestionsV2:g,suggestionsCounters:[{source:"gpt",countOffered:f.filter(L=>L.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(j=e.info.agentInfo)==null?void 0:j.agentName,agentEmail:(V=e.info.agentInfo)==null?void 0:V.agentEmail}}function zi(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return zi(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?zi(s,e):null}function up(t,e){return zi(t,e)}function pp(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function jh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function dr(t){return jh(t)&&(ft(t)||Ds(t))}var gp,Be=new Map,qh=["bottom","height","left","right","top","width"],mp=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:qh.some(o=>t[o]!==e[o]);function fp(t){var o,n;if(t.ownerDocument===document)return[];let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...fp(e)]:[]}function hp(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var ur=!1,yp=()=>{ur=!0;let t=[];if(Be.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Be.delete(o);return}let n=o.getBoundingClientRect();mp(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(hp,e.rect):e.rect;mp(o,e.totalRect)&&e.callbacks.forEach(n=>n(o)),e.totalRect=o}),Be.size===0){ur=!1;return}gp=window.requestAnimationFrame(yp)};function Vi(t,e){let o=fp(t),n=[],s=o.map((r,i)=>Vi(r,a=>{n[i]=a;let c=Be.get(t);if(!c)return;let l=n.reduce(hp,c.rect);c.callbacks.forEach(d=>d(l))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Be.has(t)){let i=Be.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Be.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!ur&&yp()},unobserve(){s.forEach(i=>i.unobserve());let r=Be.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Be.delete(t),Be.size||(cancelAnimationFrame(gp),ur=!1)}}}}var vp,Ke=new Map,Sp=()=>{Ke.forEach((t,e)=>{if(!e.isConnected){Ke.delete(e);return}let{clientHeight:o,scrollHeight:n}=e,s=n>o;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),Ke.size!==0&&(vp=window.requestAnimationFrame(Sp))};function xp(t,e){return{observe(){let o=Ke.size===0;Ke.has(t)?Ke.get(t).callbacks.push(e):Ke.set(t,{visible:void 0,callbacks:[e]}),o&&Sp()},unobserve(){let o=Ke.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ke.delete(t),Ke.size||cancelAnimationFrame(vp)}}}}var $i=["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 Wi(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function Ro(t){return parseFloat(t)}function pr(t){return Math.round(t*1e6)}function bp(t){return t/1e6}function Gi(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),c=bp(pr(s)-pr(r)-pr(i)),l=bp(pr(n));if(c-l>2){let d=c-l;o.style.paddingRight=`${a+d}px`}}function Sn(t,e={}){var d;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",zt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Wi(n,o,$i),Gi(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=xp(t,()=>{Wi(n,o,$i),Gi(n,t,o),r(),setTimeout(r,0)}),a,c=!0,l=Vi(t,u=>{if(u===null){e.onRemove&&e.onRemove(),o.remove();return}if(!c&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),c=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),c=!1},200),u.height===0&&u.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Wi(n,o,$i),Gi(n,t,o),r(),o.style.top=`${u.top}px`,o.style.left=`${u.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),m=window.getComputedStyle(e.closestScrollElement),g=Ro(m.borderTopWidth),f=Ro(m.borderBottomWidth),y=p.top+g-u.top,P=u.top+u.height+-(p.top+p.height-f);o.style.clipPath=`inset(${y}px 0px ${P}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(d=t.parentElement)==null||d.appendChild(o),l.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),l.unobserve(),i.unobserve()}]}var Cp=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{w.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Xh(t){return t.offsetParent!==null}function wp(t){if(!Xh(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 mr(t,e,o=100){let n=wp(t);e({isVisible:n});let s=setInterval(()=>{let r=wp(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var z=require("react/jsx-runtime");var Tp=Cp("showTabHint",!0),xn=class t{static version="11.3.1-beta.0";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:c}){let l=e.replace(/\/api$/,"");this.deepdeskApi=new rt(l,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let d={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[lp({broadcast:(u,p,m)=>{this.broadcastEvents.send(u,p,m)},emit:(u,p,m)=>this.emit(u,p,m),handleAfterSendMessage:u=>this.handleAfterSendMessage(u),handleInputChanged:u=>this.handleInputChanged(u),handleKeyDown:u=>this.handleKeyDown(u),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:u=>this.logSendMessage(u),onUpdateShowTabHint:u=>Tp.update(u),sendEvent:(u,p)=>this.deepdeskApi.sendEvent(u,p)})]};o&&Object.assign(d,{deepdeskBrokerAPI:new vn(o)}),this.store=ap(d),this.broadcastEvents=new qu({debug:!0,deepdeskUrl:l,eventMap:il(this.store),createCustomChannel:c}),this.store.dispatch(tn(Tp.value())),this.store.dispatch(An({locale:s,adminUrl:l,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(w.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(w.warn("Profile has not been loaded (yet)"),!0):(w.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Yt(null)),this.store.dispatch(Ve()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ee(n)&&ba(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(Ve())).payload}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){w.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(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(On({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(Dn(e))).payload}async updateConversation(e){return(await this.store.dispatch(_n(e))).payload}resetConversation(){this.store.dispatch(N()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(je());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(An(e))}setVisitorInfo(e){this.store.dispatch(Qa(e))}async setAgentInfo(e){await this.store.dispatch(No(e))}async setAgentSettings(e){await this.store.dispatch(Tr(e))}async getAgentSettings(){return(await this.store.dispatch(Er())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(Rs()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Kn(e))}notifyKeyDown(e){this.store.dispatch(Bn(e))}notifyPaste(e,o){this.store.dispatch($a({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(za(e))}notifyExternalSuggestion(e){this.store.dispatch(Ne(e)),this.store.dispatch(We())}async evaluateRule(e,o={}){let{payload:n,error:s}=await this.store.dispatch(Wt({label:e,params:o}));if(s)throw new Error(s.message);return n}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(mt({collapse:!1})),this.inputMediator&&this.store.dispatch(Ha({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Me([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,c=s!==-1;if(this.store.dispatch(Va(Oa(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let l=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Ba()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},d=()=>{o||!a||i&&s<=0||r&&(e.shiftKey||(this.store.dispatch(Ua()),e.preventDefault(),!i&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(Mo()):this.stageSelectedSuggestion({inputType:"arrow"}))))};switch(e.key){case"Up":case"ArrowUp":i?d():l();return;case"Down":case"ArrowDown":{i?l():d();return}case"Esc":case"Escape":{i&&c&&this.store.dispatch(lt(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(lt(-1)),this.store.dispatch(Mo()),e.preventDefault()):o||(this.store.dispatch(mt({collapse:!0})),this.store.dispatch(Gc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:u}=this.state.input,p=u.text.substring(0,u.selection.end),{tabCompletionSuggestion:m}=this.state.input;this.store.dispatch(tn(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&m&&m.text.startsWith(p)&&(this.store.dispatch(Ne({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(We())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Wa()),this.store.dispatch(Me([]))}handlingTimeStart(){this.state.handlingTime.startTime||(w.info("Start handling time"),this.store.dispatch(Ju()))}handlingTimeStop(){this.state.handlingTime.startTime&&(w.info("Stop handling time"),this.store.dispatch(ir()))}logSendMessage(e){let o=dp("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logHandlingTime(){let e=cp(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Yu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(We()),this.store.dispatch(Pt(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(Ne({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){w.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),w.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=Sn(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,be.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,c]=Sn(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,be.unmountComponentAtNode)(s),c()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return zt(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,be.unmountComponentAtNode)(s),s.remove()}),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,o),w.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=window.sessionStorage.getItem(e);if(!o)return;let n=JSON.parse(o);n.text.trim()===this.state.input.text.trim()?(w.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(ja(n.metrics))):w.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch{}}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!dr(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:c,showSuggestionsBeforePattern:l,showSuggestionsAfterPattern:d,isEmbedded:u,detectSubmit:p,insertLink:m,inputMediator:g,closestScrollSelector:f,appendOverlayTo:y,inlineSuggestions:P,floatingMenu:v}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:c,showSuggestionsBeforePattern:l,showSuggestionsAfterPattern:d,showTextSuggestions:i,insertLink:m,isEmbedded:u,inlineSuggestions:P,floatingMenu:!!v}),o.automaticHandlingTime&&this.setupHandlingTime(e),zt(e),this.inputMediator=g||(ft(e)?new qt(e):new jt(e)),this.inputMediator.on("change",({plainText:x})=>{this.notifyInputChanged(x)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Ga({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",x=>{this.notifyKeyDown(x)}),this.inputMediator.on("paste",({pastedText:x,selectionText:E})=>{this.notifyPaste(x,E)}),this.inputMediator.on("cut",({selectionText:x})=>{this.notifyCut(x)});let S=f&&up(e,f)||void 0;if(P){let{customStyles:x,appendOverlayTo:E}=o;if(ft(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let O=this.createInlineContainer(e,"deepdesk-caret");(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:x,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(td,{})})}),O),this.inputMediator.on("caret",V=>{this.store.dispatch(Me([])),V?(O.style.display="block",O.style.top=`${V.top}px`,O.style.left=`${V.left}px`):O.style.display="none"});let j=this.overlayContainerFactory("floating-menu",S||e,{appendTo:typeof v=="object"&&"appendOverlayTo"in v?v.appendOverlayTo:E},x==null?void 0:x.floatingMenuRootNode);(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:x,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(zc,{onLogIn:()=>this.loginViaPopup().catch(V=>w.warn(V.message))})})}),j)}else{let x=this.overlayContainerFactory("deepdesk-tab-completion",S||e,{appendTo:y,closestScrollElement:S,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),E=this.overlayContainerFactory("deepdesk-suggestions-overlay",S||e,{appendTo:y},n==null?void 0:n.suggestionsRootNode);(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:n,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(Bd,{inputElement:e})})}),x),(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:n,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(pd,{onLogIn:()=>this.loginViaPopup().catch(O=>w.warn(O.message))})})}),E)}(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:n,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(_c,{})})}),this.createContainer("deepdesk-overlays"));let I;this.inputMediator.on("selection",x=>{clearTimeout(I),x===null?I=setTimeout(()=>{x!==null&&this.store.dispatch(Cr(x))},500):this.store.dispatch(Cr(x))}),this.inputMediator.on("disabled",()=>{var x;(x=this.inputMediator)==null||x.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{p&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(si(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(si(!0))),this.store.dispatch(Fa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(We()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var x;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((x=this.state.conversation.current)==null?void 0:x.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&w.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,isEmbedded:r}=o;this.widgetRoot=e,this.configure({showImages:s,isEmbedded:r}),(0,be.render)((0,z.jsx)($t,{store:this.store,customStyles:n,children:(0,z.jsx)(Lt,{broadcastEvents:this.broadcastEvents,children:(0,z.jsx)(Vu,{onLogIn:()=>this.loginViaPopup().catch(i=>w.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&(0,be.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=mr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){pp(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(Jo());let e=Xe(this.state);e&&(await this.store.dispatch(Xo()),this.store.dispatch(An({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(e){return new Promise((o,n)=>{let s=new MessageChannel,r=s.port1,i=this.state.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let c=!1,l=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",u),clearInterval(p)};r.onmessage=async m=>{var g,f;if((g=m.data)!=null&&g.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((f=m.data)==null?void 0:f.jwt),await this.isLoggedIn(),this.broadcastEvents.send(_o),c=!0,s.port1.close(),o()}catch(y){console.error(y),n(y)}finally{c=!0,l()}};let d=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&n(new Error("Popup blocked by browser"));let u=async m=>{var g;if(m.origin===a.origin)switch((g=m.data)==null?void 0:g.type){case"deepdesk-popup-loaded":{try{let f=JSON.stringify({type:"deepdesk-popup-create-channel"});d==null||d.postMessage(f,a.origin,[s.port2])}catch(f){w.error("Error posting message to popup",f),n(f)}break}case"deepdesk-popup-error":{l(),m.data.message==="Timeout"&&w.warn("Popup timed out. Check if the account's platform url is configured correctly."),n(new Error(m.data.message));break}}};window.addEventListener("message",u);let p=setInterval(()=>{d&&!d.closed||(l(),c||n(new Error("Popup closed by user")))},200);this.unmountHandlers.push(l)})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(w.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;w.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=Es(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Re()):["cues"].includes(n)||this.store.dispatch(Ie(n))})}catch(n){this.handleError(n)}}};async function Ep(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},c=()=>{if(o.setValue)return o.setValue(i);t.value=i};return Promise.resolve(c()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function kp(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(`
|
|
11
11
|
`).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?bt(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Zh(t){let e=document.createElement("template");return e.innerHTML=t.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),e.content}function Qh(t){let e=document.createDocumentFragment();return t.split(`
|
|
12
|
-
`).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=o.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(o.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(o.slice(r)))}),e}function
|
|
12
|
+
`).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=o.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(o.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(o.slice(r)))}),e}function Rp(t,e){let o=t.parentElement;if(!o){console.warn("No insert point found");return}let{display:n}=window.getComputedStyle(o);n.includes("block")||n==="table-cell"?o==null||o.insertBefore(e,t.nextSibling):Rp(o,e)}async function Pp(t,e,{isBlock:o,isHTML:n}={}){let s;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let r=()=>{let i=t.ownerDocument.defaultView??window,a=i.getSelection();if((!a||a.rangeCount===0)&&(t.focus(),a=i.getSelection()),!a||a.rangeCount===0)return;let c=a.getRangeAt(0);if(!c)return;s=document.createElement("span"),c.insertNode(s);let l=n?Zh(e):Qh(e);o?Rp(c.startContainer,l):(c.insertNode(l),c.collapse(!1))};return Promise.resolve(r()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Ip(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Lp(t,e,o){await new rt(t).authenticateWithKey(e,o)}async function Ap(t){let o=await new Ae(t).get("/platform/config/",{version:null,useCache:!0});return A(o)}async function Jh(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 Mp(t,e){let o=await Jh(e),n=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[o]}),t.dispatchEvent(n)}finally{Object.hasOwn(t,"files")&&delete t.files}}0&&(module.exports={Card,ContentEditableInput,DeepdeskAPI,DeepdeskSDK,HTTPClient,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createFullRange,createOverlayContainer,createRangeFromOffsets,escapeHTML,fetchPlatformConfig,formatTextMarkup,getRangeOffsets,getRangeText,insertCKEditor,isHTML,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});
|