@deepdesk/deepdesk-sdk 10.10.3-beta.0 → 10.10.3-beta.1
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 +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/index.iife.js +2 -2
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -16,13 +16,13 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
|
16
16
|
`);return o=o.replace(/\n{3,}/g,`
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
`),o=o.replace(/\n/g,"<br/>"),o}createContainer(t){var n;let o=(typeof global<"u"&&global.INTERWEAVE_SSR_POLYFILL||ER)();if(!o)return;let i=(n=this.props.containerTagName)!==null&&n!==void 0?n:"body",s=i==="body"||i==="fragment"?o.body:o.createElement(i);return t.match(wR)||(s.innerHTML=this.convertLineBreaks(this.props.escapeHtml?(0,E_.default)(t):t)),s}extractAttributes(t){let{allowAttributes:n}=this.props,r={},o=0;return t.nodeType!==C_||!t.attributes||([...t.attributes].forEach(i=>{let{name:s,value:a}=i,l=s.toLowerCase(),u=Fc[l]||Fc[s];if(!this.isSafe(t)||!l.match(bR)&&(!n&&(!u||u===yg)||l.startsWith("on")||a.replace(/(\s|\0|�([9AD]);)/,"").match(/(javascript|vbscript|livescript|xss):/i)))return;let c=l==="style"?this.extractStyleAttribute(t):a;u===Sr?c=!0:u===oo?c=Number.parseFloat(String(c)):u!==Dc&&(c=String(c)),r[vg[l]||l]=this.applyAttributeFilters(l,c),o+=1}),o===0)?null:r}extractStyleAttribute(t){let n={};return Array.from(t.style).forEach(r=>{let o=t.style[r];(typeof o=="string"||typeof o=="number")&&(n[r.replace(/-([a-z])/g,(i,s)=>String(s).toUpperCase())]=o)}),n}getTagConfig(t){let n={children:[],content:0,invalid:[],parent:[],self:!0,tagName:"",type:0,void:!1};return ha[t]?{...n,...ha[t],tagName:t}:n}isSafe(t){if(typeof HTMLAnchorElement<"u"&&t instanceof HTMLAnchorElement){let n=t.getAttribute("href");if(n!=null&&n.startsWith("#"))return!0;let r=t.protocol.toLowerCase();return r===":"||r==="http:"||r==="https:"||r==="mailto:"||r==="tel:"}return!0}isTagAllowed(t){return this.banned.has(t)||this.blocked.has(t)?!1:this.props.allowElements||this.allowed.has(t)}parse(){return this.container?this.parseNode(this.container,this.getTagConfig(this.container.nodeName.toLowerCase())):[]}parseNode(t,n){let{noHtml:r,noHtmlExceptMatchers:o,allowElements:i,transform:s,transformOnlyAllowList:a}=this.props,l=[],u="";return[...t.childNodes].forEach(c=>{if(c.nodeType===C_){let d=c.nodeName.toLowerCase(),g=this.getTagConfig(d);u&&(l.push(u),u="");let y=this.applyNodeFilters(d,c);if(!y)return;let v;if(s&&!(a&&!this.isTagAllowed(d))){this.keyIndex+=1;let f=this.keyIndex;v=this.parseNode(y,g);let h=s(y,v,g);if(h===null)return;if(typeof h<"u"){l.push(so.default.cloneElement(h,{key:f}));return}this.keyIndex=f-1}if(this.banned.has(d))return;if(!(r||o&&d!=="br")&&this.isTagAllowed(d)&&(i||this.canRenderChild(n,g))){var p;this.keyIndex+=1;let f=this.extractAttributes(y),h={tagName:d};f&&(h.attributes=f),g.void&&(h.selfClose=g.void),l.push(so.default.createElement(jc,{...h,key:this.keyIndex},(p=v)!==null&&p!==void 0?p:this.parseNode(y,g)))}else l=[...l,...this.parseNode(y,g.tagName?g:n)]}else if(c.nodeType===_R){let d=r&&!o?c.textContent:this.applyMatchers(c.textContent||"",n);Array.isArray(d)?l=[...l,...d]:u+=d}}),u&&l.push(u),l}replaceTokens(t,n){if(!t.includes("{{{"))return t;let r=[],o=t,i=null;for(;i=o.match(CR);){let[s,a]=i,l=i.index,u=s.includes("/");l>0&&(r.push(o.slice(0,l)),o=o.slice(l));let{children:c,matcher:p,props:d}=n[a],g;if(u)g=s.length,r.push(p.createElement(c,d));else{let y=o.match(new RegExp(`{{{/${a}}}}`));g=y.index+y[0].length,r.push(p.createElement(this.replaceTokens(o.slice(s.length,y.index),n),d))}o=o.slice(g)}return o.length>0&&r.push(o),r.length===0?"":r.length===1&&typeof r[0]=="string"?r[0]:r}};function TR(e){var t;let{attributes:n,className:r,containerTagName:o,content:i,emptyContent:s,parsedContent:a,tagName:l,noWrap:u}=e,c=(t=o??l)!==null&&t!==void 0?t:"span",p=c==="fragment"?!0:u,d;if(a)d=a;else{let g=new Hc(i??"",e).parse();g.length>0&&(d=g)}return d||(d=s),p?so.default.createElement(so.default.Fragment,null,d):so.default.createElement(jc,{attributes:n,className:r,tagName:c},d)}function En(e){let{attributes:t,className:n,content:r="",disableFilters:o=!1,disableMatchers:i=!1,emptyContent:s=null,filters:a=[],matchers:l=[],onAfterParse:u=null,onBeforeParse:c=null,tagName:p="span",noWrap:d=!1,...g}=e,y=i?[]:l,v=o?[]:a,f=c?[c]:[],h=u?[u]:[];y.forEach(b=>{b.onBeforeParse&&f.push(b.onBeforeParse.bind(b)),b.onAfterParse&&h.push(b.onAfterParse.bind(b))});let m=f.reduce((b,C)=>C(b,e),r??""),x=new Hc(m,g,y,v),_=h.reduce((b,C)=>C(b,e),x.parse());return so.default.createElement(TR,{attributes:t,className:n,containerTagName:e.containerTagName,emptyContent:s,noWrap:d,parsedContent:_.length===0?void 0:_,tagName:p})}var Rg=S(q());var xg={root:"_root_smoda_1",agentText:"_agentText_smoda_3",textInput:"_textInput_smoda_8",textInputWrapper:"_textInputWrapper_smoda_27",alert:"_alert_smoda_31",alertText:"_alertText_smoda_50",warning:"_warning_smoda_60",success:"_success_smoda_69"};var k_=S(q());var bi=S(O());function T_(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function Bc(e){let t=(0,bi.useRef)(null),[n,r]=(0,bi.useState)(!1);return(0,bi.useEffect)(()=>{let o=!1,i=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[s,a]=T_((c,p)=>{let d=t.current;if(!d)return;let g=c/i,y=p/i,v=d.getBoundingClientRect(),f=g>v.x&&g<v.x+v.width&&y>v.y&&y<v.y+v.height;f&&!o?(o=!0,r(!0)):!f&&o&&(o=!1,r(!1))},({clientX:c,clientY:p})=>[c,p]),[l,u]=T_(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",l),()=>{a(),u(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}var Tn={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var _g=S(w()),kR=({inputElement:e,children:t})=>{let n=k("TabCompletion",Tn),[r,o]=Bc(e);return(0,_g.jsx)("mark",{ref:r,className:(0,k_.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},Ci=class extends bn{match(t){let n=t.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(t,n){return(0,_g.jsx)(kR,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var Ei=S(O());function zc(e){return e.contentEditable==="true"}function PR(e){let t=0,n=0,r=window.getSelection();if(r.rangeCount!==0){let o=r.getRangeAt(0),i=o.cloneRange();i.selectNodeContents(e),i.setEnd(o.endContainer,o.endOffset),n=i.toString().length,i.selectNodeContents(e),i.setEnd(o.startContainer,o.startOffset),t=i.toString().length}return{selectionStart:t,selectionEnd:n}}function P_(e){let{selectionStart:t,selectionEnd:n}=zc(e)?PR(e):e;return[t,n]}function Uc(e){let[,t]=(0,Ei.useState)(),n=(0,Ei.useRef)(null);return n.current=P_(e),(0,Ei.useEffect)(()=>{let r=()=>{let[o,i]=n.current??[],s=P_(e);(!s||o!==s[0]||i!==s[1])&&(n.current=s,t({}))};return e.addEventListener("keyup",r),e.addEventListener("click",r),e.addEventListener("focus",r),document.addEventListener("selectionchange",r),()=>{e.removeEventListener("keyup",r),e.removeEventListener("click",r),e.removeEventListener("focus",r),document.removeEventListener("selectionchange",r)}},[e]),n.current}function Kc(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(Lo);if(!s||s.length===0)return;let a=0;s.find(l=>{let u=r.indexOf(l,a);return o>u&&i<u+l.length?(n.selectionStart=u,n.selectionEnd=u+l.length,!0):(a=u+l.length,!1)})}var R_=S(O());function Ti(e){(0,R_.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function ao(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}var I_,sn=new Map,RR=["bottom","height","left","right","top","width"],IR=(e={},t={})=>RR.some(n=>e[n]!==t[n]);function L_(e){var n,r;if(e.ownerDocument===document)return[];let t=((r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)??null;return t?[t,...L_(t)]:[]}function A_(e,t){return!e||!t?null:{...e,top:e.top+t.top,left:e.left+t.left}}var Vc=!1,O_=()=>{Vc=!0;let e=[];if(sn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),sn.delete(n);return}let r=n.getBoundingClientRect();IR(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(A_,t.rect):t.rect;t.callbacks.forEach(r=>r(n))}),sn.size===0){Vc=!1;return}I_=window.requestAnimationFrame(O_)};function wg(e,t){let n=L_(e),r=[],o=n.map((i,s)=>wg(i,a=>{r[s]=a;let l=sn.get(e);if(!l)return;let u=r.reduce(A_,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),sn.has(e)){let s=sn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else sn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Vc&&O_()},unobserve(){o.forEach(s=>s.unobserve());let i=sn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||sn.delete(e),sn.size||(cancelAnimationFrame(I_),Vc=!1)}}}}var N_,an=new Map,M_=()=>{an.forEach((e,t)=>{if(!t.isConnected){an.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(i=>i(e.visible)))}),an.size!==0&&(N_=window.requestAnimationFrame(M_))};function D_(e,t){return{observe(){let n=an.size===0;an.has(e)?an.get(e).callbacks.push(t):an.set(e,{visible:void 0,callbacks:[t]}),n&&M_()},unobserve(){let n=an.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||an.delete(e),an.size||cancelAnimationFrame(N_)}}}}var bg=["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 Cg(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ki(e){return parseFloat(e)}function Wc(e){return Math.round(e*1e6)}function F_(e){return e/1e6}function Eg(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=ki(e.width),i=ki(e.borderLeftWidth),s=ki(e.borderRightWidth),a=ki(e.paddingRight),l=F_(Wc(o)-Wc(i)-Wc(s)),u=F_(Wc(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function lo(e,t={}){var c;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=t.position??"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",ao(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};Cg(r,n,bg),Eg(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=D_(e,()=>{Cg(r,n,bg),Eg(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=wg(e,p=>{if(p===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),p.height===0&&p.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(Cg(r,n,bg),Eg(r,e,n),i(),n.style.top=`${p.top}px`,n.style.left=`${p.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let d=t.closestScrollElement.getBoundingClientRect(),g=window.getComputedStyle(t.closestScrollElement),y=ki(g.borderTopWidth),v=ki(g.borderBottomWidth),f=d.top+y-p.top,h=p.top+p.height+-(d.top+d.height-v);n.style.clipPath=`inset(${f}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(c=e.parentElement)==null||c.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var Tg={};Pe(Tg,{enUS:()=>LR,nlNL:()=>AR});var LR={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},AR={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};var ya=S(w()),j_=()=>(0,ya.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,ya.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,ya.jsx)("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});var kg=S(w()),H_=()=>(0,kg.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,kg.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 B_=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(B_||{}),kn=class{constructor(t){this.element=t;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}triggerChange(){let t=this.getText(),n=this.getHTML(),r=t!==this.currentText;this.isActive&&(t===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&r&&!this.isSubmitting&&this.emit("change",{plainText:t}),r&&(this.currentSelection=this.getSelection()),this.currentText=t,this.isSubmitting=!1,(this.currentHTML!==n||n===null&&r)&&(this.emit("updated",{plainText:t}),this.triggerCaretPosition(),this.currentHTML=n))}triggerSelection(){let t=this.getSelection();(t.start!==this.currentSelection.start||t.end!==this.currentSelection.end)&&(this.currentSelection=t,this.emit("selection",t),this.triggerCaretPosition())}triggerCaretPosition(){let t=this.getCaretPosition();hr(t,this.currentCaret)||(this.currentCaret=t,this.emit("caret",t))}handleKeyUp(t){let{key:n,shiftKey:r}=t;(n==="Enter"&&r===!0||n==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(B_).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.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.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};var Pn=class extends kn{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:t,selectionEnd:n}=this.element;return{start:t,end:n}}getSelectedText(){let t=this.getSelection();return t?this.getText().slice(t.start,t.end):""}getCaretPosition(){return null}applyChanges(t){if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);return Promise.resolve(r).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let t=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var o;return(o=t==null?void 0:t.get)==null?void 0:o.call(this.element)},set:o=>{var i;(i=t==null?void 0:t.set)==null||i.call(this.element,o),this.triggerChange()}});let n=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==n&&(n=this.element.disabled,this.emit(n?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};var OR=/[.*+?^${}()|[\]\\]/g,NR=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function MR(e){return e.replace(OR,"\\$&")}function DR(e,t){let n=e.split("").findIndex((r,o)=>r!==t[o]);return n>-1?n:Math.min(e.length,t.length)}function FR(e){return e.search(NR)}function z_(e,t=[]){let n=e;return t.forEach(r=>{if(!r)return;let o=new RegExp(`\\b(${MR(r)})\\b`,"gi");n=n.replace(o,"<strong>$1</strong>")}),n}function U_(e){return e.replace(Lo,'<mark data-type="placeholder">$1</mark>')}function Pi(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function jR(e,t){return e.split("").map((s,a)=>({char:s,index:a})).filter(({char:s,index:a})=>/\s/.test(s)&&a<=t).map(({index:s})=>s).reverse()[0]}function Pg(e,t,n={}){if(t){let r=DR(t.toLowerCase(),e.toLowerCase()),o=Pi(e.substring(r,e.length));if(n.stripAgentPart){let l=e.substring(0,r),u=FR(l);return`<span style="opacity: 0.5">${l.substring(u+1)}</span>${o}`}let s=t.split(Ey).length>3||t.length>30?jR(t.trim(),r):0;return`${`${s>0?"\u2026":""}${Pi(e.substring(s,r))}`}<strong>${o}</strong>`}return e}var HR=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function uo(e){return HR.test(e)}function K_(e){if(uo(e)){let n=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(e);return n?n[1]:""}return e}function V_(e){let t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}var Ue=S(w()),BR=({value:e,onUse:t,...n})=>{var p;let r=j(Tg),o=U(),i=uo(e),s=k("EditSuggestionTextInput",xg),[a,l]=(0,It.useState)(null),u=(0,It.useRef)(null),c=((p=e.match(Lo))==null?void 0:p.length)||0;return(0,It.useEffect)(()=>{let d;return u.current&&(l(u.current),d=new Pn(u.current),d.on("change",({plainText:g})=>{o(nt.actions.userInput({text:g,selection:d.getSelection()}))}),d.on("keydown",g=>{o(nt.actions.registerKeyDown(pc(g))),g.code==="Enter"&&g.shiftKey&&t(d.getText())}),d.on("paste",({pastedText:g,selectionText:y})=>{o(nt.actions.registerPaste({text:g,selectionText:y}))}),d.on("cut",({selectionText:g})=>{o(nt.actions.registerCut(g))})),()=>{o(nt.actions.reset()),d.dispose(),d.deactivate()}},[u]),(0,It.useEffect)(()=>{e&&u.current&&(u.current.value=e)},[e,u]),(0,It.useEffect)(()=>{u.current&&setTimeout(()=>{if(!u.current)return;let d=u.current.value.length;u.current.setSelectionRange(d,d),u.current.focus()},0)},[u]),i?(0,Ue.jsx)("div",{className:s.textInputWrapper,children:(0,Ue.jsx)(En,{className:s.textInput,tagName:"div",content:e})}):(0,Ue.jsxs)("div",{className:s.textInputWrapper,children:[(0,Ue.jsx)("textarea",{...n,ref:u,"data-testid":"edit-suggestion-dialog-textarea",className:s.textInput,defaultValue:e,onChange:()=>{}}),a&&(0,Ue.jsx)(zR,{inputElement:u.current,value:e}),(0,Ue.jsxs)("div",{className:(0,Rg.default)(s.alert,c===0?s.success:s.warning),children:[(0,Ue.jsx)("div",{className:s.alertText,children:r("placeholders",{placeholderSize:c})}),c===0?(0,Ue.jsx)(j_,{}):(0,Ue.jsx)(H_,{})]})]})},zR=({inputElement:e,value:t})=>{let n=k("EditSuggestionTextInput",xg),r=(0,It.useRef)(null),o=Uc(e);return(0,It.useEffect)(()=>{Kc(e,o)},[o,e]),(0,Ue.jsx)(UR,{inputElement:e,children:(0,Ue.jsxs)("div",{ref:r,className:(0,Rg.default)(n.root,n.agentText),children:[(0,Ue.jsx)(En,{tagName:"span",disableLineBreaks:!0,content:t,matchers:[new Ci("placeholders")],inputElement:e,boundaryRef:r}),(0,Ue.jsx)("br",{})]})})},UR=({inputElement:e,children:t})=>{let n=(0,It.useRef)(null);return(0,It.useEffect)(()=>{if(!n.current)return()=>{};let[r,o]=lo(e,{overlayContainer:n.current,mirrorOverflow:!0});return r.setAttribute("translate","no"),()=>{o()}},[n.current]),(0,Ue.jsx)("div",{ref:n,children:t})},W_=BR;var Li=S(O());var $_=S(O()),$c=S(q());var rt={root:"_root_1mc8f_1",list:"_list_1mc8f_2",listWrapper:"_listWrapper_1mc8f_6",listHorizontal:"_listHorizontal_1mc8f_10",page:"_page_1mc8f_19",search:"_search_1mc8f_25",pageNav:"_pageNav_1mc8f_33",pageTitle:"_pageTitle_1mc8f_41",pageBackButton:"_pageBackButton_1mc8f_48",listHeading:"_listHeading_1mc8f_62",listItem:"_listItem_1mc8f_70",listItemContent:"_listItemContent_1mc8f_79",listItemText:"_listItemText_1mc8f_97",listItemDescription:"_listItemDescription_1mc8f_105",listItemActions:"_listItemActions_1mc8f_112",truncate:"_truncate_1mc8f_123",lineClamp:"_lineClamp_1mc8f_129",listItemTitle:"_listItemTitle_1mc8f_136",listItemAction:"_listItemAction_1mc8f_112",listItemPrimaryAction:"_listItemPrimaryAction_1mc8f_157",listItemSelected:"_listItemSelected_1mc8f_162",sources:"_sources_1mc8f_166",sourcesTitle:"_sourcesTitle_1mc8f_173",source:"_source_1mc8f_166",icon:"_icon_1mc8f_188",searchIcon:"_searchIcon_1mc8f_205",searchInputWrapper:"_searchInputWrapper_1mc8f_210",searchInput:"_searchInput_1mc8f_210",select:"_select_1mc8f_231",selectType:"_selectType_1mc8f_248",selectWrapper:"_selectWrapper_1mc8f_252",image:"_image_1mc8f_282",imageSrc:"_imageSrc_1mc8f_289",imageSrcHidden:"_imageSrcHidden_1mc8f_300",imageSrcStatus:"_imageSrcStatus_1mc8f_304",imageTitle:"_imageTitle_1mc8f_314",actions:"_actions_1mc8f_319",actionsWrapper:"_actionsWrapper_1mc8f_323",actionsBar:"_actionsBar_1mc8f_329",actionButton:"_actionButton_1mc8f_338",hasShortKeys:"_hasShortKeys_1mc8f_351",actionShortcut:"_actionShortcut_1mc8f_360",actionShortcutFixKerning:"_actionShortcutFixKerning_1mc8f_367"};var co={};Pe(co,{enUS:()=>KR,nlNL:()=>VR});var KR={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},VR={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var xr=S(w()),WR=({src:e,title:t})=>{let n=k("CommandPalette",rt),[r,o]=(0,$_.useState)("loading"),i=j(co);return(0,xr.jsxs)("div",{className:n.image,children:[(0,xr.jsx)("img",{src:e,alt:t,onLoad:()=>o("done"),onError:()=>o("error"),className:(0,$c.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(r)})}),r==="loading"&&(0,xr.jsx)("span",{className:(0,$c.default)(n.imageSrc,n.imageSrcStatus),children:i("loading")}),r==="error"&&(0,xr.jsx)("span",{className:(0,$c.default)(n.imageSrc,n.imageSrcStatus),children:(0,xr.jsx)(nl,{})}),t&&(0,xr.jsx)("span",{className:n.imageTitle,children:t})]})},q_=WR;var G_=S(O()),X_=S(q());var va=S(w());function Ig({children:e,heading:t,orientation:n}){let r=k("CommandPalette",rt);return G_.default.Children.count(e)===0?null:(0,va.jsxs)("div",{"data-testid":"commandpalette-list",className:r.list,children:[t&&(0,va.jsx)("h4",{className:r.listHeading,children:t}),(0,va.jsx)("div",{className:(0,X_.default)(r.listWrapper,n==="horizontal"&&r.listHorizontal),children:e})]})}var Sa=S(q());var Ae=S(O()),Q_=S(q());var Lg={root:"_root_1oh4w_1",trigger:"_trigger_1oh4w_5",content:"_content_1oh4w_19",contentOpen:"_contentOpen_1oh4w_33",contentTop:"_contentTop_1oh4w_37",contentBottom:"_contentBottom_1oh4w_41",item:"_item_1oh4w_45"};var po=S(w()),$R=0,Y_=Ae.default.createContext(null),qR=()=>{let e=(0,Ae.useContext)(Y_);if(!e)throw new Error("Invalid DropdownContext");return e},Z_=({trigger:e,children:t,position:n="bottom"})=>{let r=(0,Ae.useMemo)(()=>++$R,[]),o=(0,Ae.useRef)(null),i=(0,Ae.useRef)(null),s=k("Dropdown",Lg),[a,l]=(0,Ae.useState)(!1),[u,c]=(0,Ae.useState)(n),p=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},d=(0,Ae.useCallback)(([g])=>{!g.isIntersecting&&a&&c(u==="top"?"bottom":"top")},[a]);return(0,Ae.useEffect)(()=>{let g=y=>{o.current&&!o.current.contains(y.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),(0,Ae.useEffect)(()=>{if(!i.current&&!a)return()=>{};let g=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return i.current&&g.observe(i.current),()=>{i.current&&g.unobserve(i.current)}},[i,a]),(0,po.jsx)(Y_.Provider,{value:{setIsOpen:l},children:(0,po.jsxs)("div",{ref:o,className:s.root,children:[(0,po.jsx)("button",{id:`dropdown-${r}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:s.trigger,onClick:p,children:e}),(0,po.jsx)("div",{"data-testid":"dropdown-content",ref:i,"aria-hidden":!a,"aria-labelledby":`dropdown-${r}`,className:(0,Q_.default)(s.content,{[s.contentOpen]:a,[s.contentTop]:u==="top",[s.contentBottom]:u==="bottom"}),children:t})]})})};function GR({as:e,children:t,onClick:n,...r}){let o=e||"button",i=k("Dropdown",Lg),{setIsOpen:s}=qR(),a=l=>{s(!1),n(l),l.stopPropagation()};return(0,po.jsx)(o,{type:"button",className:i.item,onClick:a,...r,children:t})}Z_.Item=GR;var Ag=Z_;var Og=S(w()),J_=e=>(0,Og.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...e,children:(0,Og.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={};Pe(fo,{enUS:()=>XR,nlNL:()=>QR});var XR={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"}]},QR={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 qc=S(w()),YR="%0d%0a%0d%0a%0d%0a",ZR=(e,t)=>{let n=[`Suggestie: ${encodeURIComponent(t)}`,"Beschrijf je feedback:"];return`mailto:${e.join(",")}?subject=Suggestie feedback&body=${n.join(YR)}`},JR=({suggestion:e,onFeedback:t})=>{let n=j(fo),r=N("suggestionFeedbackEmailAddresses");return!r||r.length===0?null:(0,qc.jsx)(Ag,{trigger:(0,qc.jsx)(J_,{"data-testid":"feedback-dropdown-trigger"}),children:(0,qc.jsx)(Ag.Item,{as:"a",href:ZR(r,e),onClick:t,children:n("giveFeedback")})})},Gc=JR;var Xc=S(O()),nw=S(w()),ew=Xc.default.createContext(void 0);function _r(){let e=Xc.default.useContext(ew);if(e===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return e}var tw=({children:e,page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i})=>{let s=Xc.default.useMemo(()=>({page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i}),[n,t,o]);return(0,nw.jsx)(ew.Provider,{value:s,children:e})};var dt=S(w());function Ng({closeOnSelect:e=!0,lineClamp:t,children:n,onClick:r,onFeedback:o,onSourceClick:i,index:s,description:a,sources:l,styles:u,...c}){let{selected:p,setSelected:d,onChangeOpen:g}=_r(),y=k("CommandPalette",rt);function v(f){r(f),e&&g(!1)}return(0,dt.jsxs)("div",{className:(0,Sa.default)(y.listItem,p===s&&y.listItemSelected),children:[(0,dt.jsx)("button",{onMouseEnter:()=>d(s),type:"button",className:(0,Sa.default)("command-palette-list-item",y.listItemAction,y.listItemPrimaryAction),"aria-disabled":c.disabled??!1,onClick:v,...c,children:(0,dt.jsxs)("div",{className:y.listItemContent,children:[typeof n=="string"?(0,dt.jsx)("p",{className:(0,Sa.default)(y.listItemText,y.truncate,u==null?void 0:u.title),children:n}):n,a&&(0,dt.jsx)(En,{tagName:"p",allowList:[],content:uo(a)?V_(a):a,className:(0,Sa.default)(y.listItemDescription,u==null?void 0:u.description,t?y.lineClamp:y.truncate)})]})}),o&&p===s&&(0,dt.jsx)("div",{className:y.listItemActions,children:(0,dt.jsx)(Gc,{suggestion:String(n),onFeedback:o})}),l&&(0,dt.jsxs)("div",{className:y.sources,children:[(0,dt.jsx)("span",{className:y.sourcesTitle,children:"Sources"}),l.map(f=>f.url?(0,dt.jsx)("a",{className:y.source,href:f.url,target:"_blank",title:f.url,rel:"noopener noreferrer",onClick:()=>i&&i(f),children:f.name},f.url):(0,dt.jsx)("span",{className:y.source,children:f.name},f.name))]})]})}var mo=S(w());function Mg({children:e,title:t,id:n,onDismiss:r}){let o=j(co),i=k("CommandPalette",rt),{page:s}=_r();return s!==n?null:(0,mo.jsxs)("div",{className:i.page,id:`page_${n}`,tabIndex:-1,children:[r&&(0,mo.jsxs)("div",{className:i.pageNav,children:[(0,mo.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:r,children:[(0,mo.jsx)(Ac,{}),o("back")]}),t&&(0,mo.jsx)("h3",{className:i.pageTitle,children:t})]}),e]})}var wr=S(O());var Qc=()=>/Mac/i.test(navigator.platform);var eI={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},H=eI;function tI(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function Z(e){return Array.isArray(e)?e.map(Z):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[tI(n)]:Z(e[n])}),{}):e}function Dg(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function ke(e){return Array.isArray(e)?e.map(ke):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[Dg(n)]:ke(e[n])}),{}):e}var nI={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},_a=e=>{var t,n,r;return{timezone:((t=e.info.visitorInfo)==null?void 0:t.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((n=e.info.agentInfo)==null?void 0:n.agentNickname)||"",visitorName:((r=e.info.visitorInfo)==null?void 0:r.visitorName)||""}},xa=M("info/setAgentInfo",async(e,t)=>{let{deepdeskAPI:n}=t.extra;if(!e.agentId&&!e.agentNickname)throw new Error("At least provide agentId or agentNickname");let r=await n.client.get("/apis/admin/session/me/",{version:null}),o={};return r.external_id||(o.external_id=e.agentId),r.nickname||(o.nickname=e.agentNickname),!o.external_id&&!o.nickname?Z(r):(await n.client.patch("/apis/admin/session/me/",o,{version:null}),Z(r))}),Fg=M("info/setAgentSettings",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=await n.client.get("/apis/admin/session/me/",{version:null}),o={...typeof r.ui_config=="object"?r.ui_config:{},...e};return await n.client.patch("/apis/admin/session/me/",{ui_config:o}),o}),jg=M("info/getAgentSettings",async(e,t)=>{let{deepdeskAPI:n}=t.extra;return(await n.client.get("/apis/admin/session/me/",{version:null})).ui_config}),rw=e=>e.info.agentInfo,ow=z({name:"info",initialState:nI,reducers:{setVisitorInfo(e,t){e.visitorInfo={...e.visitorInfo,...t.payload}}},extraReducers:e=>{e.addCase(xa.pending,(t,n)=>{t.fetchState="loading",t.agentInfo={...t.agentInfo,...n.meta.arg}}).addCase(xa.rejected,t=>{t.fetchState="error"}).addCase(xa.fulfilled,(t,n)=>{t.fetchState="done",t.agentInfo={...t.agentInfo,...n.meta.arg,agentId:n.payload.externalId||n.meta.arg.agentId||"",agentNickname:n.payload.nickname||n.meta.arg.agentNickname||""}}).addCase(Fg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(jg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(te,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:iw}=ow.actions,sw=ow.reducer;var Yc={list:[],fetchState:"idle",isOpen:!1,page:"search"},aw=e=>e.search.isOpen,lw=e=>e.search.page,uw=e=>e.search.list;function cw(e,t=n=>n){return n=>n.search.list.filter(r=>r.type===e).map(t)}var go=M("search/getAll",async(e,t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(s=r.conversation.current)==null?void 0:s.profileCode;if(!o)throw new Error("Profile should be provided in order to be able to search");let{results:i}=await n.search({profile:o,query:e.query,filters:{type:e.type},params:_a(r),tags:e.tags});return i.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:e.query}))}),dw=z({name:"search",initialState:Yc,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=Yc.fetchState,e.list=Yc.list}},extraReducers:e=>{e.addCase(go.pending,t=>{t.fetchState="loading"}).addCase(go.rejected,(t,n)=>{t.fetchState="error",H.error(n.error)}).addCase(go.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload}).addCase(te,()=>Yc)}}),{resetSearch:Zc,setIsOpen:$e,setPage:qe}=dw.actions,pw=dw.reducer;var rI=/(https?:\/\/[^\s]+)/,Jc=e=>e.split(" ").find(t=>rI.test(t));var Hg=S(q());var ed=S(w()),oI=({onClick:e,shortKeys:t,children:n,...r})=>{let o=k("CommandPalette",rt);return(0,ed.jsxs)("button",{type:"button",...r,onClick:e,className:(0,Hg.default)(o.actionButton,r.className,{[o.hasShortKeys]:t&&t.length>0}),children:[n,t&&t.map(i=>(0,ed.jsx)("span",{className:(0,Hg.default)(o.actionShortcut,i===8629&&o.actionShortcutFixKerning),children:typeof i=="number"?String.fromCharCode(i):i},i))]})},Ri=oI;var Rn=S(w()),iI=({children:e,primaryLabel:t,secondaryLabel:n,onPrimary:r,onSecondary:o,list:i})=>{let s=k("CommandPalette",rt),a=j(co),{selected:l,setSelected:u}=_r(),c=i[l],p=c&&typeof c.text=="string"&&Jc(c.text),d=(0,wr.useRef)(null);function g(x){if(!d.current)return;let _=d.current.querySelectorAll(".command-palette-list-item"),b=0,C=0;x==="down"?(_.forEach((I,P)=>{P===l&&(b=P)}),C=b===_.length-1?0:b+1):x==="up"?(_.forEach((I,P)=>{P===l&&(b=P)}),C=b?b-1:_.length-1):u(0);let E=_[C];E&&typeof C=="number"&&(u(C),E.scrollIntoView&&E.scrollIntoView({behavior:"smooth",block:C?"center":"end"}))}function y(){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),_=0;x.forEach((C,E)=>{E===l&&(_=E)});let b=x[_];b&&b.click()}let v=()=>{p&&window.open(p,"_blank")},f=()=>{c&&r(c,l)},h=()=>{!c.type||["IMAGE","command"].includes(c.type)||o&&o(c,l)},m=(0,wr.useCallback)(x=>{if(x.key==="Enter"&&x.altKey&&p){v();return}if(x.key==="Enter"&&x.shiftKey){h();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),g("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),g("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),y())},[l]);return(0,wr.useEffect)(()=>(window.addEventListener("keyup",m),()=>{window.removeEventListener("keyup",m)}),[m]),(0,Rn.jsxs)("div",{className:s.actions,children:[(0,Rn.jsx)("div",{className:s.actionsWrapper,ref:d,children:e}),(0,Rn.jsxs)("div",{className:s.actionsBar,children:[p&&(0,Rn.jsx)(Ri,{onClick:v,shortKeys:[Qc()?8997:"ALT",8629],children:a("visitUrl")}),c&&(0,Rn.jsxs)(wr.Fragment,{children:[o&&c.type&&!["command","image"].includes(c.type.toLowerCase())&&(0,Rn.jsx)(Ri,{onClick:h,shortKeys:[8679,8629],children:n}),(0,Rn.jsx)(Ri,{onClick:f,shortKeys:[8629],children:t})]})]})]})},mw=iI;var gw=S(O());var wa=S(w()),Ii=()=>(0,wa.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,wa.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,wa.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 Kt=S(w());function sI({onChange:e,onChangeType:t,placeholder:n,typePlaceholder:r,types:o,value:i,selectedType:s},a){let l=k("CommandPalette",rt);return(0,Kt.jsxs)("div",{className:l.search,children:[(0,Kt.jsx)("div",{className:l.searchIcon,children:(0,Kt.jsx)(Ii,{})}),(0,Kt.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Kt.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:u=>{e(u.currentTarget.value)},onFocus:u=>{u.currentTarget.select()},className:l.searchInput,placeholder:n,value:i,type:"text",id:"command-palette-search-input",autoFocus:!0}),o&&o.length>0&&(0,Kt.jsx)("div",{className:l.selectWrapper,children:(0,Kt.jsxs)("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:u=>t(u.target.value===r?void 0:u.target.value),value:s||r,children:[r&&(0,Kt.jsx)("option",{children:r}),o.map(u=>(0,Kt.jsx)("option",{value:u.value,children:u.label},u.value))]})})]})]})}var hw=(0,gw.forwardRef)(sI);var ba=S(w());function ho({placeholder:e="Start typing to search...",typePlaceholder:t="All types",defaultPage:n="search",page:r,onChangePage:o,onChangeSearch:i,onChangeType:s,onChangeOpen:a,selectedType:l,types:u,children:c,isOpen:p,search:d}){let[g,y]=(0,Li.useState)(0),v=(0,Li.useRef)(null),f=()=>{o&&o(n),s(void 0),i(""),a(!1)},h=()=>{var m;if(r!==n&&o){o(n);return}if(l&&s){s(void 0),(m=v.current)==null||m.focus();return}if(d.length>0){i("");return}a(!1)};return(0,Li.useEffect)(()=>{y(0)},[d,r]),(0,ba.jsx)(wi,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:h,onClose:f,children:(0,ba.jsxs)(tw,{selected:g,setSelected:y,isOpen:p,onChangeOpen:a,page:r,children:[r===n&&(0,ba.jsx)(hw,{ref:v,onChange:i,onChangeType:s,placeholder:e,value:d,selectedType:l,types:u,typePlaceholder:t}),c]})})}ho.Page=Mg;ho.List=Ig;ho.Image=q_;ho.ListItem=Ng;ho.ActionsBar=mw;ho.Button=Ri;var $=ho;var Ke=S(w()),aI=({suggestion:e,onUse:t,onDismiss:n,onTouched:r,onNext:o,onPrevious:i})=>{let s=e.text||e.url||e.message,a=k("EditSuggestionForm",c_),l=U(),u=j(rg),c=R(y=>y.overlayInput.text);(0,Bg.useEffect)(()=>{e&&(l(nt.actions.reset()),l(nt.actions.stageSuggestion({text:s,suggestion:e,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(nt.actions.commitSuggestion()))},[e]);let p=y=>{y.preventDefault(),d(c)},d=y=>{l(gc(y)),t(y)},g=y=>v=>{c!==s?window.confirm(u("warning"))&&y(v):y(v)};return(0,Bg.useEffect)(()=>{r&&r(c!==s)},[r,e,c]),(0,Ke.jsxs)("div",{className:a.root,children:[(0,Ke.jsxs)("div",{className:a.content,children:[e.title&&(0,Ke.jsx)("h3",{className:a.title,children:e.title}),e.searchKeywords&&e.searchKeywords.length>0&&(0,Ke.jsx)(Xd,{labels:e.searchKeywords}),(0,Ke.jsx)(W_,{onUse:d,value:K_(c)})]}),(0,Ke.jsxs)("form",{className:a.actions,onSubmit:p,children:[(0,Ke.jsxs)("div",{children:[(0,Ke.jsx)("button",{disabled:!i,className:a.pagination,type:"button",onClick:i&&g(i),children:(0,Ke.jsx)(Ac,{})}),(0,Ke.jsx)("button",{disabled:!o,className:a.pagination,type:"button",onClick:o&&g(o),children:(0,Ke.jsx)(x_,{})})]}),(0,Ke.jsxs)("div",{className:a.primaryButtons,children:[(0,Ke.jsx)($.Button,{onClick:g(n),shortKeys:["esc"],children:u("dismiss")}),(0,Ke.jsx)($.Button,{shortKeys:[8679,8629],type:"submit",children:u("add")})]})]})]})},td=aI;var lI=["{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}"],uI=new RegExp(lI.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function yw(e,t){let n=e.split(uI),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],l=i===n.length-2;r+=s.length;let u=r;if(l){let p=a.charAt(0),d=0;do u=p?t.indexOf(p,u+1):-1,d+=1;while(u!==-1&&a.indexOf(t.slice(u))!==0);if(u===-1&&d>2)return e}else u=a&&a!==""?t.indexOf(a,r):-1;let c=u===-1?t.slice(r):t.slice(r,u);o.push(c),r=u}return o.join("")}function vw(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var xw={suggestions:[],fetchState:"idle",isInitialRequest:null},Sw={default:xw},nd=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)??[]},_w=e=>{let t=Object.keys(e.textSuggestions).map(n=>{var r;return(r=e.textSuggestions[n])==null?void 0:r.fetchState});return t.length===0?!0:t.every(n=>n!=="done")},br=e=>e.textSuggestions,ww=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},rd=fe("textSuggestions/refresh"),Vt=M("textSuggestions/recommendations",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,inlineSuggestions:s}=r.settings,a=xi(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getTextSuggestions(o,_a(r),e);if(e==="default"){let c=s?l.filter(ww(a)):l;t.dispatch(on(c.slice(0,i)))}return l}),Ca=M("textSuggestions/autocompletions",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,deanonymize:s,inlineSuggestions:a}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getAutocompleteSuggestions(o,{..._a(r),input:e});if(!t.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(ww(e))),s&&(l=l.map(c=>({...c,text:c.source!=="trie-with-typos"?yw(c.text,e):c.text}))),l=vw(l,i),t.dispatch(on(l)),l}),bw=z({name:"textSuggestions",initialState:Sw,reducers:{setTextSuggestions:{reducer(e,t){let{contentType:n}=t.payload;e[n].fetchState="done",e[n].suggestions=t.payload.suggestions},prepare(e,t){return{payload:{contentType:e,suggestions:t}}}},setSuggestionState(e,t){return t.payload}},extraReducers:e=>{e.addCase(Vt.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||xw;return{...t,[r]:{...o,fetchState:"loading",isInitialRequest:o.isInitialRequest===null}}}).addCase(Vt.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(Vt.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(Ca.pending,t=>{t.default.fetchState="loading"}).addCase(Ca.rejected,t=>{t.default.fetchState="error"}).addCase(Ca.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(te,()=>Sw)}}),{setTextSuggestions:Cw,setSuggestionState:Ew}=bw.actions,Tw=bw.reducer;var kw={contentType:null,suggestion:null},Pw=e=>e.activeSuggestion.suggestion,Rw=e=>e.activeSuggestion.contentType,Iw=z({name:"activeSuggestion",initialState:kw,reducers:{setActiveSuggestion(e,t){let{contentType:n,suggestion:r}=t.payload;e.contentType=n,e.suggestion=r},resetActiveSuggestion(e){e.contentType=null,e.suggestion=null}},extraReducers:e=>{e.addCase(te,()=>kw)}}),{setActiveSuggestion:In,resetActiveSuggestion:zg}=Iw.actions,Lw=Iw.reducer;var Ug={};Pe(Ug,{enUS:()=>cI,nlNL:()=>dI});var cI={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},dI={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};var pI={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var od=({ui:e})=>e.overlayCollapsed;var Aw=z({name:"ui",initialState:pI,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputHasFocus(e,t){e.overlayCollapsedUserOverwrite!==!0&&(t.payload===!0&&(e.overlayCollapsed=!1),e.inputHasFocus=t.payload)},setOverlayCollapsed(e,t){t.payload.collapse===!1&&(e.openOverlayWhenTyping=!1),!(t.payload.skipWhenInputFocus&&e.inputHasFocus)&&(e.overlayCollapsed=t.payload.collapse)},setOpenOverlayWhenTyping(e,t){e.openOverlayWhenTyping=t.payload},setOverlayCollapsedUserOverwrite(e,t){e.overlayCollapsedUserOverwrite=t.payload,e.overlayCollapsed=t.payload}}}),{setShowTabHint:Ea,setInputHasFocus:Ai,setOverlayCollapsed:Cr,setOpenOverlayWhenTyping:Ow,setOverlayCollapsedUserOverwrite:Nw}=Aw.actions,Mw=Aw.reducer;var Ta=S(O()),Fw=S(w()),Dw=Ta.default.createContext(null),yo=({broadcastEvents:e,children:t})=>{let n=Ta.default.useMemo(()=>e,[]);return(0,Fw.jsx)(Dw.Provider,{value:n,children:t})},Lt=()=>{let e=(0,Ta.useContext)(Dw);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var fI={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},pt=e=>e.auth.isLoggedIn,jw=e=>e.auth.loginFetchState,Hw=e=>e.auth.verifyFetchState,Bw=e=>e.auth.showLoginOverlay,Ln=M("auth/validate",async(e,t)=>t.extra.deepdeskAPI.isLoggedIn()),zw=M("auth/requestLogin",async({email:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.requestLoginByEmail(e)}),ka=M("auth/verifyLoginToken",async({token:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.verifyLoginToken(e)}),Uw=z({name:"auth",initialState:fI,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload}},extraReducers:e=>{e.addCase(Ln.pending,t=>{t.loginFetchState="loading"}),e.addCase(Ln.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(Ln.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(ka.pending,t=>{t.verifyFetchState="loading"}),e.addCase(ka.rejected,t=>{t.verifyFetchState="error"}),e.addCase(ka.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:Oi,setShowLoginOverlay:Kw}=Uw.actions,Vw=Uw.reducer;var Kg="SetActiveSuggestion",Ni="ShowLoginOverlay",Pa="UserLoggedIn",mI="UserLoggedOut",An="ApplySuggestion",Vg="ApplyImageSuggestion",gI="ShowCommandPalette",hI=e=>({[Kg]:t=>{e.dispatch(Ew(t.state)),e.dispatch(In({contentType:t.contentType,suggestion:t.suggestion}))},[gI]:t=>{e.dispatch($e(t.isOpen)),t.page&&e.dispatch(qe(t.page))},[Ni]:t=>{e.dispatch(Kw(t))},[Pa]:()=>{e.dispatch(Ln())},[mI]:()=>{e.dispatch(Ln())},[Vg]:t=>{e.dispatch(yc({suggestion:t.suggestion}))},[An]:t=>{e.dispatch(Bt({...t,eventMetrics:{inputType:"mouse"},replace:"selection"})),e.dispatch(wn())}}),Ww=hI;var Wg=S(w()),yI=()=>{var y;let[e,t]=(0,$w.useState)(!1),n=R(Pw),r=R(Rw),o=R(br),i=U(),s=Lt(),a=j(Ug),l=()=>{n!==null&&e?window.confirm(a("warning"))&&u():u()},u=()=>{i(zg()),i(Ai(!0)),i(nt.actions.reset())},c=(v,f)=>{i(zg()),i(Ai(!0)),s.send(An,{text:v,suggestion:{...f,source:`${f.source||"text_recommendation"}-preview`}})};if(n===null||r===null)return null;let p=(y=o[r])==null?void 0:y.suggestions.indexOf(n),d=p===0||p===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[p-1]})),g=p===o[r].suggestions.length-1||p===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[p+1]}));return(0,Wg.jsx)(wi,{autoFocus:!0,isOpen:p!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Wg.jsx)(td,{onTouched:t,onDismiss:u,onUse:v=>c(v,n),suggestion:n,onNext:g,onPrevious:d})})},qw=yI;var id=S(q()),Wt=S(O());var Xw=S(q());var Gw={root:"_root_1ukx5_1"};var Qw=S(w()),vI=({className:e,value:t,...n})=>{let r=k("TextInput",Gw);return(0,Qw.jsx)("input",{className:(0,Xw.default)(e,r.root),type:"text",value:t,...n})},Ra=vI;var $g={};Pe($g,{enUS:()=>SI,nlNL:()=>xI});var SI={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"}]},xI={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 Yw={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};var ye=S(w());var _I=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch{return e}},wI=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=j($g),s=k("LoginTokenDialog",Yw),a=R(Hw),l=U(),u=N("productName"),[c,p]=(0,Wt.useState)(e||""),[d,g]=(0,Wt.useState)(0),[y,v]=(0,Wt.useState)(""),f=(0,Wt.useCallback)(async _=>{_.preventDefault(),l(zw({email:c})),g(1)},[n,c]),h=()=>{v(""),g(0)},m=(0,Wt.useCallback)(async _=>{_.preventDefault();let b=_I(_.target.elements.token.value);if(!b){v(i("verifyCodeError",{login:x}));return}l(ka({token:b}))},[n]),x=(0,Wt.useMemo)(()=>_=>(0,ye.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:h,children:_},"back-button"),[]);return(0,Wt.useEffect)(()=>{a==="error"&&v(i("verifyCodeError",{login:x})),a==="done"&&r()},[a]),(0,ye.jsx)(wi,{autoFocus:!0,isOpen:t,contentAriaLabel:i("promptTitle",{productName:u}),overlayAriaLabel:i("promptTitle",{productName:u}),onClose:o,onBack:o,children:(0,ye.jsxs)("div",{className:s.root,children:[(0,ye.jsx)("h1",{className:s.title,children:i("promptTitle",{productName:u})}),d===0&&(0,ye.jsxs)("form",{onSubmit:f,children:[(0,ye.jsx)("h2",{className:s.subtitle,children:i("requestCodeTitle")}),(0,ye.jsx)("p",{className:s.text,children:i("requestCodeBody",{productName:u})}),(0,ye.jsx)(Ra,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:c,onChange:_=>p(_.target.value)}),(0,ye.jsx)("div",{className:s.actions,children:(0,ye.jsx)("button",{type:"submit",className:(0,id.default)(s.button,s.primaryButton),children:i("requestCodeSubmitLabel")})})]}),d===1&&(0,ye.jsxs)("form",{onSubmit:m,children:[(0,ye.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,ye.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,ye.jsx)(Ra,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),y&&(0,ye.jsx)("div",{className:s.errorMessage,children:y}),(0,ye.jsxs)("div",{className:s.actions,children:[(0,ye.jsx)("button",{type:"button",className:(0,id.default)(s.button),onClick:h,children:i("back")}),(0,ye.jsx)("button",{type:"submit",className:(0,id.default)(s.button,s.primaryButton),disabled:["loading","done"].includes(a),children:i("verifyCodeSubmitLabel")})]})]})]})})},Zw=wI;var e1=S(w()),bI=()=>{let e=R(Bw),t=R(rw),n=N("adminUrl"),r=Lt(),o=()=>r.send(Ni,!1),i=()=>{r.send(Ni,!1),r.send(Pa)};return(0,e1.jsx)(Zw,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},Jw=bI;var I1=S(Xg()),Ge=S(O());var zI={data:null,fetchState:"idle"},o1=e=>e.contentTypes.data,Ia=M("contentTypes/getContentTypes",async(e,t)=>t.extra.deepdeskAPI.getContentTypes()),UI=z({name:"contentTypes",initialState:zI,reducers:{},extraReducers:e=>{e.addCase(Ia.pending,t=>{t.fetchState="loading"}).addCase(Ia.rejected,t=>{t.fetchState="error"}).addCase(Ia.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),i1=UI.reducer;function La(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy"),t.remove()}var s1=S(O());function a1(e,t){(0,s1.useEffect)(()=>{let n=r=>{var o;((o=navigator==null?void 0:navigator.platform)!=null&&o.toLowerCase().includes("mac")?r.metaKey:r.ctrlKey)&&r.key===e&&(r.preventDefault(),r.stopPropagation(),t())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var Aa=S(O());var l1={data:null,fetchState:"idle"},sd=e=>{var i;let t=[],{visitorName:n}=e.info.visitorInfo??{},{agentName:r,agentNickname:o}=e.info.agentInfo??{};return r&&r!==n&&t.push(r),o&&o!==n&&t.push(o),((i=e.entities.data)==null?void 0:i.filter(s=>!t.includes(s.text)))??null},$t=M("entities/getEntities",async(e,t)=>{let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra;if(!r.conversationQuery)return Promise.resolve([]);let o=r.conversationQuery,i=await o();return i.length===0?Promise.resolve([]):n.getEntities(i)}),KI=e=>e.filter((t,n)=>n===e.findIndex(r=>r.text===t.text)),VI=z({name:"entities",initialState:l1,reducers:{},extraReducers:e=>{e.addCase($t.pending,t=>{t.fetchState="loading"}).addCase($t.rejected,t=>{t.fetchState="error"}).addCase($t.fulfilled,(t,n)=>{t.fetchState="done",t.data=KI(t.data?[...t.data,...n.payload]:n.payload)}).addCase(te,()=>l1)}}),u1=VI.reducer;var Qg={};Pe(Qg,{enUS:()=>WI,nlNL:()=>$I});var WI={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},$I={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var c1={root:"_root_17kae_1",empty:"_empty_17kae_5"};var vo=S(w()),qI=({onCopy:e,onUse:t})=>{let n=(0,Aa.useRef)(null),r=k("EntitiesList",c1),o=j(Qg),i=R(sd),s=U();return(0,Aa.useEffect)(()=>{s($t())},[]),(0,Aa.useEffect)(()=>{n.current&&n.current.focus()},[n]),(0,vo.jsxs)("div",{className:r.root,ref:n,tabIndex:-1,children:[i&&i.length>0&&(0,vo.jsx)($.ActionsBar,{primaryLabel:o("copy"),secondaryLabel:o("use"),onPrimary:(a,l)=>e(i[l]),onSecondary:(a,l)=>t(i[l]),list:i.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:(0,vo.jsx)($.List,{children:i.map((a,l)=>(0,vo.jsx)($.ListItem,{index:l,closeOnSelect:!0,onClick:()=>e(a),children:a.text},a.text))},"entities")}),i&&i.length===0&&(0,vo.jsx)("p",{className:r.empty,children:o("noResults")})]})},d1=qI;var qt=S(O());var p1={data:null,fetchState:"idle"},f1=e=>e.summary.data,m1=e=>e.summary.fetchState==="error",On=M("summary/getSummary",async(e,t)=>{let n=t.getState().profile.data;if(!n)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:o}=t.extra;if(!o.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let i=o.conversationQuery,s=await i();if(s.length===0)return Promise.reject(new Error("No messages are included"));let a=await r.getSummary(s,{promptInstruction:n.summarizerPromptInstruction,model:n.summarizerModel});return a?{summary:a}:Promise.reject(new Error("Summary is not provided"))}),GI=z({name:"summary",initialState:p1,reducers:{},extraReducers:e=>{e.addCase(On.pending,t=>{t.data=null,t.fetchState="loading"}).addCase(On.rejected,t=>{t.data=null,t.fetchState="error"}).addCase(On.fulfilled,(t,n)=>{t.fetchState="done",n.payload&&(t.data=n.payload.summary)}).addCase(te,()=>p1)}}),g1=GI.reducer;var Yg={};Pe(Yg,{enUS:()=>XI,nlNL:()=>QI});var XI={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},QI={copy:[{type:0,value:"Kopieer"}],error:[{type:0,value:"Kon helaas geen samenvatting genereren."}],loading:[{type:0,value:"Samenvatting wordt gemaakt, dit kan even duren."}]};var h1={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var Nn=S(w()),YI=({onCopy:e})=>{let t=(0,qt.useRef)(null),n=k("SummaryForm",h1),[r,o]=(0,qt.useState)(""),i=j(Yg),s=R(f1),a=R(m1),l=U(),u=()=>{l(Be({name:"summary copied to clipboard",data:{originalText:s,finalText:r},options:{includeConversationData:!0}})),e(r)},c=()=>{let p=document.getSelection();p&&l(Be({name:"summary copied to clipboard",data:{originalText:s,finalText:p==null?void 0:p.toString()},options:{includeConversationData:!0}}))};return(0,qt.useEffect)(()=>{l(On())},[]),(0,qt.useEffect)(()=>{o(s||"")},[s]),(0,qt.useEffect)(()=>{t.current&&s&&t.current.focus()},[t,s]),(0,qt.useEffect)(()=>{let p=d=>{d.key==="Enter"&&d.shiftKey&&u()};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[r]),(0,Nn.jsx)("div",{className:n.root,tabIndex:-1,children:a?(0,Nn.jsx)("p",{className:n.error,children:i("error")}):(0,Nn.jsxs)(qt.Fragment,{children:[(0,Nn.jsx)("div",{className:n.main,children:(0,Nn.jsx)("textarea",{placeholder:s?void 0:i("loading"),disabled:!s,className:n.textInput,ref:t,value:r,onCopy:c,onChange:p=>o(p.target.value)})}),(0,Nn.jsx)("div",{className:n.actions,children:(0,Nn.jsx)($.Button,{shortKeys:[8679,8629],onClick:u,children:i("copy")})})]})})},y1=YI;var Oa={};Pe(Oa,{enUS:()=>ZI,nlNL:()=>JI});var ZI={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},JI={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var Er=S(O());var Zg={};Pe(Zg,{enUS:()=>eL,nlNL:()=>tL});var eL={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},tL={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var v1={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};var nL={data:null,fetchState:"idle"},S1=e=>{var t;return(t=e.knowledgeAssistant)==null?void 0:t.data},Na=M("knowledgeAssistant/getKnoeledgeAssistant",async(e,t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");let i=(s=r.profile.data)==null?void 0:s.knowledgeAssistant;return i?n.getKnowledgeAssistant(i):null}),rL=z({name:"knowledgeAssistant",initialState:nL,reducers:{},extraReducers:e=>{e.addCase(Na.pending,t=>{t.fetchState="loading"}).addCase(Na.rejected,t=>{t.fetchState="error"}).addCase(Na.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),x1=rL.reducer;var Jg={data:[],fetchState:"idle"},_1=e=>{var t;return(t=e.answer)==null?void 0:t.data},w1=e=>e.answer.fetchState,Di=fe("answer/resetKnowledgeSearch"),Mi=M("answer/getAnswer",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=t.getState().answer.data,o=S1(t.getState());if(!o)throw new Error("KnowledgeAssistant is not defined");let i=await n.knowledgeAssist({promptInstruction:o.prompt,question:e},r,o.code);return{question:e,answer:i}}),oL=z({name:"answer",initialState:Jg,reducers:{},extraReducers:e=>{e.addCase(Mi.pending,t=>{t.fetchState="loading"}).addCase(Mi.rejected,t=>{t.fetchState="error"}).addCase(Mi.fulfilled,(t,n)=>{t.fetchState="done",t.data=[...t.data,n.payload]}).addCase(te,()=>Jg).addCase(Di,()=>Jg)}}),b1=oL.reducer;var Ma=S(w()),C1=()=>(0,Ma.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Ma.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Ma.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var ot=S(w()),iL=({onUse:e,onResetQuestion:t,question:n})=>{let[r,o]=Er.default.useState(""),{setSelected:i}=_r(),s=(0,Er.useRef)(null),a=k("EntitiesList",v1),l=j(Zg),u=U(),c=R(_1),p=R(w1),d=async y=>{y.preventDefault(),y.stopPropagation(),r!==""&&u(Mi(r))},g=(y,v)=>{u(Be({name:"knowledge assist source viewed",data:{question:v,sourceViewed:y.url||y.name},options:{includeConversationData:!0}}))};return(0,Er.useEffect)(()=>{var y;n&&p==="idle"?u(Mi(n)):(y=s.current)==null||y.focus()},[s,p]),(0,Er.useEffect)(()=>{p==="done"&&(u(Be({name:"knowledge assist question answered",data:{question:r||n,sources:c[c.length-1].answer.sources,answer:c[c.length-1].answer.answer,isFollowUpQuestion:c.length>1},options:{includeConversationData:!0}})),i(c.length-1),o(""))},[p,c]),(0,Er.useEffect)(()=>{s.current&&s.current.scrollIntoView({behavior:"smooth"})},[s,c]),(0,ot.jsxs)("div",{className:a.root,children:[c.length>0&&(0,ot.jsx)("div",{className:a.alignRight,children:(0,ot.jsx)($.Button,{onClick:t,children:l("reset")})}),(0,ot.jsxs)($.ActionsBar,{list:c.map(({answer:y})=>({text:y.answer,type:"answer"})),primaryLabel:l("use"),onPrimary:y=>e(y.text),children:[c.map(({question:y,answer:v},f)=>(0,ot.jsx)($.List,{children:(0,ot.jsx)($.ListItem,{"data-testid":"knowledge-search-answer",index:f,description:v.answer,closeOnSelect:!0,onClick:()=>e(v.answer),onSourceClick:h=>g(h,y),sources:v.sources,styles:{title:a.question,description:a.answer},children:y})},`${v.answer}_${f}`)),p==="loading"&&(0,ot.jsx)("p",{className:a.status,children:l("loading")}),p==="error"&&(0,ot.jsx)("p",{className:a.status,children:l("error")}),(0,ot.jsxs)("form",{className:a.form,onSubmit:d,children:[(0,ot.jsx)("input",{ref:s,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:r,onFocus:()=>{i(-1)},onChange:y=>{i(-1),o(y.target.value)}}),(0,ot.jsx)("button",{type:"submit",className:a.submit,children:(0,ot.jsx)(C1,{})})]})]})]})},E1=iL;var sL={data:null,fetchState:"idle"},Tr=e=>e.profile.data,ad=e=>e.profile.data?e.profile.data.uiConfig.widget.types.filter(t=>t.isActive):[],Da=M("profile/getProfile",async(e,t)=>{var i;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");return((i=r.profile.data)==null?void 0:i.code)===o.profileCode?r.profile.data:n.getProfile(o.profileCode)}),aL=z({name:"profile",initialState:sL,reducers:{},extraReducers:e=>{e.addCase(Da.pending,t=>{t.fetchState="loading"}).addCase(Da.rejected,t=>{t.fetchState="error"}).addCase(Da.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),T1=aL.reducer;var k1=S(O());var So=S(w()),lL=({commands:e,onClick:t,onEdit:n})=>{var c,p,d;let r=U(),o=j(Oa),i=R(Tr),s=R(br),a=((d=(p=(c=i==null?void 0:i.uiConfig)==null?void 0:c.search)==null?void 0:p.initialTypes)==null?void 0:d.filter(({isActive:g})=>g))||[],l=0,u=a.map(({type:g})=>{var y;return(y=s[g])==null?void 0:y.suggestions.map(v=>({text:v.text||v.url||v.message,type:g}))}).flat(1);return(0,k1.useEffect)(()=>{a.forEach(({type:g})=>{(!s[g]||s[g].suggestions.length===0)&&r(Vt(g))})},[]),(0,So.jsxs)($.ActionsBar,{list:[...e.map(g=>({text:g.label,type:"command"})),...u],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:g},y)=>t(g,u[y]),onSecondary:(g,y)=>{n(u[y],s[u[y].type].suggestions)},children:[e.length>0&&(0,So.jsx)($.List,{heading:o("commands"),children:e.map((g,y)=>(0,So.jsx)($.ListItem,{index:y,closeOnSelect:!1,onClick:g.onClick,children:g.label},g.label))}),a.map(({type:g,title:y})=>{var v;return(0,So.jsx)($.List,{heading:y,orientation:"vertical",children:(v=s[g])==null?void 0:v.suggestions.map(f=>(l++,(0,So.jsx)($.ListItem,{index:l+e.length-1,closeOnSelect:!1,description:f.text,onClick:()=>t(f.text,f),"data-testid":"search-overlay-suggestion",children:f.title},`${f.id}-${f.text}`)))},g)})]})},P1=lL;var _e=S(w()),uL=200,cL=5,dL=4,pL=e=>e.reduce((t,n)=>[...t,...n.list.map(r=>({...r,type:n.value}))],[]),R1=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),fL=()=>{let e=U(),t=Lt(),n=j(Oa),[r,o]=(0,Ge.useState)(!1),[i,s]=(0,Ge.useState)(""),a=R(lw),l=R(Tr),[u,c]=(0,Ge.useState)(null),[p,d]=(0,Ge.useState)([]),[g,y]=(0,Ge.useState)(),v=R(pt),f=N("showSearch"),h=N("showEntitiesCommand"),m=N("showSummaryCommand"),x=N("showKnowledgeSearch"),_=N("showImageSearch"),b=N("searchTriggerKey"),C=R(o1),E=R(uw),I=R(aw),P=L=>Eo(E.filter(J=>J.type===L.toUpperCase()),L),K=[{value:"PERSONAL",label:n("personalSuggestions"),list:P("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:n("urlSuggestions"),list:P("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:P("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:P("IMAGE"),listOrientation:"horizontal",shouldShow:_}].filter(L=>L.shouldShow),D=[{label:n("entitiesClipboard"),onClick:()=>e(qe("entities")),shouldShow:h&&R1(n("entitiesClipboard"),i)},{label:n("summaryClipboard"),onClick:()=>e(qe("summary")),shouldShow:m&&R1(n("summaryClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(qe("knowledgeAssist")),shouldShow:x}].filter(L=>L.shouldShow),B=(C==null?void 0:C.map(L=>({value:L.code.toUpperCase(),label:`${L.name}s`,list:P(L.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],be=(0,Ge.useCallback)((0,I1.default)((L,J)=>{e(go({query:L,type:J,tags:["search-overlay"]}))},uL),[]),Ar=pL([...B,...K]),Ye=(0,Ge.useCallback)((L,J)=>{e(qe("edit")),c({...L,searchTerm:void 0}),d(J)},[e,u,B]),Or=(0,Ge.useCallback)((L,J)=>{switch(J.type){case"IMAGE":t.send(Vg,{suggestion:J});break;default:t.send(An,{text:L,suggestion:J})}e($e(!1))},[e]),Wi=L=>{La(L.text),e(Be({name:"entity copied",data:{entity:L,type:"copy"}})),e($e(!1))},Nr=(0,Ge.useCallback)(L=>{e(Be({name:"suggestion feedback",data:{text:L.text,source:"search",context:i},options:{includeConversationData:!0}}))},[i]),Ga=L=>{t.send(An,{text:L,suggestion:{source:"knowledge-assist",text:L}}),e(Be({name:"answer used",data:{originalText:L},options:{includeConversationData:!0}})),s(""),e(qe("search")),e(Di()),e($e(!1))},Xa=L=>{La(L),e($e(!1))},$i=L=>{t.send(An,{text:L.text,suggestion:{source:"entity",text:L.text}}),e($e(!1))},qi=u===null||p.indexOf(u)-1<0?void 0:()=>c(p[p.indexOf(u)-1]),Mr=u===null||p.indexOf(u)===p.length-1?void 0:()=>c(p[p.indexOf(u)+1]);function Eo(L,J){return L.slice(0,g?10:J.toLowerCase()==="image"?dL:cL)}function Hd(L,J,gt){return J.reduce((cn,Un)=>gt&&g===gt?Un.length+cn:Eo(Un,gt).length+cn,L)}function Xt(L){return J=>{r?window.confirm(n("warning"))&&(L(J),o(!1)):L(J)}}return(0,Ge.useEffect)(()=>{i?be(i,g):e(Zc())},[i,g]),(0,Ge.useEffect)(()=>{a==="search"&&e(Di())},[a]),(0,Ge.useEffect)(()=>{v&&e(Ia())},[v]),a1(b,()=>e($e(!0))),!f||!l?null:(0,_e.jsxs)($,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Xt(L=>e($e(L))),onChangeType:L=>y(L),onChangePage:Xt(L=>e(qe(L))),selectedType:g,search:i,page:a,isOpen:I,types:[...B,...K],children:[(0,_e.jsxs)($.Page,{id:"search",children:[i.length===0&&(0,_e.jsx)(P1,{commands:D,onClick:Or,onEdit:Ye}),i.length>0&&(0,_e.jsxs)($.ActionsBar,{list:[...D.map(L=>({text:L.label,type:"command"})),...Ar.map(L=>({text:L.text||L.url||L.message,type:L.type}))],primaryLabel:n("use"),secondaryLabel:n("preview"),onPrimary:({text:L},J)=>Or(L,Ar[J]),onSecondary:(L,J)=>{let gt=Ar[J-D.length];!gt||!gt.type||Ye(gt,P(gt.type))},children:[D.length>0&&(0,_e.jsx)($.List,{heading:n("commands"),children:D.map((L,J)=>(0,_e.jsx)($.ListItem,{index:Hd(J,[],"commands"),closeOnSelect:!1,onClick:L.onClick,children:L.label},L.label))}),[...B,...K].map(({value:L,label:J,list:gt,lineClamp:cn,listOrientation:Un},Dh)=>(0,_e.jsx)($.List,{heading:J,orientation:Un==="horizontal"?"horizontal":"vertical",children:Eo(gt,L).map((ce,Dr)=>(0,_e.jsx)($.ListItem,{index:Hd(D.length+Dr,[...B,...K].slice(0,Dh).map(({list:MC})=>MC),L),closeOnSelect:!1,lineClamp:cn,onClick:()=>Or(ce.text,ce),description:L!=="IMAGE"?ce.title&&ce.text:void 0,onFeedback:L!=="IMAGE"?()=>Nr(ce):void 0,children:L==="IMAGE"?(0,_e.jsx)($.Image,{title:ce.title||ce.text,src:ce.image}):ce.title||ce.text},`${ce.id}-${ce.text}`))},L))]})]}),(0,_e.jsx)($.Page,{id:"edit",onDismiss:Xt(()=>{e(qe("search")),c(null)}),children:u&&(0,_e.jsx)(td,{suggestion:u,onTouched:o,onDismiss:()=>{o(!1),e(qe("search")),c(null),d([])},onNext:Mr,onPrevious:qi,onUse:L=>{e(qe("search")),Or(L,{...u,source:`${u.source||"text_recommendation"}-preview`}),e($e(!1)),d([]),c(null)}})}),(0,_e.jsx)($.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Xt(()=>{e(qe("search"))}),children:(0,_e.jsx)(d1,{onUse:$i,onCopy:Wi})}),(0,_e.jsx)($.Page,{id:"summary",title:n("summaryTitle"),onDismiss:Xt(()=>{e(qe("search"))}),children:(0,_e.jsx)(y1,{onCopy:Xa})}),(0,_e.jsx)($.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Xt(()=>{e(Di()),e(qe("search"))}),children:(0,_e.jsx)(E1,{question:i,onUse:Ga,onResetQuestion:()=>{e(Di()),s("")}})})]})},L1=fL;var Fi=S(w()),mL=()=>{let e=N("showSearch"),t=N("isEmbedded");return(0,Fi.jsxs)(A1.Fragment,{children:[e&&(0,Fi.jsx)(L1,{}),(0,Fi.jsx)(qw,{}),t&&(0,Fi.jsx)(Jw,{})]})},O1=mL;var cd=S(O());function ji(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input.userCommitted;return i.start!==i.end?!1:i.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(i.end))||r&&new RegExp(r).test(o.substring(0,i.end))?!0:n===!1&&r===!1:!1}var ld=S(O());var Hi=S(O());var N1=S(O());function M1(e,t,n){(0,N1.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var D1={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var xo=S(w()),hL=["search","personal-collection-search","search-autocomplete"];function yL(e,t,n,r={}){let o="";return hL.includes(t)?o=z_(Pg(e,n,{stripAgentPart:!0}),r.searchKeywords??[n]):o=Pg(e,n,r),r.placeholders===!0&&(o=U_(o)),o}var vL=()=>{},SL=({index:e,selected:t,suggestion:n,onFeedback:r})=>{let o=N("inlineSuggestions"),i=R(xi),s=U(),a=k("TextSuggestion",D1),l=(0,Hi.useRef)(null);(0,Hi.useEffect)(()=>{let c=setTimeout(()=>{s(t_({text:n.text,suggestion:n}))},500);return()=>{clearTimeout(c)}},[n]),M1(l,"click",()=>{s(vr(e)),s(Bt({suggestion:n,text:n.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,Hi.useMemo)(()=>yL(n.text,n.source,i,{stripAgentPart:o,placeholders:!0,searchKeywords:n.searchKeywords}),[o,n.text,n.source,i,n.searchKeywords]);return n.source==="gpt"&&!o?null:(0,xo.jsxs)("div",{className:a.root,onMouseEnter:()=>s(vr(e)),children:[(0,xo.jsx)(oe,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:vL,children:(0,xo.jsx)(En,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),t&&r&&(0,xo.jsx)("div",{className:a.actions,children:(0,xo.jsx)(Gc,{onFeedback:()=>r(n),suggestion:n.text})})]})},F1=SL;var eh=S(w()),xL=({onFeedback:e,suggestions:t,selectedIndex:n,reverse:r})=>{let o=(0,ld.useMemo)(()=>{let i=t.map((s,a)=>(0,eh.jsx)(F1,{index:a,selected:a===n,suggestion:s,onFeedback:e},`${s.text}-${s.source}`));return r?i.reverse():i},[t,n,r]);return(0,eh.jsx)(ld.Fragment,{children:o})},ud=xL;var j1={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var Fa=S(w()),_L=({textSuggestions:e,selectedIndex:t})=>{let n=(0,cd.useRef)(null),r=k("InlineSuggestionsOverlay",j1),o=R(ji),i=U(),s=R(pt),a=R(Si),l=R(od),u=N("showTextSuggestions");return Ti(()=>{i(Cr({collapse:!0,skipWhenInputFocus:!0}))}),(0,cd.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let p=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,Fa.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,Fa.jsx)("div",{ref:n,className:r.paper,children:(0,Fa.jsx)(xt,{children:(0,Fa.jsx)(ud,{suggestions:e,selectedIndex:t})})})})},wL=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),H1=xn(wL)(_L);var pd=S(q()),Bi=S(O());var B1=S(O());function z1(e,t){let[n,r]=(0,B1.useState)(()=>{if(typeof window>"u")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return H.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window<"u"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){H.error(s)}}]}var K1=S(q()),Mn=S(O());var th={};Pe(th,{enUS:()=>bL,nlNL:()=>CL});var bL={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"}]}]},CL={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 U1={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var kr=S(w()),nh=(e,t,n)=>r=>(0,kr.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),EL=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=j(th),s=Lt(),a=k("Login",U1),l=N("productName"),u=(0,Mn.useCallback)(f=>{f.preventDefault(),r&&r(parseInt(f.target.value,10))},[]),c=(0,Mn.useCallback)(f=>{f.preventDefault(),s.send(Ni,!0)},[t]),p=(0,Mn.useMemo)(()=>f=>(0,kr.jsx)("a",{onClick:m=>{m.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:f},"login"),[t]),d=(0,Mn.useCallback)(f=>(0,kr.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:f},"prompt"),[c]),{min:g,hour:y,day:v}=(0,Mn.useMemo)(()=>({min:nh(a,60*10,u),hour:nh(a,60*60,u),day:nh(a,60*60*12,u)}),[]);return(0,kr.jsxs)("div",{className:(0,K1.default)(e,a.root),children:[i("loginPlease",{login:n?d:p,productName:l}),r&&(0,kr.jsxs)(Mn.Fragment,{children:[(0,kr.jsx)("br",{}),i("snooze",{min:g,hour:y,day:v})]})]})},dd=EL;var V1={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var ja=S(w()),TL=({title:e})=>{let t=k("SearchTrigger",V1),n=U();return(0,ja.jsxs)("button",{type:"button",className:t.root,onClick:()=>n($e(!0)),children:[(0,ja.jsx)(Ii,{}),(0,ja.jsx)("span",{className:t.text,children:e})]})},W1=TL;var rh={};Pe(rh,{enUS:()=>kL,nlNL:()=>PL});var kL={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"}]},PL={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}]};var $1={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};var ue=S(w()),RL=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=k("SuggestionsOverlay",$1),o=j(rh),i=R(ji),s=Qx(),a=U(),l=(0,Bi.useRef)(null),u=N("searchTriggerKey"),c=N("productName"),p=R(od),d=R(pt),g=R(Si),[y,v]=(0,Bi.useState)(null),f=N("showSearch"),h=N("showTextSuggestions"),m=N("adminUrl"),x=N("isEmbedded"),[_,b]=z1("dd-snooze-until-ms",0),C=p||_>Date.now(),E=R(B=>B.input.text),I=e.filter(B=>B.source!=="gpt").length,P=()=>{C&&b(0),a(Nw(!C))},K=B=>{a(Be({name:"suggestion feedback",data:{text:B.text,source:"overlay",context:E},options:{includeConversationData:!0}}))},D=B=>{let be=Date.now()+B*1e3;b(be),H.info(`Snooze until: ${new Date(be)}`),a(Cr({collapse:!0}))};return(0,Bi.useEffect)(()=>{I===0&&v(null)},[e,I]),Ti(()=>{a(Cr({collapse:!0,skipWhenInputFocus:!0}))}),d===null||g===!1?null:d===!1?(0,ue.jsxs)("div",{ref:l,className:(0,pd.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,ue.jsxs)("div",{className:r.triggers,children:[(0,ue.jsx)("div",{style:{flex:1}}),(0,ue.jsx)("div",{className:r.triggersRight,children:(0,ue.jsx)(Hr,{className:r.toggleButton,title:o("collapse"),onClick:P,isCollapsed:!1})})]}),(0,ue.jsx)("div",{className:r.toggleButtonWrapper,children:(0,ue.jsx)(Hr,{className:r.toggleButton,title:o("open",{productName:c}),onClick:P,isCollapsed:!0})}),(0,ue.jsx)("div",{className:r.collapsible,children:(0,ue.jsx)(dd,{loginUrl:m,isEmbedded:x,onLogIn:n,onSnooze:D})})]}):!s||!i?null:(0,ue.jsxs)("div",{ref:l,className:(0,pd.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,ue.jsxs)("div",{className:r.triggers,children:[(0,ue.jsx)("div",{style:{flex:1},children:f&&(0,ue.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>v(o(Qc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>v(null),children:(0,ue.jsx)(W1,{title:o("search")})})}),(0,ue.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,ue.jsx)("div",{className:(0,pd.default)(!y&&r.hintsHidden,r.hints),children:y}),(0,ue.jsx)(Hr,{className:r.toggleButton,title:o("collapse"),onClick:P,isCollapsed:!1})]})]}),(0,ue.jsx)("div",{className:r.toggleButtonWrapper,children:(0,ue.jsx)(Hr,{className:r.toggleButton,title:o("open",{productName:c}),onClick:P,isCollapsed:!0})}),I>0&&h&&(0,ue.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,ue.jsx)(xt,{children:(0,ue.jsx)(ud,{onFeedback:K,suggestions:e,selectedIndex:t,reverse:!0})})})]})},IL=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),q1=xn(IL)(RL);var Ha=S(w()),LL=({children:e})=>{let n=N("locale").replace("-","");return(0,Ha.jsx)(dg.Provider,{value:n,children:e})},AL=({store:e,customStyles:t={},children:n})=>(0,Ha.jsx)($m,{store:e,children:(0,Ha.jsx)(LL,{children:(0,Ha.jsx)(Xi.Provider,{value:t,children:n})})}),_o=AL;var Ed=S(q());var jn=S(O());var G1=S(O()),OL=["div","span","mark","strong","b","i","u","em"];function oh(e,t,n=0){var i;let r=e[e.length-1],o=typeof r=="object"&&r!==null?(i=r.props)==null?void 0:i.tagName:void 0;if(o==="br")return e.pop(),[...e,...t,r];if(OL.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,G1.cloneElement)(r,{children:oh(s,t,n+1)})]}return[...e,...t]}function Pr(e){return e.tagName.toLowerCase()==="textarea"}var X1={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var ob=S(q());var _d=S(O());function Q1(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function fd(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function Y1(e){return e!=null}var sh=S(q()),At=S(O());var md=S(O()),NL=["bottom","height","left","right","top","width"],ML=(e={},t={})=>NL.some(n=>e[n]!==t[n]),Dn=new Map,Z1,J1=()=>{let e=[],t=[];Dn.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();ML(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{Dn.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),Z1=window.requestAnimationFrame(J1)};function DL(e,t){return{observe(){let n=Dn.size===0;if(Dn.has(e)){let r=Dn.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else Dn.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&J1()},unobserve(){let n=Dn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Dn.delete(e),Dn.size||cancelAnimationFrame(Z1)}}}}function ih(e){let[t,n]=(0,md.useState)(null);return(0,md.useLayoutEffect)(()=>{if(!e.current)return;let r=DL(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var zi=S(O()),tb=S(wu());var eb={root:"_root_1jq08_1"};var nb=({children:e})=>{let[t,n]=(0,zi.useState)(null),r=(0,zi.useContext)(Xi);return(0,zi.useLayoutEffect)(()=>{let o=document.createElement("div");return ao(o),o.classList.add(eb.root),r!=null&&r.portalRootNode&&o.classList.add(r==null?void 0:r.portalRootNode),document.body.appendChild(o),n(o),()=>{o.isConnected&&document.body.removeChild(o)}},[]),t?(0,tb.createPortal)(e,t):null};var ln={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};var gd=S(w()),hd=(e=!1)=>{let[t,n]=(0,At.useState)(e),r=(0,At.useCallback)(()=>n(!0),[]),o=(0,At.useCallback)(()=>n(!1),[]),i=(0,At.useCallback)(()=>n(a=>!a),[]),s=(0,At.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function ah(e,t=null,n=0){if(!e)return{display:"none"};let r=t?e.top-t.top<0||e.top<t.top-n?t.top-n:e.top+e.height>t.top+t.height+n?t.top+t.height+n-e.height:e.top:e.top,o=t?e.left<t.left-n?t.left-n:e.left+e.width>t.left+t.width+n?t.left+t.width+n-e.width:e.left:e.left;return{top:r,left:o,height:e.height,width:e.width}}var yd=({className:e,triggerRef:t,boundaryRef:n=(0,At.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=ah,...a})=>{let l=ih(t),u=ih(n),c=(0,At.useMemo)(()=>s(l,u,0),[l,u]);return(0,gd.jsx)(nb,{children:(0,gd.jsx)("div",{className:(0,sh.default)(ln.ref,{[ln.positionAbove]:r==="above",[ln.positionBelow]:r==="below",[ln.positionLeft]:r==="left",[ln.positionRight]:r==="right",[ln.alignStart]:o==="start",[ln.alignCenter]:o==="center",[ln.alignEnd]:o==="end"}),style:c,...a,role:"dialog",children:(0,gd.jsx)("div",{className:(0,sh.default)(e,ln.root),children:i})})})};var rb=S(q()),vd=S(O());var lh=S(w()),Sd=(0,vd.forwardRef)(({className:e,children:t,...n},r)=>{let o=(0,vd.useRef)(null),i=k("TabCompletion",Tn);return(0,lh.jsx)("div",{ref:fd([o,r]),className:(0,rb.default)(e,i.popoverContentContainer),...n,children:(0,lh.jsx)("div",{className:i.popoverContent,children:t})})});var Rr=S(w()),FL=e=>t=>{let n=ah(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},jL=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=k("TabCompletion",Tn),s=hd(),a=(0,_d.useMemo)(()=>FL(e.getBoundingClientRect()),[e]),[l,u]=Bc(e);return(0,_d.useEffect)(()=>{u?s.open():s.close()},[u]),(0,Rr.jsxs)("span",{children:[(0,Rr.jsx)("mark",{ref:fd([l,s.triggerRef]),className:(0,ob.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,Rr.jsx)(yd,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,Rr.jsx)(Sd,{style:n,children:(0,Rr.jsx)("div",{className:i.hintText,children:o})})})]})},xd=class extends bn{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(t,n){return n.keywordMatches&&n.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=n.keywordMatches.map(r=>({...r,keywordRegex:new RegExp(`\\b${Q1(r.keyword)}\\b`,"i")})),this.keywordMatches=n.keywordMatches),this.usedKeywordMatches.clear(),t}match(t){let n=this.preparedKeywordMatches.map(o=>{if(this.usedKeywordMatches.has(o))return null;let i=t.match(o.keywordRegex);if(!i)return null;let s=t.charAt(i.index-1),a=t.charAt(i.index+o.keyword.length);return s==="{"&&a==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:o.suggestion,preparedKeywordMatch:o,valid:!0}}).filter(Y1);if(n.length===0)return null;let r=n.reduce((o,i)=>i.index<o.index?i:o);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(t,n){return(0,Rr.jsx)(jL,{inputElement:n.inputElement,suggestion:n.suggestion,inputStyle:n.inputStyle,boundaryRef:n.boundaryRef,children:t},`keyword_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var bd=S(q());var Qe=S(O());var uh=S(w()),ib=()=>(0,uh.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,uh.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 Ir=S(O());var ab=S(Xg());var sb={root:"_root_1muu8_1",content:"_content_1muu8_7"};function wd(e,t,n){var o;let r=((o=e.imageSizes)==null?void 0:o[t])||e.image||n;if(!r)return null;try{return new URL(r).toString()}catch{return null}}function ch(e){return e.replace("https://www.","").replace("https://","")}var Ot=S(w()),HL=3,BL=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),zL=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=HL})=>{let i=k("LinkSearch",sb),[s,a]=(0,Ir.useState)(""),l=U(),u=R(nd("url")),c=R(cw("URL",BL)),[p,d]=(0,Ir.useState)(c.length-1),g=N("fallbackImage"),y=m=>{let x=m.target;a(x.value)},v=(m,x)=>{m.stopPropagation(),m.preventDefault(),window.open(x,"_blank")},f=m=>{var b;let x=p-1<0?c.length-1:p-1,_=p+1===c.length?0:p+1;m.code==="Escape"&&(a(""),t()),m.code==="ArrowUp"&&d(x),m.code==="ArrowDown"&&d(_),m.code==="Enter"&&e(((b=c[p])==null?void 0:b.text)||s)},h=(0,Ir.useCallback)((0,ab.default)(m=>{l(go({query:m,type:"URL",tags:["link-search"]}))},300),[]);return(0,Ir.useEffect)(()=>{s&&h(s)},[s]),(0,Ir.useEffect)(()=>()=>{l(Zc())},[]),(0,Ot.jsxs)("div",{className:i.root,children:[(0,Ot.jsx)(xt,{withDivider:!0,children:(s?c:u).slice(0,o).map((m,x)=>(0,Ot.jsx)(oe,{selected:p===x,onClick:()=>e(m.text),"data-testid":"linksearch-suggestion",children:(0,Ot.jsxs)(ge,{children:[(0,Ot.jsx)(ge.Image,{src:wd(m,"small",g||void 0),title:m.title||m.text}),(0,Ot.jsxs)(ge.Content,{className:i.content,cropText:!0,children:[(0,Ot.jsx)(ge.Title,{children:m.title||ch(m.text)}),m.title&&ch(m.text)]}),(0,Ot.jsx)(oe.Actions,{children:(0,Ot.jsx)(oe.ActionButton,{label:r,onClick:_=>v(_,m.text)})})]})},m.text))}),(0,Ot.jsx)(Ra,{value:s,onChange:y,autoFocus:!0,placeholder:n,onKeyUp:f})]})},lb=zL;var dh={};Pe(dh,{enUS:()=>UL,nlNL:()=>KL});var UL={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},KL={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Xe=S(w()),VL=(0,Qe.forwardRef)((e,t)=>{let n=k("TabCompletion",Tn);return(0,Xe.jsx)("mark",{ref:t,className:(0,bd.default)(n.matchSelection)},"selection-start")}),WL=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=j(dh),s=k("TabCompletion",Tn),a=(0,Qe.useRef)(null),l=(0,Qe.useRef)(null),[u,c]=(0,Qe.useState)(null),p=U(),d=hd(document.activeElement===r),[g]=(0,Qe.useState)(()=>document.createRange());d.triggerRef.current=g,(0,Qe.useEffect)(()=>()=>g.detach(),[]),(0,Qe.useEffect)(()=>{let v=e.current,f=a.current;!v||!f||(g.setStart(v,0),g.setEnd(f,0))},[e.current,a.current]),Ti(()=>{d.close()});let y=(0,Qe.useCallback)(v=>{let f=g.toString(),h=/^http(s?):\/\//.test(v)?v:`https://${v}`;p(fc({text:`[${f}](${h})`,replace:"selection"}))},[]);return(0,Xe.jsxs)("span",{children:[(0,Xe.jsx)("mark",{ref:a,className:(0,bd.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,Xe.jsx)(yd,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,Xe.jsxs)(Sd,{style:n,ref:l,children:[(0,Xe.jsx)("div",{className:(0,bd.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,Xe.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,Xe.jsx)(ib,{}),(0,Xe.jsx)("span",{children:"\xA0"}),(0,Xe.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,Xe.jsx)(lb,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:y,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},Cd=class extends bn{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(t,n){return this.props=n,this.charCount=0,this.startRef=(0,Qe.createRef)(),this.foundIndex=0,t}match(t){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[n,r]=this.props.selection;if(n===r)return null;let o=this.foundIndex===0?n:r,i=o>=this.charCount&&o<=this.charCount+t.length?{index:o-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let s=this.foundIndex===1;return i&&s?this.charCount+=o-this.charCount:this.charCount+=t.length,i?{isStart:s,...i}:null}replaceWith(t,n){return n.isStart?(0,Xe.jsx)(VL,{ref:this.startRef}):(0,Xe.jsx)(WL,{inputElement:n.inputElement,startRef:this.startRef,boundaryRef:n.boundaryRef,inputStyle:n.inputStyle})}asTag(){return"mark"}};var Fn=S(w()),$L=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=k("TabCompletion",X1),c=N("insertLink"),p=N("showMidSentenceSuggestions"),d=N("inlineSuggestions"),g=Uc(a),y=(0,jn.useRef)(null);(0,jn.useEffect)(()=>{Pr(a)&&g&&Kc(a,g)},[g]);let v=(0,jn.useCallback)(m=>{if(!o||!n)return m;let x=[(0,Fn.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,Fn.jsx)("span",{"data-testid":"tab-completion",className:(0,Ed.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&x.push((0,Fn.jsx)("span",{className:(0,Ed.default)(u.hint,u.resetIndent),children:(0,Fn.jsx)(sl,{keyCode:"tab"},"tabHint")})),oh(m,x)},[o,n,r]),f=(0,jn.useMemo)(()=>{let m=[];return c&&m.push(new Cd("selection")),m.push(new Ci("placeholders")),i&&m.push(new xd("keywords")),m},[d,c,i]),h=(0,jn.useMemo)(()=>{let m=window.getComputedStyle(a);return{"--dd-color":m.color,"--dd-font-size":m.fontSize,"--dd-font-family":m.fontFamily,"--dd-font-variant":m.fontVariant}},[]);return e?(0,Fn.jsxs)("div",{ref:m=>{m!=null&&m.parentElement&&(y.current=m==null?void 0:m.parentElement)},className:u.root,style:h,children:[(0,Fn.jsx)(En,{tagName:"span",containerTagName:"div",className:(0,Ed.default)(u.container,u.agentText),disableLineBreaks:Pr(a),content:t||"\u200B",onAfterParse:v,matchers:f,selection:g,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:y,inlineSuggestionsOnlyAtEnd:!p}),(0,Fn.jsx)("br",{})]}):null},qL=({input:e,ui:t,settings:n,styleSuggestions:r,conversation:o})=>{var v;let{tabCompletionSuggestion:i}=e,s=(i==null?void 0:i.text)||"",a=(i==null?void 0:i.source)||"",l=e.html??Pi(e.text),u=s.indexOf(e.text)===0?s.slice(e.text.length):"",{showTabHint:c}=t,{isSupported:p}=o,{showTabCompletion:d,visible:g,showStyleSuggestions:y}=n;return{showTabHint:c,showStyleSuggestions:y,showTabCompletion:d,content:l,tabText:u,source:a,keywordMatches:((v=r.list)==null?void 0:v.keywordMatches)??[],enabled:g&&p!==!1}},ub=xn(qL)($L);var Yb=S(q()),Zb=S(O());var cb={list:[],fetchState:"idle",isInitialRequest:null},pb=e=>e.autoflows.list||[],db=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},Hn=M("autoflows/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)}),ph=M("autoflows/start",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.startAutoflowSession(e),await n(Hn(e.platformSessionId))}),fh=M("autoflows/stop",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.stopAutoflowSession(e.platformSessionId),await n(Hn(e.platformSessionId))}),GL=z({name:"autoflows",initialState:cb,reducers:{},extraReducers:e=>{e.addCase(ph.pending,(t,n)=>{let r=db(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(fh.pending,(t,n)=>{let r=db(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(Hn.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}),e.addCase(Hn.rejected,t=>{t.fetchState="error"}),e.addCase(Hn.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(te,()=>cb)}}),fb=M("autoflows/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");let o=r.openStream(e);o.on("sessionAborted",()=>{n(Hn(e))}),o.on("sessionCompleted",()=>{n(Hn(e))})}),mb=M("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),gb=GL.reducer;var hb={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},yb=e=>e.customMessages.list,vb=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),Sb=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),xb=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),Ba=M("customMessages/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)}),Td=M("customMessages/send",async(e,t)=>{let{platformSessionId:n,suggestion:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.sendCustomMessage(n,r)}),kd=M("customMessages/answer",async(e,t)=>{let{platformSessionId:n,reply:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.answerCustomMessage(n,r)}),_b=z({name:"customMessages",initialState:hb,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(Ba.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(Ba.rejected,t=>{t.fetchState="error"}).addCase(Ba.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(Td.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(Td.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(kd.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(kd.rejected,(t,n)=>{let r=t.answeredSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1)),t.answeredSuggestions.splice(r,1)}).addCase(te,()=>hb)}}),wb=M("customMessages/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");r.openStream(e).on("customMessageSuggestion",i=>{n(_b.actions.onCustomMessage(i))})}),bb=M("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),Cb=_b.reducer;var XL={token:null,accountUrl:null,interval:null},Eb=e=>t=>{let{passwordlessToken:{token:n,accountUrl:r}}=t;return n&&r?`${r}/apis/admin/session/passwordless/login/?token=${n}&redirect=${e}`:null},mh=M("passwordlessToken/getTemporaryPasswordlessToken",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=await n.requestPasswordlessToken();return{accountUrl:n.client.baseUrl,token:r}}),gh=M("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(mh()),setInterval(()=>r(mh()),n)}),Tb=z({name:"passwordlessToken",initialState:XL,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(mh.fulfilled,(t,n)=>{t.token=n.payload.token,t.accountUrl=n.payload.accountUrl}),e.addCase(gh.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:kb}=Tb.actions,Pb=Tb.reducer;function Rb(e){let{customMessages:t,autoflows:n}=e;return n.fetchState==="loading"&&n.isInitialRequest===!0||t.fetchState==="loading"&&t.isInitialRequest===!0}var jb=S(O());var Mb=S(q()),Db=S(O());var Lb=S(q());var Ib={root:"_root_838fd_1"};var Ob=S(w()),QL=({className:e,children:t})=>{let n=k("Unicode",Ib);return(0,Ob.jsx)("span",{className:(0,Lb.default)(e,n.root),children:t})},Ab=QL;var Nb={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var hh={};Pe(hh,{enUS:()=>YL,nlNL:()=>ZL});var YL={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},ZL={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};var ft=S(w()),eA=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=k("Autoflow",Nb),a=j(hh),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ft.jsxs)(oe,{className:(0,Mb.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,ft.jsx)(ge,{children:(0,ft.jsxs)(ge.Content,{children:[(0,ft.jsxs)(ge.Title,{children:[t&&(0,ft.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,ft.jsx)("span",{children:r})]})}),(0,ft.jsx)(oe.Actions,{fixed:t==="Started",children:(0,ft.jsx)(oe.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,ft.jsxs)(Db.Fragment,{children:[(0,ft.jsx)(Ab,{children:u})," ",(0,ft.jsx)("span",{children:a(l)})]})})})]})},Fb=eA;var yh=S(w()),tA=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},nA=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,yh.jsx)(jb.Fragment,{children:e.map(o=>(0,yh.jsx)(Fb,{displayName:o.displayName,description:o.description,disabled:o.isBusy||tA(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),rA=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},oA={onStartAutoflow:ph,onStopAutoflow:fh},Hb=xn(rA,oA)(nA);var Pd=S(O());var xh=S(q());var vh=S(w()),Sh=()=>(0,vh.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,vh.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 Bb={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var un=S(w()),iA=({entities:e})=>{let t=k("EntitiesWidgetList",Bb),[n,r]=(0,Pd.useState)(void 0),o=U(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),La(a.text),o(Be({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Pd.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,un.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,un.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,un.jsx)("span",{className:t.entityText,children:a.text}),(0,un.jsxs)("span",{className:t.iconWrapper,children:[(0,un.jsx)("span",{className:(0,xh.default)(t.icon),children:(0,un.jsx)(Sh,{})}),(0,un.jsx)("span",{className:(0,xh.default)(t.icon,n===l&&t.iconClicked),children:(0,un.jsx)(Sh,{})})]})]},a.text))})},zb=iA;var Ub=S(q()),_h=S(O());var Bn={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};var it=S(w()),sA=({suggestion:e})=>{let t=j(fo),n=U(),r=R(vb(e.text)),o=R(Sb(e.text)),i=R(xb(e.text)),s=R(ic),{replyOptions:a}=e,l=(0,_h.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(Td({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,_h.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let p=parseInt(c.target.dataset.index,10),d=a[p];n(kd({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,it.jsxs)(oe,{onClick:l,className:(0,Ub.default)(Bn.root,{[Bn.isUsed]:r,[Bn.hasError]:i}),children:[(0,it.jsx)(ge,{children:(0,it.jsxs)(ge.Content,{children:[(0,it.jsxs)(ge.Title,{className:Bn.title,children:[e.text," ",(0,it.jsx)(al,{className:Bn.label,children:"analyse tool"})," ",i&&(0,it.jsx)("span",{className:Bn.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,it.jsx)("ul",{className:Bn.quickReplies,children:a.map(c=>(0,it.jsx)("li",{className:Bn.quickReply,children:c.title},c.title))})]})}),(0,it.jsxs)(oe.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,it.jsx)(oe.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,p)=>(0,it.jsx)(oe.DropdownItem,{index:p,label:c.title,onClick:u},c.title))}),(0,it.jsx)(oe.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},Kb=sA;var wh=S(w()),Vb=()=>(0,wh.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,wh.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 Wb=S(O());var mt=S(w()),aA=({suggestion:e,lines:t,onEdit:n,onUse:r})=>{var d;let o=e.text||e.url||e.message,i=Jc(o),s=j(fo),a=N("showImages"),l=N("fallbackImage"),u=g=>{g.preventDefault(),g.stopPropagation(),r(o)},c=g=>{g.preventDefault(),g.stopPropagation(),n(e)},p=(0,Wb.useCallback)(g=>{window.open(i,"_blank"),g.stopPropagation(),g.preventDefault()},[i]);return(0,mt.jsxs)(oe,{onClick:u,"data-testid":"edit-suggestion",children:[(0,mt.jsxs)(ge,{children:[a&&e.image&&(0,mt.jsx)(ge.Image,{src:wd(e,"small",l||void 0),title:e.title}),(0,mt.jsxs)(ge.Content,{children:[e.title&&(0,mt.jsx)(ge.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((d=e.searchKeywords)==null?void 0:d.length)>0&&(0,mt.jsx)(oe.Labels,{labels:e.searchKeywords}),(0,mt.jsx)(ge.Content,{cropText:t==="single",lineClamp:t==="multiple",children:o})]})]}),(0,mt.jsxs)(oe.Actions,{children:[i&&(0,mt.jsx)(oe.ActionButton,{onClick:p,label:s("visitUrl")}),(0,mt.jsx)(oe.ActionButton,{primary:!0,onClick:c,label:s("preview")}),(0,mt.jsx)(oe.ActionButton,{primary:!0,onClick:u,label:s("useSuggestion")})]})]})},$b=aA;var za=S(w()),lA=({contentType:e,lines:t,suggestions:n})=>{let r=Lt(),o=R(br),i=a=>{r.send(Kg,{state:o,suggestion:a,contentType:e})},s=(a,l)=>{r.send(An,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,za.jsx)(za.Fragment,{children:n.map(a=>(0,za.jsx)($b,{suggestion:a,lines:t,onEdit:l=>i(l),onUse:l=>s(l,a)},a.text||a.url||a.message))})},qb=lA;var bh={};Pe(bh,{enUS:()=>uA,nlNL:()=>cA});var uA={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},cA={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Gb={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};var Ch=S(w()),Xb=()=>(0,Ch.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ch.jsx)("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});var Eh=S(w()),Qb=()=>(0,Eh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Eh.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var V=S(w()),Rd=(e,t)=>{let n=R(pt);(0,Zb.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},dA=({onLogIn:e})=>{let t=j(bh),n=U(),r=N("isEmbedded"),o=k("Widget",Gb),i=N("showAutoflows"),s=N("showCustomMessages"),a=N("showSummaryCommand"),l=N("showKnowledgeSearch"),u=N("showSearch"),c=R(Tr),p=R(ad),d=R(pb),g=R(sd),y=R(yb),v=R(sc),f=R(Si),h=R(pt),m=R(ic),x=R(Rb),_=R(br),b=Lt(),C=R(_w),E=R(Eb("/admin/")),I=N("adminUrl"),P=N("productName");if(Rd(()=>(n(Ba(m)),n(wb(m)),()=>{n(bb(m))}),[n,f,s,m]),Rd(()=>(n(Hn(m)),n(fb(m)),()=>{n(mb(m))}),[n,f,i,m]),Rd(()=>{p.forEach(({type:D})=>{n(D==="entities"?$t():Vt(D))})},[n,f,v,c]),Rd(()=>(n(gh()),()=>{n(kb())}),[n]),f===!1)return(0,V.jsx)("div",{className:o.stateText,children:(0,V.jsx)("div",{children:(0,V.jsx)("p",{children:t("notSupported")})})},"supported");if(h===!1)return(0,V.jsx)("div",{className:o.loginText,children:(0,V.jsx)("div",{children:(0,V.jsx)(dd,{isEmbedded:r,loginUrl:I,onLogIn:e})})},"login");if(!c||!m||h===null||C||x)return(0,V.jsx)("div",{className:o.stateText,children:(0,V.jsx)("div",{children:(0,V.jsx)("p",{children:t("waiting")})})},"waiting");let K=u||a||l||E;return(0,V.jsx)("div",{className:(0,Yb.default)(o.root),"data-testid":"widget",children:(0,V.jsxs)(ll,{className:o.sectionList,children:[K&&(0,V.jsx)(Kn,{title:t("actions"),type:"shortcuts",children:(0,V.jsxs)("div",{className:o.shortcutList,children:[u&&(0,V.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-search",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0}),children:[(0,V.jsx)(Ii,{}),t("linkSearch")]}),a&&(0,V.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-summary",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,V.jsx)(Qb,{}),t("linkSummary")]}),l&&(0,V.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,V.jsx)(Xb,{}),t("linkKnowledgeSearch")]}),E&&(0,V.jsxs)("a",{className:o.shortcut,target:"_blank",href:E,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,V.jsx)(Vb,{}),t("linkStudioLogin",{productName:P})]})]})}),s&&y.length>0&&(0,V.jsx)(Kn,{type:"custom-messages","data-testid":"custom-messages",children:(0,V.jsx)(xt,{withDivider:!0,children:y.map(D=>(0,V.jsx)(Kb,{suggestion:D},D.text))})}),i&&d.length>0&&(0,V.jsx)(Kn,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,V.jsx)(xt,{withDivider:!0,children:(0,V.jsx)(Hb,{})})}),p.map(({type:D,title:B,amount:be,lines:Ar})=>{var Ye;switch(D){case"entities":return g&&g.length>0&&(0,V.jsx)(Kn,{type:D,title:B,"data-testid":`type-${D}`,children:(0,V.jsx)(zb,{entities:g})},D);default:return((Ye=_[D])==null?void 0:Ye.fetchState)==="done"&&_[D].suggestions.length>0&&(0,V.jsx)(Kn,{type:D,title:B,"data-testid":`type-${D}`,children:(0,V.jsx)(xt,{withDivider:!0,children:(0,V.jsx)(qb,{lines:Ar,contentType:D,suggestions:_[D].suggestions.slice(0,be)||[]})})},D)}})]})})},Jb=dA;function Ui(e){let t=new Range;return t.selectNodeContents(e),t}function eC(e,t,n){try{return Lr(e,t,n),!0}catch{return!1}}function Id(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Ld(e){return"tagName"in e&&e.tagName==="BR"}var Ua=/[\u200B-\u200D\uFEFF]/g;function Lr(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(l))return u;for(let d=0;d<=l.length;d++)if(p.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(Ua,""),p=o+c.length,d=t>=o&&t<=p,g=n>=o&&n<=p;if(d){let y=s(u,t-o);y===0&&!g?r.setStartBefore(l):r.setStart(l,y)}g&&(r.setEnd(l,s(u,n-o)),i=!0),o=p;break}case Node.ELEMENT_NODE:{if(Ld(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let c=0;c<l.childNodes.length&&(a(l.childNodes[c]),!i);c++);let u=l.lastChild;Id(l)&&u&&!Id(u)&&!Ld(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Ka(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(p){let d=p===n,g=p===o;switch(p.nodeType){case Node.TEXT_NODE:{let y=p.textContent;d&&(a=u+y.substring(0,r).replace(Ua,"").length),g&&(l=u+y.substring(0,i).replace(Ua,"").length),u+=y.replace(Ua,"").length;break}case Node.ELEMENT_NODE:{let y=p.nextSibling===null;Ld(p)&&!y&&u++;for(let v=0;v<p.childNodes.length;v++){let f=d&&v===r,h=g&&v===i;if(f&&(a=u),h&&(l=u),l!==void 0||((!f||!s)&&c(p.childNodes[v]),g&&v===i-1&&(l=u),l!==void 0))break}!g&&Id(p)&&!y&&u++,g&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function Va(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i}=t,s=-1,a="";function l(u){let c=u===n,p=u===o;switch(c&&s++,u.nodeType){case Node.TEXT_NODE:{if(s!==0)return;let d=c?r:0,g=p?i:void 0,y=u.textContent.replace(Ua,"");d===0&&g===void 0?a+=y:a+=y.substring(d,g);break}case Node.ELEMENT_NODE:{let d=u.nextSibling===null;s===0&&Ld(u)&&!d&&(a+=`
|
|
19
|
+
`),o=o.replace(/\n/g,"<br/>"),o}createContainer(t){var n;let o=(typeof global<"u"&&global.INTERWEAVE_SSR_POLYFILL||ER)();if(!o)return;let i=(n=this.props.containerTagName)!==null&&n!==void 0?n:"body",s=i==="body"||i==="fragment"?o.body:o.createElement(i);return t.match(wR)||(s.innerHTML=this.convertLineBreaks(this.props.escapeHtml?(0,E_.default)(t):t)),s}extractAttributes(t){let{allowAttributes:n}=this.props,r={},o=0;return t.nodeType!==C_||!t.attributes||([...t.attributes].forEach(i=>{let{name:s,value:a}=i,l=s.toLowerCase(),u=Fc[l]||Fc[s];if(!this.isSafe(t)||!l.match(bR)&&(!n&&(!u||u===yg)||l.startsWith("on")||a.replace(/(\s|\0|�([9AD]);)/,"").match(/(javascript|vbscript|livescript|xss):/i)))return;let c=l==="style"?this.extractStyleAttribute(t):a;u===Sr?c=!0:u===oo?c=Number.parseFloat(String(c)):u!==Dc&&(c=String(c)),r[vg[l]||l]=this.applyAttributeFilters(l,c),o+=1}),o===0)?null:r}extractStyleAttribute(t){let n={};return Array.from(t.style).forEach(r=>{let o=t.style[r];(typeof o=="string"||typeof o=="number")&&(n[r.replace(/-([a-z])/g,(i,s)=>String(s).toUpperCase())]=o)}),n}getTagConfig(t){let n={children:[],content:0,invalid:[],parent:[],self:!0,tagName:"",type:0,void:!1};return ha[t]?{...n,...ha[t],tagName:t}:n}isSafe(t){if(typeof HTMLAnchorElement<"u"&&t instanceof HTMLAnchorElement){let n=t.getAttribute("href");if(n!=null&&n.startsWith("#"))return!0;let r=t.protocol.toLowerCase();return r===":"||r==="http:"||r==="https:"||r==="mailto:"||r==="tel:"}return!0}isTagAllowed(t){return this.banned.has(t)||this.blocked.has(t)?!1:this.props.allowElements||this.allowed.has(t)}parse(){return this.container?this.parseNode(this.container,this.getTagConfig(this.container.nodeName.toLowerCase())):[]}parseNode(t,n){let{noHtml:r,noHtmlExceptMatchers:o,allowElements:i,transform:s,transformOnlyAllowList:a}=this.props,l=[],u="";return[...t.childNodes].forEach(c=>{if(c.nodeType===C_){let d=c.nodeName.toLowerCase(),g=this.getTagConfig(d);u&&(l.push(u),u="");let y=this.applyNodeFilters(d,c);if(!y)return;let v;if(s&&!(a&&!this.isTagAllowed(d))){this.keyIndex+=1;let f=this.keyIndex;v=this.parseNode(y,g);let h=s(y,v,g);if(h===null)return;if(typeof h<"u"){l.push(so.default.cloneElement(h,{key:f}));return}this.keyIndex=f-1}if(this.banned.has(d))return;if(!(r||o&&d!=="br")&&this.isTagAllowed(d)&&(i||this.canRenderChild(n,g))){var p;this.keyIndex+=1;let f=this.extractAttributes(y),h={tagName:d};f&&(h.attributes=f),g.void&&(h.selfClose=g.void),l.push(so.default.createElement(jc,{...h,key:this.keyIndex},(p=v)!==null&&p!==void 0?p:this.parseNode(y,g)))}else l=[...l,...this.parseNode(y,g.tagName?g:n)]}else if(c.nodeType===_R){let d=r&&!o?c.textContent:this.applyMatchers(c.textContent||"",n);Array.isArray(d)?l=[...l,...d]:u+=d}}),u&&l.push(u),l}replaceTokens(t,n){if(!t.includes("{{{"))return t;let r=[],o=t,i=null;for(;i=o.match(CR);){let[s,a]=i,l=i.index,u=s.includes("/");l>0&&(r.push(o.slice(0,l)),o=o.slice(l));let{children:c,matcher:p,props:d}=n[a],g;if(u)g=s.length,r.push(p.createElement(c,d));else{let y=o.match(new RegExp(`{{{/${a}}}}`));g=y.index+y[0].length,r.push(p.createElement(this.replaceTokens(o.slice(s.length,y.index),n),d))}o=o.slice(g)}return o.length>0&&r.push(o),r.length===0?"":r.length===1&&typeof r[0]=="string"?r[0]:r}};function TR(e){var t;let{attributes:n,className:r,containerTagName:o,content:i,emptyContent:s,parsedContent:a,tagName:l,noWrap:u}=e,c=(t=o??l)!==null&&t!==void 0?t:"span",p=c==="fragment"?!0:u,d;if(a)d=a;else{let g=new Hc(i??"",e).parse();g.length>0&&(d=g)}return d||(d=s),p?so.default.createElement(so.default.Fragment,null,d):so.default.createElement(jc,{attributes:n,className:r,tagName:c},d)}function En(e){let{attributes:t,className:n,content:r="",disableFilters:o=!1,disableMatchers:i=!1,emptyContent:s=null,filters:a=[],matchers:l=[],onAfterParse:u=null,onBeforeParse:c=null,tagName:p="span",noWrap:d=!1,...g}=e,y=i?[]:l,v=o?[]:a,f=c?[c]:[],h=u?[u]:[];y.forEach(b=>{b.onBeforeParse&&f.push(b.onBeforeParse.bind(b)),b.onAfterParse&&h.push(b.onAfterParse.bind(b))});let m=f.reduce((b,C)=>C(b,e),r??""),x=new Hc(m,g,y,v),_=h.reduce((b,C)=>C(b,e),x.parse());return so.default.createElement(TR,{attributes:t,className:n,containerTagName:e.containerTagName,emptyContent:s,noWrap:d,parsedContent:_.length===0?void 0:_,tagName:p})}var Rg=S(q());var xg={root:"_root_smoda_1",agentText:"_agentText_smoda_3",textInput:"_textInput_smoda_8",textInputWrapper:"_textInputWrapper_smoda_27",alert:"_alert_smoda_31",alertText:"_alertText_smoda_50",warning:"_warning_smoda_60",success:"_success_smoda_69"};var k_=S(q());var bi=S(O());function T_(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function Bc(e){let t=(0,bi.useRef)(null),[n,r]=(0,bi.useState)(!1);return(0,bi.useEffect)(()=>{let o=!1,i=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[s,a]=T_((c,p)=>{let d=t.current;if(!d)return;let g=c/i,y=p/i,v=d.getBoundingClientRect(),f=g>v.x&&g<v.x+v.width&&y>v.y&&y<v.y+v.height;f&&!o?(o=!0,r(!0)):!f&&o&&(o=!1,r(!1))},({clientX:c,clientY:p})=>[c,p]),[l,u]=T_(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",l),()=>{a(),u(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}var Tn={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var _g=S(w()),kR=({inputElement:e,children:t})=>{let n=k("TabCompletion",Tn),[r,o]=Bc(e);return(0,_g.jsx)("mark",{ref:r,className:(0,k_.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},Ci=class extends bn{match(t){let n=t.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(t,n){return(0,_g.jsx)(kR,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var Ei=S(O());function zc(e){return e.contentEditable==="true"}function PR(e){let t=0,n=0,r=window.getSelection();if(r.rangeCount!==0){let o=r.getRangeAt(0),i=o.cloneRange();i.selectNodeContents(e),i.setEnd(o.endContainer,o.endOffset),n=i.toString().length,i.selectNodeContents(e),i.setEnd(o.startContainer,o.startOffset),t=i.toString().length}return{selectionStart:t,selectionEnd:n}}function P_(e){let{selectionStart:t,selectionEnd:n}=zc(e)?PR(e):e;return[t,n]}function Uc(e){let[,t]=(0,Ei.useState)(),n=(0,Ei.useRef)(null);return n.current=P_(e),(0,Ei.useEffect)(()=>{let r=()=>{let[o,i]=n.current??[],s=P_(e);(!s||o!==s[0]||i!==s[1])&&(n.current=s,t({}))};return e.addEventListener("keyup",r),e.addEventListener("click",r),e.addEventListener("focus",r),document.addEventListener("selectionchange",r),()=>{e.removeEventListener("keyup",r),e.removeEventListener("click",r),e.removeEventListener("focus",r),document.removeEventListener("selectionchange",r)}},[e]),n.current}function Kc(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(Lo);if(!s||s.length===0)return;let a=0;s.find(l=>{let u=r.indexOf(l,a);return o>u&&i<u+l.length?(n.selectionStart=u,n.selectionEnd=u+l.length,!0):(a=u+l.length,!1)})}var R_=S(O());function Ti(e){(0,R_.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function ao(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}var I_,sn=new Map,RR=["bottom","height","left","right","top","width"],IR=(e={},t={})=>RR.some(n=>e[n]!==t[n]);function L_(e){var n,r;if(e.ownerDocument===document)return[];let t=((r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)??null;return t?[t,...L_(t)]:[]}function A_(e,t){return!e||!t?null:{...e,top:e.top+t.top,left:e.left+t.left}}var Vc=!1,O_=()=>{Vc=!0;let e=[];if(sn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),sn.delete(n);return}let r=n.getBoundingClientRect();IR(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(A_,t.rect):t.rect;t.callbacks.forEach(r=>r(n))}),sn.size===0){Vc=!1;return}I_=window.requestAnimationFrame(O_)};function wg(e,t){let n=L_(e),r=[],o=n.map((i,s)=>wg(i,a=>{r[s]=a;let l=sn.get(e);if(!l)return;let u=r.reduce(A_,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),sn.has(e)){let s=sn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else sn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Vc&&O_()},unobserve(){o.forEach(s=>s.unobserve());let i=sn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||sn.delete(e),sn.size||(cancelAnimationFrame(I_),Vc=!1)}}}}var N_,an=new Map,M_=()=>{an.forEach((e,t)=>{if(!t.isConnected){an.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(i=>i(e.visible)))}),an.size!==0&&(N_=window.requestAnimationFrame(M_))};function D_(e,t){return{observe(){let n=an.size===0;an.has(e)?an.get(e).callbacks.push(t):an.set(e,{visible:void 0,callbacks:[t]}),n&&M_()},unobserve(){let n=an.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||an.delete(e),an.size||cancelAnimationFrame(N_)}}}}var bg=["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 Cg(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ki(e){return parseFloat(e)}function Wc(e){return Math.round(e*1e6)}function F_(e){return e/1e6}function Eg(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=ki(e.width),i=ki(e.borderLeftWidth),s=ki(e.borderRightWidth),a=ki(e.paddingRight),l=F_(Wc(o)-Wc(i)-Wc(s)),u=F_(Wc(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function lo(e,t={}){var c;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=t.position??"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",ao(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};Cg(r,n,bg),Eg(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=D_(e,()=>{Cg(r,n,bg),Eg(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=wg(e,p=>{if(p===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),p.height===0&&p.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(Cg(r,n,bg),Eg(r,e,n),i(),n.style.top=`${p.top}px`,n.style.left=`${p.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let d=t.closestScrollElement.getBoundingClientRect(),g=window.getComputedStyle(t.closestScrollElement),y=ki(g.borderTopWidth),v=ki(g.borderBottomWidth),f=d.top+y-p.top,h=p.top+p.height+-(d.top+d.height-v);n.style.clipPath=`inset(${f}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(c=e.parentElement)==null||c.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var Tg={};Pe(Tg,{enUS:()=>LR,nlNL:()=>AR});var LR={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},AR={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};var ya=S(w()),j_=()=>(0,ya.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,ya.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,ya.jsx)("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});var kg=S(w()),H_=()=>(0,kg.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,kg.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 B_=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(B_||{}),kn=class{constructor(t){this.element=t;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}triggerChange(){let t=this.getText(),n=this.getHTML(),r=t!==this.currentText;this.isActive&&(t===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&r&&!this.isSubmitting&&this.emit("change",{plainText:t}),r&&(this.currentSelection=this.getSelection()),this.currentText=t,this.isSubmitting=!1,(this.currentHTML!==n||n===null&&r)&&(this.emit("updated",{plainText:t}),this.triggerCaretPosition(),this.currentHTML=n))}triggerSelection(){let t=this.getSelection();(t.start!==this.currentSelection.start||t.end!==this.currentSelection.end)&&(this.currentSelection=t,this.emit("selection",t),this.triggerCaretPosition())}triggerCaretPosition(){let t=this.getCaretPosition();hr(t,this.currentCaret)||(this.currentCaret=t,this.emit("caret",t))}handleKeyUp(t){let{key:n,shiftKey:r}=t;(n==="Enter"&&r===!0||n==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(B_).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.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.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};var Pn=class extends kn{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:t,selectionEnd:n}=this.element;return{start:t,end:n}}getSelectedText(){let t=this.getSelection();return t?this.getText().slice(t.start,t.end):""}getCaretPosition(){return null}applyChanges(t){if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);return Promise.resolve(r).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let t=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var o;return(o=t==null?void 0:t.get)==null?void 0:o.call(this.element)},set:o=>{var i;(i=t==null?void 0:t.set)==null||i.call(this.element,o),this.triggerChange()}});let n=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==n&&(n=this.element.disabled,this.emit(n?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};var OR=/[.*+?^${}()|[\]\\]/g,NR=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function MR(e){return e.replace(OR,"\\$&")}function DR(e,t){let n=e.split("").findIndex((r,o)=>r!==t[o]);return n>-1?n:Math.min(e.length,t.length)}function FR(e){return e.search(NR)}function z_(e,t=[]){let n=e;return t.forEach(r=>{if(!r)return;let o=new RegExp(`\\b(${MR(r)})\\b`,"gi");n=n.replace(o,"<strong>$1</strong>")}),n}function U_(e){return e.replace(Lo,'<mark data-type="placeholder">$1</mark>')}function Pi(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function jR(e,t){return e.split("").map((s,a)=>({char:s,index:a})).filter(({char:s,index:a})=>/\s/.test(s)&&a<=t).map(({index:s})=>s).reverse()[0]}function Pg(e,t,n={}){if(t){let r=DR(t.toLowerCase(),e.toLowerCase()),o=Pi(e.substring(r,e.length));if(n.stripAgentPart){let l=e.substring(0,r),u=FR(l);return`<span style="opacity: 0.5">${l.substring(u+1)}</span>${o}`}let s=t.split(Ey).length>3||t.length>30?jR(t.trim(),r):0;return`${`${s>0?"\u2026":""}${Pi(e.substring(s,r))}`}<strong>${o}</strong>`}return e}var HR=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function uo(e){return HR.test(e)}function K_(e){if(uo(e)){let n=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(e);return n?n[1]:""}return e}function V_(e){let t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}var Ue=S(w()),BR=({value:e,onUse:t,...n})=>{var p;let r=j(Tg),o=U(),i=uo(e),s=k("EditSuggestionTextInput",xg),[a,l]=(0,It.useState)(null),u=(0,It.useRef)(null),c=((p=e.match(Lo))==null?void 0:p.length)||0;return(0,It.useEffect)(()=>{let d;return u.current&&(l(u.current),d=new Pn(u.current),d.on("change",({plainText:g})=>{o(nt.actions.userInput({text:g,selection:d.getSelection()}))}),d.on("keydown",g=>{o(nt.actions.registerKeyDown(pc(g))),g.code==="Enter"&&g.shiftKey&&t(d.getText())}),d.on("paste",({pastedText:g,selectionText:y})=>{o(nt.actions.registerPaste({text:g,selectionText:y}))}),d.on("cut",({selectionText:g})=>{o(nt.actions.registerCut(g))})),()=>{o(nt.actions.reset()),d.dispose(),d.deactivate()}},[u]),(0,It.useEffect)(()=>{e&&u.current&&(u.current.value=e)},[e,u]),(0,It.useEffect)(()=>{u.current&&setTimeout(()=>{if(!u.current)return;let d=u.current.value.length;u.current.setSelectionRange(d,d),u.current.focus()},0)},[u]),i?(0,Ue.jsx)("div",{className:s.textInputWrapper,children:(0,Ue.jsx)(En,{className:s.textInput,tagName:"div",content:e})}):(0,Ue.jsxs)("div",{className:s.textInputWrapper,children:[(0,Ue.jsx)("textarea",{...n,ref:u,"data-testid":"edit-suggestion-dialog-textarea",className:s.textInput,defaultValue:e,onChange:()=>{}}),a&&(0,Ue.jsx)(zR,{inputElement:u.current,value:e}),(0,Ue.jsxs)("div",{className:(0,Rg.default)(s.alert,c===0?s.success:s.warning),children:[(0,Ue.jsx)("div",{className:s.alertText,children:r("placeholders",{placeholderSize:c})}),c===0?(0,Ue.jsx)(j_,{}):(0,Ue.jsx)(H_,{})]})]})},zR=({inputElement:e,value:t})=>{let n=k("EditSuggestionTextInput",xg),r=(0,It.useRef)(null),o=Uc(e);return(0,It.useEffect)(()=>{Kc(e,o)},[o,e]),(0,Ue.jsx)(UR,{inputElement:e,children:(0,Ue.jsxs)("div",{ref:r,className:(0,Rg.default)(n.root,n.agentText),children:[(0,Ue.jsx)(En,{tagName:"span",disableLineBreaks:!0,content:t,matchers:[new Ci("placeholders")],inputElement:e,boundaryRef:r}),(0,Ue.jsx)("br",{})]})})},UR=({inputElement:e,children:t})=>{let n=(0,It.useRef)(null);return(0,It.useEffect)(()=>{if(!n.current)return()=>{};let[r,o]=lo(e,{overlayContainer:n.current,mirrorOverflow:!0});return r.setAttribute("translate","no"),()=>{o()}},[n.current]),(0,Ue.jsx)("div",{ref:n,children:t})},W_=BR;var Li=S(O());var $_=S(O()),$c=S(q());var rt={root:"_root_1mc8f_1",list:"_list_1mc8f_2",listWrapper:"_listWrapper_1mc8f_6",listHorizontal:"_listHorizontal_1mc8f_10",page:"_page_1mc8f_19",search:"_search_1mc8f_25",pageNav:"_pageNav_1mc8f_33",pageTitle:"_pageTitle_1mc8f_41",pageBackButton:"_pageBackButton_1mc8f_48",listHeading:"_listHeading_1mc8f_62",listItem:"_listItem_1mc8f_70",listItemContent:"_listItemContent_1mc8f_79",listItemText:"_listItemText_1mc8f_97",listItemDescription:"_listItemDescription_1mc8f_105",listItemActions:"_listItemActions_1mc8f_112",truncate:"_truncate_1mc8f_123",lineClamp:"_lineClamp_1mc8f_129",listItemTitle:"_listItemTitle_1mc8f_136",listItemAction:"_listItemAction_1mc8f_112",listItemPrimaryAction:"_listItemPrimaryAction_1mc8f_157",listItemSelected:"_listItemSelected_1mc8f_162",sources:"_sources_1mc8f_166",sourcesTitle:"_sourcesTitle_1mc8f_173",source:"_source_1mc8f_166",icon:"_icon_1mc8f_188",searchIcon:"_searchIcon_1mc8f_205",searchInputWrapper:"_searchInputWrapper_1mc8f_210",searchInput:"_searchInput_1mc8f_210",select:"_select_1mc8f_231",selectType:"_selectType_1mc8f_248",selectWrapper:"_selectWrapper_1mc8f_252",image:"_image_1mc8f_282",imageSrc:"_imageSrc_1mc8f_289",imageSrcHidden:"_imageSrcHidden_1mc8f_300",imageSrcStatus:"_imageSrcStatus_1mc8f_304",imageTitle:"_imageTitle_1mc8f_314",actions:"_actions_1mc8f_319",actionsWrapper:"_actionsWrapper_1mc8f_323",actionsBar:"_actionsBar_1mc8f_329",actionButton:"_actionButton_1mc8f_338",hasShortKeys:"_hasShortKeys_1mc8f_351",actionShortcut:"_actionShortcut_1mc8f_360",actionShortcutFixKerning:"_actionShortcutFixKerning_1mc8f_367"};var co={};Pe(co,{enUS:()=>KR,nlNL:()=>VR});var KR={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},VR={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var xr=S(w()),WR=({src:e,title:t})=>{let n=k("CommandPalette",rt),[r,o]=(0,$_.useState)("loading"),i=j(co);return(0,xr.jsxs)("div",{className:n.image,children:[(0,xr.jsx)("img",{src:e,alt:t,onLoad:()=>o("done"),onError:()=>o("error"),className:(0,$c.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(r)})}),r==="loading"&&(0,xr.jsx)("span",{className:(0,$c.default)(n.imageSrc,n.imageSrcStatus),children:i("loading")}),r==="error"&&(0,xr.jsx)("span",{className:(0,$c.default)(n.imageSrc,n.imageSrcStatus),children:(0,xr.jsx)(nl,{})}),t&&(0,xr.jsx)("span",{className:n.imageTitle,children:t})]})},q_=WR;var G_=S(O()),X_=S(q());var va=S(w());function Ig({children:e,heading:t,orientation:n}){let r=k("CommandPalette",rt);return G_.default.Children.count(e)===0?null:(0,va.jsxs)("div",{"data-testid":"commandpalette-list",className:r.list,children:[t&&(0,va.jsx)("h4",{className:r.listHeading,children:t}),(0,va.jsx)("div",{className:(0,X_.default)(r.listWrapper,n==="horizontal"&&r.listHorizontal),children:e})]})}var Sa=S(q());var Ae=S(O()),Q_=S(q());var Lg={root:"_root_1oh4w_1",trigger:"_trigger_1oh4w_5",content:"_content_1oh4w_19",contentOpen:"_contentOpen_1oh4w_33",contentTop:"_contentTop_1oh4w_37",contentBottom:"_contentBottom_1oh4w_41",item:"_item_1oh4w_45"};var po=S(w()),$R=0,Y_=Ae.default.createContext(null),qR=()=>{let e=(0,Ae.useContext)(Y_);if(!e)throw new Error("Invalid DropdownContext");return e},Z_=({trigger:e,children:t,position:n="bottom"})=>{let r=(0,Ae.useMemo)(()=>++$R,[]),o=(0,Ae.useRef)(null),i=(0,Ae.useRef)(null),s=k("Dropdown",Lg),[a,l]=(0,Ae.useState)(!1),[u,c]=(0,Ae.useState)(n),p=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},d=(0,Ae.useCallback)(([g])=>{!g.isIntersecting&&a&&c(u==="top"?"bottom":"top")},[a]);return(0,Ae.useEffect)(()=>{let g=y=>{o.current&&!o.current.contains(y.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),(0,Ae.useEffect)(()=>{if(!i.current&&!a)return()=>{};let g=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return i.current&&g.observe(i.current),()=>{i.current&&g.unobserve(i.current)}},[i,a]),(0,po.jsx)(Y_.Provider,{value:{setIsOpen:l},children:(0,po.jsxs)("div",{ref:o,className:s.root,children:[(0,po.jsx)("button",{id:`dropdown-${r}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:s.trigger,onClick:p,children:e}),(0,po.jsx)("div",{"data-testid":"dropdown-content",ref:i,"aria-hidden":!a,"aria-labelledby":`dropdown-${r}`,className:(0,Q_.default)(s.content,{[s.contentOpen]:a,[s.contentTop]:u==="top",[s.contentBottom]:u==="bottom"}),children:t})]})})};function GR({as:e,children:t,onClick:n,...r}){let o=e||"button",i=k("Dropdown",Lg),{setIsOpen:s}=qR(),a=l=>{s(!1),n(l),l.stopPropagation()};return(0,po.jsx)(o,{type:"button",className:i.item,onClick:a,...r,children:t})}Z_.Item=GR;var Ag=Z_;var Og=S(w()),J_=e=>(0,Og.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...e,children:(0,Og.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={};Pe(fo,{enUS:()=>XR,nlNL:()=>QR});var XR={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"}]},QR={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 qc=S(w()),YR="%0d%0a%0d%0a%0d%0a",ZR=(e,t)=>{let n=[`Suggestie: ${encodeURIComponent(t)}`,"Beschrijf je feedback:"];return`mailto:${e.join(",")}?subject=Suggestie feedback&body=${n.join(YR)}`},JR=({suggestion:e,onFeedback:t})=>{let n=j(fo),r=N("suggestionFeedbackEmailAddresses");return!r||r.length===0?null:(0,qc.jsx)(Ag,{trigger:(0,qc.jsx)(J_,{"data-testid":"feedback-dropdown-trigger"}),children:(0,qc.jsx)(Ag.Item,{as:"a",href:ZR(r,e),onClick:t,children:n("giveFeedback")})})},Gc=JR;var Xc=S(O()),nw=S(w()),ew=Xc.default.createContext(void 0);function _r(){let e=Xc.default.useContext(ew);if(e===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return e}var tw=({children:e,page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i})=>{let s=Xc.default.useMemo(()=>({page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i}),[n,t,o]);return(0,nw.jsx)(ew.Provider,{value:s,children:e})};var dt=S(w());function Ng({closeOnSelect:e=!0,lineClamp:t,children:n,onClick:r,onFeedback:o,onSourceClick:i,index:s,description:a,sources:l,styles:u,...c}){let{selected:p,setSelected:d,onChangeOpen:g}=_r(),y=k("CommandPalette",rt);function v(f){r(f),e&&g(!1)}return(0,dt.jsxs)("div",{className:(0,Sa.default)(y.listItem,p===s&&y.listItemSelected),children:[(0,dt.jsx)("button",{onMouseEnter:()=>d(s),type:"button",className:(0,Sa.default)("command-palette-list-item",y.listItemAction,y.listItemPrimaryAction),"aria-disabled":c.disabled??!1,onClick:v,...c,children:(0,dt.jsxs)("div",{className:y.listItemContent,children:[typeof n=="string"?(0,dt.jsx)("p",{className:(0,Sa.default)(y.listItemText,y.truncate,u==null?void 0:u.title),children:n}):n,a&&(0,dt.jsx)(En,{tagName:"p",allowList:[],content:uo(a)?V_(a):a,className:(0,Sa.default)(y.listItemDescription,u==null?void 0:u.description,t?y.lineClamp:y.truncate)})]})}),o&&p===s&&(0,dt.jsx)("div",{className:y.listItemActions,children:(0,dt.jsx)(Gc,{suggestion:String(n),onFeedback:o})}),l&&(0,dt.jsxs)("div",{className:y.sources,children:[(0,dt.jsx)("span",{className:y.sourcesTitle,children:"Sources"}),l.map(f=>f.url?(0,dt.jsx)("a",{className:y.source,href:f.url,target:"_blank",title:f.url,rel:"noopener noreferrer",onClick:()=>i&&i(f),children:f.name},f.url):(0,dt.jsx)("span",{className:y.source,children:f.name},f.name))]})]})}var mo=S(w());function Mg({children:e,title:t,id:n,onDismiss:r}){let o=j(co),i=k("CommandPalette",rt),{page:s}=_r();return s!==n?null:(0,mo.jsxs)("div",{className:i.page,id:`page_${n}`,tabIndex:-1,children:[r&&(0,mo.jsxs)("div",{className:i.pageNav,children:[(0,mo.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:r,children:[(0,mo.jsx)(Ac,{}),o("back")]}),t&&(0,mo.jsx)("h3",{className:i.pageTitle,children:t})]}),e]})}var wr=S(O());var Qc=()=>/Mac/i.test(navigator.platform);var eI={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},H=eI;function tI(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function Z(e){return Array.isArray(e)?e.map(Z):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[tI(n)]:Z(e[n])}),{}):e}function Dg(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function ke(e){return Array.isArray(e)?e.map(ke):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[Dg(n)]:ke(e[n])}),{}):e}var nI={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},_a=e=>{var t,n,r;return{timezone:((t=e.info.visitorInfo)==null?void 0:t.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((n=e.info.agentInfo)==null?void 0:n.agentNickname)||"",visitorName:((r=e.info.visitorInfo)==null?void 0:r.visitorName)||""}},xa=M("info/setAgentInfo",async(e,t)=>{let{deepdeskAPI:n}=t.extra;if(!e.agentId&&!e.agentNickname)throw new Error("At least provide agentId or agentNickname");let r=await n.client.get("/apis/admin/session/me/",{version:null}),o={};return r.external_id||(o.external_id=e.agentId),r.nickname||(o.nickname=e.agentNickname),!o.external_id&&!o.nickname?Z(r):(await n.client.patch("/apis/admin/session/me/",o,{version:null}),Z(r))}),Fg=M("info/setAgentSettings",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=await n.client.get("/apis/admin/session/me/",{version:null}),o={...typeof r.ui_config=="object"?r.ui_config:{},...e};return await n.client.patch("/apis/admin/session/me/",{ui_config:o}),o}),jg=M("info/getAgentSettings",async(e,t)=>{let{deepdeskAPI:n}=t.extra;return(await n.client.get("/apis/admin/session/me/",{version:null})).ui_config}),rw=e=>e.info.agentInfo,ow=z({name:"info",initialState:nI,reducers:{setVisitorInfo(e,t){e.visitorInfo={...e.visitorInfo,...t.payload}}},extraReducers:e=>{e.addCase(xa.pending,(t,n)=>{t.fetchState="loading",t.agentInfo={...t.agentInfo,...n.meta.arg}}).addCase(xa.rejected,t=>{t.fetchState="error"}).addCase(xa.fulfilled,(t,n)=>{t.fetchState="done",t.agentInfo={...t.agentInfo,...n.meta.arg,agentId:n.payload.externalId||n.meta.arg.agentId||"",agentNickname:n.payload.nickname||n.meta.arg.agentNickname||""}}).addCase(Fg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(jg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(te,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:iw}=ow.actions,sw=ow.reducer;var Yc={list:[],fetchState:"idle",isOpen:!1,page:"search"},aw=e=>e.search.isOpen,lw=e=>e.search.page,uw=e=>e.search.list;function cw(e,t=n=>n){return n=>n.search.list.filter(r=>r.type===e).map(t)}var go=M("search/getAll",async(e,t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(s=r.conversation.current)==null?void 0:s.profileCode;if(!o)throw new Error("Profile should be provided in order to be able to search");let{results:i}=await n.search({profile:o,query:e.query,filters:{type:e.type},params:_a(r),tags:e.tags});return i.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:e.query}))}),dw=z({name:"search",initialState:Yc,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=Yc.fetchState,e.list=Yc.list}},extraReducers:e=>{e.addCase(go.pending,t=>{t.fetchState="loading"}).addCase(go.rejected,(t,n)=>{t.fetchState="error",H.error(n.error)}).addCase(go.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload}).addCase(te,()=>Yc)}}),{resetSearch:Zc,setIsOpen:$e,setPage:qe}=dw.actions,pw=dw.reducer;var rI=/(https?:\/\/[^\s]+)/,Jc=e=>e.split(" ").find(t=>rI.test(t));var Hg=S(q());var ed=S(w()),oI=({onClick:e,shortKeys:t,children:n,...r})=>{let o=k("CommandPalette",rt);return(0,ed.jsxs)("button",{type:"button",...r,onClick:e,className:(0,Hg.default)(o.actionButton,r.className,{[o.hasShortKeys]:t&&t.length>0}),children:[n,t&&t.map(i=>(0,ed.jsx)("span",{className:(0,Hg.default)(o.actionShortcut,i===8629&&o.actionShortcutFixKerning),children:typeof i=="number"?String.fromCharCode(i):i},i))]})},Ri=oI;var Rn=S(w()),iI=({children:e,primaryLabel:t,secondaryLabel:n,onPrimary:r,onSecondary:o,list:i})=>{let s=k("CommandPalette",rt),a=j(co),{selected:l,setSelected:u}=_r(),c=i[l],p=c&&typeof c.text=="string"&&Jc(c.text),d=(0,wr.useRef)(null);function g(x){if(!d.current)return;let _=d.current.querySelectorAll(".command-palette-list-item"),b=0,C=0;x==="down"?(_.forEach((I,P)=>{P===l&&(b=P)}),C=b===_.length-1?0:b+1):x==="up"?(_.forEach((I,P)=>{P===l&&(b=P)}),C=b?b-1:_.length-1):u(0);let E=_[C];E&&typeof C=="number"&&(u(C),E.scrollIntoView&&E.scrollIntoView({behavior:"smooth",block:C?"center":"end"}))}function y(){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),_=0;x.forEach((C,E)=>{E===l&&(_=E)});let b=x[_];b&&b.click()}let v=()=>{p&&window.open(p,"_blank")},f=()=>{c&&r(c,l)},h=()=>{!c.type||["IMAGE","command"].includes(c.type)||o&&o(c,l)},m=(0,wr.useCallback)(x=>{if(x.key==="Enter"&&x.altKey&&p){v();return}if(x.key==="Enter"&&x.shiftKey){h();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),g("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),g("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),y())},[l]);return(0,wr.useEffect)(()=>(window.addEventListener("keyup",m),()=>{window.removeEventListener("keyup",m)}),[m]),(0,Rn.jsxs)("div",{className:s.actions,children:[(0,Rn.jsx)("div",{className:s.actionsWrapper,ref:d,children:e}),(0,Rn.jsxs)("div",{className:s.actionsBar,children:[p&&(0,Rn.jsx)(Ri,{onClick:v,shortKeys:[Qc()?8997:"ALT",8629],children:a("visitUrl")}),c&&(0,Rn.jsxs)(wr.Fragment,{children:[o&&c.type&&!["command","image"].includes(c.type.toLowerCase())&&(0,Rn.jsx)(Ri,{onClick:h,shortKeys:[8679,8629],children:n}),(0,Rn.jsx)(Ri,{onClick:f,shortKeys:[8629],children:t})]})]})]})},mw=iI;var gw=S(O());var wa=S(w()),Ii=()=>(0,wa.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,wa.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,wa.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 Kt=S(w());function sI({onChange:e,onChangeType:t,placeholder:n,typePlaceholder:r,types:o,value:i,selectedType:s},a){let l=k("CommandPalette",rt);return(0,Kt.jsxs)("div",{className:l.search,children:[(0,Kt.jsx)("div",{className:l.searchIcon,children:(0,Kt.jsx)(Ii,{})}),(0,Kt.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Kt.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:u=>{e(u.currentTarget.value)},onFocus:u=>{u.currentTarget.select()},className:l.searchInput,placeholder:n,value:i,type:"text",id:"command-palette-search-input",autoFocus:!0}),o&&o.length>0&&(0,Kt.jsx)("div",{className:l.selectWrapper,children:(0,Kt.jsxs)("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:u=>t(u.target.value===r?void 0:u.target.value),value:s||r,children:[r&&(0,Kt.jsx)("option",{children:r}),o.map(u=>(0,Kt.jsx)("option",{value:u.value,children:u.label},u.value))]})})]})]})}var hw=(0,gw.forwardRef)(sI);var ba=S(w());function ho({placeholder:e="Start typing to search...",typePlaceholder:t="All types",defaultPage:n="search",page:r,onChangePage:o,onChangeSearch:i,onChangeType:s,onChangeOpen:a,selectedType:l,types:u,children:c,isOpen:p,search:d}){let[g,y]=(0,Li.useState)(0),v=(0,Li.useRef)(null),f=()=>{o&&o(n),s(void 0),i(""),a(!1)},h=()=>{var m;if(r!==n&&o){o(n);return}if(l&&s){s(void 0),(m=v.current)==null||m.focus();return}if(d.length>0){i("");return}a(!1)};return(0,Li.useEffect)(()=>{y(0)},[d,r]),(0,ba.jsx)(wi,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:h,onClose:f,children:(0,ba.jsxs)(tw,{selected:g,setSelected:y,isOpen:p,onChangeOpen:a,page:r,children:[r===n&&(0,ba.jsx)(hw,{ref:v,onChange:i,onChangeType:s,placeholder:e,value:d,selectedType:l,types:u,typePlaceholder:t}),c]})})}ho.Page=Mg;ho.List=Ig;ho.Image=q_;ho.ListItem=Ng;ho.ActionsBar=mw;ho.Button=Ri;var $=ho;var Ke=S(w()),aI=({suggestion:e,onUse:t,onDismiss:n,onTouched:r,onNext:o,onPrevious:i})=>{let s=e.text||e.url||e.message,a=k("EditSuggestionForm",c_),l=U(),u=j(rg),c=R(y=>y.overlayInput.text);(0,Bg.useEffect)(()=>{e&&(l(nt.actions.reset()),l(nt.actions.stageSuggestion({text:s,suggestion:e,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(nt.actions.commitSuggestion()))},[e]);let p=y=>{y.preventDefault(),d(c)},d=y=>{l(gc(y)),t(y)},g=y=>v=>{c!==s?window.confirm(u("warning"))&&y(v):y(v)};return(0,Bg.useEffect)(()=>{r&&r(c!==s)},[r,e,c]),(0,Ke.jsxs)("div",{className:a.root,children:[(0,Ke.jsxs)("div",{className:a.content,children:[e.title&&(0,Ke.jsx)("h3",{className:a.title,children:e.title}),e.searchKeywords&&e.searchKeywords.length>0&&(0,Ke.jsx)(Xd,{labels:e.searchKeywords}),(0,Ke.jsx)(W_,{onUse:d,value:K_(c)})]}),(0,Ke.jsxs)("form",{className:a.actions,onSubmit:p,children:[(0,Ke.jsxs)("div",{children:[(0,Ke.jsx)("button",{disabled:!i,className:a.pagination,type:"button",onClick:i&&g(i),children:(0,Ke.jsx)(Ac,{})}),(0,Ke.jsx)("button",{disabled:!o,className:a.pagination,type:"button",onClick:o&&g(o),children:(0,Ke.jsx)(x_,{})})]}),(0,Ke.jsxs)("div",{className:a.primaryButtons,children:[(0,Ke.jsx)($.Button,{onClick:g(n),shortKeys:["esc"],children:u("dismiss")}),(0,Ke.jsx)($.Button,{shortKeys:[8679,8629],type:"submit",children:u("add")})]})]})]})},td=aI;var lI=["{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}"],uI=new RegExp(lI.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function yw(e,t){let n=e.split(uI),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],l=i===n.length-2;r+=s.length;let u=r;if(l){let p=a.charAt(0),d=0;do u=p?t.indexOf(p,u+1):-1,d+=1;while(u!==-1&&a.indexOf(t.slice(u))!==0);if(u===-1&&d>2)return e}else u=a&&a!==""?t.indexOf(a,r):-1;let c=u===-1?t.slice(r):t.slice(r,u);o.push(c),r=u}return o.join("")}function vw(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var xw={suggestions:[],fetchState:"idle",isInitialRequest:null},Sw={default:xw},nd=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)??[]},_w=e=>{let t=Object.keys(e.textSuggestions).map(n=>{var r;return(r=e.textSuggestions[n])==null?void 0:r.fetchState});return t.length===0?!0:t.every(n=>n!=="done")},br=e=>e.textSuggestions,ww=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},rd=fe("textSuggestions/refresh"),Vt=M("textSuggestions/recommendations",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,inlineSuggestions:s}=r.settings,a=xi(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getTextSuggestions(o,_a(r),e);if(e==="default"){let c=s?l.filter(ww(a)):l;t.dispatch(on(c.slice(0,i)))}return l}),Ca=M("textSuggestions/autocompletions",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,deanonymize:s,inlineSuggestions:a}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getAutocompleteSuggestions(o,{..._a(r),input:e});if(!t.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(ww(e))),s&&(l=l.map(c=>({...c,text:c.source!=="trie-with-typos"?yw(c.text,e):c.text}))),l=vw(l,i),t.dispatch(on(l)),l}),bw=z({name:"textSuggestions",initialState:Sw,reducers:{setTextSuggestions:{reducer(e,t){let{contentType:n}=t.payload;e[n].fetchState="done",e[n].suggestions=t.payload.suggestions},prepare(e,t){return{payload:{contentType:e,suggestions:t}}}},setSuggestionState(e,t){return t.payload}},extraReducers:e=>{e.addCase(Vt.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||xw;return{...t,[r]:{...o,fetchState:"loading",isInitialRequest:o.isInitialRequest===null}}}).addCase(Vt.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(Vt.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(Ca.pending,t=>{t.default.fetchState="loading"}).addCase(Ca.rejected,t=>{t.default.fetchState="error"}).addCase(Ca.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(te,()=>Sw)}}),{setTextSuggestions:Cw,setSuggestionState:Ew}=bw.actions,Tw=bw.reducer;var kw={contentType:null,suggestion:null},Pw=e=>e.activeSuggestion.suggestion,Rw=e=>e.activeSuggestion.contentType,Iw=z({name:"activeSuggestion",initialState:kw,reducers:{setActiveSuggestion(e,t){let{contentType:n,suggestion:r}=t.payload;e.contentType=n,e.suggestion=r},resetActiveSuggestion(e){e.contentType=null,e.suggestion=null}},extraReducers:e=>{e.addCase(te,()=>kw)}}),{setActiveSuggestion:In,resetActiveSuggestion:zg}=Iw.actions,Lw=Iw.reducer;var Ug={};Pe(Ug,{enUS:()=>cI,nlNL:()=>dI});var cI={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},dI={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};var pI={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var od=({ui:e})=>e.overlayCollapsed;var Aw=z({name:"ui",initialState:pI,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputHasFocus(e,t){e.overlayCollapsedUserOverwrite!==!0&&(t.payload===!0&&(e.overlayCollapsed=!1),e.inputHasFocus=t.payload)},setOverlayCollapsed(e,t){t.payload.collapse===!1&&(e.openOverlayWhenTyping=!1),!(t.payload.skipWhenInputFocus&&e.inputHasFocus)&&(e.overlayCollapsed=t.payload.collapse)},setOpenOverlayWhenTyping(e,t){e.openOverlayWhenTyping=t.payload},setOverlayCollapsedUserOverwrite(e,t){e.overlayCollapsedUserOverwrite=t.payload,e.overlayCollapsed=t.payload}}}),{setShowTabHint:Ea,setInputHasFocus:Ai,setOverlayCollapsed:Cr,setOpenOverlayWhenTyping:Ow,setOverlayCollapsedUserOverwrite:Nw}=Aw.actions,Mw=Aw.reducer;var Ta=S(O()),Fw=S(w()),Dw=Ta.default.createContext(null),yo=({broadcastEvents:e,children:t})=>{let n=Ta.default.useMemo(()=>e,[]);return(0,Fw.jsx)(Dw.Provider,{value:n,children:t})},Lt=()=>{let e=(0,Ta.useContext)(Dw);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var fI={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},pt=e=>e.auth.isLoggedIn,jw=e=>e.auth.loginFetchState,Hw=e=>e.auth.verifyFetchState,Bw=e=>e.auth.showLoginOverlay,Ln=M("auth/validate",async(e,t)=>t.extra.deepdeskAPI.isLoggedIn()),zw=M("auth/requestLogin",async({email:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.requestLoginByEmail(e)}),ka=M("auth/verifyLoginToken",async({token:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.verifyLoginToken(e)}),Uw=z({name:"auth",initialState:fI,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload}},extraReducers:e=>{e.addCase(Ln.pending,t=>{t.loginFetchState="loading"}),e.addCase(Ln.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(Ln.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(ka.pending,t=>{t.verifyFetchState="loading"}),e.addCase(ka.rejected,t=>{t.verifyFetchState="error"}),e.addCase(ka.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:Oi,setShowLoginOverlay:Kw}=Uw.actions,Vw=Uw.reducer;var Kg="SetActiveSuggestion",Ni="ShowLoginOverlay",Pa="UserLoggedIn",mI="UserLoggedOut",An="ApplySuggestion",Vg="ApplyImageSuggestion",gI="ShowCommandPalette",hI=e=>({[Kg]:t=>{e.dispatch(Ew(t.state)),e.dispatch(In({contentType:t.contentType,suggestion:t.suggestion}))},[gI]:t=>{e.dispatch($e(t.isOpen)),t.page&&e.dispatch(qe(t.page))},[Ni]:t=>{e.dispatch(Kw(t))},[Pa]:()=>{e.dispatch(Ln())},[mI]:()=>{e.dispatch(Ln())},[Vg]:t=>{e.dispatch(yc({suggestion:t.suggestion}))},[An]:t=>{e.dispatch(Bt({...t,eventMetrics:{inputType:"mouse"},replace:"selection"})),e.dispatch(wn())}}),Ww=hI;var Wg=S(w()),yI=()=>{var y;let[e,t]=(0,$w.useState)(!1),n=R(Pw),r=R(Rw),o=R(br),i=U(),s=Lt(),a=j(Ug),l=()=>{n!==null&&e?window.confirm(a("warning"))&&u():u()},u=()=>{i(zg()),i(Ai(!0)),i(nt.actions.reset())},c=(v,f)=>{i(zg()),i(Ai(!0)),s.send(An,{text:v,suggestion:{...f,source:`${f.source||"text_recommendation"}-preview`}})};if(n===null||r===null)return null;let p=(y=o[r])==null?void 0:y.suggestions.indexOf(n),d=p===0||p===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[p-1]})),g=p===o[r].suggestions.length-1||p===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[p+1]}));return(0,Wg.jsx)(wi,{autoFocus:!0,isOpen:p!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Wg.jsx)(td,{onTouched:t,onDismiss:u,onUse:v=>c(v,n),suggestion:n,onNext:g,onPrevious:d})})},qw=yI;var id=S(q()),Wt=S(O());var Xw=S(q());var Gw={root:"_root_1ukx5_1"};var Qw=S(w()),vI=({className:e,value:t,...n})=>{let r=k("TextInput",Gw);return(0,Qw.jsx)("input",{className:(0,Xw.default)(e,r.root),type:"text",value:t,...n})},Ra=vI;var $g={};Pe($g,{enUS:()=>SI,nlNL:()=>xI});var SI={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"}]},xI={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 Yw={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};var ye=S(w());var _I=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch{return e}},wI=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=j($g),s=k("LoginTokenDialog",Yw),a=R(Hw),l=U(),u=N("productName"),[c,p]=(0,Wt.useState)(e||""),[d,g]=(0,Wt.useState)(0),[y,v]=(0,Wt.useState)(""),f=(0,Wt.useCallback)(async _=>{_.preventDefault(),l(zw({email:c})),g(1)},[n,c]),h=()=>{v(""),g(0)},m=(0,Wt.useCallback)(async _=>{_.preventDefault();let b=_I(_.target.elements.token.value);if(!b){v(i("verifyCodeError",{login:x}));return}l(ka({token:b}))},[n]),x=(0,Wt.useMemo)(()=>_=>(0,ye.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:h,children:_},"back-button"),[]);return(0,Wt.useEffect)(()=>{a==="error"&&v(i("verifyCodeError",{login:x})),a==="done"&&r()},[a]),(0,ye.jsx)(wi,{autoFocus:!0,isOpen:t,contentAriaLabel:i("promptTitle",{productName:u}),overlayAriaLabel:i("promptTitle",{productName:u}),onClose:o,onBack:o,children:(0,ye.jsxs)("div",{className:s.root,children:[(0,ye.jsx)("h1",{className:s.title,children:i("promptTitle",{productName:u})}),d===0&&(0,ye.jsxs)("form",{onSubmit:f,children:[(0,ye.jsx)("h2",{className:s.subtitle,children:i("requestCodeTitle")}),(0,ye.jsx)("p",{className:s.text,children:i("requestCodeBody",{productName:u})}),(0,ye.jsx)(Ra,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:c,onChange:_=>p(_.target.value)}),(0,ye.jsx)("div",{className:s.actions,children:(0,ye.jsx)("button",{type:"submit",className:(0,id.default)(s.button,s.primaryButton),children:i("requestCodeSubmitLabel")})})]}),d===1&&(0,ye.jsxs)("form",{onSubmit:m,children:[(0,ye.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,ye.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,ye.jsx)(Ra,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),y&&(0,ye.jsx)("div",{className:s.errorMessage,children:y}),(0,ye.jsxs)("div",{className:s.actions,children:[(0,ye.jsx)("button",{type:"button",className:(0,id.default)(s.button),onClick:h,children:i("back")}),(0,ye.jsx)("button",{type:"submit",className:(0,id.default)(s.button,s.primaryButton),disabled:["loading","done"].includes(a),children:i("verifyCodeSubmitLabel")})]})]})]})})},Zw=wI;var e1=S(w()),bI=()=>{let e=R(Bw),t=R(rw),n=N("adminUrl"),r=Lt(),o=()=>r.send(Ni,!1),i=()=>{r.send(Ni,!1),r.send(Pa)};return(0,e1.jsx)(Zw,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},Jw=bI;var I1=S(Xg()),Ge=S(O());var zI={data:null,fetchState:"idle"},o1=e=>e.contentTypes.data,Ia=M("contentTypes/getContentTypes",async(e,t)=>t.extra.deepdeskAPI.getContentTypes()),UI=z({name:"contentTypes",initialState:zI,reducers:{},extraReducers:e=>{e.addCase(Ia.pending,t=>{t.fetchState="loading"}).addCase(Ia.rejected,t=>{t.fetchState="error"}).addCase(Ia.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),i1=UI.reducer;function La(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy"),t.remove()}var s1=S(O());function a1(e,t){(0,s1.useEffect)(()=>{let n=r=>{var o;((o=navigator==null?void 0:navigator.platform)!=null&&o.toLowerCase().includes("mac")?r.metaKey:r.ctrlKey)&&r.key===e&&(r.preventDefault(),r.stopPropagation(),t())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var Aa=S(O());var l1={data:null,fetchState:"idle"},sd=e=>{var i;let t=[],{visitorName:n}=e.info.visitorInfo??{},{agentName:r,agentNickname:o}=e.info.agentInfo??{};return r&&r!==n&&t.push(r),o&&o!==n&&t.push(o),((i=e.entities.data)==null?void 0:i.filter(s=>!t.includes(s.text)))??null},$t=M("entities/getEntities",async(e,t)=>{let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra;if(!r.conversationQuery)return Promise.resolve([]);let o=r.conversationQuery,i=await o();return i.length===0?Promise.resolve([]):n.getEntities(i)}),KI=e=>e.filter((t,n)=>n===e.findIndex(r=>r.text===t.text)),VI=z({name:"entities",initialState:l1,reducers:{},extraReducers:e=>{e.addCase($t.pending,t=>{t.fetchState="loading"}).addCase($t.rejected,t=>{t.fetchState="error"}).addCase($t.fulfilled,(t,n)=>{t.fetchState="done",t.data=KI(t.data?[...t.data,...n.payload]:n.payload)}).addCase(te,()=>l1)}}),u1=VI.reducer;var Qg={};Pe(Qg,{enUS:()=>WI,nlNL:()=>$I});var WI={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},$I={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var c1={root:"_root_17kae_1",empty:"_empty_17kae_5"};var vo=S(w()),qI=({onCopy:e,onUse:t})=>{let n=(0,Aa.useRef)(null),r=k("EntitiesList",c1),o=j(Qg),i=R(sd),s=U();return(0,Aa.useEffect)(()=>{s($t())},[]),(0,Aa.useEffect)(()=>{n.current&&n.current.focus()},[n]),(0,vo.jsxs)("div",{className:r.root,ref:n,tabIndex:-1,children:[i&&i.length>0&&(0,vo.jsx)($.ActionsBar,{primaryLabel:o("copy"),secondaryLabel:o("use"),onPrimary:(a,l)=>e(i[l]),onSecondary:(a,l)=>t(i[l]),list:i.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:(0,vo.jsx)($.List,{children:i.map((a,l)=>(0,vo.jsx)($.ListItem,{index:l,closeOnSelect:!0,onClick:()=>e(a),children:a.text},a.text))},"entities")}),i&&i.length===0&&(0,vo.jsx)("p",{className:r.empty,children:o("noResults")})]})},d1=qI;var qt=S(O());var p1={data:null,fetchState:"idle"},f1=e=>e.summary.data,m1=e=>e.summary.fetchState==="error",On=M("summary/getSummary",async(e,t)=>{let n=t.getState().profile.data;if(!n)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:o}=t.extra;if(!o.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let i=o.conversationQuery,s=await i();if(s.length===0)return Promise.reject(new Error("No messages are included"));let a=await r.getSummary(s,{promptInstruction:n.summarizerPromptInstruction,model:n.summarizerModel});return a?{summary:a}:Promise.reject(new Error("Summary is not provided"))}),GI=z({name:"summary",initialState:p1,reducers:{},extraReducers:e=>{e.addCase(On.pending,t=>{t.data=null,t.fetchState="loading"}).addCase(On.rejected,t=>{t.data=null,t.fetchState="error"}).addCase(On.fulfilled,(t,n)=>{t.fetchState="done",n.payload&&(t.data=n.payload.summary)}).addCase(te,()=>p1)}}),g1=GI.reducer;var Yg={};Pe(Yg,{enUS:()=>XI,nlNL:()=>QI});var XI={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},QI={copy:[{type:0,value:"Kopieer"}],error:[{type:0,value:"Kon helaas geen samenvatting genereren."}],loading:[{type:0,value:"Samenvatting wordt gemaakt, dit kan even duren."}]};var h1={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var Nn=S(w()),YI=({onCopy:e})=>{let t=(0,qt.useRef)(null),n=k("SummaryForm",h1),[r,o]=(0,qt.useState)(""),i=j(Yg),s=R(f1),a=R(m1),l=U(),u=()=>{l(Be({name:"summary copied to clipboard",data:{originalText:s,finalText:r},options:{includeConversationData:!0}})),e(r)},c=()=>{let p=document.getSelection();p&&l(Be({name:"summary copied to clipboard",data:{originalText:s,finalText:p==null?void 0:p.toString()},options:{includeConversationData:!0}}))};return(0,qt.useEffect)(()=>{l(On())},[]),(0,qt.useEffect)(()=>{o(s||"")},[s]),(0,qt.useEffect)(()=>{t.current&&s&&t.current.focus()},[t,s]),(0,qt.useEffect)(()=>{let p=d=>{d.key==="Enter"&&d.shiftKey&&u()};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[r]),(0,Nn.jsx)("div",{className:n.root,tabIndex:-1,children:a?(0,Nn.jsx)("p",{className:n.error,children:i("error")}):(0,Nn.jsxs)(qt.Fragment,{children:[(0,Nn.jsx)("div",{className:n.main,children:(0,Nn.jsx)("textarea",{placeholder:s?void 0:i("loading"),disabled:!s,className:n.textInput,ref:t,value:r,onCopy:c,onChange:p=>o(p.target.value)})}),(0,Nn.jsx)("div",{className:n.actions,children:(0,Nn.jsx)($.Button,{shortKeys:[8679,8629],onClick:u,children:i("copy")})})]})})},y1=YI;var Oa={};Pe(Oa,{enUS:()=>ZI,nlNL:()=>JI});var ZI={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},JI={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var Er=S(O());var Zg={};Pe(Zg,{enUS:()=>eL,nlNL:()=>tL});var eL={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},tL={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var v1={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};var nL={data:null,fetchState:"idle"},S1=e=>{var t;return(t=e.knowledgeAssistant)==null?void 0:t.data},Na=M("knowledgeAssistant/getKnoeledgeAssistant",async(e,t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");let i=(s=r.profile.data)==null?void 0:s.knowledgeAssistant;return i?n.getKnowledgeAssistant(i):null}),rL=z({name:"knowledgeAssistant",initialState:nL,reducers:{},extraReducers:e=>{e.addCase(Na.pending,t=>{t.fetchState="loading"}).addCase(Na.rejected,t=>{t.fetchState="error"}).addCase(Na.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),x1=rL.reducer;var Jg={data:[],fetchState:"idle"},_1=e=>{var t;return(t=e.answer)==null?void 0:t.data},w1=e=>e.answer.fetchState,Di=fe("answer/resetKnowledgeSearch"),Mi=M("answer/getAnswer",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=t.getState().answer.data,o=S1(t.getState());if(!o)throw new Error("KnowledgeAssistant is not defined");let i=await n.knowledgeAssist({promptInstruction:o.prompt,question:e},r,o.code);return{question:e,answer:i}}),oL=z({name:"answer",initialState:Jg,reducers:{},extraReducers:e=>{e.addCase(Mi.pending,t=>{t.fetchState="loading"}).addCase(Mi.rejected,t=>{t.fetchState="error"}).addCase(Mi.fulfilled,(t,n)=>{t.fetchState="done",t.data=[...t.data,n.payload]}).addCase(te,()=>Jg).addCase(Di,()=>Jg)}}),b1=oL.reducer;var Ma=S(w()),C1=()=>(0,Ma.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Ma.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Ma.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var ot=S(w()),iL=({onUse:e,onResetQuestion:t,question:n})=>{let[r,o]=Er.default.useState(""),{setSelected:i}=_r(),s=(0,Er.useRef)(null),a=k("EntitiesList",v1),l=j(Zg),u=U(),c=R(_1),p=R(w1),d=async y=>{y.preventDefault(),y.stopPropagation(),r!==""&&u(Mi(r))},g=(y,v)=>{u(Be({name:"knowledge assist source viewed",data:{question:v,sourceViewed:y.url||y.name},options:{includeConversationData:!0}}))};return(0,Er.useEffect)(()=>{var y;n&&p==="idle"?u(Mi(n)):(y=s.current)==null||y.focus()},[s,p]),(0,Er.useEffect)(()=>{p==="done"&&(u(Be({name:"knowledge assist question answered",data:{question:r||n,sources:c[c.length-1].answer.sources,answer:c[c.length-1].answer.answer,isFollowUpQuestion:c.length>1},options:{includeConversationData:!0}})),i(c.length-1),o(""))},[p,c]),(0,Er.useEffect)(()=>{s.current&&s.current.scrollIntoView({behavior:"smooth"})},[s,c]),(0,ot.jsxs)("div",{className:a.root,children:[c.length>0&&(0,ot.jsx)("div",{className:a.alignRight,children:(0,ot.jsx)($.Button,{onClick:t,children:l("reset")})}),(0,ot.jsxs)($.ActionsBar,{list:c.map(({answer:y})=>({text:y.answer,type:"answer"})),primaryLabel:l("use"),onPrimary:y=>e(y.text),children:[c.map(({question:y,answer:v},f)=>(0,ot.jsx)($.List,{children:(0,ot.jsx)($.ListItem,{"data-testid":"knowledge-search-answer",index:f,description:v.answer,closeOnSelect:!0,onClick:()=>e(v.answer),onSourceClick:h=>g(h,y),sources:v.sources,styles:{title:a.question,description:a.answer},children:y})},`${v.answer}_${f}`)),p==="loading"&&(0,ot.jsx)("p",{className:a.status,children:l("loading")}),p==="error"&&(0,ot.jsx)("p",{className:a.status,children:l("error")}),(0,ot.jsxs)("form",{className:a.form,onSubmit:d,children:[(0,ot.jsx)("input",{ref:s,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:r,onFocus:()=>{i(-1)},onChange:y=>{i(-1),o(y.target.value)}}),(0,ot.jsx)("button",{type:"submit",className:a.submit,children:(0,ot.jsx)(C1,{})})]})]})]})},E1=iL;var sL={data:null,fetchState:"idle"},Tr=e=>e.profile.data,ad=e=>e.profile.data?e.profile.data.uiConfig.widget.types.filter(t=>t.isActive):[],Da=M("profile/getProfile",async(e,t)=>{var i;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");return((i=r.profile.data)==null?void 0:i.code)===o.profileCode?r.profile.data:n.getProfile(o.profileCode)}),aL=z({name:"profile",initialState:sL,reducers:{},extraReducers:e=>{e.addCase(Da.pending,t=>{t.fetchState="loading"}).addCase(Da.rejected,t=>{t.fetchState="error"}).addCase(Da.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),T1=aL.reducer;var k1=S(O());var So=S(w()),lL=({commands:e,onClick:t,onEdit:n})=>{var c,p,d;let r=U(),o=j(Oa),i=R(Tr),s=R(br),a=((d=(p=(c=i==null?void 0:i.uiConfig)==null?void 0:c.search)==null?void 0:p.initialTypes)==null?void 0:d.filter(({isActive:g})=>g))||[],l=0,u=a.map(({type:g})=>{var y;return(y=s[g])==null?void 0:y.suggestions.map(v=>({text:v.text||v.url||v.message,type:g}))}).flat(1);return(0,k1.useEffect)(()=>{a.forEach(({type:g})=>{(!s[g]||s[g].suggestions.length===0)&&r(Vt(g))})},[]),(0,So.jsxs)($.ActionsBar,{list:[...e.map(g=>({text:g.label,type:"command"})),...u],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:g},y)=>t(g,u[y]),onSecondary:(g,y)=>{let v=y-e.length;n(u[v],s[u[v].type].suggestions)},children:[e.length>0&&(0,So.jsx)($.List,{heading:o("commands"),children:e.map((g,y)=>(0,So.jsx)($.ListItem,{index:y,closeOnSelect:!1,onClick:g.onClick,children:g.label},g.label))}),a.map(({type:g,title:y})=>{var v;return(0,So.jsx)($.List,{heading:y,orientation:"vertical",children:(v=s[g])==null?void 0:v.suggestions.map(f=>(l++,(0,So.jsx)($.ListItem,{index:l+e.length-1,closeOnSelect:!1,description:f.text,onClick:()=>t(f.text,f),"data-testid":"search-overlay-suggestion",children:f.title},`${f.id}-${f.text}`)))},g)})]})},P1=lL;var _e=S(w()),uL=200,cL=5,dL=4,pL=e=>e.reduce((t,n)=>[...t,...n.list.map(r=>({...r,type:n.value}))],[]),R1=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),fL=()=>{let e=U(),t=Lt(),n=j(Oa),[r,o]=(0,Ge.useState)(!1),[i,s]=(0,Ge.useState)(""),a=R(lw),l=R(Tr),[u,c]=(0,Ge.useState)(null),[p,d]=(0,Ge.useState)([]),[g,y]=(0,Ge.useState)(),v=R(pt),f=N("showSearch"),h=N("showEntitiesCommand"),m=N("showSummaryCommand"),x=N("showKnowledgeSearch"),_=N("showImageSearch"),b=N("searchTriggerKey"),C=R(o1),E=R(uw),I=R(aw),P=L=>Eo(E.filter(J=>J.type===L.toUpperCase()),L),K=[{value:"PERSONAL",label:n("personalSuggestions"),list:P("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:n("urlSuggestions"),list:P("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:P("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:P("IMAGE"),listOrientation:"horizontal",shouldShow:_}].filter(L=>L.shouldShow),D=[{label:n("entitiesClipboard"),onClick:()=>e(qe("entities")),shouldShow:h&&R1(n("entitiesClipboard"),i)},{label:n("summaryClipboard"),onClick:()=>e(qe("summary")),shouldShow:m&&R1(n("summaryClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(qe("knowledgeAssist")),shouldShow:x}].filter(L=>L.shouldShow),B=(C==null?void 0:C.map(L=>({value:L.code.toUpperCase(),label:`${L.name}s`,list:P(L.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],be=(0,Ge.useCallback)((0,I1.default)((L,J)=>{e(go({query:L,type:J,tags:["search-overlay"]}))},uL),[]),Ar=pL([...B,...K]),Ye=(0,Ge.useCallback)((L,J)=>{e(qe("edit")),c({...L,searchTerm:void 0}),d(J)},[e,u,B]),Or=(0,Ge.useCallback)((L,J)=>{switch(J.type){case"IMAGE":t.send(Vg,{suggestion:J});break;default:t.send(An,{text:L,suggestion:J})}e($e(!1))},[e]),Wi=L=>{La(L.text),e(Be({name:"entity copied",data:{entity:L,type:"copy"}})),e($e(!1))},Nr=(0,Ge.useCallback)(L=>{e(Be({name:"suggestion feedback",data:{text:L.text,source:"search",context:i},options:{includeConversationData:!0}}))},[i]),Ga=L=>{t.send(An,{text:L,suggestion:{source:"knowledge-assist",text:L}}),e(Be({name:"answer used",data:{originalText:L},options:{includeConversationData:!0}})),s(""),e(qe("search")),e(Di()),e($e(!1))},Xa=L=>{La(L),e($e(!1))},$i=L=>{t.send(An,{text:L.text,suggestion:{source:"entity",text:L.text}}),e($e(!1))},qi=u===null||p.indexOf(u)-1<0?void 0:()=>c(p[p.indexOf(u)-1]),Mr=u===null||p.indexOf(u)===p.length-1?void 0:()=>c(p[p.indexOf(u)+1]);function Eo(L,J){return L.slice(0,g?10:J.toLowerCase()==="image"?dL:cL)}function Hd(L,J,gt){return J.reduce((cn,Un)=>gt&&g===gt?Un.length+cn:Eo(Un,gt).length+cn,L)}function Xt(L){return J=>{r?window.confirm(n("warning"))&&(L(J),o(!1)):L(J)}}return(0,Ge.useEffect)(()=>{i?be(i,g):e(Zc())},[i,g]),(0,Ge.useEffect)(()=>{a==="search"&&e(Di())},[a]),(0,Ge.useEffect)(()=>{v&&e(Ia())},[v]),a1(b,()=>e($e(!0))),!f||!l?null:(0,_e.jsxs)($,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Xt(L=>e($e(L))),onChangeType:L=>y(L),onChangePage:Xt(L=>e(qe(L))),selectedType:g,search:i,page:a,isOpen:I,types:[...B,...K],children:[(0,_e.jsxs)($.Page,{id:"search",children:[i.length===0&&(0,_e.jsx)(P1,{commands:D,onClick:Or,onEdit:Ye}),i.length>0&&(0,_e.jsxs)($.ActionsBar,{list:[...D.map(L=>({text:L.label,type:"command"})),...Ar.map(L=>({text:L.text||L.url||L.message,type:L.type}))],primaryLabel:n("use"),secondaryLabel:n("preview"),onPrimary:({text:L},J)=>Or(L,Ar[J]),onSecondary:(L,J)=>{let gt=Ar[J-D.length];!gt||!gt.type||Ye(gt,P(gt.type))},children:[D.length>0&&(0,_e.jsx)($.List,{heading:n("commands"),children:D.map((L,J)=>(0,_e.jsx)($.ListItem,{index:Hd(J,[],"commands"),closeOnSelect:!1,onClick:L.onClick,children:L.label},L.label))}),[...B,...K].map(({value:L,label:J,list:gt,lineClamp:cn,listOrientation:Un},Dh)=>(0,_e.jsx)($.List,{heading:J,orientation:Un==="horizontal"?"horizontal":"vertical",children:Eo(gt,L).map((ce,Dr)=>(0,_e.jsx)($.ListItem,{index:Hd(D.length+Dr,[...B,...K].slice(0,Dh).map(({list:MC})=>MC),L),closeOnSelect:!1,lineClamp:cn,onClick:()=>Or(ce.text,ce),description:L!=="IMAGE"?ce.title&&ce.text:void 0,onFeedback:L!=="IMAGE"?()=>Nr(ce):void 0,children:L==="IMAGE"?(0,_e.jsx)($.Image,{title:ce.title||ce.text,src:ce.image}):ce.title||ce.text},`${ce.id}-${ce.text}`))},L))]})]}),(0,_e.jsx)($.Page,{id:"edit",onDismiss:Xt(()=>{e(qe("search")),c(null)}),children:u&&(0,_e.jsx)(td,{suggestion:u,onTouched:o,onDismiss:()=>{o(!1),e(qe("search")),c(null),d([])},onNext:Mr,onPrevious:qi,onUse:L=>{e(qe("search")),Or(L,{...u,source:`${u.source||"text_recommendation"}-preview`}),e($e(!1)),d([]),c(null)}})}),(0,_e.jsx)($.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Xt(()=>{e(qe("search"))}),children:(0,_e.jsx)(d1,{onUse:$i,onCopy:Wi})}),(0,_e.jsx)($.Page,{id:"summary",title:n("summaryTitle"),onDismiss:Xt(()=>{e(qe("search"))}),children:(0,_e.jsx)(y1,{onCopy:Xa})}),(0,_e.jsx)($.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Xt(()=>{e(Di()),e(qe("search"))}),children:(0,_e.jsx)(E1,{question:i,onUse:Ga,onResetQuestion:()=>{e(Di()),s("")}})})]})},L1=fL;var Fi=S(w()),mL=()=>{let e=N("showSearch"),t=N("isEmbedded");return(0,Fi.jsxs)(A1.Fragment,{children:[e&&(0,Fi.jsx)(L1,{}),(0,Fi.jsx)(qw,{}),t&&(0,Fi.jsx)(Jw,{})]})},O1=mL;var cd=S(O());function ji(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input.userCommitted;return i.start!==i.end?!1:i.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(i.end))||r&&new RegExp(r).test(o.substring(0,i.end))?!0:n===!1&&r===!1:!1}var ld=S(O());var Hi=S(O());var N1=S(O());function M1(e,t,n){(0,N1.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var D1={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var xo=S(w()),hL=["search","personal-collection-search","search-autocomplete"];function yL(e,t,n,r={}){let o="";return hL.includes(t)?o=z_(Pg(e,n,{stripAgentPart:!0}),r.searchKeywords??[n]):o=Pg(e,n,r),r.placeholders===!0&&(o=U_(o)),o}var vL=()=>{},SL=({index:e,selected:t,suggestion:n,onFeedback:r})=>{let o=N("inlineSuggestions"),i=R(xi),s=U(),a=k("TextSuggestion",D1),l=(0,Hi.useRef)(null);(0,Hi.useEffect)(()=>{let c=setTimeout(()=>{s(t_({text:n.text,suggestion:n}))},500);return()=>{clearTimeout(c)}},[n]),M1(l,"click",()=>{s(vr(e)),s(Bt({suggestion:n,text:n.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,Hi.useMemo)(()=>yL(n.text,n.source,i,{stripAgentPart:o,placeholders:!0,searchKeywords:n.searchKeywords}),[o,n.text,n.source,i,n.searchKeywords]);return n.source==="gpt"&&!o?null:(0,xo.jsxs)("div",{className:a.root,onMouseEnter:()=>s(vr(e)),children:[(0,xo.jsx)(oe,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:vL,children:(0,xo.jsx)(En,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),t&&r&&(0,xo.jsx)("div",{className:a.actions,children:(0,xo.jsx)(Gc,{onFeedback:()=>r(n),suggestion:n.text})})]})},F1=SL;var eh=S(w()),xL=({onFeedback:e,suggestions:t,selectedIndex:n,reverse:r})=>{let o=(0,ld.useMemo)(()=>{let i=t.map((s,a)=>(0,eh.jsx)(F1,{index:a,selected:a===n,suggestion:s,onFeedback:e},`${s.text}-${s.source}`));return r?i.reverse():i},[t,n,r]);return(0,eh.jsx)(ld.Fragment,{children:o})},ud=xL;var j1={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var Fa=S(w()),_L=({textSuggestions:e,selectedIndex:t})=>{let n=(0,cd.useRef)(null),r=k("InlineSuggestionsOverlay",j1),o=R(ji),i=U(),s=R(pt),a=R(Si),l=R(od),u=N("showTextSuggestions");return Ti(()=>{i(Cr({collapse:!0,skipWhenInputFocus:!0}))}),(0,cd.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let p=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,Fa.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,Fa.jsx)("div",{ref:n,className:r.paper,children:(0,Fa.jsx)(xt,{children:(0,Fa.jsx)(ud,{suggestions:e,selectedIndex:t})})})})},wL=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),H1=xn(wL)(_L);var pd=S(q()),Bi=S(O());var B1=S(O());function z1(e,t){let[n,r]=(0,B1.useState)(()=>{if(typeof window>"u")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return H.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window<"u"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){H.error(s)}}]}var K1=S(q()),Mn=S(O());var th={};Pe(th,{enUS:()=>bL,nlNL:()=>CL});var bL={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"}]}]},CL={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 U1={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var kr=S(w()),nh=(e,t,n)=>r=>(0,kr.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),EL=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=j(th),s=Lt(),a=k("Login",U1),l=N("productName"),u=(0,Mn.useCallback)(f=>{f.preventDefault(),r&&r(parseInt(f.target.value,10))},[]),c=(0,Mn.useCallback)(f=>{f.preventDefault(),s.send(Ni,!0)},[t]),p=(0,Mn.useMemo)(()=>f=>(0,kr.jsx)("a",{onClick:m=>{m.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:f},"login"),[t]),d=(0,Mn.useCallback)(f=>(0,kr.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:f},"prompt"),[c]),{min:g,hour:y,day:v}=(0,Mn.useMemo)(()=>({min:nh(a,60*10,u),hour:nh(a,60*60,u),day:nh(a,60*60*12,u)}),[]);return(0,kr.jsxs)("div",{className:(0,K1.default)(e,a.root),children:[i("loginPlease",{login:n?d:p,productName:l}),r&&(0,kr.jsxs)(Mn.Fragment,{children:[(0,kr.jsx)("br",{}),i("snooze",{min:g,hour:y,day:v})]})]})},dd=EL;var V1={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var ja=S(w()),TL=({title:e})=>{let t=k("SearchTrigger",V1),n=U();return(0,ja.jsxs)("button",{type:"button",className:t.root,onClick:()=>n($e(!0)),children:[(0,ja.jsx)(Ii,{}),(0,ja.jsx)("span",{className:t.text,children:e})]})},W1=TL;var rh={};Pe(rh,{enUS:()=>kL,nlNL:()=>PL});var kL={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"}]},PL={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}]};var $1={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};var ue=S(w()),RL=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=k("SuggestionsOverlay",$1),o=j(rh),i=R(ji),s=Qx(),a=U(),l=(0,Bi.useRef)(null),u=N("searchTriggerKey"),c=N("productName"),p=R(od),d=R(pt),g=R(Si),[y,v]=(0,Bi.useState)(null),f=N("showSearch"),h=N("showTextSuggestions"),m=N("adminUrl"),x=N("isEmbedded"),[_,b]=z1("dd-snooze-until-ms",0),C=p||_>Date.now(),E=R(B=>B.input.text),I=e.filter(B=>B.source!=="gpt").length,P=()=>{C&&b(0),a(Nw(!C))},K=B=>{a(Be({name:"suggestion feedback",data:{text:B.text,source:"overlay",context:E},options:{includeConversationData:!0}}))},D=B=>{let be=Date.now()+B*1e3;b(be),H.info(`Snooze until: ${new Date(be)}`),a(Cr({collapse:!0}))};return(0,Bi.useEffect)(()=>{I===0&&v(null)},[e,I]),Ti(()=>{a(Cr({collapse:!0,skipWhenInputFocus:!0}))}),d===null||g===!1?null:d===!1?(0,ue.jsxs)("div",{ref:l,className:(0,pd.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,ue.jsxs)("div",{className:r.triggers,children:[(0,ue.jsx)("div",{style:{flex:1}}),(0,ue.jsx)("div",{className:r.triggersRight,children:(0,ue.jsx)(Hr,{className:r.toggleButton,title:o("collapse"),onClick:P,isCollapsed:!1})})]}),(0,ue.jsx)("div",{className:r.toggleButtonWrapper,children:(0,ue.jsx)(Hr,{className:r.toggleButton,title:o("open",{productName:c}),onClick:P,isCollapsed:!0})}),(0,ue.jsx)("div",{className:r.collapsible,children:(0,ue.jsx)(dd,{loginUrl:m,isEmbedded:x,onLogIn:n,onSnooze:D})})]}):!s||!i?null:(0,ue.jsxs)("div",{ref:l,className:(0,pd.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,ue.jsxs)("div",{className:r.triggers,children:[(0,ue.jsx)("div",{style:{flex:1},children:f&&(0,ue.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>v(o(Qc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>v(null),children:(0,ue.jsx)(W1,{title:o("search")})})}),(0,ue.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,ue.jsx)("div",{className:(0,pd.default)(!y&&r.hintsHidden,r.hints),children:y}),(0,ue.jsx)(Hr,{className:r.toggleButton,title:o("collapse"),onClick:P,isCollapsed:!1})]})]}),(0,ue.jsx)("div",{className:r.toggleButtonWrapper,children:(0,ue.jsx)(Hr,{className:r.toggleButton,title:o("open",{productName:c}),onClick:P,isCollapsed:!0})}),I>0&&h&&(0,ue.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,ue.jsx)(xt,{children:(0,ue.jsx)(ud,{onFeedback:K,suggestions:e,selectedIndex:t,reverse:!0})})})]})},IL=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),q1=xn(IL)(RL);var Ha=S(w()),LL=({children:e})=>{let n=N("locale").replace("-","");return(0,Ha.jsx)(dg.Provider,{value:n,children:e})},AL=({store:e,customStyles:t={},children:n})=>(0,Ha.jsx)($m,{store:e,children:(0,Ha.jsx)(LL,{children:(0,Ha.jsx)(Xi.Provider,{value:t,children:n})})}),_o=AL;var Ed=S(q());var jn=S(O());var G1=S(O()),OL=["div","span","mark","strong","b","i","u","em"];function oh(e,t,n=0){var i;let r=e[e.length-1],o=typeof r=="object"&&r!==null?(i=r.props)==null?void 0:i.tagName:void 0;if(o==="br")return e.pop(),[...e,...t,r];if(OL.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,G1.cloneElement)(r,{children:oh(s,t,n+1)})]}return[...e,...t]}function Pr(e){return e.tagName.toLowerCase()==="textarea"}var X1={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var ob=S(q());var _d=S(O());function Q1(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function fd(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function Y1(e){return e!=null}var sh=S(q()),At=S(O());var md=S(O()),NL=["bottom","height","left","right","top","width"],ML=(e={},t={})=>NL.some(n=>e[n]!==t[n]),Dn=new Map,Z1,J1=()=>{let e=[],t=[];Dn.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();ML(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{Dn.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),Z1=window.requestAnimationFrame(J1)};function DL(e,t){return{observe(){let n=Dn.size===0;if(Dn.has(e)){let r=Dn.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else Dn.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&J1()},unobserve(){let n=Dn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Dn.delete(e),Dn.size||cancelAnimationFrame(Z1)}}}}function ih(e){let[t,n]=(0,md.useState)(null);return(0,md.useLayoutEffect)(()=>{if(!e.current)return;let r=DL(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var zi=S(O()),tb=S(wu());var eb={root:"_root_1jq08_1"};var nb=({children:e})=>{let[t,n]=(0,zi.useState)(null),r=(0,zi.useContext)(Xi);return(0,zi.useLayoutEffect)(()=>{let o=document.createElement("div");return ao(o),o.classList.add(eb.root),r!=null&&r.portalRootNode&&o.classList.add(r==null?void 0:r.portalRootNode),document.body.appendChild(o),n(o),()=>{o.isConnected&&document.body.removeChild(o)}},[]),t?(0,tb.createPortal)(e,t):null};var ln={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};var gd=S(w()),hd=(e=!1)=>{let[t,n]=(0,At.useState)(e),r=(0,At.useCallback)(()=>n(!0),[]),o=(0,At.useCallback)(()=>n(!1),[]),i=(0,At.useCallback)(()=>n(a=>!a),[]),s=(0,At.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function ah(e,t=null,n=0){if(!e)return{display:"none"};let r=t?e.top-t.top<0||e.top<t.top-n?t.top-n:e.top+e.height>t.top+t.height+n?t.top+t.height+n-e.height:e.top:e.top,o=t?e.left<t.left-n?t.left-n:e.left+e.width>t.left+t.width+n?t.left+t.width+n-e.width:e.left:e.left;return{top:r,left:o,height:e.height,width:e.width}}var yd=({className:e,triggerRef:t,boundaryRef:n=(0,At.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=ah,...a})=>{let l=ih(t),u=ih(n),c=(0,At.useMemo)(()=>s(l,u,0),[l,u]);return(0,gd.jsx)(nb,{children:(0,gd.jsx)("div",{className:(0,sh.default)(ln.ref,{[ln.positionAbove]:r==="above",[ln.positionBelow]:r==="below",[ln.positionLeft]:r==="left",[ln.positionRight]:r==="right",[ln.alignStart]:o==="start",[ln.alignCenter]:o==="center",[ln.alignEnd]:o==="end"}),style:c,...a,role:"dialog",children:(0,gd.jsx)("div",{className:(0,sh.default)(e,ln.root),children:i})})})};var rb=S(q()),vd=S(O());var lh=S(w()),Sd=(0,vd.forwardRef)(({className:e,children:t,...n},r)=>{let o=(0,vd.useRef)(null),i=k("TabCompletion",Tn);return(0,lh.jsx)("div",{ref:fd([o,r]),className:(0,rb.default)(e,i.popoverContentContainer),...n,children:(0,lh.jsx)("div",{className:i.popoverContent,children:t})})});var Rr=S(w()),FL=e=>t=>{let n=ah(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},jL=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=k("TabCompletion",Tn),s=hd(),a=(0,_d.useMemo)(()=>FL(e.getBoundingClientRect()),[e]),[l,u]=Bc(e);return(0,_d.useEffect)(()=>{u?s.open():s.close()},[u]),(0,Rr.jsxs)("span",{children:[(0,Rr.jsx)("mark",{ref:fd([l,s.triggerRef]),className:(0,ob.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,Rr.jsx)(yd,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,Rr.jsx)(Sd,{style:n,children:(0,Rr.jsx)("div",{className:i.hintText,children:o})})})]})},xd=class extends bn{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(t,n){return n.keywordMatches&&n.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=n.keywordMatches.map(r=>({...r,keywordRegex:new RegExp(`\\b${Q1(r.keyword)}\\b`,"i")})),this.keywordMatches=n.keywordMatches),this.usedKeywordMatches.clear(),t}match(t){let n=this.preparedKeywordMatches.map(o=>{if(this.usedKeywordMatches.has(o))return null;let i=t.match(o.keywordRegex);if(!i)return null;let s=t.charAt(i.index-1),a=t.charAt(i.index+o.keyword.length);return s==="{"&&a==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:o.suggestion,preparedKeywordMatch:o,valid:!0}}).filter(Y1);if(n.length===0)return null;let r=n.reduce((o,i)=>i.index<o.index?i:o);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(t,n){return(0,Rr.jsx)(jL,{inputElement:n.inputElement,suggestion:n.suggestion,inputStyle:n.inputStyle,boundaryRef:n.boundaryRef,children:t},`keyword_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var bd=S(q());var Qe=S(O());var uh=S(w()),ib=()=>(0,uh.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,uh.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 Ir=S(O());var ab=S(Xg());var sb={root:"_root_1muu8_1",content:"_content_1muu8_7"};function wd(e,t,n){var o;let r=((o=e.imageSizes)==null?void 0:o[t])||e.image||n;if(!r)return null;try{return new URL(r).toString()}catch{return null}}function ch(e){return e.replace("https://www.","").replace("https://","")}var Ot=S(w()),HL=3,BL=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),zL=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=HL})=>{let i=k("LinkSearch",sb),[s,a]=(0,Ir.useState)(""),l=U(),u=R(nd("url")),c=R(cw("URL",BL)),[p,d]=(0,Ir.useState)(c.length-1),g=N("fallbackImage"),y=m=>{let x=m.target;a(x.value)},v=(m,x)=>{m.stopPropagation(),m.preventDefault(),window.open(x,"_blank")},f=m=>{var b;let x=p-1<0?c.length-1:p-1,_=p+1===c.length?0:p+1;m.code==="Escape"&&(a(""),t()),m.code==="ArrowUp"&&d(x),m.code==="ArrowDown"&&d(_),m.code==="Enter"&&e(((b=c[p])==null?void 0:b.text)||s)},h=(0,Ir.useCallback)((0,ab.default)(m=>{l(go({query:m,type:"URL",tags:["link-search"]}))},300),[]);return(0,Ir.useEffect)(()=>{s&&h(s)},[s]),(0,Ir.useEffect)(()=>()=>{l(Zc())},[]),(0,Ot.jsxs)("div",{className:i.root,children:[(0,Ot.jsx)(xt,{withDivider:!0,children:(s?c:u).slice(0,o).map((m,x)=>(0,Ot.jsx)(oe,{selected:p===x,onClick:()=>e(m.text),"data-testid":"linksearch-suggestion",children:(0,Ot.jsxs)(ge,{children:[(0,Ot.jsx)(ge.Image,{src:wd(m,"small",g||void 0),title:m.title||m.text}),(0,Ot.jsxs)(ge.Content,{className:i.content,cropText:!0,children:[(0,Ot.jsx)(ge.Title,{children:m.title||ch(m.text)}),m.title&&ch(m.text)]}),(0,Ot.jsx)(oe.Actions,{children:(0,Ot.jsx)(oe.ActionButton,{label:r,onClick:_=>v(_,m.text)})})]})},m.text))}),(0,Ot.jsx)(Ra,{value:s,onChange:y,autoFocus:!0,placeholder:n,onKeyUp:f})]})},lb=zL;var dh={};Pe(dh,{enUS:()=>UL,nlNL:()=>KL});var UL={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},KL={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Xe=S(w()),VL=(0,Qe.forwardRef)((e,t)=>{let n=k("TabCompletion",Tn);return(0,Xe.jsx)("mark",{ref:t,className:(0,bd.default)(n.matchSelection)},"selection-start")}),WL=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=j(dh),s=k("TabCompletion",Tn),a=(0,Qe.useRef)(null),l=(0,Qe.useRef)(null),[u,c]=(0,Qe.useState)(null),p=U(),d=hd(document.activeElement===r),[g]=(0,Qe.useState)(()=>document.createRange());d.triggerRef.current=g,(0,Qe.useEffect)(()=>()=>g.detach(),[]),(0,Qe.useEffect)(()=>{let v=e.current,f=a.current;!v||!f||(g.setStart(v,0),g.setEnd(f,0))},[e.current,a.current]),Ti(()=>{d.close()});let y=(0,Qe.useCallback)(v=>{let f=g.toString(),h=/^http(s?):\/\//.test(v)?v:`https://${v}`;p(fc({text:`[${f}](${h})`,replace:"selection"}))},[]);return(0,Xe.jsxs)("span",{children:[(0,Xe.jsx)("mark",{ref:a,className:(0,bd.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,Xe.jsx)(yd,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,Xe.jsxs)(Sd,{style:n,ref:l,children:[(0,Xe.jsx)("div",{className:(0,bd.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,Xe.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,Xe.jsx)(ib,{}),(0,Xe.jsx)("span",{children:"\xA0"}),(0,Xe.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,Xe.jsx)(lb,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:y,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},Cd=class extends bn{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(t,n){return this.props=n,this.charCount=0,this.startRef=(0,Qe.createRef)(),this.foundIndex=0,t}match(t){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[n,r]=this.props.selection;if(n===r)return null;let o=this.foundIndex===0?n:r,i=o>=this.charCount&&o<=this.charCount+t.length?{index:o-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let s=this.foundIndex===1;return i&&s?this.charCount+=o-this.charCount:this.charCount+=t.length,i?{isStart:s,...i}:null}replaceWith(t,n){return n.isStart?(0,Xe.jsx)(VL,{ref:this.startRef}):(0,Xe.jsx)(WL,{inputElement:n.inputElement,startRef:this.startRef,boundaryRef:n.boundaryRef,inputStyle:n.inputStyle})}asTag(){return"mark"}};var Fn=S(w()),$L=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=k("TabCompletion",X1),c=N("insertLink"),p=N("showMidSentenceSuggestions"),d=N("inlineSuggestions"),g=Uc(a),y=(0,jn.useRef)(null);(0,jn.useEffect)(()=>{Pr(a)&&g&&Kc(a,g)},[g]);let v=(0,jn.useCallback)(m=>{if(!o||!n)return m;let x=[(0,Fn.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,Fn.jsx)("span",{"data-testid":"tab-completion",className:(0,Ed.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&x.push((0,Fn.jsx)("span",{className:(0,Ed.default)(u.hint,u.resetIndent),children:(0,Fn.jsx)(sl,{keyCode:"tab"},"tabHint")})),oh(m,x)},[o,n,r]),f=(0,jn.useMemo)(()=>{let m=[];return c&&m.push(new Cd("selection")),m.push(new Ci("placeholders")),i&&m.push(new xd("keywords")),m},[d,c,i]),h=(0,jn.useMemo)(()=>{let m=window.getComputedStyle(a);return{"--dd-color":m.color,"--dd-font-size":m.fontSize,"--dd-font-family":m.fontFamily,"--dd-font-variant":m.fontVariant}},[]);return e?(0,Fn.jsxs)("div",{ref:m=>{m!=null&&m.parentElement&&(y.current=m==null?void 0:m.parentElement)},className:u.root,style:h,children:[(0,Fn.jsx)(En,{tagName:"span",containerTagName:"div",className:(0,Ed.default)(u.container,u.agentText),disableLineBreaks:Pr(a),content:t||"\u200B",onAfterParse:v,matchers:f,selection:g,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:y,inlineSuggestionsOnlyAtEnd:!p}),(0,Fn.jsx)("br",{})]}):null},qL=({input:e,ui:t,settings:n,styleSuggestions:r,conversation:o})=>{var v;let{tabCompletionSuggestion:i}=e,s=(i==null?void 0:i.text)||"",a=(i==null?void 0:i.source)||"",l=e.html??Pi(e.text),u=s.indexOf(e.text)===0?s.slice(e.text.length):"",{showTabHint:c}=t,{isSupported:p}=o,{showTabCompletion:d,visible:g,showStyleSuggestions:y}=n;return{showTabHint:c,showStyleSuggestions:y,showTabCompletion:d,content:l,tabText:u,source:a,keywordMatches:((v=r.list)==null?void 0:v.keywordMatches)??[],enabled:g&&p!==!1}},ub=xn(qL)($L);var Yb=S(q()),Zb=S(O());var cb={list:[],fetchState:"idle",isInitialRequest:null},pb=e=>e.autoflows.list||[],db=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},Hn=M("autoflows/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)}),ph=M("autoflows/start",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.startAutoflowSession(e),await n(Hn(e.platformSessionId))}),fh=M("autoflows/stop",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.stopAutoflowSession(e.platformSessionId),await n(Hn(e.platformSessionId))}),GL=z({name:"autoflows",initialState:cb,reducers:{},extraReducers:e=>{e.addCase(ph.pending,(t,n)=>{let r=db(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(fh.pending,(t,n)=>{let r=db(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(Hn.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}),e.addCase(Hn.rejected,t=>{t.fetchState="error"}),e.addCase(Hn.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(te,()=>cb)}}),fb=M("autoflows/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");let o=r.openStream(e);o.on("sessionAborted",()=>{n(Hn(e))}),o.on("sessionCompleted",()=>{n(Hn(e))})}),mb=M("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),gb=GL.reducer;var hb={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},yb=e=>e.customMessages.list,vb=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),Sb=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),xb=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),Ba=M("customMessages/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)}),Td=M("customMessages/send",async(e,t)=>{let{platformSessionId:n,suggestion:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.sendCustomMessage(n,r)}),kd=M("customMessages/answer",async(e,t)=>{let{platformSessionId:n,reply:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.answerCustomMessage(n,r)}),_b=z({name:"customMessages",initialState:hb,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(Ba.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(Ba.rejected,t=>{t.fetchState="error"}).addCase(Ba.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(Td.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(Td.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(kd.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(kd.rejected,(t,n)=>{let r=t.answeredSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1)),t.answeredSuggestions.splice(r,1)}).addCase(te,()=>hb)}}),wb=M("customMessages/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");r.openStream(e).on("customMessageSuggestion",i=>{n(_b.actions.onCustomMessage(i))})}),bb=M("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),Cb=_b.reducer;var XL={token:null,accountUrl:null,interval:null},Eb=e=>t=>{let{passwordlessToken:{token:n,accountUrl:r}}=t;return n&&r?`${r}/apis/admin/session/passwordless/login/?token=${n}&redirect=${e}`:null},mh=M("passwordlessToken/getTemporaryPasswordlessToken",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=await n.requestPasswordlessToken();return{accountUrl:n.client.baseUrl,token:r}}),gh=M("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(mh()),setInterval(()=>r(mh()),n)}),Tb=z({name:"passwordlessToken",initialState:XL,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(mh.fulfilled,(t,n)=>{t.token=n.payload.token,t.accountUrl=n.payload.accountUrl}),e.addCase(gh.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:kb}=Tb.actions,Pb=Tb.reducer;function Rb(e){let{customMessages:t,autoflows:n}=e;return n.fetchState==="loading"&&n.isInitialRequest===!0||t.fetchState==="loading"&&t.isInitialRequest===!0}var jb=S(O());var Mb=S(q()),Db=S(O());var Lb=S(q());var Ib={root:"_root_838fd_1"};var Ob=S(w()),QL=({className:e,children:t})=>{let n=k("Unicode",Ib);return(0,Ob.jsx)("span",{className:(0,Lb.default)(e,n.root),children:t})},Ab=QL;var Nb={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var hh={};Pe(hh,{enUS:()=>YL,nlNL:()=>ZL});var YL={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},ZL={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};var ft=S(w()),eA=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=k("Autoflow",Nb),a=j(hh),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ft.jsxs)(oe,{className:(0,Mb.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,ft.jsx)(ge,{children:(0,ft.jsxs)(ge.Content,{children:[(0,ft.jsxs)(ge.Title,{children:[t&&(0,ft.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,ft.jsx)("span",{children:r})]})}),(0,ft.jsx)(oe.Actions,{fixed:t==="Started",children:(0,ft.jsx)(oe.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,ft.jsxs)(Db.Fragment,{children:[(0,ft.jsx)(Ab,{children:u})," ",(0,ft.jsx)("span",{children:a(l)})]})})})]})},Fb=eA;var yh=S(w()),tA=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},nA=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,yh.jsx)(jb.Fragment,{children:e.map(o=>(0,yh.jsx)(Fb,{displayName:o.displayName,description:o.description,disabled:o.isBusy||tA(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),rA=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},oA={onStartAutoflow:ph,onStopAutoflow:fh},Hb=xn(rA,oA)(nA);var Pd=S(O());var xh=S(q());var vh=S(w()),Sh=()=>(0,vh.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,vh.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 Bb={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var un=S(w()),iA=({entities:e})=>{let t=k("EntitiesWidgetList",Bb),[n,r]=(0,Pd.useState)(void 0),o=U(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),La(a.text),o(Be({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Pd.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,un.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,un.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,un.jsx)("span",{className:t.entityText,children:a.text}),(0,un.jsxs)("span",{className:t.iconWrapper,children:[(0,un.jsx)("span",{className:(0,xh.default)(t.icon),children:(0,un.jsx)(Sh,{})}),(0,un.jsx)("span",{className:(0,xh.default)(t.icon,n===l&&t.iconClicked),children:(0,un.jsx)(Sh,{})})]})]},a.text))})},zb=iA;var Ub=S(q()),_h=S(O());var Bn={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};var it=S(w()),sA=({suggestion:e})=>{let t=j(fo),n=U(),r=R(vb(e.text)),o=R(Sb(e.text)),i=R(xb(e.text)),s=R(ic),{replyOptions:a}=e,l=(0,_h.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(Td({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,_h.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let p=parseInt(c.target.dataset.index,10),d=a[p];n(kd({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,it.jsxs)(oe,{onClick:l,className:(0,Ub.default)(Bn.root,{[Bn.isUsed]:r,[Bn.hasError]:i}),children:[(0,it.jsx)(ge,{children:(0,it.jsxs)(ge.Content,{children:[(0,it.jsxs)(ge.Title,{className:Bn.title,children:[e.text," ",(0,it.jsx)(al,{className:Bn.label,children:"analyse tool"})," ",i&&(0,it.jsx)("span",{className:Bn.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,it.jsx)("ul",{className:Bn.quickReplies,children:a.map(c=>(0,it.jsx)("li",{className:Bn.quickReply,children:c.title},c.title))})]})}),(0,it.jsxs)(oe.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,it.jsx)(oe.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,p)=>(0,it.jsx)(oe.DropdownItem,{index:p,label:c.title,onClick:u},c.title))}),(0,it.jsx)(oe.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},Kb=sA;var wh=S(w()),Vb=()=>(0,wh.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,wh.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 Wb=S(O());var mt=S(w()),aA=({suggestion:e,lines:t,onEdit:n,onUse:r})=>{var d;let o=e.text||e.url||e.message,i=Jc(o),s=j(fo),a=N("showImages"),l=N("fallbackImage"),u=g=>{g.preventDefault(),g.stopPropagation(),r(o)},c=g=>{g.preventDefault(),g.stopPropagation(),n(e)},p=(0,Wb.useCallback)(g=>{window.open(i,"_blank"),g.stopPropagation(),g.preventDefault()},[i]);return(0,mt.jsxs)(oe,{onClick:u,"data-testid":"edit-suggestion",children:[(0,mt.jsxs)(ge,{children:[a&&e.image&&(0,mt.jsx)(ge.Image,{src:wd(e,"small",l||void 0),title:e.title}),(0,mt.jsxs)(ge.Content,{children:[e.title&&(0,mt.jsx)(ge.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((d=e.searchKeywords)==null?void 0:d.length)>0&&(0,mt.jsx)(oe.Labels,{labels:e.searchKeywords}),(0,mt.jsx)(ge.Content,{cropText:t==="single",lineClamp:t==="multiple",children:o})]})]}),(0,mt.jsxs)(oe.Actions,{children:[i&&(0,mt.jsx)(oe.ActionButton,{onClick:p,label:s("visitUrl")}),(0,mt.jsx)(oe.ActionButton,{primary:!0,onClick:c,label:s("preview")}),(0,mt.jsx)(oe.ActionButton,{primary:!0,onClick:u,label:s("useSuggestion")})]})]})},$b=aA;var za=S(w()),lA=({contentType:e,lines:t,suggestions:n})=>{let r=Lt(),o=R(br),i=a=>{r.send(Kg,{state:o,suggestion:a,contentType:e})},s=(a,l)=>{r.send(An,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,za.jsx)(za.Fragment,{children:n.map(a=>(0,za.jsx)($b,{suggestion:a,lines:t,onEdit:l=>i(l),onUse:l=>s(l,a)},a.text||a.url||a.message))})},qb=lA;var bh={};Pe(bh,{enUS:()=>uA,nlNL:()=>cA});var uA={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},cA={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Gb={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};var Ch=S(w()),Xb=()=>(0,Ch.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ch.jsx)("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});var Eh=S(w()),Qb=()=>(0,Eh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Eh.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var V=S(w()),Rd=(e,t)=>{let n=R(pt);(0,Zb.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},dA=({onLogIn:e})=>{let t=j(bh),n=U(),r=N("isEmbedded"),o=k("Widget",Gb),i=N("showAutoflows"),s=N("showCustomMessages"),a=N("showSummaryCommand"),l=N("showKnowledgeSearch"),u=N("showSearch"),c=R(Tr),p=R(ad),d=R(pb),g=R(sd),y=R(yb),v=R(sc),f=R(Si),h=R(pt),m=R(ic),x=R(Rb),_=R(br),b=Lt(),C=R(_w),E=R(Eb("/admin/")),I=N("adminUrl"),P=N("productName");if(Rd(()=>(n(Ba(m)),n(wb(m)),()=>{n(bb(m))}),[n,f,s,m]),Rd(()=>(n(Hn(m)),n(fb(m)),()=>{n(mb(m))}),[n,f,i,m]),Rd(()=>{p.forEach(({type:D})=>{n(D==="entities"?$t():Vt(D))})},[n,f,v,c]),Rd(()=>(n(gh()),()=>{n(kb())}),[n]),f===!1)return(0,V.jsx)("div",{className:o.stateText,children:(0,V.jsx)("div",{children:(0,V.jsx)("p",{children:t("notSupported")})})},"supported");if(h===!1)return(0,V.jsx)("div",{className:o.loginText,children:(0,V.jsx)("div",{children:(0,V.jsx)(dd,{isEmbedded:r,loginUrl:I,onLogIn:e})})},"login");if(!c||!m||h===null||C||x)return(0,V.jsx)("div",{className:o.stateText,children:(0,V.jsx)("div",{children:(0,V.jsx)("p",{children:t("waiting")})})},"waiting");let K=u||a||l||E;return(0,V.jsx)("div",{className:(0,Yb.default)(o.root),"data-testid":"widget",children:(0,V.jsxs)(ll,{className:o.sectionList,children:[K&&(0,V.jsx)(Kn,{title:t("actions"),type:"shortcuts",children:(0,V.jsxs)("div",{className:o.shortcutList,children:[u&&(0,V.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-search",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0}),children:[(0,V.jsx)(Ii,{}),t("linkSearch")]}),a&&(0,V.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-summary",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,V.jsx)(Qb,{}),t("linkSummary")]}),l&&(0,V.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,V.jsx)(Xb,{}),t("linkKnowledgeSearch")]}),E&&(0,V.jsxs)("a",{className:o.shortcut,target:"_blank",href:E,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,V.jsx)(Vb,{}),t("linkStudioLogin",{productName:P})]})]})}),s&&y.length>0&&(0,V.jsx)(Kn,{type:"custom-messages","data-testid":"custom-messages",children:(0,V.jsx)(xt,{withDivider:!0,children:y.map(D=>(0,V.jsx)(Kb,{suggestion:D},D.text))})}),i&&d.length>0&&(0,V.jsx)(Kn,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,V.jsx)(xt,{withDivider:!0,children:(0,V.jsx)(Hb,{})})}),p.map(({type:D,title:B,amount:be,lines:Ar})=>{var Ye;switch(D){case"entities":return g&&g.length>0&&(0,V.jsx)(Kn,{type:D,title:B,"data-testid":`type-${D}`,children:(0,V.jsx)(zb,{entities:g})},D);default:return((Ye=_[D])==null?void 0:Ye.fetchState)==="done"&&_[D].suggestions.length>0&&(0,V.jsx)(Kn,{type:D,title:B,"data-testid":`type-${D}`,children:(0,V.jsx)(xt,{withDivider:!0,children:(0,V.jsx)(qb,{lines:Ar,contentType:D,suggestions:_[D].suggestions.slice(0,be)||[]})})},D)}})]})})},Jb=dA;function Ui(e){let t=new Range;return t.selectNodeContents(e),t}function eC(e,t,n){try{return Lr(e,t,n),!0}catch{return!1}}function Id(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Ld(e){return"tagName"in e&&e.tagName==="BR"}var Ua=/[\u200B-\u200D\uFEFF]/g;function Lr(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(l))return u;for(let d=0;d<=l.length;d++)if(p.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(Ua,""),p=o+c.length,d=t>=o&&t<=p,g=n>=o&&n<=p;if(d){let y=s(u,t-o);y===0&&!g?r.setStartBefore(l):r.setStart(l,y)}g&&(r.setEnd(l,s(u,n-o)),i=!0),o=p;break}case Node.ELEMENT_NODE:{if(Ld(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let c=0;c<l.childNodes.length&&(a(l.childNodes[c]),!i);c++);let u=l.lastChild;Id(l)&&u&&!Id(u)&&!Ld(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Ka(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(p){let d=p===n,g=p===o;switch(p.nodeType){case Node.TEXT_NODE:{let y=p.textContent;d&&(a=u+y.substring(0,r).replace(Ua,"").length),g&&(l=u+y.substring(0,i).replace(Ua,"").length),u+=y.replace(Ua,"").length;break}case Node.ELEMENT_NODE:{let y=p.nextSibling===null;Ld(p)&&!y&&u++;for(let v=0;v<p.childNodes.length;v++){let f=d&&v===r,h=g&&v===i;if(f&&(a=u),h&&(l=u),l!==void 0||((!f||!s)&&c(p.childNodes[v]),g&&v===i-1&&(l=u),l!==void 0))break}!g&&Id(p)&&!y&&u++,g&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function Va(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i}=t,s=-1,a="";function l(u){let c=u===n,p=u===o;switch(c&&s++,u.nodeType){case Node.TEXT_NODE:{if(s!==0)return;let d=c?r:0,g=p?i:void 0,y=u.textContent.replace(Ua,"");d===0&&g===void 0?a+=y:a+=y.substring(d,g);break}case Node.ELEMENT_NODE:{let d=u.nextSibling===null;s===0&&Ld(u)&&!d&&(a+=`
|
|
20
20
|
`);for(let g=c?r:0;g<(p?Math.min(i,u.childNodes.length):u.childNodes.length)&&(l(u.childNodes[g]),s!==1);g++);!p&&s===0&&Id(u)&&!d&&(a+=`
|
|
21
21
|
`);break}default:break}p&&s++}return l(e),a}function tC(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var wo=class extends kn{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let t=new Range;return t.selectNodeContents(this.element),Va(this.element,t)}getHTML(){return this.element.innerHTML||""}getRange(){var i;let t=this.getRootNode();if(t.activeElement!==this.element)return null;let n="getSelection"in t?t.getSelection():window.getSelection();if(!n)return null;let r="getComposedRanges"in n&&t instanceof ShadowRoot?(i=n.getComposedRanges(t))==null?void 0:i[0]:n.rangeCount>0?n.getRangeAt(0):null;if(!r)return null;let o=this.element.ownerDocument.createRange();return o.setStart(r==null?void 0:r.startContainer,r==null?void 0:r.startOffset),o.setEnd(r==null?void 0:r.endContainer,r==null?void 0:r.endOffset),!o||!this.element.contains(o.startContainer)||!this.element.contains(o.endContainer)?null:o}getCaretPosition(){let t=this.getRange();if(!t||!t.collapsed||!("getBoundingClientRect"in t))return null;let n=t.getBoundingClientRect();return!tC(n)&&(t.insertNode(this.element.ownerDocument.createTextNode("\u2060")),n=t.getBoundingClientRect(),t.deleteContents(),!tC(n))?null:{top:n.top+n.height,left:n.left}}getSelection(){let t=this.getRange();if(t)return Ka(this.element,t);let n=this.lastKnownSelection;if(n&&eC(this.element,n.start,n.end))return n;let r=Ui(this.element);return r.collapse(!1),Ka(this.element,r)}getSelectedText(){let{start:t,end:n}=this.getSelection();return Va(this.element,Lr(this.element,t,n))}applyChanges(t){var o;if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);return(o=this.observer)==null||o.takeRecords(),Promise.resolve(r).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let t=this.element.isContentEditable,n=new MutationObserver(()=>{this.element.isContentEditable!==t&&(t=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>n.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};function nC(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let i=document.createElement("iframe"),s=new URL(t);return Object.entries(n).forEach(([a,l])=>{s.searchParams.append(a,l)}),i.style.position="absolute",i.style.left="-999em",i.style.width="0px",i.style.height="0px",i.tabIndex=-1,i.id=r,i.title=`iframe-${e}`,i.src=s.toString(),window.document.body.appendChild(i),i}var Th=class{constructor(t){this.name=t;this.broadcastChannel=new BroadcastChannel(t)}broadcastChannel;disposeHandlers=[];onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(t)}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},kh=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.iframe=nC(t,`${this.targetOrigin}/v2/widget/liveengage/channel.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(t,this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},Ph=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),H.info("Set sessionId",t),this.sessionId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new kh(t,this.deepdeskUrl,{debug:!0}):new Th(t),r=o=>{var i,s;o.origin===this.deepdeskUrl&&o.data.type==="event"&&o.data.channel===t&&(H.info("Received broadcast event",this.sessionId,o),(s=(i=this.eventMap)[o.data.name])==null||s.call(i,o.data.payload))};return n.onMessage(r),n}send(t,n){var i,s;H.info("broadcast event",{sessionId:this.sessionId,name:t,payload:n});let r={type:"event",name:t,payload:n};(s=(i=this.eventMap)[t])==null||s.call(i,n);let o=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;o==null||o.postMessage({...r,channel:this.sessionId})}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),delete this.channel,t&&((r=this.defaultChannel)==null||r.close(),delete this.defaultChannel)}},rC=Ph;var Ki=class extends Error{constructor(n,r){super(n);this.body=r}name="CustomError"};var Rh=e=>new Promise(t=>{setTimeout(t,e)});var Vi=class extends Ki{name="ClientError"},Ih=class extends Ki{name="ServerError"},Gt=class e{constructor(t="",n={}){this.baseUrl=t;this.options=n;n.fetch&&(this.fetch=n.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,{abortLatest:l=!1,attempts:u=1,retryDelay:c=500,refreshTokenOn401:p=!0,retryOnError:d=_=>_ instanceof TypeError,retryOnResponse:g=_=>_.status>=500,version:y="v1",...v}=n,f={credentials:"include",...v,headers:{"Content-Type":"application/json",...v.headers}};n.method!==void 0&&n.method!=="GET"&&this.csrfToken&&(f.headers={...f.headers,"X-CSRFToken":this.csrfToken}),typeof y=="string"&&(f.headers={...f.headers,"X-Deepdesk-API-Version":y});let h=u,m=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&l&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let x=async()=>(h--,a(s,f).then(async _=>g(_)&&!i.isAborted&&h>0?(await Rh(c),x()):_.status===401&&p===!0&&m===!1?(m=!0,await this.refreshToken(),x()):_).catch(async _=>{if(d(_)&&!i.isAborted&&h>0)return await Rh(c),x();throw _}));x().then(_=>_.json().catch(()=>null).then(b=>{_.status>=500?o(new Ih("Server Error",b)):_.status===401?o(new Vi("Unauthorized",b)):_.status===403?o(new Vi("Forbidden",b)):_.status===404?o(new Vi("Not Found",b)):_.status>=400&&o(new Vi("Bad Request",b)),delete this.latestRequestByUrl[s],r(b)})).catch(_=>{o(_)})})}async validateToken(){let{has_valid_access_token:t}=await this.get("/auth/validate");if(!t)return!1;let{is_logged_in:n}=await this.get("/apis/admin/session/validate/",{version:null});return!!n}refreshToken(){return e.refreshingToken||(e.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{e.refreshingToken=null},1e3*60)})),e.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,{method:"POST",body:JSON.stringify(n),...r})}patch(t,n,r){return this.request(t,{method:"PATCH",body:JSON.stringify(n),...r})}put(t,n,r){return this.request(t,{method:"PUT",body:JSON.stringify(n),...r})}delete(t,n){return this.request(t,{method:"DELETE",...n})}};var pA;(t=>{let e;(l=>(l.SEND_MESSAGE="Send Message",l.HANDLING_TIME="Handling Time",l.START_AUTOFLOW="Start Autoflow",l.ABORT_AUTOFLOW="Abort Autoflow",l.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",l.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(e=t.EventType||={})})(pA||={});function Ad(e){return{...Z(e),tags:e.tags}}var zn=class e{constructor(t,n={}){this.options=n;this.client=new Gt(t,{fetch:n.fetch}),this.client.patchFetch(r=>async(o,i)=>{let s=await r(o,i);return this.handleDeepdeskVersionHeaders(s),s})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=await this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(e.exchangeTokenPromise||(e.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),e.exchangeTokenPromise):Promise.resolve()}async createConversation(t){await this.preflight(),H.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=await this.client.post("/api/conversations",{...ke(t),tags:t.tags},{version:"v2"});return Ad(n)}async getProfile(t){let n=await this.client.get(`/apis/admin/profiles/${t}/`,{version:null});return Z(n)}async getKnowledgeAssistant(t){let n=await this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{version:null});return Z(n)}async getContentTypes(){let t=await this.client.get("/apis/admin/content-types/",{version:null});return Z(t)}async getPlatformConfig(){let{config:t}=await this.client.get("/platform/config/",{version:null});return Z(t)}async checkUserExists(t){let{exists:n}=await this.client.get(`/apis/admin/users/exists?external_id=${t}`);return n}async getConversationBySessionId(t,n={}){await this.preflight(),H.info(`Getting conversation for session ${t}`);let{attempts:r=1,retryDelay:o=1e3}=n,i=await this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"});return Ad(i)}async isConversationSupported(t,n={}){H.info(`Check if conversation for session ${t} is supported`);let{attempts:r=1,retryDelay:o=1e3}=n;return(await this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"})).has_active_profile}async updateConversation(t,n){let r=ke(n);n.tags&&(r.tags=n.tags);let o=await this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Ad(o)}async postMessages(t,n){return(await this.client.post(`/api/conversations/${t}/messages`,n.map(o=>({...ke(o),tags:o.tags})),{version:"v2"})).map(o=>Ad(o))}async sendEvent(t,n){let{data:r,...o}=n,i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[a,l])=>({...s,[a]:l}),{});return this.client.post("/api/events",ke({...i,...o,data:r,name:t}),{version:"v2"})}async sendEventV1(t,n){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>({...o,[i]:s}),{});return this.client.post("/api/events",{event:t,data:ke({...n,...r})})}async getEntities(t){return(await this.client.post("/api/entities",{messages:t.filter(r=>r.text)})).entities}async getSummary(t,n={}){return(await this.client.post("/api/summary",{conversation:{messages:t.filter(o=>o.text&&o.source)},prompt_instruction:n.promptInstruction,model:n.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(t){return this.client.post("/apis/admin/session/jwt/",{jwt:t},{version:null}).catch(n=>{throw H.warn(`Invalid token '${t}'`),n})}async authenticateWithKey(t,n){await this.client.post("/apis/admin/session/api-key/",ke(n),{version:null,refreshTokenOn401:!1,headers:{apikey:t}})}async getTextSuggestions(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(await this.client.post(`/api/conversations/${t}/recommend/${r}`,ke(n),{abortLatest:!0})).map(i=>({...Z(i),text:i.text||i.url||i.message,source:r,type:r})).filter((i,s,a)=>s===a.findIndex(l=>l.text===i.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(t,n){return(await this.client.post(`/api/conversations/${t}/autocomplete`,ke(n),{abortLatest:!0})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))}async getPinnedMessages(t){let n=await this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0});return Z(n).map(r=>({...r,text:r.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(t){let n=await this.client.post("/api/style-suggestions",ke(t),{abortLatest:!0});return Z(n)}async search(t){let n=await this.client.post(`/api/profiles/${t.profile}/search`,ke(t),{version:"v2"});return Z(n)}async knowledgeAssist(t,n,r){let o=await this.client.post(`/api/knowledge-assist/assistants/${r}/search`,ke({question:t.question,promptInstruction:t.promptInstruction,chatHistory:n.map(i=>({question:i.question,answer:i.answer.answer}))}),{version:"v2"});return Z(o)}async requestLoginByEmail(t){let n=await this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return Z(n)}async requestPasswordlessToken(){let t=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return Z(t.token)}async getCsrfToken(){let{token:t}=await this.client.get("/apis/admin/session/csrf/",{version:null});return t}async verifyLoginToken(t){let n=await this.client.post("/apis/admin/session/passwordless/login/",{token:t},{version:null});return Z(n)}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Ty);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&H.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};var Wa=class{constructor(t,n){this.url=t;this.options={timeout:25e3,...n}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(t){this.eventSource.addEventListener(Dg(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,Z(o))}catch{H.warn(`Invalid JSON for ${t}: ${r}`)}})}connect(){clearTimeout(this.timeoutTimer);let t=new EventSource(this.url,{withCredentials:!0});this.eventSource=t;let n=!1;t.onopen=()=>{n=!0},t.onerror=()=>{n&&t.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{t.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(r=>{this.proxyEvent(r)})}disconnect(){var t;clearTimeout(this.timeoutTimer),this.eventListeners={},(t=this.eventSource)==null||t.close()}emit(t,n){this.eventListeners[t]&&this.eventListeners[t].forEach(r=>r(n))}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),this.proxyEvent(t),()=>{this.off(t,n)}}off(t,n){let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}};var fA;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||={})})(fA||={});var $a=class{constructor(t,n={}){this.apiUrl=t;this.client=new Gt(t,n)}client;streams={};logger=H;async getCustomMessages(t){let n=await this.client.get(`/sessions/${t}/suggestions`);return Z(n.suggestions)}async sendCustomMessage(t,n){let r=await this.client.post(`/sessions/${t}/messages`,ke(n));return Z(r)}async answerCustomMessage(t,n){await this.client.post(`/sessions/${t}/answers`,ke(n))}async getAutoflows(t){let n=await this.client.get(`/sessions/${t}/autoflows`);return Z(n.autoflows)}async startAutoflowSession(t){let n=await this.client.post("/autoflow-sessions",ke(t));return Z(n)}async stopAutoflowSession(t){await this.client.delete(`/autoflow-sessions/${t}`)}openStream(t){return this.streams[t]||(this.streams[t]=new Wa(`${this.apiUrl}/sessions/${t}/events`),this.streams[t].connect()),this.streams[t]}closeStream(t){this.streams[t]||(this.streams[t].disconnect(),delete this.streams[t])}};var oC={startTime:null,stopTime:null},iC=z({name:"handlingTime",initialState:oC,reducers:{handlingTimeStart(e){if(e.startTime&&!e.stopTime)throw new Error("Timing already started");e.startTime=new Date,e.stopTime=null},handlingTimeStop(e){if(!e.startTime)throw new Error("Timing not started");e.stopTime=new Date},handlingTimeReset(e){e.startTime=null,e.stopTime=null}},extraReducers:e=>{e.addCase(te,()=>oC)}}),{handlingTimeStart:sC,handlingTimeStop:Od,handlingTimeReset:aC}=iC.actions,lC=iC.reducer;var uC=(e={})=>{let t={onAuthError:Oi(!1),...e};return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Nd={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var bo=M("styleSuggestions/getAll",async({text:e},t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),{showStyleSuggestions:o}=r.settings,i=(s=r.conversation.current)==null?void 0:s.profileCode;if(!o)return Nd.list;if(!i)throw new Error("No current conversation to fetch pinned messages");return n.getStyleSuggestions({profileCode:i,message:e})}),mA=z({name:"styleSuggestions",initialState:Nd,reducers:{},extraReducers:e=>{e.addCase(bo.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(bo.rejected,t=>{t.fetchState="error"}).addCase(bo.fulfilled,(t,n)=>{t.fetchState="done",hr(t.list,n.payload)||(t.list=n.payload)}).addCase(no,t=>{t.list=Nd.list}).addCase(te,()=>Nd)}}),cC=mA.reducer;var dC=(e={})=>{let t,n=!0,r={getStyleSuggestions:bo,debounce:500,...e};return o=>i=>s=>{var g;let a=o.getState().input.text,l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:c}=u.settings;if(!((g=u.conversation.current)==null?void 0:g.id)||!c)return l;let{text:d}=u.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function gA(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var pC=(e={})=>{let t={getTextSuggestions:Vt,getAutocompleteSuggestions:Ca,debounce:200,check:ji,...e},n;return r=>o=>i=>{var v;let{input:{userCommitted:s}}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,p=(v=l.conversation.current)==null?void 0:v.id,d=i.type===rd.toString();if(!p||!u&&!c)return a;let{input:{userCommitted:g}}=l;return gA(g,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let f=xi(l);f===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(f))},d?0:t.debounce)),a}};var fC=bo.fulfilled.toString();function hA(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let i=e.keywordMatches.filter(l=>l.keyword===o),s=t.keywordMatches.filter(l=>l.keyword===o),a=s.length-i.length;a<=0||r.push(...s.slice(0,a))}),r}var mC=e=>t=>n=>r=>{var u;if(r.type!==fC){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(u=i.conversation)==null?void 0:u.current;if(o===s)return;let l=hA(o,s);r.type===fC&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var yA=Ru({activeSuggestion:Lw,answer:b1,auth:Vw,autoflows:gb,conversation:Gx,contentTypes:i1,customMessages:Cb,passwordlessToken:Pb,entities:u1,knowledgeAssistant:x1,handlingTime:lC,info:sw,input:eg.reducer,overlayInput:nt.reducer,settings:Hx,profile:T1,search:pw,summary:g1,styleSuggestions:cC,ui:Mw,textSuggestions:Tw});function gC(e){return W0({reducer:yA,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),uC(),pC({debounce:200}),dC({debounce:500}),mC(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var vA=e=>{var t;return((t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())??"unknown"},SA=e=>t=>n=>r=>{var a;let o=t.getState(),i=Gm("inlineSuggestions")(o);switch(r.type){case In.toString():{let l=nd(r.payload.contentType)(t.getState()),u=l.indexOf(r.payload.suggestion);e.emit("edit-suggestion",{contentType:r.payload.contentType,index:u,suggestions:l});break}case Oi.toString():{!r.payload&&e.emit("logout",void 0);break}case Bt.toString():{let{start:l,end:u}=o.input.selection;e.emit("select-suggestion",{type:vA(r.payload.suggestion),...r.payload,replace:r.payload.replace==="selection"?{start:l,end:u}:{start:0,end:u}},{mayApplyChanges:!0});break}case fc.toString():{let{start:l,end:u}=o.input.selection;e.emit("replace",{...r.payload,replace:r.payload.replace==="selection"?{start:l,end:u}:{start:0,end:u}},{mayApplyChanges:!0});break}case sa.toString():{let l=t.getState(),{text:u,selection:c}=l.input.userCommitted;e.emit("reset",{text:u,selectionAfter:c},{mayApplyChanges:!0});break}case yc.toString():e.emit("select-image",r.payload,{mayApplyChanges:!0}),e.sendEvent("Image attached",{conversationId:o.conversation.current.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case $t.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:o.conversation.current.id,data:{entities:r.payload}});break;case On.fulfilled.toString():e.sendEvent("conversation summarized",{conversationId:o.conversation.current.id,data:{summary:r.payload.summary}});break;case Be.toString():e.sendEvent(r.payload.name,{conversationId:((a=r.payload.options)==null?void 0:a.includeConversationData)&&o.conversation.current.id,data:r.payload.data});break;case mc.toString():e.handleKeyDown(r.payload);break;case no.toString():e.logSendMessage(r.payload);break;case gc.toString():e.logSendEditSuggestionMessage(r.payload);break;case hc.toString():e.handleInputChanged(r.payload);break;default:break}let s=n(r);switch(r.type){case no.toString():e.handleAfterSendMessage(r.payload);break;case Ea.toString():e.onUpdateShowTabHint(r.payload);break;case Od.toString():e.logHandlingTime();break;case Bt.toString():{i&&(t.dispatch(on([])),t.dispatch(wn()));break}case on.toString():{i&&r.payload.length>0&&t.dispatch(vr(0));break}default:break}return s},hC=SA;function Lh(e){return e.toISOString().replace("T"," ").replace("Z","")}function yC(e,t){var o,i,s;let{startTime:n,stopTime:r}=e.handlingTime;if(!n||!r)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:e.conversation.current.id,clientVersion:t.version,agentId:(o=e.info.agentInfo)==null?void 0:o.agentId,agentName:(i=e.info.agentInfo)==null?void 0:i.agentName,agentEmail:(s=e.info.agentInfo)==null?void 0:s.agentEmail,timeStart:Lh(n),timeStop:Lh(r)}}function Ah(e,t,n){var E,I,P;let{text:r,metrics:{numCharsTyped:o,numCharsPasted:i,numCharsCut:s,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:u,externalTimeTotalSeconds:c,pastes:p,cuts:d,deletions:g,textSuggestions:y,offeredTextSuggestions:v}}=t[e],f=r.length,m=y.reduce((K,{text:D,searchTerm:B})=>K+D.length-(B?B.length:0),0),x=u??Date.now(),_=(Date.now()-x)/1e3+(c||0),b=o/_,C=y.reduce((K,{searchTerm:D})=>K+(D?D.length:0),0);return{conversationId:t.conversation.current.id,source:"agent",text:r,clientVersion:n.version,pastes:p,cuts:d,deletions:g,lenTextTyped:o+C,lenTextTotal:f,lenTextAssisted:m,lenTextPasted:i,lenTextCut:s,lenTextDeleted:a,timeTotalSeconds:_,charsPerSecond:b,numPastes:l,textSuggestionsV2:y,suggestionsCounters:[{source:"gpt",countOffered:v.filter(K=>K.source==="gpt").length}],agentId:(E=t.info.agentInfo)==null?void 0:E.agentId,agentName:(I=t.info.agentInfo)==null?void 0:I.agentName,agentEmail:(P=t.info.agentInfo)==null?void 0:P.agentEmail}}function Oh(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return Oh(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?Oh(o,t):null}function vC(e,t){return Oh(e,t)}function SC(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function xA(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Md(e){return xA(e)&&(Pr(e)||zc(e))}var xC=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch{return t}}catch{return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch{H.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function _A(e){return e.offsetParent!==null}function _C(e){if(!_A(e))return!1;let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}function Dd(e,t,n=100){let r=_C(e);t({isVisible:r});let o=setInterval(()=>{let i=_C(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var EC=S(q());var Fd=S(w()),wC=({className:e})=>(0,Fd.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:e,children:(0,Fd.jsx)("g",{children:(0,Fd.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
|
|
22
22
|
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
|
|
23
23
|
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
|
|
24
24
|
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
|
|
25
|
-
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 Nh=S(w()),wA={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},bC=({className:e,color:t})=>(0,Nh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Nh.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:wA[t||"pink"]})});var CC={root:"_root_1tvv4_1",text:"_text_1tvv4_18",isLoggedIn:"_isLoggedIn_1tvv4_25",isLoggedOut:"_isLoggedOut_1tvv4_29",icon:"_icon_1tvv4_39",logo:"_logo_1tvv4_44",lock:"_lock_1tvv4_49"};var Mh={};Pe(Mh,{enUS:()=>bA,nlNL:()=>CA});var bA={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},CA={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Co=S(w()),TC=({onLogIn:e})=>{let t=j(Mh),n=N("productName"),r=U(),o=R(pt),i=k("FloatingMenu",CC);if(o===null)return null;let s=()=>{o===!0?r($e(!0)):e()};return(0,Co.jsxs)("button",{className:(0,EC.default)(i.root,{[i.isLoggedIn]:o,[i.isLoggedOut]:!o}),onClick:s,children:[(0,Co.jsx)("div",{className:i.text,children:t(o?"search":"signin",{productName:n})}),(0,Co.jsxs)("div",{className:i.icon,children:[(0,Co.jsx)(bC,{className:i.logo,color:"pink"}),o===!1&&(0,Co.jsx)(wC,{className:i.lock})]})]})};async function jd(e){let n=await new Gt(e).get("/platform/config/",{version:null});return Z(n)}var we=S(w());var kC=xC("showTabHint",!0),qa=class e{static version="10.10.3-beta.0";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:t,brokerUrl:n,version:r=e.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){let u=t.replace(/\/api$/,"");this.deepdeskApi=new zn(u,{token:i,fetch:s}),this.version=r,this.instanceId=e.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[hC({emit:(p,d,g)=>this.emit(p,d,g),handleAfterSendMessage:p=>this.handleAfterSendMessage(p),handleInputChanged:p=>this.handleInputChanged(p),handleKeyDown:p=>this.handleKeyDown(p),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:p=>this.logSendMessage(p),logSendEditSuggestionMessage:p=>this.logSendEditMessage(p),onUpdateShowTabHint:p=>kC.update(p),sendEvent:(p,d)=>this.deepdeskApi.sendEvent(p,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new $a(n)}),this.store=gC(c),this.broadcastEvents=new rC({debug:!0,deepdeskUrl:u,eventMap:Ww(this.store),createCustomChannel:l}),this.store.dispatch(oa),this.store.dispatch(Ea(kC.value())),this.store.dispatch(oa({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(H.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(H.warn("Profile has not been loaded (yet)"),!0):(H.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Oi(null)),this.store.dispatch(Ln()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();pt(r)&&jw(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}async isLoggedIn(){return(await this.store.dispatch(Ln())).payload}async setPlatformAgentId(t){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:t}),version:null})}catch(n){H.warn("Failed to attach user:",n)}}async isConversationSupported(t,n){return(await this.store.dispatch(Zm({sessionId:t,options:n}))).payload}async createConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(ac(t))).payload}async getConversationBySessionId(t,n){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(await this.store.dispatch(lc({sessionId:t,options:n}))).payload}async upsertConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(Jm(t))).payload}async postMessages(t){return(await this.store.dispatch(cc(t))).payload}async updateConversation(t){return(await this.store.dispatch(uc(t))).payload}resetConversation(){this.store.dispatch(te()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let t=await this.store.dispatch(On());if(t.error)throw new Error(t.error.message);return t.payload.summary}configure(t){this.store.dispatch(oa(t))}setVisitorInfo(t){this.store.dispatch(iw(t))}async setAgentInfo(t){await this.store.dispatch(xa(t))}async setAgentSettings(t){await this.store.dispatch(Fg(t))}async getAgentSettings(){return(await this.store.dispatch(jg())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let t=[];return this.store.dispatch(rd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})}notifyInputChanged(t){this.store.dispatch(hc(t))}notifyKeyDown(t){this.store.dispatch(mc(t))}notifyPaste(t,n){this.store.dispatch(i_({text:t,selectionText:n}))}notifyCut(t){this.store.dispatch(r_(t))}notifyExternalSuggestion(t){this.store.dispatch(Bt(t)),this.store.dispatch(wn())}notifyEditSuggestion(t){this.store.dispatch(Cw(t.contentType,t.suggestions)),this.store.dispatch(In({contentType:t.contentType,suggestion:typeof t.index=="number"?t.suggestions[t.index]:null}))}handleInputChanged(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui;n&&r&&this.store.dispatch(Cr({collapse:!1})),this.inputMediator&&this.store.dispatch(Yx({text:t,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(on([])))}handleKeyDown(t){let{overlayCollapsed:n}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:o,selection:i}=this.state.input,{inlineSuggestions:s}=this.state.settings,a=r.length>0,l=o!==-1;if(this.store.dispatch(o_(pc(t))),t.key!=="Tab"&&!this.settings.showTextSuggestions)return;let u=()=>{n||!a||i&&(t.shiftKey||(this.store.dispatch(e_()),s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault()))},c=()=>{n||!a||s&&o<=0||i&&(t.shiftKey||(this.store.dispatch(n_()),t.preventDefault(),!s&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(sa()):this.stageSelectedSuggestion({inputType:"arrow"}))))};switch(t.key){case"Up":case"ArrowUp":s?c():u();return;case"Down":case"ArrowDown":{s?u():c();return}case"Esc":case"Escape":{s&&l&&this.store.dispatch(vr(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(vr(-1)),this.store.dispatch(sa()),t.preventDefault()):n||(this.store.dispatch(Cr({collapse:!0})),this.store.dispatch(Ow(!0)),t.preventDefault());return}case"Tab":{let{userCommitted:p}=this.state.input,d=p.text.substring(0,p.selection.end),{tabCompletionSuggestion:g}=this.state.input;this.store.dispatch(Ea(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!s&&this.settings.showTabCompletion&&g&&g.text.startsWith(d)&&(this.store.dispatch(Bt({text:g.text,suggestion:g,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(wn())),t.preventDefault();break}default:}}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(s_()),this.store.dispatch(on([]))}handlingTimeStart(){this.state.handlingTime.startTime||(H.info("Start handling time"),this.store.dispatch(sC()))}handlingTimeStop(){this.state.handlingTime.startTime&&(H.info("Stop handling time"),this.store.dispatch(Od()))}logSendMessage(t){let n=Ah("input",this.state,{version:this.version});t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n)}logSendEditMessage(t){let n=Ah("overlayInput",this.state,{version:this.version});t&&Object.assign(n,{text:t}),this.store.dispatch(Jx(this.state.overlayInput.metrics))}logHandlingTime(){let t=yC(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(aC())}notifySubmit(t={}){this.shouldAbort()||(this.store.dispatch(wn()),this.store.dispatch(no(t.text??this.state.input.text)))}stageSelectedSuggestion(t){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:r}=this.state.input;this.store.dispatch(Bt({text:r[n].text,suggestion:r[n],eventMetrics:t,replace:"until-selection-end"}))}emit(t,n,r={}){let o=()=>{this.eventListeners[t]&&this.eventListeners[t].forEach(i=>{try{i(n)}catch(s){H.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),H.error(s)}})};this.inputMediator&&r.mayApplyChanges?this.inputMediator.applyChanges(o):o()}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=lo(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,Nt.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var s;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;if(i){let[a,l]=lo(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});a.dataset.testid=n,a.style.zIndex="2",a.appendChild(r),this.unmountHandlers.push(()=>{(0,Nt.unmountComponentAtNode)(o),l()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return ao(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,Nt.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),H.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(H.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(l_(r.metrics))):H.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch{}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Md(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:p,detectSubmit:d,insertLink:g,inputMediator:y,closestScrollSelector:v,appendOverlayTo:f,inlineSuggestions:h,floatingMenu:m}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:g,isEmbedded:p,inlineSuggestions:h,floatingMenu:!!m}),n.automaticHandlingTime&&this.setupHandlingTime(t),ao(t),this.inputMediator=y||(Pr(t)?new Pn(t):new wo(t)),this.inputMediator.on("change",({plainText:b})=>{this.notifyInputChanged(b)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(a_({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",b=>{this.notifyKeyDown(b)}),this.inputMediator.on("paste",({pastedText:b,selectionText:C})=>{this.notifyPaste(b,C)}),this.inputMediator.on("cut",({selectionText:b})=>{this.notifyCut(b)});let x=v&&vC(t,v)||void 0;if(h){let{customStyles:b,appendOverlayTo:C}=n;if(Pr(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let E=this.createInlineContainer(t,"deepdesk-caret");(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:b,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(H1,{})})}),E),this.inputMediator.on("caret",P=>{this.store.dispatch(on([])),P?(E.style.display="block",E.style.top=`${P.top}px`,E.style.left=`${P.left}px`):E.style.display="none"});let I=this.overlayContainerFactory("floating-menu",x||t,{appendTo:typeof m=="object"&&"appendOverlayTo"in m?m.appendOverlayTo:C},b==null?void 0:b.floatingMenuRootNode);(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:b,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(TC,{onLogIn:()=>this.loginViaPopup().catch(P=>H.warn(P.message))})})}),I)}else{let b=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:f,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:f},r==null?void 0:r.suggestionsRootNode);(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:r,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(ub,{inputElement:t})})}),b),(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:r,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(q1,{onLogIn:()=>this.loginViaPopup().catch(E=>H.warn(E.message))})})}),C)}(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:r,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(O1,{})})}),this.createContainer("deepdesk-overlays"));let _;this.inputMediator.on("selection",b=>{clearTimeout(_),b===null?_=setTimeout(()=>{b!==null&&this.store.dispatch(tg(b))},500):this.store.dispatch(tg(b))}),this.inputMediator.on("disabled",()=>{var b;(b=this.inputMediator)==null||b.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(Ai(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Ai(!0))),this.store.dispatch(Zx({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(wn()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var b;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((b=this.state.conversation.current)==null?void 0:b.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&H.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:r,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(Jb,{onLogIn:()=>this.loginViaPopup().catch(s=>H.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Nt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Dd(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){SC(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(Da());let t=Tr(this.state);t&&(await this.store.dispatch(Na()),this.store.dispatch(oa({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(){let t=this.state.settings.adminUrl,n=new URL(t),r=await jd(n.origin);return new Promise((o,i)=>{let s=new MessageChannel,a=s.port1,l=new URL(r.config.platform.hasSso?`${t}/platform/sso/`:`${t}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let u=!1,c=()=>{p&&!p.closed&&p.close(),window.removeEventListener("message",d),clearInterval(g)};a.onmessage=async y=>{var v,f;if((v=y.data)!=null&&v.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((f=y.data)==null?void 0:f.jwt),await this.isLoggedIn(),this.broadcastEvents.send(Pa),c(),u=!0,s.port1.close(),o()}catch(h){i(h)}};let p=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");p===null&&i(new Error("Popup blocked by browser"));let d=async y=>{var v;if(y.origin===l.origin)switch((v=y.data)==null?void 0:v.type){case"deepdesk-popup-loaded":{p==null||p.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[s.port2]);break}case"deepdesk-popup-error":{c(),y.data.message==="Timeout"&&H.warn("Popup timed out. Check if the account's platform url is configured correctly."),i(new Error(y.data.message));break}}};window.addEventListener("message",d);let g=setInterval(()=>{p&&!p.closed||(c(),u||i(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})}async checkForTrialMode(t){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(H.info("Trial is active"),!await this.deepdeskApi.checkUserExists(t))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;H.info(r),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=ad(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch($t()):this.store.dispatch(Vt(r))})}catch(r){this.handleError(r)}}};async function PC(e,t,n={}){let{value:r}=e,{start:o,end:i}=n.replace??{start:0,end:r.length},s=`${r.slice(0,o)}${t}${r.slice(i)}`,a=n.selectionAfter??{start:o+t.length,end:o+t.length},l=()=>{if(n.setValue)return n.setValue(s);e.value=s};return Promise.resolve(l()).then(()=>{e.selectionStart=a.start,e.selectionEnd=a.end,e.blur(),e.focus()})}async function RC(e,t,n={}){let r=n.replace?Lr(e,n.replace.start,n.replace.end):Ui(e),o,i=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),o=document.createElement("span"),r.insertNode(o),n.insertBRs!==!1?t.split(`
|
|
25
|
+
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 Nh=S(w()),wA={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},bC=({className:e,color:t})=>(0,Nh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Nh.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:wA[t||"pink"]})});var CC={root:"_root_1tvv4_1",text:"_text_1tvv4_18",isLoggedIn:"_isLoggedIn_1tvv4_25",isLoggedOut:"_isLoggedOut_1tvv4_29",icon:"_icon_1tvv4_39",logo:"_logo_1tvv4_44",lock:"_lock_1tvv4_49"};var Mh={};Pe(Mh,{enUS:()=>bA,nlNL:()=>CA});var bA={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},CA={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Co=S(w()),TC=({onLogIn:e})=>{let t=j(Mh),n=N("productName"),r=U(),o=R(pt),i=k("FloatingMenu",CC);if(o===null)return null;let s=()=>{o===!0?r($e(!0)):e()};return(0,Co.jsxs)("button",{className:(0,EC.default)(i.root,{[i.isLoggedIn]:o,[i.isLoggedOut]:!o}),onClick:s,children:[(0,Co.jsx)("div",{className:i.text,children:t(o?"search":"signin",{productName:n})}),(0,Co.jsxs)("div",{className:i.icon,children:[(0,Co.jsx)(bC,{className:i.logo,color:"pink"}),o===!1&&(0,Co.jsx)(wC,{className:i.lock})]})]})};async function jd(e){let n=await new Gt(e).get("/platform/config/",{version:null});return Z(n)}var we=S(w());var kC=xC("showTabHint",!0),qa=class e{static version="10.10.3-beta.1";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:t,brokerUrl:n,version:r=e.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){let u=t.replace(/\/api$/,"");this.deepdeskApi=new zn(u,{token:i,fetch:s}),this.version=r,this.instanceId=e.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[hC({emit:(p,d,g)=>this.emit(p,d,g),handleAfterSendMessage:p=>this.handleAfterSendMessage(p),handleInputChanged:p=>this.handleInputChanged(p),handleKeyDown:p=>this.handleKeyDown(p),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:p=>this.logSendMessage(p),logSendEditSuggestionMessage:p=>this.logSendEditMessage(p),onUpdateShowTabHint:p=>kC.update(p),sendEvent:(p,d)=>this.deepdeskApi.sendEvent(p,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new $a(n)}),this.store=gC(c),this.broadcastEvents=new rC({debug:!0,deepdeskUrl:u,eventMap:Ww(this.store),createCustomChannel:l}),this.store.dispatch(oa),this.store.dispatch(Ea(kC.value())),this.store.dispatch(oa({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(H.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(H.warn("Profile has not been loaded (yet)"),!0):(H.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Oi(null)),this.store.dispatch(Ln()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();pt(r)&&jw(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}async isLoggedIn(){return(await this.store.dispatch(Ln())).payload}async setPlatformAgentId(t){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:t}),version:null})}catch(n){H.warn("Failed to attach user:",n)}}async isConversationSupported(t,n){return(await this.store.dispatch(Zm({sessionId:t,options:n}))).payload}async createConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(ac(t))).payload}async getConversationBySessionId(t,n){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(await this.store.dispatch(lc({sessionId:t,options:n}))).payload}async upsertConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(Jm(t))).payload}async postMessages(t){return(await this.store.dispatch(cc(t))).payload}async updateConversation(t){return(await this.store.dispatch(uc(t))).payload}resetConversation(){this.store.dispatch(te()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let t=await this.store.dispatch(On());if(t.error)throw new Error(t.error.message);return t.payload.summary}configure(t){this.store.dispatch(oa(t))}setVisitorInfo(t){this.store.dispatch(iw(t))}async setAgentInfo(t){await this.store.dispatch(xa(t))}async setAgentSettings(t){await this.store.dispatch(Fg(t))}async getAgentSettings(){return(await this.store.dispatch(jg())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let t=[];return this.store.dispatch(rd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})}notifyInputChanged(t){this.store.dispatch(hc(t))}notifyKeyDown(t){this.store.dispatch(mc(t))}notifyPaste(t,n){this.store.dispatch(i_({text:t,selectionText:n}))}notifyCut(t){this.store.dispatch(r_(t))}notifyExternalSuggestion(t){this.store.dispatch(Bt(t)),this.store.dispatch(wn())}notifyEditSuggestion(t){this.store.dispatch(Cw(t.contentType,t.suggestions)),this.store.dispatch(In({contentType:t.contentType,suggestion:typeof t.index=="number"?t.suggestions[t.index]:null}))}handleInputChanged(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui;n&&r&&this.store.dispatch(Cr({collapse:!1})),this.inputMediator&&this.store.dispatch(Yx({text:t,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(on([])))}handleKeyDown(t){let{overlayCollapsed:n}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:o,selection:i}=this.state.input,{inlineSuggestions:s}=this.state.settings,a=r.length>0,l=o!==-1;if(this.store.dispatch(o_(pc(t))),t.key!=="Tab"&&!this.settings.showTextSuggestions)return;let u=()=>{n||!a||i&&(t.shiftKey||(this.store.dispatch(e_()),s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault()))},c=()=>{n||!a||s&&o<=0||i&&(t.shiftKey||(this.store.dispatch(n_()),t.preventDefault(),!s&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(sa()):this.stageSelectedSuggestion({inputType:"arrow"}))))};switch(t.key){case"Up":case"ArrowUp":s?c():u();return;case"Down":case"ArrowDown":{s?u():c();return}case"Esc":case"Escape":{s&&l&&this.store.dispatch(vr(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(vr(-1)),this.store.dispatch(sa()),t.preventDefault()):n||(this.store.dispatch(Cr({collapse:!0})),this.store.dispatch(Ow(!0)),t.preventDefault());return}case"Tab":{let{userCommitted:p}=this.state.input,d=p.text.substring(0,p.selection.end),{tabCompletionSuggestion:g}=this.state.input;this.store.dispatch(Ea(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!s&&this.settings.showTabCompletion&&g&&g.text.startsWith(d)&&(this.store.dispatch(Bt({text:g.text,suggestion:g,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(wn())),t.preventDefault();break}default:}}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(s_()),this.store.dispatch(on([]))}handlingTimeStart(){this.state.handlingTime.startTime||(H.info("Start handling time"),this.store.dispatch(sC()))}handlingTimeStop(){this.state.handlingTime.startTime&&(H.info("Stop handling time"),this.store.dispatch(Od()))}logSendMessage(t){let n=Ah("input",this.state,{version:this.version});t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n)}logSendEditMessage(t){let n=Ah("overlayInput",this.state,{version:this.version});t&&Object.assign(n,{text:t}),this.store.dispatch(Jx(this.state.overlayInput.metrics))}logHandlingTime(){let t=yC(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(aC())}notifySubmit(t={}){this.shouldAbort()||(this.store.dispatch(wn()),this.store.dispatch(no(t.text??this.state.input.text)))}stageSelectedSuggestion(t){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:r}=this.state.input;this.store.dispatch(Bt({text:r[n].text,suggestion:r[n],eventMetrics:t,replace:"until-selection-end"}))}emit(t,n,r={}){let o=()=>{this.eventListeners[t]&&this.eventListeners[t].forEach(i=>{try{i(n)}catch(s){H.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),H.error(s)}})};this.inputMediator&&r.mayApplyChanges?this.inputMediator.applyChanges(o):o()}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=lo(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,Nt.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var s;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;if(i){let[a,l]=lo(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});a.dataset.testid=n,a.style.zIndex="2",a.appendChild(r),this.unmountHandlers.push(()=>{(0,Nt.unmountComponentAtNode)(o),l()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return ao(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,Nt.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),H.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(H.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(l_(r.metrics))):H.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch{}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Md(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:p,detectSubmit:d,insertLink:g,inputMediator:y,closestScrollSelector:v,appendOverlayTo:f,inlineSuggestions:h,floatingMenu:m}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:g,isEmbedded:p,inlineSuggestions:h,floatingMenu:!!m}),n.automaticHandlingTime&&this.setupHandlingTime(t),ao(t),this.inputMediator=y||(Pr(t)?new Pn(t):new wo(t)),this.inputMediator.on("change",({plainText:b})=>{this.notifyInputChanged(b)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(a_({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",b=>{this.notifyKeyDown(b)}),this.inputMediator.on("paste",({pastedText:b,selectionText:C})=>{this.notifyPaste(b,C)}),this.inputMediator.on("cut",({selectionText:b})=>{this.notifyCut(b)});let x=v&&vC(t,v)||void 0;if(h){let{customStyles:b,appendOverlayTo:C}=n;if(Pr(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let E=this.createInlineContainer(t,"deepdesk-caret");(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:b,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(H1,{})})}),E),this.inputMediator.on("caret",P=>{this.store.dispatch(on([])),P?(E.style.display="block",E.style.top=`${P.top}px`,E.style.left=`${P.left}px`):E.style.display="none"});let I=this.overlayContainerFactory("floating-menu",x||t,{appendTo:typeof m=="object"&&"appendOverlayTo"in m?m.appendOverlayTo:C},b==null?void 0:b.floatingMenuRootNode);(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:b,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(TC,{onLogIn:()=>this.loginViaPopup().catch(P=>H.warn(P.message))})})}),I)}else{let b=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:f,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:f},r==null?void 0:r.suggestionsRootNode);(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:r,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(ub,{inputElement:t})})}),b),(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:r,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(q1,{onLogIn:()=>this.loginViaPopup().catch(E=>H.warn(E.message))})})}),C)}(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:r,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(O1,{})})}),this.createContainer("deepdesk-overlays"));let _;this.inputMediator.on("selection",b=>{clearTimeout(_),b===null?_=setTimeout(()=>{b!==null&&this.store.dispatch(tg(b))},500):this.store.dispatch(tg(b))}),this.inputMediator.on("disabled",()=>{var b;(b=this.inputMediator)==null||b.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(Ai(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Ai(!0))),this.store.dispatch(Zx({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(wn()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var b;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((b=this.state.conversation.current)==null?void 0:b.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&H.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,Nt.render)((0,we.jsx)(_o,{store:this.store,customStyles:r,children:(0,we.jsx)(yo,{broadcastEvents:this.broadcastEvents,children:(0,we.jsx)(Jb,{onLogIn:()=>this.loginViaPopup().catch(s=>H.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Nt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Dd(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){SC(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(Da());let t=Tr(this.state);t&&(await this.store.dispatch(Na()),this.store.dispatch(oa({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(){let t=this.state.settings.adminUrl,n=new URL(t),r=await jd(n.origin);return new Promise((o,i)=>{let s=new MessageChannel,a=s.port1,l=new URL(r.config.platform.hasSso?`${t}/platform/sso/`:`${t}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let u=!1,c=()=>{p&&!p.closed&&p.close(),window.removeEventListener("message",d),clearInterval(g)};a.onmessage=async y=>{var v,f;if((v=y.data)!=null&&v.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((f=y.data)==null?void 0:f.jwt),await this.isLoggedIn(),this.broadcastEvents.send(Pa),c(),u=!0,s.port1.close(),o()}catch(h){i(h)}};let p=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");p===null&&i(new Error("Popup blocked by browser"));let d=async y=>{var v;if(y.origin===l.origin)switch((v=y.data)==null?void 0:v.type){case"deepdesk-popup-loaded":{p==null||p.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[s.port2]);break}case"deepdesk-popup-error":{c(),y.data.message==="Timeout"&&H.warn("Popup timed out. Check if the account's platform url is configured correctly."),i(new Error(y.data.message));break}}};window.addEventListener("message",d);let g=setInterval(()=>{p&&!p.closed||(c(),u||i(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})}async checkForTrialMode(t){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(H.info("Trial is active"),!await this.deepdeskApi.checkUserExists(t))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;H.info(r),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=ad(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch($t()):this.store.dispatch(Vt(r))})}catch(r){this.handleError(r)}}};async function PC(e,t,n={}){let{value:r}=e,{start:o,end:i}=n.replace??{start:0,end:r.length},s=`${r.slice(0,o)}${t}${r.slice(i)}`,a=n.selectionAfter??{start:o+t.length,end:o+t.length},l=()=>{if(n.setValue)return n.setValue(s);e.value=s};return Promise.resolve(l()).then(()=>{e.selectionStart=a.start,e.selectionEnd=a.end,e.blur(),e.focus()})}async function RC(e,t,n={}){let r=n.replace?Lr(e,n.replace.start,n.replace.end):Ui(e),o,i=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),o=document.createElement("span"),r.insertNode(o),n.insertBRs!==!1?t.split(`
|
|
26
26
|
`).reverse().forEach((s,a)=>{a>0&&r.insertNode(document.createElement("br")),r.insertNode(document.createTextNode(s))}):r.insertNode(document.createTextNode(t))};return Promise.resolve(i()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let s=n.selectionAfter?Lr(e,n.selectionAfter.start,n.selectionAfter.end):(r.collapse(!1),r),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(s)}if(!o)return;o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}function EA(e){let t=document.createElement("template");return t.innerHTML=e.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),t.content}function TA(e){let t=document.createDocumentFragment();return e.split(`
|
|
27
27
|
`).forEach((n,r)=>{r>0&&t.appendChild(document.createElement("br"));let o={index:0},i=0;for(;o=n.slice(i).match(/(\[([^\]]+)])\(([^)]+)\)/);){let s=document.createElement("a");s.href=o[3],s.setAttribute("target","_blank"),s.setAttribute("rel","noopener noreferrer"),s.appendChild(document.createTextNode(o[2])),t.appendChild(document.createTextNode(n.slice(i,i+o.index))),t.appendChild(s),i=i+o.index+o[0].length}t.appendChild(document.createTextNode(n.slice(i)))}),t}function IC(e,t){return!e.contains(t)||t===e?null:t.parentNode===e?t:IC(e,t.parentNode)}async function LC(e,t,{isBlock:n,isHTML:r}={}){let o;e.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0}));let i=()=>{let s=e.ownerDocument.defaultView??window,a=s.getSelection();if((!a||a.rangeCount===0)&&(e.focus(),a=s.getSelection()),!a||a.rangeCount===0)return;let l=a.getRangeAt(0);if(!l)return;o=document.createElement("span"),l.insertNode(o);let u=r?EA(t):TA(t);if(n){let c=IC(e,l.startContainer)??e.firstChild;e.insertBefore(u,(c==null?void 0:c.nextSibling)??null)}else l.insertNode(u),l.collapse(!1)};return Promise.resolve(i()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!o)try{o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}function AC(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function OC(e,t,n){await new zn(e).authenticateWithKey(t,n)}async function kA(e){let n=await(e.fetch??window.fetch)(e.url),r=await n.blob();return new File([r],e.name,{type:e.mimeType??n.headers.get("Content-Type")??"image/jpeg"})}async function NC(e,t){let n=await kA(t),r=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(e,"files",{configurable:!0,get:()=>[n]}),e.dispatchEvent(r)}finally{Object.hasOwn(e,"files")&&delete e.files}}return zC(PA);})();
|
|
28
28
|
/*! Bundled license information:
|