@deepdesk/deepdesk-sdk 19.6.2-beta.5 → 19.6.2-beta.6
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 +8 -8
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.esm.js +8 -8
- package/dist/index.iife.js +25 -25
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";var Qg=Object.create;var oo=Object.defineProperty,Xg=Object.defineProperties,Jg=Object.getOwnPropertyDescriptor,Zg=Object.getOwnPropertyDescriptors,Yg=Object.getOwnPropertyNames,as=Object.getOwnPropertySymbols,em=Object.getPrototypeOf,ci=Object.prototype.hasOwnProperty,Qa=Object.prototype.propertyIsEnumerable;var Ga=(t,e,n)=>e in t?oo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,h=(t,e)=>{for(var n in e||(e={}))ci.call(e,n)&&Ga(t,n,e[n]);if(as)for(var n of as(e))Qa.call(e,n)&&Ga(t,n,e[n]);return t},b=(t,e)=>Xg(t,Zg(e));var D=(t,e)=>{var n={};for(var o in t)ci.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&as)for(var o of as(t))e.indexOf(o)<0&&Qa.call(t,o)&&(n[o]=t[o]);return n};var ee=(t,e)=>{for(var n in e)oo(t,n,{get:e[n],enumerable:!0})},Xa=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Yg(e))!ci.call(t,s)&&s!==n&&oo(t,s,{get:()=>e[s],enumerable:!(o=Jg(e,s))||o.enumerable});return t};var F=(t,e,n)=>(n=t!=null?Qg(em(t)):{},Xa(e||!t||!t.__esModule?oo(n,"default",{value:t,enumerable:!0}):n,t)),tm=t=>Xa(oo({},"__esModule",{value:!0}),t);var S=(t,e,n)=>new Promise((o,s)=>{var r=c=>{try{a(n.next(c))}catch(l){s(l)}},i=c=>{try{a(n.throw(c))}catch(l){s(l)}},a=c=>c.done?o(c.value):Promise.resolve(c.value).then(r,i);a((n=n.apply(t,e)).next())});var sv={};ee(sv,{Card:()=>B,ContentEditableInput:()=>Sn,DeepdeskAPI:()=>wt,DeepdeskSDK:()=>is,HTTPClient:()=>bn,InputMediator:()=>Ct,InputType:()=>$t,KeyboardHint:()=>ps,Label:()=>sl,Locale:()=>ro,Section:()=>Ge,SectionList:()=>En,Sources:()=>Qe,Suggestion:()=>M,SuggestionList:()=>se,TextAreaInput:()=>xn,ToggleButton:()=>qt,attachFile:()=>Wg,authenticateWithKey:()=>zg,createFullRange:()=>Yn,createOverlayContainer:()=>rs,createRangeFromOffsets:()=>Wt,escapeHTML:()=>Wn,formatTextMarkup:()=>Vg,getRangeOffsets:()=>ts,getRangeText:()=>ns,insertCKEditor:()=>Gg,isHTML:()=>Lo,isSupportedInputElement:()=>ii,logEvent:()=>Ms,updateContentEditable:()=>qg,updateTextArea:()=>jg,useClickOutsideRoot:()=>Nt,useStyles:()=>C,waitForElementVisibilityChange:()=>di});module.exports=tm(sv);var pi=F(require("classnames")),ke=F(require("react"));var ls=F(require("react")),Ja=F(require("classnames"));var so=ls.default.createContext({});function C(t,e){let r=(0,ls.useContext)(so),{debug:n}=r,s=D(r,["debug"])[t];return Object.entries(e).reduce((i,[a,c])=>{let l=s==null?void 0:s[a];return b(h({},i),{[a]:(0,Ja.default)(c,l,n?`${t}__${a}`:!1)})},{})}var Za={root:"dd-4s9wq"};var Vt=require("react/jsx-runtime"),ds=()=>(0,Vt.jsxs)("svg",{className:Za.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Vt.jsx)("defs",{children:(0,Vt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Vt.jsx)("title",{children:"Failed loading image"}),(0,Vt.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 ui={root:"dd-c9KvZ",imageWrapper:"dd-sE7D9",image:"dd-bEGMz",content:"dd-oFIQa",title:"dd-mSgoo",contentIsCropped:"dd-Uvjv4",lineClamp:"dd-ApQo-"};var jt=require("react/jsx-runtime"),cs=(0,ke.createContext)(ui),nm=({title:t,src:e})=>{let n=(0,ke.useContext)(cs),[o,s]=(0,ke.useState)(!1);return(0,ke.useEffect)(()=>{s(!1)},[e]),(0,jt.jsx)("div",{className:n.imageWrapper,children:e&&!o?(0,jt.jsx)("img",{className:n.image,alt:t,src:e,onError:()=>s(!0)}):(0,jt.jsx)(ds,{})})},om=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let s=(0,ke.useContext)(cs);return(0,jt.jsx)("div",{className:(0,pi.default)(s.content,t,{[s.contentIsCropped]:n,[s.lineClamp]:e}),children:o})},sm=r=>{var i=r,{as:t="h1",cropText:e=!1,className:n,children:o}=i,s=D(i,["as","cropText","className","children"]);let a=(0,ke.useContext)(cs);return ke.default.createElement(t,h({className:(0,pi.default)(a.title,n,{[a.contentIsCropped]:e})},s),o)},us=({children:t})=>{let e=C("Card",ui);return(0,jt.jsx)("div",{className:e.root,children:(0,jt.jsx)(cs.Provider,{value:e,children:t})})};us.Image=nm;us.Content=om;us.Title=sm;var B=us;var el=F(require("classnames"));var Ya={root:"dd-llBx9"};var tl=require("react/jsx-runtime");var rm={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},im=o=>{var s=o,{className:t,keyCode:e}=s,n=D(s,["className","keyCode"]);let r=C("KeyboardHint",Ya);return(0,tl.jsx)("span",h({"data-key":rm[e],className:(0,el.default)(t,r.root)},n))},ps=im;var ol=F(require("classnames"));var nl={root:"dd-e6HXZ"};var rl=require("react/jsx-runtime"),am=o=>{var s=o,{className:t,children:e}=s,n=D(s,["className","children"]);let r=C("Label",nl);return(0,rl.jsx)("span",b(h({},n),{className:(0,ol.default)(t,r.root),children:e}))},sl=am;var il={root:"dd-FiMI7",subTitleContainer:"dd-98jc7",subtitle:"dd-3MnW8",suggestions:"dd-0SGL8"};var Tn=require("react/jsx-runtime"),lm=s=>{var r=s,{title:t,children:e,type:n}=r,o=D(r,["title","children","type"]);let i=C("Section",il);return(0,Tn.jsxs)("section",b(h({},o),{className:i.root,"data-section-type":n,children:[t&&(0,Tn.jsx)("div",{className:i.subTitleContainer,children:(0,Tn.jsx)("span",{className:i.subtitle,children:t})}),(0,Tn.jsx)("div",{className:i.suggestions,children:e})]}))},Ge=lm;var ul=F(require("classnames")),pl=require("react");var Et=require("react"),dl=require("react/jsx-runtime"),al=(0,Et.createContext)(null),ll=({scrollContainerRef:t,children:e})=>{let n=(0,Et.useCallback)(o=>{let s=t.current;if(!s||s.scrollHeight<=s.clientHeight)return;let{top:r}=s.getBoundingClientRect(),{top:i}=o.getBoundingClientRect(),a=s.scrollTop+(i-r);typeof s.scrollTo=="function"?s.scrollTo({top:a}):s.scrollTop=a},[]);return(0,dl.jsx)(al.Provider,{value:n,children:e})},gs=t=>{let e=(0,Et.useContext)(al);(0,Et.useEffect)(()=>{let n=t.current;n&&e(n)},[])};var cl={root:"dd-uoTXh"};var gi=require("react/jsx-runtime"),dm=({className:t,children:e})=>{let n=C("SectionList",cl),o=(0,pl.useRef)(null);return(0,gi.jsx)(ll,{scrollContainerRef:o,children:(0,gi.jsx)("div",{ref:o,className:(0,ul.default)(n.root,t),children:e})})},En=dm;var kn=F(require("classnames")),fe=F(require("react"));var mi={root:"dd-1g-A9",fadein:"dd-McXxq",isClickable:"dd-CTG8E",isSelected:"dd-yhg27",actions:"dd-Nlm6p",actionsIsFixed:"dd-OK-kw",actionButton:"dd-zbXsQ",dropdownList:"dd-AvwWP",dropdownButton:"dd-piaJi",dropdownItem:"dd-qgkTO",dropdownItemButton:"dd-sTE2D",actionButtonIsPrimary:"dd-mhkWS",actionButtonIsDisabled:"dd-0eKLQ",labels:"dd-QKJu6",label:"dd-aMplE",buttonsContainer:"dd-uRYN4",button:"dd-9UE-x",buttonPrimary:"dd-aYDCB",buttonSecondary:"dd--cpPL",buttonWithIcon:"dd-MQVt5",icon:"dd-Jr-ww",buttonDisabled:"dd-agTuH"};var ce=require("react/jsx-runtime"),kt=(0,fe.createContext)(mi),cm=o=>{var s=o,{fixed:t,children:e}=s,n=D(s,["fixed","children"]);let r=(0,fe.useContext)(kt);return(0,ce.jsx)("div",b(h({},n),{className:(0,kn.default)(r.actions,{[r.actionsIsFixed]:t}),children:e}))};function um(c){var l=c,{as:t,className:e,icon:n,title:o,children:s,disabled:r,variant:i}=l,a=D(l,["as","className","icon","title","children","disabled","variant"]);let d=(0,fe.useContext)(kt);return(0,ce.jsxs)(t||"button",b(h({type:"button",className:(0,kn.default)(d.button,{[d.buttonWithIcon]:n,[d.buttonDisabled]:r,[d.buttonPrimary]:i==="primary",[d.buttonSecondary]:i==="secondary"},e),title:o,"aria-label":o},a),{children:[n&&(0,ce.jsx)("span",{className:d.icon,children:n}),s]}))}var pm=({children:t})=>{let e=(0,fe.useContext)(kt);return(0,ce.jsx)("div",{className:e.buttonsContainer,children:t})},gm=({className:t,primary:e,disabled:n,label:o,children:s})=>{let r=(0,fe.useContext)(kt);return(0,ce.jsxs)("div",{className:(0,kn.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,(0,ce.jsx)("ul",{className:r.dropdownList,children:s})]})},mm=({index:t,label:e,onClick:n})=>{let o=(0,fe.useContext)(kt);return(0,ce.jsx)("li",{className:o.dropdownItem,children:(0,ce.jsx)("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},fm=({className:t,primary:e,disabled:n,onClick:o,label:s})=>{let r=(0,fe.useContext)(kt);return(0,ce.jsx)("button",{type:"button",className:(0,kn.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onClick:o!=null?o:(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:s})},hm=({labels:t})=>{let e=(0,fe.useContext)(kt);return(0,ce.jsx)("div",{className:e.labels,children:t.map(n=>(0,ce.jsx)("span",{className:e.label,children:n},n))})},Rt=fe.default.forwardRef((a,i)=>{var c=a,{className:t,selected:e,onClick:n,children:o,as:s="div"}=c,r=D(c,["className","selected","onClick","children","as"]);let l=C("Suggestion",mi),d=(0,fe.useCallback)(p=>{p.preventDefault(),n&&n(p)},[n]);return(0,ce.jsx)(s,b(h({},r),{ref:i,className:(0,kn.default)(t,l.root,{[l.isSelected]:e,[l.isClickable]:!!n}),onClick:d,children:(0,ce.jsx)(kt.Provider,{value:l,children:o})}))});Rt.Labels=hm;Rt.Actions=cm;Rt.ActionButton=fm;Rt.DropdownButton=gm;Rt.DropdownItem=mm;Rt.ButtonsContainer=pm;Rt.Button=um;var M=Rt;var ml=F(require("classnames"));var gl={root:"dd-W35K-",isWithDivider:"dd-sscOy"};var fl=require("react/jsx-runtime"),ym=({withDivider:t,children:e})=>{let n=C("SuggestionList",gl);return(0,fl.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,ml.default)(n.root,{[n.isWithDivider]:t}),children:e})},se=ym;var yl=F(require("classnames"));var hl={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};var ms=require("react/jsx-runtime"),vm=({className:t,isCollapsed:e,title:n,onClick:o})=>{let s=C("ToggleButton",hl);return(0,ms.jsx)("button",{type:"button",className:(0,yl.default)(s.root,t,{[s.isCollapsed]:e}),onClick:o,title:n,children:(0,ms.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,ms.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},qt=vm;var vl=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,fs=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Sl=/x-deepdesk-(([a-z0-9\-_])+-version)/,hs=["cues","custom-data","custom-data-banner","knowledge-assist"],xl=Intl.DateTimeFormat().resolvedOptions().timeZone,Qe=(y=>(y.SEARCH="search",y.TEMPLATE="template",y.ELASTIC_SEARCH="search-autocomplete",y.GPT="gpt",y.TRIE="trie",y.TRIE_WITH_TYPOS="trie-with-typos",y.SEMANTIC="semantic",y.TEXT_RECOMMENDATION="text_recommendation",y.URL_RECOMMENDATION="url_recommendation",y.LINK_RECOMMENDATION="link_recommendation",y.PERSONAL_COLLECTION="personal-collection",y.PERSONAL_COLLECTION_SEARCH="personal-collection-search",y.SEARCH_OVERLAY="search-overlay",y.SEARCH_PREVIEW="search-preview",y.SEARCH_URL="search-url",y.STYLE="style",y))(Qe||{}),$t=(i=>(i.ENTER="enter",i.TAB="tab",i.ARROW="arrow",i.HOTKEY="hotkey",i.MOUSE="mouse",i.SPACE="space",i))($t||{});var J=require("react"),or=require("react-redux");var Pt=require("@reduxjs/toolkit");var ro=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(ro||{});var Sm={isLoggedIn:null,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1,loginError:null},re=t=>t.auth.isLoggedIn;var bl=t=>t.auth.verifyFetchState,Cl=t=>t.auth.showLoginOverlay,wl=t=>t.auth.loginError,lt=(0,Pt.createAsyncThunk)("auth/validate",(t,e)=>S(null,null,function*(){return e.extra.deepdeskAPI.isLoggedIn()})),Tl=(0,Pt.createAsyncThunk)("auth/requestLogin",(n,o)=>S(null,[n,o],function*({email:t},e){let{deepdeskAPI:s}=e.extra;return s.requestLoginByEmail(t)})),fi=(0,Pt.createAsyncThunk)("auth/loginWithPassword",(o,s)=>S(null,[o,s],function*({username:t,password:e},n){let{deepdeskAPI:r}=n.extra;return r.loginWithPassword(t,e)})),ys=(0,Pt.createAsyncThunk)("auth/logout",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n}=e.extra;yield n.logout()})),io=(0,Pt.createAsyncThunk)("auth/verifyLoginToken",(n,o)=>S(null,[n,o],function*({token:t},e){let{deepdeskAPI:s}=e.extra;return s.verifyLoginToken(t)})),El=(0,Pt.createSlice)({name:"auth",initialState:Sm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload},setLoginError(t,e){t.loginError=e.payload},clearLoginError(t){t.loginError=null}},extraReducers:t=>{t.addCase(lt.pending,e=>{e.loginFetchState="loading"}),t.addCase(lt.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(lt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(fi.pending,e=>{e.loginFetchState="loading",e.loginError=null}),t.addCase(fi.fulfilled,e=>{e.isLoggedIn=!0,e.loginFetchState="done",e.loginError=null,e.showLoginOverlay=!1}),t.addCase(fi.rejected,(e,n)=>{e.loginFetchState="error",e.isLoggedIn=!1,e.loginError=n.error.message==="Bad Request"?"Invalid credentials":"Login failed"}),t.addCase(ys.fulfilled,e=>{e.isLoggedIn=!1,e.loginFetchState="idle",e.loginError=null}),t.addCase(ys.rejected,e=>{e.isLoggedIn=!1,e.loginFetchState="error"}),t.addCase(io.pending,e=>{e.verifyFetchState="loading"}),t.addCase(io.rejected,e=>{e.verifyFetchState="error"}),t.addCase(io.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Rn,setShowLoginOverlay:kl,setLoginError:hi,clearLoginError:vs}=El.actions,Rl=El.reducer;var Qt=require("@reduxjs/toolkit"),Dl=require("diff");function Pl(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function It(t,e,n=10){let o=typeof t,s=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==s?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>It(r,e[i],n-1)):Pl(t)&&Pl(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>It(t[i],e[i],n-1)):!1}function xm(t){return Math.max(...t.map(e=>e.length))}function bm(t,e){let n=t.reduce((o,s)=>{if(s){let r=o[s]?o[s]+1:1;return b(h({},o),{[s]:r})}return o},{});return Object.keys(n).reduce((o,s)=>(n[s]<e&&o.push(s),o),[])}function Il(t,e){let o=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<xm(o);s++){let r=bm(o.map(a=>a[s]),e),i=o.filter(a=>!r.includes(a[s]));if(i.length>=e)o=i;else return{text:o[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Cm=2;function Al(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=Il(t,Cm);return n&&n.text!==e?n:t[0]}var He=require("@reduxjs/toolkit");var wm={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},P=wm;var yi="deepdesk.widgetAssistantSession";function Ss(t){if(!t||typeof sessionStorage=="undefined")return null;try{return sessionStorage.getItem(`${yi}:${t}`)}catch(e){return null}}function Ll(t,e){if(!(!t||typeof sessionStorage=="undefined"))try{sessionStorage.setItem(`${yi}:${t}`,e)}catch(n){}}function Ml(t){if(!(!t||typeof sessionStorage=="undefined"))try{sessionStorage.removeItem(`${yi}:${t}`)}catch(e){return}}var Nl={current:null,isSupported:null},j=(0,He.createAction)("resetConversation"),xs=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.externalId)||null},Re=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Pn=t=>t.conversation.isSupported,vi=(0,He.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),bs=(0,He.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),Cs=(0,He.createAsyncThunk)("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),ws=(0,He.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Re(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),Si=(0,He.createAsyncThunk)("conversation/upsert",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.upsertConversation(t)}),xi=(0,He.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Re(e.getState());if(!o){P.warn("No current conversation to update messages");return}return n.postMessages(o,t.map(s=>h({},s)))}),Tm=[bs.rejected,Cs.rejected,ws.rejected,xi.rejected].map(t=>t==null?void 0:t.toString());function Em(t){return Tm.includes(t.type)}var km=(0,He.createSlice)({name:"conversation",initialState:Nl,reducers:{},extraReducers:t=>{t.addCase(vi.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(bs.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Cs.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Si.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(ws.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(j,e=>{var n,o;return Ml((o=(n=e.current)==null?void 0:n.externalId)!=null?o:void 0),Nl}).addMatcher(Em,(e,n)=>{var o;throw P.info("Conversation action rejected",n.type,((o=n.error)==null?void 0:o.message)||"No message"),new Error(n.error.message)})}}),Ol=km.reducer;var Gt={text:"",html:null,suggestionTextStart:0,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],pinnedSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function bi(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}}var Ts=(0,Qt.createAction)("input/applyImageSuggestion"),_l=(0,Qt.createSlice)({name:"input",initialState:Gt,reducers:{setInput(t,e){var i,a;let{beforeInputChange:n}=t,{text:o,html:s,suggestionTextStart:r}=e.payload;if(t.text=o,t.html=s!=null?s:null,t.suggestionTextStart=o===""?0:Math.max(0,r!=null?r:0),o==="")t.metrics=Gt.metrics,t.textSuggestions=[],t.mixedSuggestion=null;else if(n!==null&&t.text!==n.text){let{key:c,shiftKey:l,ctrlKey:d,metaKey:p,altKey:u}=n.keyDown;switch(c){case"Enter":l&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:m}=t,f=(0,Dl.diffChars)(n.text,m);n.text.length-m.length>1&&t.metrics.deletions.push(...f.filter(g=>g.removed).map(g=>g.value)),t.metrics.numCharsDeleted+=n.text.length-m.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(d||p)break;default:if(!d&&!p&&!u){t.metrics.numCharsTyped+=1;let m=((i=n.selection)==null?void 0:i.start)!==void 0&&((a=n.selection)==null?void 0:a.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;m&&m.length>0&&(t.metrics.numCharsDeleted+=m.length,t.metrics.deletions.push(m))}}t.metrics.agentStartedTypingTimestamp||(t.metrics.agentStartedTypingTimestamp=Date.now())}t.beforeInputChange=null},sendMessage(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(n=>!t.metrics.textSuggestions.some(o=>o.text===n.text&&o.source===n.source))},setSelection(t,e){e.payload!==null&&(It(t.selection,e.payload)||(t.selection=e.payload))},commitSuggestion(t,e){let n=e.payload,{text:o,suggestion:{source:s,abVariant:r,abTestName:i,trainingJobs:a,sourceText:c,searchTerm:l,assistantCode:d,text:p},eventMetrics:{inputType:u},replace:m}=n,f=s==="search"||s==="personal-collection-search",g=o.slice(t.text.substring(0,t.selection.start).length);(f||m==="selection")&&(g=o),n.suggestion.source==="search-overlay"&&(g=p),t.metrics.textSuggestions.push({text:g,source:s,assistantCode:d,abVariant:r,abTestName:i,inputType:u,sourceText:c,trainingJobs:a||[],searchTerm:f?t.text:l}),t.textSuggestions=[],t.selectedSuggestionIndex=-1},offeredTextSuggestion(t,e){let{text:n,suggestion:{source:o}}=e.payload;t.metrics.offeredTextSuggestions.find(r=>r.text===n)||t.metrics.offeredTextSuggestions.push({text:n,source:o})},registerKeyDown(t,e){let{key:n}=e.payload;["Control","Meta","Shift","Alt"].includes(n)||(t.beforeInputChange={text:t.text,selection:t.selection,keyDown:e.payload})},registerKeyUp(t,e){},registerCut(t,e){let{metrics:n}=t,o=e.payload;t.metrics=b(h({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:s}=e.payload,r=n.numCharsDeleted+(s!=null&&s.length?s.length:0),i=s!=null&&s.length?[...n.deletions,s]:n.deletions;t.metrics=b(h({},t.metrics),{numCharsDeleted:r,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},selectPreviousTextSuggestion(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},selectTextSuggestionByIndex(t,e){t.selectedSuggestionIndex=e.payload},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0){t.mixedSuggestion=null;return}let n=Xt({input:t}),o=Al(e.payload,n);t.mixedSuggestion=o!=null&&o.text.includes(n)?o:null},setPinnedSuggestions(t,e){t.pinnedSuggestions=e.payload},removePinnedSuggestions(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(o=>o.source!==e.payload.source||e.payload.assistantCode&&o.assistantCode!==e.payload.assistantCode?!0:e.payload.text?o.text!==e.payload.text:!1);let n=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex>n-1&&(t.selectedSuggestionIndex=-1)},setMetrics(t,{payload:e}){t.metrics=e},resetMetrics(t){t.metrics=Gt.metrics}},extraReducers:t=>{t.addCase(j,e=>{e.mixedSuggestion=Gt.mixedSuggestion,e.textSuggestions=Gt.textSuggestions,e.selectedSuggestionIndex=Gt.selectedSuggestionIndex,e.metrics=Gt.metrics})}}),Xt=t=>{let{text:e,selection:n,suggestionTextStart:o}=t.input;return e.slice(o,n.end)},Rm=t=>t.input.mixedSuggestion,Pm=t=>t.input.pinnedSuggestions,Im=t=>t.input.textSuggestions,ao=t=>t.input.selectedSuggestionIndex,Jt=(0,Qt.createSelector)([Im,Pm],(t,e)=>[...t,...e]),In=(0,Qt.createSelector)([Jt,Rm,ao],(t,e,n)=>n>-1?t[n]:e),Fl=t=>t.input.selection,{commitSuggestion:Se,offeredTextSuggestion:Hl,registerCut:Bl,registerKeyDown:Ul,registerKeyUp:Kl,registerPaste:Wl,selectNextTextSuggestion:zl,selectPreviousTextSuggestion:Vl,selectTextSuggestionByIndex:Es,setInput:ks,setMetrics:jl,setPinnedSuggestions:An,removePinnedSuggestions:Zt,setSelection:Rs,setTextSuggestions:At,resetMetrics:ql,sendMessage:Yt}=_l.actions,$l=_l.reducer;var Mn=require("@reduxjs/toolkit");var en=require("@reduxjs/toolkit");function Gl(t){try{return Intl.DateTimeFormat(void 0,{timeZone:t}),!0}catch(e){return!1}}var Am={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle",showNicknameDialog:!1},Ln=t=>{var e;return(e=t.info.agentInfo)!=null?e:null},Ql=t=>{var e;return(e=t.info.visitorInfo)!=null?e:null},Xl=t=>{var e;return(e=t.info.customData)!=null?e:null},co=({info:{visitorInfo:t,agentInfo:e}})=>{var n,o;return{timezone:t!=null&&t.visitorTimeZone&&Gl(t.visitorTimeZone)?t.visitorTimeZone:xl,agentName:(n=e==null?void 0:e.agentNickname)!=null?n:"",visitorName:(o=t==null?void 0:t.visitorName)!=null?o:""}},Lm=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],Jl=(0,en.createAsyncThunk)("info/setAgentNickname",(n,o)=>S(null,[n,o],function*({agentNickname:t},e){var i;let{deepdeskAPI:s}=e.extra,r=yield s.patchMe({nickname:t});return{agentNickname:(i=r==null?void 0:r.nickname)!=null?i:t}})),lo=(0,en.createAsyncThunk)("info/setAgentInfo",(t,e)=>S(null,null,function*(){var r,i,a;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=[];if(t.agentId&&t.skipSync!==!0&&s.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let c=Lm.reduce((l,[d,p])=>!o[p]&&d in t?b(h({},l),{[p]:t[d]}):l,{});Object.keys(c).length>0&&s.push(n.patchMe(c).then(l=>o=l))}return s.length>0&&(yield Promise.all(s)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(r=o.nickname)!=null?r:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(a=o.defaultLocale)!=null?a:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),Ci=(0,en.createAsyncThunk)("info/setAgentSettings",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=h(h({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:s}),s})),wi=(0,en.createAsyncThunk)("info/getAgentSettings",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),Zl=(0,en.createSlice)({name:"info",initialState:Am,reducers:{setVisitorInfo(t,e){t.visitorInfo=h(h({},t.visitorInfo),e.payload)},setCustomData(t,e){t.customData=e.payload},setPlatformVariables(t,e){t.platformVariables=e.payload},setShowNicknameDialog(t,e){t.showNicknameDialog=e.payload}},extraReducers:t=>{t.addCase(lo.pending,(e,n)=>{e.fetchState="loading",e.agentInfo=h(h({},e.agentInfo),n.meta.arg)}).addCase(lo.rejected,e=>{e.fetchState="error"}).addCase(lo.fulfilled,(e,n)=>{e.fetchState="done",e.agentInfo=n.payload}).addCase(Ci.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(wi.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(j,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Yl,setCustomData:ed,setPlatformVariables:td,setShowNicknameDialog:nd}=Zl.actions,od=Zl.reducer;function Be(t,e){return e?t==null?(P.warn("replaceVars called with non-string text; upstream contract violation",{keys:Object.keys(e)}),t):Object.entries(e).reduce((n,[o,s])=>n.replaceAll(o,s),t):t}var Ps={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},sd=t=>t.search.isOpen,rd=t=>t.search.page,Ti=t=>t.search.list,id=t=>t.search.aggregates,Mm=(0,Mn.createSelector)([Ti,(t,e)=>e],(t,e)=>t.filter(n=>n.type===e)),ad=t=>e=>Mm(e,t),tn=(0,Mn.createAsyncThunk)("search/getAll",(t,e)=>S(null,null,function*(){var c;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(c=o.conversation.current)==null?void 0:c.profileCode,{platformVariables:r}=o.info;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:co(o)});return{results:i.map(l=>b(h(h({},l),l.title&&r?{title:Be(l.title,r)}:{}),{text:Be(l.text,r!=null?r:{}),source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:a}})),ld=(0,Mn.createSlice)({name:"search",initialState:Ps,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=Ps.fetchState,t.list=Ps.list}},extraReducers:t=>{t.addCase(tn.pending,e=>{e.fetchState="loading"}).addCase(tn.rejected,(e,n)=>{e.fetchState="error",P.error(n.error)}).addCase(tn.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload.results,e.aggregates=n.payload.aggregates||{}}).addCase(j,()=>Ps)}}),{resetSearch:Is,setIsOpen:Ue,setPage:Nn}=ld.actions,dd=ld.reducer;var Ei="SetOutputs",On="ShowLoginOverlay",uo="UserLoggedIn",Nm="UserLoggedOut",dt="ApplySuggestion",ki="ApplyImageSuggestion",Om="ShowCommandPalette",As="ShowNicknameDialog",Ls="ReduxAction",Dm="RemovePinnedSuggestion",_m=t=>({[Ei]:e=>{var s,r;let n=(s=t.getState().conversation.current)==null?void 0:s.externalId,o=(r=e==null?void 0:e.payload)==null?void 0:r.externalConversationId;o&&o!==n||t.dispatch(b(h({},e),{isBroadcasted:!0}))},[Ls]:e=>{e.isBroadcasted||t.dispatch(b(h({},e),{isBroadcasted:!0}))},[Dm]:e=>{t.dispatch(Zt(e))},[Om]:e=>{t.dispatch(Ue(e.isOpen)),e.page&&t.dispatch(Nn(e.page))},[As]:e=>{t.dispatch(nd(e.showNicknameDialog))},[On]:e=>{t.dispatch(kl(e))},[uo]:()=>{t.dispatch(lt())},[Nm]:()=>{t.dispatch(lt())},[ki]:e=>{t.dispatch(Ts({suggestion:e.suggestion}))},[dt]:e=>{t.dispatch(Se(b(h({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),cd=_m;var pd=require("react-redux");var ud=require("@reduxjs/toolkit");function Ms(t){return(0,ud.createAsyncThunk)("analytics/logEvent",(e,n)=>{var r,i,a;let o=(i=(r=n.getState())==null?void 0:r.conversation.current)==null?void 0:i.id,s=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,b(h({conversationId:o},s),{data:e.data}))})(t)}function X(){let t=(0,pd.useDispatch)();return(e,n)=>S(null,null,function*(){yield t(Ms({name:e,data:n}))})}var Dn=require("react"),gd=require("react-redux");function Ns(t,e){let n=(0,Dn.useRef)(t);n.current=t;let[o,s]=(0,Dn.useState)(void 0),[r,i]=(0,Dn.useState)(void 0),[a,c]=(0,Dn.useState)("idle"),l=(0,gd.useDispatch)();return{error:r,state:a,data:o,call:u=>S(null,null,function*(){c("loading"),yield l(n.current(u)).unwrap().then(m=>{s(m),c("done"),e!=null&&e.onSuccess&&(e==null||e.onSuccess(m))}).catch(m=>{i(m),c("error"),e!=null&&e.onError&&(e==null||e.onError(m))})}),reset:()=>{c("idle"),s(void 0),i(void 0)}}}var po=F(require("react")),fd=require("react/jsx-runtime"),md=po.default.createContext(null),ct=({broadcastEvents:t,children:e})=>{let n=po.default.useMemo(()=>t,[]);return(0,fd.jsx)(md.Provider,{value:n,children:e})},he=()=>{let t=(0,po.useContext)(md);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var Ks=require("react");var Ri=function(t,e){return Ri=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},Ri(t,e)};function go(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ri(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var xe=function(){return xe=Object.assign||function(e){for(var n,o=1,s=arguments.length;o<s;o++){n=arguments[o];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xe.apply(this,arguments)};function hd(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(n[o[s]]=t[o[s]]);return n}function Os(t,e,n){if(n||arguments.length===2)for(var o=0,s=e.length,r;o<s;o++)(r||!(o in e))&&(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}function Ds(t,e){var n=e&&e.cache?e.cache:zm,o=e&&e.serializer?e.serializer:Km,s=e&&e.strategy?e.strategy:Hm;return s(t,{cache:n,serializer:o})}function Fm(t){return t==null||typeof t=="number"||typeof t=="boolean"}function yd(t,e,n,o){var s=Fm(o)?o:n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.call(this,o),e.set(s,r)),r}function vd(t,e,n){var o=Array.prototype.slice.call(arguments,3),s=n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.apply(this,o),e.set(s,r)),r}function Pi(t,e,n,o,s){return n.bind(e,t,o,s)}function Hm(t,e){var n=t.length===1?yd:vd;return Pi(t,this,n,e.cache.create(),e.serializer)}function Bm(t,e){return Pi(t,this,vd,e.cache.create(),e.serializer)}function Um(t,e){return Pi(t,this,yd,e.cache.create(),e.serializer)}var Km=function(){return JSON.stringify(arguments)},Wm=(function(){function t(){this.cache=Object.create(null)}return t.prototype.get=function(e){return this.cache[e]},t.prototype.set=function(e,n){this.cache[e]=n},t})(),zm={create:function(){return new Wm}},_s={variadic:Bm,monadic:Um};var Fs;(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"})(Fs||(Fs={}));var Hs=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Pe;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(Pe||(Pe={}));var Bs;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Bs||(Bs={}));function Ii(t){return t.type===Pe.literal}function Ai(t){return t.type===Pe.argument}function mo(t){return t.type===Pe.number}function fo(t){return t.type===Pe.date}function ho(t){return t.type===Pe.time}function yo(t){return t.type===Pe.select}function vo(t){return t.type===Pe.plural}function Sd(t){return t.type===Pe.pound}function So(t){return t.type===Pe.tag}function Us(t){return!!(t&&typeof t=="object"&&t.type===Bs.number)}function xo(t){return!!(t&&typeof t=="object"&&t.type===Bs.dateTime)}function Li(t){t.forEach(function(e){if(delete e.location,yo(e)||vo(e))for(var n in e.options)delete e.options[n].location,Li(e.options[n].value);else mo(e)&&Us(e.style)||(fo(e)||ho(e))&&xo(e.style)?delete e.style.location:So(e)&&Li(e.children)})}function xd(t,e){e===void 0&&(e={}),e=xe({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new Hs(t,e).parse();if(n.err){var o=SyntaxError(Fs[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||Li(n.val),n.val}var nn;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(nn||(nn={}));var bo=(function(t){go(e,t);function e(n,o,s){var r=t.call(this,n)||this;return r.code=o,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e})(Error);var Mi=(function(t){go(e,t);function e(n,o,s,r){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(s).join('", "'),'"'),nn.INVALID_VALUE,r)||this}return e})(bo);var bd=(function(t){go(e,t);function e(n,o,s){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),nn.INVALID_VALUE,s)||this}return e})(bo);var Cd=(function(t){go(e,t);function e(n,o){return t.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(o,'"'),nn.MISSING_VALUE,o)||this}return e})(bo);var de;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(de||(de={}));function Vm(t){return t.length<2?t:t.reduce(function(e,n){var o=e[e.length-1];return!o||o.type!==de.literal||n.type!==de.literal?e.push(n):o.value+=n.value,e},[])}function jm(t){return typeof t=="function"}function Co(t,e,n,o,s,r,i){if(t.length===1&&Ii(t[0]))return[{type:de.literal,value:t[0].value}];for(var a=[],c=0,l=t;c<l.length;c++){var d=l[c];if(Ii(d)){a.push({type:de.literal,value:d.value});continue}if(Sd(d)){typeof r=="number"&&a.push({type:de.literal,value:n.getNumberFormat(e).format(r)});continue}var p=d.value;if(!(s&&p in s))throw new Cd(p,i);var u=s[p];if(Ai(d)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?de.literal:de.object,value:u});continue}if(fo(d)){var m=typeof d.style=="string"?o.date[d.style]:xo(d.style)?d.style.parsedOptions:void 0;a.push({type:de.literal,value:n.getDateTimeFormat(e,m).format(u)});continue}if(ho(d)){var m=typeof d.style=="string"?o.time[d.style]:xo(d.style)?d.style.parsedOptions:o.time.medium;a.push({type:de.literal,value:n.getDateTimeFormat(e,m).format(u)});continue}if(mo(d)){var m=typeof d.style=="string"?o.number[d.style]:Us(d.style)?d.style.parsedOptions:void 0;m&&m.scale&&(u=u*(m.scale||1)),a.push({type:de.literal,value:n.getNumberFormat(e,m).format(u)});continue}if(So(d)){var f=d.children,g=d.value,y=s[g];if(!jm(y))throw new bd(g,"function",i);var v=Co(f,e,n,o,s,r),x=y(v.map(function(k){return k.value}));Array.isArray(x)||(x=[x]),a.push.apply(a,x.map(function(k){return{type:typeof k=="string"?de.literal:de.object,value:k}}))}if(yo(d)){var w=d.options[u]||d.options.other;if(!w)throw new Mi(d.value,u,Object.keys(d.options),i);a.push.apply(a,Co(w.value,e,n,o,s));continue}if(vo(d)){var w=d.options["=".concat(u)];if(!w){if(!Intl.PluralRules)throw new bo(`Intl.PluralRules is not available in this environment.
|
|
1
|
+
"use strict";var Xg=Object.create;var oo=Object.defineProperty,Jg=Object.defineProperties,Zg=Object.getOwnPropertyDescriptor,Yg=Object.getOwnPropertyDescriptors,em=Object.getOwnPropertyNames,ds=Object.getOwnPropertySymbols,tm=Object.getPrototypeOf,ci=Object.prototype.hasOwnProperty,Qa=Object.prototype.propertyIsEnumerable;var Ga=(t,e,n)=>e in t?oo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,h=(t,e)=>{for(var n in e||(e={}))ci.call(e,n)&&Ga(t,n,e[n]);if(ds)for(var n of ds(e))Qa.call(e,n)&&Ga(t,n,e[n]);return t},b=(t,e)=>Jg(t,Yg(e));var D=(t,e)=>{var n={};for(var o in t)ci.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&ds)for(var o of ds(t))e.indexOf(o)<0&&Qa.call(t,o)&&(n[o]=t[o]);return n};var ee=(t,e)=>{for(var n in e)oo(t,n,{get:e[n],enumerable:!0})},Xa=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of em(e))!ci.call(t,s)&&s!==n&&oo(t,s,{get:()=>e[s],enumerable:!(o=Zg(e,s))||o.enumerable});return t};var _=(t,e,n)=>(n=t!=null?Xg(tm(t)):{},Xa(e||!t||!t.__esModule?oo(n,"default",{value:t,enumerable:!0}):n,t)),nm=t=>Xa(oo({},"__esModule",{value:!0}),t);var S=(t,e,n)=>new Promise((o,s)=>{var r=c=>{try{a(n.next(c))}catch(l){s(l)}},i=c=>{try{a(n.throw(c))}catch(l){s(l)}},a=c=>c.done?o(c.value):Promise.resolve(c.value).then(r,i);a((n=n.apply(t,e)).next())});var rv={};ee(rv,{Card:()=>B,ContentEditableInput:()=>xn,DeepdeskAPI:()=>Et,DeepdeskSDK:()=>ls,HTTPClient:()=>Cn,InputMediator:()=>Tt,InputType:()=>$t,KeyboardHint:()=>ms,Label:()=>sl,Locale:()=>ro,Section:()=>Qe,SectionList:()=>kn,Sources:()=>Xe,Suggestion:()=>M,SuggestionList:()=>se,TextAreaInput:()=>bn,ToggleButton:()=>qt,attachFile:()=>zg,authenticateWithKey:()=>Vg,createFullRange:()=>Yn,createOverlayContainer:()=>as,createRangeFromOffsets:()=>zt,escapeHTML:()=>Wn,formatTextMarkup:()=>jg,getRangeOffsets:()=>os,getRangeText:()=>ss,insertCKEditor:()=>Qg,isHTML:()=>No,isSupportedInputElement:()=>ii,logEvent:()=>Ns,updateContentEditable:()=>$g,updateTextArea:()=>qg,useClickOutsideRoot:()=>Ot,useStyles:()=>C,waitForElementVisibilityChange:()=>di});module.exports=nm(rv);var pi=_(require("classnames")),Re=_(require("react"));var cs=_(require("react")),Ja=_(require("classnames"));var so=cs.default.createContext({});function C(t,e){let r=(0,cs.useContext)(so),{debug:n}=r,s=D(r,["debug"])[t];return Object.entries(e).reduce((i,[a,c])=>{let l=s==null?void 0:s[a];return b(h({},i),{[a]:(0,Ja.default)(c,l,n?`${t}__${a}`:!1)})},{})}var Za={root:"dd-4s9wq"};var Vt=require("react/jsx-runtime"),us=()=>(0,Vt.jsxs)("svg",{className:Za.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Vt.jsx)("defs",{children:(0,Vt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Vt.jsx)("title",{children:"Failed loading image"}),(0,Vt.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 ui={root:"dd-c9KvZ",imageWrapper:"dd-sE7D9",image:"dd-bEGMz",content:"dd-oFIQa",title:"dd-mSgoo",contentIsCropped:"dd-Uvjv4",lineClamp:"dd-ApQo-"};var jt=require("react/jsx-runtime"),ps=(0,Re.createContext)(ui),om=({title:t,src:e})=>{let n=(0,Re.useContext)(ps),[o,s]=(0,Re.useState)(!1);return(0,Re.useEffect)(()=>{s(!1)},[e]),(0,jt.jsx)("div",{className:n.imageWrapper,children:e&&!o?(0,jt.jsx)("img",{className:n.image,alt:t,src:e,onError:()=>s(!0)}):(0,jt.jsx)(us,{})})},sm=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let s=(0,Re.useContext)(ps);return(0,jt.jsx)("div",{className:(0,pi.default)(s.content,t,{[s.contentIsCropped]:n,[s.lineClamp]:e}),children:o})},rm=r=>{var i=r,{as:t="h1",cropText:e=!1,className:n,children:o}=i,s=D(i,["as","cropText","className","children"]);let a=(0,Re.useContext)(ps);return Re.default.createElement(t,h({className:(0,pi.default)(a.title,n,{[a.contentIsCropped]:e})},s),o)},gs=({children:t})=>{let e=C("Card",ui);return(0,jt.jsx)("div",{className:e.root,children:(0,jt.jsx)(ps.Provider,{value:e,children:t})})};gs.Image=om;gs.Content=sm;gs.Title=rm;var B=gs;var el=_(require("classnames"));var Ya={root:"dd-llBx9"};var tl=require("react/jsx-runtime");var im={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},am=o=>{var s=o,{className:t,keyCode:e}=s,n=D(s,["className","keyCode"]);let r=C("KeyboardHint",Ya);return(0,tl.jsx)("span",h({"data-key":im[e],className:(0,el.default)(t,r.root)},n))},ms=am;var ol=_(require("classnames"));var nl={root:"dd-e6HXZ"};var rl=require("react/jsx-runtime"),lm=o=>{var s=o,{className:t,children:e}=s,n=D(s,["className","children"]);let r=C("Label",nl);return(0,rl.jsx)("span",b(h({},n),{className:(0,ol.default)(t,r.root),children:e}))},sl=lm;var il={root:"dd-FiMI7",subTitleContainer:"dd-98jc7",subtitle:"dd-3MnW8",suggestions:"dd-0SGL8"};var En=require("react/jsx-runtime"),dm=s=>{var r=s,{title:t,children:e,type:n}=r,o=D(r,["title","children","type"]);let i=C("Section",il);return(0,En.jsxs)("section",b(h({},o),{className:i.root,"data-section-type":n,children:[t&&(0,En.jsx)("div",{className:i.subTitleContainer,children:(0,En.jsx)("span",{className:i.subtitle,children:t})}),(0,En.jsx)("div",{className:i.suggestions,children:e})]}))},Qe=dm;var ul=_(require("classnames")),pl=require("react");var Rt=require("react"),dl=require("react/jsx-runtime"),al=(0,Rt.createContext)(null),ll=({scrollContainerRef:t,children:e})=>{let n=(0,Rt.useCallback)(o=>{let s=t.current;if(!s||s.scrollHeight<=s.clientHeight)return;let{top:r}=s.getBoundingClientRect(),{top:i}=o.getBoundingClientRect(),a=s.scrollTop+(i-r);typeof s.scrollTo=="function"?s.scrollTo({top:a}):s.scrollTop=a},[]);return(0,dl.jsx)(al.Provider,{value:n,children:e})},fs=t=>{let e=(0,Rt.useContext)(al);(0,Rt.useEffect)(()=>{let n=t.current;n&&e(n)},[])};var cl={root:"dd-uoTXh"};var gi=require("react/jsx-runtime"),cm=({className:t,children:e})=>{let n=C("SectionList",cl),o=(0,pl.useRef)(null);return(0,gi.jsx)(ll,{scrollContainerRef:o,children:(0,gi.jsx)("div",{ref:o,className:(0,ul.default)(n.root,t),children:e})})},kn=cm;var Rn=_(require("classnames")),ye=_(require("react"));var mi={root:"dd-1g-A9",fadein:"dd-McXxq",isClickable:"dd-CTG8E",isSelected:"dd-yhg27",actions:"dd-Nlm6p",actionsIsFixed:"dd-OK-kw",actionButton:"dd-zbXsQ",dropdownList:"dd-AvwWP",dropdownButton:"dd-piaJi",dropdownItem:"dd-qgkTO",dropdownItemButton:"dd-sTE2D",actionButtonIsPrimary:"dd-mhkWS",actionButtonIsDisabled:"dd-0eKLQ",labels:"dd-QKJu6",label:"dd-aMplE",buttonsContainer:"dd-uRYN4",button:"dd-9UE-x",buttonPrimary:"dd-aYDCB",buttonSecondary:"dd--cpPL",buttonWithIcon:"dd-MQVt5",icon:"dd-Jr-ww",buttonDisabled:"dd-agTuH"};var ue=require("react/jsx-runtime"),Pt=(0,ye.createContext)(mi),um=o=>{var s=o,{fixed:t,children:e}=s,n=D(s,["fixed","children"]);let r=(0,ye.useContext)(Pt);return(0,ue.jsx)("div",b(h({},n),{className:(0,Rn.default)(r.actions,{[r.actionsIsFixed]:t}),children:e}))};function pm(c){var l=c,{as:t,className:e,icon:n,title:o,children:s,disabled:r,variant:i}=l,a=D(l,["as","className","icon","title","children","disabled","variant"]);let d=(0,ye.useContext)(Pt);return(0,ue.jsxs)(t||"button",b(h({type:"button",className:(0,Rn.default)(d.button,{[d.buttonWithIcon]:n,[d.buttonDisabled]:r,[d.buttonPrimary]:i==="primary",[d.buttonSecondary]:i==="secondary"},e),title:o,"aria-label":o},a),{children:[n&&(0,ue.jsx)("span",{className:d.icon,children:n}),s]}))}var gm=({children:t})=>{let e=(0,ye.useContext)(Pt);return(0,ue.jsx)("div",{className:e.buttonsContainer,children:t})},mm=({className:t,primary:e,disabled:n,label:o,children:s})=>{let r=(0,ye.useContext)(Pt);return(0,ue.jsxs)("div",{className:(0,Rn.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,(0,ue.jsx)("ul",{className:r.dropdownList,children:s})]})},fm=({index:t,label:e,onClick:n})=>{let o=(0,ye.useContext)(Pt);return(0,ue.jsx)("li",{className:o.dropdownItem,children:(0,ue.jsx)("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},hm=({className:t,primary:e,disabled:n,onClick:o,label:s})=>{let r=(0,ye.useContext)(Pt);return(0,ue.jsx)("button",{type:"button",className:(0,Rn.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onClick:o!=null?o:(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:s})},ym=({labels:t})=>{let e=(0,ye.useContext)(Pt);return(0,ue.jsx)("div",{className:e.labels,children:t.map(n=>(0,ue.jsx)("span",{className:e.label,children:n},n))})},It=ye.default.forwardRef((a,i)=>{var c=a,{className:t,selected:e,onClick:n,children:o,as:s="div"}=c,r=D(c,["className","selected","onClick","children","as"]);let l=C("Suggestion",mi),d=(0,ye.useCallback)(p=>{p.preventDefault(),n&&n(p)},[n]);return(0,ue.jsx)(s,b(h({},r),{ref:i,className:(0,Rn.default)(t,l.root,{[l.isSelected]:e,[l.isClickable]:!!n}),onClick:d,children:(0,ue.jsx)(Pt.Provider,{value:l,children:o})}))});It.Labels=ym;It.Actions=um;It.ActionButton=hm;It.DropdownButton=mm;It.DropdownItem=fm;It.ButtonsContainer=gm;It.Button=pm;var M=It;var ml=_(require("classnames"));var gl={root:"dd-W35K-",isWithDivider:"dd-sscOy"};var fl=require("react/jsx-runtime"),vm=({withDivider:t,children:e})=>{let n=C("SuggestionList",gl);return(0,fl.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,ml.default)(n.root,{[n.isWithDivider]:t}),children:e})},se=vm;var yl=_(require("classnames"));var hl={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};var hs=require("react/jsx-runtime"),Sm=({className:t,isCollapsed:e,title:n,onClick:o})=>{let s=C("ToggleButton",hl);return(0,hs.jsx)("button",{type:"button",className:(0,yl.default)(s.root,t,{[s.isCollapsed]:e}),onClick:o,title:n,children:(0,hs.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,hs.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},qt=Sm;var vl=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,ys=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Sl=/x-deepdesk-(([a-z0-9\-_])+-version)/,vs=["cues","custom-data","custom-data-banner","knowledge-assist"],xl=Intl.DateTimeFormat().resolvedOptions().timeZone,Xe=(y=>(y.SEARCH="search",y.TEMPLATE="template",y.ELASTIC_SEARCH="search-autocomplete",y.GPT="gpt",y.TRIE="trie",y.TRIE_WITH_TYPOS="trie-with-typos",y.SEMANTIC="semantic",y.TEXT_RECOMMENDATION="text_recommendation",y.URL_RECOMMENDATION="url_recommendation",y.LINK_RECOMMENDATION="link_recommendation",y.PERSONAL_COLLECTION="personal-collection",y.PERSONAL_COLLECTION_SEARCH="personal-collection-search",y.SEARCH_OVERLAY="search-overlay",y.SEARCH_PREVIEW="search-preview",y.SEARCH_URL="search-url",y.STYLE="style",y))(Xe||{}),$t=(i=>(i.ENTER="enter",i.TAB="tab",i.ARROW="arrow",i.HOTKEY="hotkey",i.MOUSE="mouse",i.SPACE="space",i))($t||{});var Q=require("react"),or=require("react-redux");var At=require("@reduxjs/toolkit");var ro=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(ro||{});var xm={isLoggedIn:null,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1,loginError:null},re=t=>t.auth.isLoggedIn;var bl=t=>t.auth.verifyFetchState,Cl=t=>t.auth.showLoginOverlay,wl=t=>t.auth.loginError,dt=(0,At.createAsyncThunk)("auth/validate",(t,e)=>S(null,null,function*(){return e.extra.deepdeskAPI.isLoggedIn()})),Tl=(0,At.createAsyncThunk)("auth/requestLogin",(n,o)=>S(null,[n,o],function*({email:t},e){let{deepdeskAPI:s}=e.extra;return s.requestLoginByEmail(t)})),fi=(0,At.createAsyncThunk)("auth/loginWithPassword",(o,s)=>S(null,[o,s],function*({username:t,password:e},n){let{deepdeskAPI:r}=n.extra;return r.loginWithPassword(t,e)})),Ss=(0,At.createAsyncThunk)("auth/logout",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n}=e.extra;yield n.logout()})),io=(0,At.createAsyncThunk)("auth/verifyLoginToken",(n,o)=>S(null,[n,o],function*({token:t},e){let{deepdeskAPI:s}=e.extra;return s.verifyLoginToken(t)})),El=(0,At.createSlice)({name:"auth",initialState:xm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload},setLoginError(t,e){t.loginError=e.payload},clearLoginError(t){t.loginError=null}},extraReducers:t=>{t.addCase(dt.pending,e=>{e.loginFetchState="loading"}),t.addCase(dt.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(dt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(fi.pending,e=>{e.loginFetchState="loading",e.loginError=null}),t.addCase(fi.fulfilled,e=>{e.isLoggedIn=!0,e.loginFetchState="done",e.loginError=null,e.showLoginOverlay=!1}),t.addCase(fi.rejected,(e,n)=>{e.loginFetchState="error",e.isLoggedIn=!1,e.loginError=n.error.message==="Bad Request"?"Invalid credentials":"Login failed"}),t.addCase(Ss.fulfilled,e=>{e.isLoggedIn=!1,e.loginFetchState="idle",e.loginError=null}),t.addCase(Ss.rejected,e=>{e.isLoggedIn=!1,e.loginFetchState="error"}),t.addCase(io.pending,e=>{e.verifyFetchState="loading"}),t.addCase(io.rejected,e=>{e.verifyFetchState="error"}),t.addCase(io.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Pn,setShowLoginOverlay:kl,setLoginError:hi,clearLoginError:xs}=El.actions,Rl=El.reducer;var Qt=require("@reduxjs/toolkit"),Dl=require("diff");function Pl(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Lt(t,e,n=10){let o=typeof t,s=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==s?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>Lt(r,e[i],n-1)):Pl(t)&&Pl(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Lt(t[i],e[i],n-1)):!1}function bm(t){return Math.max(...t.map(e=>e.length))}function Cm(t,e){let n=t.reduce((o,s)=>{if(s){let r=o[s]?o[s]+1:1;return b(h({},o),{[s]:r})}return o},{});return Object.keys(n).reduce((o,s)=>(n[s]<e&&o.push(s),o),[])}function Il(t,e){let o=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<bm(o);s++){let r=Cm(o.map(a=>a[s]),e),i=o.filter(a=>!r.includes(a[s]));if(i.length>=e)o=i;else return{text:o[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var wm=2;function Al(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=Il(t,wm);return n&&n.text!==e?n:t[0]}var Be=require("@reduxjs/toolkit");var Tm={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},P=Tm;var yi="deepdesk.widgetAssistantSession";function ao(t){if(!t||typeof sessionStorage=="undefined")return null;try{return sessionStorage.getItem(`${yi}:${t}`)}catch(e){return null}}function Ll(t,e){if(!(!t||typeof sessionStorage=="undefined"))try{sessionStorage.setItem(`${yi}:${t}`,e)}catch(n){}}function Ml(t){if(!(!t||typeof sessionStorage=="undefined"))try{sessionStorage.removeItem(`${yi}:${t}`)}catch(e){return}}var Nl={current:null,isSupported:null},q=(0,Be.createAction)("resetConversation"),bs=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.externalId)||null},Pe=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},In=t=>t.conversation.isSupported,vi=(0,Be.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),Cs=(0,Be.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),ws=(0,Be.createAsyncThunk)("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),Ts=(0,Be.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Pe(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),Si=(0,Be.createAsyncThunk)("conversation/upsert",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.upsertConversation(t)}),xi=(0,Be.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Pe(e.getState());if(!o){P.warn("No current conversation to update messages");return}return n.postMessages(o,t.map(s=>h({},s)))}),Em=[Cs.rejected,ws.rejected,Ts.rejected,xi.rejected].map(t=>t==null?void 0:t.toString());function km(t){return Em.includes(t.type)}var Rm=(0,Be.createSlice)({name:"conversation",initialState:Nl,reducers:{},extraReducers:t=>{t.addCase(vi.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(Cs.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(ws.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Si.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Ts.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(q,e=>{var n,o;return Ml((o=(n=e.current)==null?void 0:n.externalId)!=null?o:void 0),Nl}).addMatcher(km,(e,n)=>{var o;throw P.info("Conversation action rejected",n.type,((o=n.error)==null?void 0:o.message)||"No message"),new Error(n.error.message)})}}),Ol=Rm.reducer;var Gt={text:"",html:null,suggestionTextStart:0,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],pinnedSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function bi(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}}var Es=(0,Qt.createAction)("input/applyImageSuggestion"),_l=(0,Qt.createSlice)({name:"input",initialState:Gt,reducers:{setInput(t,e){var i,a;let{beforeInputChange:n}=t,{text:o,html:s,suggestionTextStart:r}=e.payload;if(t.text=o,t.html=s!=null?s:null,t.suggestionTextStart=o===""?0:Math.max(0,r!=null?r:0),o==="")t.metrics=Gt.metrics,t.textSuggestions=[],t.mixedSuggestion=null;else if(n!==null&&t.text!==n.text){let{key:c,shiftKey:l,ctrlKey:d,metaKey:p,altKey:u}=n.keyDown;switch(c){case"Enter":l&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:m}=t,f=(0,Dl.diffChars)(n.text,m);n.text.length-m.length>1&&t.metrics.deletions.push(...f.filter(g=>g.removed).map(g=>g.value)),t.metrics.numCharsDeleted+=n.text.length-m.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(d||p)break;default:if(!d&&!p&&!u){t.metrics.numCharsTyped+=1;let m=((i=n.selection)==null?void 0:i.start)!==void 0&&((a=n.selection)==null?void 0:a.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;m&&m.length>0&&(t.metrics.numCharsDeleted+=m.length,t.metrics.deletions.push(m))}}t.metrics.agentStartedTypingTimestamp||(t.metrics.agentStartedTypingTimestamp=Date.now())}t.beforeInputChange=null},sendMessage(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(n=>!t.metrics.textSuggestions.some(o=>o.text===n.text&&o.source===n.source))},setSelection(t,e){e.payload!==null&&(Lt(t.selection,e.payload)||(t.selection=e.payload))},commitSuggestion(t,e){let n=e.payload,{text:o,suggestion:{source:s,abVariant:r,abTestName:i,trainingJobs:a,sourceText:c,searchTerm:l,assistantCode:d,text:p},eventMetrics:{inputType:u},replace:m}=n,f=s==="search"||s==="personal-collection-search",g=o.slice(t.text.substring(0,t.selection.start).length);(f||m==="selection")&&(g=o),n.suggestion.source==="search-overlay"&&(g=p),t.metrics.textSuggestions.push({text:g,source:s,assistantCode:d,abVariant:r,abTestName:i,inputType:u,sourceText:c,trainingJobs:a||[],searchTerm:f?t.text:l}),t.textSuggestions=[],t.selectedSuggestionIndex=-1},offeredTextSuggestion(t,e){let{text:n,suggestion:{source:o}}=e.payload;t.metrics.offeredTextSuggestions.find(r=>r.text===n)||t.metrics.offeredTextSuggestions.push({text:n,source:o})},registerKeyDown(t,e){let{key:n}=e.payload;["Control","Meta","Shift","Alt"].includes(n)||(t.beforeInputChange={text:t.text,selection:t.selection,keyDown:e.payload})},registerKeyUp(t,e){},registerCut(t,e){let{metrics:n}=t,o=e.payload;t.metrics=b(h({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:s}=e.payload,r=n.numCharsDeleted+(s!=null&&s.length?s.length:0),i=s!=null&&s.length?[...n.deletions,s]:n.deletions;t.metrics=b(h({},t.metrics),{numCharsDeleted:r,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},selectPreviousTextSuggestion(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},selectTextSuggestionByIndex(t,e){t.selectedSuggestionIndex=e.payload},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0){t.mixedSuggestion=null;return}let n=Xt({input:t}),o=Al(e.payload,n);t.mixedSuggestion=o!=null&&o.text.includes(n)?o:null},setPinnedSuggestions(t,e){t.pinnedSuggestions=e.payload},removePinnedSuggestions(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(o=>o.source!==e.payload.source||e.payload.assistantCode&&o.assistantCode!==e.payload.assistantCode?!0:e.payload.text?o.text!==e.payload.text:!1);let n=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex>n-1&&(t.selectedSuggestionIndex=-1)},setMetrics(t,{payload:e}){t.metrics=e},resetMetrics(t){t.metrics=Gt.metrics}},extraReducers:t=>{t.addCase(q,e=>{e.mixedSuggestion=Gt.mixedSuggestion,e.textSuggestions=Gt.textSuggestions,e.selectedSuggestionIndex=Gt.selectedSuggestionIndex,e.metrics=Gt.metrics})}}),Xt=t=>{let{text:e,selection:n,suggestionTextStart:o}=t.input;return e.slice(o,n.end)},Pm=t=>t.input.mixedSuggestion,Im=t=>t.input.pinnedSuggestions,Am=t=>t.input.textSuggestions,lo=t=>t.input.selectedSuggestionIndex,Jt=(0,Qt.createSelector)([Am,Im],(t,e)=>[...t,...e]),An=(0,Qt.createSelector)([Jt,Pm,lo],(t,e,n)=>n>-1?t[n]:e),Fl=t=>t.input.selection,{commitSuggestion:be,offeredTextSuggestion:Hl,registerCut:Bl,registerKeyDown:Ul,registerKeyUp:Kl,registerPaste:Wl,selectNextTextSuggestion:zl,selectPreviousTextSuggestion:Vl,selectTextSuggestionByIndex:ks,setInput:Rs,setMetrics:jl,setPinnedSuggestions:Ln,removePinnedSuggestions:Zt,setSelection:Ps,setTextSuggestions:Mt,resetMetrics:ql,sendMessage:Yt}=_l.actions,$l=_l.reducer;var Nn=require("@reduxjs/toolkit");var en=require("@reduxjs/toolkit");function Gl(t){try{return Intl.DateTimeFormat(void 0,{timeZone:t}),!0}catch(e){return!1}}var Lm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle",showNicknameDialog:!1},Mn=t=>{var e;return(e=t.info.agentInfo)!=null?e:null},Ql=t=>{var e;return(e=t.info.visitorInfo)!=null?e:null},Xl=t=>{var e;return(e=t.info.customData)!=null?e:null},uo=({info:{visitorInfo:t,agentInfo:e}})=>{var n,o;return{timezone:t!=null&&t.visitorTimeZone&&Gl(t.visitorTimeZone)?t.visitorTimeZone:xl,agentName:(n=e==null?void 0:e.agentNickname)!=null?n:"",visitorName:(o=t==null?void 0:t.visitorName)!=null?o:""}},Mm=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],Jl=(0,en.createAsyncThunk)("info/setAgentNickname",(n,o)=>S(null,[n,o],function*({agentNickname:t},e){var i;let{deepdeskAPI:s}=e.extra,r=yield s.patchMe({nickname:t});return{agentNickname:(i=r==null?void 0:r.nickname)!=null?i:t}})),co=(0,en.createAsyncThunk)("info/setAgentInfo",(t,e)=>S(null,null,function*(){var r,i,a;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=[];if(t.agentId&&t.skipSync!==!0&&s.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let c=Mm.reduce((l,[d,p])=>!o[p]&&d in t?b(h({},l),{[p]:t[d]}):l,{});Object.keys(c).length>0&&s.push(n.patchMe(c).then(l=>o=l))}return s.length>0&&(yield Promise.all(s)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(r=o.nickname)!=null?r:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(a=o.defaultLocale)!=null?a:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),Ci=(0,en.createAsyncThunk)("info/setAgentSettings",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),s=h(h({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:s}),s})),wi=(0,en.createAsyncThunk)("info/getAgentSettings",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),Zl=(0,en.createSlice)({name:"info",initialState:Lm,reducers:{setVisitorInfo(t,e){t.visitorInfo=h(h({},t.visitorInfo),e.payload)},setCustomData(t,e){t.customData=e.payload},setPlatformVariables(t,e){t.platformVariables=e.payload},setShowNicknameDialog(t,e){t.showNicknameDialog=e.payload}},extraReducers:t=>{t.addCase(co.pending,(e,n)=>{e.fetchState="loading",e.agentInfo=h(h({},e.agentInfo),n.meta.arg)}).addCase(co.rejected,e=>{e.fetchState="error"}).addCase(co.fulfilled,(e,n)=>{e.fetchState="done",e.agentInfo=n.payload}).addCase(Ci.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(wi.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(q,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Yl,setCustomData:ed,setPlatformVariables:td,setShowNicknameDialog:nd}=Zl.actions,od=Zl.reducer;function Ue(t,e){return e?t==null?(P.warn("replaceVars called with non-string text; upstream contract violation",{keys:Object.keys(e)}),t):Object.entries(e).reduce((n,[o,s])=>n.replaceAll(o,s),t):t}var Is={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},sd=t=>t.search.isOpen,rd=t=>t.search.page,Ti=t=>t.search.list,id=t=>t.search.aggregates,Nm=(0,Nn.createSelector)([Ti,(t,e)=>e],(t,e)=>t.filter(n=>n.type===e)),ad=t=>e=>Nm(e,t),tn=(0,Nn.createAsyncThunk)("search/getAll",(t,e)=>S(null,null,function*(){var c;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(c=o.conversation.current)==null?void 0:c.profileCode,{platformVariables:r}=o.info;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:uo(o)});return{results:i.map(l=>b(h(h({},l),l.title&&r?{title:Ue(l.title,r)}:{}),{text:Ue(l.text,r!=null?r:{}),source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:a}})),ld=(0,Nn.createSlice)({name:"search",initialState:Is,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=Is.fetchState,t.list=Is.list}},extraReducers:t=>{t.addCase(tn.pending,e=>{e.fetchState="loading"}).addCase(tn.rejected,(e,n)=>{e.fetchState="error",P.error(n.error)}).addCase(tn.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload.results,e.aggregates=n.payload.aggregates||{}}).addCase(q,()=>Is)}}),{resetSearch:As,setIsOpen:Ke,setPage:On}=ld.actions,dd=ld.reducer;var Ei="SetOutputs",Dn="ShowLoginOverlay",po="UserLoggedIn",Om="UserLoggedOut",ct="ApplySuggestion",ki="ApplyImageSuggestion",Dm="ShowCommandPalette",Ls="ShowNicknameDialog",Ms="ReduxAction",_m="RemovePinnedSuggestion",Fm=t=>({[Ei]:e=>{var s,r;let n=(s=t.getState().conversation.current)==null?void 0:s.externalId,o=(r=e==null?void 0:e.payload)==null?void 0:r.externalConversationId;o&&o!==n||t.dispatch(b(h({},e),{isBroadcasted:!0}))},[Ms]:e=>{e.isBroadcasted||t.dispatch(b(h({},e),{isBroadcasted:!0}))},[_m]:e=>{t.dispatch(Zt(e))},[Dm]:e=>{t.dispatch(Ke(e.isOpen)),e.page&&t.dispatch(On(e.page))},[Ls]:e=>{t.dispatch(nd(e.showNicknameDialog))},[Dn]:e=>{t.dispatch(kl(e))},[po]:()=>{t.dispatch(dt())},[Om]:()=>{t.dispatch(dt())},[ki]:e=>{t.dispatch(Es({suggestion:e.suggestion}))},[ct]:e=>{t.dispatch(be(b(h({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),cd=Fm;var pd=require("react-redux");var ud=require("@reduxjs/toolkit");function Ns(t){return(0,ud.createAsyncThunk)("analytics/logEvent",(e,n)=>{var r,i,a;let o=(i=(r=n.getState())==null?void 0:r.conversation.current)==null?void 0:i.id,s=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,b(h({conversationId:o},s),{data:e.data}))})(t)}function J(){let t=(0,pd.useDispatch)();return(e,n)=>S(null,null,function*(){yield t(Ns({name:e,data:n}))})}var _n=require("react"),gd=require("react-redux");function go(t,e){let n=(0,_n.useRef)(t);n.current=t;let[o,s]=(0,_n.useState)(void 0),[r,i]=(0,_n.useState)(void 0),[a,c]=(0,_n.useState)("idle"),l=(0,gd.useDispatch)();return{error:r,state:a,data:o,call:u=>S(null,null,function*(){c("loading"),yield l(n.current(u)).unwrap().then(m=>{s(m),c("done"),e!=null&&e.onSuccess&&(e==null||e.onSuccess(m))}).catch(m=>{i(m),c("error"),e!=null&&e.onError&&(e==null||e.onError(m))})}),reset:()=>{c("idle"),s(void 0),i(void 0)}}}var mo=_(require("react")),fd=require("react/jsx-runtime"),md=mo.default.createContext(null),ut=({broadcastEvents:t,children:e})=>{let n=mo.default.useMemo(()=>t,[]);return(0,fd.jsx)(md.Provider,{value:n,children:e})},ve=()=>{let t=(0,mo.useContext)(md);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var Ks=require("react");var Ri=function(t,e){return Ri=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},Ri(t,e)};function fo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ri(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var Ce=function(){return Ce=Object.assign||function(e){for(var n,o=1,s=arguments.length;o<s;o++){n=arguments[o];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ce.apply(this,arguments)};function hd(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(n[o[s]]=t[o[s]]);return n}function Os(t,e,n){if(n||arguments.length===2)for(var o=0,s=e.length,r;o<s;o++)(r||!(o in e))&&(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}function Ds(t,e){var n=e&&e.cache?e.cache:Vm,o=e&&e.serializer?e.serializer:Wm,s=e&&e.strategy?e.strategy:Bm;return s(t,{cache:n,serializer:o})}function Hm(t){return t==null||typeof t=="number"||typeof t=="boolean"}function yd(t,e,n,o){var s=Hm(o)?o:n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.call(this,o),e.set(s,r)),r}function vd(t,e,n){var o=Array.prototype.slice.call(arguments,3),s=n(o),r=e.get(s);return typeof r=="undefined"&&(r=t.apply(this,o),e.set(s,r)),r}function Pi(t,e,n,o,s){return n.bind(e,t,o,s)}function Bm(t,e){var n=t.length===1?yd:vd;return Pi(t,this,n,e.cache.create(),e.serializer)}function Um(t,e){return Pi(t,this,vd,e.cache.create(),e.serializer)}function Km(t,e){return Pi(t,this,yd,e.cache.create(),e.serializer)}var Wm=function(){return JSON.stringify(arguments)},zm=(function(){function t(){this.cache=Object.create(null)}return t.prototype.get=function(e){return this.cache[e]},t.prototype.set=function(e,n){this.cache[e]=n},t})(),Vm={create:function(){return new zm}},_s={variadic:Um,monadic:Km};var Fs;(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"})(Fs||(Fs={}));var Hs=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Ie;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(Ie||(Ie={}));var Bs;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Bs||(Bs={}));function Ii(t){return t.type===Ie.literal}function Ai(t){return t.type===Ie.argument}function ho(t){return t.type===Ie.number}function yo(t){return t.type===Ie.date}function vo(t){return t.type===Ie.time}function So(t){return t.type===Ie.select}function xo(t){return t.type===Ie.plural}function Sd(t){return t.type===Ie.pound}function bo(t){return t.type===Ie.tag}function Us(t){return!!(t&&typeof t=="object"&&t.type===Bs.number)}function Co(t){return!!(t&&typeof t=="object"&&t.type===Bs.dateTime)}function Li(t){t.forEach(function(e){if(delete e.location,So(e)||xo(e))for(var n in e.options)delete e.options[n].location,Li(e.options[n].value);else ho(e)&&Us(e.style)||(yo(e)||vo(e))&&Co(e.style)?delete e.style.location:bo(e)&&Li(e.children)})}function xd(t,e){e===void 0&&(e={}),e=Ce({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new Hs(t,e).parse();if(n.err){var o=SyntaxError(Fs[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||Li(n.val),n.val}var nn;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(nn||(nn={}));var wo=(function(t){fo(e,t);function e(n,o,s){var r=t.call(this,n)||this;return r.code=o,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e})(Error);var Mi=(function(t){fo(e,t);function e(n,o,s,r){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(s).join('", "'),'"'),nn.INVALID_VALUE,r)||this}return e})(wo);var bd=(function(t){fo(e,t);function e(n,o,s){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),nn.INVALID_VALUE,s)||this}return e})(wo);var Cd=(function(t){fo(e,t);function e(n,o){return t.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(o,'"'),nn.MISSING_VALUE,o)||this}return e})(wo);var de;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(de||(de={}));function jm(t){return t.length<2?t:t.reduce(function(e,n){var o=e[e.length-1];return!o||o.type!==de.literal||n.type!==de.literal?e.push(n):o.value+=n.value,e},[])}function qm(t){return typeof t=="function"}function To(t,e,n,o,s,r,i){if(t.length===1&&Ii(t[0]))return[{type:de.literal,value:t[0].value}];for(var a=[],c=0,l=t;c<l.length;c++){var d=l[c];if(Ii(d)){a.push({type:de.literal,value:d.value});continue}if(Sd(d)){typeof r=="number"&&a.push({type:de.literal,value:n.getNumberFormat(e).format(r)});continue}var p=d.value;if(!(s&&p in s))throw new Cd(p,i);var u=s[p];if(Ai(d)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?de.literal:de.object,value:u});continue}if(yo(d)){var m=typeof d.style=="string"?o.date[d.style]:Co(d.style)?d.style.parsedOptions:void 0;a.push({type:de.literal,value:n.getDateTimeFormat(e,m).format(u)});continue}if(vo(d)){var m=typeof d.style=="string"?o.time[d.style]:Co(d.style)?d.style.parsedOptions:o.time.medium;a.push({type:de.literal,value:n.getDateTimeFormat(e,m).format(u)});continue}if(ho(d)){var m=typeof d.style=="string"?o.number[d.style]:Us(d.style)?d.style.parsedOptions:void 0;m&&m.scale&&(u=u*(m.scale||1)),a.push({type:de.literal,value:n.getNumberFormat(e,m).format(u)});continue}if(bo(d)){var f=d.children,g=d.value,y=s[g];if(!qm(y))throw new bd(g,"function",i);var v=To(f,e,n,o,s,r),x=y(v.map(function(k){return k.value}));Array.isArray(x)||(x=[x]),a.push.apply(a,x.map(function(k){return{type:typeof k=="string"?de.literal:de.object,value:k}}))}if(So(d)){var w=d.options[u]||d.options.other;if(!w)throw new Mi(d.value,u,Object.keys(d.options),i);a.push.apply(a,To(w.value,e,n,o,s));continue}if(xo(d)){var w=d.options["=".concat(u)];if(!w){if(!Intl.PluralRules)throw new wo(`Intl.PluralRules is not available in this environment.
|
|
2
2
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
3
|
-
`,nn.MISSING_INTL_API,i);var T=n.getPluralRules(e,{type:d.pluralType}).select(u-(d.offset||0));w=d.options[T]||d.options.other}if(!w)throw new Mi(d.value,u,Object.keys(d.options),i);a.push.apply(a,
|
|
4
|
-
`):""}var Nd=(0,Lt.createSlice)({name:"assistants",initialState:kd,reducers:{resetCues(t){t.cues=[]},setActiveAssistantCode(t,e){t.activeAssistantCode=e.payload},setWidgetAssistantSessionId(t,e){t.widgetAssistantSessionId=e.payload},registerAssistantThreadId(t,e){let{assistantCode:n,threadId:o}=e.payload;t.assistantThreads[n]={threadId:o},o>=t.nextLocalThreadId&&(t.nextLocalThreadId=o+1)},resetAssistantThread(t,e){let n=t.assistantThreads[e.payload.assistantCode];n&&(delete t.threads[n.threadId],delete t.assistantThreads[e.payload.assistantCode])},removeCueByCode(t,e){t.cues=t.cues.filter(n=>n.code!==e.payload.code)},removeThreadById(t,e){delete t.threads[e.payload]},receiveChunk(t,e){let{code:n,name:o,payload:s,evaluationId:r}=e.payload,i=t.cues.findIndex(a=>a.code===n);i!==-1?t.cues[i].response+=s.text:t.cues.push({code:n,name:o,evaluationId:r,response:s.text})},userNotification(t,e){let n=t.cues.find(d=>d.code===e.payload.code),o=t.cues.filter(d=>d.code!==e.payload.code),{code:s,name:r,evaluationId:i,payload:a}=e.payload,{callToAction:c}=a,l=a.sources!==void 0?a.sources.filter(d=>!!d.url):n==null?void 0:n.sources;t.cues=[...o,b(h({code:s,name:r,evaluationId:i,response:a.message,editable:a.editableMessage},l!=null&&l.length?{sources:l}:{}),{callToAction:c&&{label:c.displayName,event:c.onClickEvent,value:c.eventPayload}})]}},extraReducers:t=>{t.addCase(be.pending,(e,n)=>{e.pending.includes(n.meta.arg.assistantCode)&&P.warn(`Assistant ${n.meta.arg.assistantCode} already evaluating`),e.pending.push(n.meta.arg.assistantCode)}).addCase(be.rejected,(e,n)=>{var s;P.warn((s=n.error)==null?void 0:s.message);let o=e.pending.indexOf(n.meta.arg.assistantCode);o!==-1&&e.pending.splice(o,1)}).addCase(be.fulfilled,(e,n)=>{let o=e.pending.indexOf(n.meta.arg.assistantCode);if(o!==-1&&e.pending.splice(o,1),n.meta.arg.skipState)return;let{evaluationId:s,output:r,externalConversationId:i,currentExternalIdAtRequest:a}=n.payload;if(i&&a&&i!==a)return;let c=r.map(p=>p.code),l=e.cues.filter(p=>!c.includes(p.code)),d=r.map(p=>h(b(h({},p),{evaluationId:s}),i?{externalConversationId:i}:{}));e.cues=[...l,...d]}).addCase(wo.fulfilled,(e,n)=>{let a=n.payload,{threadId:o,externalConversationId:s,currentExternalIdAtRequest:r}=a,i=D(a,["threadId","externalConversationId","currentExternalIdAtRequest"]);s&&r&&s!==r||(e.threads[o]=[...e.threads[o]||[],i])}).addCase(j,()=>kd)}}),{removeCueByCode:Vs,resetCues:Fb,removeThreadById:Od,receiveChunk:Dd,userNotification:_d,setActiveAssistantCode:Hi,setWidgetAssistantSessionId:Bi,registerAssistantThreadId:Ui,resetAssistantThread:Fd}=Nd.actions,Hd=Nd.reducer;var Bd=require("@reduxjs/toolkit"),Ud=require("react-redux");var Jm={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,signInViaPopup:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showStyleSuggestionList:!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,addToPersonalCollection:!1,inlineSuggestions:!1,autoSelectSuggestion:!1,suggestionsPlacement:"above",floatingMenu:!1,detectSubmit:!1,automaticHandlingTime:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!0,adminUrl:void 0,productName:"Deepdesk",hasKeyboardInput:!0},Ki={showSearch:!1,showImageSearch:!1,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,recommendTextSuggestions:!0},Kd=(0,Bd.createSlice)({name:"settings",initialState:Jm,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,s]=n;typeof s!="undefined"&&(t[o]=s)})}},extraReducers:t=>{t.addCase(j,e=>{Object.assign(e,Ki)})}}),{set:To}=Kd.actions,on=t=>e=>e.settings[t],R=t=>(0,Ud.useSelector)(on(t)),Wd=Kd.reducer;function Xe(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 Eo=F(require("classnames")),Jd=require("react");var Wi=require("react/jsx-runtime"),js=t=>(0,Wi.jsx)("svg",b(h({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Wi.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 zi=require("react/jsx-runtime"),zd=t=>(0,zi.jsx)("svg",b(h({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,zi.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 Mt(t,e){var s;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(r=>{n.classList.add(r)}),n.addEventListener("animationend",()=>n.remove()),(s=t.parentElement)==null||s.appendChild(n)}var Vi={};ee(Vi,{enUS:()=>Zm,nlNL:()=>Ym});var Zm={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},Ym={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Vd={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};var jd=({conversationId:t,evaluationId:e,type:n,assistantCode:o,contentType:s},r,i)=>{let a=new URLSearchParams;return t!=null&&a.set("conversationId",String(t)),e&&a.set("evaluationId",e),a.set("type",n),o&&a.set("assistantCode",o),a.set(s,r),i!==void 0&&a.set("data",i),`/admin/feedback?${a.toString()}`},qs=t=>{let e=t.content,n=jd(t,e,t.data),o=encodeURIComponent(n).length;for(;o>3e3&&e.length>0;){let s=Math.max(0,Math.floor(e.length*3e3/o)-1);e=t.content.slice(0,s),n=jd(t,e?`${e}\u2026`:"",t.data),o=encodeURIComponent(n).length}return n};var Xd=require("react-redux");var $s=require("react"),Qd=require("react/jsx-runtime"),qd=(0,$s.createContext)(null),$d=({handler:t,children:e})=>(0,Qd.jsx)(qd.Provider,{value:t!=null?t:null,children:e}),Gd=()=>(0,$s.useContext)(qd);var _n=t=>e=>{let{passwordlessToken:{token:n},settings:{isEmbedded:o,adminUrl:s}}=e,r=s||window.location.origin;return o&&!n?null:o&&n?`${r}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${r}${t}`};function Gs(t){let e=R("enableFeedbackForm"),n=Gd(),o=(0,Xd.useSelector)(_n(t));return e?n?{mode:"custom-handler",open:()=>n(t)}:o?{mode:"passwordless-link",href:o}:{mode:"disabled"}:{mode:"disabled"}}var Zd=require("react-redux");var Ke=require("react/jsx-runtime"),ef=({assistantCode:t,assistantOutput:e,evaluationId:n,feedbackType:o})=>{let s=C("FeedbackThumbs",Vd),r=(0,Zd.useSelector)(Re),i=qs({conversationId:r,evaluationId:n,type:o,assistantCode:t,contentType:"assistantOutput",content:e}),a=Gs(i),c=A(Vi),l=X(),[d,p]=(0,Jd.useState)(null),u=g=>{l("Assistant response feedback",{assistantCode:t,assistantOutput:e,evaluationId:n,rating:g})},m=g=>{g.stopPropagation(),Mt(g.target,s.fadeup),p("up"),u("up")},f=g=>S(null,null,function*(){g.stopPropagation(),Mt(g.target,s.fadedown),p("down"),u("down"),a.mode==="custom-handler"&&(yield a.open())});return(0,Ke.jsxs)("div",{className:s.thumbs,children:[(0,Ke.jsx)(M.Button,{title:c("thumbsUp"),onClick:m,icon:(0,Ke.jsx)(zd,{}),className:(0,Eo.default)(s.thumbsUp,d==="up"&&s.selected),disabled:!!d}),a.mode==="custom-handler"?(0,Ke.jsx)(M.Button,{title:c("thumbsDown"),onClick:f,icon:(0,Ke.jsx)(js,{}),className:(0,Eo.default)(s.thumbsDown,d==="down"&&s.selected),disabled:!!d}):a.mode==="passwordless-link"?(0,Ke.jsx)(M.Button,{as:"a",title:c("thumbsDown"),href:a.href,target:"_blank",rel:"noreferrer",onClick:f,icon:(0,Ke.jsx)(js,{}),className:(0,Eo.default)(s.thumbsDown,d==="down"&&s.selected),disabled:!!d}):(0,Ke.jsx)(M.Button,{title:c("thumbsDown"),onClick:f,icon:(0,Ke.jsx)(js,{}),className:(0,Eo.default)(s.thumbsDown,d==="down"&&s.selected),disabled:!!d})]})},Qs=ef;var pc=F(require("dompurify")),gc=require("marked"),pt=require("react");var oc=require("react");var W=require("@floating-ui/react"),Je=F(require("react"));var Xs={tooltip:"dd-XpCXd",tooltipTrigger:"dd-8TKeF",arrow:"dd-ZEu2Y"};var Ie=require("react/jsx-runtime");function tf({initialOpen:t=!1,placement:e="bottom",modal:n,tooltip:o,open:s,onOpenChange:r}={}){let[i,a]=Je.useState(t),c=s!=null?s:i,l=r!=null?r:a,d=(0,W.useFloating)({placement:e,open:c,onOpenChange:l,whileElementsMounted:W.autoUpdate,middleware:[(0,W.offset)(5),(0,W.flip)({crossAxis:e.includes("-"),fallbackAxisSideDirection:"end",padding:5}),(0,W.shift)({padding:10})]}),p=d.context,u=(0,W.useClick)(p,{enabled:s==null}),m=(0,W.useDismiss)(p),f=(0,W.useRole)(p),g=(0,W.useHover)(p,{enabled:o!=null?o:!1,handleClose:(0,W.safePolygon)()}),y=(0,W.useInteractions)([u,m,f,g]);return Je.useMemo(()=>b(h(h({open:c,setOpen:l},y),d),{modal:n,tooltip:o}),[c,l,y,d,n,o])}var Yd=Je.createContext(null),ji=()=>{let t=Je.useContext(Yd);if(t==null)throw new Error("Popover components must be wrapped in <Popover />");return t},sn=o=>{var s=o,{children:t,modal:e=!1}=s,n=D(s,["children","modal"]);let r=tf(h({modal:e},n));return(0,Ie.jsx)(Yd.Provider,{value:r,children:t})};function nf(o){var s=o,{as:t,children:e}=s,n=D(s,["as","children"]);let r=ji(),i=t||"button",a=e.ref,c=(0,W.useMergeRefs)([r.refs.setReference,a]);return(0,Ie.jsx)(i,b(h(h({ref:c},i==="button"||t===void 0||t==="button"?{type:"button"}:{}),r.getReferenceProps(n)),{children:e}))}var of=Je.forwardRef(function(s,o){var r=s,{style:e}=r,n=D(r,["style"]);var d;let l=ji(),{context:i}=l,a=D(l,["context"]),c=(0,W.useMergeRefs)([a.refs.setFloating,o]);return i.open?(0,Ie.jsx)(W.FloatingPortal,{children:(0,Ie.jsx)(W.FloatingFocusManager,{context:i,modal:a.modal,disabled:(d=n.disableFocusManager)!=null?d:a.tooltip,children:(0,Ie.jsx)("div",b(h({ref:c,style:h(b(h({},a.floatingStyles),{zIndex:1e7}),e)},a.getFloatingProps(n)),{children:n.children}))})}):null});function sf(s){var r=s,{as:t,children:e,onClick:n}=r,o=D(r,["as","children","onClick"]);let{setOpen:i}=ji();return(0,Ie.jsx)(t||"button",b(h({type:"button",onClick:l=>{n(l),i(!1),l.stopPropagation()}},o),{children:e}))}function ec({trigger:t,children:e,placement:n="top"}){return(0,Ie.jsxs)(sn,{tooltip:!0,placement:n,children:[(0,Ie.jsxs)(sn.Content,{className:Xs.tooltip,children:[e,(0,Ie.jsx)("div",{className:Xs.arrow})]}),(0,Ie.jsx)(sn.Trigger,{className:Xs.tooltipTrigger,children:t})]})}sn.Trigger=nf;sn.Content=of;sn.Button=sf;var q=sn;var qi={};ee(qi,{enUS:()=>rf,nlNL:()=>af});var rf={showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}],showLess:[{type:0,value:"Show less"}]},af={showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}],showLess:[{type:0,value:"Toon minder"}]};var tc={sources:"dd-cNsGl",source:"dd-LoJ6U",tooltip:"dd-7ZGu9",linkContent:"dd-O2IoN",showMoreSources:"dd-ev8Yr"};var Ze=require("react/jsx-runtime"),nc=3,lf=({sources:t,onClick:e,sourceTestId:n="assistant-source"})=>{let o=A(qi),s=C("AssistantSources",tc),[r,i]=(0,oc.useState)(!1),a=t.filter(d=>!!d.url),c=r?a:a.slice(0,nc),l=a.length>nc;return c.length===0?null:(0,Ze.jsxs)("ul",{className:s.sources,children:[c.map(d=>(0,Ze.jsx)("li",{className:s.source,"data-testid":n,children:(0,Ze.jsxs)(q,{tooltip:!0,placement:"top-start",children:[(0,Ze.jsx)(q.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:d.url,onClick:p=>{p.stopPropagation(),e==null||e(d)},children:(0,Ze.jsx)("span",{className:s.linkContent,children:d.name})}),d.url&&(0,Ze.jsx)(q.Content,{className:s.tooltip,children:decodeURIComponent(d.url)})]})},d.name)),l&&(0,Ze.jsx)("li",{className:s.source,children:(0,Ze.jsx)("button",{type:"button",className:s.showMoreSources,onClick:()=>i(d=>!d),children:r?o("showLess"):o("showMore",{amount:a.length-c.length})})})]})},sc=lf;var Gi=F(require("classnames")),Ae=require("react");var Js=require("react"),df=["bottom","height","left","right","top","width"],cf=(t={},e={})=>df.some(n=>t[n]!==e[n]),ut=new Map,rc,ic=()=>{let t=[],e=[];ut.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let s=o.getBoundingClientRect();cf(s,n.rect)&&(n.rect=s,t.push(n))}),e.forEach(n=>{ut.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),rc=window.requestAnimationFrame(ic)};function uf(t,e){return{observe(){let n=ut.size===0;if(ut.has(t)){let o=ut.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else ut.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&ic()},unobserve(){let n=ut.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||ut.delete(t),ut.size||cancelAnimationFrame(rc)}}}}function $i(t){let[e,n]=(0,Js.useState)(null);return(0,Js.useLayoutEffect)(()=>{if(!t.current)return;let o=uf(t.current,s=>{n(s)});return o.observe(),()=>{o.unobserve()}},[t]),e}var Fn=require("react"),dc=require("react-dom");var ac=require("react");function Nt(t){(0,ac.useEffect)(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function rn(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var lc={root:"dd-r-dgo"};var cc=({children:t,parentNode:e})=>{let[n,o]=(0,Fn.useState)(null),s=(0,Fn.useContext)(so);return(0,Fn.useLayoutEffect)(()=>{let r=document.createElement("div");return rn(r),r.classList.add(lc.root),s!=null&&s.portalRootNode&&r.classList.add(s==null?void 0:s.portalRootNode),(e||document.body).appendChild(r),o(r),()=>{r.isConnected&&r.remove()}},[]),n?(0,dc.createPortal)(t,n):null};var Ye={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};var Zs=require("react/jsx-runtime"),Ys=(t=!1)=>{let[e,n]=(0,Ae.useState)(t),o=(0,Ae.useCallback)(()=>n(!0),[]),s=(0,Ae.useCallback)(()=>n(!1),[]),r=(0,Ae.useCallback)(()=>n(a=>!a),[]),i=(0,Ae.useRef)(null);return{opened:e,open:o,close:s,toggle:r,triggerRef:i}};function Qi(t,e=null,n=0){if(!t)return{display:"none"};let o=e?t.top-e.top<0||t.top<e.top-n?e.top-n:t.top+t.height>e.top+e.height+n?e.top+e.height+n-t.height:t.top:t.top,s=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:s,height:t.height,width:t.width}}var Hn=l=>{var d=l,{className:t,triggerRef:e,boundaryRef:n=(0,Ae.createRef)(),position:o="above",align:s="center",children:r,toStyle:i=Qi,parentNode:a}=d,c=D(d,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let p=$i(e),u=$i(n),m=(0,Ae.useMemo)(()=>i(p,u,0),[p,u]);return(0,Zs.jsx)(cc,{parentNode:a,children:(0,Zs.jsx)("div",b(h({className:(0,Gi.default)(Ye.ref,{[Ye.positionAbove]:o==="above",[Ye.positionBelow]:o==="below",[Ye.positionLeft]:o==="left",[Ye.positionRight]:o==="right",[Ye.alignStart]:s==="start",[Ye.alignCenter]:s==="center",[Ye.alignEnd]:s==="end"}),style:m},c),{role:"dialog",children:(0,Zs.jsx)("div",{className:(0,Gi.default)(t,Ye.root),children:r})}))})};var uc={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};var Le=require("react/jsx-runtime");function pf(t){return`<button type="button" data-copy-icon 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 Xi(t){var n,o;let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(s=>s.remove()),(o=(n=e.textContent)==null?void 0:n.trim())!=null?o:""}function gf(t){return t.replace(/\r\n/g,`
|
|
5
|
-
`)}var mf=({content:t,useLabel:e,copyLabel:n,onCopy:o,onUse:s,sources:r,onSourceClick:i})=>{let a=C("Markdown",uc),c=(0,pt.useRef)(null),[l,d]=(0,pt.useState)(null),p=(0,pt.useMemo)(()=>{let v=gc.marked.parse(gf(t));return pc.default.sanitize(v.toString()).replaceAll("</code>",`${pf(a.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[t]),u=v=>{var T;let x=v.target,w=!!((T=c.current)!=null&&T.querySelector("code"));if(["A","BUTTON"].includes(x.tagName)){d(null);return}l||w&&x.tagName!=="CODE"||!w&&x!==c.current||(x.addEventListener("mouseleave",()=>d(null),{once:!0}),d(x))},m=()=>{if(!l)return;d(null);let v=l.querySelector("button");v&&(Mt(v,a.fadeup),o==null||o(Xi(l)))},f=v=>{let x=v.target,w=x instanceof HTMLElement?x:null;if(x instanceof Element?x.closest("a"):null){v.stopPropagation();return}w&&"copyIcon"in w.dataset&&(Mt(w,a.fadeup),o==null||o(Xi(w.parentElement)))},g=()=>{!l||!s||(d(null),s(Xi(l)))},y=v=>{if(v===null)return;let x=v.getBoundingClientRect();x.left<0?v.style.transform=`translateX(${-x.left+2}px)`:x.right>window.innerWidth&&(v.style.transform=`translateX(${window.innerWidth-x.right-2}px)`)};return(0,Le.jsxs)(pt.Fragment,{children:[l&&(o||s)&&(0,Le.jsxs)(Hn,{triggerRef:{current:l},className:a.popover,parentNode:l,children:[(0,Le.jsxs)("div",{className:a.options,ref:y,children:[o&&(l==null?void 0:l.tagName)==="CODE"&&(0,Le.jsx)("button",{type:"button",className:a.option,onClick:m,children:n}),s&&(0,Le.jsxs)(pt.Fragment,{children:[(0,Le.jsx)("div",{className:a.divider}),(0,Le.jsx)("button",{type:"button",className:a.option,onClick:g,children:e})]})]}),(0,Le.jsx)("div",{className:a.arrow})]}),(0,Le.jsx)("div",{ref:c,"data-testid":"widget-markdown-content",className:a.root,dangerouslySetInnerHTML:{__html:p},onMouseOver:u,onClick:f}),r&&r.length>0&&(0,Le.jsx)(sc,{sources:r,onClick:i})]})},an=mf;var hc=require("react");var mc={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var fc=require("react/jsx-runtime"),ff=({width:t})=>{let e=C("LoadingProgressBar",mc);return(0,fc.jsx)("div",{className:e.loadingBar,style:{width:t}})},er=ff;var gt=require("react/jsx-runtime"),tr=({title:t})=>{let e=(0,hc.useRef)(null);return gs(e),(0,gt.jsx)(M,{ref:e,children:(0,gt.jsx)(B,{children:(0,gt.jsxs)(B.Content,{children:[(0,gt.jsx)(B.Title,{children:t}),(0,gt.jsx)(er,{width:"60%"}),(0,gt.jsx)(er,{width:"90%"}),(0,gt.jsx)(er,{width:"50%"})]})})})};var Bn={};ee(Bn,{enUS:()=>hf,nlNL:()=>yf});var hf={inputPlaceholder:[{type:0,value:"What is your question?"}],useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Submit"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},yf={inputPlaceholder:[{type:0,value:"Wat is je vraag?"}],useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Verzend"}],resetLabel:[{type:0,value:"Gesprek wissen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var nr={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",resetContainer:"dd-qKIDX",sources:"dd-xf9c6",source:"dd-a-vyX",tooltip:"dd-EsgcZ",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};var vc=require("react");var yc={error:"dd-CoAuB"};var Ji={};ee(Ji,{enUS:()=>vf,nlNL:()=>Sf});var vf={errorPrefix:[{type:0,value:"Error:"}]},Sf={errorPrefix:[{type:0,value:"Foutmelding:"}]};var ko=require("react/jsx-runtime"),Sc=({message:t})=>{let e=(0,vc.useRef)(null),n=C("WidgetCardError",yc),o=A(Ji);return gs(e),(0,ko.jsx)(M,{ref:e,children:(0,ko.jsx)(B,{children:(0,ko.jsxs)(B.Content,{className:n.error,children:[o("errorPrefix")," ",t]})})})};var H=require("react/jsx-runtime"),xf=3,bf=({sources:t,onClick:e})=>{let n=A(Bn),o=C("WidgetKnowledgeAssistant",nr),[s,r]=(0,J.useState)(!1),i=s?t:t.slice(0,xf);return i.length===0?null:(0,H.jsxs)("ul",{className:o.sources,children:[i.map(a=>(0,H.jsx)("li",{className:o.source,"data-testid":"knowledge-assist-source",children:(0,H.jsxs)(q,{tooltip:!0,placement:"top-start",children:[(0,H.jsx)(q.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:c=>{c.stopPropagation(),e(a)},children:(0,H.jsx)("span",{className:o.linkContent,children:a.name})}),a.url&&(0,H.jsx)(q.Content,{className:o.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),i<t&&(0,H.jsx)("button",{type:"button",className:o.showMoreSources,onClick:()=>r(!0),children:n("showMore",{amount:t.length-i.length})})]})},Cf=({title:t,description:e})=>(0,H.jsx)(M,{"data-testid":"knowledge-assist-empty-state",children:(0,H.jsx)(B,{children:(0,H.jsxs)(B.Content,{children:[(0,H.jsx)(B.Title,{children:t}),(0,H.jsx)(an,{content:e})]})})}),wf=({innerRef:t,item:e,hasKeyboardInput:n,onCopy:o,onUse:s,onSourceClick:r})=>{var c;let i=A(Bn),a=(0,J.useContext)(sr);return(0,H.jsxs)(M,{"data-testid":"knowledge-assist-answer",ref:t,children:[(0,H.jsx)(B,{children:(0,H.jsxs)(B.Content,{children:[(0,H.jsx)(B.Title,{children:e.question}),(0,H.jsx)(an,{content:e.answer.answer,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:o,onUse:n?s:void 0}),(0,H.jsx)(bf,{sources:(c=e.answer.sources)!=null?c:[],onClick:r})]})}),a.assistantCode&&(0,H.jsxs)(M.ButtonsContainer,{children:[(0,H.jsx)("div",{}),(0,H.jsx)(Qs,{evaluationId:e.evaluationId,feedbackType:"assistant",assistantCode:a.assistantCode,assistantOutput:e.answer.answer})]})]})},sr=(0,J.createContext)(null),rr=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,onInitialQuestionConsumed:o,children:s,threadId:r,onThreadIdChange:i})=>{let[a,c]=(0,J.useState)(null),l=r!==void 0?r:a,d=N=>{i&&i(N),r===void 0&&c(N)},[p,u]=(0,J.useState)(!1),[m,f]=(0,J.useState)(null),[g,y]=(0,J.useState)(!!n),[v,x]=(0,J.useState)(null),w=(0,or.useDispatch)(),T=X(),k=Ns(N=>{if(!t)throw new Error("No knowledge assistant was defined");return f(null),e({assistantCode:t,input:N,threadId:l,onNewThreadId(G){d(G)}})},{onSuccess(N){var G;T("Assistant response displayed",{evaluationId:N.evaluationId,assistantCode:t,assistantOutput:N.answer.answer,input:N.question,sources:(G=N.answer.sources)!=null?G:[]}),y(!1)},onError(N){var G;f((G=N.message)!=null?G:"Unknown error")}}),E=N=>S(null,null,function*(){u(!0),x(N),yield k.call(N),u(!1),x(null)}),I={isEnabled:!!t,assistantCode:t,isSubmitting:p,threadId:l,pendingInput:v,errorMessage:m,onSubmit:E,onReset(){l&&w(Od(l)),t&&w(Fd({assistantCode:t})),f(null),d(null),t&&T("Assistant thread reset",{threadId:l!=null?l:void 0,assistantCode:t})}};return(0,J.useEffect)(()=>{!n||!I.isEnabled||E(n).finally(()=>{o==null||o()})},[n,t,I.isEnabled,o]),(0,H.jsx)(sr.Provider,{value:I,children:s})},ir=()=>{let t=A(Bn),e=C("WidgetKnowledgeAssistant",nr),n=(0,J.useContext)(sr),o=(0,J.useRef)(null),[s,r]=(0,J.useState)(""),i=c=>{r(c.target.value)},a=c=>{c.preventDefault(),n.onSubmit(s).then(()=>{var l;o.current&&((l=o.current)==null||l.focus(),r(""))})};return n.isEnabled?(0,H.jsxs)("form",{className:e.form,onSubmit:a,children:[(0,H.jsx)("input",{ref:o,className:e.formInput,placeholder:t("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:s,onChange:i}),(0,H.jsx)("button",{type:"submit",disabled:n.isSubmitting||s==="",className:e.formSubmit,children:t("submitLabel")})]}):null},ar=({title:t,emptyState:e})=>{var f,g;let n=A(Bn),o=X(),s=C("WidgetKnowledgeAssistant",nr),r=(0,J.useRef)(null),i=(0,J.useContext)(sr),a=(g=(0,or.useSelector)(Pd((f=i.threadId)!=null?f:-1)))!=null?g:[],c=R("hasKeyboardInput"),l=he(),d=(y,v)=>{Xe(y),i.assistantCode&&o("Assistant response copied",{assistantCode:i.assistantCode,assistantOutput:y,copiedText:y,evaluationId:v.evaluationId})},p=(y,v)=>{i.assistantCode&&o("Assistant source clicked",{evaluationId:v.evaluationId,assistantCode:i.assistantCode,source:y})},u=y=>{y.preventDefault(),i.onReset()},m=(y,v)=>{l.send(dt,{text:y,suggestion:{source:"assistant",sourceText:y}}),i.assistantCode&&o("Assistant response used",{assistantCode:i.assistantCode,evaluationId:v.evaluationId,assistantOutput:v.answer.answer,usedText:y})};return!i.isEnabled||(a==null?void 0:a.length)===0&&!i.isSubmitting&&!e&&!i.errorMessage?null:(0,H.jsxs)(J.Fragment,{children:[(0,H.jsx)(Ge,{type:"knowledge",title:t,"data-testid":"knowledge",children:(0,H.jsxs)(se,{withDivider:!0,children:[e&&a.length===0&&!i.pendingInput&&(0,H.jsx)(Cf,h({},e)),a.map((y,v)=>(0,H.jsx)(wf,{innerRef:v===a.length-1?r:void 0,item:y,hasKeyboardInput:c,onCopy:x=>d(x,y),onUse:x=>m(x,y),onSourceClick:x=>p(x,y)},`${y.question}_${y.answer}_${v}`)),i.pendingInput&&(0,H.jsx)(tr,{title:i.pendingInput}),i.errorMessage&&(0,H.jsx)(Sc,{message:i.errorMessage})]})}),a.length>0&&(0,H.jsx)("div",{className:s.resetContainer,children:(0,H.jsx)(M.Button,{disabled:i.threadId===null||i.isSubmitting,onClick:u,children:n("resetLabel")})})]})};var Tt=require("react-dom/client");var wc=F(require("react"));function lr(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}var bc="queueMicrotask error",Tf=1e3,Ef=8e3;function kf(t){return lr(t)&&t.name==="TypeError"&&typeof t.message=="string"&&/queueMicrotask/.test(t.message)}function Rf(){try{return typeof window=="undefined"?"no-window":typeof window.queueMicrotask}catch(t){return"inaccessible"}}function Pf(){try{return typeof globalThis.queueMicrotask}catch(t){return"inaccessible"}}function If(t){return{message:String(t.message).slice(0,Tf),stack:typeof t.stack=="string"?t.stack.slice(0,Ef):null,typeofQueueMicrotask:typeof queueMicrotask,typeofWindowQueueMicrotask:Rf(),typeofGlobalThisQueueMicrotask:Pf()}}function Cc(t,e){try{if(!kf(t))return!1;let n=e(If(t));return Promise.resolve(n).catch(()=>{}),!0}catch(n){return!1}}var dr=class extends wc.default.Component{constructor(){super(...arguments);this.state={error:null,caught:!1,rethrow:!1}}static getDerivedStateFromError(n){return{error:n,caught:!0}}componentDidCatch(n){Cc(n,this.props.report),this.setState({rethrow:!0})}render(){if(this.state.rethrow)throw this.state.error;return this.state.caught?null:this.props.children}};var Su=require("react");var ea=require("react-redux");var ur=F(require("classnames")),We=require("react"),pr=require("react-redux");var cr=require("react");var Tc={root:"dd-tvkOF",content:"dd-eXA1D"};var Zi=require("react/jsx-runtime"),Af=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:s,onKeyDown:r,overlayAriaLabel:i,contentAriaLabel:a})=>{let c=(0,cr.useRef)(null),l=C("Dialog",Tc),d=u=>{if(u.key==="Escape"){u.preventDefault(),u.stopPropagation(),s();return}r&&r(u)},p=u=>{u.target===c.current&&t&&o()};return(0,cr.useEffect)(()=>{var u,m;!c.current||!t||!e||(m=(u=c.current)==null?void 0:u.querySelector("input, textarea"))==null||m.focus()},[t,e,c]),t?(0,Zi.jsx)("div",{role:"dialog","data-testid":"dialog",className:l.root,"aria-label":i,ref:c,onKeyDown:d,onMouseDown:p,children:(0,Zi.jsx)("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:n})}):null},Un=Af;var kc=F(require("classnames"));var Ec={root:"dd-ranhW"};var Rc=require("react/jsx-runtime"),Lf=o=>{var s=o,{className:t,value:e}=s,n=D(s,["className","value"]);let r=C("TextInput",Ec);return(0,Rc.jsx)("input",h({className:(0,kc.default)(t,r.root),type:"text",value:e},n))},Ro=Lf;var Yi={};ee(Yi,{enUS:()=>Mf,nlNL:()=>Nf});var Mf={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"}]},Nf={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 Pc={root:"dd-lWxnE",anchorButton:"dd-TZ4in",errorMessage:"dd-fIsPg",title:"dd-pGhJx",subtitle:"dd-f5l29",text:"dd-iamoD",input:"dd-uhQZ3",actions:"dd-lubvx",button:"dd-CJsNI",primaryButton:"dd-MWBfl"};var Y=require("react/jsx-runtime");var Of=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch(e){return t}},Df=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:s})=>{let r=A(Yi),i=C("LoginTokenDialog",Pc),a=(0,pr.useSelector)(bl),c=(0,pr.useDispatch)(),l=R("productName"),[d,p]=(0,We.useState)(t||""),[u,m]=(0,We.useState)(0),[f,g]=(0,We.useState)(""),y=(0,We.useCallback)(T=>S(null,null,function*(){T.preventDefault(),c(Tl({email:d})),m(1)}),[n,d]),v=()=>{g(""),m(0)},x=(0,We.useCallback)(T=>S(null,null,function*(){T.preventDefault();let k=Of(T.target.elements.token.value);if(!k){g(r("verifyCodeError",{login:w}));return}c(io({token:k}))}),[n]),w=(0,We.useMemo)(()=>T=>(0,Y.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:v,children:T},"back-button"),[]);return(0,We.useEffect)(()=>{a==="error"&&g(r("verifyCodeError",{login:w})),a==="done"&&o()},[a]),(0,Y.jsx)(Un,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:l}),overlayAriaLabel:r("promptTitle",{productName:l}),onClose:s,onBack:s,children:(0,Y.jsxs)("div",{className:i.root,children:[(0,Y.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:l})}),u===0&&(0,Y.jsxs)("form",{onSubmit:y,children:[(0,Y.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,Y.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:l})}),(0,Y.jsx)(Ro,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:d,onChange:T=>p(T.target.value)}),(0,Y.jsx)("div",{className:i.actions,children:(0,Y.jsx)("button",{type:"submit",className:(0,ur.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&(0,Y.jsxs)("form",{onSubmit:x,children:[(0,Y.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,Y.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,Y.jsx)(Ro,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&(0,Y.jsx)("div",{className:i.errorMessage,children:f}),(0,Y.jsxs)("div",{className:i.actions,children:[(0,Y.jsx)("button",{type:"button",className:(0,ur.default)(i.button),onClick:v,children:r("back")}),(0,Y.jsx)("button",{type:"submit",className:(0,ur.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Ic=Df;var Lc=require("react/jsx-runtime"),_f=()=>{let t=(0,ea.useSelector)(Cl),e=(0,ea.useSelector)(Ln),n=R("adminUrl"),o=he(),s=()=>o.send(On,!1),r=()=>{o.send(On,!1),o.send(uo)};return(0,Lc.jsx)(Ic,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:s,onSuccess:r})},Ac=_f;var yu=F(require("lodash.debounce")),ye=require("react"),et=require("react-redux");var gr=require("@reduxjs/toolkit");var Ff={data:null,fetchState:"idle"},Mc=t=>t.contentTypes.data,Po=(0,gr.createAsyncThunk)("contentTypes/getContentTypes",(t,e)=>S(null,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),Hf=(0,gr.createSlice)({name:"contentTypes",initialState:Ff,reducers:{},extraReducers:t=>{t.addCase(Po.pending,e=>{e.fetchState="loading"}).addCase(Po.rejected,e=>{e.fetchState="error"}).addCase(Po.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),Nc=Hf.reducer;var mt=require("@reduxjs/toolkit");var Bf={data:null,fetchState:"idle",generation:0,inFlightRequestId:null},Oc=t=>{t.data=null,t.fetchState="idle",t.generation+=1,t.inFlightRequestId=null},Uf=[],Me=t=>t.profile.data,Kf=t=>t.profile.data?t.profile.data.uiConfig.widget.types:Uf,Ao=(0,mt.createSelector)([Kf],t=>t.filter(e=>e.isActive)),Dc=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},_c=t=>e=>Ao(e).find(n=>n.type===t),Fc=t=>t.profile.data?!!t.profile.data.uiConfig.widget.types.find(e=>e.type==="custom-data"):!1,Hc=(0,mt.createSelector)([Me],t=>{var o;let e=(o=t==null?void 0:t.widgetInteractiveAssistants)!=null?o:[];if(e.length>0)return[...e].sort((s,r)=>s.order-r.order||s.code.localeCompare(r.code));let n=t==null?void 0:t.knowledgeAssistantNew;return n?[{code:n,name:n,displayName:null,order:0}]:[]});var Kn="stale-profile-request",ta=(0,mt.createAction)("profile/clear"),Io=(0,mt.createAsyncThunk)("profile/getProfile",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=e.getState(),s=o.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=s.profileCode,i=s.id,a=o.profile.generation,c=()=>{let p=e.getState(),u=p.conversation.current;return!u||u.id!==i||u.profileCode!==r||p.profile.generation!==a},l=e.getState().profile.data;if((l==null?void 0:l.code)===r)return c()?e.rejectWithValue(Kn):l;let d;try{d=yield n.getProfile(r)}catch(p){if(c())return e.rejectWithValue(Kn);throw p}if(c())return e.rejectWithValue(Kn);if(d.code!==r)throw new Error(`Profile response code "${d.code}" does not match requested "${r}"`);return d})),Wf=(0,mt.createSlice)({name:"profile",initialState:Bf,reducers:{},extraReducers:t=>{t.addCase(Io.pending,(e,n)=>{e.fetchState="loading",e.inFlightRequestId=n.meta.requestId}).addCase(Io.rejected,(e,n)=>{if(n.payload===Kn){if(n.meta.requestId!==e.inFlightRequestId)return;e.inFlightRequestId=null,e.fetchState="idle";return}n.meta.requestId===e.inFlightRequestId&&(e.fetchState="error",e.inFlightRequestId=null)}).addCase(Io.fulfilled,(e,n)=>{n.meta.requestId===e.inFlightRequestId&&(e.fetchState="done",e.data=n.payload,e.inFlightRequestId=null)}).addCase(j,Oc).addCase(ta,Oc)}}),Bc=Wf.reducer;var ht=require("react");var Uc=require("react"),mr=F(require("classnames"));var Ce={root:"dd-U2SX4",list:"dd-cYTlj",listWrapper:"dd-GLQFR",listHorizontal:"dd-x-knl",page:"dd-1F4vk",search:"dd-nvbxc",pageNav:"dd-sRUuT",pageTitle:"dd-t-MKS",pageBackButton:"dd-cjptm",listHeader:"dd-Fg666",listHeading:"dd-w-xhJ",listMoreButton:"dd--mKep",listItem:"dd-wpvuA",listItemContent:"dd-V-mKo",listItemText:"dd-ukCHL",listItemDescription:"dd-sSyu4",listItemActions:"dd-xelho",listItemTooltip:"dd-SWFsE",listItemTooltipContent:"dd-I7J9N",truncate:"dd-IlopJ",lineClamp:"dd-Twaca",listItemTitle:"dd-lMGHq",listItemAction:"dd-xPLAs",listItemSelected:"dd-jFX0Y",sources:"dd-pZx4v",sourcesTitle:"dd-phYVd",source:"dd-DaR6h",sourceShowMore:"dd-M1-8j",icon:"dd-m6yxD",searchIcon:"dd-0AU-O",searchInputWrapper:"dd-DUFcE",searchInput:"dd-ukrlD",select:"dd--Tifv",selectType:"dd-IkZb2",selectWrapper:"dd-J14mx",image:"dd-RQgsB",imageSrc:"dd-jxh8F",imageSrcHidden:"dd-e20Jk",imageSrcStatus:"dd-j50Tt",imageTitle:"dd-qCjfW",actions:"dd-3mfWc",actionsWrapper:"dd-TjDyI",actionsBar:"dd-LiA35",actionButton:"dd-4wk0u",hasShortKeys:"dd-XilV-",actionShortcut:"dd-s4Mla",actionShortcutFixKerning:"dd-lyh5e"};var ft={};ee(ft,{enUS:()=>zf,nlNL:()=>Vf});var zf={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"}],sources:[{type:0,value:"Sources"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},Vf={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"}],sources:[{type:0,value:"Bronnen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var Ot=require("react/jsx-runtime"),jf=({src:t,title:e})=>{let n=C("CommandPalette",Ce),[o,s]=(0,Uc.useState)("loading"),r=A(ft);return(0,Ot.jsxs)("div",{className:n.image,children:[(0,Ot.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,mr.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&(0,Ot.jsx)("span",{className:(0,mr.default)(n.imageSrc,n.imageSrcStatus),children:r("loading")}),o==="error"&&(0,Ot.jsx)("span",{className:(0,mr.default)(n.imageSrc,n.imageSrcStatus),children:(0,Ot.jsx)(ds,{})}),e&&(0,Ot.jsx)("span",{className:n.imageTitle,children:e})]})},Kc=jf;var Wc=F(require("react")),zc=F(require("classnames"));var ln=require("react/jsx-runtime");function na({children:t,heading:e,orientation:n,hasMore:o,onShowAll:s}){let r=A(ft),i=C("CommandPalette",Ce);return Wc.default.Children.count(t)===0?null:(0,ln.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||o)&&(0,ln.jsxs)("div",{className:i.listHeader,children:[e&&(0,ln.jsx)("h4",{className:i.listHeading,children:e}),o&&s&&(0,ln.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,ln.jsx)("div",{className:(0,zc.default)(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}var Mo=F(require("classnames")),ra=require("interweave"),Dt=require("react");var qf=/[.*+?^${}()|[\]\\]/g,$f=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Gf(t){return t.replace(qf,"\\$&")}function Qf(t,e){let n=t.split("").findIndex((o,s)=>o!==e[s]);return n>-1?n:Math.min(t.length,e.length)}function Xf(t){return t.search($f)}function Vc(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let s=new RegExp(`\\b(${Gf(o)})\\b`,"gi");n=n.replace(s,"<strong>$1</strong>")}),n}function jc(t){return t.replace(fs,'<mark data-type="placeholder">$1</mark>')}function Wn(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Jf(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 oa(t,e,n={}){if(e){let o=Qf(e.toLowerCase(),t.toLowerCase()),s=Wn(t.substring(o,t.length));if(n.stripAgentPart){let c=t.substring(0,o),l=Xf(c);return`<span style="opacity: 0.5">${c.substring(l+1)}</span>${s}`}let i=e.split(vl).length>3||e.length>30?Jf(e.trim(),o):0;return`${`${i>0?"\u2026":""}${Wn(t.substring(i,o))}`}<strong>${s}</strong>`}return t}var Zf=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function Lo(t){return Zf.test(t)}function sa(t){var n;let e=document.createElement("template");return e.innerHTML=t,(n=e.content.textContent)!=null?n:""}var fr=F(require("react")),Gc=require("react/jsx-runtime"),qc=fr.default.createContext(void 0);function zn(){let t=fr.default.useContext(qc);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var $c=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r})=>{let i=fr.default.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r}),[n,e,s]);return(0,Gc.jsx)(qc.Provider,{value:i,children:t})};var ue=require("react/jsx-runtime"),Yf=3,eh=90,Qc=({children:t})=>{let e=C("CommandPalette",Ce);return(0,ue.jsx)("div",{className:e.listItemActions,children:t})};function ia(m){var f=m,{closeOnSelect:t=!0,lineClamp:e,tooltip:n,children:o,onClick:s,extra:r,onSourceClick:i,description:a,sources:c,id:l,styles:d,defaultSourcesAmount:p=Yf}=f,u=D(f,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var Ee;let g=A(ft),[y,v]=(0,Dt.useState)(!1),{selected:x,onChangeOpen:w}=zn(),[T,k]=(0,Dt.useState)(!1),E=C("CommandPalette",Ce);function I(_){s(_),t&&w(!1)}let N=(0,Dt.useMemo)(()=>typeof a!="string"?a:Lo(a)?sa(a).trim():a,[a]),G=(0,Dt.useMemo)(()=>typeof n!="string"?n:Lo(n)?sa(n).trim():n,[n]);return(0,Dt.useEffect)(()=>{k(x===l)},[x]),(0,ue.jsxs)("div",{className:(0,Mo.default)(E.listItem,l===x&&E.listItemSelected),children:[(0,ue.jsxs)(q,{placement:"right-start",tooltip:!0,onOpenChange:k,open:T,children:[(0,ue.jsx)(q.Trigger,b(h({className:E.listItemAction,"aria-disabled":(Ee=u.disabled)!=null?Ee:!1,onClick:I,"data-command-palette-item":!0,"data-item-id":l},u),{children:(0,ue.jsxs)("div",{className:E.listItemContent,children:[typeof o=="string"?(0,ue.jsx)("p",{className:(0,Mo.default)(E.listItemText,E.truncate,d==null?void 0:d.title),children:o}):o,N&&typeof N=="string"?(0,ue.jsx)(ra.Interweave,{tagName:"p",allowList:[],content:N,className:(0,Mo.default)(E.listItemDescription,d==null?void 0:d.description,e?E.lineClamp:E.truncate)}):a]})})),G&&G.length>eh&&(0,ue.jsx)(q.Content,{className:E.listItemTooltip,disableFocusManager:!0,children:(0,ue.jsx)(ra.Interweave,{className:E.listItemTooltipContent,allowList:["h1","h2","h3","h4","h5","h6","a","p","br"],tagName:"div",content:G.replace(/\n/g,"<br />")})})]}),l===x&&r,c&&c.length>0&&(0,ue.jsxs)("div",{className:E.sources,children:[(0,ue.jsx)("span",{className:E.sourcesTitle,children:g("sources")}),c.slice(0,y?c.length:p).map(_=>(0,ue.jsx)("a",{className:E.source,href:_.url,target:"_blank",title:_.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i==null?void 0:i(_),children:_.name},_.url)),!y&&c.length>p&&(0,ue.jsx)("button",{className:(0,Mo.default)(E.source,E.sourceShowMore),type:"button",onClick:()=>v(!0),children:g("showMore",{amount:c.length-p})})]})]})}var No=require("react/jsx-runtime"),Xc=()=>(0,No.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,No.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,No.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 dn=require("react/jsx-runtime");function aa({children:t,title:e,id:n,onDismiss:o}){let s=A(ft),r=C("CommandPalette",Ce),{page:i}=zn();return i!==n?null:(0,dn.jsxs)("div",{className:r.page,id:`page_${n}`,tabIndex:-1,children:[o&&(0,dn.jsxs)("div",{className:r.pageNav,children:[(0,dn.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:o,children:[(0,dn.jsx)(Xc,{}),s("back")]}),e&&(0,dn.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var Jc=require("react");var Oo=require("react/jsx-runtime"),Vn=()=>(0,Oo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Oo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Oo.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 ze=require("react/jsx-runtime");function th({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:s,value:r,selectedType:i},a){let c=C("CommandPalette",Ce);return(0,ze.jsxs)("div",{className:c.search,children:[(0,ze.jsx)("div",{className:c.searchIcon,children:(0,ze.jsx)(Vn,{})}),(0,ze.jsxs)("div",{className:c.searchInputWrapper,children:[(0,ze.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:l=>{t(l.currentTarget.value)},onFocus:l=>{l.currentTarget.select()},className:c.searchInput,placeholder:n,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&(0,ze.jsx)("div",{className:c.selectWrapper,children:(0,ze.jsxs)("select",{"data-testid":"command-palette-type-select",className:c.select,onChange:l=>e(l.target.value===o?void 0:l.target.value),value:i||o,children:[o&&(0,ze.jsx)("option",{children:o}),s.map(l=>(0,ze.jsx)("option",{value:l.value,children:l.label},l.value))]})})]})]})}var Zc=(0,Jc.forwardRef)(th);var la=F(require("classnames"));var hr=require("react/jsx-runtime"),nh=s=>{var r=s,{onClick:t,shortKeys:e,children:n}=r,o=D(r,["onClick","shortKeys","children"]);let i=C("CommandPalette",Ce);return(0,hr.jsxs)("button",b(h({type:"button"},o),{onClick:t,className:(0,la.default)(i.actionButton,o.className,{[i.hasShortKeys]:e&&e.length>0}),children:[n,e==null?void 0:e.map(a=>(0,hr.jsx)("span",{className:(0,la.default)(i.actionShortcut,a===8629&&i.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},Yc=nh;var Do=require("react/jsx-runtime"),oh="[data-command-palette-item]";function cn({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:c,types:l,children:d,isOpen:p,search:u,updateDeps:m=[]}){let[f,g]=(0,ht.useState)(),y=(0,ht.useRef)(null),v=()=>{s&&s(n),i(void 0),r(""),a(!1)},x=()=>{var _;if(o!==n&&s){s(n);return}if(c&&i){i(void 0),(_=y.current)==null||_.focus();return}if(u.length>0){r("");return}a(!1)},w=()=>{let _=T();_.length!==0&&g(_[0].dataset.itemId)},T=()=>Array.from(document.querySelectorAll(oh)||[]),k=_=>document.querySelector(`[data-item-id=${_}]`),E=_=>{let K=k(_);K&&g(K.dataset.itemId)},I=_=>{let K=k(_);K&&K.scrollIntoView({behavior:"smooth"})},N=()=>{if(!f)return;let _=T(),K=k(f);if(!K)return;let $e=_.indexOf(K),oe=_[$e+1];oe!=null&&oe.dataset.itemId?E(oe.dataset.itemId):w()},G=()=>{if(!f)return;let _=T(),K=k(f);if(!K)return;let $e=_.indexOf(K),oe=_[$e-1];oe!=null&&oe.dataset.itemId?E(oe.dataset.itemId):E(_[_.length-1].dataset.itemId)},Ee=(0,ht.useCallback)(_=>{switch(_.key){case"ArrowDown":{_.preventDefault(),N();break}case"ArrowUp":{_.preventDefault(),G();break}case"Enter":{if(f){let K=k(f);K==null||K.click()}break}}},[f]);return(0,ht.useEffect)(()=>{w()},[u,o,c,p,...m]),(0,ht.useEffect)(()=>{f&&I(f)},[f]),(0,Do.jsx)(Un,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:x,onClose:v,onKeyDown:Ee,children:(0,Do.jsxs)($c,{selected:f,setSelected:g,isOpen:p,onChangeOpen:a,page:o,children:[o===n&&(0,Do.jsx)(Zc,{ref:y,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:c,types:l,typePlaceholder:e}),d]})})}cn.Page=aa;cn.List=na;cn.Image=Kc;cn.ListItem=ia;cn.ListItemActions=Qc;cn.Button=Yc;var ne=cn;var eu=require("react");function tu(t,e){(0,eu.useEffect)(()=>{let n=o=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var _o=require("react"),vr=require("react-redux");var jn=require("@reduxjs/toolkit");var nu={data:null,fetchState:"idle"},sh=t=>{var e;return(e=t.entities.data)!=null?e:null},yr=(0,jn.createSelector)([sh,Ln,Ql],(t,e,n)=>{var a;let o=[],{visitorName:s}=n!=null?n:{},{agentName:r,agentNickname:i}=e!=null?e:{};return r&&r!==s&&o.push(r),i&&i!==s&&o.push(i),(a=t==null?void 0:t.filter(c=>!o.includes(c.text)))!=null?a:null}),Ve=(0,jn.createAsyncThunk)("entities/getEntities",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let s=o.conversationQuery,r=yield s();return r.length===0?Promise.resolve([]):n.getEntities(r)})),rh=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),ih=(0,jn.createSlice)({name:"entities",initialState:nu,reducers:{},extraReducers:t=>{t.addCase(Ve.pending,e=>{e.fetchState="loading"}).addCase(Ve.rejected,e=>{e.fetchState="error"}).addCase(Ve.fulfilled,(e,n)=>{e.fetchState="done",e.data=rh(e.data?[...e.data,...n.payload]:n.payload)}).addCase(j,()=>nu)}}),ou=ih.reducer;var da={};ee(da,{enUS:()=>ah,nlNL:()=>lh});var ah={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},lh={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var su={root:"dd-TYTKs",empty:"dd-AU7uT"};var qn=require("react/jsx-runtime"),dh=({onCopy:t})=>{let e=(0,_o.useRef)(null),n=C("EntitiesList",su),o=(0,vr.useSelector)(yr),{setSelected:s}=zn(),r=A(da),i=(0,vr.useDispatch)();return(0,_o.useEffect)(()=>{i(Ve())},[]),(0,_o.useEffect)(()=>{e.current&&(e.current.focus(),s("entity-0"))},[e]),(0,qn.jsxs)("div",{className:n.root,ref:e,tabIndex:-1,children:[o&&o.length>0&&(0,qn.jsx)(ne.List,{children:o.map((a,c)=>(0,qn.jsx)(ne.ListItem,{id:`entity-${c}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),o&&o.length===0&&(0,qn.jsx)("p",{className:n.empty,children:r("noResults")})]})},ru=dh;var ca=require("react/jsx-runtime"),Sr=t=>(0,ca.jsx)("svg",b(h({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},t),{children:(0,ca.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 Fo={};ee(Fo,{enUS:()=>ch,nlNL:()=>uh});var ch={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"}]},uh={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 iu=require("react-redux");var Ho={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var _t=require("react/jsx-runtime"),ph=({suggestion:t,source:e,context:n})=>{let o=A(Fo),s=(0,iu.useSelector)(Re),r=X(),i=R("enableSuggestionFeedback"),a=qs({conversationId:s,type:e,contentType:"text",content:t.text,data:n?JSON.stringify({context:n}):void 0}),c=Gs(a),l=()=>S(null,null,function*(){r("suggestion feedback",{text:t.text,source:e,context:n}),c.mode==="custom-handler"&&(yield c.open())});return!i||c.mode==="disabled"?null:(0,_t.jsxs)(q,{placement:"top-end",children:[(0,_t.jsx)(q.Trigger,{className:Ho.trigger,children:(0,_t.jsx)(Sr,{"data-testid":"feedback-dropdown-trigger"})}),(0,_t.jsx)(q.Content,{className:Ho.content,children:c.mode==="custom-handler"?(0,_t.jsx)(q.Button,{className:Ho.item,onClick:l,children:o("giveFeedback")}):(0,_t.jsx)(q.Button,{className:Ho.item,as:"a",onClick:l,target:"_blank",rel:"noreferrer noopener",href:c.href,children:o("giveFeedback")})})]})},xr=ph;var Bo={};ee(Bo,{enUS:()=>gh,nlNL:()=>mh});var gh={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"URL 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"}],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?"}]},mh={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:"URL 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"}],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 fu=require("react"),wr=require("react-redux");var un=require("@reduxjs/toolkit");var fh=["{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}"],hh=new RegExp(fh.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function au(t,e){let n=t.split(hh),o=0,s=[];for(let r=0;r<n.length;r++){let i=n[r];if(s.push(i),r===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[r+1],c=r===n.length-2;o+=i.length;let l=o;if(c){let p=a.charAt(0),u=0;do l=p?e.indexOf(p,l+1):-1,u+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&u>2)return t}else l=a&&a!==""?e.indexOf(a,o):-1;let d=l===-1?e.slice(o):e.slice(o,l);s.push(d),o=l}return s.join("")}function lu(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var cu={suggestions:[],fetchState:"idle"},du={default:cu},uu=t=>e=>{var n,o;return(o=(n=e.textSuggestions[t])==null?void 0:n.suggestions)!=null?o:[]},br=t=>t.textSuggestions,pu=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Cr=(0,un.createAction)("textSuggestions/refresh"),je=(0,un.createAsyncThunk)("textSuggestions/recommendations",(t,e)=>S(null,null,function*(){var d,p,u;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:s}=o.info,{textSuggestionsCount:r,inlineSuggestions:i}=o.settings,a=Xt(o),c=(d=o.conversation.current)==null?void 0:d.id;if(!c)throw new Error("No current conversation to fetch text suggestions");if(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];let l=[];if(t==="sticky-messages"){let m=(u=o.profile.data)==null?void 0:u.code;if(!m)throw new Error("No current profile to fetch pinned messages");l=yield n.getPinnedMessages(m)}else l=yield n.getTextSuggestions(c,co(o),t);if(s&&(l=l.map(m=>h(b(h({},m),{text:Be(m.text,s)}),m.title?{title:Be(m.title,s)}:{}))),t==="default"){let m=i?l.filter(pu(a)):l;e.dispatch(At(m.slice(0,r)))}return l})),Uo=(0,un.createAsyncThunk)("textSuggestions/autocompletions",(t,e)=>S(null,null,function*(){var d,p;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(d=o.conversation.current)==null?void 0:d.id,{platformVariables:r}=o.info,{textSuggestionsCount:i,deanonymize:a,inlineSuggestions:c}=o.settings;if(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];if(!s)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(s,b(h({},co(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return c&&(l=l.filter(pu(t))),r&&(l=l.map(u=>b(h({},u),{text:Be(u.text,r)}))),a&&(l=l.map(u=>b(h({},u),{text:u.source!=="trie-with-typos"?au(u.text,t):u.text}))),l=lu(l,i),e.dispatch(At(l)),l})),gu=(0,un.createSlice)({name:"textSuggestions",initialState:du,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:n}=e.payload;t[n].fetchState="done",t[n].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}}},extraReducers:t=>{t.addCase(je.pending,(e,n)=>{let o=n.meta.arg,s=e[o]||cu;return b(h({},e),{[o]:b(h({},s),{fetchState:"loading"})})}).addCase(je.rejected,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="error")}).addCase(je.fulfilled,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="done",e[o].suggestions=n.payload)}).addCase(Uo.pending,e=>{e.default.fetchState="loading"}).addCase(Uo.rejected,e=>{e.default.fetchState="error"}).addCase(Uo.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(j,()=>du)}}),{setTextSuggestions:T1}=gu.actions,mu=gu.reducer;var pn=require("react/jsx-runtime"),yh=({types:t,commands:e,onClick:n})=>{let o=(0,wr.useDispatch)(),s=A(Bo),r=(0,wr.useSelector)(br);return(0,fu.useEffect)(()=>{t.forEach(({type:i})=>{(!r[i]||r[i].suggestions.length===0)&&o(je(i))})},[]),(0,pn.jsxs)("div",{children:[e.length>0&&(0,pn.jsx)(ne.List,{heading:s("commands"),children:e.map((i,a)=>(0,pn.jsx)(ne.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:i.onClick,children:i.label},i.label))}),t.map(({type:i,title:a})=>{var c;return(0,pn.jsx)(ne.List,{heading:a,orientation:"vertical",children:(c=r[i])==null?void 0:c.suggestions.map((l,d)=>(0,pn.jsx)(ne.ListItem,{id:`${i}-${d}`,closeOnSelect:!1,description:l.title&&l.text,onClick:()=>n(l.text,l),"data-testid":"search-overlay-suggestion",children:l.title||l.text},`${l.id}-${l.text}`))},i)})]})},hu=yh;var pe=require("react/jsx-runtime"),Sh=200,xh=5,bh=4,ua=(t,e,n)=>t.slice(0,n?10:e.toLowerCase()==="image"?bh:xh),Ch=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),wh=()=>{var $e,oe,zt;let t=(0,et.useDispatch)(),e=he(),n=A(Bo),[o,s]=(0,ye.useState)(!1),[r,i]=(0,ye.useState)(""),a=(0,et.useSelector)(rd),c=(0,et.useSelector)(Me),[l,d]=(0,ye.useState)(),p=(0,et.useSelector)(re),u=R("showSearch"),m=R("enableSuggestionFeedback"),f=R("showEntitiesCommand"),g=R("showImageSearch"),y=R("searchTriggerKey"),v=(0,et.useSelector)(Mc),x=(0,et.useSelector)(Ti),w=(0,et.useSelector)(id),T=(0,et.useSelector)(sd),k=((zt=(oe=($e=c==null?void 0:c.uiConfig)==null?void 0:$e.search)==null?void 0:oe.initialTypes)==null?void 0:zt.filter(({isActive:O})=>O))||[],E=X(),I=(0,ye.useMemo)(()=>{let O=me=>ua(x.filter(Z=>Z.type===me.toUpperCase()),me,l),Q=(v==null?void 0:v.map(me=>({value:me.code.toUpperCase(),label:`${me.name}s`,list:O(me.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(Q.push({value:"PERSONAL",label:n("personalSuggestions"),list:O("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:O("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:O("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),g&&Q.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:O("IMAGE"),listOrientation:"horizontal"}),k.length===0)return Q;let at=k.map(me=>Q.find(Z=>Z.value.toLowerCase()===me.type)).filter(me=>!!me),wn=Q.filter(me=>!at.find(Z=>Z.value===me.value));return[...at,...wn]},[v,k,g,l]),N=[{label:n("entitiesClipboard"),onClick:()=>t(Nn("entities")),shouldShow:f&&Ch(n("entitiesClipboard"),r)}].filter(O=>O.shouldShow).filter(()=>!l),G=(0,ye.useCallback)((0,yu.default)((O,Q)=>{t(tn({query:O,type:Q,tags:["search-overlay"],size:l?50:20}))},Sh),[l]),Ee=(0,ye.useCallback)((O,Q)=>{Q.type==="IMAGE"?e.send(ki,{suggestion:Q}):e.send(dt,{text:O,suggestion:Q}),t(Ue(!1))},[t]),_=O=>{Xe(O.text),E("entity copied",{entity:O,type:"copy"}),t(Ue(!1))};function K(O){return Q=>{o?window.confirm(n("warning"))&&(O(Q),s(!1)):O(Q)}}return(0,ye.useEffect)(()=>{r?G(r,l):t(Is())},[r,l]),(0,ye.useEffect)(()=>{p&&t(Po())},[p]),tu(y,()=>{t(Ue(!0)),E("open search",{via:"ctrl+k"})}),!u||!c?null:(0,pe.jsxs)(ne,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:K(O=>t(Ue(O))),onChangeType:O=>d(O),onChangePage:K(O=>t(Nn(O))),selectedType:l,search:r,page:a,isOpen:T,types:I,updateDeps:[x],children:[(0,pe.jsxs)(ne.Page,{id:"search",children:[r.length===0&&(0,pe.jsx)(hu,{types:k,commands:N,onClick:Ee}),r.length>0&&(0,pe.jsxs)(ye.Fragment,{children:[N.length>0&&(0,pe.jsx)(ne.List,{heading:n("commands"),children:N.map((O,Q)=>(0,pe.jsx)(ne.ListItem,{closeOnSelect:!1,onClick:O.onClick,id:`commands-${Q}`,children:O.label},O.label))}),I.map(({value:O,label:Q,list:at,lineClamp:wn,listOrientation:me})=>(0,pe.jsx)(ne.List,{heading:Q,orientation:me==="horizontal"?"horizontal":"vertical",onShowAll:()=>d(O),hasMore:!l&&w[O.toLowerCase()]>ua(at,O,l).length,children:ua(at,O,l).map(Z=>(0,pe.jsx)(ne.ListItem,{id:`${O}-${Z.id}`,closeOnSelect:!1,lineClamp:wn,onClick:()=>Ee(Z.text,Z),description:O!=="IMAGE"?Z.title&&Z.text:void 0,tooltip:Z.text,extra:m&&(0,pe.jsx)(ne.ListItemActions,{children:(0,pe.jsx)(xr,{context:r,source:"search",suggestion:Z})}),children:O==="IMAGE"?(0,pe.jsx)(ne.Image,{title:Z.title||Z.text,src:Z.image}):Z.title||Z.text},`${Z.id}-${Z.text}`))},O))]})]}),(0,pe.jsx)(ne.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:K(()=>{t(Nn("search"))}),children:(0,pe.jsx)(ru,{onCopy:_})})]})},vu=wh;var Ko=require("react/jsx-runtime"),Th=()=>{let t=R("showSearch"),e=R("isEmbedded");return(0,Ko.jsxs)(Su.Fragment,{children:[t&&(0,Ko.jsx)(vu,{}),e&&(0,Ko.jsx)(Ac,{})]})},xu=Th;var Tu=F(require("classnames")),Eu=require("react-redux");var Tr=require("react/jsx-runtime"),bu=({className:t})=>(0,Tr.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,Tr.jsx)("g",{children:(0,Tr.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
|
+
`,nn.MISSING_INTL_API,i);var T=n.getPluralRules(e,{type:d.pluralType}).select(u-(d.offset||0));w=d.options[T]||d.options.other}if(!w)throw new Mi(d.value,u,Object.keys(d.options),i);a.push.apply(a,To(w.value,e,n,o,s,u-(d.offset||0)));continue}}return jm(a)}function $m(t,e){return e?Ce(Ce(Ce({},t||{}),e||{}),Object.keys(t).reduce(function(n,o){return n[o]=Ce(Ce({},t[o]),e[o]||{}),n},{})):t}function Gm(t,e){return e?Object.keys(t).reduce(function(n,o){return n[o]=$m(t[o],e[o]),n},Ce({},t)):t}function Ni(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,n){t[e]=n}}}}}function Qm(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Ds(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,Os([void 0],n,!1)))},{cache:Ni(t.number),strategy:_s.variadic}),getDateTimeFormat:Ds(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,Os([void 0],n,!1)))},{cache:Ni(t.dateTime),strategy:_s.variadic}),getPluralRules:Ds(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,Os([void 0],n,!1)))},{cache:Ni(t.pluralRules),strategy:_s.variadic})}}var Oi=(function(){function t(e,n,o,s){n===void 0&&(n=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 p=d.reduce(function(u,m){return!u.length||m.type!==de.literal||typeof u[u.length-1]!="string"?u.push(m.value):u[u.length-1]+=m.value,u},[]);return p.length<=1?p[0]||"":p},this.formatToParts=function(l){return To(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=n,this.resolvedLocale=t.resolveLocale(n),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=hd(i,["formatters"]);this.ast=t.__parse(e,Ce(Ce({},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=Gm(t.formats,o),this.formatters=s&&s.formatters||Qm(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!="undefined"){var n=Intl.NumberFormat.supportedLocalesOf(e);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=xd,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 Xm(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var Jm="dummy",Di=(0,Ks.createContext)(null);function A(t){var o;let e=(0,Ks.useContext)(Di);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=(o=t[e])!=null?o:{};return(s,r)=>{let i=Xm(n,s);return i?new Oi(i).format(r):(e!==Jm&&console.warn(`${s} does not exist in messages of ${e}`),`[${s}]`)}}var pt=require("@reduxjs/toolkit");var wd=require("marked"),Ws=(t,e)=>{let n=[],o=new wd.Marked,s=r=>{r.type==="code"&&r.lang===e&&n.push(r.text)};return o.use({walkTokens:s}),o.parse(t),n};var _i=new Map;function Td(t){var e;return t&&(e=_i.get(t))!=null?e:null}function Ed(t){if(!t)return()=>{};let e,n=new Promise(o=>{e=o});return _i.set(t,n),o=>{_i.delete(t),e(o)}}function Fi(t){return Array.isArray(t.attachments)&&t.attachments.length>0?t.attachments:Array.isArray(t.transcript)?t.transcript.flatMap(e=>{var n;return(n=e==null?void 0:e.attachments)!=null?n:[]}):[]}var kd={cues:[],threads:{},pending:[],widgetAssistantSessionId:null,assistantThreads:{},activeAssistantCode:null,nextLocalThreadId:1},Rd=t=>{var e;return(e=t.assistants)==null?void 0:e.cues};var Pd=t=>e=>{var n,o;return(o=(n=e.assistants)==null?void 0:n.threads[t])!=null?o:null},Id=t=>{var n,o;let e=t.assistants.activeAssistantCode;return e&&(o=(n=t.assistants.assistantThreads[e])==null?void 0:n.threadId)!=null?o:null},Ad=t=>t.assistants.activeAssistantCode;var zs=(0,pt.createAction)("assistants/callToAction"),Eo=(0,pt.createAsyncThunk)("assistants/evaluateKnowledgeAssistant",(t,e)=>S(null,null,function*(){var f,g,y,v,x,w,T,k,E,I,W,oe,fe,N;let{threadId:n}=t,{deepdeskAPI:o}=e.extra,s=e.getState(),{platformVariables:r}=s.info,i=(g=(f=s.conversation.current)==null?void 0:f.externalId)!=null?g:null,a=(v=(y=t.externalConversationId)!=null?y:i)!=null?v:void 0;if((x=t.attachments)!=null&&x.length)throw new Error("Attachments are not supported for widget assistant interact; use evaluateAssistant instead.");let c=(T=(w=s.assistants.widgetAssistantSessionId)!=null?w:ao(a))!=null?T:void 0;if(!c&&a){let H=Td(a);H&&(c=(k=yield H)!=null?k:void 0)}let l=!c&&a?Ed(a):null;if(!n){let H=(E=s.assistants.assistantThreads[t.assistantCode])==null?void 0:E.threadId;H?n=H:(n=s.assistants.nextLocalThreadId,e.dispatch(Ui({assistantCode:t.assistantCode,threadId:n})))}if(n==null)throw new Error("Failed to resolve thread id for widget assistant interact");let d;try{d=yield o.interactWithAssistant({assistantCode:t.assistantCode,message:t.input,sessionId:c,externalConversationId:a})}catch(H){throw l==null||l(void 0),H}let p=(W=(I=e.getState().conversation.current)==null?void 0:I.externalId)!=null?W:null;if(a&&i&&a!==p)throw l==null||l(void 0),new Error("Conversation changed before interact completed");if(d.sessionId?(e.dispatch(Bi(d.sessionId)),Ll(a,d.sessionId),l==null||l(d.sessionId)):l==null||l(c),d.evaluationStatus!=="success")throw new Error(`Assistant ${t.assistantCode} evaluation failed: ${d.evaluationStatus}`);let m=(oe=Ld(d,t.assistantCode)[0])!=null?oe:{response:"",sources:[]};return t.onNewThreadId&&t.onNewThreadId(n),{threadId:n,question:t.input,evaluationId:d.evaluationId,answer:{answer:(fe=Ue(m.response,r!=null?r:{}))!=null?fe:"",sources:(N=m.sources)!=null?N:[]},externalConversationId:a,currentExternalIdAtRequest:i}})),Fb=(0,pt.createAction)("assistants/extractedTextSuggestions");function Ld(t,e){var n,o;return Array.isArray(t.output)?t.output:typeof t.output=="string"?[{code:e,name:e,response:t.output}]:[b(h({code:e,name:e},t.output&&typeof t.output=="object"?t.output:{}),{response:(o=(n=t.output)==null?void 0:n.response)!=null?o:""})]}var Md=(0,pt.createAsyncThunk)("assistants/resetKnowledgeAssistantThread",(t,e)=>S(null,null,function*(){var i,a,c;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(a=(i=o.conversation.current)==null?void 0:i.externalId)!=null?a:void 0,r=(c=o.assistants.widgetAssistantSessionId)!=null?c:ao(s);r&&(yield n.resetAssistantThread({assistantCode:t.assistantCode,sessionId:r}))})),we=(0,pt.createAsyncThunk)("assistants/evaluate",(t,e)=>S(null,null,function*(){var x,w,T,k,E;let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra,{transcript:s,input:r={},threadId:i,attachments:a}=t,c=e.getState(),{platformVariables:l}=c.info,d=(w=(x=c.conversation.current)==null?void 0:x.externalId)!=null?w:null,p=(k=(T=t.externalConversationId)!=null?T:d)!=null?k:void 0,u;if(s==="in-memory-transcript"){if(!o.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");let I=yield o.conversationQuery();u=Array.isArray(I)?I:void 0}else Array.isArray(s)&&(u=s);if(t.includeMetadata&&c.conversation.current&&((E=t.externalConversationId)!=null?E:d)===d){let{metadata:W}=c.conversation.current;Object.assign(r,{metadata:W})}let m=Fi({attachments:a,transcript:u}),f=yield n.evaluateAssistant(t.assistantCode,h({input:r,transcript:u,externalConversationId:p,threadId:i},m.length>0?{attachments:m}:{}));if(f.evaluationStatus!=="success")return e.rejectWithValue(`Assistant ${t.assistantCode} evaluation failed: ${f.evaluationStatus}`);let y=Ld(f,t.assistantCode).map(I=>b(h({},I),{name:Ue(I.name,l),response:Ue(I.response,l)||""})),v=[];return y.forEach(I=>{if(!I.response)return;let W=Ws(I.response,"reply");W.length!==0&&v.push(...W.map(oe=>({text:oe,type:"text",source:"assistant",assistantCode:I.code,sourceLabel:I.name})))}),v.length>0&&e.dispatch(Ln(v)),b(h({},f),{output:y,externalConversationId:p,currentExternalIdAtRequest:d})}));function Nd(t){return t!=null&&t.length?t.map(e=>e.response).filter(Boolean).join(`
|
|
4
|
+
`):""}var Od=(0,pt.createSlice)({name:"assistants",initialState:kd,reducers:{resetCues(t){t.cues=[]},setActiveAssistantCode(t,e){t.activeAssistantCode=e.payload},setWidgetAssistantSessionId(t,e){t.widgetAssistantSessionId=e.payload},registerAssistantThreadId(t,e){let{assistantCode:n,threadId:o}=e.payload;t.assistantThreads[n]={threadId:o},o>=t.nextLocalThreadId&&(t.nextLocalThreadId=o+1)},resetAssistantThread(t,e){let n=t.assistantThreads[e.payload.assistantCode];n&&(delete t.threads[n.threadId],delete t.assistantThreads[e.payload.assistantCode])},removeCueByCode(t,e){t.cues=t.cues.filter(n=>n.code!==e.payload.code)},removeThreadById(t,e){delete t.threads[e.payload]},receiveChunk(t,e){let{code:n,name:o,payload:s,evaluationId:r}=e.payload,i=t.cues.findIndex(a=>a.code===n);i!==-1?t.cues[i].response+=s.text:t.cues.push({code:n,name:o,evaluationId:r,response:s.text})},userNotification(t,e){let n=t.cues.find(d=>d.code===e.payload.code),o=t.cues.filter(d=>d.code!==e.payload.code),{code:s,name:r,evaluationId:i,payload:a}=e.payload,{callToAction:c}=a,l=a.sources!==void 0?a.sources.filter(d=>!!d.url):n==null?void 0:n.sources;t.cues=[...o,b(h({code:s,name:r,evaluationId:i,response:a.message,editable:a.editableMessage},l!=null&&l.length?{sources:l}:{}),{callToAction:c&&{label:c.displayName,event:c.onClickEvent,value:c.eventPayload}})]}},extraReducers:t=>{t.addCase(we.pending,(e,n)=>{e.pending.includes(n.meta.arg.assistantCode)&&P.warn(`Assistant ${n.meta.arg.assistantCode} already evaluating`),e.pending.push(n.meta.arg.assistantCode)}).addCase(we.rejected,(e,n)=>{var s;P.warn((s=n.error)==null?void 0:s.message);let o=e.pending.indexOf(n.meta.arg.assistantCode);o!==-1&&e.pending.splice(o,1)}).addCase(we.fulfilled,(e,n)=>{let o=e.pending.indexOf(n.meta.arg.assistantCode);if(o!==-1&&e.pending.splice(o,1),n.meta.arg.skipState)return;let{evaluationId:s,output:r,externalConversationId:i,currentExternalIdAtRequest:a}=n.payload;if(i&&a&&i!==a)return;let c=r.map(p=>p.code),l=e.cues.filter(p=>!c.includes(p.code)),d=r.map(p=>h(b(h({},p),{evaluationId:s}),i?{externalConversationId:i}:{}));e.cues=[...l,...d]}).addCase(Eo.fulfilled,(e,n)=>{let a=n.payload,{threadId:o,externalConversationId:s,currentExternalIdAtRequest:r}=a,i=D(a,["threadId","externalConversationId","currentExternalIdAtRequest"]);s&&r&&s!==r||(e.threads[o]=[...e.threads[o]||[],i])}).addCase(q,()=>kd)}}),{removeCueByCode:Vs,resetCues:Hb,removeThreadById:Dd,receiveChunk:_d,userNotification:Fd,setActiveAssistantCode:Hi,setWidgetAssistantSessionId:Bi,registerAssistantThreadId:Ui,resetAssistantThread:Hd}=Od.actions,Bd=Od.reducer;var Ud=require("@reduxjs/toolkit"),Kd=require("react-redux");var Zm={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,signInViaPopup:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showStyleSuggestionList:!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,addToPersonalCollection:!1,inlineSuggestions:!1,autoSelectSuggestion:!1,suggestionsPlacement:"above",floatingMenu:!1,detectSubmit:!1,automaticHandlingTime:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!0,adminUrl:void 0,productName:"Deepdesk",hasKeyboardInput:!0},Ki={showSearch:!1,showImageSearch:!1,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,recommendTextSuggestions:!0},Wd=(0,Ud.createSlice)({name:"settings",initialState:Zm,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,s]=n;typeof s!="undefined"&&(t[o]=s)})}},extraReducers:t=>{t.addCase(q,e=>{Object.assign(e,Ki)})}}),{set:ko}=Wd.actions,on=t=>e=>e.settings[t],R=t=>(0,Kd.useSelector)(on(t)),zd=Wd.reducer;function Je(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 Ro=_(require("classnames")),Zd=require("react");var Wi=require("react/jsx-runtime"),js=t=>(0,Wi.jsx)("svg",b(h({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Wi.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 zi=require("react/jsx-runtime"),Vd=t=>(0,zi.jsx)("svg",b(h({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,zi.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 Nt(t,e){var s;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(r=>{n.classList.add(r)}),n.addEventListener("animationend",()=>n.remove()),(s=t.parentElement)==null||s.appendChild(n)}var Vi={};ee(Vi,{enUS:()=>Ym,nlNL:()=>ef});var Ym={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},ef={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var jd={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};var qd=({conversationId:t,evaluationId:e,type:n,assistantCode:o,contentType:s},r,i)=>{let a=new URLSearchParams;return t!=null&&a.set("conversationId",String(t)),e&&a.set("evaluationId",e),a.set("type",n),o&&a.set("assistantCode",o),a.set(s,r),i!==void 0&&a.set("data",i),`/admin/feedback?${a.toString()}`},qs=t=>{let e=t.content,n=qd(t,e,t.data),o=encodeURIComponent(n).length;for(;o>3e3&&e.length>0;){let s=Math.max(0,Math.floor(e.length*3e3/o)-1);e=t.content.slice(0,s),n=qd(t,e?`${e}\u2026`:"",t.data),o=encodeURIComponent(n).length}return n};var Jd=require("react-redux");var $s=require("react"),Xd=require("react/jsx-runtime"),$d=(0,$s.createContext)(null),Gd=({handler:t,children:e})=>(0,Xd.jsx)($d.Provider,{value:t!=null?t:null,children:e}),Qd=()=>(0,$s.useContext)($d);var Fn=t=>e=>{let{passwordlessToken:{token:n},settings:{isEmbedded:o,adminUrl:s}}=e,r=s||window.location.origin;return o&&!n?null:o&&n?`${r}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${r}${t}`};function Gs(t){let e=R("enableFeedbackForm"),n=Qd(),o=(0,Jd.useSelector)(Fn(t));return e?n?{mode:"custom-handler",open:()=>n(t)}:o?{mode:"passwordless-link",href:o}:{mode:"disabled"}:{mode:"disabled"}}var Yd=require("react-redux");var We=require("react/jsx-runtime"),tf=({assistantCode:t,assistantOutput:e,evaluationId:n,feedbackType:o})=>{let s=C("FeedbackThumbs",jd),r=(0,Yd.useSelector)(Pe),i=qs({conversationId:r,evaluationId:n,type:o,assistantCode:t,contentType:"assistantOutput",content:e}),a=Gs(i),c=A(Vi),l=J(),[d,p]=(0,Zd.useState)(null),u=g=>{l("Assistant response feedback",{assistantCode:t,assistantOutput:e,evaluationId:n,rating:g})},m=g=>{g.stopPropagation(),Nt(g.target,s.fadeup),p("up"),u("up")},f=g=>S(null,null,function*(){g.stopPropagation(),Nt(g.target,s.fadedown),p("down"),u("down"),a.mode==="custom-handler"&&(yield a.open())});return(0,We.jsxs)("div",{className:s.thumbs,children:[(0,We.jsx)(M.Button,{title:c("thumbsUp"),onClick:m,icon:(0,We.jsx)(Vd,{}),className:(0,Ro.default)(s.thumbsUp,d==="up"&&s.selected),disabled:!!d}),a.mode==="custom-handler"?(0,We.jsx)(M.Button,{title:c("thumbsDown"),onClick:f,icon:(0,We.jsx)(js,{}),className:(0,Ro.default)(s.thumbsDown,d==="down"&&s.selected),disabled:!!d}):a.mode==="passwordless-link"?(0,We.jsx)(M.Button,{as:"a",title:c("thumbsDown"),href:a.href,target:"_blank",rel:"noreferrer",onClick:f,icon:(0,We.jsx)(js,{}),className:(0,Ro.default)(s.thumbsDown,d==="down"&&s.selected),disabled:!!d}):(0,We.jsx)(M.Button,{title:c("thumbsDown"),onClick:f,icon:(0,We.jsx)(js,{}),className:(0,Ro.default)(s.thumbsDown,d==="down"&&s.selected),disabled:!!d})]})},Qs=tf;var gc=_(require("dompurify")),mc=require("marked"),mt=require("react");var sc=require("react");var z=require("@floating-ui/react"),Ze=_(require("react"));var Xs={tooltip:"dd-XpCXd",tooltipTrigger:"dd-8TKeF",arrow:"dd-ZEu2Y"};var Ae=require("react/jsx-runtime");function nf({initialOpen:t=!1,placement:e="bottom",modal:n,tooltip:o,open:s,onOpenChange:r}={}){let[i,a]=Ze.useState(t),c=s!=null?s:i,l=r!=null?r:a,d=(0,z.useFloating)({placement:e,open:c,onOpenChange:l,whileElementsMounted:z.autoUpdate,middleware:[(0,z.offset)(5),(0,z.flip)({crossAxis:e.includes("-"),fallbackAxisSideDirection:"end",padding:5}),(0,z.shift)({padding:10})]}),p=d.context,u=(0,z.useClick)(p,{enabled:s==null}),m=(0,z.useDismiss)(p),f=(0,z.useRole)(p),g=(0,z.useHover)(p,{enabled:o!=null?o:!1,handleClose:(0,z.safePolygon)()}),y=(0,z.useInteractions)([u,m,f,g]);return Ze.useMemo(()=>b(h(h({open:c,setOpen:l},y),d),{modal:n,tooltip:o}),[c,l,y,d,n,o])}var ec=Ze.createContext(null),ji=()=>{let t=Ze.useContext(ec);if(t==null)throw new Error("Popover components must be wrapped in <Popover />");return t},sn=o=>{var s=o,{children:t,modal:e=!1}=s,n=D(s,["children","modal"]);let r=nf(h({modal:e},n));return(0,Ae.jsx)(ec.Provider,{value:r,children:t})};function of(o){var s=o,{as:t,children:e}=s,n=D(s,["as","children"]);let r=ji(),i=t||"button",a=e.ref,c=(0,z.useMergeRefs)([r.refs.setReference,a]);return(0,Ae.jsx)(i,b(h(h({ref:c},i==="button"||t===void 0||t==="button"?{type:"button"}:{}),r.getReferenceProps(n)),{children:e}))}var sf=Ze.forwardRef(function(s,o){var r=s,{style:e}=r,n=D(r,["style"]);var d;let l=ji(),{context:i}=l,a=D(l,["context"]),c=(0,z.useMergeRefs)([a.refs.setFloating,o]);return i.open?(0,Ae.jsx)(z.FloatingPortal,{children:(0,Ae.jsx)(z.FloatingFocusManager,{context:i,modal:a.modal,disabled:(d=n.disableFocusManager)!=null?d:a.tooltip,children:(0,Ae.jsx)("div",b(h({ref:c,style:h(b(h({},a.floatingStyles),{zIndex:1e7}),e)},a.getFloatingProps(n)),{children:n.children}))})}):null});function rf(s){var r=s,{as:t,children:e,onClick:n}=r,o=D(r,["as","children","onClick"]);let{setOpen:i}=ji();return(0,Ae.jsx)(t||"button",b(h({type:"button",onClick:l=>{n(l),i(!1),l.stopPropagation()}},o),{children:e}))}function tc({trigger:t,children:e,placement:n="top"}){return(0,Ae.jsxs)(sn,{tooltip:!0,placement:n,children:[(0,Ae.jsxs)(sn.Content,{className:Xs.tooltip,children:[e,(0,Ae.jsx)("div",{className:Xs.arrow})]}),(0,Ae.jsx)(sn.Trigger,{className:Xs.tooltipTrigger,children:t})]})}sn.Trigger=of;sn.Content=sf;sn.Button=rf;var $=sn;var qi={};ee(qi,{enUS:()=>af,nlNL:()=>lf});var af={showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}],showLess:[{type:0,value:"Show less"}]},lf={showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}],showLess:[{type:0,value:"Toon minder"}]};var nc={sources:"dd-cNsGl",source:"dd-LoJ6U",tooltip:"dd-7ZGu9",linkContent:"dd-O2IoN",showMoreSources:"dd-ev8Yr"};var Ye=require("react/jsx-runtime"),oc=3,df=({sources:t,onClick:e,sourceTestId:n="assistant-source"})=>{let o=A(qi),s=C("AssistantSources",nc),[r,i]=(0,sc.useState)(!1),a=t.filter(d=>!!d.url),c=r?a:a.slice(0,oc),l=a.length>oc;return c.length===0?null:(0,Ye.jsxs)("ul",{className:s.sources,children:[c.map(d=>(0,Ye.jsx)("li",{className:s.source,"data-testid":n,children:(0,Ye.jsxs)($,{tooltip:!0,placement:"top-start",children:[(0,Ye.jsx)($.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:d.url,onClick:p=>{p.stopPropagation(),e==null||e(d)},children:(0,Ye.jsx)("span",{className:s.linkContent,children:d.name})}),d.url&&(0,Ye.jsx)($.Content,{className:s.tooltip,children:decodeURIComponent(d.url)})]})},d.name)),l&&(0,Ye.jsx)("li",{className:s.source,children:(0,Ye.jsx)("button",{type:"button",className:s.showMoreSources,onClick:()=>i(d=>!d),children:r?o("showLess"):o("showMore",{amount:a.length-c.length})})})]})},rc=df;var Gi=_(require("classnames")),Le=require("react");var Js=require("react"),cf=["bottom","height","left","right","top","width"],uf=(t={},e={})=>cf.some(n=>t[n]!==e[n]),gt=new Map,ic,ac=()=>{let t=[],e=[];gt.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let s=o.getBoundingClientRect();uf(s,n.rect)&&(n.rect=s,t.push(n))}),e.forEach(n=>{gt.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),ic=window.requestAnimationFrame(ac)};function pf(t,e){return{observe(){let n=gt.size===0;if(gt.has(t)){let o=gt.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else gt.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&ac()},unobserve(){let n=gt.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||gt.delete(t),gt.size||cancelAnimationFrame(ic)}}}}function $i(t){let[e,n]=(0,Js.useState)(null);return(0,Js.useLayoutEffect)(()=>{if(!t.current)return;let o=pf(t.current,s=>{n(s)});return o.observe(),()=>{o.unobserve()}},[t]),e}var Hn=require("react"),cc=require("react-dom");var lc=require("react");function Ot(t){(0,lc.useEffect)(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function rn(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var dc={root:"dd-r-dgo"};var uc=({children:t,parentNode:e})=>{let[n,o]=(0,Hn.useState)(null),s=(0,Hn.useContext)(so);return(0,Hn.useLayoutEffect)(()=>{let r=document.createElement("div");return rn(r),r.classList.add(dc.root),s!=null&&s.portalRootNode&&r.classList.add(s==null?void 0:s.portalRootNode),(e||document.body).appendChild(r),o(r),()=>{r.isConnected&&r.remove()}},[]),n?(0,cc.createPortal)(t,n):null};var et={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};var Zs=require("react/jsx-runtime"),Ys=(t=!1)=>{let[e,n]=(0,Le.useState)(t),o=(0,Le.useCallback)(()=>n(!0),[]),s=(0,Le.useCallback)(()=>n(!1),[]),r=(0,Le.useCallback)(()=>n(a=>!a),[]),i=(0,Le.useRef)(null);return{opened:e,open:o,close:s,toggle:r,triggerRef:i}};function Qi(t,e=null,n=0){if(!t)return{display:"none"};let o=e?t.top-e.top<0||t.top<e.top-n?e.top-n:t.top+t.height>e.top+e.height+n?e.top+e.height+n-t.height:t.top:t.top,s=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:s,height:t.height,width:t.width}}var Bn=l=>{var d=l,{className:t,triggerRef:e,boundaryRef:n=(0,Le.createRef)(),position:o="above",align:s="center",children:r,toStyle:i=Qi,parentNode:a}=d,c=D(d,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let p=$i(e),u=$i(n),m=(0,Le.useMemo)(()=>i(p,u,0),[p,u]);return(0,Zs.jsx)(uc,{parentNode:a,children:(0,Zs.jsx)("div",b(h({className:(0,Gi.default)(et.ref,{[et.positionAbove]:o==="above",[et.positionBelow]:o==="below",[et.positionLeft]:o==="left",[et.positionRight]:o==="right",[et.alignStart]:s==="start",[et.alignCenter]:s==="center",[et.alignEnd]:s==="end"}),style:m},c),{role:"dialog",children:(0,Zs.jsx)("div",{className:(0,Gi.default)(t,et.root),children:r})}))})};var pc={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};var Me=require("react/jsx-runtime");function gf(t){return`<button type="button" data-copy-icon 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 Xi(t){var n,o;let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(s=>s.remove()),(o=(n=e.textContent)==null?void 0:n.trim())!=null?o:""}function mf(t){return t.replace(/\r\n/g,`
|
|
5
|
+
`)}var ff=({content:t,useLabel:e,copyLabel:n,onCopy:o,onUse:s,sources:r,onSourceClick:i})=>{let a=C("Markdown",pc),c=(0,mt.useRef)(null),[l,d]=(0,mt.useState)(null),p=(0,mt.useMemo)(()=>{let v=mc.marked.parse(mf(t));return gc.default.sanitize(v.toString()).replaceAll("</code>",`${gf(a.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[t]),u=v=>{var T;let x=v.target,w=!!((T=c.current)!=null&&T.querySelector("code"));if(["A","BUTTON"].includes(x.tagName)){d(null);return}l||w&&x.tagName!=="CODE"||!w&&x!==c.current||(x.addEventListener("mouseleave",()=>d(null),{once:!0}),d(x))},m=()=>{if(!l)return;d(null);let v=l.querySelector("button");v&&(Nt(v,a.fadeup),o==null||o(Xi(l)))},f=v=>{let x=v.target,w=x instanceof HTMLElement?x:null;if(x instanceof Element?x.closest("a"):null){v.stopPropagation();return}w&&"copyIcon"in w.dataset&&(Nt(w,a.fadeup),o==null||o(Xi(w.parentElement)))},g=()=>{!l||!s||(d(null),s(Xi(l)))},y=v=>{if(v===null)return;let x=v.getBoundingClientRect();x.left<0?v.style.transform=`translateX(${-x.left+2}px)`:x.right>window.innerWidth&&(v.style.transform=`translateX(${window.innerWidth-x.right-2}px)`)};return(0,Me.jsxs)(mt.Fragment,{children:[l&&(o||s)&&(0,Me.jsxs)(Bn,{triggerRef:{current:l},className:a.popover,parentNode:l,children:[(0,Me.jsxs)("div",{className:a.options,ref:y,children:[o&&(l==null?void 0:l.tagName)==="CODE"&&(0,Me.jsx)("button",{type:"button",className:a.option,onClick:m,children:n}),s&&(0,Me.jsxs)(mt.Fragment,{children:[(0,Me.jsx)("div",{className:a.divider}),(0,Me.jsx)("button",{type:"button",className:a.option,onClick:g,children:e})]})]}),(0,Me.jsx)("div",{className:a.arrow})]}),(0,Me.jsx)("div",{ref:c,"data-testid":"widget-markdown-content",className:a.root,dangerouslySetInnerHTML:{__html:p},onMouseOver:u,onClick:f}),r&&r.length>0&&(0,Me.jsx)(rc,{sources:r,onClick:i})]})},an=ff;var yc=require("react");var fc={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var hc=require("react/jsx-runtime"),hf=({width:t})=>{let e=C("LoadingProgressBar",fc);return(0,hc.jsx)("div",{className:e.loadingBar,style:{width:t}})},er=hf;var ft=require("react/jsx-runtime"),tr=({title:t})=>{let e=(0,yc.useRef)(null);return fs(e),(0,ft.jsx)(M,{ref:e,children:(0,ft.jsx)(B,{children:(0,ft.jsxs)(B.Content,{children:[(0,ft.jsx)(B.Title,{children:t}),(0,ft.jsx)(er,{width:"60%"}),(0,ft.jsx)(er,{width:"90%"}),(0,ft.jsx)(er,{width:"50%"})]})})})};var ln={};ee(ln,{enUS:()=>yf,nlNL:()=>vf});var yf={inputPlaceholder:[{type:0,value:"What is your question?"}],useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Submit"}],resetLabel:[{type:0,value:"Reset"}],resetError:[{type:0,value:"The conversation could not be reset. Please try again."}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},vf={inputPlaceholder:[{type:0,value:"Wat is je vraag?"}],useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Verzend"}],resetLabel:[{type:0,value:"Gesprek wissen"}],resetError:[{type:0,value:"Het gesprek kon niet worden gewist. Probeer het opnieuw."}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var nr={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",resetContainer:"dd-qKIDX",sources:"dd-xf9c6",source:"dd-a-vyX",tooltip:"dd-EsgcZ",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};var Sc=require("react");var vc={error:"dd-CoAuB"};var Ji={};ee(Ji,{enUS:()=>Sf,nlNL:()=>xf});var Sf={errorPrefix:[{type:0,value:"Error:"}]},xf={errorPrefix:[{type:0,value:"Foutmelding:"}]};var Po=require("react/jsx-runtime"),xc=({message:t})=>{let e=(0,Sc.useRef)(null),n=C("WidgetCardError",vc),o=A(Ji);return fs(e),(0,Po.jsx)(M,{ref:e,children:(0,Po.jsx)(B,{children:(0,Po.jsxs)(B.Content,{className:n.error,children:[o("errorPrefix")," ",t]})})})};var F=require("react/jsx-runtime"),bf=3,Cf=({sources:t,onClick:e})=>{let n=A(ln),o=C("WidgetKnowledgeAssistant",nr),[s,r]=(0,Q.useState)(!1),i=s?t:t.slice(0,bf);return i.length===0?null:(0,F.jsxs)("ul",{className:o.sources,children:[i.map(a=>(0,F.jsx)("li",{className:o.source,"data-testid":"knowledge-assist-source",children:(0,F.jsxs)($,{tooltip:!0,placement:"top-start",children:[(0,F.jsx)($.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:c=>{c.stopPropagation(),e(a)},children:(0,F.jsx)("span",{className:o.linkContent,children:a.name})}),a.url&&(0,F.jsx)($.Content,{className:o.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),i<t&&(0,F.jsx)("button",{type:"button",className:o.showMoreSources,onClick:()=>r(!0),children:n("showMore",{amount:t.length-i.length})})]})},wf=({title:t,description:e})=>(0,F.jsx)(M,{"data-testid":"knowledge-assist-empty-state",children:(0,F.jsx)(B,{children:(0,F.jsxs)(B.Content,{children:[(0,F.jsx)(B.Title,{children:t}),(0,F.jsx)(an,{content:e})]})})}),Tf=({innerRef:t,item:e,hasKeyboardInput:n,onCopy:o,onUse:s,onSourceClick:r})=>{var c;let i=A(ln),a=(0,Q.useContext)(sr);return(0,F.jsxs)(M,{"data-testid":"knowledge-assist-answer",ref:t,children:[(0,F.jsx)(B,{children:(0,F.jsxs)(B.Content,{children:[(0,F.jsx)(B.Title,{children:e.question}),(0,F.jsx)(an,{content:e.answer.answer,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:o,onUse:n?s:void 0}),(0,F.jsx)(Cf,{sources:(c=e.answer.sources)!=null?c:[],onClick:r})]})}),a.assistantCode&&(0,F.jsxs)(M.ButtonsContainer,{children:[(0,F.jsx)("div",{}),(0,F.jsx)(Qs,{evaluationId:e.evaluationId,feedbackType:"assistant",assistantCode:a.assistantCode,assistantOutput:e.answer.answer})]})]})},sr=(0,Q.createContext)(null),rr=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,onInitialQuestionConsumed:o,children:s,threadId:r,onThreadIdChange:i})=>{let[a,c]=(0,Q.useState)(null),l=r!==void 0?r:a,d=U=>{i&&i(U),r===void 0&&c(U)},p=A(ln),[u,m]=(0,Q.useState)(!1),[f,g]=(0,Q.useState)(!1),[y,v]=(0,Q.useState)(null),[x,w]=(0,Q.useState)(!!n),[T,k]=(0,Q.useState)(null),E=(0,or.useDispatch)(),I=J(),W=go(U=>{if(!t)throw new Error("No knowledge assistant was defined");return v(null),e({assistantCode:t,input:U,threadId:l,onNewThreadId(ce){d(ce)}})},{onSuccess(U){var ce;I("Assistant response displayed",{evaluationId:U.evaluationId,assistantCode:t,assistantOutput:U.answer.answer,input:U.question,sources:(ce=U.answer.sources)!=null?ce:[]}),w(!1)},onError(U){var ce;v((ce=U.message)!=null?ce:"Unknown error")}}),oe=()=>{l&&E(Dd(l)),t&&E(Hd({assistantCode:t})),d(null),t&&I("Assistant thread reset",{threadId:l!=null?l:void 0,assistantCode:t})},fe=go(Md,{onSuccess(){oe()},onError(){v(p("resetError"))}}),N=U=>S(null,null,function*(){m(!0),k(U),yield W.call(U),m(!1),k(null)}),H={isEnabled:!!t,assistantCode:t,isSubmitting:u,isResetting:f,threadId:l,pendingInput:T,errorMessage:y,onSubmit:N,onReset(){return S(this,null,function*(){if(!f){if(v(null),!t){oe();return}g(!0),yield fe.call({assistantCode:t}),g(!1)}})}};return(0,Q.useEffect)(()=>{!n||!H.isEnabled||N(n).finally(()=>{o==null||o()})},[n,t,H.isEnabled,o]),(0,F.jsx)(sr.Provider,{value:H,children:s})},ir=()=>{let t=A(ln),e=C("WidgetKnowledgeAssistant",nr),n=(0,Q.useContext)(sr),o=(0,Q.useRef)(null),[s,r]=(0,Q.useState)(""),i=c=>{r(c.target.value)},a=c=>{c.preventDefault(),n.onSubmit(s).then(()=>{var l;o.current&&((l=o.current)==null||l.focus(),r(""))})};return n.isEnabled?(0,F.jsxs)("form",{className:e.form,onSubmit:a,children:[(0,F.jsx)("input",{ref:o,className:e.formInput,placeholder:t("inputPlaceholder"),type:"text",disabled:n.isSubmitting||n.isResetting,value:s,onChange:i}),(0,F.jsx)("button",{type:"submit",disabled:n.isSubmitting||n.isResetting||s==="",className:e.formSubmit,children:t("submitLabel")})]}):null},ar=({title:t,emptyState:e})=>{var f,g;let n=A(ln),o=J(),s=C("WidgetKnowledgeAssistant",nr),r=(0,Q.useRef)(null),i=(0,Q.useContext)(sr),a=(g=(0,or.useSelector)(Pd((f=i.threadId)!=null?f:-1)))!=null?g:[],c=R("hasKeyboardInput"),l=ve(),d=(y,v)=>{Je(y),i.assistantCode&&o("Assistant response copied",{assistantCode:i.assistantCode,assistantOutput:y,copiedText:y,evaluationId:v.evaluationId})},p=(y,v)=>{i.assistantCode&&o("Assistant source clicked",{evaluationId:v.evaluationId,assistantCode:i.assistantCode,source:y})},u=y=>{y.preventDefault(),i.onReset()},m=(y,v)=>{l.send(ct,{text:y,suggestion:{source:"assistant",sourceText:y}}),i.assistantCode&&o("Assistant response used",{assistantCode:i.assistantCode,evaluationId:v.evaluationId,assistantOutput:v.answer.answer,usedText:y})};return!i.isEnabled||(a==null?void 0:a.length)===0&&!i.isSubmitting&&!e&&!i.errorMessage?null:(0,F.jsxs)(Q.Fragment,{children:[(0,F.jsx)(Qe,{type:"knowledge",title:t,"data-testid":"knowledge",children:(0,F.jsxs)(se,{withDivider:!0,children:[e&&a.length===0&&!i.pendingInput&&(0,F.jsx)(wf,h({},e)),a.map((y,v)=>(0,F.jsx)(Tf,{innerRef:v===a.length-1?r:void 0,item:y,hasKeyboardInput:c,onCopy:x=>d(x,y),onUse:x=>m(x,y),onSourceClick:x=>p(x,y)},`${y.question}_${y.answer}_${v}`)),i.pendingInput&&(0,F.jsx)(tr,{title:i.pendingInput}),i.errorMessage&&(0,F.jsx)(xc,{message:i.errorMessage})]})}),a.length>0&&(0,F.jsx)("div",{className:s.resetContainer,children:(0,F.jsx)(M.Button,{disabled:i.threadId===null||i.isSubmitting||i.isResetting,onClick:u,children:n("resetLabel")})})]})};var kt=require("react-dom/client");var Tc=_(require("react"));function lr(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}var Cc="queueMicrotask error",Ef=1e3,kf=8e3;function Rf(t){return lr(t)&&t.name==="TypeError"&&typeof t.message=="string"&&/queueMicrotask/.test(t.message)}function Pf(){try{return typeof window=="undefined"?"no-window":typeof window.queueMicrotask}catch(t){return"inaccessible"}}function If(){try{return typeof globalThis.queueMicrotask}catch(t){return"inaccessible"}}function Af(t){return{message:String(t.message).slice(0,Ef),stack:typeof t.stack=="string"?t.stack.slice(0,kf):null,typeofQueueMicrotask:typeof queueMicrotask,typeofWindowQueueMicrotask:Pf(),typeofGlobalThisQueueMicrotask:If()}}function wc(t,e){try{if(!Rf(t))return!1;let n=e(Af(t));return Promise.resolve(n).catch(()=>{}),!0}catch(n){return!1}}var dr=class extends Tc.default.Component{constructor(){super(...arguments);this.state={error:null,caught:!1,rethrow:!1}}static getDerivedStateFromError(n){return{error:n,caught:!0}}componentDidCatch(n){wc(n,this.props.report),this.setState({rethrow:!0})}render(){if(this.state.rethrow)throw this.state.error;return this.state.caught?null:this.props.children}};var xu=require("react");var ea=require("react-redux");var ur=_(require("classnames")),ze=require("react"),pr=require("react-redux");var cr=require("react");var Ec={root:"dd-tvkOF",content:"dd-eXA1D"};var Zi=require("react/jsx-runtime"),Lf=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:s,onKeyDown:r,overlayAriaLabel:i,contentAriaLabel:a})=>{let c=(0,cr.useRef)(null),l=C("Dialog",Ec),d=u=>{if(u.key==="Escape"){u.preventDefault(),u.stopPropagation(),s();return}r&&r(u)},p=u=>{u.target===c.current&&t&&o()};return(0,cr.useEffect)(()=>{var u,m;!c.current||!t||!e||(m=(u=c.current)==null?void 0:u.querySelector("input, textarea"))==null||m.focus()},[t,e,c]),t?(0,Zi.jsx)("div",{role:"dialog","data-testid":"dialog",className:l.root,"aria-label":i,ref:c,onKeyDown:d,onMouseDown:p,children:(0,Zi.jsx)("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:n})}):null},Un=Lf;var Rc=_(require("classnames"));var kc={root:"dd-ranhW"};var Pc=require("react/jsx-runtime"),Mf=o=>{var s=o,{className:t,value:e}=s,n=D(s,["className","value"]);let r=C("TextInput",kc);return(0,Pc.jsx)("input",h({className:(0,Rc.default)(t,r.root),type:"text",value:e},n))},Io=Mf;var Yi={};ee(Yi,{enUS:()=>Nf,nlNL:()=>Of});var Nf={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"}]},Of={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 Ic={root:"dd-lWxnE",anchorButton:"dd-TZ4in",errorMessage:"dd-fIsPg",title:"dd-pGhJx",subtitle:"dd-f5l29",text:"dd-iamoD",input:"dd-uhQZ3",actions:"dd-lubvx",button:"dd-CJsNI",primaryButton:"dd-MWBfl"};var Y=require("react/jsx-runtime");var Df=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch(e){return t}},_f=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:s})=>{let r=A(Yi),i=C("LoginTokenDialog",Ic),a=(0,pr.useSelector)(bl),c=(0,pr.useDispatch)(),l=R("productName"),[d,p]=(0,ze.useState)(t||""),[u,m]=(0,ze.useState)(0),[f,g]=(0,ze.useState)(""),y=(0,ze.useCallback)(T=>S(null,null,function*(){T.preventDefault(),c(Tl({email:d})),m(1)}),[n,d]),v=()=>{g(""),m(0)},x=(0,ze.useCallback)(T=>S(null,null,function*(){T.preventDefault();let k=Df(T.target.elements.token.value);if(!k){g(r("verifyCodeError",{login:w}));return}c(io({token:k}))}),[n]),w=(0,ze.useMemo)(()=>T=>(0,Y.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:v,children:T},"back-button"),[]);return(0,ze.useEffect)(()=>{a==="error"&&g(r("verifyCodeError",{login:w})),a==="done"&&o()},[a]),(0,Y.jsx)(Un,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:l}),overlayAriaLabel:r("promptTitle",{productName:l}),onClose:s,onBack:s,children:(0,Y.jsxs)("div",{className:i.root,children:[(0,Y.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:l})}),u===0&&(0,Y.jsxs)("form",{onSubmit:y,children:[(0,Y.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,Y.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:l})}),(0,Y.jsx)(Io,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:d,onChange:T=>p(T.target.value)}),(0,Y.jsx)("div",{className:i.actions,children:(0,Y.jsx)("button",{type:"submit",className:(0,ur.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&(0,Y.jsxs)("form",{onSubmit:x,children:[(0,Y.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,Y.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,Y.jsx)(Io,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&(0,Y.jsx)("div",{className:i.errorMessage,children:f}),(0,Y.jsxs)("div",{className:i.actions,children:[(0,Y.jsx)("button",{type:"button",className:(0,ur.default)(i.button),onClick:v,children:r("back")}),(0,Y.jsx)("button",{type:"submit",className:(0,ur.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Ac=_f;var Mc=require("react/jsx-runtime"),Ff=()=>{let t=(0,ea.useSelector)(Cl),e=(0,ea.useSelector)(Mn),n=R("adminUrl"),o=ve(),s=()=>o.send(Dn,!1),r=()=>{o.send(Dn,!1),o.send(po)};return(0,Mc.jsx)(Ac,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:s,onSuccess:r})},Lc=Ff;var vu=_(require("lodash.debounce")),Se=require("react"),tt=require("react-redux");var gr=require("@reduxjs/toolkit");var Hf={data:null,fetchState:"idle"},Nc=t=>t.contentTypes.data,Ao=(0,gr.createAsyncThunk)("contentTypes/getContentTypes",(t,e)=>S(null,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),Bf=(0,gr.createSlice)({name:"contentTypes",initialState:Hf,reducers:{},extraReducers:t=>{t.addCase(Ao.pending,e=>{e.fetchState="loading"}).addCase(Ao.rejected,e=>{e.fetchState="error"}).addCase(Ao.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),Oc=Bf.reducer;var ht=require("@reduxjs/toolkit");var Uf={data:null,fetchState:"idle",generation:0,inFlightRequestId:null},Dc=t=>{t.data=null,t.fetchState="idle",t.generation+=1,t.inFlightRequestId=null},Kf=[],Ne=t=>t.profile.data,Wf=t=>t.profile.data?t.profile.data.uiConfig.widget.types:Kf,Mo=(0,ht.createSelector)([Wf],t=>t.filter(e=>e.isActive)),_c=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},Fc=t=>e=>Mo(e).find(n=>n.type===t),Hc=t=>t.profile.data?!!t.profile.data.uiConfig.widget.types.find(e=>e.type==="custom-data"):!1,Bc=(0,ht.createSelector)([Ne],t=>{var o;let e=(o=t==null?void 0:t.widgetInteractiveAssistants)!=null?o:[];if(e.length>0)return[...e].sort((s,r)=>s.order-r.order||s.code.localeCompare(r.code));let n=t==null?void 0:t.knowledgeAssistantNew;return n?[{code:n,name:n,displayName:null,order:0}]:[]});var Kn="stale-profile-request",ta=(0,ht.createAction)("profile/clear"),Lo=(0,ht.createAsyncThunk)("profile/getProfile",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=e.getState(),s=o.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=s.profileCode,i=s.id,a=o.profile.generation,c=()=>{let p=e.getState(),u=p.conversation.current;return!u||u.id!==i||u.profileCode!==r||p.profile.generation!==a},l=e.getState().profile.data;if((l==null?void 0:l.code)===r)return c()?e.rejectWithValue(Kn):l;let d;try{d=yield n.getProfile(r)}catch(p){if(c())return e.rejectWithValue(Kn);throw p}if(c())return e.rejectWithValue(Kn);if(d.code!==r)throw new Error(`Profile response code "${d.code}" does not match requested "${r}"`);return d})),zf=(0,ht.createSlice)({name:"profile",initialState:Uf,reducers:{},extraReducers:t=>{t.addCase(Lo.pending,(e,n)=>{e.fetchState="loading",e.inFlightRequestId=n.meta.requestId}).addCase(Lo.rejected,(e,n)=>{if(n.payload===Kn){if(n.meta.requestId!==e.inFlightRequestId)return;e.inFlightRequestId=null,e.fetchState="idle";return}n.meta.requestId===e.inFlightRequestId&&(e.fetchState="error",e.inFlightRequestId=null)}).addCase(Lo.fulfilled,(e,n)=>{n.meta.requestId===e.inFlightRequestId&&(e.fetchState="done",e.data=n.payload,e.inFlightRequestId=null)}).addCase(q,Dc).addCase(ta,Dc)}}),Uc=zf.reducer;var vt=require("react");var Kc=require("react"),mr=_(require("classnames"));var Te={root:"dd-U2SX4",list:"dd-cYTlj",listWrapper:"dd-GLQFR",listHorizontal:"dd-x-knl",page:"dd-1F4vk",search:"dd-nvbxc",pageNav:"dd-sRUuT",pageTitle:"dd-t-MKS",pageBackButton:"dd-cjptm",listHeader:"dd-Fg666",listHeading:"dd-w-xhJ",listMoreButton:"dd--mKep",listItem:"dd-wpvuA",listItemContent:"dd-V-mKo",listItemText:"dd-ukCHL",listItemDescription:"dd-sSyu4",listItemActions:"dd-xelho",listItemTooltip:"dd-SWFsE",listItemTooltipContent:"dd-I7J9N",truncate:"dd-IlopJ",lineClamp:"dd-Twaca",listItemTitle:"dd-lMGHq",listItemAction:"dd-xPLAs",listItemSelected:"dd-jFX0Y",sources:"dd-pZx4v",sourcesTitle:"dd-phYVd",source:"dd-DaR6h",sourceShowMore:"dd-M1-8j",icon:"dd-m6yxD",searchIcon:"dd-0AU-O",searchInputWrapper:"dd-DUFcE",searchInput:"dd-ukrlD",select:"dd--Tifv",selectType:"dd-IkZb2",selectWrapper:"dd-J14mx",image:"dd-RQgsB",imageSrc:"dd-jxh8F",imageSrcHidden:"dd-e20Jk",imageSrcStatus:"dd-j50Tt",imageTitle:"dd-qCjfW",actions:"dd-3mfWc",actionsWrapper:"dd-TjDyI",actionsBar:"dd-LiA35",actionButton:"dd-4wk0u",hasShortKeys:"dd-XilV-",actionShortcut:"dd-s4Mla",actionShortcutFixKerning:"dd-lyh5e"};var yt={};ee(yt,{enUS:()=>Vf,nlNL:()=>jf});var Vf={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"}],sources:[{type:0,value:"Sources"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},jf={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"}],sources:[{type:0,value:"Bronnen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var Dt=require("react/jsx-runtime"),qf=({src:t,title:e})=>{let n=C("CommandPalette",Te),[o,s]=(0,Kc.useState)("loading"),r=A(yt);return(0,Dt.jsxs)("div",{className:n.image,children:[(0,Dt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,mr.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&(0,Dt.jsx)("span",{className:(0,mr.default)(n.imageSrc,n.imageSrcStatus),children:r("loading")}),o==="error"&&(0,Dt.jsx)("span",{className:(0,mr.default)(n.imageSrc,n.imageSrcStatus),children:(0,Dt.jsx)(us,{})}),e&&(0,Dt.jsx)("span",{className:n.imageTitle,children:e})]})},Wc=qf;var zc=_(require("react")),Vc=_(require("classnames"));var dn=require("react/jsx-runtime");function na({children:t,heading:e,orientation:n,hasMore:o,onShowAll:s}){let r=A(yt),i=C("CommandPalette",Te);return zc.default.Children.count(t)===0?null:(0,dn.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||o)&&(0,dn.jsxs)("div",{className:i.listHeader,children:[e&&(0,dn.jsx)("h4",{className:i.listHeading,children:e}),o&&s&&(0,dn.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,dn.jsx)("div",{className:(0,Vc.default)(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}var Oo=_(require("classnames")),ra=require("interweave"),_t=require("react");var $f=/[.*+?^${}()|[\]\\]/g,Gf=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Qf(t){return t.replace($f,"\\$&")}function Xf(t,e){let n=t.split("").findIndex((o,s)=>o!==e[s]);return n>-1?n:Math.min(t.length,e.length)}function Jf(t){return t.search(Gf)}function jc(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let s=new RegExp(`\\b(${Qf(o)})\\b`,"gi");n=n.replace(s,"<strong>$1</strong>")}),n}function qc(t){return t.replace(ys,'<mark data-type="placeholder">$1</mark>')}function Wn(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Zf(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 oa(t,e,n={}){if(e){let o=Xf(e.toLowerCase(),t.toLowerCase()),s=Wn(t.substring(o,t.length));if(n.stripAgentPart){let c=t.substring(0,o),l=Jf(c);return`<span style="opacity: 0.5">${c.substring(l+1)}</span>${s}`}let i=e.split(vl).length>3||e.length>30?Zf(e.trim(),o):0;return`${`${i>0?"\u2026":""}${Wn(t.substring(i,o))}`}<strong>${s}</strong>`}return t}var Yf=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function No(t){return Yf.test(t)}function sa(t){var n;let e=document.createElement("template");return e.innerHTML=t,(n=e.content.textContent)!=null?n:""}var fr=_(require("react")),Qc=require("react/jsx-runtime"),$c=fr.default.createContext(void 0);function zn(){let t=fr.default.useContext($c);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Gc=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r})=>{let i=fr.default.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r}),[n,e,s]);return(0,Qc.jsx)($c.Provider,{value:i,children:t})};var pe=require("react/jsx-runtime"),eh=3,th=90,Xc=({children:t})=>{let e=C("CommandPalette",Te);return(0,pe.jsx)("div",{className:e.listItemActions,children:t})};function ia(m){var f=m,{closeOnSelect:t=!0,lineClamp:e,tooltip:n,children:o,onClick:s,extra:r,onSourceClick:i,description:a,sources:c,id:l,styles:d,defaultSourcesAmount:p=eh}=f,u=D(f,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var fe;let g=A(yt),[y,v]=(0,_t.useState)(!1),{selected:x,onChangeOpen:w}=zn(),[T,k]=(0,_t.useState)(!1),E=C("CommandPalette",Te);function I(N){s(N),t&&w(!1)}let W=(0,_t.useMemo)(()=>typeof a!="string"?a:No(a)?sa(a).trim():a,[a]),oe=(0,_t.useMemo)(()=>typeof n!="string"?n:No(n)?sa(n).trim():n,[n]);return(0,_t.useEffect)(()=>{k(x===l)},[x]),(0,pe.jsxs)("div",{className:(0,Oo.default)(E.listItem,l===x&&E.listItemSelected),children:[(0,pe.jsxs)($,{placement:"right-start",tooltip:!0,onOpenChange:k,open:T,children:[(0,pe.jsx)($.Trigger,b(h({className:E.listItemAction,"aria-disabled":(fe=u.disabled)!=null?fe:!1,onClick:I,"data-command-palette-item":!0,"data-item-id":l},u),{children:(0,pe.jsxs)("div",{className:E.listItemContent,children:[typeof o=="string"?(0,pe.jsx)("p",{className:(0,Oo.default)(E.listItemText,E.truncate,d==null?void 0:d.title),children:o}):o,W&&typeof W=="string"?(0,pe.jsx)(ra.Interweave,{tagName:"p",allowList:[],content:W,className:(0,Oo.default)(E.listItemDescription,d==null?void 0:d.description,e?E.lineClamp:E.truncate)}):a]})})),oe&&oe.length>th&&(0,pe.jsx)($.Content,{className:E.listItemTooltip,disableFocusManager:!0,children:(0,pe.jsx)(ra.Interweave,{className:E.listItemTooltipContent,allowList:["h1","h2","h3","h4","h5","h6","a","p","br"],tagName:"div",content:oe.replace(/\n/g,"<br />")})})]}),l===x&&r,c&&c.length>0&&(0,pe.jsxs)("div",{className:E.sources,children:[(0,pe.jsx)("span",{className:E.sourcesTitle,children:g("sources")}),c.slice(0,y?c.length:p).map(N=>(0,pe.jsx)("a",{className:E.source,href:N.url,target:"_blank",title:N.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i==null?void 0:i(N),children:N.name},N.url)),!y&&c.length>p&&(0,pe.jsx)("button",{className:(0,Oo.default)(E.source,E.sourceShowMore),type:"button",onClick:()=>v(!0),children:g("showMore",{amount:c.length-p})})]})]})}var Do=require("react/jsx-runtime"),Jc=()=>(0,Do.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Do.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Do.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 cn=require("react/jsx-runtime");function aa({children:t,title:e,id:n,onDismiss:o}){let s=A(yt),r=C("CommandPalette",Te),{page:i}=zn();return i!==n?null:(0,cn.jsxs)("div",{className:r.page,id:`page_${n}`,tabIndex:-1,children:[o&&(0,cn.jsxs)("div",{className:r.pageNav,children:[(0,cn.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:o,children:[(0,cn.jsx)(Jc,{}),s("back")]}),e&&(0,cn.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var Zc=require("react");var _o=require("react/jsx-runtime"),Vn=()=>(0,_o.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,_o.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,_o.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});var Ve=require("react/jsx-runtime");function nh({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:s,value:r,selectedType:i},a){let c=C("CommandPalette",Te);return(0,Ve.jsxs)("div",{className:c.search,children:[(0,Ve.jsx)("div",{className:c.searchIcon,children:(0,Ve.jsx)(Vn,{})}),(0,Ve.jsxs)("div",{className:c.searchInputWrapper,children:[(0,Ve.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:l=>{t(l.currentTarget.value)},onFocus:l=>{l.currentTarget.select()},className:c.searchInput,placeholder:n,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&(0,Ve.jsx)("div",{className:c.selectWrapper,children:(0,Ve.jsxs)("select",{"data-testid":"command-palette-type-select",className:c.select,onChange:l=>e(l.target.value===o?void 0:l.target.value),value:i||o,children:[o&&(0,Ve.jsx)("option",{children:o}),s.map(l=>(0,Ve.jsx)("option",{value:l.value,children:l.label},l.value))]})})]})]})}var Yc=(0,Zc.forwardRef)(nh);var la=_(require("classnames"));var hr=require("react/jsx-runtime"),oh=s=>{var r=s,{onClick:t,shortKeys:e,children:n}=r,o=D(r,["onClick","shortKeys","children"]);let i=C("CommandPalette",Te);return(0,hr.jsxs)("button",b(h({type:"button"},o),{onClick:t,className:(0,la.default)(i.actionButton,o.className,{[i.hasShortKeys]:e&&e.length>0}),children:[n,e==null?void 0:e.map(a=>(0,hr.jsx)("span",{className:(0,la.default)(i.actionShortcut,a===8629&&i.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},eu=oh;var Fo=require("react/jsx-runtime"),sh="[data-command-palette-item]";function un({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:c,types:l,children:d,isOpen:p,search:u,updateDeps:m=[]}){let[f,g]=(0,vt.useState)(),y=(0,vt.useRef)(null),v=()=>{s&&s(n),i(void 0),r(""),a(!1)},x=()=>{var N;if(o!==n&&s){s(n);return}if(c&&i){i(void 0),(N=y.current)==null||N.focus();return}if(u.length>0){r("");return}a(!1)},w=()=>{let N=T();N.length!==0&&g(N[0].dataset.itemId)},T=()=>Array.from(document.querySelectorAll(sh)||[]),k=N=>document.querySelector(`[data-item-id=${N}]`),E=N=>{let H=k(N);H&&g(H.dataset.itemId)},I=N=>{let H=k(N);H&&H.scrollIntoView({behavior:"smooth"})},W=()=>{if(!f)return;let N=T(),H=k(f);if(!H)return;let Ge=N.indexOf(H),U=N[Ge+1];U!=null&&U.dataset.itemId?E(U.dataset.itemId):w()},oe=()=>{if(!f)return;let N=T(),H=k(f);if(!H)return;let Ge=N.indexOf(H),U=N[Ge-1];U!=null&&U.dataset.itemId?E(U.dataset.itemId):E(N[N.length-1].dataset.itemId)},fe=(0,vt.useCallback)(N=>{switch(N.key){case"ArrowDown":{N.preventDefault(),W();break}case"ArrowUp":{N.preventDefault(),oe();break}case"Enter":{if(f){let H=k(f);H==null||H.click()}break}}},[f]);return(0,vt.useEffect)(()=>{w()},[u,o,c,p,...m]),(0,vt.useEffect)(()=>{f&&I(f)},[f]),(0,Fo.jsx)(Un,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:x,onClose:v,onKeyDown:fe,children:(0,Fo.jsxs)(Gc,{selected:f,setSelected:g,isOpen:p,onChangeOpen:a,page:o,children:[o===n&&(0,Fo.jsx)(Yc,{ref:y,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:c,types:l,typePlaceholder:e}),d]})})}un.Page=aa;un.List=na;un.Image=Wc;un.ListItem=ia;un.ListItemActions=Xc;un.Button=eu;var ne=un;var tu=require("react");function nu(t,e){(0,tu.useEffect)(()=>{let n=o=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var Ho=require("react"),vr=require("react-redux");var jn=require("@reduxjs/toolkit");var ou={data:null,fetchState:"idle"},rh=t=>{var e;return(e=t.entities.data)!=null?e:null},yr=(0,jn.createSelector)([rh,Mn,Ql],(t,e,n)=>{var a;let o=[],{visitorName:s}=n!=null?n:{},{agentName:r,agentNickname:i}=e!=null?e:{};return r&&r!==s&&o.push(r),i&&i!==s&&o.push(i),(a=t==null?void 0:t.filter(c=>!o.includes(c.text)))!=null?a:null}),je=(0,jn.createAsyncThunk)("entities/getEntities",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let s=o.conversationQuery,r=yield s();return r.length===0?Promise.resolve([]):n.getEntities(r)})),ih=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),ah=(0,jn.createSlice)({name:"entities",initialState:ou,reducers:{},extraReducers:t=>{t.addCase(je.pending,e=>{e.fetchState="loading"}).addCase(je.rejected,e=>{e.fetchState="error"}).addCase(je.fulfilled,(e,n)=>{e.fetchState="done",e.data=ih(e.data?[...e.data,...n.payload]:n.payload)}).addCase(q,()=>ou)}}),su=ah.reducer;var da={};ee(da,{enUS:()=>lh,nlNL:()=>dh});var lh={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},dh={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var ru={root:"dd-TYTKs",empty:"dd-AU7uT"};var qn=require("react/jsx-runtime"),ch=({onCopy:t})=>{let e=(0,Ho.useRef)(null),n=C("EntitiesList",ru),o=(0,vr.useSelector)(yr),{setSelected:s}=zn(),r=A(da),i=(0,vr.useDispatch)();return(0,Ho.useEffect)(()=>{i(je())},[]),(0,Ho.useEffect)(()=>{e.current&&(e.current.focus(),s("entity-0"))},[e]),(0,qn.jsxs)("div",{className:n.root,ref:e,tabIndex:-1,children:[o&&o.length>0&&(0,qn.jsx)(ne.List,{children:o.map((a,c)=>(0,qn.jsx)(ne.ListItem,{id:`entity-${c}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),o&&o.length===0&&(0,qn.jsx)("p",{className:n.empty,children:r("noResults")})]})},iu=ch;var ca=require("react/jsx-runtime"),Sr=t=>(0,ca.jsx)("svg",b(h({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},t),{children:(0,ca.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 Bo={};ee(Bo,{enUS:()=>uh,nlNL:()=>ph});var uh={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"}]},ph={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 au=require("react-redux");var Uo={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var Ft=require("react/jsx-runtime"),gh=({suggestion:t,source:e,context:n})=>{let o=A(Bo),s=(0,au.useSelector)(Pe),r=J(),i=R("enableSuggestionFeedback"),a=qs({conversationId:s,type:e,contentType:"text",content:t.text,data:n?JSON.stringify({context:n}):void 0}),c=Gs(a),l=()=>S(null,null,function*(){r("suggestion feedback",{text:t.text,source:e,context:n}),c.mode==="custom-handler"&&(yield c.open())});return!i||c.mode==="disabled"?null:(0,Ft.jsxs)($,{placement:"top-end",children:[(0,Ft.jsx)($.Trigger,{className:Uo.trigger,children:(0,Ft.jsx)(Sr,{"data-testid":"feedback-dropdown-trigger"})}),(0,Ft.jsx)($.Content,{className:Uo.content,children:c.mode==="custom-handler"?(0,Ft.jsx)($.Button,{className:Uo.item,onClick:l,children:o("giveFeedback")}):(0,Ft.jsx)($.Button,{className:Uo.item,as:"a",onClick:l,target:"_blank",rel:"noreferrer noopener",href:c.href,children:o("giveFeedback")})})]})},xr=gh;var Ko={};ee(Ko,{enUS:()=>mh,nlNL:()=>fh});var mh={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"URL 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"}],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?"}]},fh={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:"URL 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"}],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 hu=require("react"),wr=require("react-redux");var pn=require("@reduxjs/toolkit");var hh=["{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}"],yh=new RegExp(hh.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function lu(t,e){let n=t.split(yh),o=0,s=[];for(let r=0;r<n.length;r++){let i=n[r];if(s.push(i),r===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[r+1],c=r===n.length-2;o+=i.length;let l=o;if(c){let p=a.charAt(0),u=0;do l=p?e.indexOf(p,l+1):-1,u+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&u>2)return t}else l=a&&a!==""?e.indexOf(a,o):-1;let d=l===-1?e.slice(o):e.slice(o,l);s.push(d),o=l}return s.join("")}function du(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var uu={suggestions:[],fetchState:"idle"},cu={default:uu},pu=t=>e=>{var n,o;return(o=(n=e.textSuggestions[t])==null?void 0:n.suggestions)!=null?o:[]},br=t=>t.textSuggestions,gu=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Cr=(0,pn.createAction)("textSuggestions/refresh"),qe=(0,pn.createAsyncThunk)("textSuggestions/recommendations",(t,e)=>S(null,null,function*(){var d,p,u;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:s}=o.info,{textSuggestionsCount:r,inlineSuggestions:i}=o.settings,a=Xt(o),c=(d=o.conversation.current)==null?void 0:d.id;if(!c)throw new Error("No current conversation to fetch text suggestions");if(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];let l=[];if(t==="sticky-messages"){let m=(u=o.profile.data)==null?void 0:u.code;if(!m)throw new Error("No current profile to fetch pinned messages");l=yield n.getPinnedMessages(m)}else l=yield n.getTextSuggestions(c,uo(o),t);if(s&&(l=l.map(m=>h(b(h({},m),{text:Ue(m.text,s)}),m.title?{title:Ue(m.title,s)}:{}))),t==="default"){let m=i?l.filter(gu(a)):l;e.dispatch(Mt(m.slice(0,r)))}return l})),Wo=(0,pn.createAsyncThunk)("textSuggestions/autocompletions",(t,e)=>S(null,null,function*(){var d,p;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(d=o.conversation.current)==null?void 0:d.id,{platformVariables:r}=o.info,{textSuggestionsCount:i,deanonymize:a,inlineSuggestions:c}=o.settings;if(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];if(!s)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(s,b(h({},uo(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return c&&(l=l.filter(gu(t))),r&&(l=l.map(u=>b(h({},u),{text:Ue(u.text,r)}))),a&&(l=l.map(u=>b(h({},u),{text:u.source!=="trie-with-typos"?lu(u.text,t):u.text}))),l=du(l,i),e.dispatch(Mt(l)),l})),mu=(0,pn.createSlice)({name:"textSuggestions",initialState:cu,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:n}=e.payload;t[n].fetchState="done",t[n].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}}},extraReducers:t=>{t.addCase(qe.pending,(e,n)=>{let o=n.meta.arg,s=e[o]||uu;return b(h({},e),{[o]:b(h({},s),{fetchState:"loading"})})}).addCase(qe.rejected,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="error")}).addCase(qe.fulfilled,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="done",e[o].suggestions=n.payload)}).addCase(Wo.pending,e=>{e.default.fetchState="loading"}).addCase(Wo.rejected,e=>{e.default.fetchState="error"}).addCase(Wo.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(q,()=>cu)}}),{setTextSuggestions:E1}=mu.actions,fu=mu.reducer;var gn=require("react/jsx-runtime"),vh=({types:t,commands:e,onClick:n})=>{let o=(0,wr.useDispatch)(),s=A(Ko),r=(0,wr.useSelector)(br);return(0,hu.useEffect)(()=>{t.forEach(({type:i})=>{(!r[i]||r[i].suggestions.length===0)&&o(qe(i))})},[]),(0,gn.jsxs)("div",{children:[e.length>0&&(0,gn.jsx)(ne.List,{heading:s("commands"),children:e.map((i,a)=>(0,gn.jsx)(ne.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:i.onClick,children:i.label},i.label))}),t.map(({type:i,title:a})=>{var c;return(0,gn.jsx)(ne.List,{heading:a,orientation:"vertical",children:(c=r[i])==null?void 0:c.suggestions.map((l,d)=>(0,gn.jsx)(ne.ListItem,{id:`${i}-${d}`,closeOnSelect:!1,description:l.title&&l.text,onClick:()=>n(l.text,l),"data-testid":"search-overlay-suggestion",children:l.title||l.text},`${l.id}-${l.text}`))},i)})]})},yu=vh;var ge=require("react/jsx-runtime"),xh=200,bh=5,Ch=4,ua=(t,e,n)=>t.slice(0,n?10:e.toLowerCase()==="image"?Ch:bh),wh=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Th=()=>{var Ge,U,ce;let t=(0,tt.useDispatch)(),e=ve(),n=A(Ko),[o,s]=(0,Se.useState)(!1),[r,i]=(0,Se.useState)(""),a=(0,tt.useSelector)(rd),c=(0,tt.useSelector)(Ne),[l,d]=(0,Se.useState)(),p=(0,tt.useSelector)(re),u=R("showSearch"),m=R("enableSuggestionFeedback"),f=R("showEntitiesCommand"),g=R("showImageSearch"),y=R("searchTriggerKey"),v=(0,tt.useSelector)(Nc),x=(0,tt.useSelector)(Ti),w=(0,tt.useSelector)(id),T=(0,tt.useSelector)(sd),k=((ce=(U=(Ge=c==null?void 0:c.uiConfig)==null?void 0:Ge.search)==null?void 0:U.initialTypes)==null?void 0:ce.filter(({isActive:O})=>O))||[],E=J(),I=(0,Se.useMemo)(()=>{let O=he=>ua(x.filter(Z=>Z.type===he.toUpperCase()),he,l),X=(v==null?void 0:v.map(he=>({value:he.code.toUpperCase(),label:`${he.name}s`,list:O(he.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(X.push({value:"PERSONAL",label:n("personalSuggestions"),list:O("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:O("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:O("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),g&&X.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:O("IMAGE"),listOrientation:"horizontal"}),k.length===0)return X;let lt=k.map(he=>X.find(Z=>Z.value.toLowerCase()===he.type)).filter(he=>!!he),Tn=X.filter(he=>!lt.find(Z=>Z.value===he.value));return[...lt,...Tn]},[v,k,g,l]),W=[{label:n("entitiesClipboard"),onClick:()=>t(On("entities")),shouldShow:f&&wh(n("entitiesClipboard"),r)}].filter(O=>O.shouldShow).filter(()=>!l),oe=(0,Se.useCallback)((0,vu.default)((O,X)=>{t(tn({query:O,type:X,tags:["search-overlay"],size:l?50:20}))},xh),[l]),fe=(0,Se.useCallback)((O,X)=>{X.type==="IMAGE"?e.send(ki,{suggestion:X}):e.send(ct,{text:O,suggestion:X}),t(Ke(!1))},[t]),N=O=>{Je(O.text),E("entity copied",{entity:O,type:"copy"}),t(Ke(!1))};function H(O){return X=>{o?window.confirm(n("warning"))&&(O(X),s(!1)):O(X)}}return(0,Se.useEffect)(()=>{r?oe(r,l):t(As())},[r,l]),(0,Se.useEffect)(()=>{p&&t(Ao())},[p]),nu(y,()=>{t(Ke(!0)),E("open search",{via:"ctrl+k"})}),!u||!c?null:(0,ge.jsxs)(ne,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:H(O=>t(Ke(O))),onChangeType:O=>d(O),onChangePage:H(O=>t(On(O))),selectedType:l,search:r,page:a,isOpen:T,types:I,updateDeps:[x],children:[(0,ge.jsxs)(ne.Page,{id:"search",children:[r.length===0&&(0,ge.jsx)(yu,{types:k,commands:W,onClick:fe}),r.length>0&&(0,ge.jsxs)(Se.Fragment,{children:[W.length>0&&(0,ge.jsx)(ne.List,{heading:n("commands"),children:W.map((O,X)=>(0,ge.jsx)(ne.ListItem,{closeOnSelect:!1,onClick:O.onClick,id:`commands-${X}`,children:O.label},O.label))}),I.map(({value:O,label:X,list:lt,lineClamp:Tn,listOrientation:he})=>(0,ge.jsx)(ne.List,{heading:X,orientation:he==="horizontal"?"horizontal":"vertical",onShowAll:()=>d(O),hasMore:!l&&w[O.toLowerCase()]>ua(lt,O,l).length,children:ua(lt,O,l).map(Z=>(0,ge.jsx)(ne.ListItem,{id:`${O}-${Z.id}`,closeOnSelect:!1,lineClamp:Tn,onClick:()=>fe(Z.text,Z),description:O!=="IMAGE"?Z.title&&Z.text:void 0,tooltip:Z.text,extra:m&&(0,ge.jsx)(ne.ListItemActions,{children:(0,ge.jsx)(xr,{context:r,source:"search",suggestion:Z})}),children:O==="IMAGE"?(0,ge.jsx)(ne.Image,{title:Z.title||Z.text,src:Z.image}):Z.title||Z.text},`${Z.id}-${Z.text}`))},O))]})]}),(0,ge.jsx)(ne.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:H(()=>{t(On("search"))}),children:(0,ge.jsx)(iu,{onCopy:N})})]})},Su=Th;var zo=require("react/jsx-runtime"),Eh=()=>{let t=R("showSearch"),e=R("isEmbedded");return(0,zo.jsxs)(xu.Fragment,{children:[t&&(0,zo.jsx)(Su,{}),e&&(0,zo.jsx)(Lc,{})]})},bu=Eh;var Eu=_(require("classnames")),ku=require("react-redux");var Tr=require("react/jsx-runtime"),Cu=({className:t})=>(0,Tr.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,Tr.jsx)("g",{children:(0,Tr.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
6
6
|
c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
|
|
7
7
|
c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
|
|
8
8
|
c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
|
|
9
|
-
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var pa=require("react/jsx-runtime"),Eh={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Cu=({className:t,color:e})=>(0,pa.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,pa.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:Eh[e||"pink"]})});var wu={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var ga={};ee(ga,{enUS:()=>kh,nlNL:()=>Rh});var kh={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Rh={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var ku=require("react-redux"),gn=require("react/jsx-runtime"),Ru=({onLogIn:t})=>{let e=A(ga),n=R("floatingMenu"),o=R("productName"),s=(0,ku.useDispatch)(),r=(0,Eu.useSelector)(re),i=C("FloatingMenu",wu);if(r===null||n===!1)return null;let a=()=>{r===!0?s(Ue(!0)):t()};return(0,gn.jsxs)("button",{type:"button",className:(0,Tu.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,gn.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:o})}),(0,gn.jsxs)("div",{className:i.icon,children:[(0,gn.jsx)(Cu,{className:i.logo,color:"pink"}),r===!1&&(0,gn.jsx)(bu,{className:i.lock})]})]})};var Nr=require("react"),nt=require("react-redux");function tt(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:s,selection:r}=t.input;return r.end<t.input.suggestionTextStart||r.start!==r.end?!1:r.end>=s.length?!0:e?n&&new RegExp(n).test(s.substring(r.end))||o&&new RegExp(o).test(s.substring(0,r.end))?!0:n===!1&&o===!1:!1}var Pu=require("@reduxjs/toolkit"),Ph={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Er=({ui:t})=>t.overlayCollapsed,Iu=(0,Pu.createSlice)({name:"ui",initialState:Ph,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputFocus(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:Wo,setInputFocus:kr,setOverlayCollapsed:Ft,setOpenOverlayWhenTyping:Au,setOverlayCollapsedUserOverwrite:Lu}=Iu.actions,Mu=Iu.reducer;var Nu={styleRow:"dd-prYfH",styleSuggestion:"dd-JTmXy"};var zo=require("react/jsx-runtime"),Ih=({match:t,selected:e,styles:n})=>(0,zo.jsx)(M,{as:"button",selected:e,className:n.styleRow,"data-testid":"style-suggestion-item",title:t.suggestion,children:(0,zo.jsx)("span",{className:n.styleSuggestion,children:t.suggestion})}),Ah=({matches:t,selectedIndex:e})=>{let n=C("StyleSuggestionList",Nu);return(0,zo.jsx)(se,{children:t.map((o,s)=>(0,zo.jsx)(Ih,{match:o,selected:e===s,styles:n},`${o.keyword}-${s}`))})},Rr=Ah;var Bu=require("react");var fa=require("interweave"),Ht=require("react"),jo=require("react-redux");var Ou=require("react");function Du(t,e,n){(0,Ou.useEffect)(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var _u={root:"dd-1MBCO",actions:"dd--x4cy",closeIconContainer:"dd-1z5NR",closeIcon:"dd-8qMF-",badge:"dd-4Fpkz",formattedText:"dd-EzvTB",assistantContainer:"dd-j6o8F",formattedTextTruncated:"dd-fv169",assistantBadge:"dd-VD57E"};var Vo=require("react/jsx-runtime"),Fu=({title:t})=>(0,Vo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24","aria-labelledby":"closeTitle",children:[(0,Vo.jsx)("title",{id:"closeTitle",children:t}),(0,Vo.jsx)("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})]});var ma={};ee(ma,{enUS:()=>Lh,nlNL:()=>Mh});var Lh={assistant:[{type:0,value:"Assistant"}],close:[{type:0,value:"Close"}]},Mh={assistant:[{type:0,value:"Assistent"}],close:[{type:0,value:"Sluiten"}]};var we=require("react/jsx-runtime"),Oh=["search","personal-collection-search","search-autocomplete"];function Dh(t,e,n,o={}){var r;let s="";return Oh.includes(e)?s=Vc(oa(t,n,{stripAgentPart:!0}),(r=o.searchKeywords)!=null?r:[n]):s=oa(t,n,o),o.placeholders===!0&&(s=jc(s)),s}var _h=()=>{},Fh=({selected:t,suggestion:e})=>{let n=A(ma),o=R("inlineSuggestions"),s=(0,jo.useSelector)(Xt),[r,i]=(0,Ht.useState)(!1),a=R("enableSuggestionFeedback"),c=(0,jo.useSelector)(y=>y.input.text),l=(0,jo.useDispatch)(),d=C("TextSuggestion",_u),p=(0,Ht.useRef)(null),u=e.source==="assistant",m=a&&!u;(0,Ht.useEffect)(()=>{let y=setTimeout(()=>{l(Hl({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(y)}},[e]),Du(p,"click",()=>{l(Se({suggestion:e,text:e.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let f=()=>{l(Zt({source:e.source,text:e.text,assistantCode:e.assistantCode}))},g=(0,Ht.useMemo)(()=>Dh(e.text,e.source,s,{stripAgentPart:o,placeholders:!0,searchKeywords:e.searchKeywords}),[o,e.text,e.source,s,e.searchKeywords]);return e.source==="gpt"&&!o?null:(0,we.jsxs)("div",{className:d.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,we.jsx)(M,{ref:p,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:_h,children:e.source==="assistant"?(0,we.jsxs)("div",{className:d.assistantContainer,children:[(0,we.jsx)(fa.Interweave,{containerTagName:"div",tagName:"span",className:d.formattedTextTruncated,content:g}),(0,we.jsx)("span",{className:d.assistantBadge,children:n("assistant")})]}):(0,we.jsx)(fa.Interweave,{containerTagName:"div",tagName:"span",className:d.formattedText,content:g})}),m&&r&&(0,we.jsx)("div",{className:d.actions,children:(0,we.jsx)(xr,{source:"overlay",context:c,suggestion:e})}),u&&r&&(0,we.jsx)("div",{className:d.closeIconContainer,children:(0,we.jsx)("button",{type:"button",className:d.closeIcon,onClick:f,title:n("close"),children:(0,we.jsx)(Fu,{title:n("close")})})})]})},Hu=Fh;var Uu=require("react/jsx-runtime"),Hh=({suggestions:t,selectedIndex:e,reverse:n})=>(0,Bu.useMemo)(()=>{let s=t.map((r,i)=>(0,Uu.jsx)(Hu,{index:i,selected:i===e,suggestion:r},`${r.text}-${r.source}`));return n?s.reverse():s},[t,e,n]),Pr=Hh;var Ku={root:"dd-PfvRI",paper:"dd-HYlyY"};var Ar=require("@reduxjs/toolkit");var Ir={list:{keywordMatches:[]},fetchState:"idle"},Lr=t=>t.styleSuggestions.list,mn=(0,Ar.createAsyncThunk)("styleSuggestions/getAll",(n,o)=>S(null,[n,o],function*({text:t},e){var c;let{deepdeskAPI:s}=e.extra,r=e.getState(),{showStyleSuggestions:i}=r.settings,a=(c=r.conversation.current)==null?void 0:c.profileCode;if(!i)return Ir.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return s.getStyleSuggestions({profileCode:a,message:t})})),Wu=(0,Ar.createSlice)({name:"styleSuggestions",initialState:Ir,reducers:{commitStyleSuggestion(t,e){let{keyword:n,suggestion:o}=e.payload;t.list.keywordMatches=t.list.keywordMatches.filter(s=>s.keyword.toLowerCase()!==n.toLowerCase()||s.suggestion!==o)}},extraReducers:t=>{t.addCase(mn.pending,e=>{e.fetchState="loading"}).addCase(mn.rejected,e=>{e.fetchState="error"}).addCase(mn.fulfilled,(e,n)=>{e.fetchState="done",It(e.list,n.payload)||(e.list=n.payload)}).addCase(Yt,e=>{e.list=Ir.list}).addCase(j,()=>Ir)}}),{commitStyleSuggestion:zu}=Wu.actions,Vu=Wu.reducer;var Mr=t=>{let e=new Set;return t.filter(({keyword:n,suggestion:o})=>{let s=JSON.stringify([n.toLowerCase(),o]);return e.has(s)?!1:(e.add(s),!0)})};var fn=require("react/jsx-runtime"),Bh=()=>{var y;let t=(0,Nr.useRef)(null),e=C("InlineSuggestionsOverlay",Ku),n=(0,nt.useSelector)(tt),o=(0,nt.useDispatch)(),s=(0,nt.useSelector)(re),r=(0,nt.useSelector)(Pn),i=(0,nt.useSelector)(Er),a=R("showTextSuggestions"),c=(0,nt.useSelector)(Jt),l=(0,nt.useSelector)(ao),d=R("showStyleSuggestions"),p=R("showStyleSuggestionList"),u=(0,nt.useSelector)(Lr),m=d&&p?Mr((y=u.keywordMatches)!=null?y:[]):[],f=m.length>0,g=a&&c.length>0;return Nt(()=>{setTimeout(()=>{o(Ft({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Nr.useEffect)(()=>{let v=t.current;if(!v||!v.parentElement)return;v.parentElement.style.left="0px";let x=v.getBoundingClientRect();v.parentElement.style.left=`${Math.min(window.innerWidth-4-x.right,0)}px`}),i||s!==!0||r===!1||!n&&!f||!g&&!f?null:(0,fn.jsx)("div",{className:e.root,"data-variant":"inline",children:(0,fn.jsxs)("div",{ref:t,className:e.paper,children:[f&&(0,fn.jsx)(Rr,{matches:m,selectedIndex:-1}),g&&(0,fn.jsx)(se,{children:(0,fn.jsx)(Pr,{suggestions:c,selectedIndex:l})})]})})},ju=Bh;var Bt=F(require("react"));var qu={root:"dd-7zvcP",dialogContent:"dd-4C0lK",continueButton:"dd-YUPQW",buttonContinueWrapper:"dd-IKpYs",nicknameInput:"dd-rxhGp",titleWrapper:"dd-nw3nD",title:"dd-5iof5",closeButtonWrapper:"dd-UUAzA",closeButton:"dd-7rjP5",buttonsWrapper:"dd-5e9Xb",errorMessage:"dd--5VgX",errorLink:"dd-u461n"};var $u=require("react-redux");var ha={};ee(ha,{enUS:()=>Uh,nlNL:()=>Kh});var Uh={title:[{type:0,value:"Enter your nickname"}],close:[{type:0,value:"Close"}],nicknameDialogTitle:[{type:0,value:"Please enter the name you'd like customers to see during chat conversations. This nickname will be used across your Deepdesk environment."}],nicknameDialogInputPlaceholder:[{type:0,value:"Enter your nickname"}],nicknameDialogContinueButton:[{type:0,value:"Continue"}],nicknameDialogError:[{type:0,value:"Nickname cannot be empty or spaces only"}],nicknameDialogEmojiError:[{type:0,value:"You cannot use emojis in this field."}],nicknameDialogSaveError:[{type:0,value:"We couldn't save your details just now. Please try again, or update it at "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We couldn\u2019t save your details just now. Please try again later, or update them in My Deepdesk \u2192 Settings."}]},Kh={title:[{type:0,value:"Voer je bijnaam in"}],close:[{type:0,value:"Sluiten"}],nicknameDialogTitle:[{type:0,value:"Voer de naam in die je wilt dat klanten zien tijdens chatgesprekken. Deze bijnaam wordt gebruikt in je Deepdesk-omgeving."}],nicknameDialogInputPlaceholder:[{type:0,value:"Voer je bijnaam in"}],nicknameDialogContinueButton:[{type:0,value:"Doorgaan"}],nicknameDialogError:[{type:0,value:"Bijnaam mag niet leeg of alleen spaties zijn"}],nicknameDialogEmojiError:[{type:0,value:"Je kunt geen emoji's gebruiken in dit veld."}],nicknameDialogSaveError:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw of werk het bij op "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw later, of werk ze bij in My Deepdesk \u2192 Instellingen."}]};var te=require("react/jsx-runtime"),Gu=({onClose:t,onSave:e,id:n,error:o})=>{let[s,r]=(0,Bt.useState)(""),[i,a]=(0,Bt.useState)(!1),[c,l]=(0,Bt.useState)(!1),d=C("Nickname",qu),p=Bt.default.useRef(null),u=(0,$u.useSelector)(v=>v.info.showNicknameDialog),m=A(ha),f=R("adminUrl");(0,Bt.useEffect)(()=>{o&&a(!0)},[o]);let g=()=>{if(!p.current)return;s.trim()?p.current.setCustomValidity(""):p.current.setCustomValidity(m("nicknameDialogError")),p.current.reportValidity()},y=v=>{v.preventDefault();let x=s.trim(),w=v.currentTarget.querySelector("#nickname-input");if(!x){w.setCustomValidity(m("nicknameDialogError")),w.reportValidity();return}w.setCustomValidity(""),e(x)};return(0,te.jsxs)(Un,{isOpen:u,"datatest-id":n,onClose:t||(()=>{}),onBack:t||(()=>{}),children:[(0,te.jsx)("div",{className:d.titleWrapper,children:(0,te.jsx)("h1",{className:d.title,children:m("title")})}),(0,te.jsxs)("form",{className:d.dialogContent,onSubmit:y,children:[(0,te.jsx)("p",{children:m("nicknameDialogTitle")}),i&&o&&(0,te.jsx)("div",{className:d.errorMessage,children:f?(()=>{let v=m("nicknameDialogSaveError",{account:f}),x=`${f}.deepdesk.com/admin/user-settings`,w=v.indexOf(x);if(w!==-1){let T=v.substring(0,w),k=v.substring(w+x.length);return(0,te.jsxs)(te.Fragment,{children:[T,(0,te.jsx)("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:d.errorLink,children:x}),k]})}return v})():m("nicknameDialogSaveErrorWithoutLink")}),(0,te.jsx)("input",{required:!0,minLength:1,maxLength:20,"data-testid":"nickname-input",id:"nickname-input",className:d.nicknameInput,type:"text",placeholder:m("nicknameDialogInputPlaceholder"),value:s,onChange:v=>{l(new RegExp("\\p{Extended_Pictographic}","u").test(v.target.value)),r(v.target.value)},onBlur:g,ref:p}),c&&(0,te.jsx)("div",{className:d.errorMessage,role:"alert",children:m("nicknameDialogEmojiError")}),(0,te.jsxs)("div",{className:d.buttonsWrapper,children:[o?(0,te.jsx)("div",{className:d.closeButtonWrapper,children:(0,te.jsx)("button",{type:"button",className:d.closeButton,onClick:()=>t==null?void 0:t(),children:m("close")})}):null,(0,te.jsx)("div",{className:d.buttonContinueWrapper,children:(0,te.jsx)("button",{type:"submit",className:d.continueButton,disabled:!s.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(s),children:m("nicknameDialogContinueButton")})})]})]})]})};var Qu=require("react-redux");var qo=require("react/jsx-runtime"),Wh=({children:t})=>{let n=R("locale").replace("-","");return(0,qo.jsx)(Di.Provider,{value:n,children:t})},zh=({store:t,customStyles:e={},children:n})=>(0,qo.jsx)(Qu.Provider,{store:t,children:(0,qo.jsx)(Wh,{children:(0,qo.jsx)(so.Provider,{value:e,children:n})})}),yt=zh;var Dr=F(require("classnames")),$n=require("react"),Ne=require("react-redux");var Xu=require("react");function Ju(t,e){let[n,o]=(0,Xu.useState)(()=>{if(typeof window=="undefined")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return P.error(r),e}});return[n,r=>{try{let i=r instanceof Function?r(n):r;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){P.error(i)}}]}var Zu=()=>/Mac/i.test(navigator.platform);var ep=F(require("classnames")),vt=require("react");var ya={};ee(ya,{enUS:()=>Vh,nlNL:()=>jh});var Vh={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"}]}]},jh={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 Yu={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var Ut=require("react/jsx-runtime"),va=(t,e,n)=>o=>(0,Ut.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),qh=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o,onLogIn:s})=>{let r=A(ya),i=he(),a=C("Login",Yu),c=R("productName"),l=R("signInViaPopup"),d=n&&!l,p=(0,vt.useCallback)(x=>{x.preventDefault(),o&&o(Number.parseInt(x.target.value,10))},[]),u=(0,vt.useCallback)(x=>{x.preventDefault(),i.send(On,!0)},[e]),m=(0,vt.useMemo)(()=>x=>(0,Ut.jsx)("a",{onClick:T=>{T.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:x},"login"),[e]),f=(0,vt.useCallback)(x=>(0,Ut.jsx)("button",{type:"button",className:a.anchorButton,onClick:u,children:x},"prompt"),[u]),{min:g,hour:y,day:v}=(0,vt.useMemo)(()=>({min:va(a,600,p),hour:va(a,3600,p),day:va(a,3600*12,p)}),[]);return(0,Ut.jsxs)("div",{className:(0,ep.default)(t,a.root),children:[r("loginPlease",{login:d?f:m,productName:c}),o&&(0,Ut.jsxs)(vt.Fragment,{children:[(0,Ut.jsx)("br",{}),r("snooze",{min:g,hour:y,day:v})]})]})},Or=qh;var np=require("react-redux");var tp={root:"dd-DoQhb",text:"dd-Jwnev"};var $o=require("react/jsx-runtime"),$h=({title:t})=>{let e=C("SearchTrigger",tp),n=(0,np.useDispatch)(),o=X();return(0,$o.jsxs)("button",{type:"button",className:e.root,onClick:()=>{n(Ue(!0)),o("open search",{via:"autocomplete-overlay"})},children:[(0,$o.jsx)(Vn,{}),(0,$o.jsx)("span",{className:e.text,children:t})]})},op=$h;var Sa={};ee(Sa,{enUS:()=>Gh,nlNL:()=>Qh});var Gh={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"}],dismiss:[{type:0,value:"Dismiss"}],dismissError:[{type:0,value:"Dismiss error"}]},Qh={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"}],dismiss:[{type:0,value:"Sluiten"}],dismissError:[{type:0,value:"Foutmelding sluiten"}]};var sp={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2",loginError:"dd-KCXeb",loginErrorMessage:"dd-Bv-BG",loginErrorDismiss:"dd-iSCjU"};var z=require("react/jsx-runtime"),Xh=({onLogIn:t})=>{var Q;let e=C("SuggestionsOverlay",sp),n=A(Sa),o=(0,Ne.useSelector)(tt),s=(0,Ne.useSelector)(Fl),r=(0,Ne.useDispatch)(),i=(0,$n.useRef)(null),a=R("searchTriggerKey"),c=R("productName"),l=(0,Ne.useSelector)(Er),d=(0,Ne.useSelector)(re),p=(0,Ne.useSelector)(wl),u=(0,Ne.useSelector)(Pn),[m,f]=(0,$n.useState)(null),g=R("showSearch"),y=R("showTextSuggestions"),v=R("adminUrl"),x=R("isEmbedded"),w=R("suggestionsPlacement"),[T,k]=Ju("dd-snooze-until-ms",0),E=l||T>Date.now(),I=(0,Ne.useSelector)(Jt),N=(0,Ne.useSelector)(ao),G=R("showStyleSuggestions"),Ee=R("showStyleSuggestionList"),_=(0,Ne.useSelector)(Lr),K=G&&Ee?Mr((Q=_.keywordMatches)!=null?Q:[]):[],$e=K.length>0,oe=I.filter(at=>at.source!=="gpt").length,zt=()=>{E&&k(0),r(Lu(!E))},O=at=>{let wn=Date.now()+at*1e3;k(wn),P.info(`Snooze until: ${new Date(wn)}`),r(Ft({collapse:!0}))};return(0,$n.useEffect)(()=>{oe===0&&f(null)},[I,oe]),Nt(()=>{r(Ft({collapse:!0,skipWhenInputFocus:!0}))}),d===null||u===!1?null:d===!1?(0,z.jsxs)("div",{ref:i,className:(0,Dr.default)(e.root,{[e.isCollapsed]:E}),children:[!E&&(0,z.jsxs)("div",{className:e.triggers,children:[(0,z.jsx)("div",{style:{flex:1}}),(0,z.jsx)("div",{className:e.triggersRight,children:(0,z.jsx)(qt,{className:e.toggleButton,title:n("collapse"),onClick:zt,isCollapsed:!1})})]}),(0,z.jsx)("div",{className:e.toggleButtonWrapper,children:(0,z.jsx)(qt,{className:e.toggleButton,title:n("open",{productName:c}),onClick:zt,isCollapsed:!0})}),(0,z.jsxs)("div",{className:e.collapsible,children:[p&&(0,z.jsxs)("div",{className:e.loginError,children:[(0,z.jsx)("span",{className:e.loginErrorMessage,children:p}),(0,z.jsx)("button",{type:"button",className:e.loginErrorDismiss,onClick:()=>r(vs()),"aria-label":n("dismissError"),children:n("dismiss")})]}),(0,z.jsx)(Or,{loginUrl:v,isEmbedded:x,onLogIn:t,onSnooze:O})]})]}):!s||!o&&!$e?null:(0,z.jsxs)("div",{ref:i,className:(0,Dr.default)(e.root,{[e.isCollapsed]:E}),children:[!E&&(0,z.jsxs)("div",{className:e.triggers,children:[(0,z.jsx)("div",{style:{flex:1},children:g&&(0,z.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(n(Zu()?"searchHintMac":"searchHintWindows",{searchTriggerKey:a.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,z.jsx)(op,{title:n("search")})})}),(0,z.jsxs)("div",{className:e.triggersRight,onFocus:()=>{},children:[(0,z.jsx)("div",{className:(0,Dr.default)(!m&&e.hintsHidden,e.hints),children:m}),(0,z.jsx)(qt,{className:e.toggleButton,title:n("collapse"),onClick:zt,isCollapsed:!1})]})]}),(0,z.jsx)("div",{className:e.toggleButtonWrapper,children:(0,z.jsx)(qt,{className:e.toggleButton,title:n("open",{productName:c}),onClick:zt,isCollapsed:!0})}),($e||oe>0&&y)&&(0,z.jsxs)("div",{className:e.collapsible,onFocus:()=>{},children:[$e&&(0,z.jsx)(Rr,{matches:K,selectedIndex:-1}),oe>0&&y&&(0,z.jsx)(se,{children:(0,z.jsx)(Pr,{suggestions:I,selectedIndex:N,reverse:w==="above"})})]})]})},rp=Xh;var Gr=F(require("classnames")),Tp=require("interweave"),bt=require("react"),Ep=require("react-redux");var Gn=require("react");function _r(t){return t.contentEditable==="true"}function Jh(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let s=o.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),n=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:n}}function ip(t){let{selectionStart:e,selectionEnd:n}=_r(t)?Jh(t):t;return[e,n]}function ap(t){let[,e]=(0,Gn.useState)(),n=(0,Gn.useRef)(null);return n.current=ip(t),(0,Gn.useEffect)(()=>{let o=()=>{var a;let[s,r]=(a=n.current)!=null?a:[],i=ip(t);(!i||s!==i[0]||r!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function lp(t,e){if(!e)return;let n=t,{value:o}=n,[s,r]=e,i=o.match(fs);if(!i||i.length===0)return;let a=0;i.find(c=>{let l=o.indexOf(c,a);return s>l&&r<l+c.length?(n.selectionStart=l,n.selectionEnd=l+c.length,!0):(a=l+c.length,!1)})}var dp=require("react"),Zh=["div","span","mark","strong","b","i","u","em"];function xa(t,e,n=0){var r;let o=t[t.length-1],s=typeof o=="object"&&o!==null?(r=o.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,o];if(Zh.includes(s)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),(0,dp.cloneElement)(o,{children:xa(i,e,n+1)})]}return[...t,...e]}function hn(t){return t.tagName.toLowerCase()==="textarea"}var cp={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var mp=F(require("classnames")),fp=require("interweave"),zr=require("react");var Qn=require("react");function up(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let s=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(n)]}function Fr(t){let e=(0,Qn.useRef)(null),[n,o]=(0,Qn.useState)(!1);return(0,Qn.useEffect)(()=>{var d;let s=!1,r=Number.parseFloat((d=window.getComputedStyle(document.body).zoom)!=null?d:"1"),[i,a]=up((p,u)=>{let m=e.current;if(!m)return;let f=p/r,g=u/r,y=m.getBoundingClientRect(),v=f>y.x&&f<y.x+y.width&&g>y.y&&g<y.y+y.height;v&&!s?(s=!0,o(!0)):!v&&s&&(s=!1,o(!1))},({clientX:p,clientY:u})=>[p,u]),[c,l]=up(()=>{s=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",c),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",c)}},[e]),[e,n]}function Hr(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Br(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function pp(t){return t!=null}var gp=F(require("classnames")),Ur=require("react");var St={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var ba=require("react/jsx-runtime"),Kr=(0,Ur.forwardRef)((s,o)=>{var r=s,{className:t,children:e}=r,n=D(r,["className","children"]);let i=(0,Ur.useRef)(null),a=C("TabCompletion",St);return(0,ba.jsx)("div",b(h({ref:Br([i,o]),className:(0,gp.default)(t,a.popoverContentContainer)},n),{children:(0,ba.jsx)("div",{className:a.popoverContent,children:e})}))});var Kt=require("react/jsx-runtime"),Yh=t=>e=>{let n=Qi(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},ey=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:s})=>{let r=C("TabCompletion",St),i=Ys(),a=(0,zr.useMemo)(()=>Yh(t.getBoundingClientRect()),[t]),[c,l]=Fr(t);return(0,zr.useEffect)(()=>{l?i.open():i.close()},[l]),(0,Kt.jsxs)("span",{children:[(0,Kt.jsx)("mark",{ref:Br([c,i.triggerRef]),className:(0,mp.default)(r.matchKeyword,{[r.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&(0,Kt.jsx)(Hn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,Kt.jsx)(Kr,{style:n,children:(0,Kt.jsx)("div",{className:r.hintText,children:s})})})]})},Wr=class extends fp.Matcher{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(s=>b(h({},s),{keywordRegex:new RegExp(`\\b${Hr(s.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=this.preparedKeywordMatches.map(r=>{if(this.usedKeywordMatches.has(r))return null;let i=n.match(r.keywordRegex);if(!i)return null;let a=n.charAt(i.index-1),c=n.charAt(i.index+r.keyword.length);return a==="{"&&c==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:r.suggestion,preparedKeywordMatch:r,valid:!0}}).filter(pp);if(o.length===0)return null;let s=o.reduce((r,i)=>i.index<r.index?i:r);return this.usedKeywordMatches.add(s.preparedKeywordMatch),s}replaceWith(n,o){return(0,Kt.jsx)(ey,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:n},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var hp=require("interweave"),yp=F(require("classnames"));var Ca=require("react/jsx-runtime"),ty=({inputElement:t,children:e})=>{let n=C("TabCompletion",St),[o,s]=Fr(t);return(0,Ca.jsx)("mark",{ref:o,className:(0,yp.default)(n.matchPlaceholder,{[n.hover]:s}),children:e})},Vr=class extends hp.Matcher{match(e){let n=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(e,n){return(0,Ca.jsx)(ty,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var qr=F(require("classnames")),wp=require("interweave"),ge=require("react"),Xn=require("react-redux");function vp(t,e){let n=new URL(t),o=n.searchParams.get("redirect");if(o){let s=new URL(o,n.origin);return e.forEach((r,i)=>{s.searchParams.set(i,r)}),n.searchParams.set("redirect",`${s.pathname}${s.search}${s.hash}`),n.toString()}return e.forEach((s,r)=>{n.searchParams.set(r,s)}),n.toString()}var wa=require("react/jsx-runtime"),Sp=()=>(0,wa.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,wa.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 ot=require("react"),Go=require("react-redux"),bp=F(require("lodash.debounce"));var xp={root:"dd-ky-Bv",content:"dd-kV5e1"};function jr(t,e,n){var s;let o=((s=t.imageSizes)==null?void 0:s[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(r){return null}}function Ta(t){return t.replace("https://www.","").replace("https://","")}var Oe=require("react/jsx-runtime"),ny=3,oy=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),sy=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:s=ny})=>{let r=C("LinkSearch",xp),[i,a]=(0,ot.useState)(""),c=(0,Go.useDispatch)(),l=(0,Go.useSelector)(uu("url")),d=(0,Go.useSelector)(ad("URL")),p=(0,ot.useMemo)(()=>d.map(oy),[d]),[u,m]=(0,ot.useState)(p.length-1),f=R("fallbackImage"),g=w=>{let T=w.target;a(T.value)},y=(w,T)=>{w.stopPropagation(),w.preventDefault(),window.open(T,"_blank")},v=w=>{var E;let T=u-1<0?p.length-1:u-1,k=u+1===p.length?0:u+1;w.code==="Escape"&&(a(""),e()),w.code==="ArrowUp"&&m(T),w.code==="ArrowDown"&&m(k),w.code==="Enter"&&t(((E=p[u])==null?void 0:E.text)||i)},x=(0,ot.useCallback)((0,bp.default)(w=>{c(tn({query:w,type:"URL",tags:["link-search"]}))},300),[]);return(0,ot.useEffect)(()=>{i&&x(i)},[i]),(0,ot.useEffect)(()=>()=>{c(Is())},[]),(0,Oe.jsxs)("div",{className:r.root,children:[(0,Oe.jsx)(se,{withDivider:!0,children:(i?p:l).slice(0,s).map((w,T)=>(0,Oe.jsx)(M,{selected:u===T,onClick:()=>t(w.text),"data-testid":"linksearch-suggestion",children:(0,Oe.jsxs)(B,{children:[(0,Oe.jsx)(B.Image,{src:jr(w,"small",f||void 0),title:w.title||w.text}),(0,Oe.jsxs)(B.Content,{className:r.content,cropText:!0,children:[(0,Oe.jsx)(B.Title,{children:w.title||Ta(w.text)}),w.title&&Ta(w.text)]}),(0,Oe.jsx)(M.Actions,{children:(0,Oe.jsx)(M.ActionButton,{label:o,onClick:k=>y(k,w.text)})})]})},w.text))}),(0,Oe.jsx)(Ro,{value:i,onChange:g,autoFocus:!0,placeholder:n,onKeyUp:v})]})},Cp=sy;var Ea={};ee(Ea,{enUS:()=>ry,nlNL:()=>iy});var ry={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}],addToPersonalCollection:[{type:0,value:"Add to Personal Collection"}]},iy={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}],addToPersonalCollection:[{type:0,value:"Toevoegen aan Personal Collection"}]};var ie=require("react/jsx-runtime"),ay=(0,ge.forwardRef)((t,e)=>{let n=C("TabCompletion",St);return(0,ie.jsx)("mark",{ref:e,className:(0,qr.default)(n.matchSelection)},"selection-start")}),ly=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:s})=>{let r=A(Ea),i=C("TabCompletion",St),a=R("addToPersonalCollection"),c=(0,Xn.useSelector)(_n("/admin/personal-collection/new")),l=(0,Xn.useSelector)(w=>{var T;return(T=w.conversation.current)==null?void 0:T.profileCode}),d=(0,Xn.useSelector)(Re)!==null,p=(0,ge.useRef)(null),u=(0,ge.useRef)(null),[m,f]=(0,ge.useState)(null),g=(0,Xn.useDispatch)(),y=Ys(document.activeElement===o),[v]=(0,ge.useState)(()=>document.createRange());y.triggerRef.current=v,(0,ge.useEffect)(()=>()=>v.detach(),[]),(0,ge.useEffect)(()=>{let w=t.current,T=p.current;!w||!T||(v.setStart(w,0),v.setEnd(T,0))},[t.current,p.current]),Nt(()=>{y.close()});let x=(0,ge.useCallback)(w=>{let T=v.toString(),k=/^http(s?):\/\//.test(w)?w:`https://${w}`,E=`[${T}](${k})`;g(Se({text:E,suggestion:{text:E,source:"search-url",type:"url"},eventMetrics:{inputType:"mouse"},replace:"selection"}))},[]);return(0,ie.jsxs)("span",{children:[(0,ie.jsx)("mark",{ref:p,className:(0,qr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":y.opened?"true":"false",children:s}),y.opened&&(0,ie.jsx)(Hn,{className:i.popoverRoot,triggerRef:y.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,ie.jsxs)(Kr,{style:n,ref:u,children:[(0,ie.jsxs)("div",{className:(0,qr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:m!==null}),children:[(0,ie.jsxs)("button",{type:"button",tabIndex:m===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>f("insertLink"),children:[(0,ie.jsx)(Sp,{}),(0,ie.jsx)("span",{children:"\xA0"}),(0,ie.jsx)("span",{children:r("insertLink")})]}),a&&c&&(0,ie.jsx)("button",{type:"button",tabIndex:m===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>{let w=v.toString(),T=new URLSearchParams({text:w});d&&l&&T.set("profile",l);let k=vp(c,T);window.open(k,"_blank")},children:(0,ie.jsx)("span",{children:r("addToPersonalCollection")})})]}),m==="insertLink"&&(0,ie.jsx)(Cp,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:x,onDismiss:()=>{f(null),y.close()}})]})})]},"selection-end")},$r=class extends wp.Matcher{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,o){return this.props=o,this.charCount=0,this.startRef=(0,ge.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,s]=this.props.selection;if(o===s)return null;let r=this.foundIndex===0?o:s,i=r>=this.charCount&&r<=this.charCount+n.length?{index:r-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let a=this.foundIndex===1;return i&&a?this.charCount+=r-this.charCount:this.charCount+=n.length,i?h({isStart:a},i):null}replaceWith(n,o){return o.isStart?(0,ie.jsx)(ay,{ref:this.startRef}):(0,ie.jsx)(ly,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var kp=require("react-redux");var xt=require("react/jsx-runtime"),dy=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:c})=>{let l=C("TabCompletion",cp),d=R("insertLink"),p=R("addToPersonalCollection"),u=R("showMidSentenceSuggestions"),m=R("inlineSuggestions"),f=ap(a),g=(0,bt.useRef)(null),y=(0,kp.useSelector)(re);(0,bt.useEffect)(()=>{hn(a)&&f&&lp(a,f)},[f]);let v=(0,bt.useCallback)(T=>{if(!s||!n)return T;let k=[(0,xt.jsx)("span",{className:l.resetIndent,children:"\u200B"},"u200B"),(0,xt.jsx)("span",{"data-testid":"tab-completion",className:(0,Gr.default)(l.tabText,l.resetIndent),"data-source":c,children:n},"tabText")];return o&&k.push((0,xt.jsx)("span",{className:(0,Gr.default)(l.hint,l.resetIndent),children:(0,xt.jsx)(ps,{keyCode:"tab"},"tabHint")},"tabHint")),xa(T,k)},[s,n,o]),x=(0,bt.useMemo)(()=>{let T=[];return(d||p)&&T.push(new $r("selection")),T.push(new Vr("placeholders")),r&&T.push(new Wr("keywords")),T},[m,d,p,r]),w=(0,bt.useMemo)(()=>{let T=window.getComputedStyle(a);return{"--dd-color":T.color,"--dd-font-size":T.fontSize,"--dd-font-family":T.fontFamily,"--dd-font-variant":T.fontVariant}},[]);return!t||!y?null:(0,xt.jsxs)("div",{ref:T=>{T!=null&&T.parentElement&&(g.current=T==null?void 0:T.parentElement)},className:l.root,style:w,children:[(0,xt.jsx)(Tp.Interweave,{tagName:"span",containerTagName:"div",className:(0,Gr.default)(l.container,l.agentText),disableLineBreaks:hn(a),content:e||"\u200B",onAfterParse:v,matchers:x,selection:f,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:g,inlineSuggestionsOnlyAtEnd:!u}),(0,xt.jsx)("br",{})]},"tab-completion")},cy=t=>{var v,x,w;let{input:e,ui:n,settings:o,styleSuggestions:s,conversation:r}=t,i=In({input:e}),a=(i==null?void 0:i.text)||"",c=(i==null?void 0:i.source)||"",l=(v=e.html)!=null?v:Wn(e.text),d=e.text.slice(e.suggestionTextStart,e.selection.end),p=a.indexOf(d)===0?a.slice(d.length):"",{showTabHint:u}=n,{isSupported:m}=r,{showTabCompletion:f,visible:g,showStyleSuggestions:y}=o;return{showTabHint:u,showStyleSuggestions:y,showTabCompletion:f&&tt(t),content:l,tabText:p,source:c,keywordMatches:(w=(x=s.list)==null?void 0:x.keywordMatches)!=null?w:[],enabled:g&&m!==!1}},Rp=(0,Ep.connect)(cy)(dy);var _e=require("react"),$=require("react-redux");var Qo=require("@reduxjs/toolkit");var uy={token:null,interval:null},ka=(0,Qo.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),Ra=(0,Qo.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(ka()),setInterval(()=>o(ka()),n)}),Pp=(0,Qo.createSlice)({name:"passwordlessToken",initialState:uy,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(ka.fulfilled,(e,n)=>{e.token=n.payload.token}),t.addCase(Ra.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollPasswordlessToken:Ip}=Pp.actions,Ap=Pp.reducer;var Lp=require("@reduxjs/toolkit");function py(t){return"buttonText"in t&&"eventName"in t}function Mp(t){if(t)return py(t)?{label:t.buttonText,event:t.eventName,value:t.payload}:t}function gy(t){return t==null?void 0:t.map(e=>Mp(e))}function my(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}var Np=(0,Lp.createSelector)([Rd,xs],(t,e)=>(e?t.filter(s=>!s.externalConversationId||s.externalConversationId===e):t).map(s=>{var a;let r=Mp(s.callToAction),i=gy(s.callToActions);return b(h(h(h(h({text:s.response,title:s.name},r?{callToAction:r}:{}),i!=null&&i.length?{callToActions:i}:{}),s.message!==void 0?{message:s.message}:{}),(a=s.sources)!=null&&a.length?{sources:s.sources}:{}),{editable:s.editable,isLoading:s.isLoading,evaluationId:s.evaluationId,rule:{id:my(s.code),label:s.code,name:s.name,description:s.name}})}));var Qr=require("react"),Ia=F(require("classnames"));var Pa=require("react/jsx-runtime"),Jn=()=>(0,Pa.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,Pa.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 Op={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var st=require("react/jsx-runtime"),fy=({entities:t})=>{let e=C("EntitiesWidgetList",Op),[n,o]=(0,Qr.useState)(void 0),s=X(),r=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),Xe(a.text),s("entity copied",{entity:a,type:"copy"}))};return(0,Qr.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[n]),!t||t.length===0?null:(0,st.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,c)=>(0,st.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,st.jsx)("span",{className:e.entityText,children:a.text}),(0,st.jsxs)("span",{className:e.iconWrapper,children:[(0,st.jsx)("span",{className:(0,Ia.default)(e.icon),children:(0,st.jsx)(Jn,{})}),(0,st.jsx)("span",{className:(0,Ia.default)(e.icon,n===c&&e.iconClicked),children:(0,st.jsx)(Jn,{})})]})]},a.text))})},Dp=fy;var Aa=require("react/jsx-runtime"),_p=()=>(0,Aa.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Aa.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 zp=require("react"),Xr=require("react-redux");var Fp={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var Hp={root:"dd-nazq3",rotation:"dd-3EHTv"};var Up=require("react/jsx-runtime"),hy=({size:t=12})=>{let e=C("LoadingSpinner",Hp);return(0,Up.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},Bp=hy;var La=require("react/jsx-runtime"),Kp=()=>(0,La.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:(0,La.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var Xo=require("react/jsx-runtime"),Wp=t=>(0,Xo.jsxs)("svg",b(h({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},t),{children:[(0,Xo.jsx)("title",{id:"checkTitle",children:"Check"}),(0,Xo.jsx)("path",{fill:"#666",d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"})]}));var Ma={};ee(Ma,{enUS:()=>yy,nlNL:()=>vy});var yy={error:[{type:0,value:"Something went wrong"}]},vy={error:[{type:0,value:"Er ging iets fout"}]};var Te=require("react/jsx-runtime"),Sy=3e3,xy=({assistantOptions:t})=>{let e=C("OnDemandAssistants",Fp),n=A(Ma),o=(0,zp.useRef)(),s=(0,Xr.useDispatch)(),r=Ns(be),i=(0,Xr.useSelector)(Dc),a=X(),c=i.filter(u=>u.isPinned),l=i.filter(u=>!u.isPinned),d=()=>S(null,null,function*(){return t.attachments&&t.attachments.length>0?t.attachments:s(((u,m,f)=>S(null,null,function*(){let g;if(t.transcript==="in-memory-transcript"){let y=f.dynamicThunkObject.conversationQuery;if(y){let v=yield y();g=Array.isArray(v)?v:void 0}}else Array.isArray(t.transcript)&&(g=t.transcript);return Fi({transcript:g})})))}),p=u=>S(null,null,function*(){clearTimeout(o.current);let m=yield d();a("trigger on demand assistant",{assistantCode:u}),yield r.call(h(b(h({},t),{assistantCode:u}),m.length>0?{attachments:m}:{})),o.current=setTimeout(()=>r.reset(),Sy)});return i.length===0?null:(0,Te.jsxs)("div",{className:e.root,children:[c.map(({assistant:u,assistantName:m,displayName:f})=>(0,Te.jsx)("button",{type:"button",className:e.button,disabled:r.state==="loading",onClick:()=>p(u),children:f||m},u)),l.length>0&&(0,Te.jsxs)(q,{placement:"top-end",children:[(0,Te.jsx)(q.Trigger,{className:e.trigger,disabled:r.state==="loading",children:(0,Te.jsx)(Sr,{"data-testid":"trigger"})}),(0,Te.jsx)(q.Content,{className:e.nav,"data-testid":"popover",children:l.map(({assistant:u,assistantName:m,displayName:f})=>(0,Te.jsx)(q.Button,{className:e.item,disabled:r.state==="loading",onClick:()=>p(u),children:f||m},u))})]}),r.state==="loading"&&(0,Te.jsx)(Bp,{}),r.state==="done"&&(0,Te.jsx)(Wp,{"data-testid":"trigger-done"}),r.state==="error"&&(0,Te.jsx)(ec,{trigger:(0,Te.jsx)(Kp,{}),children:n("error")})]})},Vp=xy;var qp=require("react-redux");var yn=require("react");var Jo={};ee(Jo,{enUS:()=>by,nlNL:()=>Cy});var by={useCue:[{type:0,value:"Add to message"}],__summarizerAssistant__:[{type:0,value:"Summary"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},Cy={useCue:[{type:0,value:"Voeg toe aan bericht"}],__summarizerAssistant__:[{type:0,value:"Samenvatting"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Na={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",ctaMessage:"dd-ge8nB",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l",form:"dd-sPNU2",formInput:"dd-F3E4I",formSubmit:"dd-vw5S0",actionButton:"dd-cCWyJ",editableCue:"dd-nWSD-",inputSpace:"dd-DGYB1"};var ae=require("react/jsx-runtime"),wy=500,Ty=100,Ey=({content:t,onChange:e,onCopy:n})=>{let o=(0,yn.useRef)(null),s=C("WidgetCue",Na);return(0,yn.useEffect)(()=>{let r=o.current;if(!r)return;r.style.setProperty("height","0px");let i=Math.min(Math.max(r.scrollHeight,Ty),wy);r.style.setProperty("height",`${i}px`)},[t]),(0,ae.jsx)("textarea",{ref:o,className:s.editableCue,onCopy:n,onChange:e,value:t})},ky=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:s,onSourceClick:r})=>{var y;let i=C("WidgetCue",Na),a=A(Jo),c=X(),l=R("hasKeyboardInput"),[d,p]=(0,yn.useState)(t.text),u=v=>{let x=v?b(h({},t),{callToAction:v}):t;e&&e(d,x),n(t)},m=(v,x)=>{o&&o(v,t),x&&Mt(x,i.fadeup)},f=v=>{s&&s(v,t)},g=v=>{v.preventDefault(),v.stopPropagation(),n(t)};return(0,yn.useEffect)(()=>{c("Assistant response displayed",{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text})},[]),(0,ae.jsxs)(M,{"data-testid":"cue",children:[(0,ae.jsx)(B,{children:(0,ae.jsxs)(B.Content,{children:[t.title&&(0,ae.jsx)(B.Title,{className:i.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?a(t.rule.label):t.title}),t.message&&(0,ae.jsx)("p",{className:i.ctaMessage,children:t.message}),t.editable?(0,ae.jsx)(Ey,{content:d,onCopy:()=>{let v=document.getSelection();v&&m(v.toString())},onChange:v=>{var x;return p((x=v.target.value)!=null?x:"")}}):(0,ae.jsx)(an,{content:t.text,sources:t.sources,onSourceClick:v=>r==null?void 0:r(v,t),useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:m,onUse:l?f:void 0})]})}),(0,ae.jsxs)(M.ButtonsContainer,{children:[(0,ae.jsxs)("div",{className:i.actions,children:[(0,ae.jsx)(M.Button,{onClick:v=>{var x;return m((x=Ws(d,"reply")[0])!=null?x:d,v.target)},variant:"primary",children:a("copyCue")}),t.callToAction&&(0,ae.jsx)(M.Button,{onClick:()=>u(),variant:"primary",children:t.callToAction.label}),(y=t.callToActions)==null?void 0:y.map((v,x)=>(0,ae.jsx)(M.Button,{onClick:()=>u(v),variant:"primary",children:v.label},`${v.event}-${v.label}-${x}`)),(0,ae.jsx)(M.Button,{onClick:g,variant:"secondary",children:a("removeCue")})]}),(0,ae.jsx)(Qs,{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text,feedbackType:"assistant"})]})]})},jp=ky;var Zn=require("react/jsx-runtime"),Ry=({cues:t})=>{let e=(0,qp.useDispatch)(),n=he(),o=A(Jo),s=X(),r=d=>{e(Vs({code:d.rule.label})),s("Assistant response closed",{evaluationId:d.evaluationId,assistantCode:d.rule.label,assistantOutput:d.text})},i=(d,p)=>{Xe(d),s("Assistant response copied",{evaluationId:p.evaluationId,assistantCode:p.rule.label,assistantOutput:p.text,copiedText:d})},a=(d,p)=>{var u;p.callToAction&&(e(zs(p)),s("Assistant call to action",{evaluationId:p.evaluationId,assistantCode:p.rule.label,assistantOutput:p.text,eventName:p.callToAction.event,value:(u=p.callToAction.value)!=null?u:d}))},c=(d,p)=>{var u;n.send(dt,{text:d,suggestion:{source:"assistant",assistantCode:(u=p.rule)==null?void 0:u.label,sourceText:d}}),s("Assistant response used",{evaluationId:p.evaluationId,assistantCode:p.rule.label,assistantOutput:p.text,usedText:d})},l=(d,p)=>{s("Assistant source clicked",{evaluationId:p.evaluationId,assistantCode:p.rule.label,source:d})};return(0,Zn.jsx)(Zn.Fragment,{children:t.map(d=>d.isLoading?(0,Zn.jsx)(tr,{title:d.rule.label.startsWith("__")?o(d.rule.label):d.title},d.rule.id):(0,Zn.jsx)(jp,{cue:d,onCallToAction:a,onRemove:r,onCopy:i,onUse:c,onSourceClick:l},d.evaluationId))})},$p=Ry;var Jr=require("react");var Gp={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var ve=require("react/jsx-runtime");function Py(t,e){return e.split(".").reduce((n,o)=>!n||typeof n!="object"||!(o in n)?null:n[o],t)}var Qp=({data:t,schema:e})=>{let n=C("WidgetCustomData",Gp),o=s=>{Xe(s)};return(0,Jr.useEffect)(()=>{P.info("Custom data",t,e)},[t]),(0,ve.jsx)("dl",{className:n.root,children:e.map(s=>{let r=Py(t,s.path);return(0,ve.jsxs)(Jr.Fragment,{children:[(0,ve.jsx)("dt",{className:n.label,children:s.label}),(0,ve.jsx)("dd",{className:n.value,children:s.type==="boolean"&&r?(0,ve.jsx)("span",{className:n.isTrue,children:s.trueValue}):s.type==="boolean"&&!r?(0,ve.jsx)("span",{className:n.isFalse,children:s.falseValue}):s.type==="array"&&Array.isArray(r)&&r.length>0?(0,ve.jsxs)("button",{type:"button",onClick:()=>o(r.join(", ")),className:n.copyButton,children:[(0,ve.jsx)("span",{className:n.copyButtonText,children:r.join(", ")}),(0,ve.jsx)(Jn,{})]}):typeof r=="string"||typeof r=="number"?(0,ve.jsxs)("button",{type:"button",onClick:()=>o(`${r}`),className:n.copyButton,children:[(0,ve.jsx)("span",{className:n.copyButtonText,children:r}),(0,ve.jsx)(Jn,{})]}):"-"})]},s.label)})})};var Jp=require("react");var Iy=/(https?:\/\/[^\s]+)/,Xp=t=>t.split(" ").find(e=>Iy.test(e));var De=require("react/jsx-runtime"),Ay=({suggestion:t,lines:e,onUse:n})=>{var p;let o=t.text||t.url||t.message,s=Xp(o),r=A(Fo),i=R("showImages"),a=R("fallbackImage"),c=R("hasKeyboardInput"),l=u=>{u.preventDefault(),u.stopPropagation(),c&&n(o)},d=(0,Jp.useCallback)(u=>{window.open(s,"_blank"),u.stopPropagation(),u.preventDefault()},[s]);return(0,De.jsxs)(M,{onClick:c?l:void 0,"data-testid":"edit-suggestion",children:[(0,De.jsxs)(B,{children:[i&&t.image&&(0,De.jsx)(B.Image,{src:jr(t,"small",a||void 0),title:t.title}),(0,De.jsxs)(B.Content,{children:[t.title&&(0,De.jsx)(B.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((p=t.searchKeywords)==null?void 0:p.length)>0&&(0,De.jsx)(M.Labels,{labels:t.searchKeywords}),(0,De.jsx)(B.Content,{cropText:e==="single",lineClamp:e==="multiple",children:o})]})]}),(0,De.jsxs)(M.Actions,{children:[s&&(0,De.jsx)(M.ActionButton,{onClick:d,label:r("visitUrl")}),c&&(0,De.jsx)(M.ActionButton,{primary:!0,onClick:l,label:r("useSuggestion")})]})]})},Zp=Ay;var Zo=require("react/jsx-runtime"),Ly=({lines:t,suggestions:e})=>{let n=he(),o=(s,r)=>{n.send(dt,{text:s,suggestion:b(h({},r),{source:r.source,sourceText:r.text})})};return(0,Zo.jsx)(Zo.Fragment,{children:e.map(s=>(0,Zo.jsx)(Zp,{suggestion:s,lines:t,onUse:r=>o(r,s)},s.text||s.url||s.message))})},Yp=Ly;var Yo={};ee(Yo,{enUS:()=>My,nlNL:()=>Ny});var My={waiting:[{type:0,value:"Loading\u2026"}],waitingForConversation:[{type:0,value:"Waiting for conversation\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],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"}],close:[{type:0,value:"Close"}]},Ny={waiting:[{type:0,value:"Laden\u2026"}],waitingForConversation:[{type:0,value:"Wachten op gesprek\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],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"}],close:[{type:0,value:"Sluiten"}]};var vn={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x",interactiveAssistantTabs:"dd-eSP1-",interactiveAssistantTab:"dd-CwcHD",interactiveAssistantTabActive:"dd-GzRs-"};var L=require("react/jsx-runtime"),eg=(t,e)=>{let n=(0,$.useSelector)(re);(0,_e.useEffect)(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},Oy=({onLogIn:t})=>{let e=C("Widget",vn),n=R("isEmbedded"),o=R("adminUrl");return(0,L.jsx)("div",{className:e.loginText,children:(0,L.jsx)("div",{children:(0,L.jsx)(Or,{isEmbedded:n,loginUrl:o,onLogIn:t})})},"login")},Oa=({text:t})=>{let e=C("Widget",vn);return(0,L.jsx)("div",{className:e.stateText,children:(0,L.jsx)("div",{children:(0,L.jsx)("p",{children:t})})},"notification")},Dy=()=>{let t=A(Yo),e=(0,$.useDispatch)(),n=C("Widget",vn),o=R("showSearch"),s=R("isEmbedded"),r=(0,$.useSelector)(_n("/admin/")),i=he(),a=R("productName"),c=X();return eg(()=>{if(s)return e(Ra()),()=>{e(Ip())}},[e,s]),!o&&!r?null:(0,L.jsxs)("div",{className:n.shortcutList,children:[o&&(0,L.jsx)(M.Button,{"data-testid":"shortcut-search","aria-label":t("linkSearch"),className:n.shortcut,icon:(0,L.jsx)(Vn,{}),onClick:()=>{i.send("ShowCommandPalette",{isOpen:!0}),c("open search",{via:"widget-shortcut"})},children:t("linkSearch")}),r&&(0,L.jsx)(M.Button,{as:"a",target:"_blank",icon:(0,L.jsx)(_p,{}),href:r,"data-testid":"shortcut-studio-login","aria-label":t("linkStudioLogin",{productName:a}),className:n.shortcut,rel:"noreferrer",onClick:()=>{c("open my deepdesk",{via:"widget-shortcut"})},children:t("linkStudioLogin",{productName:a})})]})},_y=({title:t,content:e})=>{let n=A(Yo),[o,s]=(0,_e.useState)(!0);return o?(0,L.jsx)(Ge,{"data-testid":"custom-data-banner",type:"custom-data-banner",title:t,children:(0,L.jsx)(se,{withDivider:!0,children:(0,L.jsxs)(M,{children:[(0,L.jsx)(B,{children:(0,L.jsx)(B.Content,{children:(0,L.jsx)(an,{content:e})})}),(0,L.jsx)(M.ButtonsContainer,{children:(0,L.jsx)(M.Button,{onClick:()=>s(!1),children:n("close")})})]})})}):null},Fy=()=>{let t=(0,$.useDispatch)(),e=(0,$.useSelector)(Ao),n=(0,$.useSelector)(Fc),o=(0,$.useSelector)(Np),s=(0,$.useSelector)(Xl),r=(0,$.useSelector)(yr),i=(0,$.useSelector)(br),a=(0,$.useSelector)(Me),c=(0,$.useSelector)(Re);return(0,_e.useEffect)(()=>{s&&!n&&P.warn("Custom data provided, but no schema.")},[s,n]),eg(()=>{e.forEach(({type:l})=>{l==="entities"?t(Ve()):hs.includes(l)||t(je(l))})},[t,c,a]),(0,_e.useEffect)(()=>{o.length>0&&!e.some(l=>l.type==="cues")&&P.warn("Received cues, but cues are not configured in widget.")},[e,o]),(0,L.jsx)(_e.Fragment,{children:e.map(({type:l,title:d,amount:p,lines:u,schema:m,property:f})=>{var g,y;switch(l){case"entities":return r&&r.length>0&&(0,L.jsx)(Ge,{type:l,title:d,"data-testid":`type-${l}`,children:(0,L.jsx)(Dp,{entities:r})},l);case"cues":return o&&o.length>0&&(0,L.jsx)(Ge,{type:l,title:d,"data-testid":`type-${l}`,children:(0,L.jsx)(se,{withDivider:!0,children:(0,L.jsx)($p,{cues:o})})},l);case"custom-data-banner":return s&&f&&s[f]&&(0,L.jsx)(_y,{title:d,content:String(s[f])},l);case"custom-data":return s&&m&&(0,L.jsx)(Ge,{type:l,title:d,"data-testid":`type-${l}`,children:(0,L.jsx)(se,{withDivider:!0,children:(0,L.jsx)(Qp,{data:s,schema:m})})},l);default:return((y=(g=i[l])==null?void 0:g.suggestions)==null?void 0:y.length)>0&&(0,L.jsx)(Ge,{type:l,title:d,"data-testid":`type-${l}`,children:(0,L.jsx)(se,{withDivider:!0,children:(0,L.jsx)(Yp,{lines:u,contentType:l,suggestions:i[l].suggestions.slice(0,p)||[]})})},l)}})})},Da=({children:t})=>{let e=C("Widget",vn);return(0,L.jsx)("div",{className:e.footer,children:t})},_a=({children:t})=>{let e=C("Widget",vn);return(0,L.jsx)("div",{className:e.root,"data-testid":"widget",children:t})},Hy=({onLogIn:t,knowledgeAssistOptions:e={},assistantOptions:n={transcript:"in-memory-transcript"},openAdminFeedback:o})=>{var T;let s=A(Yo),r=C("Widget",vn),i=(0,$.useDispatch)(),a=(0,$.useSelector)(Pn),c=(0,$.useSelector)(re),l=(0,$.useSelector)(xs),d=(0,$.useSelector)(Me),p=(0,$.useSelector)(_c("knowledge-assist")),u=(0,$.useSelector)(Hc),m=(0,$.useSelector)(Ad),f=(0,$.useSelector)(Id),g=(T=u.find(k=>k.code===m))!=null?T:u[0],[y,v]=(0,_e.useState)(e.initialQuestion);(0,_e.useEffect)(()=>{v(e.initialQuestion)},[l,e.initialQuestion]),(0,_e.useEffect)(()=>{if(!l)return;let k=Ss(l);k&&i(Bi(k))},[i,l]),(0,_e.useEffect)(()=>{if(u.length===0)return;let k=u.some(E=>E.code===m);(!m||!k)&&i(Hi(u[0].code))},[u,m,i]);let x=!!p&&u.length>0&&!!g,w=(g==null?void 0:g.displayName)||(g==null?void 0:g.name)||(p==null?void 0:p.title)||"Knowledge Assistant";return a===!1?(0,L.jsx)(Oa,{text:s("notSupported")}):c===!1?(0,L.jsx)(Oy,{onLogIn:t}):c===null?(0,L.jsx)(Oa,{text:s("waiting")}):!l||!d?(0,L.jsx)(Oa,{text:s("waitingForConversation")}):(0,L.jsx)($d,{handler:o,children:(0,L.jsx)(_a,{children:(0,L.jsxs)(rr,{initialQuestion:y,onInitialQuestionConsumed:()=>v(void 0),assistantCode:g==null?void 0:g.code,threadId:f,onThreadIdChange:k=>{g!=null&&g.code&&k!=null&&i(Ui({assistantCode:g.code,threadId:k}))},evaluateKnowledgeAssistFn:wo,children:[(0,L.jsxs)(En,{children:[(0,L.jsx)(Dy,{}),(0,L.jsx)(Fy,{}),x&&(0,L.jsx)(ar,{title:w,emptyState:e.emptyState})]}),(0,L.jsxs)(Da,{children:[x&&u.length>1&&(0,L.jsx)("div",{className:r.interactiveAssistantTabs,"data-testid":"widget-interactive-assistant-tabs",children:u.map(k=>{let E=k.code===(g==null?void 0:g.code);return(0,L.jsx)("button",{type:"button","aria-pressed":E,className:E?r.interactiveAssistantTabActive:r.interactiveAssistantTab,onClick:()=>i(Hi(k.code)),children:k.displayName||k.name},k.code)})}),x&&(0,L.jsx)(ir,{}),(0,L.jsx)(Vp,{assistantOptions:n})]})]},g==null?void 0:g.code)})})},tg=Hy;function Yn(t){let e=new Range;return e.selectNodeContents(t),e}function ng(t,e,n){try{return Wt(t,e,n),!0}catch(o){return!1}}function Zr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Yr(t){return"tagName"in t&&t.tagName==="BR"}var es=/[\u200B-\u200D\uFEFF]/g;function Wt(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let s=0,r=!1;function i(c,l){let d=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(c))return l;for(let u=0;u<=c.length;u++)if(p.test(c[u])||d++,d===l)return u;throw new Error("Offset out of range")}function a(c){switch(c.nodeType){case Node.TEXT_NODE:{let l=c.textContent,d=l.replace(es,""),p=s+d.length,u=e>=s&&e<=p,m=n>=s&&n<=p;if(u){let f=i(l,e-s);f===0&&!m?o.setStartBefore(c):o.setStart(c,f)}m&&(o.setEnd(c,i(l,n-s)),r=!0),s=p;break}case Node.ELEMENT_NODE:{if(Yr(c)&&(s===e&&o.setStartBefore(c),s++,s===n)){o.setEndAfter(c),r=!0;return}for(let d=0;d<c.childNodes.length&&(a(c.childNodes[d]),!r);d++);let l=c.lastChild;Zr(c)&&l&&!Zr(l)&&!Yr(l)&&s++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function ts(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r,collapsed:i}=e,a,c,l=0;function d(p){let u=p===t,m=p===n,f=p===s;switch(p.nodeType){case Node.TEXT_NODE:{let g=p.textContent;m&&(a=l+g.substring(0,o).replace(es,"").length),f&&(c=l+g.substring(0,r).replace(es,"").length),l+=g.replace(es,"").length;break}case Node.ELEMENT_NODE:{if(Yr(p)&&p.nextSibling){l++;break}!u&&Zr(p)&&p.previousSibling&&l++;for(let g=0;g<p.childNodes.length;g++){let y=m&&g===o,v=f&&g===r;if(y&&(a=l),v&&(c=l),c!==void 0||((!y||!i)&&d(p.childNodes[g]),f&&g===r-1&&(c=l),c!==void 0))break}f&&(c=l);break}default:break}}if(d(t),c===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:c,end:c}}function ns(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r,collapsed:i}=e,a=0,c="";function l(d){let p=d===t,u=d===n,m=d===s;switch(u&&(a=1),d.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let f=u?o:0,g=m?r:void 0;c+=d.textContent.replace(es,"").substring(f,g);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&Yr(d)&&d.nextSibling){c+=`
|
|
9
|
+
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var pa=require("react/jsx-runtime"),kh={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},wu=({className:t,color:e})=>(0,pa.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,pa.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:kh[e||"pink"]})});var Tu={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var ga={};ee(ga,{enUS:()=>Rh,nlNL:()=>Ph});var Rh={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Ph={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Ru=require("react-redux"),mn=require("react/jsx-runtime"),Pu=({onLogIn:t})=>{let e=A(ga),n=R("floatingMenu"),o=R("productName"),s=(0,Ru.useDispatch)(),r=(0,ku.useSelector)(re),i=C("FloatingMenu",Tu);if(r===null||n===!1)return null;let a=()=>{r===!0?s(Ke(!0)):t()};return(0,mn.jsxs)("button",{type:"button",className:(0,Eu.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,mn.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:o})}),(0,mn.jsxs)("div",{className:i.icon,children:[(0,mn.jsx)(wu,{className:i.logo,color:"pink"}),r===!1&&(0,mn.jsx)(Cu,{className:i.lock})]})]})};var Nr=require("react"),ot=require("react-redux");function nt(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:s,selection:r}=t.input;return r.end<t.input.suggestionTextStart||r.start!==r.end?!1:r.end>=s.length?!0:e?n&&new RegExp(n).test(s.substring(r.end))||o&&new RegExp(o).test(s.substring(0,r.end))?!0:n===!1&&o===!1:!1}var Iu=require("@reduxjs/toolkit"),Ih={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Er=({ui:t})=>t.overlayCollapsed,Au=(0,Iu.createSlice)({name:"ui",initialState:Ih,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputFocus(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:Vo,setInputFocus:kr,setOverlayCollapsed:Ht,setOpenOverlayWhenTyping:Lu,setOverlayCollapsedUserOverwrite:Mu}=Au.actions,Nu=Au.reducer;var Ou={styleRow:"dd-prYfH",styleSuggestion:"dd-JTmXy"};var jo=require("react/jsx-runtime"),Ah=({match:t,selected:e,styles:n})=>(0,jo.jsx)(M,{as:"button",selected:e,className:n.styleRow,"data-testid":"style-suggestion-item",title:t.suggestion,children:(0,jo.jsx)("span",{className:n.styleSuggestion,children:t.suggestion})}),Lh=({matches:t,selectedIndex:e})=>{let n=C("StyleSuggestionList",Ou);return(0,jo.jsx)(se,{children:t.map((o,s)=>(0,jo.jsx)(Ah,{match:o,selected:e===s,styles:n},`${o.keyword}-${s}`))})},Rr=Lh;var Uu=require("react");var fa=require("interweave"),Bt=require("react"),$o=require("react-redux");var Du=require("react");function _u(t,e,n){(0,Du.useEffect)(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var Fu={root:"dd-1MBCO",actions:"dd--x4cy",closeIconContainer:"dd-1z5NR",closeIcon:"dd-8qMF-",badge:"dd-4Fpkz",formattedText:"dd-EzvTB",assistantContainer:"dd-j6o8F",formattedTextTruncated:"dd-fv169",assistantBadge:"dd-VD57E"};var qo=require("react/jsx-runtime"),Hu=({title:t})=>(0,qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24","aria-labelledby":"closeTitle",children:[(0,qo.jsx)("title",{id:"closeTitle",children:t}),(0,qo.jsx)("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})]});var ma={};ee(ma,{enUS:()=>Mh,nlNL:()=>Nh});var Mh={assistant:[{type:0,value:"Assistant"}],close:[{type:0,value:"Close"}]},Nh={assistant:[{type:0,value:"Assistent"}],close:[{type:0,value:"Sluiten"}]};var Ee=require("react/jsx-runtime"),Dh=["search","personal-collection-search","search-autocomplete"];function _h(t,e,n,o={}){var r;let s="";return Dh.includes(e)?s=jc(oa(t,n,{stripAgentPart:!0}),(r=o.searchKeywords)!=null?r:[n]):s=oa(t,n,o),o.placeholders===!0&&(s=qc(s)),s}var Fh=()=>{},Hh=({selected:t,suggestion:e})=>{let n=A(ma),o=R("inlineSuggestions"),s=(0,$o.useSelector)(Xt),[r,i]=(0,Bt.useState)(!1),a=R("enableSuggestionFeedback"),c=(0,$o.useSelector)(y=>y.input.text),l=(0,$o.useDispatch)(),d=C("TextSuggestion",Fu),p=(0,Bt.useRef)(null),u=e.source==="assistant",m=a&&!u;(0,Bt.useEffect)(()=>{let y=setTimeout(()=>{l(Hl({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(y)}},[e]),_u(p,"click",()=>{l(be({suggestion:e,text:e.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let f=()=>{l(Zt({source:e.source,text:e.text,assistantCode:e.assistantCode}))},g=(0,Bt.useMemo)(()=>_h(e.text,e.source,s,{stripAgentPart:o,placeholders:!0,searchKeywords:e.searchKeywords}),[o,e.text,e.source,s,e.searchKeywords]);return e.source==="gpt"&&!o?null:(0,Ee.jsxs)("div",{className:d.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,Ee.jsx)(M,{ref:p,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:Fh,children:e.source==="assistant"?(0,Ee.jsxs)("div",{className:d.assistantContainer,children:[(0,Ee.jsx)(fa.Interweave,{containerTagName:"div",tagName:"span",className:d.formattedTextTruncated,content:g}),(0,Ee.jsx)("span",{className:d.assistantBadge,children:n("assistant")})]}):(0,Ee.jsx)(fa.Interweave,{containerTagName:"div",tagName:"span",className:d.formattedText,content:g})}),m&&r&&(0,Ee.jsx)("div",{className:d.actions,children:(0,Ee.jsx)(xr,{source:"overlay",context:c,suggestion:e})}),u&&r&&(0,Ee.jsx)("div",{className:d.closeIconContainer,children:(0,Ee.jsx)("button",{type:"button",className:d.closeIcon,onClick:f,title:n("close"),children:(0,Ee.jsx)(Hu,{title:n("close")})})})]})},Bu=Hh;var Ku=require("react/jsx-runtime"),Bh=({suggestions:t,selectedIndex:e,reverse:n})=>(0,Uu.useMemo)(()=>{let s=t.map((r,i)=>(0,Ku.jsx)(Bu,{index:i,selected:i===e,suggestion:r},`${r.text}-${r.source}`));return n?s.reverse():s},[t,e,n]),Pr=Bh;var Wu={root:"dd-PfvRI",paper:"dd-HYlyY"};var Ar=require("@reduxjs/toolkit");var Ir={list:{keywordMatches:[]},fetchState:"idle"},Lr=t=>t.styleSuggestions.list,fn=(0,Ar.createAsyncThunk)("styleSuggestions/getAll",(n,o)=>S(null,[n,o],function*({text:t},e){var c;let{deepdeskAPI:s}=e.extra,r=e.getState(),{showStyleSuggestions:i}=r.settings,a=(c=r.conversation.current)==null?void 0:c.profileCode;if(!i)return Ir.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return s.getStyleSuggestions({profileCode:a,message:t})})),zu=(0,Ar.createSlice)({name:"styleSuggestions",initialState:Ir,reducers:{commitStyleSuggestion(t,e){let{keyword:n,suggestion:o}=e.payload;t.list.keywordMatches=t.list.keywordMatches.filter(s=>s.keyword.toLowerCase()!==n.toLowerCase()||s.suggestion!==o)}},extraReducers:t=>{t.addCase(fn.pending,e=>{e.fetchState="loading"}).addCase(fn.rejected,e=>{e.fetchState="error"}).addCase(fn.fulfilled,(e,n)=>{e.fetchState="done",Lt(e.list,n.payload)||(e.list=n.payload)}).addCase(Yt,e=>{e.list=Ir.list}).addCase(q,()=>Ir)}}),{commitStyleSuggestion:Vu}=zu.actions,ju=zu.reducer;var Mr=t=>{let e=new Set;return t.filter(({keyword:n,suggestion:o})=>{let s=JSON.stringify([n.toLowerCase(),o]);return e.has(s)?!1:(e.add(s),!0)})};var hn=require("react/jsx-runtime"),Uh=()=>{var y;let t=(0,Nr.useRef)(null),e=C("InlineSuggestionsOverlay",Wu),n=(0,ot.useSelector)(nt),o=(0,ot.useDispatch)(),s=(0,ot.useSelector)(re),r=(0,ot.useSelector)(In),i=(0,ot.useSelector)(Er),a=R("showTextSuggestions"),c=(0,ot.useSelector)(Jt),l=(0,ot.useSelector)(lo),d=R("showStyleSuggestions"),p=R("showStyleSuggestionList"),u=(0,ot.useSelector)(Lr),m=d&&p?Mr((y=u.keywordMatches)!=null?y:[]):[],f=m.length>0,g=a&&c.length>0;return Ot(()=>{setTimeout(()=>{o(Ht({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Nr.useEffect)(()=>{let v=t.current;if(!v||!v.parentElement)return;v.parentElement.style.left="0px";let x=v.getBoundingClientRect();v.parentElement.style.left=`${Math.min(window.innerWidth-4-x.right,0)}px`}),i||s!==!0||r===!1||!n&&!f||!g&&!f?null:(0,hn.jsx)("div",{className:e.root,"data-variant":"inline",children:(0,hn.jsxs)("div",{ref:t,className:e.paper,children:[f&&(0,hn.jsx)(Rr,{matches:m,selectedIndex:-1}),g&&(0,hn.jsx)(se,{children:(0,hn.jsx)(Pr,{suggestions:c,selectedIndex:l})})]})})},qu=Uh;var Ut=_(require("react"));var $u={root:"dd-7zvcP",dialogContent:"dd-4C0lK",continueButton:"dd-YUPQW",buttonContinueWrapper:"dd-IKpYs",nicknameInput:"dd-rxhGp",titleWrapper:"dd-nw3nD",title:"dd-5iof5",closeButtonWrapper:"dd-UUAzA",closeButton:"dd-7rjP5",buttonsWrapper:"dd-5e9Xb",errorMessage:"dd--5VgX",errorLink:"dd-u461n"};var Gu=require("react-redux");var ha={};ee(ha,{enUS:()=>Kh,nlNL:()=>Wh});var Kh={title:[{type:0,value:"Enter your nickname"}],close:[{type:0,value:"Close"}],nicknameDialogTitle:[{type:0,value:"Please enter the name you'd like customers to see during chat conversations. This nickname will be used across your Deepdesk environment."}],nicknameDialogInputPlaceholder:[{type:0,value:"Enter your nickname"}],nicknameDialogContinueButton:[{type:0,value:"Continue"}],nicknameDialogError:[{type:0,value:"Nickname cannot be empty or spaces only"}],nicknameDialogEmojiError:[{type:0,value:"You cannot use emojis in this field."}],nicknameDialogSaveError:[{type:0,value:"We couldn't save your details just now. Please try again, or update it at "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We couldn\u2019t save your details just now. Please try again later, or update them in My Deepdesk \u2192 Settings."}]},Wh={title:[{type:0,value:"Voer je bijnaam in"}],close:[{type:0,value:"Sluiten"}],nicknameDialogTitle:[{type:0,value:"Voer de naam in die je wilt dat klanten zien tijdens chatgesprekken. Deze bijnaam wordt gebruikt in je Deepdesk-omgeving."}],nicknameDialogInputPlaceholder:[{type:0,value:"Voer je bijnaam in"}],nicknameDialogContinueButton:[{type:0,value:"Doorgaan"}],nicknameDialogError:[{type:0,value:"Bijnaam mag niet leeg of alleen spaties zijn"}],nicknameDialogEmojiError:[{type:0,value:"Je kunt geen emoji's gebruiken in dit veld."}],nicknameDialogSaveError:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw of werk het bij op "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw later, of werk ze bij in My Deepdesk \u2192 Instellingen."}]};var te=require("react/jsx-runtime"),Qu=({onClose:t,onSave:e,id:n,error:o})=>{let[s,r]=(0,Ut.useState)(""),[i,a]=(0,Ut.useState)(!1),[c,l]=(0,Ut.useState)(!1),d=C("Nickname",$u),p=Ut.default.useRef(null),u=(0,Gu.useSelector)(v=>v.info.showNicknameDialog),m=A(ha),f=R("adminUrl");(0,Ut.useEffect)(()=>{o&&a(!0)},[o]);let g=()=>{if(!p.current)return;s.trim()?p.current.setCustomValidity(""):p.current.setCustomValidity(m("nicknameDialogError")),p.current.reportValidity()},y=v=>{v.preventDefault();let x=s.trim(),w=v.currentTarget.querySelector("#nickname-input");if(!x){w.setCustomValidity(m("nicknameDialogError")),w.reportValidity();return}w.setCustomValidity(""),e(x)};return(0,te.jsxs)(Un,{isOpen:u,"datatest-id":n,onClose:t||(()=>{}),onBack:t||(()=>{}),children:[(0,te.jsx)("div",{className:d.titleWrapper,children:(0,te.jsx)("h1",{className:d.title,children:m("title")})}),(0,te.jsxs)("form",{className:d.dialogContent,onSubmit:y,children:[(0,te.jsx)("p",{children:m("nicknameDialogTitle")}),i&&o&&(0,te.jsx)("div",{className:d.errorMessage,children:f?(()=>{let v=m("nicknameDialogSaveError",{account:f}),x=`${f}.deepdesk.com/admin/user-settings`,w=v.indexOf(x);if(w!==-1){let T=v.substring(0,w),k=v.substring(w+x.length);return(0,te.jsxs)(te.Fragment,{children:[T,(0,te.jsx)("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:d.errorLink,children:x}),k]})}return v})():m("nicknameDialogSaveErrorWithoutLink")}),(0,te.jsx)("input",{required:!0,minLength:1,maxLength:20,"data-testid":"nickname-input",id:"nickname-input",className:d.nicknameInput,type:"text",placeholder:m("nicknameDialogInputPlaceholder"),value:s,onChange:v=>{l(new RegExp("\\p{Extended_Pictographic}","u").test(v.target.value)),r(v.target.value)},onBlur:g,ref:p}),c&&(0,te.jsx)("div",{className:d.errorMessage,role:"alert",children:m("nicknameDialogEmojiError")}),(0,te.jsxs)("div",{className:d.buttonsWrapper,children:[o?(0,te.jsx)("div",{className:d.closeButtonWrapper,children:(0,te.jsx)("button",{type:"button",className:d.closeButton,onClick:()=>t==null?void 0:t(),children:m("close")})}):null,(0,te.jsx)("div",{className:d.buttonContinueWrapper,children:(0,te.jsx)("button",{type:"submit",className:d.continueButton,disabled:!s.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(s),children:m("nicknameDialogContinueButton")})})]})]})]})};var Xu=require("react-redux");var Go=require("react/jsx-runtime"),zh=({children:t})=>{let n=R("locale").replace("-","");return(0,Go.jsx)(Di.Provider,{value:n,children:t})},Vh=({store:t,customStyles:e={},children:n})=>(0,Go.jsx)(Xu.Provider,{store:t,children:(0,Go.jsx)(zh,{children:(0,Go.jsx)(so.Provider,{value:e,children:n})})}),St=Vh;var Dr=_(require("classnames")),$n=require("react"),Oe=require("react-redux");var Ju=require("react");function Zu(t,e){let[n,o]=(0,Ju.useState)(()=>{if(typeof window=="undefined")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return P.error(r),e}});return[n,r=>{try{let i=r instanceof Function?r(n):r;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){P.error(i)}}]}var Yu=()=>/Mac/i.test(navigator.platform);var tp=_(require("classnames")),xt=require("react");var ya={};ee(ya,{enUS:()=>jh,nlNL:()=>qh});var jh={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"}]}]},qh={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 ep={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var Kt=require("react/jsx-runtime"),va=(t,e,n)=>o=>(0,Kt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),$h=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o,onLogIn:s})=>{let r=A(ya),i=ve(),a=C("Login",ep),c=R("productName"),l=R("signInViaPopup"),d=n&&!l,p=(0,xt.useCallback)(x=>{x.preventDefault(),o&&o(Number.parseInt(x.target.value,10))},[]),u=(0,xt.useCallback)(x=>{x.preventDefault(),i.send(Dn,!0)},[e]),m=(0,xt.useMemo)(()=>x=>(0,Kt.jsx)("a",{onClick:T=>{T.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:x},"login"),[e]),f=(0,xt.useCallback)(x=>(0,Kt.jsx)("button",{type:"button",className:a.anchorButton,onClick:u,children:x},"prompt"),[u]),{min:g,hour:y,day:v}=(0,xt.useMemo)(()=>({min:va(a,600,p),hour:va(a,3600,p),day:va(a,3600*12,p)}),[]);return(0,Kt.jsxs)("div",{className:(0,tp.default)(t,a.root),children:[r("loginPlease",{login:d?f:m,productName:c}),o&&(0,Kt.jsxs)(xt.Fragment,{children:[(0,Kt.jsx)("br",{}),r("snooze",{min:g,hour:y,day:v})]})]})},Or=$h;var op=require("react-redux");var np={root:"dd-DoQhb",text:"dd-Jwnev"};var Qo=require("react/jsx-runtime"),Gh=({title:t})=>{let e=C("SearchTrigger",np),n=(0,op.useDispatch)(),o=J();return(0,Qo.jsxs)("button",{type:"button",className:e.root,onClick:()=>{n(Ke(!0)),o("open search",{via:"autocomplete-overlay"})},children:[(0,Qo.jsx)(Vn,{}),(0,Qo.jsx)("span",{className:e.text,children:t})]})},sp=Gh;var Sa={};ee(Sa,{enUS:()=>Qh,nlNL:()=>Xh});var Qh={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"}],dismiss:[{type:0,value:"Dismiss"}],dismissError:[{type:0,value:"Dismiss error"}]},Xh={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"}],dismiss:[{type:0,value:"Sluiten"}],dismissError:[{type:0,value:"Foutmelding sluiten"}]};var rp={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2",loginError:"dd-KCXeb",loginErrorMessage:"dd-Bv-BG",loginErrorDismiss:"dd-iSCjU"};var V=require("react/jsx-runtime"),Jh=({onLogIn:t})=>{var X;let e=C("SuggestionsOverlay",rp),n=A(Sa),o=(0,Oe.useSelector)(nt),s=(0,Oe.useSelector)(Fl),r=(0,Oe.useDispatch)(),i=(0,$n.useRef)(null),a=R("searchTriggerKey"),c=R("productName"),l=(0,Oe.useSelector)(Er),d=(0,Oe.useSelector)(re),p=(0,Oe.useSelector)(wl),u=(0,Oe.useSelector)(In),[m,f]=(0,$n.useState)(null),g=R("showSearch"),y=R("showTextSuggestions"),v=R("adminUrl"),x=R("isEmbedded"),w=R("suggestionsPlacement"),[T,k]=Zu("dd-snooze-until-ms",0),E=l||T>Date.now(),I=(0,Oe.useSelector)(Jt),W=(0,Oe.useSelector)(lo),oe=R("showStyleSuggestions"),fe=R("showStyleSuggestionList"),N=(0,Oe.useSelector)(Lr),H=oe&&fe?Mr((X=N.keywordMatches)!=null?X:[]):[],Ge=H.length>0,U=I.filter(lt=>lt.source!=="gpt").length,ce=()=>{E&&k(0),r(Mu(!E))},O=lt=>{let Tn=Date.now()+lt*1e3;k(Tn),P.info(`Snooze until: ${new Date(Tn)}`),r(Ht({collapse:!0}))};return(0,$n.useEffect)(()=>{U===0&&f(null)},[I,U]),Ot(()=>{r(Ht({collapse:!0,skipWhenInputFocus:!0}))}),d===null||u===!1?null:d===!1?(0,V.jsxs)("div",{ref:i,className:(0,Dr.default)(e.root,{[e.isCollapsed]:E}),children:[!E&&(0,V.jsxs)("div",{className:e.triggers,children:[(0,V.jsx)("div",{style:{flex:1}}),(0,V.jsx)("div",{className:e.triggersRight,children:(0,V.jsx)(qt,{className:e.toggleButton,title:n("collapse"),onClick:ce,isCollapsed:!1})})]}),(0,V.jsx)("div",{className:e.toggleButtonWrapper,children:(0,V.jsx)(qt,{className:e.toggleButton,title:n("open",{productName:c}),onClick:ce,isCollapsed:!0})}),(0,V.jsxs)("div",{className:e.collapsible,children:[p&&(0,V.jsxs)("div",{className:e.loginError,children:[(0,V.jsx)("span",{className:e.loginErrorMessage,children:p}),(0,V.jsx)("button",{type:"button",className:e.loginErrorDismiss,onClick:()=>r(xs()),"aria-label":n("dismissError"),children:n("dismiss")})]}),(0,V.jsx)(Or,{loginUrl:v,isEmbedded:x,onLogIn:t,onSnooze:O})]})]}):!s||!o&&!Ge?null:(0,V.jsxs)("div",{ref:i,className:(0,Dr.default)(e.root,{[e.isCollapsed]:E}),children:[!E&&(0,V.jsxs)("div",{className:e.triggers,children:[(0,V.jsx)("div",{style:{flex:1},children:g&&(0,V.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(n(Yu()?"searchHintMac":"searchHintWindows",{searchTriggerKey:a.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,V.jsx)(sp,{title:n("search")})})}),(0,V.jsxs)("div",{className:e.triggersRight,onFocus:()=>{},children:[(0,V.jsx)("div",{className:(0,Dr.default)(!m&&e.hintsHidden,e.hints),children:m}),(0,V.jsx)(qt,{className:e.toggleButton,title:n("collapse"),onClick:ce,isCollapsed:!1})]})]}),(0,V.jsx)("div",{className:e.toggleButtonWrapper,children:(0,V.jsx)(qt,{className:e.toggleButton,title:n("open",{productName:c}),onClick:ce,isCollapsed:!0})}),(Ge||U>0&&y)&&(0,V.jsxs)("div",{className:e.collapsible,onFocus:()=>{},children:[Ge&&(0,V.jsx)(Rr,{matches:H,selectedIndex:-1}),U>0&&y&&(0,V.jsx)(se,{children:(0,V.jsx)(Pr,{suggestions:I,selectedIndex:W,reverse:w==="above"})})]})]})},ip=Jh;var Gr=_(require("classnames")),Ep=require("interweave"),wt=require("react"),kp=require("react-redux");var Gn=require("react");function _r(t){return t.contentEditable==="true"}function Zh(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let s=o.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),n=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:n}}function ap(t){let{selectionStart:e,selectionEnd:n}=_r(t)?Zh(t):t;return[e,n]}function lp(t){let[,e]=(0,Gn.useState)(),n=(0,Gn.useRef)(null);return n.current=ap(t),(0,Gn.useEffect)(()=>{let o=()=>{var a;let[s,r]=(a=n.current)!=null?a:[],i=ap(t);(!i||s!==i[0]||r!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function dp(t,e){if(!e)return;let n=t,{value:o}=n,[s,r]=e,i=o.match(ys);if(!i||i.length===0)return;let a=0;i.find(c=>{let l=o.indexOf(c,a);return s>l&&r<l+c.length?(n.selectionStart=l,n.selectionEnd=l+c.length,!0):(a=l+c.length,!1)})}var cp=require("react"),Yh=["div","span","mark","strong","b","i","u","em"];function xa(t,e,n=0){var r;let o=t[t.length-1],s=typeof o=="object"&&o!==null?(r=o.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,o];if(Yh.includes(s)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),(0,cp.cloneElement)(o,{children:xa(i,e,n+1)})]}return[...t,...e]}function yn(t){return t.tagName.toLowerCase()==="textarea"}var up={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var fp=_(require("classnames")),hp=require("interweave"),zr=require("react");var Qn=require("react");function pp(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let s=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(n)]}function Fr(t){let e=(0,Qn.useRef)(null),[n,o]=(0,Qn.useState)(!1);return(0,Qn.useEffect)(()=>{var d;let s=!1,r=Number.parseFloat((d=window.getComputedStyle(document.body).zoom)!=null?d:"1"),[i,a]=pp((p,u)=>{let m=e.current;if(!m)return;let f=p/r,g=u/r,y=m.getBoundingClientRect(),v=f>y.x&&f<y.x+y.width&&g>y.y&&g<y.y+y.height;v&&!s?(s=!0,o(!0)):!v&&s&&(s=!1,o(!1))},({clientX:p,clientY:u})=>[p,u]),[c,l]=pp(()=>{s=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",c),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",c)}},[e]),[e,n]}function Hr(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Br(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function gp(t){return t!=null}var mp=_(require("classnames")),Ur=require("react");var bt={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var ba=require("react/jsx-runtime"),Kr=(0,Ur.forwardRef)((s,o)=>{var r=s,{className:t,children:e}=r,n=D(r,["className","children"]);let i=(0,Ur.useRef)(null),a=C("TabCompletion",bt);return(0,ba.jsx)("div",b(h({ref:Br([i,o]),className:(0,mp.default)(t,a.popoverContentContainer)},n),{children:(0,ba.jsx)("div",{className:a.popoverContent,children:e})}))});var Wt=require("react/jsx-runtime"),ey=t=>e=>{let n=Qi(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},ty=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:s})=>{let r=C("TabCompletion",bt),i=Ys(),a=(0,zr.useMemo)(()=>ey(t.getBoundingClientRect()),[t]),[c,l]=Fr(t);return(0,zr.useEffect)(()=>{l?i.open():i.close()},[l]),(0,Wt.jsxs)("span",{children:[(0,Wt.jsx)("mark",{ref:Br([c,i.triggerRef]),className:(0,fp.default)(r.matchKeyword,{[r.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&(0,Wt.jsx)(Bn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,Wt.jsx)(Kr,{style:n,children:(0,Wt.jsx)("div",{className:r.hintText,children:s})})})]})},Wr=class extends hp.Matcher{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(s=>b(h({},s),{keywordRegex:new RegExp(`\\b${Hr(s.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=this.preparedKeywordMatches.map(r=>{if(this.usedKeywordMatches.has(r))return null;let i=n.match(r.keywordRegex);if(!i)return null;let a=n.charAt(i.index-1),c=n.charAt(i.index+r.keyword.length);return a==="{"&&c==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:r.suggestion,preparedKeywordMatch:r,valid:!0}}).filter(gp);if(o.length===0)return null;let s=o.reduce((r,i)=>i.index<r.index?i:r);return this.usedKeywordMatches.add(s.preparedKeywordMatch),s}replaceWith(n,o){return(0,Wt.jsx)(ty,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:n},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var yp=require("interweave"),vp=_(require("classnames"));var Ca=require("react/jsx-runtime"),ny=({inputElement:t,children:e})=>{let n=C("TabCompletion",bt),[o,s]=Fr(t);return(0,Ca.jsx)("mark",{ref:o,className:(0,vp.default)(n.matchPlaceholder,{[n.hover]:s}),children:e})},Vr=class extends yp.Matcher{match(e){let n=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(e,n){return(0,Ca.jsx)(ny,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var qr=_(require("classnames")),Tp=require("interweave"),me=require("react"),Xn=require("react-redux");function Sp(t,e){let n=new URL(t),o=n.searchParams.get("redirect");if(o){let s=new URL(o,n.origin);return e.forEach((r,i)=>{s.searchParams.set(i,r)}),n.searchParams.set("redirect",`${s.pathname}${s.search}${s.hash}`),n.toString()}return e.forEach((s,r)=>{n.searchParams.set(r,s)}),n.toString()}var wa=require("react/jsx-runtime"),xp=()=>(0,wa.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,wa.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 st=require("react"),Xo=require("react-redux"),Cp=_(require("lodash.debounce"));var bp={root:"dd-ky-Bv",content:"dd-kV5e1"};function jr(t,e,n){var s;let o=((s=t.imageSizes)==null?void 0:s[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(r){return null}}function Ta(t){return t.replace("https://www.","").replace("https://","")}var De=require("react/jsx-runtime"),oy=3,sy=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),ry=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:s=oy})=>{let r=C("LinkSearch",bp),[i,a]=(0,st.useState)(""),c=(0,Xo.useDispatch)(),l=(0,Xo.useSelector)(pu("url")),d=(0,Xo.useSelector)(ad("URL")),p=(0,st.useMemo)(()=>d.map(sy),[d]),[u,m]=(0,st.useState)(p.length-1),f=R("fallbackImage"),g=w=>{let T=w.target;a(T.value)},y=(w,T)=>{w.stopPropagation(),w.preventDefault(),window.open(T,"_blank")},v=w=>{var E;let T=u-1<0?p.length-1:u-1,k=u+1===p.length?0:u+1;w.code==="Escape"&&(a(""),e()),w.code==="ArrowUp"&&m(T),w.code==="ArrowDown"&&m(k),w.code==="Enter"&&t(((E=p[u])==null?void 0:E.text)||i)},x=(0,st.useCallback)((0,Cp.default)(w=>{c(tn({query:w,type:"URL",tags:["link-search"]}))},300),[]);return(0,st.useEffect)(()=>{i&&x(i)},[i]),(0,st.useEffect)(()=>()=>{c(As())},[]),(0,De.jsxs)("div",{className:r.root,children:[(0,De.jsx)(se,{withDivider:!0,children:(i?p:l).slice(0,s).map((w,T)=>(0,De.jsx)(M,{selected:u===T,onClick:()=>t(w.text),"data-testid":"linksearch-suggestion",children:(0,De.jsxs)(B,{children:[(0,De.jsx)(B.Image,{src:jr(w,"small",f||void 0),title:w.title||w.text}),(0,De.jsxs)(B.Content,{className:r.content,cropText:!0,children:[(0,De.jsx)(B.Title,{children:w.title||Ta(w.text)}),w.title&&Ta(w.text)]}),(0,De.jsx)(M.Actions,{children:(0,De.jsx)(M.ActionButton,{label:o,onClick:k=>y(k,w.text)})})]})},w.text))}),(0,De.jsx)(Io,{value:i,onChange:g,autoFocus:!0,placeholder:n,onKeyUp:v})]})},wp=ry;var Ea={};ee(Ea,{enUS:()=>iy,nlNL:()=>ay});var iy={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}],addToPersonalCollection:[{type:0,value:"Add to Personal Collection"}]},ay={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}],addToPersonalCollection:[{type:0,value:"Toevoegen aan Personal Collection"}]};var ie=require("react/jsx-runtime"),ly=(0,me.forwardRef)((t,e)=>{let n=C("TabCompletion",bt);return(0,ie.jsx)("mark",{ref:e,className:(0,qr.default)(n.matchSelection)},"selection-start")}),dy=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:s})=>{let r=A(Ea),i=C("TabCompletion",bt),a=R("addToPersonalCollection"),c=(0,Xn.useSelector)(Fn("/admin/personal-collection/new")),l=(0,Xn.useSelector)(w=>{var T;return(T=w.conversation.current)==null?void 0:T.profileCode}),d=(0,Xn.useSelector)(Pe)!==null,p=(0,me.useRef)(null),u=(0,me.useRef)(null),[m,f]=(0,me.useState)(null),g=(0,Xn.useDispatch)(),y=Ys(document.activeElement===o),[v]=(0,me.useState)(()=>document.createRange());y.triggerRef.current=v,(0,me.useEffect)(()=>()=>v.detach(),[]),(0,me.useEffect)(()=>{let w=t.current,T=p.current;!w||!T||(v.setStart(w,0),v.setEnd(T,0))},[t.current,p.current]),Ot(()=>{y.close()});let x=(0,me.useCallback)(w=>{let T=v.toString(),k=/^http(s?):\/\//.test(w)?w:`https://${w}`,E=`[${T}](${k})`;g(be({text:E,suggestion:{text:E,source:"search-url",type:"url"},eventMetrics:{inputType:"mouse"},replace:"selection"}))},[]);return(0,ie.jsxs)("span",{children:[(0,ie.jsx)("mark",{ref:p,className:(0,qr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":y.opened?"true":"false",children:s}),y.opened&&(0,ie.jsx)(Bn,{className:i.popoverRoot,triggerRef:y.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,ie.jsxs)(Kr,{style:n,ref:u,children:[(0,ie.jsxs)("div",{className:(0,qr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:m!==null}),children:[(0,ie.jsxs)("button",{type:"button",tabIndex:m===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>f("insertLink"),children:[(0,ie.jsx)(xp,{}),(0,ie.jsx)("span",{children:"\xA0"}),(0,ie.jsx)("span",{children:r("insertLink")})]}),a&&c&&(0,ie.jsx)("button",{type:"button",tabIndex:m===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>{let w=v.toString(),T=new URLSearchParams({text:w});d&&l&&T.set("profile",l);let k=Sp(c,T);window.open(k,"_blank")},children:(0,ie.jsx)("span",{children:r("addToPersonalCollection")})})]}),m==="insertLink"&&(0,ie.jsx)(wp,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:x,onDismiss:()=>{f(null),y.close()}})]})})]},"selection-end")},$r=class extends Tp.Matcher{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,o){return this.props=o,this.charCount=0,this.startRef=(0,me.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,s]=this.props.selection;if(o===s)return null;let r=this.foundIndex===0?o:s,i=r>=this.charCount&&r<=this.charCount+n.length?{index:r-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let a=this.foundIndex===1;return i&&a?this.charCount+=r-this.charCount:this.charCount+=n.length,i?h({isStart:a},i):null}replaceWith(n,o){return o.isStart?(0,ie.jsx)(ly,{ref:this.startRef}):(0,ie.jsx)(dy,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Rp=require("react-redux");var Ct=require("react/jsx-runtime"),cy=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:c})=>{let l=C("TabCompletion",up),d=R("insertLink"),p=R("addToPersonalCollection"),u=R("showMidSentenceSuggestions"),m=R("inlineSuggestions"),f=lp(a),g=(0,wt.useRef)(null),y=(0,Rp.useSelector)(re);(0,wt.useEffect)(()=>{yn(a)&&f&&dp(a,f)},[f]);let v=(0,wt.useCallback)(T=>{if(!s||!n)return T;let k=[(0,Ct.jsx)("span",{className:l.resetIndent,children:"\u200B"},"u200B"),(0,Ct.jsx)("span",{"data-testid":"tab-completion",className:(0,Gr.default)(l.tabText,l.resetIndent),"data-source":c,children:n},"tabText")];return o&&k.push((0,Ct.jsx)("span",{className:(0,Gr.default)(l.hint,l.resetIndent),children:(0,Ct.jsx)(ms,{keyCode:"tab"},"tabHint")},"tabHint")),xa(T,k)},[s,n,o]),x=(0,wt.useMemo)(()=>{let T=[];return(d||p)&&T.push(new $r("selection")),T.push(new Vr("placeholders")),r&&T.push(new Wr("keywords")),T},[m,d,p,r]),w=(0,wt.useMemo)(()=>{let T=window.getComputedStyle(a);return{"--dd-color":T.color,"--dd-font-size":T.fontSize,"--dd-font-family":T.fontFamily,"--dd-font-variant":T.fontVariant}},[]);return!t||!y?null:(0,Ct.jsxs)("div",{ref:T=>{T!=null&&T.parentElement&&(g.current=T==null?void 0:T.parentElement)},className:l.root,style:w,children:[(0,Ct.jsx)(Ep.Interweave,{tagName:"span",containerTagName:"div",className:(0,Gr.default)(l.container,l.agentText),disableLineBreaks:yn(a),content:e||"\u200B",onAfterParse:v,matchers:x,selection:f,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:g,inlineSuggestionsOnlyAtEnd:!u}),(0,Ct.jsx)("br",{})]},"tab-completion")},uy=t=>{var v,x,w;let{input:e,ui:n,settings:o,styleSuggestions:s,conversation:r}=t,i=An({input:e}),a=(i==null?void 0:i.text)||"",c=(i==null?void 0:i.source)||"",l=(v=e.html)!=null?v:Wn(e.text),d=e.text.slice(e.suggestionTextStart,e.selection.end),p=a.indexOf(d)===0?a.slice(d.length):"",{showTabHint:u}=n,{isSupported:m}=r,{showTabCompletion:f,visible:g,showStyleSuggestions:y}=o;return{showTabHint:u,showStyleSuggestions:y,showTabCompletion:f&&nt(t),content:l,tabText:p,source:c,keywordMatches:(w=(x=s.list)==null?void 0:x.keywordMatches)!=null?w:[],enabled:g&&m!==!1}},Pp=(0,kp.connect)(uy)(cy);var Fe=require("react"),G=require("react-redux");var Jo=require("@reduxjs/toolkit");var py={token:null,interval:null},ka=(0,Jo.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>S(null,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),Ra=(0,Jo.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(ka()),setInterval(()=>o(ka()),n)}),Ip=(0,Jo.createSlice)({name:"passwordlessToken",initialState:py,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(ka.fulfilled,(e,n)=>{e.token=n.payload.token}),t.addCase(Ra.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollPasswordlessToken:Ap}=Ip.actions,Lp=Ip.reducer;var Mp=require("@reduxjs/toolkit");function gy(t){return"buttonText"in t&&"eventName"in t}function Np(t){if(t)return gy(t)?{label:t.buttonText,event:t.eventName,value:t.payload}:t}function my(t){return t==null?void 0:t.map(e=>Np(e))}function fy(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}var Op=(0,Mp.createSelector)([Rd,bs],(t,e)=>(e?t.filter(s=>!s.externalConversationId||s.externalConversationId===e):t).map(s=>{var a;let r=Np(s.callToAction),i=my(s.callToActions);return b(h(h(h(h({text:s.response,title:s.name},r?{callToAction:r}:{}),i!=null&&i.length?{callToActions:i}:{}),s.message!==void 0?{message:s.message}:{}),(a=s.sources)!=null&&a.length?{sources:s.sources}:{}),{editable:s.editable,isLoading:s.isLoading,evaluationId:s.evaluationId,rule:{id:fy(s.code),label:s.code,name:s.name,description:s.name}})}));var Qr=require("react"),Ia=_(require("classnames"));var Pa=require("react/jsx-runtime"),Jn=()=>(0,Pa.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,Pa.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 Dp={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var rt=require("react/jsx-runtime"),hy=({entities:t})=>{let e=C("EntitiesWidgetList",Dp),[n,o]=(0,Qr.useState)(void 0),s=J(),r=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),Je(a.text),s("entity copied",{entity:a,type:"copy"}))};return(0,Qr.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[n]),!t||t.length===0?null:(0,rt.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,c)=>(0,rt.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,rt.jsx)("span",{className:e.entityText,children:a.text}),(0,rt.jsxs)("span",{className:e.iconWrapper,children:[(0,rt.jsx)("span",{className:(0,Ia.default)(e.icon),children:(0,rt.jsx)(Jn,{})}),(0,rt.jsx)("span",{className:(0,Ia.default)(e.icon,n===c&&e.iconClicked),children:(0,rt.jsx)(Jn,{})})]})]},a.text))})},_p=hy;var Aa=require("react/jsx-runtime"),Fp=()=>(0,Aa.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Aa.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 Vp=require("react"),Xr=require("react-redux");var Hp={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var Bp={root:"dd-nazq3",rotation:"dd-3EHTv"};var Kp=require("react/jsx-runtime"),yy=({size:t=12})=>{let e=C("LoadingSpinner",Bp);return(0,Kp.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},Up=yy;var La=require("react/jsx-runtime"),Wp=()=>(0,La.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:(0,La.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var Zo=require("react/jsx-runtime"),zp=t=>(0,Zo.jsxs)("svg",b(h({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},t),{children:[(0,Zo.jsx)("title",{id:"checkTitle",children:"Check"}),(0,Zo.jsx)("path",{fill:"#666",d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"})]}));var Ma={};ee(Ma,{enUS:()=>vy,nlNL:()=>Sy});var vy={error:[{type:0,value:"Something went wrong"}]},Sy={error:[{type:0,value:"Er ging iets fout"}]};var ke=require("react/jsx-runtime"),xy=3e3,by=({assistantOptions:t})=>{let e=C("OnDemandAssistants",Hp),n=A(Ma),o=(0,Vp.useRef)(),s=(0,Xr.useDispatch)(),r=go(we),i=(0,Xr.useSelector)(_c),a=J(),c=i.filter(u=>u.isPinned),l=i.filter(u=>!u.isPinned),d=()=>S(null,null,function*(){return t.attachments&&t.attachments.length>0?t.attachments:s(((u,m,f)=>S(null,null,function*(){let g;if(t.transcript==="in-memory-transcript"){let y=f.dynamicThunkObject.conversationQuery;if(y){let v=yield y();g=Array.isArray(v)?v:void 0}}else Array.isArray(t.transcript)&&(g=t.transcript);return Fi({transcript:g})})))}),p=u=>S(null,null,function*(){clearTimeout(o.current);let m=yield d();a("trigger on demand assistant",{assistantCode:u}),yield r.call(h(b(h({},t),{assistantCode:u}),m.length>0?{attachments:m}:{})),o.current=setTimeout(()=>r.reset(),xy)});return i.length===0?null:(0,ke.jsxs)("div",{className:e.root,children:[c.map(({assistant:u,assistantName:m,displayName:f})=>(0,ke.jsx)("button",{type:"button",className:e.button,disabled:r.state==="loading",onClick:()=>p(u),children:f||m},u)),l.length>0&&(0,ke.jsxs)($,{placement:"top-end",children:[(0,ke.jsx)($.Trigger,{className:e.trigger,disabled:r.state==="loading",children:(0,ke.jsx)(Sr,{"data-testid":"trigger"})}),(0,ke.jsx)($.Content,{className:e.nav,"data-testid":"popover",children:l.map(({assistant:u,assistantName:m,displayName:f})=>(0,ke.jsx)($.Button,{className:e.item,disabled:r.state==="loading",onClick:()=>p(u),children:f||m},u))})]}),r.state==="loading"&&(0,ke.jsx)(Up,{}),r.state==="done"&&(0,ke.jsx)(zp,{"data-testid":"trigger-done"}),r.state==="error"&&(0,ke.jsx)(tc,{trigger:(0,ke.jsx)(Wp,{}),children:n("error")})]})},jp=by;var $p=require("react-redux");var vn=require("react");var Yo={};ee(Yo,{enUS:()=>Cy,nlNL:()=>wy});var Cy={useCue:[{type:0,value:"Add to message"}],__summarizerAssistant__:[{type:0,value:"Summary"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},wy={useCue:[{type:0,value:"Voeg toe aan bericht"}],__summarizerAssistant__:[{type:0,value:"Samenvatting"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Na={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",ctaMessage:"dd-ge8nB",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l",form:"dd-sPNU2",formInput:"dd-F3E4I",formSubmit:"dd-vw5S0",actionButton:"dd-cCWyJ",editableCue:"dd-nWSD-",inputSpace:"dd-DGYB1"};var ae=require("react/jsx-runtime"),Ty=500,Ey=100,ky=({content:t,onChange:e,onCopy:n})=>{let o=(0,vn.useRef)(null),s=C("WidgetCue",Na);return(0,vn.useEffect)(()=>{let r=o.current;if(!r)return;r.style.setProperty("height","0px");let i=Math.min(Math.max(r.scrollHeight,Ey),Ty);r.style.setProperty("height",`${i}px`)},[t]),(0,ae.jsx)("textarea",{ref:o,className:s.editableCue,onCopy:n,onChange:e,value:t})},Ry=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:s,onSourceClick:r})=>{var y;let i=C("WidgetCue",Na),a=A(Yo),c=J(),l=R("hasKeyboardInput"),[d,p]=(0,vn.useState)(t.text),u=v=>{let x=v?b(h({},t),{callToAction:v}):t;e&&e(d,x),n(t)},m=(v,x)=>{o&&o(v,t),x&&Nt(x,i.fadeup)},f=v=>{s&&s(v,t)},g=v=>{v.preventDefault(),v.stopPropagation(),n(t)};return(0,vn.useEffect)(()=>{c("Assistant response displayed",{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text})},[]),(0,ae.jsxs)(M,{"data-testid":"cue",children:[(0,ae.jsx)(B,{children:(0,ae.jsxs)(B.Content,{children:[t.title&&(0,ae.jsx)(B.Title,{className:i.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?a(t.rule.label):t.title}),t.message&&(0,ae.jsx)("p",{className:i.ctaMessage,children:t.message}),t.editable?(0,ae.jsx)(ky,{content:d,onCopy:()=>{let v=document.getSelection();v&&m(v.toString())},onChange:v=>{var x;return p((x=v.target.value)!=null?x:"")}}):(0,ae.jsx)(an,{content:t.text,sources:t.sources,onSourceClick:v=>r==null?void 0:r(v,t),useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:m,onUse:l?f:void 0})]})}),(0,ae.jsxs)(M.ButtonsContainer,{children:[(0,ae.jsxs)("div",{className:i.actions,children:[(0,ae.jsx)(M.Button,{onClick:v=>{var x;return m((x=Ws(d,"reply")[0])!=null?x:d,v.target)},variant:"primary",children:a("copyCue")}),t.callToAction&&(0,ae.jsx)(M.Button,{onClick:()=>u(),variant:"primary",children:t.callToAction.label}),(y=t.callToActions)==null?void 0:y.map((v,x)=>(0,ae.jsx)(M.Button,{onClick:()=>u(v),variant:"primary",children:v.label},`${v.event}-${v.label}-${x}`)),(0,ae.jsx)(M.Button,{onClick:g,variant:"secondary",children:a("removeCue")})]}),(0,ae.jsx)(Qs,{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text,feedbackType:"assistant"})]})]})},qp=Ry;var Zn=require("react/jsx-runtime"),Py=({cues:t})=>{let e=(0,$p.useDispatch)(),n=ve(),o=A(Yo),s=J(),r=d=>{e(Vs({code:d.rule.label})),s("Assistant response closed",{evaluationId:d.evaluationId,assistantCode:d.rule.label,assistantOutput:d.text})},i=(d,p)=>{Je(d),s("Assistant response copied",{evaluationId:p.evaluationId,assistantCode:p.rule.label,assistantOutput:p.text,copiedText:d})},a=(d,p)=>{var u;p.callToAction&&(e(zs(p)),s("Assistant call to action",{evaluationId:p.evaluationId,assistantCode:p.rule.label,assistantOutput:p.text,eventName:p.callToAction.event,value:(u=p.callToAction.value)!=null?u:d}))},c=(d,p)=>{var u;n.send(ct,{text:d,suggestion:{source:"assistant",assistantCode:(u=p.rule)==null?void 0:u.label,sourceText:d}}),s("Assistant response used",{evaluationId:p.evaluationId,assistantCode:p.rule.label,assistantOutput:p.text,usedText:d})},l=(d,p)=>{s("Assistant source clicked",{evaluationId:p.evaluationId,assistantCode:p.rule.label,source:d})};return(0,Zn.jsx)(Zn.Fragment,{children:t.map(d=>d.isLoading?(0,Zn.jsx)(tr,{title:d.rule.label.startsWith("__")?o(d.rule.label):d.title},d.rule.id):(0,Zn.jsx)(qp,{cue:d,onCallToAction:a,onRemove:r,onCopy:i,onUse:c,onSourceClick:l},d.evaluationId))})},Gp=Py;var Jr=require("react");var Qp={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var xe=require("react/jsx-runtime");function Iy(t,e){return e.split(".").reduce((n,o)=>!n||typeof n!="object"||!(o in n)?null:n[o],t)}var Xp=({data:t,schema:e})=>{let n=C("WidgetCustomData",Qp),o=s=>{Je(s)};return(0,Jr.useEffect)(()=>{P.info("Custom data",t,e)},[t]),(0,xe.jsx)("dl",{className:n.root,children:e.map(s=>{let r=Iy(t,s.path);return(0,xe.jsxs)(Jr.Fragment,{children:[(0,xe.jsx)("dt",{className:n.label,children:s.label}),(0,xe.jsx)("dd",{className:n.value,children:s.type==="boolean"&&r?(0,xe.jsx)("span",{className:n.isTrue,children:s.trueValue}):s.type==="boolean"&&!r?(0,xe.jsx)("span",{className:n.isFalse,children:s.falseValue}):s.type==="array"&&Array.isArray(r)&&r.length>0?(0,xe.jsxs)("button",{type:"button",onClick:()=>o(r.join(", ")),className:n.copyButton,children:[(0,xe.jsx)("span",{className:n.copyButtonText,children:r.join(", ")}),(0,xe.jsx)(Jn,{})]}):typeof r=="string"||typeof r=="number"?(0,xe.jsxs)("button",{type:"button",onClick:()=>o(`${r}`),className:n.copyButton,children:[(0,xe.jsx)("span",{className:n.copyButtonText,children:r}),(0,xe.jsx)(Jn,{})]}):"-"})]},s.label)})})};var Zp=require("react");var Ay=/(https?:\/\/[^\s]+)/,Jp=t=>t.split(" ").find(e=>Ay.test(e));var _e=require("react/jsx-runtime"),Ly=({suggestion:t,lines:e,onUse:n})=>{var p;let o=t.text||t.url||t.message,s=Jp(o),r=A(Bo),i=R("showImages"),a=R("fallbackImage"),c=R("hasKeyboardInput"),l=u=>{u.preventDefault(),u.stopPropagation(),c&&n(o)},d=(0,Zp.useCallback)(u=>{window.open(s,"_blank"),u.stopPropagation(),u.preventDefault()},[s]);return(0,_e.jsxs)(M,{onClick:c?l:void 0,"data-testid":"edit-suggestion",children:[(0,_e.jsxs)(B,{children:[i&&t.image&&(0,_e.jsx)(B.Image,{src:jr(t,"small",a||void 0),title:t.title}),(0,_e.jsxs)(B.Content,{children:[t.title&&(0,_e.jsx)(B.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((p=t.searchKeywords)==null?void 0:p.length)>0&&(0,_e.jsx)(M.Labels,{labels:t.searchKeywords}),(0,_e.jsx)(B.Content,{cropText:e==="single",lineClamp:e==="multiple",children:o})]})]}),(0,_e.jsxs)(M.Actions,{children:[s&&(0,_e.jsx)(M.ActionButton,{onClick:d,label:r("visitUrl")}),c&&(0,_e.jsx)(M.ActionButton,{primary:!0,onClick:l,label:r("useSuggestion")})]})]})},Yp=Ly;var es=require("react/jsx-runtime"),My=({lines:t,suggestions:e})=>{let n=ve(),o=(s,r)=>{n.send(ct,{text:s,suggestion:b(h({},r),{source:r.source,sourceText:r.text})})};return(0,es.jsx)(es.Fragment,{children:e.map(s=>(0,es.jsx)(Yp,{suggestion:s,lines:t,onUse:r=>o(r,s)},s.text||s.url||s.message))})},eg=My;var ts={};ee(ts,{enUS:()=>Ny,nlNL:()=>Oy});var Ny={waiting:[{type:0,value:"Loading\u2026"}],waitingForConversation:[{type:0,value:"Waiting for conversation\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],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"}],close:[{type:0,value:"Close"}]},Oy={waiting:[{type:0,value:"Laden\u2026"}],waitingForConversation:[{type:0,value:"Wachten op gesprek\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],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"}],close:[{type:0,value:"Sluiten"}]};var Sn={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x",interactiveAssistantTabs:"dd-eSP1-",interactiveAssistantTab:"dd-CwcHD",interactiveAssistantTabActive:"dd-GzRs-"};var L=require("react/jsx-runtime"),tg=(t,e)=>{let n=(0,G.useSelector)(re);(0,Fe.useEffect)(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},Dy=({onLogIn:t})=>{let e=C("Widget",Sn),n=R("isEmbedded"),o=R("adminUrl");return(0,L.jsx)("div",{className:e.loginText,children:(0,L.jsx)("div",{children:(0,L.jsx)(Or,{isEmbedded:n,loginUrl:o,onLogIn:t})})},"login")},Oa=({text:t})=>{let e=C("Widget",Sn);return(0,L.jsx)("div",{className:e.stateText,children:(0,L.jsx)("div",{children:(0,L.jsx)("p",{children:t})})},"notification")},_y=()=>{let t=A(ts),e=(0,G.useDispatch)(),n=C("Widget",Sn),o=R("showSearch"),s=R("isEmbedded"),r=(0,G.useSelector)(Fn("/admin/")),i=ve(),a=R("productName"),c=J();return tg(()=>{if(s)return e(Ra()),()=>{e(Ap())}},[e,s]),!o&&!r?null:(0,L.jsxs)("div",{className:n.shortcutList,children:[o&&(0,L.jsx)(M.Button,{"data-testid":"shortcut-search","aria-label":t("linkSearch"),className:n.shortcut,icon:(0,L.jsx)(Vn,{}),onClick:()=>{i.send("ShowCommandPalette",{isOpen:!0}),c("open search",{via:"widget-shortcut"})},children:t("linkSearch")}),r&&(0,L.jsx)(M.Button,{as:"a",target:"_blank",icon:(0,L.jsx)(Fp,{}),href:r,"data-testid":"shortcut-studio-login","aria-label":t("linkStudioLogin",{productName:a}),className:n.shortcut,rel:"noreferrer",onClick:()=>{c("open my deepdesk",{via:"widget-shortcut"})},children:t("linkStudioLogin",{productName:a})})]})},Fy=({title:t,content:e})=>{let n=A(ts),[o,s]=(0,Fe.useState)(!0);return o?(0,L.jsx)(Qe,{"data-testid":"custom-data-banner",type:"custom-data-banner",title:t,children:(0,L.jsx)(se,{withDivider:!0,children:(0,L.jsxs)(M,{children:[(0,L.jsx)(B,{children:(0,L.jsx)(B.Content,{children:(0,L.jsx)(an,{content:e})})}),(0,L.jsx)(M.ButtonsContainer,{children:(0,L.jsx)(M.Button,{onClick:()=>s(!1),children:n("close")})})]})})}):null},Hy=()=>{let t=(0,G.useDispatch)(),e=(0,G.useSelector)(Mo),n=(0,G.useSelector)(Hc),o=(0,G.useSelector)(Op),s=(0,G.useSelector)(Xl),r=(0,G.useSelector)(yr),i=(0,G.useSelector)(br),a=(0,G.useSelector)(Ne),c=(0,G.useSelector)(Pe);return(0,Fe.useEffect)(()=>{s&&!n&&P.warn("Custom data provided, but no schema.")},[s,n]),tg(()=>{e.forEach(({type:l})=>{l==="entities"?t(je()):vs.includes(l)||t(qe(l))})},[t,c,a]),(0,Fe.useEffect)(()=>{o.length>0&&!e.some(l=>l.type==="cues")&&P.warn("Received cues, but cues are not configured in widget.")},[e,o]),(0,L.jsx)(Fe.Fragment,{children:e.map(({type:l,title:d,amount:p,lines:u,schema:m,property:f})=>{var g,y;switch(l){case"entities":return r&&r.length>0&&(0,L.jsx)(Qe,{type:l,title:d,"data-testid":`type-${l}`,children:(0,L.jsx)(_p,{entities:r})},l);case"cues":return o&&o.length>0&&(0,L.jsx)(Qe,{type:l,title:d,"data-testid":`type-${l}`,children:(0,L.jsx)(se,{withDivider:!0,children:(0,L.jsx)(Gp,{cues:o})})},l);case"custom-data-banner":return s&&f&&s[f]&&(0,L.jsx)(Fy,{title:d,content:String(s[f])},l);case"custom-data":return s&&m&&(0,L.jsx)(Qe,{type:l,title:d,"data-testid":`type-${l}`,children:(0,L.jsx)(se,{withDivider:!0,children:(0,L.jsx)(Xp,{data:s,schema:m})})},l);default:return((y=(g=i[l])==null?void 0:g.suggestions)==null?void 0:y.length)>0&&(0,L.jsx)(Qe,{type:l,title:d,"data-testid":`type-${l}`,children:(0,L.jsx)(se,{withDivider:!0,children:(0,L.jsx)(eg,{lines:u,contentType:l,suggestions:i[l].suggestions.slice(0,p)||[]})})},l)}})})},Da=({children:t})=>{let e=C("Widget",Sn);return(0,L.jsx)("div",{className:e.footer,children:t})},_a=({children:t})=>{let e=C("Widget",Sn);return(0,L.jsx)("div",{className:e.root,"data-testid":"widget",children:t})},By=({onLogIn:t,knowledgeAssistOptions:e={},assistantOptions:n={transcript:"in-memory-transcript"},openAdminFeedback:o})=>{var T;let s=A(ts),r=C("Widget",Sn),i=(0,G.useDispatch)(),a=(0,G.useSelector)(In),c=(0,G.useSelector)(re),l=(0,G.useSelector)(bs),d=(0,G.useSelector)(Ne),p=(0,G.useSelector)(Fc("knowledge-assist")),u=(0,G.useSelector)(Bc),m=(0,G.useSelector)(Ad),f=(0,G.useSelector)(Id),g=(T=u.find(k=>k.code===m))!=null?T:u[0],[y,v]=(0,Fe.useState)(e.initialQuestion);(0,Fe.useEffect)(()=>{v(e.initialQuestion)},[l,e.initialQuestion]),(0,Fe.useEffect)(()=>{if(!l)return;let k=ao(l);k&&i(Bi(k))},[i,l]),(0,Fe.useEffect)(()=>{if(u.length===0)return;let k=u.some(E=>E.code===m);(!m||!k)&&i(Hi(u[0].code))},[u,m,i]);let x=!!p&&u.length>0&&!!g,w=(g==null?void 0:g.displayName)||(g==null?void 0:g.name)||(p==null?void 0:p.title)||"Knowledge Assistant";return a===!1?(0,L.jsx)(Oa,{text:s("notSupported")}):c===!1?(0,L.jsx)(Dy,{onLogIn:t}):c===null?(0,L.jsx)(Oa,{text:s("waiting")}):!l||!d?(0,L.jsx)(Oa,{text:s("waitingForConversation")}):(0,L.jsx)(Gd,{handler:o,children:(0,L.jsx)(_a,{children:(0,L.jsxs)(rr,{initialQuestion:y,onInitialQuestionConsumed:()=>v(void 0),assistantCode:g==null?void 0:g.code,threadId:f,onThreadIdChange:k=>{g!=null&&g.code&&k!=null&&i(Ui({assistantCode:g.code,threadId:k}))},evaluateKnowledgeAssistFn:Eo,children:[(0,L.jsxs)(kn,{children:[(0,L.jsx)(_y,{}),(0,L.jsx)(Hy,{}),x&&(0,L.jsx)(ar,{title:w,emptyState:e.emptyState})]}),(0,L.jsxs)(Da,{children:[x&&u.length>1&&(0,L.jsx)("div",{className:r.interactiveAssistantTabs,"data-testid":"widget-interactive-assistant-tabs",children:u.map(k=>{let E=k.code===(g==null?void 0:g.code);return(0,L.jsx)("button",{type:"button","aria-pressed":E,className:E?r.interactiveAssistantTabActive:r.interactiveAssistantTab,onClick:()=>i(Hi(k.code)),children:k.displayName||k.name},k.code)})}),x&&(0,L.jsx)(ir,{}),(0,L.jsx)(jp,{assistantOptions:n})]})]},g==null?void 0:g.code)})})},ng=By;function Yn(t){let e=new Range;return e.selectNodeContents(t),e}function og(t,e,n){try{return zt(t,e,n),!0}catch(o){return!1}}function Zr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Yr(t){return"tagName"in t&&t.tagName==="BR"}var ns=/[\u200B-\u200D\uFEFF]/g;function zt(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let s=0,r=!1;function i(c,l){let d=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(c))return l;for(let u=0;u<=c.length;u++)if(p.test(c[u])||d++,d===l)return u;throw new Error("Offset out of range")}function a(c){switch(c.nodeType){case Node.TEXT_NODE:{let l=c.textContent,d=l.replace(ns,""),p=s+d.length,u=e>=s&&e<=p,m=n>=s&&n<=p;if(u){let f=i(l,e-s);f===0&&!m?o.setStartBefore(c):o.setStart(c,f)}m&&(o.setEnd(c,i(l,n-s)),r=!0),s=p;break}case Node.ELEMENT_NODE:{if(Yr(c)&&(s===e&&o.setStartBefore(c),s++,s===n)){o.setEndAfter(c),r=!0;return}for(let d=0;d<c.childNodes.length&&(a(c.childNodes[d]),!r);d++);let l=c.lastChild;Zr(c)&&l&&!Zr(l)&&!Yr(l)&&s++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function os(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r,collapsed:i}=e,a,c,l=0;function d(p){let u=p===t,m=p===n,f=p===s;switch(p.nodeType){case Node.TEXT_NODE:{let g=p.textContent;m&&(a=l+g.substring(0,o).replace(ns,"").length),f&&(c=l+g.substring(0,r).replace(ns,"").length),l+=g.replace(ns,"").length;break}case Node.ELEMENT_NODE:{if(Yr(p)&&p.nextSibling){l++;break}!u&&Zr(p)&&p.previousSibling&&l++;for(let g=0;g<p.childNodes.length;g++){let y=m&&g===o,v=f&&g===r;if(y&&(a=l),v&&(c=l),c!==void 0||((!y||!i)&&d(p.childNodes[g]),f&&g===r-1&&(c=l),c!==void 0))break}f&&(c=l);break}default:break}}if(d(t),c===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:c,end:c}}function ss(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r,collapsed:i}=e,a=0,c="";function l(d){let p=d===t,u=d===n,m=d===s;switch(u&&(a=1),d.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let f=u?o:0,g=m?r:void 0;c+=d.textContent.replace(ns,"").substring(f,g);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&Yr(d)&&d.nextSibling){c+=`
|
|
10
10
|
`;break}!p&&!i&&a===1&&Zr(d)&&d.previousSibling&&(c+=`
|
|
11
|
-
`);let f=u?o:0,g=m?Math.min(r,d.childNodes.length):d.childNodes.length;for(let y=f;y<g&&(l(d.childNodes[y]),a!==2);y++);break}default:break}m&&(a=2)}return l(t),c}var og=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(og||{}),Ct=class{constructor(e){this.element=e;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedSuggestionTextStart=0;this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedSuggestionTextStart=this.getSuggestionTextStart(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(e,n){let o=s=>{n(s)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}handleInteraction(){let e=this.getText(),n=this.getHTML(),o=this.getSelection(),s=this.getSuggestionTextStart(),r=this.cachedCaretPosition===null;if(!this.isActive)return;e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit");let i=e!==this.cachedText,a=n!==null&&n!==this.cachedHTML,c=s!==this.cachedSuggestionTextStart;if((i||a||c)&&(i?(this.cachedText=e,this.cachedHTML=n):a&&(this.cachedHTML=n),this.cachedSuggestionTextStart=s,r=!0,this.emit("change",{plainText:e,rawHTML:n,suggestionTextStart:s})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,r=!0,this.emit("selection",o)),!r)return;let l=this.getCaretPosition();It(l,this.cachedCaretPosition)||(this.cachedCaretPosition=l,this.emit("caretposition",l))}handleClick(){this.handleInteraction()}handleFocus(){let e=!this.isFocused;this.isFocused=!0,e&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let e=this.isFocused;this.isFocused=!1,e&&this.emit("blur")}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(og).includes(n)||n.toLowerCase()==="z"&&(o||s),this.emit("keydown",e)}handleKeyUp(e){this.handleInteraction(),this.emit("keyup",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var o,s;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),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.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()})}getSuggestionTextStart(){return 0}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}off(e,n){if(!this.eventListeners[e])return;let o=this.eventListeners[e].indexOf(n);o!==-1&&this.eventListeners[e].splice(o,1)}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function sg(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Sn=class extends Ct{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),ns(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){let n=this.getRootNode();if(n.activeElement!==this.element)return null;let o="getSelection"in n?n.getSelection():window.getSelection();if(!o)return null;let s=o.rangeCount>0?o.getRangeAt(0):null;if(!s)return null;let r=this.element.ownerDocument.createRange();return r.setStart(s==null?void 0:s.startContainer,s==null?void 0:s.startOffset),r.setEnd(s==null?void 0:s.endContainer,s==null?void 0:s.endOffset),!r||!this.element.contains(r.startContainer)||!this.element.contains(r.endContainer)?null:r}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let o=n.getBoundingClientRect();return!sg(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!sg(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let n=this.getRange();if(n)return ts(this.element,n);let o=this.lastKnownSelection;if(o&&ng(this.element,o.start,o.end))return o;let s=Yn(this.element);return s.collapse(!1),ts(this.element,s)}getSelectedText(){let{start:n,end:o}=this.getSelection();return ns(this.element,Wt(this.element,n,o))}listen(){super.listen();let n=new MutationObserver(r=>{var i,a;r.length===2&&r[0].addedNodes.length===1&&((i=r[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=r[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let o=this.element.isContentEditable,s=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>s.disconnect())}};var By=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function rg(t,e){let n="mozInnerScreenX"in window,o=document.createElement("div");o.id="input-textarea-caret-position-mirror-div";let s=o.style,r=window.getComputedStyle(t),i=t.ownerDocument.body;s.whiteSpace="pre-wrap",s.wordWrap="break-word",s.position="absolute",s.visibility="hidden",By.forEach(d=>{s[d]=r[d]}),n?t.scrollHeight>Number.parseInt(r.height)&&(s.overflowY="scroll"):s.overflow="hidden",o.textContent=t.value.substring(0,e);let a=document.createElement("span");a.textContent=t.value.substring(e)||".",o.appendChild(a),i.appendChild(o);let c=t.getBoundingClientRect(),l={top:c.top-t.scrollTop+a.offsetTop+Number.parseInt(r.borderTopWidth)+a.offsetHeight,left:c.left-t.scrollLeft+a.offsetLeft+Number.parseInt(r.borderLeftWidth)};return i.removeChild(o),l}var xn=class extends Ct{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:o}=this.element;return{start:n,end:o}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return rg(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var r;return(r=n==null?void 0:n.get)==null?void 0:r.call(this.element)},set:r=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,r),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let o=this.element.disabled,s=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>s.disconnect())}};function ig(t,e,n){let o=`deepdesk-iframe-${t}`,s=document.getElementById(o);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(n).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=o,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}function Uy(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch(e){return t}}var Fa=class{constructor(e){this.name=e;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(e)}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()}},Ha=class{constructor(e,n,o){this.name=e;this.targetOrigin=n;this.options=o;this.disposeHandlers=[];this.iframe=ig(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(n=>n()),(e=this.iframe)==null||e.remove()}},Ba=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(e){this.externalId!==e&&(this.cleanup(),P.info("Set externalId",e),this.externalId=e,this.channel=this.createChannel(e))}createChannel(e){let n=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Ha(e,this.deepdeskUrl,{debug:!0}):new Fa(e),o=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=Uy(s.data);typeof r!="object"||r.type!=="event"||r.channel!==e||(P.info("Received broadcast event",this.externalId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return n.onMessage(o),n}send(e,n,o){var i,a;P.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let s={type:"event",name:e,payload:n};o!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,n));let r=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage(b(h({},s),{channel:this.externalId}))}cleanup(e=!1){var n,o;(n=this.channel)==null||n.close(),this.channel=void 0,e&&((o=this.defaultChannel)==null||o.close(),this.defaultChannel=void 0)}},ag=Ba;function Ky(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function V(t){return Array.isArray(t)?t.map(V):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>b(h({},e),{[Ky(n)]:V(t[n])}),{}):t}function Wy(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function le(t){return Array.isArray(t)?t.map(le):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>b(h({},e),{[Wy(n)]:le(t[n])}),{}):t}var eo=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var os=t=>new Promise(e=>{setTimeout(e,t)});var qe=class extends eo{constructor(){super(...arguments);this.name="ClientError"}},ei=class extends eo{constructor(){super(...arguments);this.name="ServerError"}},Ua=new Map;function lg(t){return S(this,null,function*(){if(t.status===204)return t.text().catch(()=>{}),null;let e=t.headers.get("content-type");if(e!=null&&e.includes("application/json"))return t.json();let n=yield t.text();return n===""?null:(P.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var bn=class{constructor(e="",n={}){this.baseUrl=e;this.options=n;this.latestRequestByUrl={};this.refreshingToken=null;this.lastFailedRefreshAt=null;this.failedRefreshCooldown=1e4;var o;this.fetch=(o=n.fetch)!=null?o:window.fetch.bind(window)}patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,n={}){return new Promise((o,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,c=n.method===void 0||n.method.toLowerCase()==="get",E=n,{useCache:l=!1,abortLatest:d=!1,attempts:p=1,retryDelay:u=500,refreshTokenOn401:m=!0,retryOnError:f=I=>I instanceof TypeError,retryOnResponse:g=I=>I.status>=500,version:y=null}=E,v=D(E,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(l){if(!c)throw new Error(`Can't use 'useCache' for ${n.method}`);if(Ua.has(i)){o(Ua.get(i));return}}let x=b(h({credentials:"include"},v),{headers:h({Accept:"application/json","Content-Type":"application/json"},v.headers)});!c&&this.csrfToken&&(x.headers=b(h({},x.headers),{"X-CSRFToken":this.csrfToken})),typeof y=="string"&&(x.headers=b(h({},x.headers),{"X-Deepdesk-API-Version":y}));let w=p,T=!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 k=()=>S(this,null,function*(){return w--,a(i,x).then(I=>S(this,null,function*(){return g(I)&&!r.isAborted&&w>0?(yield os(u),k()):I.status===401&&m===!0&&T===!1?(T=!0,yield this.refreshToken(),k()):I})).catch(I=>S(this,null,function*(){if(f(I)&&!r.isAborted&&w>0)return yield os(u),k();throw I}))});k().then(I=>S(this,null,function*(){let N=yield lg(I);if(delete this.latestRequestByUrl[i],I.status>=500){s(new ei("Server Error",N));return}if(I.status===401){s(new qe("Unauthorized",N));return}if(I.status===403){s(new qe("Forbidden",N));return}if(I.status===404){s(new qe("Not Found",N));return}if(I.status>=400){s(new qe("Bad Request",N));return}l&&Ua.set(i,N),o(N)})).catch(I=>{s(I)})})}validateToken(){return S(this,null,function*(){let e,n,o;try{({has_valid_access_token:e,is_logged_in:n,has_valid_refresh_token:o}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1}))}catch(s){return!1}if(!e){if(!o)return!1;try{yield this.refreshToken();let{is_logged_in:s}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return s}catch(s){return!1}}return n})}refreshToken(){let e=Date.now();return this.lastFailedRefreshAt&&e-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new qe("Unauthorized","Failed to refresh token")):this.refreshingToken?this.refreshingToken:(this.refreshingToken=this.get("/apis/admin/session/refresh/",{refreshTokenOn401:!1}).catch(n=>{throw(n==null?void 0:n.message)==="Unauthorized"&&(this.lastFailedRefreshAt=Date.now()),n}).finally(()=>{this.refreshingToken=null}),this.refreshingToken)}get(e,n){return this.request(e,n)}post(e,n,o){return this.request(e,h({method:"POST",body:JSON.stringify(n)},o))}postWithStatus(e,n,o){return this.requestWithStatus(e,h({method:"POST",body:JSON.stringify(n)},o))}requestWithStatus(e,n={}){return new Promise((o,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,k=n,{useCache:c=!1,abortLatest:l=!1,attempts:d=1,retryDelay:p=500,refreshTokenOn401:u=!0,retryOnError:m=E=>E instanceof TypeError,retryOnResponse:f=E=>E.status>=500,version:g=null}=k,y=D(k,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]),v=b(h({credentials:"include"},y),{headers:h({Accept:"application/json","Content-Type":"application/json"},y.headers)});this.csrfToken&&(v.headers=b(h({},v.headers),{"X-CSRFToken":this.csrfToken})),typeof g=="string"&&(v.headers=b(h({},v.headers),{"X-Deepdesk-API-Version":g}));let x=d,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let T=()=>S(this,null,function*(){return x--,a(i,v).then(E=>S(this,null,function*(){return f(E)&&!r.isAborted&&x>0?(yield os(p),T()):E.status===401&&u===!0&&w===!1?(w=!0,yield this.refreshToken(),T()):E})).catch(E=>S(this,null,function*(){if(m(E)&&!r.isAborted&&x>0)return yield os(p),T();throw E}))});T().then(E=>S(this,null,function*(){let I=yield lg(E);if(delete this.latestRequestByUrl[i],E.status>=500){s(new ei("Server Error",I));return}if(E.status===401){s(new qe("Unauthorized",I));return}if(E.status===403){s(new qe("Forbidden",I));return}if(E.status===404){s(new qe("Not Found",I));return}if(E.status>=400){s(new qe("Bad Request",I));return}o({status:E.status,data:I})})).catch(E=>{delete this.latestRequestByUrl[i],s(E)})})}patch(e,n,o){return this.request(e,h({method:"PATCH",body:JSON.stringify(n)},o))}put(e,n,o){return this.request(e,h({method:"PUT",body:JSON.stringify(n)},o))}delete(e,n){return this.request(e,h({method:"DELETE"},n))}};var dg;(e=>{let t;(a=>(a.SUCCESS="success",a.FAILURE="failure",a.CONDITIONS_NOT_MET="conditions_not_met",a.MAX_RECURSION_LEVEL="max_recursion_level",a.NO_ACCESS_TO_ASSISTANT="no_access_to_assistant"))(t=e.EvaluationStatus||(e.EvaluationStatus={}))})(dg||(dg={}));function ti(t){return b(h({},V(t)),{metadata:t.metadata})}var Cn=class Cn{constructor(e,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new bn(e,{fetch:n.fetch}),this.client.patchFetch(o=>(s,r)=>S(this,null,function*(){let i=yield o(s,r);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return S(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=yield this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(Cn.exchangeTokenPromise||(Cn.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),Cn.exchangeTokenPromise):Promise.resolve()})}createConversation(e){return S(this,null,function*(){var o;yield this.preflight(),P.info(`Creating conversation for session ${e.externalId} and agent ${e.agentId}`);let n=yield this.client.post("/api/v2/conversations",b(h({chat_start_time:new Date().toISOString()},le(e)),{metadata:(o=e.metadata)!=null?o:{}}));return ti(n)})}upsertConversation(e){return S(this,null,function*(){var d;yield this.preflight(),P.info(`Upserting conversation for session ${e.externalId} and agent ${e.agentId}`);let{status:n,data:o}=yield this.client.postWithStatus("/api/v2/conversations",b(h({chat_start_time:new Date().toISOString()},le(e)),{metadata:(d=e.metadata)!=null?d:{}}),{version:"v2"}),s=ti(o);if(n===201)return s;let{agentId:r,agentName:i,agentEmail:a,agentNickname:c,metadata:l}=e;return this.updateConversation(s.id,{agentId:r,agentEmail:a,agentName:i,agentNickname:c,metadata:l})})}getMe(){return S(this,null,function*(){yield this.preflight();let e=yield this.client.get("/apis/admin/session/me/");return V(e)})}postIdentity(e){return S(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",le(e))})}patchMe(e){return S(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",le(e));return V(n)})}getProfile(e){return S(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${e}/`,{useCache:!0});return V(n)})}getKnowledgeAssistant(e){return S(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{useCache:!0});return V(n)})}getContentTypes(){return S(this,null,function*(){let e=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return V(e)})}getAccount(){return S(this,null,function*(){let e=yield this.client.get("/apis/admin/account/",{useCache:!0});return V(e)})}getPlatformConfig(e){return S(this,null,function*(){let n=e!==void 0?`/platform/config/${e}/`:"/platform/config/",{config:o}=yield this.client.get(n,{useCache:!0});return V(o)})}checkUserExists(e){return S(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${e}`,{version:"v1"});return n})}getConversationByExternalId(o){return S(this,arguments,function*(e,n={}){yield this.preflight(),P.info(`Getting conversation for session ${e}`);let{attempts:s=1,retryDelay:r=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return P.info(`Successfully retrieved conversation ${i.id} for session ${e}`),ti(i)})}isConversationSupported(o){return S(this,arguments,function*(e,n={}){P.info(`Check if conversation for session ${e} is supported`);let{attempts:s=1,retryDelay:r=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(e,n){return S(this,null,function*(){var r;yield this.preflight();let o=le(n);n.metadata&&(o.metadata=(r=n.metadata)!=null?r:{});let s=yield this.client.put(`/api/v2/conversations/${e}`,o);return ti(s)})}postMessages(e,n){return S(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${e}/messages`,n.map(o=>b(h({},le(o)),{metadata:o.metadata})))})}sendEvent(e,n){return S(this,null,function*(){yield this.preflight();let a=n,{data:o}=a,s=D(a,["data"]),r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((c,[l,d])=>b(h({},c),{[l]:d}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((c,l)=>(s[l]&&(c[l]=s[l]),c),{});return this.client.post("/api/v2/events",le(b(h(h({},r),i),{data:o,name:e})),{version:"v2"})})}getEntities(e){return S(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:e.filter(o=>o.text)})})}getTemporaryExchangeToken(){return S(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(e){return S(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:e}).catch(n=>{throw P.warn(`Invalid token '${e}'`),n})})}authenticateWithKey(e,n){return S(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",le(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(s){return S(this,arguments,function*(e,n={},o){if(yield this.preflight(),o==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${e}/recommend/${o}`,le(n),{abortLatest:!0})).map(i=>b(h({},V(i)),{text:i.text||i.url||i.message,source:o,type:o})).filter((i,a,c)=>a===c.findIndex(l=>l.text===i.text))})}isLoggedIn(){return S(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(e,n){return S(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${e}/autocomplete`,le(n),{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))})}getPinnedMessages(e){return S(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return V(n).map(o=>b(h({},o),{text:o.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(e){return S(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",le(e),{abortLatest:!0,version:"v2"});return V(n)})}search(e){return S(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${e.profile}/search`,le(e));return V(n)})}loginWithPassword(e,n){return S(this,null,function*(){yield this.preflight();let o=yield this.client.post("/apis/admin/session/login/",{username:e,password:n},{refreshTokenOn401:!1});return V(o)})}logout(){return S(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/logout/",{},{refreshTokenOn401:!1})})}requestLoginByEmail(e){return S(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:e});return V(n)})}requestPasswordlessToken(){return S(this,null,function*(){let e=yield this.client.get("/apis/admin/session/passwordless/request/");return V(e.token)})}getCsrfToken(){return S(this,null,function*(){let{token:e}=yield this.client.get("/apis/admin/session/csrf/");return e})}verifyLoginToken(e){return S(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:e});return V(n)})}evaluateAssistant(e,n){return S(this,null,function*(){var c,l,d;yield this.preflight();let o=new URLSearchParams;n!=null&&n.externalConversationId&&o.append("external_conversation_id",n.externalConversationId);let s=n!=null&&n.threadId?`/api/v2/assistants/${e}/threads/${n==null?void 0:n.threadId}/evaluate?${o.toString()}`:`/api/v2/assistants/${e}/evaluate?${o.toString()}`,r=p=>le(p),i=(c=n==null?void 0:n.transcript)==null?void 0:c.map(p=>{var u;return h({source:p.source,text:p.text},(u=p.attachments)!=null&&u.length?{attachments:p.attachments.map(r)}:{})}),a=yield this.client.post(s,h({input:(l=n==null?void 0:n.input)!=null?l:{},conversation:i},(d=n==null?void 0:n.attachments)!=null&&d.length?{attachments:n.attachments.map(r)}:{}));return V(a)})}interactWithAssistant(e){return S(this,null,function*(){yield this.preflight();let n=new URLSearchParams;e.sessionId&&n.append("session_id",e.sessionId),e.externalConversationId&&n.append("external_conversation_id",e.externalConversationId);let o=`/api/v2/assistants/${e.assistantCode}/interact?${n.toString()}`,s=yield this.client.post(o,{message:e.message});return V(s)})}createAssistantThread(e){return S(this,null,function*(){yield this.preflight();let{assistantCode:n}=e,o=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return V(o)})}postMessageToAssistantThread(e){return S(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:s}=e,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:s,role:"user"});return V(r)})}translateMessages(e){return S(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",le(e));return V(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let s=o.toLowerCase(),r=s.match(Sl);if(!n||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&P.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};Cn.exchangeTokenPromise=null;var wt=Cn;var ni=class{constructor(e){this.options=e;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,o;this.socket,this.eventListeners=new Map,this.url=e.url,this.maxReconnectAttempts=(n=e.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(o=e.reconnectInterval)!=null?o:this.reconnectInterval,this.shouldReconnect=e.shouldReconnect}connect(){let e=()=>this.cleanup();window.addEventListener("beforeunload",e),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",e)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=e=>{var n;try{let o=V(JSON.parse(e.data));o.event&&this.eventListeners.has(o.event)&&((n=this.eventListeners.get(o.event))==null||n.forEach(s=>s(o.data)))}catch(o){console.error("Error parsing WebSocket message:",o)}},this.socket.onclose=e=>{console.log("WebSocket connection closed:",e),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=e=>{console.error("WebSocket error:",e)})}reconnect(){var e,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(e=this.socket)==null||e.close();return}if(!this.shouldReconnect()){console.error("Should not reconnect, closing WebSocket connection."),(n=this.socket)==null||n.close();return}this.socket&&(this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this.socket=new WebSocket(this.url),this.setupListeners(),this.maxReconnectAttempts--}send(e,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:e,data:n}))}on(e,n){this.eventListeners.has(e)||this.eventListeners.set(e,[]);let o=this.eventListeners.get(e);o&&!o.includes(n)&&o.push(n)}close(){var e;(e=this.socket)==null||e.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(e=>e()),this.cleanupCallbacks=[]}};var si=require("@reduxjs/toolkit");var ug=require("@reduxjs/toolkit");var cg={startTime:null,stopTime:null},pg=t=>t.handlingTime,gg=(0,ug.createSlice)({name:"handlingTime",initialState:cg,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(j,()=>cg)}}),{handlingTimeStart:mg,handlingTimeStop:oi,handlingTimeReset:fg}=gg.actions,hg=gg.reducer;var yg=(t={})=>{let e=h({onAuthError:Rn(!1)},t);return n=>o=>s=>("error"in s&&s.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(s))};var vg=(t={})=>{let e,n=!0,o=h({getStyleSuggestions:mn,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:u}=l.input;return u===a&&!n||(clearTimeout(e),u==="")||(e=setTimeout(()=>{n=!1,s.dispatch(o.getStyleSuggestions({text:u}))},t.debounce)),c}};function zy(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end&&t.suggestionTextStart===e.suggestionTextStart}var Sg=(t={})=>{let e=h({getTextSuggestions:je,getAutocompleteSuggestions:Uo,debounce:200,check:tt},t),n;return o=>s=>r=>{var g;let{input:i}=o.getState(),a=s(r),c=o.getState();if(c.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:d}=c.settings,p=(g=c.conversation.current)==null?void 0:g.id,u=r.type===Cr.toString();if(!p||!l&&!d)return a;let{input:m}=c;return zy(m,i)&&!u||(clearTimeout(n),!e.check(c))||(n=setTimeout(()=>{let y=Xt(c);y===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(y))},u?0:e.debounce)),a}};var xg=mn.fulfilled.toString();function Vy(t,e){let n=new Set([...e.keywordMatches.map(s=>s.keyword)]),o=[];return n.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||o.push(...i.slice(0,a))}),o}var bg=t=>e=>n=>o=>{var l;if(o.type!==xg){n(o);return}let s=e.getState().styleSuggestions.list;n(o);let r=e.getState(),i=r.styleSuggestions.list,a=(l=r.conversation)==null?void 0:l.current;if(s===i)return;let c=Vy(s,i);o.type===xg&&c.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:c}})};var jy=(0,si.combineReducers)({assistants:Hd,auth:Rl,conversation:Ol,contentTypes:Nc,passwordlessToken:Ap,entities:ou,handlingTime:hg,info:od,input:$l,settings:Wd,profile:Bc,search:dd,styleSuggestions:Vu,ui:Mu,textSuggestions:mu});function Cg(t){return(0,si.configureStore)({reducer:jy,middleware:e=>{var o;let n=e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}).concat(yg()).concat(Sg({debounce:200})).concat(vg({debounce:500})).concat(bg(t.deepdeskAPI));return((o=t.middleware)!=null?o:[]).reduce((s,r)=>s.concat(r),n)},preloadedState:t.preloadedState})}function wg(t,e,n){if(e==="")return null;let o=new RegExp(`\\b${Hr(e)}\\b`,"gi"),s,r=null;for(;(s=o.exec(t))!==null&&!(s.index>n);)r={start:s.index,end:s.index+s[0].length};return r}var qy=t=>{var e,n;return(n=(e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())!=null?n:"unknown"},$y=t=>e=>n=>o=>{var c,l,d,p,u,m;let s=e.getState(),r=on("inlineSuggestions")(s),i=on("autoSelectSuggestion")(s)||r;switch(o.type){case Rn.toString():{!o.payload&&t.emit("logout",void 0);break}case ys.fulfilled.toString():{t.emit("logout",void 0);break}case Ve.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:(c=s.conversation.current)==null?void 0:c.id,data:{entities:o.payload}});break;case Yt.toString():t.logSendMessage(o.payload);break;case zs.toString():t.emit("call-to-action",{cue:o.payload});break;case be.fulfilled.toString():if(!o.isBroadcasted){let{externalConversationId:f,currentExternalIdAtRequest:g}=(l=o.payload)!=null?l:{};(!f||!g||f===g)&&t.broadcast(Ei,o,!1)}break;case be.rejected.toString():break;default:break}let a=n(o);switch(o.type){case Yt.toString():t.handleAfterSendMessage(o.payload);break;case Wo.toString():t.onUpdateShowTabHint(o.payload);break;case oi.toString():t.logHandlingTime();break;case An.toString():t.broadcast(Ls,o);break;case Zt.toString():t.broadcast(Ls,o);break;case Vs.toString():e.dispatch(Zt({source:"assistant",assistantCode:o.payload.code}));break;case"analytics/logEvent/fulfilled":{let f=s.assistants.cues.find(g=>g.code===o.meta.arg.data.assistantCode);t.emit("event",b(h({},o.meta.arg),{cue:f}));break}case Se.toString():{let{start:f,end:g}=s.input.selection;t.emit("select-suggestion",b(h({type:qy(o.payload.suggestion)},o.payload),{replace:o.payload.replace==="selection"?{start:f,end:g}:{start:0,end:g}})),r&&e.dispatch(At([]));break}case zu.toString():{let{keyword:f,suggestion:g,eventMetrics:y}=o.payload,{text:v,selection:x}=s.input,w=wg(v,f,(d=x==null?void 0:x.end)!=null?d:v.length);if(!w)break;t.emit("select-suggestion",{text:g,type:"style",replace:w,suggestion:{text:g,source:"style"},eventMetrics:y});break}case Ts.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(p=s.conversation.current)==null?void 0:p.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case At.toString():{i&&o.payload.length>0&&e.dispatch(Es(0));break}case be.fulfilled.toString():{let{evaluationId:f,output:g,externalConversationId:y}=o.payload,v=o.meta.arg.assistantCode;if(t.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:f,assistantCode:v,assistantOutput:Md(g),externalConversationId:y,evaluationStatus:"success"}}),!o.meta.arg.skipState){let x=e.getState().assistants.cues;t.emit("cues",x)}break}case be.rejected.toString():{let f=o.meta.arg.assistantCode,g=(m=o.meta.arg.externalConversationId)!=null?m:(u=e.getState().conversation.current)==null?void 0:u.externalId;t.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:"",assistantCode:f,assistantOutput:"",externalConversationId:g,evaluationStatus:"failed"}});break}default:break}return a},Tg=$y;var Eg=require("@reduxjs/toolkit");function Ka(t){return t.toISOString().replace("T"," ").replace("Z","")}var Gy=(t,e)=>e.version,kg=(0,Eg.createSelector)([Ln,Re,pg,Gy],(t,e,n,o)=>{if(!e)return P.warn("No conversationId for handling time metrics"),null;let{startTime:s,stopTime:r}=n;return!s||!r?(P.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:e,clientVersion:o,agentId:t==null?void 0:t.agentId,agentName:t==null?void 0:t.agentName,agentEmail:t==null?void 0:t.agentEmail,timeStart:Ka(s),timeStop:Ka(r)}});function Rg(t,e){let{text:n,metrics:{numPaste:o,pastes:s,textSuggestions:r}}=t.input,i=n.length;return{source:"agent",clientVersion:e.version,pastes:s,lenTextTotal:i,numPastes:o,suggestions:r}}var ss=class extends Error{};function Qy(){let t,e;return{promise:new Promise((o,s)=>{t=o,e=s}),resolve:t,reject:e}}var ri=class{constructor(){this.queues={}}push(e,n){let o=()=>{let r=this.queues[e][1];r?(this.queues[e]=[r.promise,null],r.resolve()):delete this.queues[e]};if(!this.queues[e]){let r=n().finally(o);return this.queues[e]=[r,null],r}this.queues[e][1]&&this.queues[e][1].reject(new ss("Queued async function is outdated"));let s=Qy();return this.queues[e][1]=s,s.promise.then(()=>n().finally(o))}};function Wa(t,e){var r;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return Wa(o,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?Wa(s,e):null}function za(t,e){return Wa(t,e)}var Xy={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},Pg=(t,e)=>{var s,r,i;if(!((i=(r=(s=t.uiConfig)==null?void 0:s.widget)==null?void 0:r.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return P.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let o=t[Xy[e]];return o&&o.length>0?o.map(a=>a.code):(P.warn(`No assistant set in profile for conversation event "${e}"`),[])};function Jy(t){var e,n,o,s;return(s=(o=(n=(e=t.uiConfig)==null?void 0:e.widget)==null?void 0:n.types)==null?void 0:o.some(r=>r.type==="knowledge-assist"&&r.isActive))!=null?s:!1}function Ig(t){var n,o;return((o=(n=t.widgetInteractiveAssistants)==null?void 0:n.length)!=null?o:0)>0&&Jy(t)?!0:!!t.knowledgeAssistantNew||!!t.knowledgeAssistant}function Zy(t){return typeof t=="object"&&t!==null&&"tagName"in t}function ii(t){return Zy(t)&&(hn(t)||_r(t))}var Lg,rt=new Map,Yy=["bottom","height","left","right","top","width"],Ag=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:Yy.some(n=>t[n]!==e[n]);function Mg(t){var n,o,s;if(t.ownerDocument===document)return[];let e=(s=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?s:null;return e?[e,...Mg(e)]:[]}function Ng(t,e){return!t||!e?null:b(h({},t),{top:t.top+e.top,left:t.left+e.left})}var ai=!1,Og=()=>{ai=!0;let t=[];if(rt.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),rt.delete(n);return}let o=n.getBoundingClientRect();Ag(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{let n=e.parentRects?e.parentRects.reduce(Ng,e.rect):e.rect;Ag(n,e.totalRect)&&e.callbacks.forEach(o=>o(n)),e.totalRect=n}),rt.size===0){ai=!1;return}Lg=window.requestAnimationFrame(Og)};function Va(t,e){let n=Mg(t),o=[],s=n.map((r,i)=>Va(r,a=>{o[i]=a;let c=rt.get(t);if(!c)return;let l=o.reduce(Ng,c.rect);c.callbacks.forEach(d=>d(l))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),rt.has(t)){let i=rt.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else rt.set(t,{rect:void 0,callbacks:[e],parentRects:o});r&&!ai&&Og()},unobserve(){s.forEach(i=>i.unobserve());let r=rt.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||rt.delete(t),rt.size||(cancelAnimationFrame(Lg),ai=!1)}}}}var Dg,it=new Map,_g=()=>{it.forEach((t,e)=>{if(!e.isConnected){it.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,s=o>n;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),it.size!==0&&(Dg=window.requestAnimationFrame(_g))};function Fg(t,e){return{observe(){let n=it.size===0;it.has(t)?it.get(t).callbacks.push(e):it.set(t,{visible:void 0,callbacks:[e]}),n&&_g()},unobserve(){let n=it.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||it.delete(t),it.size||cancelAnimationFrame(Dg)}}}}var ja=["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 qa(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function to(t){return Number.parseFloat(t)}function li(t){return Math.round(t*1e6)}function Hg(t){return t/1e6}function $a(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,s=to(t.width),r=to(t.borderLeftWidth),i=to(t.borderRightWidth),a=to(t.paddingRight),c=Hg(li(s)-li(r)-li(i)),l=Hg(li(o));if(c-l>2){let d=c-l;n.style.paddingRight=`${a+d}px`}}function rs(t,e={}){var d,p;let n=e.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(d=e.position)!=null?d:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",rn(n);let o=window.getComputedStyle(t),s=!0,r=()=>{n.scrollTop=t.scrollTop};qa(o,n,ja),$a(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",r));let i=Fg(t,()=>{qa(o,n,ja),$a(o,t,n),r(),setTimeout(r,0)}),a,c=!0,l=Va(t,u=>{if(u===null){e.onRemove&&e.onRemove(),n.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(),n.style.display="none",s=!0;return}if(qa(o,n,ja),$a(o,t,n),r(),e.placement==="below"&&n.classList.add("below"),n.style.top=`${u.top}px`,n.style.left=`${u.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let m=e.closestScrollElement.getBoundingClientRect(),f=window.getComputedStyle(e.closestScrollElement),g=to(f.borderTopWidth),y=to(f.borderBottomWidth),v=m.top+g-u.top,x=u.top+u.height+-(m.top+m.height-y);n.style.clipPath=`inset(${v}px 0px ${x}px 0px)`}s&&(n.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(n):(p=t.parentElement)==null||p.appendChild(n),l.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",r),l.unobserve(),i.unobserve(),n.remove()}]}function ev(t){return t.offsetParent!==null}function Bg(t){if(!ev(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 di(t,e,n=100){let o=Bg(t);e({isVisible:o});let s=setInterval(()=>{let r=Bg(t);r!==o&&(o=r,e({isVisible:o}))},n);return()=>{clearTimeout(s)}}var Ug=(t,e)=>({value(){try{let n=sessionStorage.getItem(`dd-${t}`);if(!n)return e;try{return JSON.parse(n)}catch(o){return e}}catch(n){return e}},update(n){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(n))}catch(o){P.warn("[Deepdesk] SessionStorage is blocked by browser")}}});var U=require("react/jsx-runtime");var Kg=Ug("showTabHint",!0),no=class no{constructor({deepdeskUrl:e,version:n=no.version||"unknown",locale:o="en-US",token:s,fetch:r,productName:i,createCustomChannel:a,websocketClient:c=ni}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.disposeHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.belowSuggestions=null;this.floatingMenu=null;this.widgetElement=null;this.widgetRoot=null;this.nicknameDialogUnsubscribe=null;this.nicknameDialogFailed=!1;this.dynamicThunkObject={};this.queues=new ri;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;this.loadProfileConfigPromiseKey=null;let l=e.replace(/\/api$/,"");this.deepdeskApi=new wt(l,{token:s,fetch:r}),this.version=n,this.instanceId=no.count++;let d={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Tg({broadcast:(f,g,y)=>{this.broadcastEvents.send(f,g,y)},emit:(f,g)=>this.emit(f,g),handleAfterSendMessage:f=>this.handleAfterSendMessage(f),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:f=>this.logSendMessage(f),onUpdateShowTabHint:f=>Kg.update(f),sendEvent:(f,g)=>this.deepdeskApi.sendEvent(f,g)})]};this.store=Cg(d),this.broadcastEvents=new ag({debug:!0,deepdeskUrl:l,eventMap:cd(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new c({url:`${l}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>S(this,null,function*(){var f;return(f=re(this.state))!=null?f:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(Wo(Kg.value())),this.store.dispatch(To({locale:o,adminUrl:l,productName:i}));let p=[],u=f=>{if(!f.conversationId)return;let g=()=>{this.conversationId()===f.conversationId&&this.store.dispatch(_d(f))};this.hasConversation()?g():p.push(g)};this.ws.on("assistants::direct_response",u),this.ws.on("assistants::user_notification",u),this.ws.on("assistants::response_chunk",f=>{if(!f.conversationId)return;let g=()=>{this.conversationId()===f.conversationId&&this.store.dispatch(Dd(f))};this.hasConversation()?g():p.push(g)}),this.ws.on("assistants::suggest_as_reply",f=>{if(!f.conversationId)return;let g=()=>{this.conversationId()===f.conversationId&&this.store.dispatch(An([{text:f.payload.message,type:"text",source:"assistant",assistantCode:f.code,sourceLabel:f.name}]))};this.hasConversation()?g():p.push(g)});let m=this.whenConversationLoaded(()=>{var f;this.broadcastEvents.setExternalId((f=this.state.conversation.current)==null?void 0:f.externalId),p.forEach(g=>g()),p.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),p.length=0,m()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var e;return(e=Jt(this.state)[this.state.input.selectedSuggestionIndex])!=null?e:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}externalId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.externalId}shouldAbort(){return this.state.conversation.isSupported===!1?(P.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(P.warn("Profile has not been loaded (yet)"),!0):(P.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(e){if(re(this.state))e();else{let n=this.subscribe(re,o=>{o&&e()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch(Rn(null)),this.store.dispatch(lt()),new Promise(e=>{this.whenLoggedIn(()=>e())})}isLoggedIn(){return S(this,null,function*(){return(yield this.store.dispatch(lt())).payload})}isConversationSupported(e,n){return S(this,null,function*(){return(yield this.store.dispatch(vi({externalId:e,options:n}))).payload})}createConversation(e){return S(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(bs(b(h({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}getConversationByExternalId(e,n){return S(this,null,function*(){return this.hasConversation()&&this.externalId()!==e&&this.resetConversation(),(yield this.store.dispatch(Cs({externalId:e,options:n}))).payload})}upsertConversation(e){return S(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Si(b(h({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return S(this,null,function*(){yield this.store.dispatch(xi(e))})}updateConversation(e){return S(this,null,function*(){return(yield this.store.dispatch(ws(e))).payload})}resetConversation(){this.store.dispatch(j()),this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(To(e))}setVisitorInfo(e){this.store.dispatch(Yl(e))}setCustomData(e){this.store.dispatch(ed(e))}setAgentInfo(e,n){return S(this,null,function*(){var s;yield this.store.dispatch(lo(h(h({},e),n))),(s=this.state.info.agentInfo)!=null&&s.agentNickname||this.broadcastEvents.send(As,{showNicknameDialog:!0})})}setAgentSettings(e){return S(this,null,function*(){yield this.store.dispatch(Ci(e))})}getAgentSettings(){return S(this,null,function*(){return(yield this.store.dispatch(wi())).payload})}getMe(){return S(this,null,function*(){return this.deepdeskApi.getMe()})}refresh(){return S(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let e=[];return e.push(this.refreshTextSuggestions()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(ks({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()}))}notifyExternalSuggestion(e){this.store.dispatch(Se(e))}evaluateAssistant(e,n){return S(this,null,function*(){var d;let{input:o={},attachments:s=[],transcript:r,showCuesInWidget:i=!0,includeMetadata:a,externalConversationId:c}=n||{},l=yield this.store.dispatch(be({assistantCode:e,attachments:s,transcript:r,includeMetadata:a,input:o,externalConversationId:c,skipState:!i}));if(l.error)throw new Error(`Assistant evaluation failed: ${(d=l.payload)!=null?d:l.error.message}`);return l.payload.output})}evaluateConversationAssistant(e,n){return S(this,null,function*(){var d,p,m;yield this.loadProfileConfig();let o=this.state.profile.data;if(!o&&((d=this.state.conversation.current)!=null&&d.profileCode)&&(yield this.loadProfileConfig(),o=this.state.profile.data),!o){P.warn("Can't evaluate assistant when profile is not loaded yet.");return}let s=Pg(o,e),r=(p=n==null?void 0:n.showCuesInWidget)!=null?p:!0,u=n!=null?n:{},{showCuesInWidget:i}=u,a=D(u,["showCuesInWidget"]),c=(m=n==null?void 0:n.externalConversationId)!=null?m:this.hasConversation()?this.externalId():"",l=yield Promise.all(s.map(f=>this.queues.push(f,()=>S(this,null,function*(){var y,v;let g=yield this.store.dispatch(be(h(b(h({assistantCode:f,includeMetadata:!0},a),{skipState:!r}),n!=null&&n.attachments&&(n==null?void 0:n.attachments.length)>0?{attachments:n==null?void 0:n.attachments}:{})));if(g.error)throw new Error(`Assistant evaluation failed: ${(y=g.payload)!=null?y:g.error.message}`);return{assistantCode:f,evaluationId:g.payload.evaluationId,output:g.payload.output,externalConversationId:(v=g.payload.externalConversationId)!=null?v:c}})).catch(g=>{if(g instanceof ss)return P.warn(`Queued assistant "${f}" was outdated and dropped`),null;throw g})));if(!r)return l.filter(f=>f!==null)})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:s,selectedSuggestionIndex:r,selection:i}=this.state.input,{inlineSuggestions:a,autoSelectSuggestion:c,showTextSuggestions:l,suggestionsPlacement:d}=this.settings,p=a||c,u=d==="inline"||d==="below"?"below":"above",m=s.length>0;if(this.store.dispatch(Ul(bi(e))),!tt(this.state)||e.key!=="Tab"&&!l)return;let f=()=>{n||!m||i&&(e.shiftKey||(this.store.dispatch(zl()),e.preventDefault()))},g=()=>{n||!m||p&&r<=0||i&&(e.shiftKey||(this.store.dispatch(Vl()),e.preventDefault()))};switch(e.key){case"ArrowUp":u==="below"?g():f();break;case"ArrowDown":{u==="below"?f():g();break}case"Escape":{n||(this.store.dispatch(Es(-1)),this.store.dispatch(Ft({collapse:!0})),this.store.dispatch(Au(!0)),e.preventDefault());break}case"Tab":{e.preventDefault();let y=In(this.state);if(!y)return;this.store.dispatch(Wo(!1)),this.store.dispatch(Se({text:y.text,suggestion:y,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(p||this.state.input.selectedSuggestionIndex===-1)return;let y=In(this.state);if(!y)return;this.store.dispatch(Se({text:y.text,suggestion:y,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(p||e.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let y=In(this.state);if(!y)return;this.store.dispatch(Se({text:y.text,suggestion:y,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),e.preventDefault();break}default:}n&&o&&this.store.dispatch(Ft({collapse:!1}))}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(At([]))}handlingTimeStart(){this.state.handlingTime.startTime||(P.info("Start handling time"),this.store.dispatch(mg()))}handlingTimeStop(){this.state.handlingTime.startTime&&(P.info("Stop handling time"),this.store.dispatch(oi()))}logSendMessage(e){let n=Rg(this.state,{version:this.version});n&&(e&&(Object.assign(n,{text:e}),Object.assign(n,{lenTextTotal:e.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let e=kg(this.state,{version:this.version});e&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:e}),this.store.dispatch(fg()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch(Yt((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(ql()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(s=>{try{s(n)}catch(r){P.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),P.error(r)}})}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}setPlatformVariables(e){this.store.dispatch(td(e))}whenConversationLoaded(e){let n=()=>this.getConversationLoadedKey(),o=()=>{let r=n();r&&this.loadProfileConfig().then(()=>{if(n()!==r)return;let i=this.state.conversation.current,a=Me(this.state);!(i!=null&&i.id)||i.profileCode&&(a==null?void 0:a.code)!==i.profileCode||e()})};return n()&&o(),this.subscribe(r=>this.getConversationProfileKey(r.conversation.current),r=>{r&&o()})}overlayContainerFactory(e,n,o,s){let[r,i]=rs(n,o);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),[r,i]}createInlineContainer(e,n){var a;let o=document.createElement("div");o.style.position="absolute",o.style.top="0px",o.style.left="0px",o.style.height="0px",o.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",o.appendChild(s);let r=(a=e.ownerDocument.defaultView)==null?void 0:a.frameElement,i=r?r.ownerDocument.defaultView:null;if(r&&(i===window||(i==null?void 0:i.parent)===window)){let[c,l]=rs(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});c.dataset.testid=n,c.style.zIndex="2",c.appendChild(o),this.unmountHandlers.push(()=>{l()})}else document.body.appendChild(o);return s}createContainer(e,n=document.body){let o=window.getComputedStyle(n),s=document.createElement("div");return rn(s),s.dataset.testid=e,s.style.color=o.color,s.style.fontSize=o.fontSize,s.style.fontFamily=o.fontFamily,s.style.fontVariant=o.fontVariant,s.setAttribute("translate","no"),n.appendChild(s),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,n),P.info(`Stored analytics for ${this.conversationId()}`)}catch(e){}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(e);if(!n)return;let o=JSON.parse(n);o.text.trim()===this.state.input.text.trim()?(P.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(jl(o.metrics))):P.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch(e){}}mount(e,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!ii(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let u=n,{customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i,inputMediator:a}=u,c=D(u,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i};this.configure(c),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),rn(e),this.inputMediator=a||(hn(e)?new xn(e):new Sn(e)),this.inputMediator.on("change",({plainText:m,rawHTML:f,suggestionTextStart:g})=>{this.store.dispatch(ks({text:m,html:f,suggestionTextStart:g}))}),this.inputMediator.on("keyup",m=>{this.store.dispatch(Kl(bi(m)))}),this.inputMediator.on("keydown",m=>{this.handleKeyDown(m)}),this.inputMediator.on("paste",({pastedText:m,selectionText:f})=>{this.store.dispatch(Wl({text:m,selectionText:f}))}),this.inputMediator.on("cut",({selectionText:m})=>{this.store.dispatch(Bl(m))});let d;this.inputMediator.on("selection",m=>{clearTimeout(d),m===null?d=setTimeout(()=>{m!==null&&this.store.dispatch(Rs(m))},500):this.store.dispatch(Rs(m))}),this.unmountHandlers.push(()=>{clearTimeout(d)}),this.inputMediator.on("disabled",()=>{var m;(m=this.inputMediator)==null||m.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(kr(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(kr(!0))}),this.renderSuggestions(e,l),this.subscribe(on("inlineSuggestions"),()=>{this.renderSuggestions(e,l)}),this.subscribe(on("suggestionsPlacement"),()=>{this.renderSuggestions(e,l)});let p=this.renderOverlays(n);this.unmountHandlers.push(()=>{p.unmount()}),this.store.dispatch(ks({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()})),this.store.dispatch(Rs(this.inputMediator.getSelection())),this.store.dispatch(kr(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{this.restoreMetrics(),this.syncInputMediator(),this.refreshTextSuggestions(),this.promptForNickname()}),this.isMounted=!0}promptForNickname(e){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let o=(0,Tt.createRoot)(n),s=null,r=a=>{s=a,i()},i=()=>{o==null||o.render((0,U.jsx)(yt,{store:this.store,children:(0,U.jsx)(ct,{broadcastEvents:this.broadcastEvents,children:(0,U.jsx)(Gu,{id:"deepdesk-nickname-dialog",error:s,onSave:a=>S(this,null,function*(){try{yield this.store.dispatch(Jl({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(As,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(c){P.error("Error setting agent nickname",c),r("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{o.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(e,n){let o=e(this.store.getState());return this.store.subscribe(()=>{let s=e(this.store.getState());s!==o&&(o=s,n(o))})}unmount(){var e,n,o,s,r;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.belowSuggestions)==null||o.unmount(),(s=this.floatingMenu)==null||s.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(r=this.inputMediator)==null||r.dispose(),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe(),this.isMounted=!1}dispose(){this.unmount(),this.unmountWidget(),this.disposeHandlers.forEach(e=>e()),this.disposeHandlers=[],this.off()}renderSuggestions(e,n){var o,s,r,i;(o=this.floatingMenu)==null||o.unmount(),(s=this.inlineSuggestions)==null||s.unmount(),(r=this.aboveSuggestions)==null||r.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(e,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(e,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(e,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(e,n,"above")}renderInlineSuggestions(e,n){let{customStyles:o}=n,s=this.createInlineContainer(e,"deepdesk-caret"),r=(0,Tt.createRoot)(s);r.render((0,U.jsx)(yt,{store:this.store,customStyles:o,children:(0,U.jsx)(ct,{broadcastEvents:this.broadcastEvents,children:(0,U.jsx)(ju,{})})}));let i=a=>{a?(s.style.display="block",s.style.top=`${a.top}px`,s.style.left=`${a.left}px`):s.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),r.unmount(),s.remove()}}}renderAboveOrBelowSuggestions(e,n,o){let{customStyles:s,closestScrollSelector:r,appendOverlayTo:i}=n,a=r&&za(e,r)||void 0,[c,l]=this.overlayContainerFactory("deepdesk-tab-completion",a||e,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},s==null?void 0:s.rootNode),[d,p]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||e,{appendTo:i,placement:o},s==null?void 0:s.suggestionsRootNode),u=(0,Tt.createRoot)(c);u.render((0,U.jsx)(yt,{store:this.store,customStyles:s,children:(0,U.jsx)(ct,{broadcastEvents:this.broadcastEvents,children:(0,U.jsx)(Rp,{inputElement:e})})}));let m=(0,Tt.createRoot)(d);return m.render((0,U.jsx)(yt,{store:this.store,customStyles:s,children:(0,U.jsx)(ct,{broadcastEvents:this.broadcastEvents,children:(0,U.jsx)(rp,{onLogIn:()=>this.loginViaPopup().catch(f=>P.warn(f.message))})})})),{unmount(){u.unmount(),m.unmount(),l(),p()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:s,appendOverlayTo:r,floatingMenuParent:i}=n,a=s&&za(e,s)||void 0,[c,l]=this.overlayContainerFactory("floating-menu",a||e,{appendTo:i!=null?i:r},o==null?void 0:o.floatingMenuParent),d=(0,Tt.createRoot)(c);return d.render((0,U.jsx)(yt,{store:this.store,customStyles:o,children:(0,U.jsx)(ct,{broadcastEvents:this.broadcastEvents,children:(0,U.jsx)(Ru,{onLogIn:()=>this.loginViaPopup().catch(p=>P.warn(p.message))})})})),{unmount(){d.unmount(),l()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays"),s=(0,Tt.createRoot)(o);return s.render((0,U.jsx)(yt,{store:this.store,customStyles:n,children:(0,U.jsx)(ct,{broadcastEvents:this.broadcastEvents,children:(0,U.jsx)(xu,{})})})),{unmount(){s.unmount(),o.remove()}}}renderWidget(e,n={}){if(this.widgetElement&&P.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:s,isEmbedded:r,signInViaPopup:i,ssoUrl:a,openAdminFeedback:c}=n;this.widgetElement=e,this.configure({showImages:s,isEmbedded:r,signInViaPopup:i});let l;if(a)try{l={url:new URL(a,this.settings.adminUrl).toString()}}catch(d){P.warn(`Invalid ssoUrl '${a}' passed to renderWidget`)}this.widgetRoot=(0,Tt.createRoot)(e),this.widgetRoot.render((0,U.jsx)(yt,{store:this.store,customStyles:o,children:(0,U.jsx)(ct,{broadcastEvents:this.broadcastEvents,children:(0,U.jsx)(dr,{report:d=>this.deepdeskApi.sendEvent(bc,{data:d}),children:(0,U.jsx)(tg,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,openAdminFeedback:c,onLogIn:()=>this.loginViaPopup(l).catch(d=>P.warn(d.message))})})})}))}unmountWidget(){var e,n;(n=(e=this.widgetRoot)==null?void 0:e.unmount)==null||n.call(e),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(e,n,o={}){let{customStyles:s,initialQuestion:r}=o,i=(0,Tt.createRoot)(n);return i.render((0,U.jsx)(yt,{store:this.store,customStyles:s,children:(0,U.jsx)(ct,{broadcastEvents:this.broadcastEvents,children:(0,U.jsx)(_a,{children:(0,U.jsxs)(rr,{assistantCode:e,initialQuestion:r,evaluateKnowledgeAssistFn:wo,children:[(0,U.jsx)(En,{children:(0,U.jsx)(ar,{title:o.title,emptyState:o.emptyState})}),(0,U.jsx)(Da,{children:(0,U.jsx)(ir,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(e){let n=di(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){lr(e)&&e.message==="Unauthorized"&&this.login()}getConversationProfileKey(e){var n;if(e!=null&&e.id)return`${e.id}:${(n=e.profileCode)!=null?n:""}`}getProfileLoadKey(){var n;let e=this.state.conversation.current;return e!=null&&e.profileCode&&(n=this.getConversationProfileKey(e))!=null?n:null}isCurrentProfileLoadKey(e){return this.getProfileLoadKey()===e}getConversationLoadedKey(){return this.getConversationProfileKey(this.state.conversation.current)}resetProfileDerivedSettings(){this.store.dispatch(ta()),this.store.dispatch(To(Ki))}loadProfileConfig(e=!0){let n=this.getProfileLoadKey();if(!n)return this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=null,this.resetProfileDerivedSettings(),Promise.resolve();let o=this.state.conversation.current,s=Me(this.state);if(s&&s.code!==(o==null?void 0:o.profileCode)&&(this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=null,this.resetProfileDerivedSettings()),this.loadProfileConfigPromise&&this.loadProfileConfigPromiseKey===n)return this.loadProfileConfigPromise;this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=n;let r=Promise.resolve().then(()=>S(this,null,function*(){try{yield this.store.dispatch(Io()).unwrap()}catch(c){if(c===Kn)return this.loadProfileConfigPromise===r&&(this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=null),e&&this.isCurrentProfileLoadKey(n)&&!Me(this.state)?this.loadProfileConfig(!1):void 0;throw c}if(!this.isCurrentProfileLoadKey(n))return;let i=Me(this.state),a=this.state.conversation.current;!i||i.code!==(a==null?void 0:a.profileCode)||this.store.dispatch(To({showSearch:i.search,showImageSearch:i.imageSearch,showEntitiesCommand:i.entitiesCommand,showSummaryCommand:!!i.summarizerAssistantNew,showKnowledgeSearch:Ig(i),recommendTextSuggestions:i.recommendTextSuggestions}))})).finally(()=>{this.loadProfileConfigPromise===r&&(Me(this.state)||(this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=null))});return this.loadProfileConfigPromise=r,r}loginViaPopup(e){return S(this,null,function*(){return new Promise((n,o)=>{this.store.dispatch(vs());let s=new MessageChannel,r=s.port1,i=this.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",p),clearInterval(u)};r.onmessage=m=>S(this,null,function*(){var f,g;if((f=m.data)!=null&&f.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((g=m.data)==null?void 0:g.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(uo),c=!0,s.port1.close(),n()}catch(y){console.error(y),o(y)}finally{c=!0,l()}});let d=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");if(d===null){o(new Error("Popup blocked by browser"));return}let p=m=>S(this,null,function*(){var f;if(!(m.origin!==a.origin||m.source!==d))switch((f=m.data)==null?void 0:f.type){case"deepdesk-popup-request-origin":{try{let g=JSON.stringify({type:"deepdesk-popup-parent-origin"});d.postMessage(g,a.origin)}catch(g){P.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-loaded":{try{let g=JSON.stringify({type:"deepdesk-popup-create-channel"});d.postMessage(g,a.origin,[s.port2])}catch(g){P.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-error":{if(l(),m.data.message==="Platform account url mismatch"){let g="Please contact your administrator: The page that opened the popup is not a trusted origin.";P.warn(g),this.store.dispatch(hi(g)),o(new Error(g));return}if(m.data.message==="Timeout"){let g="Please contact your administrator: Popup timed out. Check if the account's platform.url or account.url is configured correctly.";P.warn(g),this.store.dispatch(hi(g)),o(new Error(g));return}o(new Error(m.data.message));break}}});window.addEventListener("message",p);let u=setInterval(()=>{d&&!d.closed||(l(),c||o(new Error("Popup closed by user")))},200);this.disposeHandlers.push(l)})})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}refreshTextSuggestions(){return S(this,null,function*(){this.isMounted&&(yield this.store.dispatch(Cr()))})}refreshWidgetSuggestions(){return S(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=Ao(this.state);try{n.forEach(({type:o})=>{switch(o){case"entities":this.store.dispatch(Ve());break;case"pinned-messages":case"sticky-messages":break;default:hs.includes(o)||this.store.dispatch(je(o))}})}catch(o){this.handleError(o)}})}};no.version="19.6.2-beta.5",no.count=0;var is=no;function tv(t){return S(this,null,function*(){var s,r,i;let n=yield((s=t.fetch)!=null?s:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(r=t.mimeType)!=null?r:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function Wg(t,e){return S(this,null,function*(){let n=yield tv(e),o=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[n]}),t.dispatchEvent(o)}finally{Object.hasOwn(t,"files")&&delete t.files}})}function zg(t,e,n){return S(this,null,function*(){yield new wt(t).authenticateWithKey(e,n)})}function Vg(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function jg(o,s){return S(this,arguments,function*(t,e,n={}){var p,u;let{value:r}=t,{start:i,end:a}=(p=n.replace)!=null?p:{start:0,end:r.length},c=`${r.slice(0,i)}${e}${r.slice(a)}`,l=(u=n.selectionAfter)!=null?u:{start:i+e.length,end:i+e.length},d=()=>{if(n.setValue)return n.setValue(c);t.value=c};return Promise.resolve(d()).then(()=>{t.selectionStart=l.start,t.selectionEnd=l.end,t.blur(),t.focus()})})}function qg(o,s){return S(this,arguments,function*(t,e,n={}){let r=n.replace?Wt(t,n.replace.start,n.replace.end):Yn(t),i,a=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),i=document.createElement("span"),r.insertNode(i),n.insertBRs!==!1?e.split(`
|
|
12
|
-
`).reverse().forEach((c,l)=>{l>0&&r.insertNode(document.createElement("br")),r.insertNode(document.createTextNode(c))}):r.insertNode(document.createTextNode(e))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let c=n.selectionAfter?
|
|
13
|
-
`).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=n.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(n.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(n.slice(r)))}),e}function
|
|
11
|
+
`);let f=u?o:0,g=m?Math.min(r,d.childNodes.length):d.childNodes.length;for(let y=f;y<g&&(l(d.childNodes[y]),a!==2);y++);break}default:break}m&&(a=2)}return l(t),c}var sg=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(sg||{}),Tt=class{constructor(e){this.element=e;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedSuggestionTextStart=0;this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedSuggestionTextStart=this.getSuggestionTextStart(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(e,n){let o=s=>{n(s)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}handleInteraction(){let e=this.getText(),n=this.getHTML(),o=this.getSelection(),s=this.getSuggestionTextStart(),r=this.cachedCaretPosition===null;if(!this.isActive)return;e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit");let i=e!==this.cachedText,a=n!==null&&n!==this.cachedHTML,c=s!==this.cachedSuggestionTextStart;if((i||a||c)&&(i?(this.cachedText=e,this.cachedHTML=n):a&&(this.cachedHTML=n),this.cachedSuggestionTextStart=s,r=!0,this.emit("change",{plainText:e,rawHTML:n,suggestionTextStart:s})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,r=!0,this.emit("selection",o)),!r)return;let l=this.getCaretPosition();Lt(l,this.cachedCaretPosition)||(this.cachedCaretPosition=l,this.emit("caretposition",l))}handleClick(){this.handleInteraction()}handleFocus(){let e=!this.isFocused;this.isFocused=!0,e&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let e=this.isFocused;this.isFocused=!1,e&&this.emit("blur")}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(sg).includes(n)||n.toLowerCase()==="z"&&(o||s),this.emit("keydown",e)}handleKeyUp(e){this.handleInteraction(),this.emit("keyup",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var o,s;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),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.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()})}getSuggestionTextStart(){return 0}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}off(e,n){if(!this.eventListeners[e])return;let o=this.eventListeners[e].indexOf(n);o!==-1&&this.eventListeners[e].splice(o,1)}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function rg(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var xn=class extends Tt{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),ss(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){let n=this.getRootNode();if(n.activeElement!==this.element)return null;let o="getSelection"in n?n.getSelection():window.getSelection();if(!o)return null;let s=o.rangeCount>0?o.getRangeAt(0):null;if(!s)return null;let r=this.element.ownerDocument.createRange();return r.setStart(s==null?void 0:s.startContainer,s==null?void 0:s.startOffset),r.setEnd(s==null?void 0:s.endContainer,s==null?void 0:s.endOffset),!r||!this.element.contains(r.startContainer)||!this.element.contains(r.endContainer)?null:r}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let o=n.getBoundingClientRect();return!rg(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!rg(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let n=this.getRange();if(n)return os(this.element,n);let o=this.lastKnownSelection;if(o&&og(this.element,o.start,o.end))return o;let s=Yn(this.element);return s.collapse(!1),os(this.element,s)}getSelectedText(){let{start:n,end:o}=this.getSelection();return ss(this.element,zt(this.element,n,o))}listen(){super.listen();let n=new MutationObserver(r=>{var i,a;r.length===2&&r[0].addedNodes.length===1&&((i=r[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=r[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let o=this.element.isContentEditable,s=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>s.disconnect())}};var Uy=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function ig(t,e){let n="mozInnerScreenX"in window,o=document.createElement("div");o.id="input-textarea-caret-position-mirror-div";let s=o.style,r=window.getComputedStyle(t),i=t.ownerDocument.body;s.whiteSpace="pre-wrap",s.wordWrap="break-word",s.position="absolute",s.visibility="hidden",Uy.forEach(d=>{s[d]=r[d]}),n?t.scrollHeight>Number.parseInt(r.height)&&(s.overflowY="scroll"):s.overflow="hidden",o.textContent=t.value.substring(0,e);let a=document.createElement("span");a.textContent=t.value.substring(e)||".",o.appendChild(a),i.appendChild(o);let c=t.getBoundingClientRect(),l={top:c.top-t.scrollTop+a.offsetTop+Number.parseInt(r.borderTopWidth)+a.offsetHeight,left:c.left-t.scrollLeft+a.offsetLeft+Number.parseInt(r.borderLeftWidth)};return i.removeChild(o),l}var bn=class extends Tt{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:o}=this.element;return{start:n,end:o}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return ig(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var r;return(r=n==null?void 0:n.get)==null?void 0:r.call(this.element)},set:r=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,r),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let o=this.element.disabled,s=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>s.disconnect())}};function ag(t,e,n){let o=`deepdesk-iframe-${t}`,s=document.getElementById(o);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(n).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=o,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}function Ky(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch(e){return t}}var Fa=class{constructor(e){this.name=e;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(e)}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()}},Ha=class{constructor(e,n,o){this.name=e;this.targetOrigin=n;this.options=o;this.disposeHandlers=[];this.iframe=ag(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(n=>n()),(e=this.iframe)==null||e.remove()}},Ba=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(e){this.externalId!==e&&(this.cleanup(),P.info("Set externalId",e),this.externalId=e,this.channel=this.createChannel(e))}createChannel(e){let n=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Ha(e,this.deepdeskUrl,{debug:!0}):new Fa(e),o=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=Ky(s.data);typeof r!="object"||r.type!=="event"||r.channel!==e||(P.info("Received broadcast event",this.externalId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return n.onMessage(o),n}send(e,n,o){var i,a;P.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let s={type:"event",name:e,payload:n};o!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,n));let r=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage(b(h({},s),{channel:this.externalId}))}cleanup(e=!1){var n,o;(n=this.channel)==null||n.close(),this.channel=void 0,e&&((o=this.defaultChannel)==null||o.close(),this.defaultChannel=void 0)}},lg=Ba;function Wy(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function j(t){return Array.isArray(t)?t.map(j):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>b(h({},e),{[Wy(n)]:j(t[n])}),{}):t}function zy(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function le(t){return Array.isArray(t)?t.map(le):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>b(h({},e),{[zy(n)]:le(t[n])}),{}):t}var eo=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var rs=t=>new Promise(e=>{setTimeout(e,t)});var $e=class extends eo{constructor(){super(...arguments);this.name="ClientError"}},ei=class extends eo{constructor(){super(...arguments);this.name="ServerError"}},Ua=new Map;function dg(t){return S(this,null,function*(){if(t.status===204)return t.text().catch(()=>{}),null;let e=t.headers.get("content-type");if(e!=null&&e.includes("application/json"))return t.json();let n=yield t.text();return n===""?null:(P.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var Cn=class{constructor(e="",n={}){this.baseUrl=e;this.options=n;this.latestRequestByUrl={};this.refreshingToken=null;this.lastFailedRefreshAt=null;this.failedRefreshCooldown=1e4;var o;this.fetch=(o=n.fetch)!=null?o:window.fetch.bind(window)}patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,n={}){return new Promise((o,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,c=n.method===void 0||n.method.toLowerCase()==="get",E=n,{useCache:l=!1,abortLatest:d=!1,attempts:p=1,retryDelay:u=500,refreshTokenOn401:m=!0,retryOnError:f=I=>I instanceof TypeError,retryOnResponse:g=I=>I.status>=500,version:y=null}=E,v=D(E,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(l){if(!c)throw new Error(`Can't use 'useCache' for ${n.method}`);if(Ua.has(i)){o(Ua.get(i));return}}let x=b(h({credentials:"include"},v),{headers:h({Accept:"application/json","Content-Type":"application/json"},v.headers)});!c&&this.csrfToken&&(x.headers=b(h({},x.headers),{"X-CSRFToken":this.csrfToken})),typeof y=="string"&&(x.headers=b(h({},x.headers),{"X-Deepdesk-API-Version":y}));let w=p,T=!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 k=()=>S(this,null,function*(){return w--,a(i,x).then(I=>S(this,null,function*(){return g(I)&&!r.isAborted&&w>0?(yield rs(u),k()):I.status===401&&m===!0&&T===!1?(T=!0,yield this.refreshToken(),k()):I})).catch(I=>S(this,null,function*(){if(f(I)&&!r.isAborted&&w>0)return yield rs(u),k();throw I}))});k().then(I=>S(this,null,function*(){let W=yield dg(I);if(delete this.latestRequestByUrl[i],I.status>=500){s(new ei("Server Error",W));return}if(I.status===401){s(new $e("Unauthorized",W));return}if(I.status===403){s(new $e("Forbidden",W));return}if(I.status===404){s(new $e("Not Found",W));return}if(I.status>=400){s(new $e("Bad Request",W));return}l&&Ua.set(i,W),o(W)})).catch(I=>{s(I)})})}validateToken(){return S(this,null,function*(){let e,n,o;try{({has_valid_access_token:e,is_logged_in:n,has_valid_refresh_token:o}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1}))}catch(s){return!1}if(!e){if(!o)return!1;try{yield this.refreshToken();let{is_logged_in:s}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return s}catch(s){return!1}}return n})}refreshToken(){let e=Date.now();return this.lastFailedRefreshAt&&e-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new $e("Unauthorized","Failed to refresh token")):this.refreshingToken?this.refreshingToken:(this.refreshingToken=this.get("/apis/admin/session/refresh/",{refreshTokenOn401:!1}).catch(n=>{throw(n==null?void 0:n.message)==="Unauthorized"&&(this.lastFailedRefreshAt=Date.now()),n}).finally(()=>{this.refreshingToken=null}),this.refreshingToken)}get(e,n){return this.request(e,n)}post(e,n,o){return this.request(e,h({method:"POST",body:JSON.stringify(n)},o))}postWithStatus(e,n,o){return this.requestWithStatus(e,h({method:"POST",body:JSON.stringify(n)},o))}requestWithStatus(e,n={}){return new Promise((o,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,k=n,{useCache:c=!1,abortLatest:l=!1,attempts:d=1,retryDelay:p=500,refreshTokenOn401:u=!0,retryOnError:m=E=>E instanceof TypeError,retryOnResponse:f=E=>E.status>=500,version:g=null}=k,y=D(k,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]),v=b(h({credentials:"include"},y),{headers:h({Accept:"application/json","Content-Type":"application/json"},y.headers)});this.csrfToken&&(v.headers=b(h({},v.headers),{"X-CSRFToken":this.csrfToken})),typeof g=="string"&&(v.headers=b(h({},v.headers),{"X-Deepdesk-API-Version":g}));let x=d,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let T=()=>S(this,null,function*(){return x--,a(i,v).then(E=>S(this,null,function*(){return f(E)&&!r.isAborted&&x>0?(yield rs(p),T()):E.status===401&&u===!0&&w===!1?(w=!0,yield this.refreshToken(),T()):E})).catch(E=>S(this,null,function*(){if(m(E)&&!r.isAborted&&x>0)return yield rs(p),T();throw E}))});T().then(E=>S(this,null,function*(){let I=yield dg(E);if(delete this.latestRequestByUrl[i],E.status>=500){s(new ei("Server Error",I));return}if(E.status===401){s(new $e("Unauthorized",I));return}if(E.status===403){s(new $e("Forbidden",I));return}if(E.status===404){s(new $e("Not Found",I));return}if(E.status>=400){s(new $e("Bad Request",I));return}o({status:E.status,data:I})})).catch(E=>{delete this.latestRequestByUrl[i],s(E)})})}patch(e,n,o){return this.request(e,h({method:"PATCH",body:JSON.stringify(n)},o))}put(e,n,o){return this.request(e,h({method:"PUT",body:JSON.stringify(n)},o))}delete(e,n){return this.request(e,h({method:"DELETE"},n))}};var cg;(e=>{let t;(a=>(a.SUCCESS="success",a.FAILURE="failure",a.CONDITIONS_NOT_MET="conditions_not_met",a.MAX_RECURSION_LEVEL="max_recursion_level",a.NO_ACCESS_TO_ASSISTANT="no_access_to_assistant"))(t=e.EvaluationStatus||(e.EvaluationStatus={}))})(cg||(cg={}));function ti(t){return b(h({},j(t)),{metadata:t.metadata})}var wn=class wn{constructor(e,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new Cn(e,{fetch:n.fetch}),this.client.patchFetch(o=>(s,r)=>S(this,null,function*(){let i=yield o(s,r);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return S(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=yield this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(wn.exchangeTokenPromise||(wn.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),wn.exchangeTokenPromise):Promise.resolve()})}createConversation(e){return S(this,null,function*(){var o;yield this.preflight(),P.info(`Creating conversation for session ${e.externalId} and agent ${e.agentId}`);let n=yield this.client.post("/api/v2/conversations",b(h({chat_start_time:new Date().toISOString()},le(e)),{metadata:(o=e.metadata)!=null?o:{}}));return ti(n)})}upsertConversation(e){return S(this,null,function*(){var d;yield this.preflight(),P.info(`Upserting conversation for session ${e.externalId} and agent ${e.agentId}`);let{status:n,data:o}=yield this.client.postWithStatus("/api/v2/conversations",b(h({chat_start_time:new Date().toISOString()},le(e)),{metadata:(d=e.metadata)!=null?d:{}}),{version:"v2"}),s=ti(o);if(n===201)return s;let{agentId:r,agentName:i,agentEmail:a,agentNickname:c,metadata:l}=e;return this.updateConversation(s.id,{agentId:r,agentEmail:a,agentName:i,agentNickname:c,metadata:l})})}getMe(){return S(this,null,function*(){yield this.preflight();let e=yield this.client.get("/apis/admin/session/me/");return j(e)})}postIdentity(e){return S(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",le(e))})}patchMe(e){return S(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",le(e));return j(n)})}getProfile(e){return S(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${e}/`,{useCache:!0});return j(n)})}getKnowledgeAssistant(e){return S(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{useCache:!0});return j(n)})}getContentTypes(){return S(this,null,function*(){let e=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return j(e)})}getAccount(){return S(this,null,function*(){let e=yield this.client.get("/apis/admin/account/",{useCache:!0});return j(e)})}getPlatformConfig(e){return S(this,null,function*(){let n=e!==void 0?`/platform/config/${e}/`:"/platform/config/",{config:o}=yield this.client.get(n,{useCache:!0});return j(o)})}checkUserExists(e){return S(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${e}`,{version:"v1"});return n})}getConversationByExternalId(o){return S(this,arguments,function*(e,n={}){yield this.preflight(),P.info(`Getting conversation for session ${e}`);let{attempts:s=1,retryDelay:r=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return P.info(`Successfully retrieved conversation ${i.id} for session ${e}`),ti(i)})}isConversationSupported(o){return S(this,arguments,function*(e,n={}){P.info(`Check if conversation for session ${e} is supported`);let{attempts:s=1,retryDelay:r=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:s,retryDelay:r,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(e,n){return S(this,null,function*(){var r;yield this.preflight();let o=le(n);n.metadata&&(o.metadata=(r=n.metadata)!=null?r:{});let s=yield this.client.put(`/api/v2/conversations/${e}`,o);return ti(s)})}postMessages(e,n){return S(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${e}/messages`,n.map(o=>b(h({},le(o)),{metadata:o.metadata})))})}sendEvent(e,n){return S(this,null,function*(){yield this.preflight();let a=n,{data:o}=a,s=D(a,["data"]),r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((c,[l,d])=>b(h({},c),{[l]:d}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((c,l)=>(s[l]&&(c[l]=s[l]),c),{});return this.client.post("/api/v2/events",le(b(h(h({},r),i),{data:o,name:e})),{version:"v2"})})}getEntities(e){return S(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:e.filter(o=>o.text)})})}getTemporaryExchangeToken(){return S(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(e){return S(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:e}).catch(n=>{throw P.warn(`Invalid token '${e}'`),n})})}authenticateWithKey(e,n){return S(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",le(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(s){return S(this,arguments,function*(e,n={},o){if(yield this.preflight(),o==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${e}/recommend/${o}`,le(n),{abortLatest:!0})).map(i=>b(h({},j(i)),{text:i.text||i.url||i.message,source:o,type:o})).filter((i,a,c)=>a===c.findIndex(l=>l.text===i.text))})}isLoggedIn(){return S(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(e,n){return S(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${e}/autocomplete`,le(n),{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))})}getPinnedMessages(e){return S(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return j(n).map(o=>b(h({},o),{text:o.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(e){return S(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",le(e),{abortLatest:!0,version:"v2"});return j(n)})}search(e){return S(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${e.profile}/search`,le(e));return j(n)})}loginWithPassword(e,n){return S(this,null,function*(){yield this.preflight();let o=yield this.client.post("/apis/admin/session/login/",{username:e,password:n},{refreshTokenOn401:!1});return j(o)})}logout(){return S(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/logout/",{},{refreshTokenOn401:!1})})}requestLoginByEmail(e){return S(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:e});return j(n)})}requestPasswordlessToken(){return S(this,null,function*(){let e=yield this.client.get("/apis/admin/session/passwordless/request/");return j(e.token)})}getCsrfToken(){return S(this,null,function*(){let{token:e}=yield this.client.get("/apis/admin/session/csrf/");return e})}verifyLoginToken(e){return S(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:e});return j(n)})}evaluateAssistant(e,n){return S(this,null,function*(){var c,l,d;yield this.preflight();let o=new URLSearchParams;n!=null&&n.externalConversationId&&o.append("external_conversation_id",n.externalConversationId);let s=n!=null&&n.threadId?`/api/v2/assistants/${e}/threads/${n==null?void 0:n.threadId}/evaluate?${o.toString()}`:`/api/v2/assistants/${e}/evaluate?${o.toString()}`,r=p=>le(p),i=(c=n==null?void 0:n.transcript)==null?void 0:c.map(p=>{var u;return h({source:p.source,text:p.text},(u=p.attachments)!=null&&u.length?{attachments:p.attachments.map(r)}:{})}),a=yield this.client.post(s,h({input:(l=n==null?void 0:n.input)!=null?l:{},conversation:i},(d=n==null?void 0:n.attachments)!=null&&d.length?{attachments:n.attachments.map(r)}:{}));return j(a)})}interactWithAssistant(e){return S(this,null,function*(){yield this.preflight();let n=new URLSearchParams;e.sessionId&&n.append("session_id",e.sessionId),e.externalConversationId&&n.append("external_conversation_id",e.externalConversationId);let o=`/api/v2/assistants/${e.assistantCode}/interact?${n.toString()}`,s=yield this.client.post(o,{message:e.message});return j(s)})}resetAssistantThread(e){return S(this,null,function*(){yield this.preflight();let n=encodeURIComponent(e.assistantCode),o=encodeURIComponent(e.sessionId);yield this.client.delete(`/api/v2/assistants/${n}/sessions/${o}/thread`)})}createAssistantThread(e){return S(this,null,function*(){yield this.preflight();let{assistantCode:n}=e,o=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return j(o)})}postMessageToAssistantThread(e){return S(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:s}=e,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:s,role:"user"});return j(r)})}translateMessages(e){return S(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",le(e));return j(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let s=o.toLowerCase(),r=s.match(Sl);if(!n||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&P.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};wn.exchangeTokenPromise=null;var Et=wn;var ni=class{constructor(e){this.options=e;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,o;this.socket,this.eventListeners=new Map,this.url=e.url,this.maxReconnectAttempts=(n=e.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(o=e.reconnectInterval)!=null?o:this.reconnectInterval,this.shouldReconnect=e.shouldReconnect}connect(){let e=()=>this.cleanup();window.addEventListener("beforeunload",e),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",e)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=e=>{var n;try{let o=j(JSON.parse(e.data));o.event&&this.eventListeners.has(o.event)&&((n=this.eventListeners.get(o.event))==null||n.forEach(s=>s(o.data)))}catch(o){console.error("Error parsing WebSocket message:",o)}},this.socket.onclose=e=>{console.log("WebSocket connection closed:",e),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=e=>{console.error("WebSocket error:",e)})}reconnect(){var e,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(e=this.socket)==null||e.close();return}if(!this.shouldReconnect()){console.error("Should not reconnect, closing WebSocket connection."),(n=this.socket)==null||n.close();return}this.socket&&(this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this.socket=new WebSocket(this.url),this.setupListeners(),this.maxReconnectAttempts--}send(e,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:e,data:n}))}on(e,n){this.eventListeners.has(e)||this.eventListeners.set(e,[]);let o=this.eventListeners.get(e);o&&!o.includes(n)&&o.push(n)}close(){var e;(e=this.socket)==null||e.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(e=>e()),this.cleanupCallbacks=[]}};var si=require("@reduxjs/toolkit");var pg=require("@reduxjs/toolkit");var ug={startTime:null,stopTime:null},gg=t=>t.handlingTime,mg=(0,pg.createSlice)({name:"handlingTime",initialState:ug,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(q,()=>ug)}}),{handlingTimeStart:fg,handlingTimeStop:oi,handlingTimeReset:hg}=mg.actions,yg=mg.reducer;var vg=(t={})=>{let e=h({onAuthError:Pn(!1)},t);return n=>o=>s=>("error"in s&&s.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(s))};var Sg=(t={})=>{let e,n=!0,o=h({getStyleSuggestions:fn,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:u}=l.input;return u===a&&!n||(clearTimeout(e),u==="")||(e=setTimeout(()=>{n=!1,s.dispatch(o.getStyleSuggestions({text:u}))},t.debounce)),c}};function Vy(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end&&t.suggestionTextStart===e.suggestionTextStart}var xg=(t={})=>{let e=h({getTextSuggestions:qe,getAutocompleteSuggestions:Wo,debounce:200,check:nt},t),n;return o=>s=>r=>{var g;let{input:i}=o.getState(),a=s(r),c=o.getState();if(c.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:d}=c.settings,p=(g=c.conversation.current)==null?void 0:g.id,u=r.type===Cr.toString();if(!p||!l&&!d)return a;let{input:m}=c;return Vy(m,i)&&!u||(clearTimeout(n),!e.check(c))||(n=setTimeout(()=>{let y=Xt(c);y===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(y))},u?0:e.debounce)),a}};var bg=fn.fulfilled.toString();function jy(t,e){let n=new Set([...e.keywordMatches.map(s=>s.keyword)]),o=[];return n.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||o.push(...i.slice(0,a))}),o}var Cg=t=>e=>n=>o=>{var l;if(o.type!==bg){n(o);return}let s=e.getState().styleSuggestions.list;n(o);let r=e.getState(),i=r.styleSuggestions.list,a=(l=r.conversation)==null?void 0:l.current;if(s===i)return;let c=jy(s,i);o.type===bg&&c.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:c}})};var qy=(0,si.combineReducers)({assistants:Bd,auth:Rl,conversation:Ol,contentTypes:Oc,passwordlessToken:Lp,entities:su,handlingTime:yg,info:od,input:$l,settings:zd,profile:Uc,search:dd,styleSuggestions:ju,ui:Nu,textSuggestions:fu});function wg(t){return(0,si.configureStore)({reducer:qy,middleware:e=>{var o;let n=e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}).concat(vg()).concat(xg({debounce:200})).concat(Sg({debounce:500})).concat(Cg(t.deepdeskAPI));return((o=t.middleware)!=null?o:[]).reduce((s,r)=>s.concat(r),n)},preloadedState:t.preloadedState})}function Tg(t,e,n){if(e==="")return null;let o=new RegExp(`\\b${Hr(e)}\\b`,"gi"),s,r=null;for(;(s=o.exec(t))!==null&&!(s.index>n);)r={start:s.index,end:s.index+s[0].length};return r}var $y=t=>{var e,n;return(n=(e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())!=null?n:"unknown"},Gy=t=>e=>n=>o=>{var c,l,d,p,u,m;let s=e.getState(),r=on("inlineSuggestions")(s),i=on("autoSelectSuggestion")(s)||r;switch(o.type){case Pn.toString():{!o.payload&&t.emit("logout",void 0);break}case Ss.fulfilled.toString():{t.emit("logout",void 0);break}case je.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:(c=s.conversation.current)==null?void 0:c.id,data:{entities:o.payload}});break;case Yt.toString():t.logSendMessage(o.payload);break;case zs.toString():t.emit("call-to-action",{cue:o.payload});break;case we.fulfilled.toString():if(!o.isBroadcasted){let{externalConversationId:f,currentExternalIdAtRequest:g}=(l=o.payload)!=null?l:{};(!f||!g||f===g)&&t.broadcast(Ei,o,!1)}break;case we.rejected.toString():break;default:break}let a=n(o);switch(o.type){case Yt.toString():t.handleAfterSendMessage(o.payload);break;case Vo.toString():t.onUpdateShowTabHint(o.payload);break;case oi.toString():t.logHandlingTime();break;case Ln.toString():t.broadcast(Ms,o);break;case Zt.toString():t.broadcast(Ms,o);break;case Vs.toString():e.dispatch(Zt({source:"assistant",assistantCode:o.payload.code}));break;case"analytics/logEvent/fulfilled":{let f=s.assistants.cues.find(g=>g.code===o.meta.arg.data.assistantCode);t.emit("event",b(h({},o.meta.arg),{cue:f}));break}case be.toString():{let{start:f,end:g}=s.input.selection;t.emit("select-suggestion",b(h({type:$y(o.payload.suggestion)},o.payload),{replace:o.payload.replace==="selection"?{start:f,end:g}:{start:0,end:g}})),r&&e.dispatch(Mt([]));break}case Vu.toString():{let{keyword:f,suggestion:g,eventMetrics:y}=o.payload,{text:v,selection:x}=s.input,w=Tg(v,f,(d=x==null?void 0:x.end)!=null?d:v.length);if(!w)break;t.emit("select-suggestion",{text:g,type:"style",replace:w,suggestion:{text:g,source:"style"},eventMetrics:y});break}case Es.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(p=s.conversation.current)==null?void 0:p.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Mt.toString():{i&&o.payload.length>0&&e.dispatch(ks(0));break}case we.fulfilled.toString():{let{evaluationId:f,output:g,externalConversationId:y}=o.payload,v=o.meta.arg.assistantCode;if(t.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:f,assistantCode:v,assistantOutput:Nd(g),externalConversationId:y,evaluationStatus:"success"}}),!o.meta.arg.skipState){let x=e.getState().assistants.cues;t.emit("cues",x)}break}case we.rejected.toString():{let f=o.meta.arg.assistantCode,g=(m=o.meta.arg.externalConversationId)!=null?m:(u=e.getState().conversation.current)==null?void 0:u.externalId;t.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:"",assistantCode:f,assistantOutput:"",externalConversationId:g,evaluationStatus:"failed"}});break}default:break}return a},Eg=Gy;var kg=require("@reduxjs/toolkit");function Ka(t){return t.toISOString().replace("T"," ").replace("Z","")}var Qy=(t,e)=>e.version,Rg=(0,kg.createSelector)([Mn,Pe,gg,Qy],(t,e,n,o)=>{if(!e)return P.warn("No conversationId for handling time metrics"),null;let{startTime:s,stopTime:r}=n;return!s||!r?(P.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:e,clientVersion:o,agentId:t==null?void 0:t.agentId,agentName:t==null?void 0:t.agentName,agentEmail:t==null?void 0:t.agentEmail,timeStart:Ka(s),timeStop:Ka(r)}});function Pg(t,e){let{text:n,metrics:{numPaste:o,pastes:s,textSuggestions:r}}=t.input,i=n.length;return{source:"agent",clientVersion:e.version,pastes:s,lenTextTotal:i,numPastes:o,suggestions:r}}var is=class extends Error{};function Xy(){let t,e;return{promise:new Promise((o,s)=>{t=o,e=s}),resolve:t,reject:e}}var ri=class{constructor(){this.queues={}}push(e,n){let o=()=>{let r=this.queues[e][1];r?(this.queues[e]=[r.promise,null],r.resolve()):delete this.queues[e]};if(!this.queues[e]){let r=n().finally(o);return this.queues[e]=[r,null],r}this.queues[e][1]&&this.queues[e][1].reject(new is("Queued async function is outdated"));let s=Xy();return this.queues[e][1]=s,s.promise.then(()=>n().finally(o))}};function Wa(t,e){var r;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return Wa(o,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?Wa(s,e):null}function za(t,e){return Wa(t,e)}var Jy={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},Ig=(t,e)=>{var s,r,i;if(!((i=(r=(s=t.uiConfig)==null?void 0:s.widget)==null?void 0:r.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return P.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let o=t[Jy[e]];return o&&o.length>0?o.map(a=>a.code):(P.warn(`No assistant set in profile for conversation event "${e}"`),[])};function Zy(t){var e,n,o,s;return(s=(o=(n=(e=t.uiConfig)==null?void 0:e.widget)==null?void 0:n.types)==null?void 0:o.some(r=>r.type==="knowledge-assist"&&r.isActive))!=null?s:!1}function Ag(t){var n,o;return((o=(n=t.widgetInteractiveAssistants)==null?void 0:n.length)!=null?o:0)>0&&Zy(t)?!0:!!t.knowledgeAssistantNew||!!t.knowledgeAssistant}function Yy(t){return typeof t=="object"&&t!==null&&"tagName"in t}function ii(t){return Yy(t)&&(yn(t)||_r(t))}var Mg,it=new Map,ev=["bottom","height","left","right","top","width"],Lg=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:ev.some(n=>t[n]!==e[n]);function Ng(t){var n,o,s;if(t.ownerDocument===document)return[];let e=(s=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?s:null;return e?[e,...Ng(e)]:[]}function Og(t,e){return!t||!e?null:b(h({},t),{top:t.top+e.top,left:t.left+e.left})}var ai=!1,Dg=()=>{ai=!0;let t=[];if(it.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),it.delete(n);return}let o=n.getBoundingClientRect();Lg(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{let n=e.parentRects?e.parentRects.reduce(Og,e.rect):e.rect;Lg(n,e.totalRect)&&e.callbacks.forEach(o=>o(n)),e.totalRect=n}),it.size===0){ai=!1;return}Mg=window.requestAnimationFrame(Dg)};function Va(t,e){let n=Ng(t),o=[],s=n.map((r,i)=>Va(r,a=>{o[i]=a;let c=it.get(t);if(!c)return;let l=o.reduce(Og,c.rect);c.callbacks.forEach(d=>d(l))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),it.has(t)){let i=it.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else it.set(t,{rect:void 0,callbacks:[e],parentRects:o});r&&!ai&&Dg()},unobserve(){s.forEach(i=>i.unobserve());let r=it.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||it.delete(t),it.size||(cancelAnimationFrame(Mg),ai=!1)}}}}var _g,at=new Map,Fg=()=>{at.forEach((t,e)=>{if(!e.isConnected){at.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,s=o>n;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),at.size!==0&&(_g=window.requestAnimationFrame(Fg))};function Hg(t,e){return{observe(){let n=at.size===0;at.has(t)?at.get(t).callbacks.push(e):at.set(t,{visible:void 0,callbacks:[e]}),n&&Fg()},unobserve(){let n=at.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||at.delete(t),at.size||cancelAnimationFrame(_g)}}}}var ja=["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 qa(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function to(t){return Number.parseFloat(t)}function li(t){return Math.round(t*1e6)}function Bg(t){return t/1e6}function $a(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,s=to(t.width),r=to(t.borderLeftWidth),i=to(t.borderRightWidth),a=to(t.paddingRight),c=Bg(li(s)-li(r)-li(i)),l=Bg(li(o));if(c-l>2){let d=c-l;n.style.paddingRight=`${a+d}px`}}function as(t,e={}){var d,p;let n=e.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(d=e.position)!=null?d:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",rn(n);let o=window.getComputedStyle(t),s=!0,r=()=>{n.scrollTop=t.scrollTop};qa(o,n,ja),$a(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",r));let i=Hg(t,()=>{qa(o,n,ja),$a(o,t,n),r(),setTimeout(r,0)}),a,c=!0,l=Va(t,u=>{if(u===null){e.onRemove&&e.onRemove(),n.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(),n.style.display="none",s=!0;return}if(qa(o,n,ja),$a(o,t,n),r(),e.placement==="below"&&n.classList.add("below"),n.style.top=`${u.top}px`,n.style.left=`${u.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let m=e.closestScrollElement.getBoundingClientRect(),f=window.getComputedStyle(e.closestScrollElement),g=to(f.borderTopWidth),y=to(f.borderBottomWidth),v=m.top+g-u.top,x=u.top+u.height+-(m.top+m.height-y);n.style.clipPath=`inset(${v}px 0px ${x}px 0px)`}s&&(n.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(n):(p=t.parentElement)==null||p.appendChild(n),l.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",r),l.unobserve(),i.unobserve(),n.remove()}]}function tv(t){return t.offsetParent!==null}function Ug(t){if(!tv(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 di(t,e,n=100){let o=Ug(t);e({isVisible:o});let s=setInterval(()=>{let r=Ug(t);r!==o&&(o=r,e({isVisible:o}))},n);return()=>{clearTimeout(s)}}var Kg=(t,e)=>({value(){try{let n=sessionStorage.getItem(`dd-${t}`);if(!n)return e;try{return JSON.parse(n)}catch(o){return e}}catch(n){return e}},update(n){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(n))}catch(o){P.warn("[Deepdesk] SessionStorage is blocked by browser")}}});var K=require("react/jsx-runtime");var Wg=Kg("showTabHint",!0),no=class no{constructor({deepdeskUrl:e,version:n=no.version||"unknown",locale:o="en-US",token:s,fetch:r,productName:i,createCustomChannel:a,websocketClient:c=ni}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.disposeHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.belowSuggestions=null;this.floatingMenu=null;this.widgetElement=null;this.widgetRoot=null;this.nicknameDialogUnsubscribe=null;this.nicknameDialogFailed=!1;this.dynamicThunkObject={};this.queues=new ri;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;this.loadProfileConfigPromiseKey=null;let l=e.replace(/\/api$/,"");this.deepdeskApi=new Et(l,{token:s,fetch:r}),this.version=n,this.instanceId=no.count++;let d={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Eg({broadcast:(f,g,y)=>{this.broadcastEvents.send(f,g,y)},emit:(f,g)=>this.emit(f,g),handleAfterSendMessage:f=>this.handleAfterSendMessage(f),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:f=>this.logSendMessage(f),onUpdateShowTabHint:f=>Wg.update(f),sendEvent:(f,g)=>this.deepdeskApi.sendEvent(f,g)})]};this.store=wg(d),this.broadcastEvents=new lg({debug:!0,deepdeskUrl:l,eventMap:cd(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new c({url:`${l}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>S(this,null,function*(){var f;return(f=re(this.state))!=null?f:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(Vo(Wg.value())),this.store.dispatch(ko({locale:o,adminUrl:l,productName:i}));let p=[],u=f=>{if(!f.conversationId)return;let g=()=>{this.conversationId()===f.conversationId&&this.store.dispatch(Fd(f))};this.hasConversation()?g():p.push(g)};this.ws.on("assistants::direct_response",u),this.ws.on("assistants::user_notification",u),this.ws.on("assistants::response_chunk",f=>{if(!f.conversationId)return;let g=()=>{this.conversationId()===f.conversationId&&this.store.dispatch(_d(f))};this.hasConversation()?g():p.push(g)}),this.ws.on("assistants::suggest_as_reply",f=>{if(!f.conversationId)return;let g=()=>{this.conversationId()===f.conversationId&&this.store.dispatch(Ln([{text:f.payload.message,type:"text",source:"assistant",assistantCode:f.code,sourceLabel:f.name}]))};this.hasConversation()?g():p.push(g)});let m=this.whenConversationLoaded(()=>{var f;this.broadcastEvents.setExternalId((f=this.state.conversation.current)==null?void 0:f.externalId),p.forEach(g=>g()),p.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),p.length=0,m()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var e;return(e=Jt(this.state)[this.state.input.selectedSuggestionIndex])!=null?e:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}externalId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.externalId}shouldAbort(){return this.state.conversation.isSupported===!1?(P.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(P.warn("Profile has not been loaded (yet)"),!0):(P.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(e){if(re(this.state))e();else{let n=this.subscribe(re,o=>{o&&e()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch(Pn(null)),this.store.dispatch(dt()),new Promise(e=>{this.whenLoggedIn(()=>e())})}isLoggedIn(){return S(this,null,function*(){return(yield this.store.dispatch(dt())).payload})}isConversationSupported(e,n){return S(this,null,function*(){return(yield this.store.dispatch(vi({externalId:e,options:n}))).payload})}createConversation(e){return S(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Cs(b(h({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}getConversationByExternalId(e,n){return S(this,null,function*(){return this.hasConversation()&&this.externalId()!==e&&this.resetConversation(),(yield this.store.dispatch(ws({externalId:e,options:n}))).payload})}upsertConversation(e){return S(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Si(b(h({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return S(this,null,function*(){yield this.store.dispatch(xi(e))})}updateConversation(e){return S(this,null,function*(){return(yield this.store.dispatch(Ts(e))).payload})}resetConversation(){this.store.dispatch(q()),this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(ko(e))}setVisitorInfo(e){this.store.dispatch(Yl(e))}setCustomData(e){this.store.dispatch(ed(e))}setAgentInfo(e,n){return S(this,null,function*(){var s;yield this.store.dispatch(co(h(h({},e),n))),(s=this.state.info.agentInfo)!=null&&s.agentNickname||this.broadcastEvents.send(Ls,{showNicknameDialog:!0})})}setAgentSettings(e){return S(this,null,function*(){yield this.store.dispatch(Ci(e))})}getAgentSettings(){return S(this,null,function*(){return(yield this.store.dispatch(wi())).payload})}getMe(){return S(this,null,function*(){return this.deepdeskApi.getMe()})}refresh(){return S(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let e=[];return e.push(this.refreshTextSuggestions()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(Rs({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()}))}notifyExternalSuggestion(e){this.store.dispatch(be(e))}evaluateAssistant(e,n){return S(this,null,function*(){var d;let{input:o={},attachments:s=[],transcript:r,showCuesInWidget:i=!0,includeMetadata:a,externalConversationId:c}=n||{},l=yield this.store.dispatch(we({assistantCode:e,attachments:s,transcript:r,includeMetadata:a,input:o,externalConversationId:c,skipState:!i}));if(l.error)throw new Error(`Assistant evaluation failed: ${(d=l.payload)!=null?d:l.error.message}`);return l.payload.output})}evaluateConversationAssistant(e,n){return S(this,null,function*(){var d,p,m;yield this.loadProfileConfig();let o=this.state.profile.data;if(!o&&((d=this.state.conversation.current)!=null&&d.profileCode)&&(yield this.loadProfileConfig(),o=this.state.profile.data),!o){P.warn("Can't evaluate assistant when profile is not loaded yet.");return}let s=Ig(o,e),r=(p=n==null?void 0:n.showCuesInWidget)!=null?p:!0,u=n!=null?n:{},{showCuesInWidget:i}=u,a=D(u,["showCuesInWidget"]),c=(m=n==null?void 0:n.externalConversationId)!=null?m:this.hasConversation()?this.externalId():"",l=yield Promise.all(s.map(f=>this.queues.push(f,()=>S(this,null,function*(){var y,v;let g=yield this.store.dispatch(we(h(b(h({assistantCode:f,includeMetadata:!0},a),{skipState:!r}),n!=null&&n.attachments&&(n==null?void 0:n.attachments.length)>0?{attachments:n==null?void 0:n.attachments}:{})));if(g.error)throw new Error(`Assistant evaluation failed: ${(y=g.payload)!=null?y:g.error.message}`);return{assistantCode:f,evaluationId:g.payload.evaluationId,output:g.payload.output,externalConversationId:(v=g.payload.externalConversationId)!=null?v:c}})).catch(g=>{if(g instanceof is)return P.warn(`Queued assistant "${f}" was outdated and dropped`),null;throw g})));if(!r)return l.filter(f=>f!==null)})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:s,selectedSuggestionIndex:r,selection:i}=this.state.input,{inlineSuggestions:a,autoSelectSuggestion:c,showTextSuggestions:l,suggestionsPlacement:d}=this.settings,p=a||c,u=d==="inline"||d==="below"?"below":"above",m=s.length>0;if(this.store.dispatch(Ul(bi(e))),!nt(this.state)||e.key!=="Tab"&&!l)return;let f=()=>{n||!m||i&&(e.shiftKey||(this.store.dispatch(zl()),e.preventDefault()))},g=()=>{n||!m||p&&r<=0||i&&(e.shiftKey||(this.store.dispatch(Vl()),e.preventDefault()))};switch(e.key){case"ArrowUp":u==="below"?g():f();break;case"ArrowDown":{u==="below"?f():g();break}case"Escape":{n||(this.store.dispatch(ks(-1)),this.store.dispatch(Ht({collapse:!0})),this.store.dispatch(Lu(!0)),e.preventDefault());break}case"Tab":{e.preventDefault();let y=An(this.state);if(!y)return;this.store.dispatch(Vo(!1)),this.store.dispatch(be({text:y.text,suggestion:y,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(p||this.state.input.selectedSuggestionIndex===-1)return;let y=An(this.state);if(!y)return;this.store.dispatch(be({text:y.text,suggestion:y,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(p||e.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let y=An(this.state);if(!y)return;this.store.dispatch(be({text:y.text,suggestion:y,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),e.preventDefault();break}default:}n&&o&&this.store.dispatch(Ht({collapse:!1}))}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Mt([]))}handlingTimeStart(){this.state.handlingTime.startTime||(P.info("Start handling time"),this.store.dispatch(fg()))}handlingTimeStop(){this.state.handlingTime.startTime&&(P.info("Stop handling time"),this.store.dispatch(oi()))}logSendMessage(e){let n=Pg(this.state,{version:this.version});n&&(e&&(Object.assign(n,{text:e}),Object.assign(n,{lenTextTotal:e.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let e=Rg(this.state,{version:this.version});e&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:e}),this.store.dispatch(hg()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch(Yt((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(ql()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(s=>{try{s(n)}catch(r){P.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),P.error(r)}})}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}setPlatformVariables(e){this.store.dispatch(td(e))}whenConversationLoaded(e){let n=()=>this.getConversationLoadedKey(),o=()=>{let r=n();r&&this.loadProfileConfig().then(()=>{if(n()!==r)return;let i=this.state.conversation.current,a=Ne(this.state);!(i!=null&&i.id)||i.profileCode&&(a==null?void 0:a.code)!==i.profileCode||e()})};return n()&&o(),this.subscribe(r=>this.getConversationProfileKey(r.conversation.current),r=>{r&&o()})}overlayContainerFactory(e,n,o,s){let[r,i]=as(n,o);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),[r,i]}createInlineContainer(e,n){var a;let o=document.createElement("div");o.style.position="absolute",o.style.top="0px",o.style.left="0px",o.style.height="0px",o.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",o.appendChild(s);let r=(a=e.ownerDocument.defaultView)==null?void 0:a.frameElement,i=r?r.ownerDocument.defaultView:null;if(r&&(i===window||(i==null?void 0:i.parent)===window)){let[c,l]=as(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});c.dataset.testid=n,c.style.zIndex="2",c.appendChild(o),this.unmountHandlers.push(()=>{l()})}else document.body.appendChild(o);return s}createContainer(e,n=document.body){let o=window.getComputedStyle(n),s=document.createElement("div");return rn(s),s.dataset.testid=e,s.style.color=o.color,s.style.fontSize=o.fontSize,s.style.fontFamily=o.fontFamily,s.style.fontVariant=o.fontVariant,s.setAttribute("translate","no"),n.appendChild(s),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,n),P.info(`Stored analytics for ${this.conversationId()}`)}catch(e){}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(e);if(!n)return;let o=JSON.parse(n);o.text.trim()===this.state.input.text.trim()?(P.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(jl(o.metrics))):P.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch(e){}}mount(e,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!ii(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let u=n,{customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i,inputMediator:a}=u,c=D(u,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:o,closestScrollSelector:s,floatingMenuParent:r,appendOverlayTo:i};this.configure(c),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),rn(e),this.inputMediator=a||(yn(e)?new bn(e):new xn(e)),this.inputMediator.on("change",({plainText:m,rawHTML:f,suggestionTextStart:g})=>{this.store.dispatch(Rs({text:m,html:f,suggestionTextStart:g}))}),this.inputMediator.on("keyup",m=>{this.store.dispatch(Kl(bi(m)))}),this.inputMediator.on("keydown",m=>{this.handleKeyDown(m)}),this.inputMediator.on("paste",({pastedText:m,selectionText:f})=>{this.store.dispatch(Wl({text:m,selectionText:f}))}),this.inputMediator.on("cut",({selectionText:m})=>{this.store.dispatch(Bl(m))});let d;this.inputMediator.on("selection",m=>{clearTimeout(d),m===null?d=setTimeout(()=>{m!==null&&this.store.dispatch(Ps(m))},500):this.store.dispatch(Ps(m))}),this.unmountHandlers.push(()=>{clearTimeout(d)}),this.inputMediator.on("disabled",()=>{var m;(m=this.inputMediator)==null||m.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(kr(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(kr(!0))}),this.renderSuggestions(e,l),this.subscribe(on("inlineSuggestions"),()=>{this.renderSuggestions(e,l)}),this.subscribe(on("suggestionsPlacement"),()=>{this.renderSuggestions(e,l)});let p=this.renderOverlays(n);this.unmountHandlers.push(()=>{p.unmount()}),this.store.dispatch(Rs({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()})),this.store.dispatch(Ps(this.inputMediator.getSelection())),this.store.dispatch(kr(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{this.restoreMetrics(),this.syncInputMediator(),this.refreshTextSuggestions(),this.promptForNickname()}),this.isMounted=!0}promptForNickname(e){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let o=(0,kt.createRoot)(n),s=null,r=a=>{s=a,i()},i=()=>{o==null||o.render((0,K.jsx)(St,{store:this.store,children:(0,K.jsx)(ut,{broadcastEvents:this.broadcastEvents,children:(0,K.jsx)(Qu,{id:"deepdesk-nickname-dialog",error:s,onSave:a=>S(this,null,function*(){try{yield this.store.dispatch(Jl({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(Ls,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(c){P.error("Error setting agent nickname",c),r("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{o.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(e,n){let o=e(this.store.getState());return this.store.subscribe(()=>{let s=e(this.store.getState());s!==o&&(o=s,n(o))})}unmount(){var e,n,o,s,r;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.belowSuggestions)==null||o.unmount(),(s=this.floatingMenu)==null||s.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(r=this.inputMediator)==null||r.dispose(),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe(),this.isMounted=!1}dispose(){this.unmount(),this.unmountWidget(),this.disposeHandlers.forEach(e=>e()),this.disposeHandlers=[],this.off()}renderSuggestions(e,n){var o,s,r,i;(o=this.floatingMenu)==null||o.unmount(),(s=this.inlineSuggestions)==null||s.unmount(),(r=this.aboveSuggestions)==null||r.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(e,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(e,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(e,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(e,n,"above")}renderInlineSuggestions(e,n){let{customStyles:o}=n,s=this.createInlineContainer(e,"deepdesk-caret"),r=(0,kt.createRoot)(s);r.render((0,K.jsx)(St,{store:this.store,customStyles:o,children:(0,K.jsx)(ut,{broadcastEvents:this.broadcastEvents,children:(0,K.jsx)(qu,{})})}));let i=a=>{a?(s.style.display="block",s.style.top=`${a.top}px`,s.style.left=`${a.left}px`):s.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),r.unmount(),s.remove()}}}renderAboveOrBelowSuggestions(e,n,o){let{customStyles:s,closestScrollSelector:r,appendOverlayTo:i}=n,a=r&&za(e,r)||void 0,[c,l]=this.overlayContainerFactory("deepdesk-tab-completion",a||e,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},s==null?void 0:s.rootNode),[d,p]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||e,{appendTo:i,placement:o},s==null?void 0:s.suggestionsRootNode),u=(0,kt.createRoot)(c);u.render((0,K.jsx)(St,{store:this.store,customStyles:s,children:(0,K.jsx)(ut,{broadcastEvents:this.broadcastEvents,children:(0,K.jsx)(Pp,{inputElement:e})})}));let m=(0,kt.createRoot)(d);return m.render((0,K.jsx)(St,{store:this.store,customStyles:s,children:(0,K.jsx)(ut,{broadcastEvents:this.broadcastEvents,children:(0,K.jsx)(ip,{onLogIn:()=>this.loginViaPopup().catch(f=>P.warn(f.message))})})})),{unmount(){u.unmount(),m.unmount(),l(),p()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:s,appendOverlayTo:r,floatingMenuParent:i}=n,a=s&&za(e,s)||void 0,[c,l]=this.overlayContainerFactory("floating-menu",a||e,{appendTo:i!=null?i:r},o==null?void 0:o.floatingMenuParent),d=(0,kt.createRoot)(c);return d.render((0,K.jsx)(St,{store:this.store,customStyles:o,children:(0,K.jsx)(ut,{broadcastEvents:this.broadcastEvents,children:(0,K.jsx)(Pu,{onLogIn:()=>this.loginViaPopup().catch(p=>P.warn(p.message))})})})),{unmount(){d.unmount(),l()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays"),s=(0,kt.createRoot)(o);return s.render((0,K.jsx)(St,{store:this.store,customStyles:n,children:(0,K.jsx)(ut,{broadcastEvents:this.broadcastEvents,children:(0,K.jsx)(bu,{})})})),{unmount(){s.unmount(),o.remove()}}}renderWidget(e,n={}){if(this.widgetElement&&P.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:s,isEmbedded:r,signInViaPopup:i,ssoUrl:a,openAdminFeedback:c}=n;this.widgetElement=e,this.configure({showImages:s,isEmbedded:r,signInViaPopup:i});let l;if(a)try{l={url:new URL(a,this.settings.adminUrl).toString()}}catch(d){P.warn(`Invalid ssoUrl '${a}' passed to renderWidget`)}this.widgetRoot=(0,kt.createRoot)(e),this.widgetRoot.render((0,K.jsx)(St,{store:this.store,customStyles:o,children:(0,K.jsx)(ut,{broadcastEvents:this.broadcastEvents,children:(0,K.jsx)(dr,{report:d=>this.deepdeskApi.sendEvent(Cc,{data:d}),children:(0,K.jsx)(ng,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,openAdminFeedback:c,onLogIn:()=>this.loginViaPopup(l).catch(d=>P.warn(d.message))})})})}))}unmountWidget(){var e,n;(n=(e=this.widgetRoot)==null?void 0:e.unmount)==null||n.call(e),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(e,n,o={}){let{customStyles:s,initialQuestion:r}=o,i=(0,kt.createRoot)(n);return i.render((0,K.jsx)(St,{store:this.store,customStyles:s,children:(0,K.jsx)(ut,{broadcastEvents:this.broadcastEvents,children:(0,K.jsx)(_a,{children:(0,K.jsxs)(rr,{assistantCode:e,initialQuestion:r,evaluateKnowledgeAssistFn:Eo,children:[(0,K.jsx)(kn,{children:(0,K.jsx)(ar,{title:o.title,emptyState:o.emptyState})}),(0,K.jsx)(Da,{children:(0,K.jsx)(ir,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(e){let n=di(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){lr(e)&&e.message==="Unauthorized"&&this.login()}getConversationProfileKey(e){var n;if(e!=null&&e.id)return`${e.id}:${(n=e.profileCode)!=null?n:""}`}getProfileLoadKey(){var n;let e=this.state.conversation.current;return e!=null&&e.profileCode&&(n=this.getConversationProfileKey(e))!=null?n:null}isCurrentProfileLoadKey(e){return this.getProfileLoadKey()===e}getConversationLoadedKey(){return this.getConversationProfileKey(this.state.conversation.current)}resetProfileDerivedSettings(){this.store.dispatch(ta()),this.store.dispatch(ko(Ki))}loadProfileConfig(e=!0){let n=this.getProfileLoadKey();if(!n)return this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=null,this.resetProfileDerivedSettings(),Promise.resolve();let o=this.state.conversation.current,s=Ne(this.state);if(s&&s.code!==(o==null?void 0:o.profileCode)&&(this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=null,this.resetProfileDerivedSettings()),this.loadProfileConfigPromise&&this.loadProfileConfigPromiseKey===n)return this.loadProfileConfigPromise;this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=n;let r=Promise.resolve().then(()=>S(this,null,function*(){try{yield this.store.dispatch(Lo()).unwrap()}catch(c){if(c===Kn)return this.loadProfileConfigPromise===r&&(this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=null),e&&this.isCurrentProfileLoadKey(n)&&!Ne(this.state)?this.loadProfileConfig(!1):void 0;throw c}if(!this.isCurrentProfileLoadKey(n))return;let i=Ne(this.state),a=this.state.conversation.current;!i||i.code!==(a==null?void 0:a.profileCode)||this.store.dispatch(ko({showSearch:i.search,showImageSearch:i.imageSearch,showEntitiesCommand:i.entitiesCommand,showSummaryCommand:!!i.summarizerAssistantNew,showKnowledgeSearch:Ag(i),recommendTextSuggestions:i.recommendTextSuggestions}))})).finally(()=>{this.loadProfileConfigPromise===r&&(Ne(this.state)||(this.loadProfileConfigPromise=null,this.loadProfileConfigPromiseKey=null))});return this.loadProfileConfigPromise=r,r}loginViaPopup(e){return S(this,null,function*(){return new Promise((n,o)=>{this.store.dispatch(xs());let s=new MessageChannel,r=s.port1,i=this.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",p),clearInterval(u)};r.onmessage=m=>S(this,null,function*(){var f,g;if((f=m.data)!=null&&f.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((g=m.data)==null?void 0:g.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(po),c=!0,s.port1.close(),n()}catch(y){console.error(y),o(y)}finally{c=!0,l()}});let d=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");if(d===null){o(new Error("Popup blocked by browser"));return}let p=m=>S(this,null,function*(){var f;if(!(m.origin!==a.origin||m.source!==d))switch((f=m.data)==null?void 0:f.type){case"deepdesk-popup-request-origin":{try{let g=JSON.stringify({type:"deepdesk-popup-parent-origin"});d.postMessage(g,a.origin)}catch(g){P.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-loaded":{try{let g=JSON.stringify({type:"deepdesk-popup-create-channel"});d.postMessage(g,a.origin,[s.port2])}catch(g){P.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-error":{if(l(),m.data.message==="Platform account url mismatch"){let g="Please contact your administrator: The page that opened the popup is not a trusted origin.";P.warn(g),this.store.dispatch(hi(g)),o(new Error(g));return}if(m.data.message==="Timeout"){let g="Please contact your administrator: Popup timed out. Check if the account's platform.url or account.url is configured correctly.";P.warn(g),this.store.dispatch(hi(g)),o(new Error(g));return}o(new Error(m.data.message));break}}});window.addEventListener("message",p);let u=setInterval(()=>{d&&!d.closed||(l(),c||o(new Error("Popup closed by user")))},200);this.disposeHandlers.push(l)})})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}refreshTextSuggestions(){return S(this,null,function*(){this.isMounted&&(yield this.store.dispatch(Cr()))})}refreshWidgetSuggestions(){return S(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=Mo(this.state);try{n.forEach(({type:o})=>{switch(o){case"entities":this.store.dispatch(je());break;case"pinned-messages":case"sticky-messages":break;default:vs.includes(o)||this.store.dispatch(qe(o))}})}catch(o){this.handleError(o)}})}};no.version="19.6.2-beta.6",no.count=0;var ls=no;function nv(t){return S(this,null,function*(){var s,r,i;let n=yield((s=t.fetch)!=null?s:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(r=t.mimeType)!=null?r:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function zg(t,e){return S(this,null,function*(){let n=yield nv(e),o=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[n]}),t.dispatchEvent(o)}finally{Object.hasOwn(t,"files")&&delete t.files}})}function Vg(t,e,n){return S(this,null,function*(){yield new Et(t).authenticateWithKey(e,n)})}function jg(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function qg(o,s){return S(this,arguments,function*(t,e,n={}){var p,u;let{value:r}=t,{start:i,end:a}=(p=n.replace)!=null?p:{start:0,end:r.length},c=`${r.slice(0,i)}${e}${r.slice(a)}`,l=(u=n.selectionAfter)!=null?u:{start:i+e.length,end:i+e.length},d=()=>{if(n.setValue)return n.setValue(c);t.value=c};return Promise.resolve(d()).then(()=>{t.selectionStart=l.start,t.selectionEnd=l.end,t.blur(),t.focus()})})}function $g(o,s){return S(this,arguments,function*(t,e,n={}){let r=n.replace?zt(t,n.replace.start,n.replace.end):Yn(t),i,a=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),i=document.createElement("span"),r.insertNode(i),n.insertBRs!==!1?e.split(`
|
|
12
|
+
`).reverse().forEach((c,l)=>{l>0&&r.insertNode(document.createElement("br")),r.insertNode(document.createTextNode(c))}):r.insertNode(document.createTextNode(e))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let c=n.selectionAfter?zt(t,n.selectionAfter.start,n.selectionAfter.end):(r.collapse(!1),r),l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(c)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function ov(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 sv(t){let e=document.createDocumentFragment();return t.split(`
|
|
13
|
+
`).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=n.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(n.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(n.slice(r)))}),e}function Gg(t,e){let n=t.parentElement;if(!n){console.warn("No insert point found");return}let{display:o}=window.getComputedStyle(n);o.includes("block")||o==="table-cell"?n==null||n.insertBefore(e,t.nextSibling):Gg(n,e)}function Qg(s,r){return S(this,arguments,function*(t,e,{isBlock:n,isHTML:o}={}){let i;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let a=()=>{var u;let c=(u=t.ownerDocument.defaultView)!=null?u:window,l=c.getSelection();if((!l||l.rangeCount===0)&&(t.focus(),l=c.getSelection()),!l||l.rangeCount===0)return;let d=l.getRangeAt(0);if(!d)return;i=document.createElement("span"),d.insertNode(i);let p=o?ov(e):sv(e);n?Gg(d.startContainer,p):(d.insertNode(p),d.collapse(!1))};return Promise.resolve(a()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!i)try{i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}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,formatTextMarkup,getRangeOffsets,getRangeText,insertCKEditor,isHTML,isSupportedInputElement,logEvent,updateContentEditable,updateTextArea,useClickOutsideRoot,useStyles,waitForElementVisibilityChange});
|