@deepdesk/deepdesk-sdk 10.3.1-beta.3 → 10.3.1-beta.4

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.
@@ -16,9 +16,9 @@ ${W.current.stack}
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||iR)();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(nR)||(s.innerHTML=this.convertLineBreaks(this.props.escapeHtml?(0,v_.default)(t):t)),s}extractAttributes(t){let{allowAttributes:n}=this.props,r={},o=0;return t.nodeType!==y_||!t.attributes||([...t.attributes].forEach(i=>{let{name:s,value:a}=i,l=s.toLowerCase(),u=Nc[l]||Nc[s];if(!this.isSafe(t)||!l.match(rR)&&(!n&&(!u||u===cg)||l.startsWith("on")||a.replace(/(\s|\0|&#x0([9AD]);)/,"").match(/(javascript|vbscript|livescript|xss):/i)))return;let c=l==="style"?this.extractStyleAttribute(t):a;u===vr?c=!0:u===no?c=Number.parseFloat(String(c)):u!==Oc&&(c=String(c)),r[dg[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 ma[t]?{...n,...ma[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===y_){let d=c.nodeName.toLowerCase(),y=this.getTagConfig(d);u&&(l.push(u),u="");let S=this.applyNodeFilters(d,c);if(!S)return;let h;if(s&&!(a&&!this.isTagAllowed(d))){this.keyIndex+=1;let g=this.keyIndex;h=this.parseNode(S,y);let m=s(S,h,y);if(m===null)return;if(typeof m<"u"){l.push(oo.default.cloneElement(m,{key:g}));return}this.keyIndex=g-1}if(this.banned.has(d))return;if(!(r||o&&d!=="br")&&this.isTagAllowed(d)&&(i||this.canRenderChild(n,y))){var f;this.keyIndex+=1;let g=this.extractAttributes(S),m={tagName:d};g&&(m.attributes=g),y.void&&(m.selfClose=y.void),l.push(oo.default.createElement(Mc,{...m,key:this.keyIndex},(f=h)!==null&&f!==void 0?f:this.parseNode(S,y)))}else l=[...l,...this.parseNode(S,y.tagName?y:n)]}else if(c.nodeType===tR){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(oR);){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:f,props:d}=n[a],y;if(u)y=s.length,r.push(f.createElement(c,d));else{let S=o.match(new RegExp(`{{{/${a}}}}`));y=S.index+S[0].length,r.push(f.createElement(this.replaceTokens(o.slice(s.length,S.index),n),d))}o=o.slice(y)}return o.length>0&&r.push(o),r.length===0?"":r.length===1&&typeof r[0]=="string"?r[0]:r}};function sR(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",f=c==="fragment"?!0:u,d;if(a)d=a;else{let y=new Dc(i??"",e).parse();y.length>0&&(d=y)}return d||(d=s),f?oo.default.createElement(oo.default.Fragment,null,d):oo.default.createElement(Mc,{attributes:n,className:r,tagName:c},d)}function fi(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:f="span",noWrap:d=!1,...y}=e,S=i?[]:l,h=o?[]:a,g=c?[c]:[],m=u?[u]:[];S.forEach(C=>{C.onBeforeParse&&g.push(C.onBeforeParse.bind(C)),C.onAfterParse&&m.push(C.onAfterParse.bind(C))});let p=g.reduce((C,E)=>E(C,e),r??""),v=new Dc(p,y,S,h),_=m.reduce((C,E)=>E(C,e),v.parse());return oo.default.createElement(sR,{attributes:t,className:n,containerTagName:e.containerTagName,emptyContent:s,noWrap:d,parsedContent:_.length===0?void 0:_,tagName:f})}var wg=x(X());var pg={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var x_=x(X());var pi=x(O());function S_(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function Fc(e){let t=(0,pi.useRef)(null),[n,r]=(0,pi.useState)(!1);return(0,pi.useEffect)(()=>{let o=!1,i=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[s,a]=S_((c,f)=>{let d=t.current;if(!d)return;let y=c/i,S=f/i,h=d.getBoundingClientRect(),g=y>h.x&&y<h.x+h.width&&S>h.y&&S<h.y+h.height;g&&!o?(o=!0,r(!0)):!g&&o&&(o=!1,r(!1))},({clientX:c,clientY:f})=>[c,f]),[l,u]=S_(()=>{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 Tt={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 mg=x(w()),aR=({inputElement:e,children:t})=>{let n=k("TabCompletion",Tt),[r,o]=Fc(e);return(0,mg.jsx)("mark",{ref:r,className:(0,x_.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},mi=class extends Ut{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,mg.jsx)(aR,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var gi=x(O());function jc(e){return e.contentEditable==="true"}function lR(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 __(e){let{selectionStart:t,selectionEnd:n}=jc(e)?lR(e):e;return[t,n]}function Hc(e){let[,t]=(0,gi.useState)(),n=(0,gi.useRef)(null);return n.current=__(e),(0,gi.useEffect)(()=>{let r=()=>{let[o,i]=n.current??[],s=__(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 Bc(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(xo);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 w_=x(O());function Sr(e){(0,w_.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function io(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}var E_,on=new Map,uR=["bottom","height","left","right","top","width"],cR=(e={},t={})=>uR.some(n=>e[n]!==t[n]);function C_(e){var n,r;let t=((r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)??null;return t?[t,...C_(t)]:[]}function b_(e,t){return!e||!t?null:{...e,top:e.top+t.top,left:e.left+t.left}}var gg=!1,T_=()=>{gg=!0;let e=[];on.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),on.delete(n);return}let r=n.getBoundingClientRect();cR(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(b_,t.rect):t.rect;t.callbacks.forEach(r=>r(n))}),on.size!==0&&(E_=window.requestAnimationFrame(T_))};function hg(e,t){let n=C_(e),r=[],o=n.map((i,s)=>hg(i,a=>{r[s]=a;let l=on.get(e);if(!l)return;let u=r.reduce(b_,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),on.has(e)){let s=on.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else on.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!gg&&T_()},unobserve(){o.forEach(s=>s.unobserve());let i=on.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||on.delete(e),on.size||(cancelAnimationFrame(E_),gg=!1)}}}}var k_,sn=new Map,P_=()=>{sn.forEach((e,t)=>{if(!t.isConnected){sn.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)))}),sn.size!==0&&(k_=window.requestAnimationFrame(P_))};function R_(e,t){return{observe(){let n=sn.size===0;sn.has(e)?sn.get(e).callbacks.push(t):sn.set(e,{visible:void 0,callbacks:[t]}),n&&P_()},unobserve(){let n=sn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||sn.delete(e),sn.size||cancelAnimationFrame(k_)}}}}var yg=["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 vg(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function hi(e){return parseFloat(e)}function Uc(e){return Math.round(e*1e6)}function I_(e){return e/1e6}function Sg(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=hi(e.width),i=hi(e.borderLeftWidth),s=hi(e.borderRightWidth),a=hi(e.paddingRight),l=I_(Uc(o)-Uc(i)-Uc(s)),u=I_(Uc(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function so(e,t={}){var l;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",io(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};vg(r,n,yg),Sg(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=R_(e,()=>{vg(r,n,yg),Sg(r,e,n),i(),setTimeout(i,0)}),a=hg(e,u=>{if(u===null){t.onRemove&&t.onRemove(),n.remove();return}if(u.height===0&&u.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(vg(r,n,yg),Sg(r,e,n),i(),n.style.top=`${u.top}px`,n.style.left=`${u.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let c=t.closestScrollElement.getBoundingClientRect(),f=window.getComputedStyle(t.closestScrollElement),d=hi(f.borderTopWidth),y=hi(f.borderBottomWidth),S=c.top+d-u.top,h=u.top+u.height+-(c.top+c.height-y);n.style.clipPath=`inset(${S}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(l=e.parentElement)==null||l.appendChild(n),a.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),a.unobserve(),s.unobserve()}]}var xg={};Ce(xg,{enUS:()=>dR,nlNL:()=>fR});var dR={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"}]},fR={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 ga=x(w()),L_=()=>(0,ga.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,ga.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,ga.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 _g=x(w()),A_=()=>(0,_g.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,_g.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});function pR(e){let t=e.scrollHeight>e.clientHeight,r=window.getComputedStyle(e).overflowY.indexOf("hidden")!==-1;return t&&!r}function zc(e){return e?e instanceof ShadowRoot?zc(e.host):e===e.ownerDocument.body?e.ownerDocument:pR(e)?e:zc(e.parentNode):document.body}var O_=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(O_||{}),Tn=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();gr(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(O_).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",r=>this.handleKeyDown(r)),this.addEventListener("keyup",r=>this.handleKeyUp(r)),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",r=>this.handlePaste(r)),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()});let n=zc(this.element);if(n){let r=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};n.addEventListener("scroll",r),this.disposeHandlers.push(()=>{n.removeEventListener("scroll",r)})}}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 kn=class extends Tn{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 Qe=x(w()),mR=({value:e,onUse:t,...n})=>{var c;let r=j(xg),o=B(),i=k("EditSuggestionTextInput",pg),[s,a]=(0,kt.useState)(null),l=(0,kt.useRef)(null),u=((c=e.match(xo))==null?void 0:c.length)||0;return(0,kt.useEffect)(()=>{let f;return l.current&&(a(l.current),f=new kn(l.current),f.on("change",({plainText:d})=>{o(Xe.actions.userInput({text:d,selection:f.getSelection()}))}),f.on("keydown",d=>{o(Xe.actions.registerKeyDown(Ec(d))),d.code==="Enter"&&d.shiftKey&&t(f.getText())}),f.on("paste",({pastedText:d,selectionText:y})=>{o(Xe.actions.registerPaste({text:d,selectionText:y}))}),f.on("cut",({selectionText:d})=>{o(Xe.actions.registerCut(d))})),()=>{o(Xe.actions.reset()),f.dispose(),f.deactivate()}},[l]),(0,kt.useEffect)(()=>{e&&l.current&&(l.current.value=e)},[e,l]),(0,kt.useEffect)(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let f=l.current.value.length;l.current.setSelectionRange(f,f),l.current.focus()},0)},[l]),(0,Qe.jsxs)("div",{className:i.textInputWrapper,children:[(0,Qe.jsx)("textarea",{...n,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:e,onChange:()=>{}}),s&&(0,Qe.jsx)(gR,{inputElement:l.current,value:e}),(0,Qe.jsxs)("div",{className:(0,wg.default)(i.alert,u===0?i.success:i.warning),children:[(0,Qe.jsx)("div",{className:i.alertText,children:r("placeholders",{placeholderSize:u})}),u===0?(0,Qe.jsx)(L_,{}):(0,Qe.jsx)(A_,{})]})]})},gR=({inputElement:e,value:t})=>{let n=k("EditSuggestionTextInput",pg),r=(0,kt.useRef)(null),o=Hc(e);return(0,kt.useEffect)(()=>{Bc(e,o)},[o,e]),(0,Qe.jsx)(hR,{inputElement:e,children:(0,Qe.jsxs)("div",{ref:r,className:(0,wg.default)(n.root,n.agentText),children:[(0,Qe.jsx)(fi,{tagName:"span",disableLineBreaks:!0,content:t,matchers:[new mi("placeholders")],inputElement:e,boundaryRef:r}),(0,Qe.jsx)("br",{})]})})},hR=({inputElement:e,children:t})=>{let n=(0,kt.useRef)(null);return(0,kt.useEffect)(()=>{if(!n.current)return()=>{};let[r,o]=so(e,{overlayContainer:n.current,mirrorOverflow:!0});return r.setAttribute("translate","no"),()=>{o()}},[n.current]),(0,Qe.jsx)("div",{ref:n,children:t})},N_=mR;var Si=x(O());var M_=x(O()),Vc=x(X());var Ye={root:"_root_185k9_1",list:"_list_185k9_2",listWrapper:"_listWrapper_185k9_6",listHorizontal:"_listHorizontal_185k9_10",page:"_page_185k9_19",search:"_search_185k9_25",pageNav:"_pageNav_185k9_33",pageTitle:"_pageTitle_185k9_41",pageBackButton:"_pageBackButton_185k9_48",listHeading:"_listHeading_185k9_62",listItem:"_listItem_185k9_70",listItemContent:"_listItemContent_185k9_79",listItemText:"_listItemText_185k9_97",listItemDescription:"_listItemDescription_185k9_105",truncate:"_truncate_185k9_112",lineClamp:"_lineClamp_185k9_118",listItemTitle:"_listItemTitle_185k9_125",listItemAction:"_listItemAction_185k9_132",listItemPrimaryAction:"_listItemPrimaryAction_185k9_146",listItemSelected:"_listItemSelected_185k9_151",sources:"_sources_185k9_155",sourcesTitle:"_sourcesTitle_185k9_162",source:"_source_185k9_155",icon:"_icon_185k9_177",searchIcon:"_searchIcon_185k9_194",searchInputWrapper:"_searchInputWrapper_185k9_199",searchInput:"_searchInput_185k9_199",select:"_select_185k9_220",selectType:"_selectType_185k9_237",selectWrapper:"_selectWrapper_185k9_241",image:"_image_185k9_271",imageSrc:"_imageSrc_185k9_278",imageSrcHidden:"_imageSrcHidden_185k9_289",imageSrcStatus:"_imageSrcStatus_185k9_293",imageTitle:"_imageTitle_185k9_303",actions:"_actions_185k9_308",actionsWrapper:"_actionsWrapper_185k9_312",actionsBar:"_actionsBar_185k9_318",actionButton:"_actionButton_185k9_327",actionShortcut:"_actionShortcut_185k9_345",actionShortcutFixKerning:"_actionShortcutFixKerning_185k9_352"};var ao={};Ce(ao,{enUS:()=>yR,nlNL:()=>vR});var yR={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=x(w()),SR=({src:e,title:t})=>{let n=k("CommandPalette",Ye),[r,o]=(0,M_.useState)("loading"),i=j(ao);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,Vc.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(r)})}),r==="loading"&&(0,xr.jsx)("span",{className:(0,Vc.default)(n.imageSrc,n.imageSrcStatus),children:i("loading")}),r==="error"&&(0,xr.jsx)("span",{className:(0,Vc.default)(n.imageSrc,n.imageSrcStatus),children:(0,xr.jsx)(Za,{})}),t&&(0,xr.jsx)("span",{className:n.imageTitle,children:t})]})},D_=SR;var F_=x(O()),j_=x(X());var ha=x(w());function Eg({children:e,heading:t,orientation:n}){let r=k("CommandPalette",Ye);return F_.default.Children.count(e)===0?null:(0,ha.jsxs)("div",{"data-testid":"commandpalette-list",className:r.list,children:[t&&(0,ha.jsx)("h4",{className:r.listHeading,children:t}),(0,ha.jsx)("div",{className:(0,j_.default)(r.listWrapper,n==="horizontal"&&r.listHorizontal),children:e})]})}var ya=x(X());var Kc=x(O()),U_=x(w()),H_=Kc.default.createContext(void 0);function _r(){let e=Kc.default.useContext(H_);if(e===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return e}var B_=({children:e,page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i})=>{let s=Kc.default.useMemo(()=>({page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i}),[n,t,o]);return(0,U_.jsx)(H_.Provider,{value:s,children:e})};var Pt=x(w());function Cg({closeOnSelect:e=!0,lineClamp:t,children:n,onClick:r,onSourceClick:o,index:i,isExperimental:s,description:a,sources:l,styles:u,...c}){let{selected:f,onChangeOpen:d}=_r(),y=k("CommandPalette",Ye);function S(h){r(h),e&&d(!1)}return(0,Pt.jsxs)("div",{className:(0,ya.default)(y.listItem,f===i&&y.listItemSelected),children:[(0,Pt.jsxs)("button",{type:"button",className:(0,ya.default)("command-palette-list-item",y.listItemAction,y.listItemPrimaryAction),"aria-disabled":c.disabled??!1,onClick:S,...c,children:[(0,Pt.jsxs)("div",{className:y.listItemContent,children:[typeof n=="string"?(0,Pt.jsx)("p",{className:(0,ya.default)(y.listItemText,y.truncate,u==null?void 0:u.title),children:n}):n,a&&(0,Pt.jsx)("p",{className:(0,ya.default)(y.listItemDescription,u==null?void 0:u.description,t?y.lineClamp:y.truncate),children:a})]}),s&&(0,Pt.jsx)(hl,{})]}),l&&(0,Pt.jsxs)("div",{className:y.sources,children:[(0,Pt.jsx)("span",{className:y.sourcesTitle,children:"Sources"}),l.map(h=>h.url?(0,Pt.jsx)("a",{className:y.source,href:h.url,target:"_blank",title:h.url,rel:"noopener noreferrer",onClick:()=>o&&o(h),children:h.name},h.url):(0,Pt.jsx)("span",{className:y.source,children:h.name},h.name))]})]})}var wr=x(w());function bg({children:e,title:t,id:n,onDismiss:r,isExperimental:o}){let i=j(ao),s=k("CommandPalette",Ye),{page:a}=_r();return a!==n?null:(0,wr.jsxs)("div",{className:s.page,id:`page_${n}`,tabIndex:-1,children:[r&&(0,wr.jsxs)("div",{className:s.pageNav,children:[(0,wr.jsxs)("button",{className:s.pageBackButton,type:"button",onClick:r,children:[(0,wr.jsx)(Rc,{}),i("back")]}),t&&(0,wr.jsx)("h3",{className:s.pageTitle,children:t}),o&&(0,wr.jsx)(hl,{})]}),e]})}var Er=x(O());var Wc=()=>/Mac/i.test(navigator.platform);var xR={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},U=xR;function _R(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function re(e){return Array.isArray(e)?e.map(re):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[_R(n)]:re(e[n])}),{}):e}function Tg(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function we(e){return Array.isArray(e)?e.map(we):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[Tg(n)]:we(e[n])}),{}):e}var wR={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Sa=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)||""}},va=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?re(r):(await n.client.patch("/apis/admin/session/me/",o,{version:null}),re(r))}),kg=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}),Pg=M("info/getAgentSettings",async(e,t)=>{let{deepdeskAPI:n}=t.extra;return(await n.client.get("/apis/admin/session/me/",{version:null})).ui_config}),z_=e=>e.info.agentInfo,V_=H({name:"info",initialState:wR,reducers:{setVisitorInfo(e,t){e.visitorInfo={...e.visitorInfo,...t.payload}}},extraReducers:e=>{e.addCase(va.pending,(t,n)=>{t.fetchState="loading",t.agentInfo={...t.agentInfo,...n.meta.arg}}).addCase(va.rejected,t=>{t.fetchState="error"}).addCase(va.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(kg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(Pg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(J,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:K_}=V_.actions,W_=V_.reducer;var $c={list:[],fetchState:"idle",isOpen:!1,page:"search"},$_=e=>e.search.isOpen,q_=e=>e.search.page,G_=e=>e.search.list;function X_(e,t=n=>n){return n=>n.search.list.filter(r=>r.type===e).map(t)}var lo=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:Sa(r),tags:e.tags});return i.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:e.query}))}),Q_=H({name:"search",initialState:$c,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=$c.fetchState,e.list=$c.list}},extraReducers:e=>{e.addCase(lo.pending,t=>{t.fetchState="loading"}).addCase(lo.rejected,(t,n)=>{t.fetchState="error",U.error(n.error)}).addCase(lo.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload}).addCase(J,()=>$c)}}),{resetSearch:qc,setIsOpen:at,setPage:ze}=Q_.actions,Y_=Q_.reducer;var ER=/(https?:\/\/[^\s]+)/,Gc=e=>e.split(" ").find(t=>ER.test(t));var Rg=x(X());var Xc=x(w()),CR=({onClick:e,shortKeys:t,children:n,...r})=>{let o=k("CommandPalette",Ye);return(0,Xc.jsxs)("button",{type:"button",...r,onClick:e,className:(0,Rg.default)(o.actionButton,r.className),children:[n,t&&t.map(i=>(0,Xc.jsx)("span",{className:(0,Rg.default)(o.actionShortcut,i===8629&&o.actionShortcutFixKerning),children:typeof i=="number"?String.fromCharCode(i):i},i))]})},yi=CR;var Pn=x(w()),bR=({children:e,primaryLabel:t,secondaryLabel:n,onPrimary:r,onSecondary:o,list:i})=>{let s=k("CommandPalette",Ye),a=j(ao),{selected:l,setSelected:u}=_r(),c=i[l],f=c&&typeof c.text=="string"&&Gc(c.text),d=(0,Er.useRef)(null);function y(v){if(!d.current)return;let _=d.current.querySelectorAll(".command-palette-list-item"),C=0,E=0;v==="down"?(_.forEach((R,P)=>{P===l&&(C=P)}),E=C===_.length-1?0:C+1):v==="up"?(_.forEach((R,P)=>{P===l&&(C=P)}),E=C?C-1:_.length-1):u(0);let b=_[E];b&&typeof E=="number"&&(u(E),b.scrollIntoView&&b.scrollIntoView({behavior:"smooth",block:E?"center":"end"}))}function S(){if(!d.current)return;let v=d.current.querySelectorAll(".command-palette-list-item"),_=0;v.forEach((E,b)=>{b===l&&(_=b)});let C=v[_];C&&C.click()}let h=()=>{f&&window.open(f,"_blank")},g=()=>{c&&r(c,l)},m=()=>{!c.type||["IMAGE","command"].includes(c.type)||o&&o(c,l)},p=(0,Er.useCallback)(v=>{if(v.key==="Enter"&&v.altKey&&f){h();return}if(v.key==="Enter"&&v.shiftKey){m();return}if(v.key==="ArrowDown"){v.preventDefault(),v.stopPropagation(),y("down");return}if(v.key==="ArrowUp"){v.preventDefault(),v.stopPropagation(),y("up");return}v.key==="Enter"&&l!==-1&&(v.preventDefault(),v.stopPropagation(),S())},[l]);return(0,Er.useEffect)(()=>(window.addEventListener("keyup",p),()=>{window.removeEventListener("keyup",p)}),[p]),(0,Pn.jsxs)("div",{className:s.actions,children:[(0,Pn.jsx)("div",{className:s.actionsWrapper,ref:d,children:e}),(0,Pn.jsxs)("div",{className:s.actionsBar,children:[f&&(0,Pn.jsx)(yi,{onClick:h,shortKeys:[Wc()?8997:"ALT",8629],children:a("visitUrl")}),c&&(0,Pn.jsxs)(Er.Fragment,{children:[o&&c.type&&!["command","image"].includes(c.type.toLowerCase())&&(0,Pn.jsx)(yi,{onClick:m,shortKeys:[8679,8629],children:n}),(0,Pn.jsx)(yi,{onClick:g,shortKeys:[8629],children:t})]})]})]})},J_=bR;var ew=x(O());var xa=x(w()),vi=()=>(0,xa.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,xa.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,xa.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 zt=x(w());function TR({onChange:e,onChangeType:t,placeholder:n,typePlaceholder:r,types:o,value:i,selectedType:s},a){let l=k("CommandPalette",Ye);return(0,zt.jsxs)("div",{className:l.search,children:[(0,zt.jsx)("div",{className:l.searchIcon,children:(0,zt.jsx)(vi,{})}),(0,zt.jsxs)("div",{className:l.searchInputWrapper,children:[(0,zt.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,zt.jsx)("div",{className:l.selectWrapper,children:(0,zt.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,zt.jsx)("option",{children:r}),o.map(u=>(0,zt.jsx)("option",{value:u.value,children:u.label},u.value))]})})]})]})}var tw=(0,ew.forwardRef)(TR);var _a=x(w());function uo({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:f,search:d}){let[y,S]=(0,Si.useState)(0),h=(0,Si.useRef)(null),g=()=>{o&&o(n),s(void 0),i(""),a(!1)},m=()=>{var p;if(r!==n&&o){o(n);return}if(l&&s){s(void 0),(p=h.current)==null||p.focus();return}if(d.length>0){i("");return}a(!1)};return(0,Si.useEffect)(()=>{S(0)},[d,r]),(0,_a.jsx)(di,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:f,onBack:m,onClose:g,children:(0,_a.jsxs)(B_,{selected:y,setSelected:S,isOpen:f,onChangeOpen:a,page:r,children:[r===n&&(0,_a.jsx)(tw,{ref:h,onChange:i,onChangeType:s,placeholder:e,value:d,selectedType:l,types:u,typePlaceholder:t}),c]})})}uo.Page=bg;uo.List=Eg;uo.Image=D_;uo.ListItem=Cg;uo.ActionsBar=J_;uo.Button=yi;var te=uo;var Fe=x(w()),kR=({suggestion:e,onUse:t,onDismiss:n,onTouched:r,onNext:o,onPrevious:i})=>{let s=e.text||e.url||e.message,a=k("EditSuggestionForm",f_),l=B(),u=j(og),c=L(S=>S.overlayInput.text);(0,Ig.useEffect)(()=>{e&&(l(Xe.actions.reset()),l(Xe.actions.stageSuggestion({text:s,suggestion:e,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Xe.actions.commitSuggestion()))},[e]);let f=S=>{S.preventDefault(),d(c)},d=S=>{l(Tc(S)),t(S)},y=S=>h=>{c!==s?window.confirm(u("warning"))&&S(h):S(h)};return(0,Ig.useEffect)(()=>{r&&r(c!==s)},[r,e,c]),(0,Fe.jsxs)("div",{className:a.root,children:[(0,Fe.jsxs)("div",{className:a.content,children:[e.title&&(0,Fe.jsx)("h3",{className:a.title,children:e.title}),e.searchKeywords&&e.searchKeywords.length>0&&(0,Fe.jsx)(Qd,{labels:e.searchKeywords}),(0,Fe.jsx)(N_,{onUse:d,value:c})]}),(0,Fe.jsxs)("form",{className:a.actions,onSubmit:f,children:[(0,Fe.jsxs)("div",{children:[(0,Fe.jsx)("button",{disabled:!i,className:a.pagination,type:"button",onClick:i&&y(i),children:(0,Fe.jsx)(Rc,{})}),(0,Fe.jsx)("button",{disabled:!o,className:a.pagination,type:"button",onClick:o&&y(o),children:(0,Fe.jsx)(p_,{})})]}),(0,Fe.jsxs)("div",{className:a.primaryButtons,children:[(0,Fe.jsx)(te.Button,{onClick:y(n),shortKeys:["esc"],children:u("dismiss")}),(0,Fe.jsx)(te.Button,{shortKeys:[8679,8629],type:"submit",children:u("add")})]})]})]})},Qc=kR;var PR=["{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}"],RR=new RegExp(PR.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function nw(e,t){let n=e.split(RR),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 f=a.charAt(0),d=0;do u=f?t.indexOf(f,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 rw(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var iw={suggestions:[],fetchState:"idle",isInitialRequest:null},ow={default:iw},sw=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)||[]},aw=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)??[]},lw=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")},xi=e=>e.textSuggestions,uw=e=>t=>t.text.startsWith(e),Yc=fe("textSuggestions/refresh"),Rn=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=ui(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getTextSuggestions(o,Sa(r),e);if(e==="default"){let c=s?l.filter(uw(a)):l;t.dispatch(Cn(c.slice(0,i)))}return l}),wa=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,{...Sa(r),input:e});if(!t.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(uw(e))),s&&(l=l.map(c=>({...c,text:c.source!=="trie-with-typos"?nw(c.text,e):c.text}))),l=rw(l,i),t.dispatch(Cn(l)),l}),cw=H({name:"textSuggestions",initialState:ow,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(Rn.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||iw;return{...t,[r]:{...o,fetchState:"loading",isInitialRequest:o.isInitialRequest===null}}}).addCase(Rn.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(Rn.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(wa.pending,t=>{t.default.fetchState="loading"}).addCase(wa.rejected,t=>{t.default.fetchState="error"}).addCase(wa.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(J,()=>ow)}}),{setTextSuggestions:dw,setSuggestionState:fw}=cw.actions,pw=cw.reducer;var mw={contentType:null,suggestion:null},gw=e=>e.activeSuggestion.suggestion,hw=e=>e.activeSuggestion.contentType,yw=H({name:"activeSuggestion",initialState:mw,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(J,()=>mw)}}),{setActiveSuggestion:In,resetActiveSuggestion:Lg}=yw.actions,vw=yw.reducer;var Ag={};Ce(Ag,{enUS:()=>IR,nlNL:()=>LR});var IR={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"}]},LR={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 AR={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Zc=({ui:e})=>e.overlayCollapsed;var Sw=H({name:"ui",initialState:AR,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:_i,setOverlayCollapsed:Cr,setOpenOverlayWhenTyping:xw,setOverlayCollapsedUserOverwrite:_w}=Sw.actions,ww=Sw.reducer;var Ca=x(O()),Cw=x(w()),Ew=Ca.default.createContext(null),wi=({broadcastEvents:e,children:t})=>{let n=Ca.default.useMemo(()=>e,[]);return(0,Cw.jsx)(Ew.Provider,{value:n,children:t})},Rt=()=>{let e=(0,Ca.useContext)(Ew);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var OR={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Vt=e=>e.auth.isLoggedIn,bw=e=>e.auth.loginFetchState,Tw=e=>e.auth.verifyFetchState,kw=e=>e.auth.showLoginOverlay,br=M("auth/validate",async(e,t)=>t.extra.deepdeskAPI.isLoggedIn()),Pw=M("auth/requestLogin",async({email:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.requestLoginByEmail(e)}),ba=M("auth/verifyLoginToken",async({token:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.verifyLoginToken(e)}),Rw=H({name:"auth",initialState:OR,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload}},extraReducers:e=>{e.addCase(br.pending,t=>{t.loginFetchState="loading"}),e.addCase(br.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(br.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(ba.pending,t=>{t.verifyFetchState="loading"}),e.addCase(ba.rejected,t=>{t.verifyFetchState="error"}),e.addCase(ba.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:Ei,setShowLoginOverlay:Iw}=Rw.actions,Lw=Rw.reducer;var Og="SetActiveSuggestion",Ci="ShowLoginOverlay",Ng="UserLoggedIn",NR="UserLoggedOut",Ln="ApplySuggestion",Mg="ApplyImageSuggestion",MR="ShowCommandPalette",DR=e=>({[Og]:t=>{e.dispatch(fw(t.state)),e.dispatch(In({contentType:t.contentType,suggestion:t.suggestion}))},[MR]:t=>{e.dispatch(at(t.isOpen)),t.page&&e.dispatch(ze(t.page))},[Ci]:t=>{e.dispatch(Iw(t))},[Ng]:()=>{e.dispatch(br())},[NR]:()=>{e.dispatch(br())},[Mg]:t=>{e.dispatch(Pc({suggestion:t.suggestion}))},[Ln]:t=>{e.dispatch(Ht({...t,eventMetrics:{inputType:"mouse"},replace:"selection"})),e.dispatch(yr())}}),Aw=DR;var Dg=x(w()),FR=()=>{var S;let[e,t]=(0,Ow.useState)(!1),n=L(gw),r=L(hw),o=L(xi),i=B(),s=Rt(),a=j(Ag),l=()=>{n!==null&&e?window.confirm(a("warning"))&&u():u()},u=()=>{i(Lg()),i(_i(!0)),i(Xe.actions.reset())},c=(h,g)=>{i(Lg()),i(_i(!0)),s.send(Ln,{text:h,suggestion:{...g,source:`${g.source||"text_recommendation"}-preview`}})};if(n===null||r===null)return null;let f=(S=o[r])==null?void 0:S.suggestions.indexOf(n),d=f===0||f===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[f-1]})),y=f===o[r].suggestions.length-1||f===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[f+1]}));return(0,Dg.jsx)(di,{autoFocus:!0,isOpen:f!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Dg.jsx)(Qc,{onTouched:t,onDismiss:u,onUse:h=>c(h,n),suggestion:n,onNext:y,onPrevious:d})})},Nw=FR;var Jc=x(X()),Kt=x(O());var Dw=x(X());var Mw={root:"_root_1ukx5_1"};var Fw=x(w()),jR=({className:e,value:t,...n})=>{let r=k("TextInput",Mw);return(0,Fw.jsx)("input",{className:(0,Dw.default)(e,r.root),type:"text",value:t,...n})},Ta=jR;var Fg={};Ce(Fg,{enUS:()=>HR,nlNL:()=>BR});var HR={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"}]},BR={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 jw={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 he=x(w());var UR=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch{return e}},zR=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=j(Fg),s=k("LoginTokenDialog",jw),a=L(Tw),l=B(),u=D("productName"),[c,f]=(0,Kt.useState)(e||""),[d,y]=(0,Kt.useState)(0),[S,h]=(0,Kt.useState)(""),g=(0,Kt.useCallback)(async _=>{_.preventDefault(),l(Pw({email:c})),y(1)},[n,c]),m=()=>{h(""),y(0)},p=(0,Kt.useCallback)(async _=>{_.preventDefault();let C=UR(_.target.elements.token.value);if(!C){h(i("verifyCodeError",{login:v}));return}l(ba({token:C}))},[n]),v=(0,Kt.useMemo)(()=>_=>(0,he.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:m,children:_},"back-button"),[]);return(0,Kt.useEffect)(()=>{a==="error"&&h(i("verifyCodeError",{login:v})),a==="done"&&r()},[a]),(0,he.jsx)(di,{autoFocus:!0,isOpen:t,contentAriaLabel:i("promptTitle",{productName:u}),overlayAriaLabel:i("promptTitle",{productName:u}),onClose:o,onBack:o,children:(0,he.jsxs)("div",{className:s.root,children:[(0,he.jsx)("h1",{className:s.title,children:i("promptTitle",{productName:u})}),d===0&&(0,he.jsxs)("form",{onSubmit:g,children:[(0,he.jsx)("h2",{className:s.subtitle,children:i("requestCodeTitle")}),(0,he.jsx)("p",{className:s.text,children:i("requestCodeBody",{productName:u})}),(0,he.jsx)(Ta,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:c,onChange:_=>f(_.target.value)}),(0,he.jsx)("div",{className:s.actions,children:(0,he.jsx)("button",{type:"submit",className:(0,Jc.default)(s.button,s.primaryButton),children:i("requestCodeSubmitLabel")})})]}),d===1&&(0,he.jsxs)("form",{onSubmit:p,children:[(0,he.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,he.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,he.jsx)(Ta,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),S&&(0,he.jsx)("div",{className:s.errorMessage,children:S}),(0,he.jsxs)("div",{className:s.actions,children:[(0,he.jsx)("button",{type:"button",className:(0,Jc.default)(s.button),onClick:m,children:i("back")}),(0,he.jsx)("button",{type:"submit",className:(0,Jc.default)(s.button,s.primaryButton),disabled:["loading","done"].includes(a),children:i("verifyCodeSubmitLabel")})]})]})]})})},Hw=zR;var Uw=x(w()),VR=()=>{let e=L(kw),t=L(z_),n=D("adminUrl"),r=Rt(),o=()=>r.send(Ci,!1),i=()=>{r.send(Ci,!1),r.send(Ng)};return(0,Uw.jsx)(Hw,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},Bw=VR;var p1=x(Bg()),Je=x(O());var aI={data:null,fetchState:"idle"},Ww=e=>e.contentTypes.data,ka=M("contentTypes/getContentTypes",async(e,t)=>t.extra.deepdeskAPI.getContentTypes()),lI=H({name:"contentTypes",initialState:aI,reducers:{},extraReducers:e=>{e.addCase(ka.pending,t=>{t.fetchState="loading"}).addCase(ka.rejected,t=>{t.fetchState="error"}).addCase(ka.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),$w=lI.reducer;function Pa(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 qw=x(O());function Gw(e,t){(0,qw.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 Ra=x(O());var Xw={data:null,fetchState:"idle"},ed=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},Wt=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)}),uI=e=>e.filter((t,n)=>n===e.findIndex(r=>r.text===t.text)),cI=H({name:"entities",initialState:Xw,reducers:{},extraReducers:e=>{e.addCase(Wt.pending,t=>{t.fetchState="loading"}).addCase(Wt.rejected,t=>{t.fetchState="error"}).addCase(Wt.fulfilled,(t,n)=>{t.fetchState="done",t.data=uI(t.data?[...t.data,...n.payload]:n.payload)}).addCase(J,()=>Xw)}}),Qw=cI.reducer;var Ug={};Ce(Ug,{enUS:()=>dI,nlNL:()=>fI});var dI={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},fI={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Yw={root:"_root_17kae_1",empty:"_empty_17kae_5"};var co=x(w()),pI=({onCopy:e,onUse:t})=>{let n=(0,Ra.useRef)(null),r=k("EntitiesList",Yw),o=j(Ug),i=L(ed),s=B();return(0,Ra.useEffect)(()=>{s(Wt())},[]),(0,Ra.useEffect)(()=>{n.current&&n.current.focus()},[n]),(0,co.jsxs)("div",{className:r.root,ref:n,tabIndex:-1,children:[i&&i.length>0&&(0,co.jsx)(te.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,co.jsx)(te.List,{children:i.map((a,l)=>(0,co.jsx)(te.ListItem,{index:l,closeOnSelect:!0,onClick:()=>e(a),children:a.text},a.text))},"entities")}),i&&i.length===0&&(0,co.jsx)("p",{className:r.empty,children:o("noResults")})]})},Zw=pI;var $t=x(O());var Jw={data:null,fetchState:"idle"},e1=e=>e.summary.data,t1=e=>e.summary.fetchState==="error",An=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();return s.length===0?Promise.reject(new Error("No messages are included")):{summary:await r.getSummary(s,{promptInstruction:n.summarizerPromptInstruction,model:n.summarizerModel})}}),mI=H({name:"summary",initialState:Jw,reducers:{},extraReducers:e=>{e.addCase(An.pending,t=>{t.data=null,t.fetchState="loading"}).addCase(An.rejected,t=>{t.data=null,t.fetchState="error"}).addCase(An.fulfilled,(t,n)=>{t.fetchState="done",n.payload&&(t.data=n.payload.summary)}).addCase(J,()=>Jw)}}),n1=mI.reducer;var zg={};Ce(zg,{enUS:()=>gI,nlNL:()=>hI});var gI={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."}]},hI={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 r1={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 On=x(w()),yI=({onCopy:e})=>{let t=(0,$t.useRef)(null),n=k("SummaryForm",r1),[r,o]=(0,$t.useState)(""),i=j(zg),s=L(e1),a=L(t1),l=B(),u=()=>{l(st({name:"summary copied to clipboard",data:{originalText:s,finalText:r},options:{includeConversationData:!0}})),e(r)},c=()=>{let f=document.getSelection();f&&l(st({name:"summary copied to clipboard",data:{originalText:s,finalText:f==null?void 0:f.toString()},options:{includeConversationData:!0}}))};return(0,$t.useEffect)(()=>{l(An())},[]),(0,$t.useEffect)(()=>{o(s||"")},[s]),(0,$t.useEffect)(()=>{t.current&&s&&t.current.focus()},[t,s]),(0,$t.useEffect)(()=>{let f=d=>{d.key==="Enter"&&d.shiftKey&&u()};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f)}},[r]),(0,On.jsx)("div",{className:n.root,tabIndex:-1,children:a?(0,On.jsx)("p",{className:n.error,children:i("error")}):(0,On.jsxs)($t.Fragment,{children:[(0,On.jsx)("div",{className:n.main,children:(0,On.jsx)("textarea",{placeholder:s?void 0:i("loading"),disabled:!s,className:n.textInput,ref:t,value:r,onCopy:c,onChange:f=>o(f.target.value)})}),(0,On.jsx)("div",{className:n.actions,children:(0,On.jsx)(te.Button,{shortKeys:[8679,8629],onClick:u,children:i("copy")})})]})})},o1=yI;var Vg={};Ce(Vg,{enUS:()=>vI,nlNL:()=>SI});var vI={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?"}]},SI={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 Tr=x(O());var Kg={};Ce(Kg,{enUS:()=>xI,nlNL:()=>_I});var xI={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"}]},_I={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 i1={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 Wg={data:[],fetchState:"idle"},s1=e=>{var t;return(t=e.answer)==null?void 0:t.data},a1=e=>e.answer.fetchState,Ti=fe("answer/resetKnowledgeSearch"),bi=M("answer/getAnswer",async(e,t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState().answer.data,o=(s=t.getState().conversation.current)==null?void 0:s.profileCode;if(!o)throw new Error("Profile is not defined");let i=await n.knowledgeAssist({promptInstruction:e.promptInstruction,question:e.question},r,o);return{question:e.question,answer:i}}),wI=H({name:"answer",initialState:Wg,reducers:{},extraReducers:e=>{e.addCase(bi.pending,t=>{t.fetchState="loading"}).addCase(bi.rejected,t=>{t.fetchState="error"}).addCase(bi.fulfilled,(t,n)=>{t.fetchState="done",t.data=[...t.data,n.payload]}).addCase(J,()=>Wg).addCase(Ti,()=>Wg)}}),l1=wI.reducer;var Ia=x(w()),u1=()=>(0,Ia.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Ia.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Ia.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 Ze=x(w()),EI=({onUse:e,onResetQuestion:t,question:n,promptInstruction:r})=>{let[o,i]=Tr.default.useState(""),{setSelected:s}=_r(),a=(0,Tr.useRef)(null),l=k("EntitiesList",i1),u=j(Kg),c=B(),f=L(s1),d=L(a1),y=async h=>{h.preventDefault(),h.stopPropagation(),o!==""&&c(bi({question:o,promptInstruction:r}))},S=(h,g)=>{c(st({name:"knowledge assist source viewed",data:{question:g,sourceViewed:h.url||h.name},options:{includeConversationData:!0}}))};return(0,Tr.useEffect)(()=>{var h;n&&d==="idle"?c(bi({question:n,promptInstruction:r})):(h=a.current)==null||h.focus()},[a,d]),(0,Tr.useEffect)(()=>{d==="done"&&(c(st({name:"knowledge assist question answered",data:{question:o||n,sources:f[f.length-1].answer.sources,answer:f[f.length-1].answer.answer,isFollowUpQuestion:f.length>1},options:{includeConversationData:!0}})),s(f.length-1),i(""))},[d,f]),(0,Tr.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,f]),(0,Ze.jsxs)("div",{className:l.root,children:[f.length>0&&(0,Ze.jsx)("div",{className:l.alignRight,children:(0,Ze.jsx)(te.Button,{onClick:t,children:u("reset")})}),(0,Ze.jsxs)(te.ActionsBar,{list:f.map(({answer:h})=>({text:h.answer,type:"answer"})),primaryLabel:u("use"),onPrimary:h=>e(h.text),children:[f.map(({question:h,answer:g},m)=>(0,Ze.jsx)(te.List,{children:(0,Ze.jsx)(te.ListItem,{"data-testid":"knowledge-search-answer",index:m,description:g.answer,closeOnSelect:!0,onClick:()=>e(g.answer),onSourceClick:p=>S(p,h),sources:g.sources,styles:{title:l.question,description:l.answer},children:h})},`${g.answer}_${m}`)),d==="loading"&&(0,Ze.jsx)("p",{className:l.status,children:u("loading")}),d==="error"&&(0,Ze.jsx)("p",{className:l.status,children:u("error")}),(0,Ze.jsxs)("form",{className:l.form,onSubmit:y,children:[(0,Ze.jsx)("input",{ref:a,placeholder:u("anotherQuestion"),className:l.input,type:"text",value:o,onFocus:()=>{s(-1)},onChange:h=>{s(-1),i(h.target.value)}}),(0,Ze.jsx)("button",{type:"submit",className:l.submit,children:(0,Ze.jsx)(u1,{})})]})]})]})},c1=EI;var CI={data:null,fetchState:"idle"},ki=e=>e.profile.data,td=e=>e.profile.data?e.profile.data.uiConfig.widget.types.filter(t=>t.isActive):[],La=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)}),bI=H({name:"profile",initialState:CI,reducers:{},extraReducers:e=>{e.addCase(La.pending,t=>{t.fetchState="loading"}).addCase(La.rejected,t=>{t.fetchState="error"}).addCase(La.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),d1=bI.reducer;var Ee=x(w()),TI=200,kI=5,PI=4,RI=e=>e.reduce((t,n)=>[...t,...n.list.map(r=>({...r,type:n.value}))],[]),f1=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),II=()=>{let e=B(),t=Rt(),n=j(Vg),[r,o]=(0,Je.useState)(!1),[i,s]=(0,Je.useState)(""),a=L(q_),l=L(ki),[u,c]=(0,Je.useState)(null),[f,d]=(0,Je.useState)([]),[y,S]=(0,Je.useState)(),h=L(Vt),g=D("showSearch"),m=D("showEntitiesCommand"),p=D("showSummaryCommand"),v=D("showKnowledgeSearch"),_=D("showImageSearch"),C=D("searchTriggerKey"),E=L(Ww),b=L(G_),R=L($_),P=I=>dn(b.filter(W=>W.type===I.toUpperCase()),I),N=[{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(I=>I.shouldShow),G=[{label:n("entitiesClipboard"),onClick:()=>e(ze("entities")),shouldShow:m&&f1(n("entitiesClipboard"),i),experimental:!0},{label:n("summaryClipboard"),onClick:()=>e(ze("summary")),shouldShow:p&&f1(n("summaryClipboard"),i),experimental:!0},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(ze("knowledgeAssist")),shouldShow:v,experimental:!0}].filter(I=>I.shouldShow),V=(E==null?void 0:E.map(I=>({value:I.code.toUpperCase(),label:`${I.name}s`,list:P(I.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],He=(0,Je.useCallback)((0,p1.default)((I,W)=>{e(lo({query:I,type:W,tags:["search-overlay"]}))},TI),[]),cn=RI([...V,...N]),Xt=(0,Je.useCallback)((I,W)=>{if(!W)return;let At=[...N,...V].find(({value:Un})=>Un===W);At&&(e(ze("edit")),c({...I,searchTerm:void 0}),d(At.list))},[e,u,V]),mo=(0,Je.useCallback)((I,W)=>{switch(W.type){case"IMAGE":t.send(Mg,{suggestion:W});break;default:t.send(Ln,{text:I,suggestion:W})}e(at(!1))},[e]),Bi=I=>{Pa(I.text),e(st({name:"entity copied",data:{entity:I,type:"copy"}})),e(at(!1))},Ar=I=>{t.send(Ln,{text:I,suggestion:{source:"knowledge-assist",text:I}}),e(st({name:"answer used",data:{originalText:I},options:{includeConversationData:!0}})),s(""),e(ze("search")),e(Ti()),e(at(!1))},Ka=I=>{Pa(I),e(at(!1))},Wa=I=>{t.send(Ln,{text:I.text,suggestion:{source:"entity",text:I.text}}),e(at(!1))},Ui=u===null||f.indexOf(u)-1<0?void 0:()=>c(f[f.indexOf(u)-1]),zi=u===null||f.indexOf(u)===f.length-1?void 0:()=>c(f[f.indexOf(u)+1]);function dn(I,W){return I.slice(0,y?10:W.toLowerCase()==="image"?PI:kI)}function Vi(I,W,At){return W.reduce((Un,fn)=>At&&y===At?fn.length+Un:dn(fn,At).length+Un,I)}function Or(I){return W=>{r?window.confirm(n("warning"))&&(I(W),o(!1)):I(W)}}return(0,Je.useEffect)(()=>{i?He(i,y):e(qc())},[i,y]),(0,Je.useEffect)(()=>{a==="search"&&e(Ti())},[a]),(0,Je.useEffect)(()=>{h&&e(ka())},[h]),Gw(C,()=>e(at(!0))),!g||!l?null:(0,Ee.jsxs)(te,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Or(I=>e(at(I))),onChangeType:I=>S(I),onChangePage:Or(I=>e(ze(I))),selectedType:y,search:i,page:a,isOpen:R,types:[...V,...N],children:[(0,Ee.jsx)(te.Page,{id:"search",children:(0,Ee.jsxs)(te.ActionsBar,{list:[...G.map(I=>({text:I.label,type:"command"})),...cn.map(I=>({text:I.text||I.url||I.message,type:I.type}))],primaryLabel:n("use"),secondaryLabel:n("preview"),onPrimary:({text:I},W)=>mo(I,cn[W]),onSecondary:(I,W)=>{Xt(cn[W-G.length],cn[W-G.length].type)},children:[G.length>0&&(0,Ee.jsx)(te.List,{heading:n("commands"),children:G.map((I,W)=>(0,Ee.jsx)(te.ListItem,{index:Vi(W,[],"commands"),closeOnSelect:!1,onClick:I.onClick,isExperimental:I.experimental,children:I.label},I.label))}),[...V,...N].map(({value:I,label:W,list:At,lineClamp:Un,listOrientation:fn},Ki)=>(0,Ee.jsx)(te.List,{heading:W,orientation:fn==="horizontal"?"horizontal":"vertical",children:dn(At,I).map((ct,dt)=>(0,Ee.jsx)(te.ListItem,{index:Vi(G.length+dt,[...V,...N].slice(0,Ki).map(({list:Nr})=>Nr),I),closeOnSelect:!1,lineClamp:Un,onClick:()=>mo(ct.text,ct),description:I!=="IMAGE"?ct.title&&ct.text:void 0,children:I==="IMAGE"?(0,Ee.jsx)(te.Image,{title:ct.title||ct.text,src:ct.image}):ct.title||ct.text},`${ct.id}-${ct.text}`))},I))]})}),(0,Ee.jsx)(te.Page,{id:"edit",onDismiss:Or(()=>{e(ze("search")),c(null)}),children:u&&(0,Ee.jsx)(Qc,{suggestion:u,onTouched:o,onDismiss:()=>{o(!1),e(ze("search")),c(null),d([])},onNext:zi,onPrevious:Ui,onUse:I=>{e(ze("search")),mo(I,{...u,source:`${u.source||"text_recommendation"}-preview`}),e(at(!1)),d([]),c(null)}})}),(0,Ee.jsx)(te.Page,{id:"entities",title:n("entitiesTitle"),isExperimental:!0,onDismiss:Or(()=>{e(ze("search"))}),children:(0,Ee.jsx)(Zw,{onUse:Wa,onCopy:Bi})}),(0,Ee.jsx)(te.Page,{id:"summary",title:n("summaryTitle"),isExperimental:!0,onDismiss:Or(()=>{e(ze("search"))}),children:(0,Ee.jsx)(o1,{onCopy:Ka})}),(0,Ee.jsx)(te.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),isExperimental:!0,onDismiss:Or(()=>{e(Ti()),e(ze("search"))}),children:(0,Ee.jsx)(c1,{promptInstruction:l.knowledgeAssistPromptInstruction,question:i,onUse:Ar,onResetQuestion:()=>{e(Ti()),s("")}})})]})},m1=II;var Pi=x(w()),LI=()=>{let e=D("showSearch"),t=D("isEmbedded");return(0,Pi.jsxs)(g1.Fragment,{children:[e&&(0,Pi.jsx)(m1,{}),(0,Pi.jsx)(Nw,{}),t&&(0,Pi.jsx)(Bw,{})]})},h1=LI;function Ri(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 nd=x(O());var Li=x(O());var y1=x(O());function v1(e,t,n){(0,y1.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var AI=/[.*+?^${}()|[\]\\]/g,OI=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function NI(e){return e.replace(AI,"\\$&")}function MI(e,t){let n=e.split("").findIndex((r,o)=>r!==t[o]);return n>-1?n:Math.min(e.length,t.length)}function $g(e){return e.search(OI)}function S1(e,t=[]){let n=e;return t.forEach(r=>{if(!r)return;let o=new RegExp(`\\b(${NI(r)})\\b`,"gi");n=n.replace(o,"<strong>$1</strong>")}),n}function x1(e){return e.replace(xo,'<mark data-type="placeholder">$1</mark>')}function Ii(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function DI(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 qg(e,t,n={}){if(t){let r=MI(t.toLowerCase(),e.toLowerCase()),o=Ii(e.substring(r,e.length));if(n.stripAgentPart){let l=e.substring(0,r),u=$g(l);return`<span style="opacity: 0.5">${l.substring(u+1)}</span>${o}`}let s=t.split(Py).length>3||t.length>30?DI(t.trim(),r):0;return`${`${s>0?"\u2026":""}${Ii(e.substring(s,r))}`}<strong>${o}</strong>`}return e}var _1={badge:"_badge_1syy2_1",formattedText:"_formattedText_1syy2_5"};var Gg=x(w()),jI=["search","personal-collection-search","search-autocomplete"];function HI(e,t,n,r={}){let o="";return jI.includes(t)?o=S1(qg(e,n,{stripAgentPart:!0}),r.searchKeywords??[n]):o=qg(e,n,r),r.placeholders===!0&&(o=x1(o)),o}var BI=()=>{},UI=({index:e,selected:t,suggestion:n})=>{let r=D("inlineSuggestions"),o=L(ui),i=B(),s=k("TextSuggestion",_1),a=(0,Li.useRef)(null);(0,Li.useEffect)(()=>{let u=setTimeout(()=>{i(o_({text:n.text,suggestion:n}))},500);return()=>{clearTimeout(u)}},[n]),v1(a,"click",()=>{i(la(e)),i(Ht({suggestion:n,text:n.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,Li.useMemo)(()=>HI(n.text,n.source,o,{stripAgentPart:r,placeholders:!0,searchKeywords:n.searchKeywords}),[r,n.text,n.source,o,n.searchKeywords]);return n.source==="gpt"&&!r?null:(0,Gg.jsx)(oe,{ref:a,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:BI,children:(0,Gg.jsx)(fi,{containerTagName:"div",noWrap:!1,tagName:"span",className:s.formattedText,content:l})})},w1=UI;var Xg=x(w()),zI=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,nd.useMemo)(()=>{let o=e.map((i,s)=>(0,Xg.jsx)(w1,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,Xg.jsx)(nd.Fragment,{children:r})},rd=zI;var E1={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var Aa=x(w()),VI=({textSuggestions:e,selectedIndex:t})=>{let n=k("InlineSuggestionsOverlay",E1),r=L(Ri),o=B(),i=L(Vt),s=L(li),a=L(Zc),l=D("showTextSuggestions");return Sr(()=>{o(Cr({collapse:!0,skipWhenInputFocus:!0}))}),a||!r||!l||e.length===0||i!==!0||s===!1?null:(0,Aa.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,Aa.jsx)("div",{className:n.paper,children:(0,Aa.jsx)(ht,{children:(0,Aa.jsx)(rd,{suggestions:e,selectedIndex:t})})})})},KI=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),C1=wn(KI)(VI);var id=x(X()),Ai=x(O());var b1=x(O());function T1(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 U.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){U.error(s)}}]}var P1=x(X()),Nn=x(O());var Qg={};Ce(Qg,{enUS:()=>WI,nlNL:()=>$I});var WI={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"}]}]},$I={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 k1={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var kr=x(w()),Yg=(e,t,n)=>r=>(0,kr.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),qI=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r})=>{let o=j(Qg),i=Rt(),s=k("Login",k1),a=D("productName"),l=(0,Nn.useCallback)(h=>{h.preventDefault(),r&&r(parseInt(h.target.value,10))},[]),u=(0,Nn.useCallback)(h=>{h.preventDefault(),i.send(Ci,!0)},[t]),c=(0,Nn.useMemo)(()=>h=>(0,kr.jsx)("a",{href:t,className:s.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[t]),f=(0,Nn.useCallback)(h=>(0,kr.jsx)("button",{type:"button",className:s.anchorButton,onClick:u,children:h},"prompt"),[u]),{min:d,hour:y,day:S}=(0,Nn.useMemo)(()=>({min:Yg(s,60*10,l),hour:Yg(s,60*60,l),day:Yg(s,60*60*12,l)}),[]);return(0,kr.jsxs)("div",{className:(0,P1.default)(e,s.root),children:[o("loginPlease",{login:n?f:c,productName:a}),r&&(0,kr.jsxs)(Nn.Fragment,{children:[(0,kr.jsx)("br",{}),o("snooze",{min:d,hour:y,day:S})]})]})},od=qI;var R1={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var Oa=x(w()),GI=({title:e})=>{let t=k("SearchTrigger",R1),n=B();return(0,Oa.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(at(!0)),children:[(0,Oa.jsx)(vi,{}),(0,Oa.jsx)("span",{className:t.text,children:e})]})},I1=GI;var Zg={};Ce(Zg,{enUS:()=>XI,nlNL:()=>QI});var XI={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"}]},QI={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 L1={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=x(w()),YI=({textSuggestions:e,selectedIndex:t})=>{let n=k("SuggestionsOverlay",L1),r=j(Zg),o=L(Ri),i=Jx(),s=B(),a=(0,Ai.useRef)(null),l=D("searchTriggerKey"),u=D("productName"),c=L(Zc),f=L(Vt),d=L(li),[y,S]=(0,Ai.useState)(null),h=D("showSearch"),g=D("showTextSuggestions"),m=D("adminUrl"),p=D("isEmbedded"),[v,_]=T1("dd-snooze-until-ms",0),C=c||v>Date.now(),E=e.filter(P=>P.source!=="gpt").length,b=()=>{C&&_(0),s(_w(!C))},R=P=>{let N=Date.now()+P*1e3;_(N),U.info(`Snooze until: ${new Date(N)}`),s(Cr({collapse:!0}))};return(0,Ai.useEffect)(()=>{E===0&&S(null)},[e,E]),Sr(()=>{s(Cr({collapse:!0,skipWhenInputFocus:!0}))}),f===null||d===!1?null:f===!1?(0,ue.jsxs)("div",{ref:a,className:(0,id.default)(n.root,{[n.isCollapsed]:C}),children:[!C&&(0,ue.jsxs)("div",{className:n.triggers,children:[(0,ue.jsx)("div",{style:{flex:1}}),(0,ue.jsx)("div",{className:n.triggersRight,children:(0,ue.jsx)(jr,{className:n.toggleButton,title:r("collapse"),onClick:b,isCollapsed:!1})})]}),(0,ue.jsx)("div",{className:n.toggleButtonWrapper,children:(0,ue.jsx)(jr,{className:n.toggleButton,title:r("open",{productName:u}),onClick:b,isCollapsed:!0})}),(0,ue.jsx)("div",{className:n.collapsible,children:(0,ue.jsx)(od,{loginUrl:m,isEmbedded:p,onSnooze:R})})]}):!i||!o?null:(0,ue.jsxs)("div",{ref:a,className:(0,id.default)(n.root,{[n.isCollapsed]:C}),children:[!C&&(0,ue.jsxs)("div",{className:n.triggers,children:[(0,ue.jsx)("div",{style:{flex:1},children:h&&(0,ue.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>S(r(Wc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>S(null),children:(0,ue.jsx)(I1,{title:r("search")})})}),(0,ue.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,ue.jsx)("div",{className:(0,id.default)(!y&&n.hintsHidden,n.hints),children:y}),(0,ue.jsx)(jr,{className:n.toggleButton,title:r("collapse"),onClick:b,isCollapsed:!1})]})]}),(0,ue.jsx)("div",{className:n.toggleButtonWrapper,children:(0,ue.jsx)(jr,{className:n.toggleButton,title:r("open",{productName:u}),onClick:b,isCollapsed:!0})}),E>0&&g&&(0,ue.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,ue.jsx)(ht,{children:(0,ue.jsx)(rd,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},ZI=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),sd=wn(ZI)(YI);var Na=x(w()),JI=({children:e})=>{let n=D("locale").replace("-","");return(0,Na.jsx)($d.Provider,{value:n,children:e})},eL=({store:e,customStyles:t={},children:n})=>(0,Na.jsx)(qm,{store:e,children:(0,Na.jsx)(JI,{children:(0,Na.jsx)($i.Provider,{value:t,children:n})})}),Oi=eL;var Sd=x(X());var Fn=x(O());var A1=x(O()),tL=["div","span","mark","strong","b","i","u","em"];function Jg(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(tL.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,A1.cloneElement)(r,{children:Jg(s,t,n+1)})]}return[...e,...t]}function an(e){return e.tagName.toLowerCase()==="textarea"}var O1={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 cd=x(O());var th=x(X()),It=x(O());var ad=x(O()),nL=["bottom","height","left","right","top","width"],rL=(e={},t={})=>nL.some(n=>e[n]!==t[n]),Mn=new Map,N1,M1=()=>{let e=[],t=[];Mn.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();rL(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{Mn.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),N1=window.requestAnimationFrame(M1)};function oL(e,t){return{observe(){let n=Mn.size===0;if(Mn.has(e)){let r=Mn.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else Mn.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&M1()},unobserve(){let n=Mn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Mn.delete(e),Mn.size||cancelAnimationFrame(N1)}}}}function eh(e){let[t,n]=(0,ad.useState)(null);return(0,ad.useLayoutEffect)(()=>{if(!e.current)return;let r=oL(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var Ni=x(O()),F1=x(Ou());var D1={root:"_root_1jq08_1"};var j1=({children:e})=>{let[t,n]=(0,Ni.useState)(null),r=(0,Ni.useContext)($i);return(0,Ni.useLayoutEffect)(()=>{let o=document.createElement("div");return io(o),o.classList.add(D1.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,F1.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 ld=x(w()),Mi=(e=!1)=>{let[t,n]=(0,It.useState)(e),r=(0,It.useCallback)(()=>n(!0),[]),o=(0,It.useCallback)(()=>n(!1),[]),i=(0,It.useCallback)(()=>n(a=>!a),[]),s=(0,It.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function nh(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 Di=({className:e,triggerRef:t,boundaryRef:n=(0,It.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=nh,...a})=>{let l=eh(t),u=eh(n),c=(0,It.useMemo)(()=>s(l,u,0),[l,u]);return(0,ld.jsx)(j1,{children:(0,ld.jsx)("div",{className:(0,th.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,ld.jsx)("div",{className:(0,th.default)(e,ln.root),children:i})})})};var Pr=x(w()),iL=({inputStyle:e,inputElement:t})=>{let n=k("TabCompletion",Tt),r=Mi(document.activeElement===t);return Sr(()=>r.close()),(0,cd.useEffect)(()=>{let o=()=>r.open();return t.addEventListener("focus",o),()=>{t.removeEventListener("focus",o)}},[]),(0,Pr.jsxs)(cd.Fragment,{children:[(0,Pr.jsx)("mark",{className:Tt.caret,ref:r.triggerRef}),r.opened&&(0,Pr.jsx)(Di,{className:n.popoverSuggestionsRoot,triggerRef:r.triggerRef,position:"above",align:"start",children:(0,Pr.jsx)("div",{style:e,className:n.suggestionsOverlayInputStyles,children:(0,Pr.jsx)(sd,{inline:!0})})})]})},ud=class extends Ut{charCounter=0;charLength=0;found=!1;onlyAtEnd=!1;props;onBeforeParse(t,n){var r;return this.props=n,this.charCounter=0,this.onlyAtEnd=n.inlineSuggestionsOnlyAtEnd??!1,this.charLength=(an(n.inputElement)?n.inputElement.value.length:(r=n.inputElement.textContent)==null?void 0:r.length)??0,this.found=!1,t}match(t){if(this.found||!this.props||this.props.selection===null)return null;let[n,r]=this.props.selection;if(n!==r||this.onlyAtEnd&&n!==this.charLength)return null;let o=n,s=o>=this.charCounter&&o<=this.charCounter+t.length?{index:$g(t.slice(0,o))+1-this.charCounter,length:0,match:"",valid:!0}:null;return s&&(this.found=!0),this.charCounter+=t.length,s??null}replaceWith(t,n){return(0,Pr.jsx)(iL,{inputStyle:n.inputStyle,inputElement:n.inputElement},"caret")}asTag(){return"mark"}};var z1=x(X());var gd=x(O());function H1(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function dd(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function B1(e){return e!=null}var U1=x(X()),fd=x(O());var rh=x(w()),pd=(0,fd.forwardRef)(({className:e,children:t,...n},r)=>{let o=(0,fd.useRef)(null),i=k("TabCompletion",Tt);return(0,rh.jsx)("div",{ref:dd([o,r]),className:(0,U1.default)(e,i.popoverContentContainer),...n,children:(0,rh.jsx)("div",{className:i.popoverContent,children:t})})});var Rr=x(w()),sL=e=>t=>{let n=nh(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},aL=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=k("TabCompletion",Tt),s=Mi(),a=(0,gd.useMemo)(()=>sL(e.getBoundingClientRect()),[e]),[l,u]=Fc(e);return(0,gd.useEffect)(()=>{u?s.open():s.close()},[u]),(0,Rr.jsxs)("span",{children:[(0,Rr.jsx)("mark",{ref:dd([l,s.triggerRef]),className:(0,z1.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,Rr.jsx)(Di,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,Rr.jsx)(pd,{style:n,children:(0,Rr.jsx)("div",{className:i.hintText,children:o})})})]})},md=class extends Ut{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${H1(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(B1);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)(aL,{inputElement:n.inputElement,suggestion:n.suggestion,inputStyle:n.inputStyle,boundaryRef:n.boundaryRef,children:t},`keyword_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var yd=x(X());var Ke=x(O());var oh=x(w()),V1=()=>(0,oh.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,oh.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=x(O());var W1=x(Bg());var K1={root:"_root_1muu8_1",content:"_content_1muu8_7"};function hd(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 ih(e){return e.replace("https://www.","").replace("https://","")}var Lt=x(w()),lL=3,uL=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),cL=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=lL})=>{let i=k("LinkSearch",K1),[s,a]=(0,Ir.useState)(""),l=B(),u=L(sw("url")),c=L(X_("URL",uL)),[f,d]=(0,Ir.useState)(c.length-1),y=D("fallbackImage"),S=p=>{let v=p.target;a(v.value)},h=(p,v)=>{p.stopPropagation(),p.preventDefault(),window.open(v,"_blank")},g=p=>{var C;let v=f-1<0?c.length-1:f-1,_=f+1===c.length?0:f+1;p.code==="Escape"&&(a(""),t()),p.code==="ArrowUp"&&d(v),p.code==="ArrowDown"&&d(_),p.code==="Enter"&&e(((C=c[f])==null?void 0:C.text)||s)},m=(0,Ir.useCallback)((0,W1.default)(p=>{l(lo({query:p,type:"URL",tags:["link-search"]}))},300),[]);return(0,Ir.useEffect)(()=>{s&&m(s)},[s]),(0,Ir.useEffect)(()=>()=>{l(qc())},[]),(0,Lt.jsxs)("div",{className:i.root,children:[(0,Lt.jsx)(ht,{withDivider:!0,children:(s?c:u).slice(0,o).map((p,v)=>(0,Lt.jsx)(oe,{selected:f===v,onClick:()=>e(p.text),"data-testid":"linksearch-suggestion",children:(0,Lt.jsxs)(me,{children:[(0,Lt.jsx)(me.Image,{src:hd(p,"small",y||void 0),title:p.title||p.text}),(0,Lt.jsxs)(me.Content,{className:i.content,cropText:!0,children:[(0,Lt.jsx)(me.Title,{children:p.title||ih(p.text)}),p.title&&ih(p.text)]}),(0,Lt.jsx)(oe.Actions,{children:(0,Lt.jsx)(oe.ActionButton,{label:r,onClick:_=>h(_,p.text)})})]})},p.text))}),(0,Lt.jsx)(Ta,{value:s,onChange:S,autoFocus:!0,placeholder:n,onKeyUp:g})]})},$1=cL;var sh={};Ce(sh,{enUS:()=>dL,nlNL:()=>fL});var dL={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},fL={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Ve=x(w()),pL=(0,Ke.forwardRef)((e,t)=>{let n=k("TabCompletion",Tt);return(0,Ve.jsx)("mark",{ref:t,className:(0,yd.default)(n.matchSelection)},"selection-start")}),mL=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=j(sh),s=k("TabCompletion",Tt),a=(0,Ke.useRef)(null),l=(0,Ke.useRef)(null),[u,c]=(0,Ke.useState)(null),f=B(),d=Mi(document.activeElement===r),[y]=(0,Ke.useState)(()=>document.createRange());d.triggerRef.current=y,(0,Ke.useEffect)(()=>()=>y.detach(),[]),(0,Ke.useEffect)(()=>{let h=e.current,g=a.current;!h||!g||(y.setStart(h,0),y.setEnd(g,0))},[e.current,a.current]),Sr(()=>{d.close()});let S=(0,Ke.useCallback)(h=>{let g=y.toString(),m=/^http(s?):\/\//.test(h)?h:`https://${h}`;f(Cc({text:`[${g}](${m})`,replace:"selection"}))},[]);return(0,Ve.jsxs)("span",{children:[(0,Ve.jsx)("mark",{ref:a,className:(0,yd.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,Ve.jsx)(Di,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,Ve.jsxs)(pd,{style:n,ref:l,children:[(0,Ve.jsx)("div",{className:(0,yd.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,Ve.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,Ve.jsx)(V1,{}),(0,Ve.jsx)("span",{children:"\xA0"}),(0,Ve.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,Ve.jsx)($1,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:S,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},vd=class extends Ut{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(t,n){return this.props=n,this.charCount=0,this.startRef=(0,Ke.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,Ve.jsx)(pL,{ref:this.startRef}):(0,Ve.jsx)(mL,{inputElement:n.inputElement,startRef:this.startRef,boundaryRef:n.boundaryRef,inputStyle:n.inputStyle})}asTag(){return"mark"}};var Dn=x(w()),gL=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=k("TabCompletion",O1),c=D("insertLink"),f=D("showMidSentenceSuggestions"),d=D("inlineSuggestions"),y=Hc(a),S=(0,Fn.useRef)(null);(0,Fn.useEffect)(()=>{an(a)&&y&&Bc(a,y)},[y]);let h=(0,Fn.useCallback)(p=>{if(!o||!n)return p;let v=[(0,Dn.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,Dn.jsx)("span",{"data-testid":"tab-completion",className:(0,Sd.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&v.push((0,Dn.jsx)("span",{className:(0,Sd.default)(u.hint,u.resetIndent),children:(0,Dn.jsx)(yl,{keyCode:"tab"},"tabHint")})),Jg(p,v)},[o,n,r]),g=(0,Fn.useMemo)(()=>{let p=[];return d&&p.push(new ud("inline")),c&&p.push(new vd("selection")),p.push(new mi("placeholders")),i&&p.push(new md("keywords")),p},[d,c,i]),m=(0,Fn.useMemo)(()=>{let p=window.getComputedStyle(a);return{"--dd-color":p.color,"--dd-font-size":p.fontSize,"--dd-font-family":p.fontFamily,"--dd-font-variant":p.fontVariant}},[]);return e?(0,Dn.jsxs)("div",{ref:p=>{p!=null&&p.parentElement&&(S.current=p==null?void 0:p.parentElement)},className:u.root,style:m,children:[(0,Dn.jsx)(fi,{tagName:"span",containerTagName:"div",className:(0,Sd.default)(u.container,u.agentText),disableLineBreaks:an(a),content:t||"\u200B",onAfterParse:h,matchers:g,selection:y,keywordMatches:s,inputElement:a,inputStyle:m,boundaryRef:S,inlineSuggestionsOnlyAtEnd:!f}),(0,Dn.jsx)("br",{})]}):null},hL=({input:e,ui:t,settings:n,styleSuggestions:r,conversation:o})=>{var h;let{tabCompletionSuggestion:i}=e,s=(i==null?void 0:i.text)||"",a=(i==null?void 0:i.source)||"",l=e.html??Ii(e.text),u=s.indexOf(e.text)===0?s.slice(e.text.length):"",{showTabHint:c}=t,{isSupported:f}=o,{showTabCompletion:d,visible:y,showStyleSuggestions:S}=n;return{showTabHint:c,showStyleSuggestions:S,showTabCompletion:d,content:l,tabText:u,source:a,keywordMatches:((h=r.list)==null?void 0:h.keywordMatches)??[],enabled:y&&f!==!1}},q1=wn(hL)(gL);var ME=x(X()),DE=x(O());var G1={list:[],fetchState:"idle",isInitialRequest:null},Q1=e=>e.autoflows.list||[],X1=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},jn=M("autoflows/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)}),ah=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(jn(e.platformSessionId))}),lh=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(jn(e.platformSessionId))}),yL=H({name:"autoflows",initialState:G1,reducers:{},extraReducers:e=>{e.addCase(ah.pending,(t,n)=>{let r=X1(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(lh.pending,(t,n)=>{let r=X1(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(jn.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}),e.addCase(jn.rejected,t=>{t.fetchState="error"}),e.addCase(jn.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(J,()=>G1)}}),Y1=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(jn(e))}),o.on("sessionCompleted",()=>{n(jn(e))})}),Z1=M("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),J1=yL.reducer;var eE={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},tE=e=>e.customMessages.list,nE=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),rE=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),oE=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),Ma=M("customMessages/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)}),xd=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)}),_d=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)}),iE=H({name:"customMessages",initialState:eE,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(Ma.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(Ma.rejected,t=>{t.fetchState="error"}).addCase(Ma.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(xd.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(xd.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(_d.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(_d.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(J,()=>eE)}}),sE=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(iE.actions.onCustomMessage(i))})}),aE=M("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),lE=iE.reducer;var vL={jwt:null,accountUrl:null,interval:null},uE=e=>t=>{let{exchangeToken:{jwt:n,accountUrl:r}}=t;return n&&r?`${r}/apis/admin/session/jwt/?jwt=${n}&redirect=${e}`:null},uh=M("exchangeToken/getTemporaryExchangeToken",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=await n.getTemporaryExchangeToken();return{accountUrl:n.client.baseUrl,jwt:r}}),ch=M("exchangeToken/pollExchangeToken",(e={},t)=>{let{interval:n=1e3*60*30}=e,{dispatch:r}=t;return r(uh()),setInterval(()=>r(uh()),n)}),cE=H({name:"exchangeToken",initialState:vL,reducers:{stopPollExchangeToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(uh.fulfilled,(t,n)=>{t.jwt=n.payload.jwt,t.accountUrl=n.payload.accountUrl}),e.addCase(ch.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollExchangeToken:dE}=cE.actions,fE=cE.reducer;function pE(e){let{customMessages:t,autoflows:n}=e;return n.fetchState==="loading"&&n.isInitialRequest===!0||t.fetchState==="loading"&&t.isInitialRequest===!0}var wE=x(O());var SE=x(X()),xE=x(O());var gE=x(X());var mE={root:"_root_838fd_1"};var yE=x(w()),SL=({className:e,children:t})=>{let n=k("Unicode",mE);return(0,yE.jsx)("span",{className:(0,gE.default)(e,n.root),children:t})},hE=SL;var vE={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 dh={};Ce(dh,{enUS:()=>xL,nlNL:()=>_L});var xL={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"}]},_L={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 lt=x(w()),EL=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=k("Autoflow",vE),a=j(dh),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,lt.jsxs)(oe,{className:(0,SE.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,lt.jsx)(me,{children:(0,lt.jsxs)(me.Content,{children:[(0,lt.jsxs)(me.Title,{children:[t&&(0,lt.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,lt.jsx)("span",{children:r})]})}),(0,lt.jsx)(oe.Actions,{fixed:t==="Started",children:(0,lt.jsx)(oe.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,lt.jsxs)(xE.Fragment,{children:[(0,lt.jsx)(hE,{children:u})," ",(0,lt.jsx)("span",{children:a(l)})]})})})]})},_E=EL;var fh=x(w()),CL=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},bL=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,fh.jsx)(wE.Fragment,{children:e.map(o=>(0,fh.jsx)(_E,{displayName:o.displayName,description:o.description,disabled:o.isBusy||CL(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),TL=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},kL={onStartAutoflow:ah,onStopAutoflow:lh},EE=wn(TL,kL)(bL);var wd=x(O());var gh=x(X());var ph=x(w()),mh=()=>(0,ph.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,ph.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 CE={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=x(w()),PL=({entities:e})=>{let t=k("EntitiesWidgetList",CE),[n,r]=(0,wd.useState)(void 0),o=B(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Pa(a.text),o(st({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,wd.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,gh.default)(t.icon),children:(0,un.jsx)(mh,{})}),(0,un.jsx)("span",{className:(0,gh.default)(t.icon,n===l&&t.iconClicked),children:(0,un.jsx)(mh,{})})]})]},a.text))})},bE=PL;var TE=x(X()),hh=x(O());var Da={};Ce(Da,{enUS:()=>RL,nlNL:()=>IL});var RL={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],answer:[{type:0,value:"Answer"}]},IL={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],answer:[{type:0,value:"Antwoord"}]};var Hn={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 et=x(w()),LL=({suggestion:e})=>{let t=j(Da),n=B(),r=L(nE(e.text)),o=L(rE(e.text)),i=L(oE(e.text)),s=L(hc),{replyOptions:a}=e,l=(0,hh.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(xd({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,hh.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let f=parseInt(c.target.dataset.index,10),d=a[f];n(_d({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,et.jsxs)(oe,{onClick:l,className:(0,TE.default)(Hn.root,{[Hn.isUsed]:r,[Hn.hasError]:i}),children:[(0,et.jsx)(me,{children:(0,et.jsxs)(me.Content,{children:[(0,et.jsxs)(me.Title,{className:Hn.title,children:[e.text," ",(0,et.jsx)(vl,{className:Hn.label,children:"analyse tool"})," ",i&&(0,et.jsx)("span",{className:Hn.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,et.jsx)("ul",{className:Hn.quickReplies,children:a.map(c=>(0,et.jsx)("li",{className:Hn.quickReply,children:c.title},c.title))})]})}),(0,et.jsxs)(oe.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,et.jsx)(oe.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,f)=>(0,et.jsx)(oe.DropdownItem,{index:f,label:c.title,onClick:u},c.title))}),(0,et.jsx)(oe.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},kE=LL;var yh=x(w()),PE=()=>(0,yh.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,yh.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 RE=x(O());var ut=x(w()),AL=({suggestion:e,lines:t,onEdit:n,onUse:r})=>{var d;let o=e.text||e.url||e.message,i=Gc(o),s=j(Da),a=D("showImages"),l=D("fallbackImage"),u=y=>{y.preventDefault(),y.stopPropagation(),r(o)},c=y=>{y.preventDefault(),y.stopPropagation(),n(e)},f=(0,RE.useCallback)(y=>{window.open(i,"_blank"),y.stopPropagation(),y.preventDefault()},[i]);return(0,ut.jsxs)(oe,{onClick:u,"data-testid":"edit-suggestion",children:[(0,ut.jsxs)(me,{children:[a&&e.image&&(0,ut.jsx)(me.Image,{src:hd(e,"small",l||void 0),title:e.title}),(0,ut.jsxs)(me.Content,{children:[e.title&&(0,ut.jsx)(me.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((d=e.searchKeywords)==null?void 0:d.length)>0&&(0,ut.jsx)(oe.Labels,{labels:e.searchKeywords}),(0,ut.jsx)(me.Content,{cropText:t==="single",lineClamp:t==="multiple",children:o})]})]}),(0,ut.jsxs)(oe.Actions,{children:[i&&(0,ut.jsx)(oe.ActionButton,{onClick:f,label:s("visitUrl")}),(0,ut.jsx)(oe.ActionButton,{primary:!0,onClick:c,label:s("preview")}),(0,ut.jsx)(oe.ActionButton,{primary:!0,onClick:u,label:s("useSuggestion")})]})]})},IE=AL;var Fa=x(w()),OL=({contentType:e,lines:t,suggestions:n})=>{let r=Rt(),o=L(xi),i=a=>{r.send(Og,{state:o,suggestion:a,contentType:e})},s=(a,l)=>{r.send(Ln,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,Fa.jsx)(Fa.Fragment,{children:n.map(a=>(0,Fa.jsx)(IE,{suggestion:a,lines:t,onEdit:l=>i(l),onUse:l=>s(l,a)},a.text||a.url||a.message))})},LE=OL;var vh={};Ce(vh,{enUS:()=>NL,nlNL:()=>ML});var NL={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},ML={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var AE={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 Sh=x(w()),OE=()=>(0,Sh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Sh.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 xh=x(w()),NE=()=>(0,xh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,xh.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 z=x(w()),Ed=(e,t)=>{let n=L(Vt);(0,DE.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},DL=()=>{let e=j(vh),t=B(),n=D("isEmbedded"),r=k("Widget",AE),o=D("showAutoflows"),i=D("showCustomMessages"),s=D("showPersonalCollectionLink"),a=D("showSummaryCommand"),l=D("showKnowledgeSearch"),u=D("showSearch"),c=L(ki),f=L(td),d=L(Q1),y=L(ed),S=L(tE),h=L(yc),g=L(li),m=L(Vt),p=L(hc),v=L(pE),_=L(xi),C=Rt(),E=L(lw),b=L(uE("/admin/personal-collection")),R=D("adminUrl");if(Ed(()=>(t(Ma(p)),t(sE(p)),()=>{t(aE(p))}),[t,g,i,p]),Ed(()=>(t(jn(p)),t(Y1(p)),()=>{t(Z1(p))}),[t,g,o,p]),Ed(()=>{f.forEach(({type:N})=>{t(N==="entities"?Wt():Rn(N))})},[t,g,h,c]),Ed(()=>(t(ch()),()=>{t(dE())}),[t,g,s,h]),g===!1)return(0,z.jsx)("div",{className:r.stateText,children:(0,z.jsx)("div",{children:(0,z.jsx)("p",{children:e("notSupported")})})},"supported");if(m===!1)return(0,z.jsx)("div",{className:r.loginText,children:(0,z.jsx)("div",{children:(0,z.jsx)(od,{isEmbedded:n,loginUrl:R})})},"login");if(!c||!p||m===null||E||v)return(0,z.jsx)("div",{className:r.stateText,children:(0,z.jsx)("div",{children:(0,z.jsx)("p",{children:e("waiting")})})},"waiting");let P=u||a||l||b;return(0,z.jsx)("div",{className:(0,ME.default)(r.root),"data-testid":"widget",children:(0,z.jsxs)(Sl,{className:r.sectionList,children:[P&&(0,z.jsx)(zn,{title:e("actions"),type:"shortcuts",children:(0,z.jsxs)("div",{className:r.shortcutList,children:[u&&(0,z.jsxs)("button",{className:r.shortcut,"data-testid":"shortcut-search",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0}),children:[(0,z.jsx)(vi,{}),e("linkSearch")]}),a&&(0,z.jsxs)("button",{className:r.shortcut,"data-testid":"shortcut-summary",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,z.jsx)(NE,{}),e("linkSummary")]}),l&&(0,z.jsxs)("button",{className:r.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,z.jsx)(OE,{}),e("linkKnowledgeSearch")]}),b&&(0,z.jsxs)("a",{className:r.shortcut,target:"_blank",href:b,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[(0,z.jsx)(PE,{}),e("linkPersonalcollection")]})]})}),i&&S.length>0&&(0,z.jsx)(zn,{type:"custom-messages","data-testid":"custom-messages",children:(0,z.jsx)(ht,{withDivider:!0,children:S.map(N=>(0,z.jsx)(kE,{suggestion:N},N.text))})}),o&&d.length>0&&(0,z.jsx)(zn,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,z.jsx)(ht,{withDivider:!0,children:(0,z.jsx)(EE,{})})}),f.map(({type:N,title:G,amount:V,lines:He})=>{var cn;switch(N){case"entities":return y&&y.length>0&&(0,z.jsx)(zn,{type:N,title:G,"data-testid":`type-${N}`,children:(0,z.jsx)(bE,{entities:y})},N);default:return((cn=_[N])==null?void 0:cn.fetchState)==="done"&&_[N].suggestions.length>0&&(0,z.jsx)(zn,{type:N,title:G,"data-testid":`type-${N}`,children:(0,z.jsx)(ht,{withDivider:!0,children:(0,z.jsx)(LE,{lines:He,contentType:N,suggestions:_[N].suggestions.slice(0,V)||[]})})},N)}})]})})},FE=DL;function Fi(e){let t=new Range;return t.selectNodeContents(e),t}function jE(e,t,n){try{return Lr(e,t,n),!0}catch{return!1}}function Cd(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function bd(e){return"tagName"in e&&e.tagName==="BR"}var ja=/[\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,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(l))return u;for(let d=0;d<=l.length;d++)if(f.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(ja,""),f=o+c.length,d=t>=o&&t<=f,y=n>=o&&n<=f;if(d){let S=s(u,t-o);S===0&&!y?r.setStartBefore(l):r.setStart(l,S)}y&&(r.setEnd(l,s(u,n-o)),i=!0),o=f;break}case Node.ELEMENT_NODE:{if(bd(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;Cd(l)&&u&&!Cd(u)&&!bd(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Ha(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(f){let d=f===n,y=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let S=f.textContent;d&&(a=u+S.substring(0,r).replace(ja,"").length),y&&(l=u+S.substring(0,i).replace(ja,"").length),u+=S.replace(ja,"").length;break}case Node.ELEMENT_NODE:{let S=f.nextSibling===null;bd(f)&&!S&&u++;for(let h=0;h<f.childNodes.length;h++){let g=d&&h===r,m=y&&h===i;if(g&&(a=u),m&&(l=u),l!==void 0||((!g||!s)&&c(f.childNodes[h]),y&&h===i-1&&(l=u),l!==void 0))break}!y&&Cd(f)&&!S&&u++,y&&(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 Ba(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,f=u===o;switch(c&&s++,u.nodeType){case Node.TEXT_NODE:{if(s!==0)return;let d=c?r:0,y=f?i:void 0,S=u.textContent.replace(ja,"");d===0&&y===void 0?a+=S:a+=S.substring(d,y);break}case Node.ELEMENT_NODE:{let d=u.nextSibling===null;s===0&&bd(u)&&!d&&(a+=`
19
+ `),o=o.replace(/\n/g,"<br/>"),o}createContainer(t){var n;let o=(typeof global<"u"&&global.INTERWEAVE_SSR_POLYFILL||iR)();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(nR)||(s.innerHTML=this.convertLineBreaks(this.props.escapeHtml?(0,v_.default)(t):t)),s}extractAttributes(t){let{allowAttributes:n}=this.props,r={},o=0;return t.nodeType!==y_||!t.attributes||([...t.attributes].forEach(i=>{let{name:s,value:a}=i,l=s.toLowerCase(),u=Nc[l]||Nc[s];if(!this.isSafe(t)||!l.match(rR)&&(!n&&(!u||u===cg)||l.startsWith("on")||a.replace(/(\s|\0|&#x0([9AD]);)/,"").match(/(javascript|vbscript|livescript|xss):/i)))return;let c=l==="style"?this.extractStyleAttribute(t):a;u===vr?c=!0:u===no?c=Number.parseFloat(String(c)):u!==Oc&&(c=String(c)),r[dg[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 ma[t]?{...n,...ma[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===y_){let d=c.nodeName.toLowerCase(),y=this.getTagConfig(d);u&&(l.push(u),u="");let S=this.applyNodeFilters(d,c);if(!S)return;let h;if(s&&!(a&&!this.isTagAllowed(d))){this.keyIndex+=1;let g=this.keyIndex;h=this.parseNode(S,y);let m=s(S,h,y);if(m===null)return;if(typeof m<"u"){l.push(oo.default.cloneElement(m,{key:g}));return}this.keyIndex=g-1}if(this.banned.has(d))return;if(!(r||o&&d!=="br")&&this.isTagAllowed(d)&&(i||this.canRenderChild(n,y))){var f;this.keyIndex+=1;let g=this.extractAttributes(S),m={tagName:d};g&&(m.attributes=g),y.void&&(m.selfClose=y.void),l.push(oo.default.createElement(Mc,{...m,key:this.keyIndex},(f=h)!==null&&f!==void 0?f:this.parseNode(S,y)))}else l=[...l,...this.parseNode(S,y.tagName?y:n)]}else if(c.nodeType===tR){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(oR);){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:f,props:d}=n[a],y;if(u)y=s.length,r.push(f.createElement(c,d));else{let S=o.match(new RegExp(`{{{/${a}}}}`));y=S.index+S[0].length,r.push(f.createElement(this.replaceTokens(o.slice(s.length,S.index),n),d))}o=o.slice(y)}return o.length>0&&r.push(o),r.length===0?"":r.length===1&&typeof r[0]=="string"?r[0]:r}};function sR(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",f=c==="fragment"?!0:u,d;if(a)d=a;else{let y=new Dc(i??"",e).parse();y.length>0&&(d=y)}return d||(d=s),f?oo.default.createElement(oo.default.Fragment,null,d):oo.default.createElement(Mc,{attributes:n,className:r,tagName:c},d)}function fi(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:f="span",noWrap:d=!1,...y}=e,S=i?[]:l,h=o?[]:a,g=c?[c]:[],m=u?[u]:[];S.forEach(C=>{C.onBeforeParse&&g.push(C.onBeforeParse.bind(C)),C.onAfterParse&&m.push(C.onAfterParse.bind(C))});let p=g.reduce((C,E)=>E(C,e),r??""),v=new Dc(p,y,S,h),_=m.reduce((C,E)=>E(C,e),v.parse());return oo.default.createElement(sR,{attributes:t,className:n,containerTagName:e.containerTagName,emptyContent:s,noWrap:d,parsedContent:_.length===0?void 0:_,tagName:f})}var wg=x(X());var pg={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var x_=x(X());var pi=x(O());function S_(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function Fc(e){let t=(0,pi.useRef)(null),[n,r]=(0,pi.useState)(!1);return(0,pi.useEffect)(()=>{let o=!1,i=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[s,a]=S_((c,f)=>{let d=t.current;if(!d)return;let y=c/i,S=f/i,h=d.getBoundingClientRect(),g=y>h.x&&y<h.x+h.width&&S>h.y&&S<h.y+h.height;g&&!o?(o=!0,r(!0)):!g&&o&&(o=!1,r(!1))},({clientX:c,clientY:f})=>[c,f]),[l,u]=S_(()=>{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 Tt={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 mg=x(w()),aR=({inputElement:e,children:t})=>{let n=k("TabCompletion",Tt),[r,o]=Fc(e);return(0,mg.jsx)("mark",{ref:r,className:(0,x_.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},mi=class extends Ut{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,mg.jsx)(aR,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var gi=x(O());function jc(e){return e.contentEditable==="true"}function lR(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 __(e){let{selectionStart:t,selectionEnd:n}=jc(e)?lR(e):e;return[t,n]}function Hc(e){let[,t]=(0,gi.useState)(),n=(0,gi.useRef)(null);return n.current=__(e),(0,gi.useEffect)(()=>{let r=()=>{let[o,i]=n.current??[],s=__(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 Bc(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(xo);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 w_=x(O());function Sr(e){(0,w_.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function io(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}var E_,on=new Map,uR=["bottom","height","left","right","top","width"],cR=(e={},t={})=>uR.some(n=>e[n]!==t[n]);function C_(e){var n,r;let t=((r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)??null;return t?[t,...C_(t)]:[]}function b_(e,t){return!e||!t?null:{...e,top:e.top+t.top,left:e.left+t.left}}var gg=!1,T_=()=>{gg=!0;let e=[];on.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),on.delete(n);return}let r=n.getBoundingClientRect();cR(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(b_,t.rect):t.rect;t.callbacks.forEach(r=>r(n))}),on.size!==0&&(E_=window.requestAnimationFrame(T_))};function hg(e,t){let n=C_(e),r=[],o=n.map((i,s)=>hg(i,a=>{r[s]=a;let l=on.get(e);if(!l)return;let u=r.reduce(b_,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),on.has(e)){let s=on.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else on.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!gg&&T_()},unobserve(){o.forEach(s=>s.unobserve());let i=on.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||on.delete(e),on.size||(cancelAnimationFrame(E_),gg=!1)}}}}var k_,sn=new Map,P_=()=>{sn.forEach((e,t)=>{if(!t.isConnected){sn.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)))}),sn.size!==0&&(k_=window.requestAnimationFrame(P_))};function R_(e,t){return{observe(){let n=sn.size===0;sn.has(e)?sn.get(e).callbacks.push(t):sn.set(e,{visible:void 0,callbacks:[t]}),n&&P_()},unobserve(){let n=sn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||sn.delete(e),sn.size||cancelAnimationFrame(k_)}}}}var yg=["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 vg(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function hi(e){return parseFloat(e)}function Uc(e){return Math.round(e*1e6)}function I_(e){return e/1e6}function Sg(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=hi(e.width),i=hi(e.borderLeftWidth),s=hi(e.borderRightWidth),a=hi(e.paddingRight),l=I_(Uc(o)-Uc(i)-Uc(s)),u=I_(Uc(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function so(e,t={}){var l;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",io(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};vg(r,n,yg),Sg(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=R_(e,()=>{vg(r,n,yg),Sg(r,e,n),i(),setTimeout(i,0)}),a=hg(e,u=>{if(u===null){t.onRemove&&t.onRemove(),n.remove();return}if(u.height===0&&u.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(vg(r,n,yg),Sg(r,e,n),i(),n.style.top=`${u.top}px`,n.style.left=`${u.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let c=t.closestScrollElement.getBoundingClientRect(),f=window.getComputedStyle(t.closestScrollElement),d=hi(f.borderTopWidth),y=hi(f.borderBottomWidth),S=c.top+d-u.top,h=u.top+u.height+-(c.top+c.height-y);n.style.clipPath=`inset(${S}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(l=e.parentElement)==null||l.appendChild(n),a.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),a.unobserve(),s.unobserve()}]}var xg={};Ce(xg,{enUS:()=>dR,nlNL:()=>fR});var dR={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"}]},fR={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 ga=x(w()),L_=()=>(0,ga.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,ga.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,ga.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 _g=x(w()),A_=()=>(0,_g.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,_g.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});function pR(e){let t=e.scrollHeight>e.clientHeight,r=window.getComputedStyle(e).overflowY.indexOf("hidden")!==-1;return t&&!r}function zc(e){return e?e instanceof ShadowRoot?zc(e.host):e===e.ownerDocument.body?e.ownerDocument:pR(e)?e:zc(e.parentNode):document.body}var O_=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(O_||{}),Tn=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();gr(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(O_).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",r=>this.handleKeyDown(r)),this.addEventListener("keyup",r=>this.handleKeyUp(r)),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",r=>this.handlePaste(r)),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()});let n=zc(this.element);if(n){let r=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};n.addEventListener("scroll",r),this.disposeHandlers.push(()=>{n.removeEventListener("scroll",r)})}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 kn=class extends Tn{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 Qe=x(w()),mR=({value:e,onUse:t,...n})=>{var c;let r=j(xg),o=B(),i=k("EditSuggestionTextInput",pg),[s,a]=(0,kt.useState)(null),l=(0,kt.useRef)(null),u=((c=e.match(xo))==null?void 0:c.length)||0;return(0,kt.useEffect)(()=>{let f;return l.current&&(a(l.current),f=new kn(l.current),f.on("change",({plainText:d})=>{o(Xe.actions.userInput({text:d,selection:f.getSelection()}))}),f.on("keydown",d=>{o(Xe.actions.registerKeyDown(Ec(d))),d.code==="Enter"&&d.shiftKey&&t(f.getText())}),f.on("paste",({pastedText:d,selectionText:y})=>{o(Xe.actions.registerPaste({text:d,selectionText:y}))}),f.on("cut",({selectionText:d})=>{o(Xe.actions.registerCut(d))})),()=>{o(Xe.actions.reset()),f.dispose(),f.deactivate()}},[l]),(0,kt.useEffect)(()=>{e&&l.current&&(l.current.value=e)},[e,l]),(0,kt.useEffect)(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let f=l.current.value.length;l.current.setSelectionRange(f,f),l.current.focus()},0)},[l]),(0,Qe.jsxs)("div",{className:i.textInputWrapper,children:[(0,Qe.jsx)("textarea",{...n,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:e,onChange:()=>{}}),s&&(0,Qe.jsx)(gR,{inputElement:l.current,value:e}),(0,Qe.jsxs)("div",{className:(0,wg.default)(i.alert,u===0?i.success:i.warning),children:[(0,Qe.jsx)("div",{className:i.alertText,children:r("placeholders",{placeholderSize:u})}),u===0?(0,Qe.jsx)(L_,{}):(0,Qe.jsx)(A_,{})]})]})},gR=({inputElement:e,value:t})=>{let n=k("EditSuggestionTextInput",pg),r=(0,kt.useRef)(null),o=Hc(e);return(0,kt.useEffect)(()=>{Bc(e,o)},[o,e]),(0,Qe.jsx)(hR,{inputElement:e,children:(0,Qe.jsxs)("div",{ref:r,className:(0,wg.default)(n.root,n.agentText),children:[(0,Qe.jsx)(fi,{tagName:"span",disableLineBreaks:!0,content:t,matchers:[new mi("placeholders")],inputElement:e,boundaryRef:r}),(0,Qe.jsx)("br",{})]})})},hR=({inputElement:e,children:t})=>{let n=(0,kt.useRef)(null);return(0,kt.useEffect)(()=>{if(!n.current)return()=>{};let[r,o]=so(e,{overlayContainer:n.current,mirrorOverflow:!0});return r.setAttribute("translate","no"),()=>{o()}},[n.current]),(0,Qe.jsx)("div",{ref:n,children:t})},N_=mR;var Si=x(O());var M_=x(O()),Vc=x(X());var Ye={root:"_root_185k9_1",list:"_list_185k9_2",listWrapper:"_listWrapper_185k9_6",listHorizontal:"_listHorizontal_185k9_10",page:"_page_185k9_19",search:"_search_185k9_25",pageNav:"_pageNav_185k9_33",pageTitle:"_pageTitle_185k9_41",pageBackButton:"_pageBackButton_185k9_48",listHeading:"_listHeading_185k9_62",listItem:"_listItem_185k9_70",listItemContent:"_listItemContent_185k9_79",listItemText:"_listItemText_185k9_97",listItemDescription:"_listItemDescription_185k9_105",truncate:"_truncate_185k9_112",lineClamp:"_lineClamp_185k9_118",listItemTitle:"_listItemTitle_185k9_125",listItemAction:"_listItemAction_185k9_132",listItemPrimaryAction:"_listItemPrimaryAction_185k9_146",listItemSelected:"_listItemSelected_185k9_151",sources:"_sources_185k9_155",sourcesTitle:"_sourcesTitle_185k9_162",source:"_source_185k9_155",icon:"_icon_185k9_177",searchIcon:"_searchIcon_185k9_194",searchInputWrapper:"_searchInputWrapper_185k9_199",searchInput:"_searchInput_185k9_199",select:"_select_185k9_220",selectType:"_selectType_185k9_237",selectWrapper:"_selectWrapper_185k9_241",image:"_image_185k9_271",imageSrc:"_imageSrc_185k9_278",imageSrcHidden:"_imageSrcHidden_185k9_289",imageSrcStatus:"_imageSrcStatus_185k9_293",imageTitle:"_imageTitle_185k9_303",actions:"_actions_185k9_308",actionsWrapper:"_actionsWrapper_185k9_312",actionsBar:"_actionsBar_185k9_318",actionButton:"_actionButton_185k9_327",actionShortcut:"_actionShortcut_185k9_345",actionShortcutFixKerning:"_actionShortcutFixKerning_185k9_352"};var ao={};Ce(ao,{enUS:()=>yR,nlNL:()=>vR});var yR={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=x(w()),SR=({src:e,title:t})=>{let n=k("CommandPalette",Ye),[r,o]=(0,M_.useState)("loading"),i=j(ao);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,Vc.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(r)})}),r==="loading"&&(0,xr.jsx)("span",{className:(0,Vc.default)(n.imageSrc,n.imageSrcStatus),children:i("loading")}),r==="error"&&(0,xr.jsx)("span",{className:(0,Vc.default)(n.imageSrc,n.imageSrcStatus),children:(0,xr.jsx)(Za,{})}),t&&(0,xr.jsx)("span",{className:n.imageTitle,children:t})]})},D_=SR;var F_=x(O()),j_=x(X());var ha=x(w());function Eg({children:e,heading:t,orientation:n}){let r=k("CommandPalette",Ye);return F_.default.Children.count(e)===0?null:(0,ha.jsxs)("div",{"data-testid":"commandpalette-list",className:r.list,children:[t&&(0,ha.jsx)("h4",{className:r.listHeading,children:t}),(0,ha.jsx)("div",{className:(0,j_.default)(r.listWrapper,n==="horizontal"&&r.listHorizontal),children:e})]})}var ya=x(X());var Kc=x(O()),U_=x(w()),H_=Kc.default.createContext(void 0);function _r(){let e=Kc.default.useContext(H_);if(e===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return e}var B_=({children:e,page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i})=>{let s=Kc.default.useMemo(()=>({page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i}),[n,t,o]);return(0,U_.jsx)(H_.Provider,{value:s,children:e})};var Pt=x(w());function Cg({closeOnSelect:e=!0,lineClamp:t,children:n,onClick:r,onSourceClick:o,index:i,isExperimental:s,description:a,sources:l,styles:u,...c}){let{selected:f,onChangeOpen:d}=_r(),y=k("CommandPalette",Ye);function S(h){r(h),e&&d(!1)}return(0,Pt.jsxs)("div",{className:(0,ya.default)(y.listItem,f===i&&y.listItemSelected),children:[(0,Pt.jsxs)("button",{type:"button",className:(0,ya.default)("command-palette-list-item",y.listItemAction,y.listItemPrimaryAction),"aria-disabled":c.disabled??!1,onClick:S,...c,children:[(0,Pt.jsxs)("div",{className:y.listItemContent,children:[typeof n=="string"?(0,Pt.jsx)("p",{className:(0,ya.default)(y.listItemText,y.truncate,u==null?void 0:u.title),children:n}):n,a&&(0,Pt.jsx)("p",{className:(0,ya.default)(y.listItemDescription,u==null?void 0:u.description,t?y.lineClamp:y.truncate),children:a})]}),s&&(0,Pt.jsx)(hl,{})]}),l&&(0,Pt.jsxs)("div",{className:y.sources,children:[(0,Pt.jsx)("span",{className:y.sourcesTitle,children:"Sources"}),l.map(h=>h.url?(0,Pt.jsx)("a",{className:y.source,href:h.url,target:"_blank",title:h.url,rel:"noopener noreferrer",onClick:()=>o&&o(h),children:h.name},h.url):(0,Pt.jsx)("span",{className:y.source,children:h.name},h.name))]})]})}var wr=x(w());function bg({children:e,title:t,id:n,onDismiss:r,isExperimental:o}){let i=j(ao),s=k("CommandPalette",Ye),{page:a}=_r();return a!==n?null:(0,wr.jsxs)("div",{className:s.page,id:`page_${n}`,tabIndex:-1,children:[r&&(0,wr.jsxs)("div",{className:s.pageNav,children:[(0,wr.jsxs)("button",{className:s.pageBackButton,type:"button",onClick:r,children:[(0,wr.jsx)(Rc,{}),i("back")]}),t&&(0,wr.jsx)("h3",{className:s.pageTitle,children:t}),o&&(0,wr.jsx)(hl,{})]}),e]})}var Er=x(O());var Wc=()=>/Mac/i.test(navigator.platform);var xR={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},U=xR;function _R(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function re(e){return Array.isArray(e)?e.map(re):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[_R(n)]:re(e[n])}),{}):e}function Tg(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function we(e){return Array.isArray(e)?e.map(we):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[Tg(n)]:we(e[n])}),{}):e}var wR={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Sa=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)||""}},va=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?re(r):(await n.client.patch("/apis/admin/session/me/",o,{version:null}),re(r))}),kg=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}),Pg=M("info/getAgentSettings",async(e,t)=>{let{deepdeskAPI:n}=t.extra;return(await n.client.get("/apis/admin/session/me/",{version:null})).ui_config}),z_=e=>e.info.agentInfo,V_=H({name:"info",initialState:wR,reducers:{setVisitorInfo(e,t){e.visitorInfo={...e.visitorInfo,...t.payload}}},extraReducers:e=>{e.addCase(va.pending,(t,n)=>{t.fetchState="loading",t.agentInfo={...t.agentInfo,...n.meta.arg}}).addCase(va.rejected,t=>{t.fetchState="error"}).addCase(va.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(kg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(Pg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(J,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:K_}=V_.actions,W_=V_.reducer;var $c={list:[],fetchState:"idle",isOpen:!1,page:"search"},$_=e=>e.search.isOpen,q_=e=>e.search.page,G_=e=>e.search.list;function X_(e,t=n=>n){return n=>n.search.list.filter(r=>r.type===e).map(t)}var lo=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:Sa(r),tags:e.tags});return i.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:e.query}))}),Q_=H({name:"search",initialState:$c,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=$c.fetchState,e.list=$c.list}},extraReducers:e=>{e.addCase(lo.pending,t=>{t.fetchState="loading"}).addCase(lo.rejected,(t,n)=>{t.fetchState="error",U.error(n.error)}).addCase(lo.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload}).addCase(J,()=>$c)}}),{resetSearch:qc,setIsOpen:at,setPage:ze}=Q_.actions,Y_=Q_.reducer;var ER=/(https?:\/\/[^\s]+)/,Gc=e=>e.split(" ").find(t=>ER.test(t));var Rg=x(X());var Xc=x(w()),CR=({onClick:e,shortKeys:t,children:n,...r})=>{let o=k("CommandPalette",Ye);return(0,Xc.jsxs)("button",{type:"button",...r,onClick:e,className:(0,Rg.default)(o.actionButton,r.className),children:[n,t&&t.map(i=>(0,Xc.jsx)("span",{className:(0,Rg.default)(o.actionShortcut,i===8629&&o.actionShortcutFixKerning),children:typeof i=="number"?String.fromCharCode(i):i},i))]})},yi=CR;var Pn=x(w()),bR=({children:e,primaryLabel:t,secondaryLabel:n,onPrimary:r,onSecondary:o,list:i})=>{let s=k("CommandPalette",Ye),a=j(ao),{selected:l,setSelected:u}=_r(),c=i[l],f=c&&typeof c.text=="string"&&Gc(c.text),d=(0,Er.useRef)(null);function y(v){if(!d.current)return;let _=d.current.querySelectorAll(".command-palette-list-item"),C=0,E=0;v==="down"?(_.forEach((R,P)=>{P===l&&(C=P)}),E=C===_.length-1?0:C+1):v==="up"?(_.forEach((R,P)=>{P===l&&(C=P)}),E=C?C-1:_.length-1):u(0);let b=_[E];b&&typeof E=="number"&&(u(E),b.scrollIntoView&&b.scrollIntoView({behavior:"smooth",block:E?"center":"end"}))}function S(){if(!d.current)return;let v=d.current.querySelectorAll(".command-palette-list-item"),_=0;v.forEach((E,b)=>{b===l&&(_=b)});let C=v[_];C&&C.click()}let h=()=>{f&&window.open(f,"_blank")},g=()=>{c&&r(c,l)},m=()=>{!c.type||["IMAGE","command"].includes(c.type)||o&&o(c,l)},p=(0,Er.useCallback)(v=>{if(v.key==="Enter"&&v.altKey&&f){h();return}if(v.key==="Enter"&&v.shiftKey){m();return}if(v.key==="ArrowDown"){v.preventDefault(),v.stopPropagation(),y("down");return}if(v.key==="ArrowUp"){v.preventDefault(),v.stopPropagation(),y("up");return}v.key==="Enter"&&l!==-1&&(v.preventDefault(),v.stopPropagation(),S())},[l]);return(0,Er.useEffect)(()=>(window.addEventListener("keyup",p),()=>{window.removeEventListener("keyup",p)}),[p]),(0,Pn.jsxs)("div",{className:s.actions,children:[(0,Pn.jsx)("div",{className:s.actionsWrapper,ref:d,children:e}),(0,Pn.jsxs)("div",{className:s.actionsBar,children:[f&&(0,Pn.jsx)(yi,{onClick:h,shortKeys:[Wc()?8997:"ALT",8629],children:a("visitUrl")}),c&&(0,Pn.jsxs)(Er.Fragment,{children:[o&&c.type&&!["command","image"].includes(c.type.toLowerCase())&&(0,Pn.jsx)(yi,{onClick:m,shortKeys:[8679,8629],children:n}),(0,Pn.jsx)(yi,{onClick:g,shortKeys:[8629],children:t})]})]})]})},J_=bR;var ew=x(O());var xa=x(w()),vi=()=>(0,xa.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,xa.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,xa.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 zt=x(w());function TR({onChange:e,onChangeType:t,placeholder:n,typePlaceholder:r,types:o,value:i,selectedType:s},a){let l=k("CommandPalette",Ye);return(0,zt.jsxs)("div",{className:l.search,children:[(0,zt.jsx)("div",{className:l.searchIcon,children:(0,zt.jsx)(vi,{})}),(0,zt.jsxs)("div",{className:l.searchInputWrapper,children:[(0,zt.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,zt.jsx)("div",{className:l.selectWrapper,children:(0,zt.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,zt.jsx)("option",{children:r}),o.map(u=>(0,zt.jsx)("option",{value:u.value,children:u.label},u.value))]})})]})]})}var tw=(0,ew.forwardRef)(TR);var _a=x(w());function uo({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:f,search:d}){let[y,S]=(0,Si.useState)(0),h=(0,Si.useRef)(null),g=()=>{o&&o(n),s(void 0),i(""),a(!1)},m=()=>{var p;if(r!==n&&o){o(n);return}if(l&&s){s(void 0),(p=h.current)==null||p.focus();return}if(d.length>0){i("");return}a(!1)};return(0,Si.useEffect)(()=>{S(0)},[d,r]),(0,_a.jsx)(di,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:f,onBack:m,onClose:g,children:(0,_a.jsxs)(B_,{selected:y,setSelected:S,isOpen:f,onChangeOpen:a,page:r,children:[r===n&&(0,_a.jsx)(tw,{ref:h,onChange:i,onChangeType:s,placeholder:e,value:d,selectedType:l,types:u,typePlaceholder:t}),c]})})}uo.Page=bg;uo.List=Eg;uo.Image=D_;uo.ListItem=Cg;uo.ActionsBar=J_;uo.Button=yi;var te=uo;var Fe=x(w()),kR=({suggestion:e,onUse:t,onDismiss:n,onTouched:r,onNext:o,onPrevious:i})=>{let s=e.text||e.url||e.message,a=k("EditSuggestionForm",f_),l=B(),u=j(og),c=L(S=>S.overlayInput.text);(0,Ig.useEffect)(()=>{e&&(l(Xe.actions.reset()),l(Xe.actions.stageSuggestion({text:s,suggestion:e,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Xe.actions.commitSuggestion()))},[e]);let f=S=>{S.preventDefault(),d(c)},d=S=>{l(Tc(S)),t(S)},y=S=>h=>{c!==s?window.confirm(u("warning"))&&S(h):S(h)};return(0,Ig.useEffect)(()=>{r&&r(c!==s)},[r,e,c]),(0,Fe.jsxs)("div",{className:a.root,children:[(0,Fe.jsxs)("div",{className:a.content,children:[e.title&&(0,Fe.jsx)("h3",{className:a.title,children:e.title}),e.searchKeywords&&e.searchKeywords.length>0&&(0,Fe.jsx)(Qd,{labels:e.searchKeywords}),(0,Fe.jsx)(N_,{onUse:d,value:c})]}),(0,Fe.jsxs)("form",{className:a.actions,onSubmit:f,children:[(0,Fe.jsxs)("div",{children:[(0,Fe.jsx)("button",{disabled:!i,className:a.pagination,type:"button",onClick:i&&y(i),children:(0,Fe.jsx)(Rc,{})}),(0,Fe.jsx)("button",{disabled:!o,className:a.pagination,type:"button",onClick:o&&y(o),children:(0,Fe.jsx)(p_,{})})]}),(0,Fe.jsxs)("div",{className:a.primaryButtons,children:[(0,Fe.jsx)(te.Button,{onClick:y(n),shortKeys:["esc"],children:u("dismiss")}),(0,Fe.jsx)(te.Button,{shortKeys:[8679,8629],type:"submit",children:u("add")})]})]})]})},Qc=kR;var PR=["{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}"],RR=new RegExp(PR.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function nw(e,t){let n=e.split(RR),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 f=a.charAt(0),d=0;do u=f?t.indexOf(f,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 rw(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var iw={suggestions:[],fetchState:"idle",isInitialRequest:null},ow={default:iw},sw=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)||[]},aw=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)??[]},lw=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")},xi=e=>e.textSuggestions,uw=e=>t=>t.text.startsWith(e),Yc=fe("textSuggestions/refresh"),Rn=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=ui(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getTextSuggestions(o,Sa(r),e);if(e==="default"){let c=s?l.filter(uw(a)):l;t.dispatch(Cn(c.slice(0,i)))}return l}),wa=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,{...Sa(r),input:e});if(!t.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(uw(e))),s&&(l=l.map(c=>({...c,text:c.source!=="trie-with-typos"?nw(c.text,e):c.text}))),l=rw(l,i),t.dispatch(Cn(l)),l}),cw=H({name:"textSuggestions",initialState:ow,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(Rn.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||iw;return{...t,[r]:{...o,fetchState:"loading",isInitialRequest:o.isInitialRequest===null}}}).addCase(Rn.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(Rn.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(wa.pending,t=>{t.default.fetchState="loading"}).addCase(wa.rejected,t=>{t.default.fetchState="error"}).addCase(wa.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(J,()=>ow)}}),{setTextSuggestions:dw,setSuggestionState:fw}=cw.actions,pw=cw.reducer;var mw={contentType:null,suggestion:null},gw=e=>e.activeSuggestion.suggestion,hw=e=>e.activeSuggestion.contentType,yw=H({name:"activeSuggestion",initialState:mw,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(J,()=>mw)}}),{setActiveSuggestion:In,resetActiveSuggestion:Lg}=yw.actions,vw=yw.reducer;var Ag={};Ce(Ag,{enUS:()=>IR,nlNL:()=>LR});var IR={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"}]},LR={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 AR={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Zc=({ui:e})=>e.overlayCollapsed;var Sw=H({name:"ui",initialState:AR,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:_i,setOverlayCollapsed:Cr,setOpenOverlayWhenTyping:xw,setOverlayCollapsedUserOverwrite:_w}=Sw.actions,ww=Sw.reducer;var Ca=x(O()),Cw=x(w()),Ew=Ca.default.createContext(null),wi=({broadcastEvents:e,children:t})=>{let n=Ca.default.useMemo(()=>e,[]);return(0,Cw.jsx)(Ew.Provider,{value:n,children:t})},Rt=()=>{let e=(0,Ca.useContext)(Ew);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var OR={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Vt=e=>e.auth.isLoggedIn,bw=e=>e.auth.loginFetchState,Tw=e=>e.auth.verifyFetchState,kw=e=>e.auth.showLoginOverlay,br=M("auth/validate",async(e,t)=>t.extra.deepdeskAPI.isLoggedIn()),Pw=M("auth/requestLogin",async({email:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.requestLoginByEmail(e)}),ba=M("auth/verifyLoginToken",async({token:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.verifyLoginToken(e)}),Rw=H({name:"auth",initialState:OR,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload}},extraReducers:e=>{e.addCase(br.pending,t=>{t.loginFetchState="loading"}),e.addCase(br.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(br.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(ba.pending,t=>{t.verifyFetchState="loading"}),e.addCase(ba.rejected,t=>{t.verifyFetchState="error"}),e.addCase(ba.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:Ei,setShowLoginOverlay:Iw}=Rw.actions,Lw=Rw.reducer;var Og="SetActiveSuggestion",Ci="ShowLoginOverlay",Ng="UserLoggedIn",NR="UserLoggedOut",Ln="ApplySuggestion",Mg="ApplyImageSuggestion",MR="ShowCommandPalette",DR=e=>({[Og]:t=>{e.dispatch(fw(t.state)),e.dispatch(In({contentType:t.contentType,suggestion:t.suggestion}))},[MR]:t=>{e.dispatch(at(t.isOpen)),t.page&&e.dispatch(ze(t.page))},[Ci]:t=>{e.dispatch(Iw(t))},[Ng]:()=>{e.dispatch(br())},[NR]:()=>{e.dispatch(br())},[Mg]:t=>{e.dispatch(Pc({suggestion:t.suggestion}))},[Ln]:t=>{e.dispatch(Ht({...t,eventMetrics:{inputType:"mouse"},replace:"selection"})),e.dispatch(yr())}}),Aw=DR;var Dg=x(w()),FR=()=>{var S;let[e,t]=(0,Ow.useState)(!1),n=L(gw),r=L(hw),o=L(xi),i=B(),s=Rt(),a=j(Ag),l=()=>{n!==null&&e?window.confirm(a("warning"))&&u():u()},u=()=>{i(Lg()),i(_i(!0)),i(Xe.actions.reset())},c=(h,g)=>{i(Lg()),i(_i(!0)),s.send(Ln,{text:h,suggestion:{...g,source:`${g.source||"text_recommendation"}-preview`}})};if(n===null||r===null)return null;let f=(S=o[r])==null?void 0:S.suggestions.indexOf(n),d=f===0||f===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[f-1]})),y=f===o[r].suggestions.length-1||f===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[f+1]}));return(0,Dg.jsx)(di,{autoFocus:!0,isOpen:f!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Dg.jsx)(Qc,{onTouched:t,onDismiss:u,onUse:h=>c(h,n),suggestion:n,onNext:y,onPrevious:d})})},Nw=FR;var Jc=x(X()),Kt=x(O());var Dw=x(X());var Mw={root:"_root_1ukx5_1"};var Fw=x(w()),jR=({className:e,value:t,...n})=>{let r=k("TextInput",Mw);return(0,Fw.jsx)("input",{className:(0,Dw.default)(e,r.root),type:"text",value:t,...n})},Ta=jR;var Fg={};Ce(Fg,{enUS:()=>HR,nlNL:()=>BR});var HR={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"}]},BR={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 jw={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 he=x(w());var UR=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch{return e}},zR=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=j(Fg),s=k("LoginTokenDialog",jw),a=L(Tw),l=B(),u=D("productName"),[c,f]=(0,Kt.useState)(e||""),[d,y]=(0,Kt.useState)(0),[S,h]=(0,Kt.useState)(""),g=(0,Kt.useCallback)(async _=>{_.preventDefault(),l(Pw({email:c})),y(1)},[n,c]),m=()=>{h(""),y(0)},p=(0,Kt.useCallback)(async _=>{_.preventDefault();let C=UR(_.target.elements.token.value);if(!C){h(i("verifyCodeError",{login:v}));return}l(ba({token:C}))},[n]),v=(0,Kt.useMemo)(()=>_=>(0,he.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:m,children:_},"back-button"),[]);return(0,Kt.useEffect)(()=>{a==="error"&&h(i("verifyCodeError",{login:v})),a==="done"&&r()},[a]),(0,he.jsx)(di,{autoFocus:!0,isOpen:t,contentAriaLabel:i("promptTitle",{productName:u}),overlayAriaLabel:i("promptTitle",{productName:u}),onClose:o,onBack:o,children:(0,he.jsxs)("div",{className:s.root,children:[(0,he.jsx)("h1",{className:s.title,children:i("promptTitle",{productName:u})}),d===0&&(0,he.jsxs)("form",{onSubmit:g,children:[(0,he.jsx)("h2",{className:s.subtitle,children:i("requestCodeTitle")}),(0,he.jsx)("p",{className:s.text,children:i("requestCodeBody",{productName:u})}),(0,he.jsx)(Ta,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:c,onChange:_=>f(_.target.value)}),(0,he.jsx)("div",{className:s.actions,children:(0,he.jsx)("button",{type:"submit",className:(0,Jc.default)(s.button,s.primaryButton),children:i("requestCodeSubmitLabel")})})]}),d===1&&(0,he.jsxs)("form",{onSubmit:p,children:[(0,he.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,he.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,he.jsx)(Ta,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),S&&(0,he.jsx)("div",{className:s.errorMessage,children:S}),(0,he.jsxs)("div",{className:s.actions,children:[(0,he.jsx)("button",{type:"button",className:(0,Jc.default)(s.button),onClick:m,children:i("back")}),(0,he.jsx)("button",{type:"submit",className:(0,Jc.default)(s.button,s.primaryButton),disabled:["loading","done"].includes(a),children:i("verifyCodeSubmitLabel")})]})]})]})})},Hw=zR;var Uw=x(w()),VR=()=>{let e=L(kw),t=L(z_),n=D("adminUrl"),r=Rt(),o=()=>r.send(Ci,!1),i=()=>{r.send(Ci,!1),r.send(Ng)};return(0,Uw.jsx)(Hw,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},Bw=VR;var p1=x(Bg()),Je=x(O());var aI={data:null,fetchState:"idle"},Ww=e=>e.contentTypes.data,ka=M("contentTypes/getContentTypes",async(e,t)=>t.extra.deepdeskAPI.getContentTypes()),lI=H({name:"contentTypes",initialState:aI,reducers:{},extraReducers:e=>{e.addCase(ka.pending,t=>{t.fetchState="loading"}).addCase(ka.rejected,t=>{t.fetchState="error"}).addCase(ka.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),$w=lI.reducer;function Pa(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 qw=x(O());function Gw(e,t){(0,qw.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 Ra=x(O());var Xw={data:null,fetchState:"idle"},ed=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},Wt=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)}),uI=e=>e.filter((t,n)=>n===e.findIndex(r=>r.text===t.text)),cI=H({name:"entities",initialState:Xw,reducers:{},extraReducers:e=>{e.addCase(Wt.pending,t=>{t.fetchState="loading"}).addCase(Wt.rejected,t=>{t.fetchState="error"}).addCase(Wt.fulfilled,(t,n)=>{t.fetchState="done",t.data=uI(t.data?[...t.data,...n.payload]:n.payload)}).addCase(J,()=>Xw)}}),Qw=cI.reducer;var Ug={};Ce(Ug,{enUS:()=>dI,nlNL:()=>fI});var dI={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},fI={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Yw={root:"_root_17kae_1",empty:"_empty_17kae_5"};var co=x(w()),pI=({onCopy:e,onUse:t})=>{let n=(0,Ra.useRef)(null),r=k("EntitiesList",Yw),o=j(Ug),i=L(ed),s=B();return(0,Ra.useEffect)(()=>{s(Wt())},[]),(0,Ra.useEffect)(()=>{n.current&&n.current.focus()},[n]),(0,co.jsxs)("div",{className:r.root,ref:n,tabIndex:-1,children:[i&&i.length>0&&(0,co.jsx)(te.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,co.jsx)(te.List,{children:i.map((a,l)=>(0,co.jsx)(te.ListItem,{index:l,closeOnSelect:!0,onClick:()=>e(a),children:a.text},a.text))},"entities")}),i&&i.length===0&&(0,co.jsx)("p",{className:r.empty,children:o("noResults")})]})},Zw=pI;var $t=x(O());var Jw={data:null,fetchState:"idle"},e1=e=>e.summary.data,t1=e=>e.summary.fetchState==="error",An=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();return s.length===0?Promise.reject(new Error("No messages are included")):{summary:await r.getSummary(s,{promptInstruction:n.summarizerPromptInstruction,model:n.summarizerModel})}}),mI=H({name:"summary",initialState:Jw,reducers:{},extraReducers:e=>{e.addCase(An.pending,t=>{t.data=null,t.fetchState="loading"}).addCase(An.rejected,t=>{t.data=null,t.fetchState="error"}).addCase(An.fulfilled,(t,n)=>{t.fetchState="done",n.payload&&(t.data=n.payload.summary)}).addCase(J,()=>Jw)}}),n1=mI.reducer;var zg={};Ce(zg,{enUS:()=>gI,nlNL:()=>hI});var gI={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."}]},hI={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 r1={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 On=x(w()),yI=({onCopy:e})=>{let t=(0,$t.useRef)(null),n=k("SummaryForm",r1),[r,o]=(0,$t.useState)(""),i=j(zg),s=L(e1),a=L(t1),l=B(),u=()=>{l(st({name:"summary copied to clipboard",data:{originalText:s,finalText:r},options:{includeConversationData:!0}})),e(r)},c=()=>{let f=document.getSelection();f&&l(st({name:"summary copied to clipboard",data:{originalText:s,finalText:f==null?void 0:f.toString()},options:{includeConversationData:!0}}))};return(0,$t.useEffect)(()=>{l(An())},[]),(0,$t.useEffect)(()=>{o(s||"")},[s]),(0,$t.useEffect)(()=>{t.current&&s&&t.current.focus()},[t,s]),(0,$t.useEffect)(()=>{let f=d=>{d.key==="Enter"&&d.shiftKey&&u()};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f)}},[r]),(0,On.jsx)("div",{className:n.root,tabIndex:-1,children:a?(0,On.jsx)("p",{className:n.error,children:i("error")}):(0,On.jsxs)($t.Fragment,{children:[(0,On.jsx)("div",{className:n.main,children:(0,On.jsx)("textarea",{placeholder:s?void 0:i("loading"),disabled:!s,className:n.textInput,ref:t,value:r,onCopy:c,onChange:f=>o(f.target.value)})}),(0,On.jsx)("div",{className:n.actions,children:(0,On.jsx)(te.Button,{shortKeys:[8679,8629],onClick:u,children:i("copy")})})]})})},o1=yI;var Vg={};Ce(Vg,{enUS:()=>vI,nlNL:()=>SI});var vI={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?"}]},SI={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 Tr=x(O());var Kg={};Ce(Kg,{enUS:()=>xI,nlNL:()=>_I});var xI={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"}]},_I={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 i1={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 Wg={data:[],fetchState:"idle"},s1=e=>{var t;return(t=e.answer)==null?void 0:t.data},a1=e=>e.answer.fetchState,Ti=fe("answer/resetKnowledgeSearch"),bi=M("answer/getAnswer",async(e,t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState().answer.data,o=(s=t.getState().conversation.current)==null?void 0:s.profileCode;if(!o)throw new Error("Profile is not defined");let i=await n.knowledgeAssist({promptInstruction:e.promptInstruction,question:e.question},r,o);return{question:e.question,answer:i}}),wI=H({name:"answer",initialState:Wg,reducers:{},extraReducers:e=>{e.addCase(bi.pending,t=>{t.fetchState="loading"}).addCase(bi.rejected,t=>{t.fetchState="error"}).addCase(bi.fulfilled,(t,n)=>{t.fetchState="done",t.data=[...t.data,n.payload]}).addCase(J,()=>Wg).addCase(Ti,()=>Wg)}}),l1=wI.reducer;var Ia=x(w()),u1=()=>(0,Ia.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Ia.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Ia.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 Ze=x(w()),EI=({onUse:e,onResetQuestion:t,question:n,promptInstruction:r})=>{let[o,i]=Tr.default.useState(""),{setSelected:s}=_r(),a=(0,Tr.useRef)(null),l=k("EntitiesList",i1),u=j(Kg),c=B(),f=L(s1),d=L(a1),y=async h=>{h.preventDefault(),h.stopPropagation(),o!==""&&c(bi({question:o,promptInstruction:r}))},S=(h,g)=>{c(st({name:"knowledge assist source viewed",data:{question:g,sourceViewed:h.url||h.name},options:{includeConversationData:!0}}))};return(0,Tr.useEffect)(()=>{var h;n&&d==="idle"?c(bi({question:n,promptInstruction:r})):(h=a.current)==null||h.focus()},[a,d]),(0,Tr.useEffect)(()=>{d==="done"&&(c(st({name:"knowledge assist question answered",data:{question:o||n,sources:f[f.length-1].answer.sources,answer:f[f.length-1].answer.answer,isFollowUpQuestion:f.length>1},options:{includeConversationData:!0}})),s(f.length-1),i(""))},[d,f]),(0,Tr.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,f]),(0,Ze.jsxs)("div",{className:l.root,children:[f.length>0&&(0,Ze.jsx)("div",{className:l.alignRight,children:(0,Ze.jsx)(te.Button,{onClick:t,children:u("reset")})}),(0,Ze.jsxs)(te.ActionsBar,{list:f.map(({answer:h})=>({text:h.answer,type:"answer"})),primaryLabel:u("use"),onPrimary:h=>e(h.text),children:[f.map(({question:h,answer:g},m)=>(0,Ze.jsx)(te.List,{children:(0,Ze.jsx)(te.ListItem,{"data-testid":"knowledge-search-answer",index:m,description:g.answer,closeOnSelect:!0,onClick:()=>e(g.answer),onSourceClick:p=>S(p,h),sources:g.sources,styles:{title:l.question,description:l.answer},children:h})},`${g.answer}_${m}`)),d==="loading"&&(0,Ze.jsx)("p",{className:l.status,children:u("loading")}),d==="error"&&(0,Ze.jsx)("p",{className:l.status,children:u("error")}),(0,Ze.jsxs)("form",{className:l.form,onSubmit:y,children:[(0,Ze.jsx)("input",{ref:a,placeholder:u("anotherQuestion"),className:l.input,type:"text",value:o,onFocus:()=>{s(-1)},onChange:h=>{s(-1),i(h.target.value)}}),(0,Ze.jsx)("button",{type:"submit",className:l.submit,children:(0,Ze.jsx)(u1,{})})]})]})]})},c1=EI;var CI={data:null,fetchState:"idle"},ki=e=>e.profile.data,td=e=>e.profile.data?e.profile.data.uiConfig.widget.types.filter(t=>t.isActive):[],La=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)}),bI=H({name:"profile",initialState:CI,reducers:{},extraReducers:e=>{e.addCase(La.pending,t=>{t.fetchState="loading"}).addCase(La.rejected,t=>{t.fetchState="error"}).addCase(La.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),d1=bI.reducer;var Ee=x(w()),TI=200,kI=5,PI=4,RI=e=>e.reduce((t,n)=>[...t,...n.list.map(r=>({...r,type:n.value}))],[]),f1=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),II=()=>{let e=B(),t=Rt(),n=j(Vg),[r,o]=(0,Je.useState)(!1),[i,s]=(0,Je.useState)(""),a=L(q_),l=L(ki),[u,c]=(0,Je.useState)(null),[f,d]=(0,Je.useState)([]),[y,S]=(0,Je.useState)(),h=L(Vt),g=D("showSearch"),m=D("showEntitiesCommand"),p=D("showSummaryCommand"),v=D("showKnowledgeSearch"),_=D("showImageSearch"),C=D("searchTriggerKey"),E=L(Ww),b=L(G_),R=L($_),P=I=>dn(b.filter(W=>W.type===I.toUpperCase()),I),N=[{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(I=>I.shouldShow),G=[{label:n("entitiesClipboard"),onClick:()=>e(ze("entities")),shouldShow:m&&f1(n("entitiesClipboard"),i),experimental:!0},{label:n("summaryClipboard"),onClick:()=>e(ze("summary")),shouldShow:p&&f1(n("summaryClipboard"),i),experimental:!0},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(ze("knowledgeAssist")),shouldShow:v,experimental:!0}].filter(I=>I.shouldShow),V=(E==null?void 0:E.map(I=>({value:I.code.toUpperCase(),label:`${I.name}s`,list:P(I.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],He=(0,Je.useCallback)((0,p1.default)((I,W)=>{e(lo({query:I,type:W,tags:["search-overlay"]}))},TI),[]),cn=RI([...V,...N]),Xt=(0,Je.useCallback)((I,W)=>{if(!W)return;let At=[...N,...V].find(({value:Un})=>Un===W);At&&(e(ze("edit")),c({...I,searchTerm:void 0}),d(At.list))},[e,u,V]),mo=(0,Je.useCallback)((I,W)=>{switch(W.type){case"IMAGE":t.send(Mg,{suggestion:W});break;default:t.send(Ln,{text:I,suggestion:W})}e(at(!1))},[e]),Bi=I=>{Pa(I.text),e(st({name:"entity copied",data:{entity:I,type:"copy"}})),e(at(!1))},Ar=I=>{t.send(Ln,{text:I,suggestion:{source:"knowledge-assist",text:I}}),e(st({name:"answer used",data:{originalText:I},options:{includeConversationData:!0}})),s(""),e(ze("search")),e(Ti()),e(at(!1))},Ka=I=>{Pa(I),e(at(!1))},Wa=I=>{t.send(Ln,{text:I.text,suggestion:{source:"entity",text:I.text}}),e(at(!1))},Ui=u===null||f.indexOf(u)-1<0?void 0:()=>c(f[f.indexOf(u)-1]),zi=u===null||f.indexOf(u)===f.length-1?void 0:()=>c(f[f.indexOf(u)+1]);function dn(I,W){return I.slice(0,y?10:W.toLowerCase()==="image"?PI:kI)}function Vi(I,W,At){return W.reduce((Un,fn)=>At&&y===At?fn.length+Un:dn(fn,At).length+Un,I)}function Or(I){return W=>{r?window.confirm(n("warning"))&&(I(W),o(!1)):I(W)}}return(0,Je.useEffect)(()=>{i?He(i,y):e(qc())},[i,y]),(0,Je.useEffect)(()=>{a==="search"&&e(Ti())},[a]),(0,Je.useEffect)(()=>{h&&e(ka())},[h]),Gw(C,()=>e(at(!0))),!g||!l?null:(0,Ee.jsxs)(te,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Or(I=>e(at(I))),onChangeType:I=>S(I),onChangePage:Or(I=>e(ze(I))),selectedType:y,search:i,page:a,isOpen:R,types:[...V,...N],children:[(0,Ee.jsx)(te.Page,{id:"search",children:(0,Ee.jsxs)(te.ActionsBar,{list:[...G.map(I=>({text:I.label,type:"command"})),...cn.map(I=>({text:I.text||I.url||I.message,type:I.type}))],primaryLabel:n("use"),secondaryLabel:n("preview"),onPrimary:({text:I},W)=>mo(I,cn[W]),onSecondary:(I,W)=>{Xt(cn[W-G.length],cn[W-G.length].type)},children:[G.length>0&&(0,Ee.jsx)(te.List,{heading:n("commands"),children:G.map((I,W)=>(0,Ee.jsx)(te.ListItem,{index:Vi(W,[],"commands"),closeOnSelect:!1,onClick:I.onClick,isExperimental:I.experimental,children:I.label},I.label))}),[...V,...N].map(({value:I,label:W,list:At,lineClamp:Un,listOrientation:fn},Ki)=>(0,Ee.jsx)(te.List,{heading:W,orientation:fn==="horizontal"?"horizontal":"vertical",children:dn(At,I).map((ct,dt)=>(0,Ee.jsx)(te.ListItem,{index:Vi(G.length+dt,[...V,...N].slice(0,Ki).map(({list:Nr})=>Nr),I),closeOnSelect:!1,lineClamp:Un,onClick:()=>mo(ct.text,ct),description:I!=="IMAGE"?ct.title&&ct.text:void 0,children:I==="IMAGE"?(0,Ee.jsx)(te.Image,{title:ct.title||ct.text,src:ct.image}):ct.title||ct.text},`${ct.id}-${ct.text}`))},I))]})}),(0,Ee.jsx)(te.Page,{id:"edit",onDismiss:Or(()=>{e(ze("search")),c(null)}),children:u&&(0,Ee.jsx)(Qc,{suggestion:u,onTouched:o,onDismiss:()=>{o(!1),e(ze("search")),c(null),d([])},onNext:zi,onPrevious:Ui,onUse:I=>{e(ze("search")),mo(I,{...u,source:`${u.source||"text_recommendation"}-preview`}),e(at(!1)),d([]),c(null)}})}),(0,Ee.jsx)(te.Page,{id:"entities",title:n("entitiesTitle"),isExperimental:!0,onDismiss:Or(()=>{e(ze("search"))}),children:(0,Ee.jsx)(Zw,{onUse:Wa,onCopy:Bi})}),(0,Ee.jsx)(te.Page,{id:"summary",title:n("summaryTitle"),isExperimental:!0,onDismiss:Or(()=>{e(ze("search"))}),children:(0,Ee.jsx)(o1,{onCopy:Ka})}),(0,Ee.jsx)(te.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),isExperimental:!0,onDismiss:Or(()=>{e(Ti()),e(ze("search"))}),children:(0,Ee.jsx)(c1,{promptInstruction:l.knowledgeAssistPromptInstruction,question:i,onUse:Ar,onResetQuestion:()=>{e(Ti()),s("")}})})]})},m1=II;var Pi=x(w()),LI=()=>{let e=D("showSearch"),t=D("isEmbedded");return(0,Pi.jsxs)(g1.Fragment,{children:[e&&(0,Pi.jsx)(m1,{}),(0,Pi.jsx)(Nw,{}),t&&(0,Pi.jsx)(Bw,{})]})},h1=LI;function Ri(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 nd=x(O());var Li=x(O());var y1=x(O());function v1(e,t,n){(0,y1.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var AI=/[.*+?^${}()|[\]\\]/g,OI=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function NI(e){return e.replace(AI,"\\$&")}function MI(e,t){let n=e.split("").findIndex((r,o)=>r!==t[o]);return n>-1?n:Math.min(e.length,t.length)}function $g(e){return e.search(OI)}function S1(e,t=[]){let n=e;return t.forEach(r=>{if(!r)return;let o=new RegExp(`\\b(${NI(r)})\\b`,"gi");n=n.replace(o,"<strong>$1</strong>")}),n}function x1(e){return e.replace(xo,'<mark data-type="placeholder">$1</mark>')}function Ii(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function DI(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 qg(e,t,n={}){if(t){let r=MI(t.toLowerCase(),e.toLowerCase()),o=Ii(e.substring(r,e.length));if(n.stripAgentPart){let l=e.substring(0,r),u=$g(l);return`<span style="opacity: 0.5">${l.substring(u+1)}</span>${o}`}let s=t.split(Py).length>3||t.length>30?DI(t.trim(),r):0;return`${`${s>0?"\u2026":""}${Ii(e.substring(s,r))}`}<strong>${o}</strong>`}return e}var _1={badge:"_badge_1syy2_1",formattedText:"_formattedText_1syy2_5"};var Gg=x(w()),jI=["search","personal-collection-search","search-autocomplete"];function HI(e,t,n,r={}){let o="";return jI.includes(t)?o=S1(qg(e,n,{stripAgentPart:!0}),r.searchKeywords??[n]):o=qg(e,n,r),r.placeholders===!0&&(o=x1(o)),o}var BI=()=>{},UI=({index:e,selected:t,suggestion:n})=>{let r=D("inlineSuggestions"),o=L(ui),i=B(),s=k("TextSuggestion",_1),a=(0,Li.useRef)(null);(0,Li.useEffect)(()=>{let u=setTimeout(()=>{i(o_({text:n.text,suggestion:n}))},500);return()=>{clearTimeout(u)}},[n]),v1(a,"click",()=>{i(la(e)),i(Ht({suggestion:n,text:n.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,Li.useMemo)(()=>HI(n.text,n.source,o,{stripAgentPart:r,placeholders:!0,searchKeywords:n.searchKeywords}),[r,n.text,n.source,o,n.searchKeywords]);return n.source==="gpt"&&!r?null:(0,Gg.jsx)(oe,{ref:a,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:BI,children:(0,Gg.jsx)(fi,{containerTagName:"div",noWrap:!1,tagName:"span",className:s.formattedText,content:l})})},w1=UI;var Xg=x(w()),zI=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,nd.useMemo)(()=>{let o=e.map((i,s)=>(0,Xg.jsx)(w1,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,Xg.jsx)(nd.Fragment,{children:r})},rd=zI;var E1={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var Aa=x(w()),VI=({textSuggestions:e,selectedIndex:t})=>{let n=k("InlineSuggestionsOverlay",E1),r=L(Ri),o=B(),i=L(Vt),s=L(li),a=L(Zc),l=D("showTextSuggestions");return Sr(()=>{o(Cr({collapse:!0,skipWhenInputFocus:!0}))}),a||!r||!l||e.length===0||i!==!0||s===!1?null:(0,Aa.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,Aa.jsx)("div",{className:n.paper,children:(0,Aa.jsx)(ht,{children:(0,Aa.jsx)(rd,{suggestions:e,selectedIndex:t})})})})},KI=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),C1=wn(KI)(VI);var id=x(X()),Ai=x(O());var b1=x(O());function T1(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 U.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){U.error(s)}}]}var P1=x(X()),Nn=x(O());var Qg={};Ce(Qg,{enUS:()=>WI,nlNL:()=>$I});var WI={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"}]}]},$I={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 k1={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var kr=x(w()),Yg=(e,t,n)=>r=>(0,kr.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),qI=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r})=>{let o=j(Qg),i=Rt(),s=k("Login",k1),a=D("productName"),l=(0,Nn.useCallback)(h=>{h.preventDefault(),r&&r(parseInt(h.target.value,10))},[]),u=(0,Nn.useCallback)(h=>{h.preventDefault(),i.send(Ci,!0)},[t]),c=(0,Nn.useMemo)(()=>h=>(0,kr.jsx)("a",{href:t,className:s.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[t]),f=(0,Nn.useCallback)(h=>(0,kr.jsx)("button",{type:"button",className:s.anchorButton,onClick:u,children:h},"prompt"),[u]),{min:d,hour:y,day:S}=(0,Nn.useMemo)(()=>({min:Yg(s,60*10,l),hour:Yg(s,60*60,l),day:Yg(s,60*60*12,l)}),[]);return(0,kr.jsxs)("div",{className:(0,P1.default)(e,s.root),children:[o("loginPlease",{login:n?f:c,productName:a}),r&&(0,kr.jsxs)(Nn.Fragment,{children:[(0,kr.jsx)("br",{}),o("snooze",{min:d,hour:y,day:S})]})]})},od=qI;var R1={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var Oa=x(w()),GI=({title:e})=>{let t=k("SearchTrigger",R1),n=B();return(0,Oa.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(at(!0)),children:[(0,Oa.jsx)(vi,{}),(0,Oa.jsx)("span",{className:t.text,children:e})]})},I1=GI;var Zg={};Ce(Zg,{enUS:()=>XI,nlNL:()=>QI});var XI={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"}]},QI={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 L1={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=x(w()),YI=({textSuggestions:e,selectedIndex:t})=>{let n=k("SuggestionsOverlay",L1),r=j(Zg),o=L(Ri),i=Jx(),s=B(),a=(0,Ai.useRef)(null),l=D("searchTriggerKey"),u=D("productName"),c=L(Zc),f=L(Vt),d=L(li),[y,S]=(0,Ai.useState)(null),h=D("showSearch"),g=D("showTextSuggestions"),m=D("adminUrl"),p=D("isEmbedded"),[v,_]=T1("dd-snooze-until-ms",0),C=c||v>Date.now(),E=e.filter(P=>P.source!=="gpt").length,b=()=>{C&&_(0),s(_w(!C))},R=P=>{let N=Date.now()+P*1e3;_(N),U.info(`Snooze until: ${new Date(N)}`),s(Cr({collapse:!0}))};return(0,Ai.useEffect)(()=>{E===0&&S(null)},[e,E]),Sr(()=>{s(Cr({collapse:!0,skipWhenInputFocus:!0}))}),f===null||d===!1?null:f===!1?(0,ue.jsxs)("div",{ref:a,className:(0,id.default)(n.root,{[n.isCollapsed]:C}),children:[!C&&(0,ue.jsxs)("div",{className:n.triggers,children:[(0,ue.jsx)("div",{style:{flex:1}}),(0,ue.jsx)("div",{className:n.triggersRight,children:(0,ue.jsx)(jr,{className:n.toggleButton,title:r("collapse"),onClick:b,isCollapsed:!1})})]}),(0,ue.jsx)("div",{className:n.toggleButtonWrapper,children:(0,ue.jsx)(jr,{className:n.toggleButton,title:r("open",{productName:u}),onClick:b,isCollapsed:!0})}),(0,ue.jsx)("div",{className:n.collapsible,children:(0,ue.jsx)(od,{loginUrl:m,isEmbedded:p,onSnooze:R})})]}):!i||!o?null:(0,ue.jsxs)("div",{ref:a,className:(0,id.default)(n.root,{[n.isCollapsed]:C}),children:[!C&&(0,ue.jsxs)("div",{className:n.triggers,children:[(0,ue.jsx)("div",{style:{flex:1},children:h&&(0,ue.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>S(r(Wc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>S(null),children:(0,ue.jsx)(I1,{title:r("search")})})}),(0,ue.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,ue.jsx)("div",{className:(0,id.default)(!y&&n.hintsHidden,n.hints),children:y}),(0,ue.jsx)(jr,{className:n.toggleButton,title:r("collapse"),onClick:b,isCollapsed:!1})]})]}),(0,ue.jsx)("div",{className:n.toggleButtonWrapper,children:(0,ue.jsx)(jr,{className:n.toggleButton,title:r("open",{productName:u}),onClick:b,isCollapsed:!0})}),E>0&&g&&(0,ue.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,ue.jsx)(ht,{children:(0,ue.jsx)(rd,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},ZI=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),sd=wn(ZI)(YI);var Na=x(w()),JI=({children:e})=>{let n=D("locale").replace("-","");return(0,Na.jsx)($d.Provider,{value:n,children:e})},eL=({store:e,customStyles:t={},children:n})=>(0,Na.jsx)(qm,{store:e,children:(0,Na.jsx)(JI,{children:(0,Na.jsx)($i.Provider,{value:t,children:n})})}),Oi=eL;var Sd=x(X());var Fn=x(O());var A1=x(O()),tL=["div","span","mark","strong","b","i","u","em"];function Jg(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(tL.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,A1.cloneElement)(r,{children:Jg(s,t,n+1)})]}return[...e,...t]}function an(e){return e.tagName.toLowerCase()==="textarea"}var O1={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 cd=x(O());var th=x(X()),It=x(O());var ad=x(O()),nL=["bottom","height","left","right","top","width"],rL=(e={},t={})=>nL.some(n=>e[n]!==t[n]),Mn=new Map,N1,M1=()=>{let e=[],t=[];Mn.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();rL(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{Mn.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),N1=window.requestAnimationFrame(M1)};function oL(e,t){return{observe(){let n=Mn.size===0;if(Mn.has(e)){let r=Mn.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else Mn.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&M1()},unobserve(){let n=Mn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Mn.delete(e),Mn.size||cancelAnimationFrame(N1)}}}}function eh(e){let[t,n]=(0,ad.useState)(null);return(0,ad.useLayoutEffect)(()=>{if(!e.current)return;let r=oL(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var Ni=x(O()),F1=x(Ou());var D1={root:"_root_1jq08_1"};var j1=({children:e})=>{let[t,n]=(0,Ni.useState)(null),r=(0,Ni.useContext)($i);return(0,Ni.useLayoutEffect)(()=>{let o=document.createElement("div");return io(o),o.classList.add(D1.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,F1.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 ld=x(w()),Mi=(e=!1)=>{let[t,n]=(0,It.useState)(e),r=(0,It.useCallback)(()=>n(!0),[]),o=(0,It.useCallback)(()=>n(!1),[]),i=(0,It.useCallback)(()=>n(a=>!a),[]),s=(0,It.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function nh(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 Di=({className:e,triggerRef:t,boundaryRef:n=(0,It.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=nh,...a})=>{let l=eh(t),u=eh(n),c=(0,It.useMemo)(()=>s(l,u,0),[l,u]);return(0,ld.jsx)(j1,{children:(0,ld.jsx)("div",{className:(0,th.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,ld.jsx)("div",{className:(0,th.default)(e,ln.root),children:i})})})};var Pr=x(w()),iL=({inputStyle:e,inputElement:t})=>{let n=k("TabCompletion",Tt),r=Mi(document.activeElement===t);return Sr(()=>r.close()),(0,cd.useEffect)(()=>{let o=()=>r.open();return t.addEventListener("focus",o),()=>{t.removeEventListener("focus",o)}},[]),(0,Pr.jsxs)(cd.Fragment,{children:[(0,Pr.jsx)("mark",{className:Tt.caret,ref:r.triggerRef}),r.opened&&(0,Pr.jsx)(Di,{className:n.popoverSuggestionsRoot,triggerRef:r.triggerRef,position:"above",align:"start",children:(0,Pr.jsx)("div",{style:e,className:n.suggestionsOverlayInputStyles,children:(0,Pr.jsx)(sd,{inline:!0})})})]})},ud=class extends Ut{charCounter=0;charLength=0;found=!1;onlyAtEnd=!1;props;onBeforeParse(t,n){var r;return this.props=n,this.charCounter=0,this.onlyAtEnd=n.inlineSuggestionsOnlyAtEnd??!1,this.charLength=(an(n.inputElement)?n.inputElement.value.length:(r=n.inputElement.textContent)==null?void 0:r.length)??0,this.found=!1,t}match(t){if(this.found||!this.props||this.props.selection===null)return null;let[n,r]=this.props.selection;if(n!==r||this.onlyAtEnd&&n!==this.charLength)return null;let o=n,s=o>=this.charCounter&&o<=this.charCounter+t.length?{index:$g(t.slice(0,o))+1-this.charCounter,length:0,match:"",valid:!0}:null;return s&&(this.found=!0),this.charCounter+=t.length,s??null}replaceWith(t,n){return(0,Pr.jsx)(iL,{inputStyle:n.inputStyle,inputElement:n.inputElement},"caret")}asTag(){return"mark"}};var z1=x(X());var gd=x(O());function H1(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function dd(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function B1(e){return e!=null}var U1=x(X()),fd=x(O());var rh=x(w()),pd=(0,fd.forwardRef)(({className:e,children:t,...n},r)=>{let o=(0,fd.useRef)(null),i=k("TabCompletion",Tt);return(0,rh.jsx)("div",{ref:dd([o,r]),className:(0,U1.default)(e,i.popoverContentContainer),...n,children:(0,rh.jsx)("div",{className:i.popoverContent,children:t})})});var Rr=x(w()),sL=e=>t=>{let n=nh(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},aL=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=k("TabCompletion",Tt),s=Mi(),a=(0,gd.useMemo)(()=>sL(e.getBoundingClientRect()),[e]),[l,u]=Fc(e);return(0,gd.useEffect)(()=>{u?s.open():s.close()},[u]),(0,Rr.jsxs)("span",{children:[(0,Rr.jsx)("mark",{ref:dd([l,s.triggerRef]),className:(0,z1.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,Rr.jsx)(Di,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,Rr.jsx)(pd,{style:n,children:(0,Rr.jsx)("div",{className:i.hintText,children:o})})})]})},md=class extends Ut{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${H1(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(B1);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)(aL,{inputElement:n.inputElement,suggestion:n.suggestion,inputStyle:n.inputStyle,boundaryRef:n.boundaryRef,children:t},`keyword_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var yd=x(X());var Ke=x(O());var oh=x(w()),V1=()=>(0,oh.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,oh.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=x(O());var W1=x(Bg());var K1={root:"_root_1muu8_1",content:"_content_1muu8_7"};function hd(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 ih(e){return e.replace("https://www.","").replace("https://","")}var Lt=x(w()),lL=3,uL=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),cL=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=lL})=>{let i=k("LinkSearch",K1),[s,a]=(0,Ir.useState)(""),l=B(),u=L(sw("url")),c=L(X_("URL",uL)),[f,d]=(0,Ir.useState)(c.length-1),y=D("fallbackImage"),S=p=>{let v=p.target;a(v.value)},h=(p,v)=>{p.stopPropagation(),p.preventDefault(),window.open(v,"_blank")},g=p=>{var C;let v=f-1<0?c.length-1:f-1,_=f+1===c.length?0:f+1;p.code==="Escape"&&(a(""),t()),p.code==="ArrowUp"&&d(v),p.code==="ArrowDown"&&d(_),p.code==="Enter"&&e(((C=c[f])==null?void 0:C.text)||s)},m=(0,Ir.useCallback)((0,W1.default)(p=>{l(lo({query:p,type:"URL",tags:["link-search"]}))},300),[]);return(0,Ir.useEffect)(()=>{s&&m(s)},[s]),(0,Ir.useEffect)(()=>()=>{l(qc())},[]),(0,Lt.jsxs)("div",{className:i.root,children:[(0,Lt.jsx)(ht,{withDivider:!0,children:(s?c:u).slice(0,o).map((p,v)=>(0,Lt.jsx)(oe,{selected:f===v,onClick:()=>e(p.text),"data-testid":"linksearch-suggestion",children:(0,Lt.jsxs)(me,{children:[(0,Lt.jsx)(me.Image,{src:hd(p,"small",y||void 0),title:p.title||p.text}),(0,Lt.jsxs)(me.Content,{className:i.content,cropText:!0,children:[(0,Lt.jsx)(me.Title,{children:p.title||ih(p.text)}),p.title&&ih(p.text)]}),(0,Lt.jsx)(oe.Actions,{children:(0,Lt.jsx)(oe.ActionButton,{label:r,onClick:_=>h(_,p.text)})})]})},p.text))}),(0,Lt.jsx)(Ta,{value:s,onChange:S,autoFocus:!0,placeholder:n,onKeyUp:g})]})},$1=cL;var sh={};Ce(sh,{enUS:()=>dL,nlNL:()=>fL});var dL={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},fL={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Ve=x(w()),pL=(0,Ke.forwardRef)((e,t)=>{let n=k("TabCompletion",Tt);return(0,Ve.jsx)("mark",{ref:t,className:(0,yd.default)(n.matchSelection)},"selection-start")}),mL=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=j(sh),s=k("TabCompletion",Tt),a=(0,Ke.useRef)(null),l=(0,Ke.useRef)(null),[u,c]=(0,Ke.useState)(null),f=B(),d=Mi(document.activeElement===r),[y]=(0,Ke.useState)(()=>document.createRange());d.triggerRef.current=y,(0,Ke.useEffect)(()=>()=>y.detach(),[]),(0,Ke.useEffect)(()=>{let h=e.current,g=a.current;!h||!g||(y.setStart(h,0),y.setEnd(g,0))},[e.current,a.current]),Sr(()=>{d.close()});let S=(0,Ke.useCallback)(h=>{let g=y.toString(),m=/^http(s?):\/\//.test(h)?h:`https://${h}`;f(Cc({text:`[${g}](${m})`,replace:"selection"}))},[]);return(0,Ve.jsxs)("span",{children:[(0,Ve.jsx)("mark",{ref:a,className:(0,yd.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,Ve.jsx)(Di,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,Ve.jsxs)(pd,{style:n,ref:l,children:[(0,Ve.jsx)("div",{className:(0,yd.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,Ve.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,Ve.jsx)(V1,{}),(0,Ve.jsx)("span",{children:"\xA0"}),(0,Ve.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,Ve.jsx)($1,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:S,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},vd=class extends Ut{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(t,n){return this.props=n,this.charCount=0,this.startRef=(0,Ke.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,Ve.jsx)(pL,{ref:this.startRef}):(0,Ve.jsx)(mL,{inputElement:n.inputElement,startRef:this.startRef,boundaryRef:n.boundaryRef,inputStyle:n.inputStyle})}asTag(){return"mark"}};var Dn=x(w()),gL=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=k("TabCompletion",O1),c=D("insertLink"),f=D("showMidSentenceSuggestions"),d=D("inlineSuggestions"),y=Hc(a),S=(0,Fn.useRef)(null);(0,Fn.useEffect)(()=>{an(a)&&y&&Bc(a,y)},[y]);let h=(0,Fn.useCallback)(p=>{if(!o||!n)return p;let v=[(0,Dn.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,Dn.jsx)("span",{"data-testid":"tab-completion",className:(0,Sd.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&v.push((0,Dn.jsx)("span",{className:(0,Sd.default)(u.hint,u.resetIndent),children:(0,Dn.jsx)(yl,{keyCode:"tab"},"tabHint")})),Jg(p,v)},[o,n,r]),g=(0,Fn.useMemo)(()=>{let p=[];return d&&p.push(new ud("inline")),c&&p.push(new vd("selection")),p.push(new mi("placeholders")),i&&p.push(new md("keywords")),p},[d,c,i]),m=(0,Fn.useMemo)(()=>{let p=window.getComputedStyle(a);return{"--dd-color":p.color,"--dd-font-size":p.fontSize,"--dd-font-family":p.fontFamily,"--dd-font-variant":p.fontVariant}},[]);return e?(0,Dn.jsxs)("div",{ref:p=>{p!=null&&p.parentElement&&(S.current=p==null?void 0:p.parentElement)},className:u.root,style:m,children:[(0,Dn.jsx)(fi,{tagName:"span",containerTagName:"div",className:(0,Sd.default)(u.container,u.agentText),disableLineBreaks:an(a),content:t||"\u200B",onAfterParse:h,matchers:g,selection:y,keywordMatches:s,inputElement:a,inputStyle:m,boundaryRef:S,inlineSuggestionsOnlyAtEnd:!f}),(0,Dn.jsx)("br",{})]}):null},hL=({input:e,ui:t,settings:n,styleSuggestions:r,conversation:o})=>{var h;let{tabCompletionSuggestion:i}=e,s=(i==null?void 0:i.text)||"",a=(i==null?void 0:i.source)||"",l=e.html??Ii(e.text),u=s.indexOf(e.text)===0?s.slice(e.text.length):"",{showTabHint:c}=t,{isSupported:f}=o,{showTabCompletion:d,visible:y,showStyleSuggestions:S}=n;return{showTabHint:c,showStyleSuggestions:S,showTabCompletion:d,content:l,tabText:u,source:a,keywordMatches:((h=r.list)==null?void 0:h.keywordMatches)??[],enabled:y&&f!==!1}},q1=wn(hL)(gL);var ME=x(X()),DE=x(O());var G1={list:[],fetchState:"idle",isInitialRequest:null},Q1=e=>e.autoflows.list||[],X1=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},jn=M("autoflows/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)}),ah=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(jn(e.platformSessionId))}),lh=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(jn(e.platformSessionId))}),yL=H({name:"autoflows",initialState:G1,reducers:{},extraReducers:e=>{e.addCase(ah.pending,(t,n)=>{let r=X1(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(lh.pending,(t,n)=>{let r=X1(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(jn.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}),e.addCase(jn.rejected,t=>{t.fetchState="error"}),e.addCase(jn.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(J,()=>G1)}}),Y1=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(jn(e))}),o.on("sessionCompleted",()=>{n(jn(e))})}),Z1=M("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),J1=yL.reducer;var eE={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},tE=e=>e.customMessages.list,nE=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),rE=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),oE=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),Ma=M("customMessages/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)}),xd=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)}),_d=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)}),iE=H({name:"customMessages",initialState:eE,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(Ma.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(Ma.rejected,t=>{t.fetchState="error"}).addCase(Ma.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(xd.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(xd.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(_d.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(_d.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(J,()=>eE)}}),sE=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(iE.actions.onCustomMessage(i))})}),aE=M("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),lE=iE.reducer;var vL={jwt:null,accountUrl:null,interval:null},uE=e=>t=>{let{exchangeToken:{jwt:n,accountUrl:r}}=t;return n&&r?`${r}/apis/admin/session/jwt/?jwt=${n}&redirect=${e}`:null},uh=M("exchangeToken/getTemporaryExchangeToken",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=await n.getTemporaryExchangeToken();return{accountUrl:n.client.baseUrl,jwt:r}}),ch=M("exchangeToken/pollExchangeToken",(e={},t)=>{let{interval:n=1e3*60*30}=e,{dispatch:r}=t;return r(uh()),setInterval(()=>r(uh()),n)}),cE=H({name:"exchangeToken",initialState:vL,reducers:{stopPollExchangeToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(uh.fulfilled,(t,n)=>{t.jwt=n.payload.jwt,t.accountUrl=n.payload.accountUrl}),e.addCase(ch.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollExchangeToken:dE}=cE.actions,fE=cE.reducer;function pE(e){let{customMessages:t,autoflows:n}=e;return n.fetchState==="loading"&&n.isInitialRequest===!0||t.fetchState==="loading"&&t.isInitialRequest===!0}var wE=x(O());var SE=x(X()),xE=x(O());var gE=x(X());var mE={root:"_root_838fd_1"};var yE=x(w()),SL=({className:e,children:t})=>{let n=k("Unicode",mE);return(0,yE.jsx)("span",{className:(0,gE.default)(e,n.root),children:t})},hE=SL;var vE={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 dh={};Ce(dh,{enUS:()=>xL,nlNL:()=>_L});var xL={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"}]},_L={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 lt=x(w()),EL=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=k("Autoflow",vE),a=j(dh),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,lt.jsxs)(oe,{className:(0,SE.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,lt.jsx)(me,{children:(0,lt.jsxs)(me.Content,{children:[(0,lt.jsxs)(me.Title,{children:[t&&(0,lt.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,lt.jsx)("span",{children:r})]})}),(0,lt.jsx)(oe.Actions,{fixed:t==="Started",children:(0,lt.jsx)(oe.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,lt.jsxs)(xE.Fragment,{children:[(0,lt.jsx)(hE,{children:u})," ",(0,lt.jsx)("span",{children:a(l)})]})})})]})},_E=EL;var fh=x(w()),CL=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},bL=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,fh.jsx)(wE.Fragment,{children:e.map(o=>(0,fh.jsx)(_E,{displayName:o.displayName,description:o.description,disabled:o.isBusy||CL(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),TL=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},kL={onStartAutoflow:ah,onStopAutoflow:lh},EE=wn(TL,kL)(bL);var wd=x(O());var gh=x(X());var ph=x(w()),mh=()=>(0,ph.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,ph.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 CE={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=x(w()),PL=({entities:e})=>{let t=k("EntitiesWidgetList",CE),[n,r]=(0,wd.useState)(void 0),o=B(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Pa(a.text),o(st({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,wd.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,gh.default)(t.icon),children:(0,un.jsx)(mh,{})}),(0,un.jsx)("span",{className:(0,gh.default)(t.icon,n===l&&t.iconClicked),children:(0,un.jsx)(mh,{})})]})]},a.text))})},bE=PL;var TE=x(X()),hh=x(O());var Da={};Ce(Da,{enUS:()=>RL,nlNL:()=>IL});var RL={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],answer:[{type:0,value:"Answer"}]},IL={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],answer:[{type:0,value:"Antwoord"}]};var Hn={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 et=x(w()),LL=({suggestion:e})=>{let t=j(Da),n=B(),r=L(nE(e.text)),o=L(rE(e.text)),i=L(oE(e.text)),s=L(hc),{replyOptions:a}=e,l=(0,hh.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(xd({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,hh.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let f=parseInt(c.target.dataset.index,10),d=a[f];n(_d({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,et.jsxs)(oe,{onClick:l,className:(0,TE.default)(Hn.root,{[Hn.isUsed]:r,[Hn.hasError]:i}),children:[(0,et.jsx)(me,{children:(0,et.jsxs)(me.Content,{children:[(0,et.jsxs)(me.Title,{className:Hn.title,children:[e.text," ",(0,et.jsx)(vl,{className:Hn.label,children:"analyse tool"})," ",i&&(0,et.jsx)("span",{className:Hn.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,et.jsx)("ul",{className:Hn.quickReplies,children:a.map(c=>(0,et.jsx)("li",{className:Hn.quickReply,children:c.title},c.title))})]})}),(0,et.jsxs)(oe.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,et.jsx)(oe.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,f)=>(0,et.jsx)(oe.DropdownItem,{index:f,label:c.title,onClick:u},c.title))}),(0,et.jsx)(oe.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},kE=LL;var yh=x(w()),PE=()=>(0,yh.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,yh.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 RE=x(O());var ut=x(w()),AL=({suggestion:e,lines:t,onEdit:n,onUse:r})=>{var d;let o=e.text||e.url||e.message,i=Gc(o),s=j(Da),a=D("showImages"),l=D("fallbackImage"),u=y=>{y.preventDefault(),y.stopPropagation(),r(o)},c=y=>{y.preventDefault(),y.stopPropagation(),n(e)},f=(0,RE.useCallback)(y=>{window.open(i,"_blank"),y.stopPropagation(),y.preventDefault()},[i]);return(0,ut.jsxs)(oe,{onClick:u,"data-testid":"edit-suggestion",children:[(0,ut.jsxs)(me,{children:[a&&e.image&&(0,ut.jsx)(me.Image,{src:hd(e,"small",l||void 0),title:e.title}),(0,ut.jsxs)(me.Content,{children:[e.title&&(0,ut.jsx)(me.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((d=e.searchKeywords)==null?void 0:d.length)>0&&(0,ut.jsx)(oe.Labels,{labels:e.searchKeywords}),(0,ut.jsx)(me.Content,{cropText:t==="single",lineClamp:t==="multiple",children:o})]})]}),(0,ut.jsxs)(oe.Actions,{children:[i&&(0,ut.jsx)(oe.ActionButton,{onClick:f,label:s("visitUrl")}),(0,ut.jsx)(oe.ActionButton,{primary:!0,onClick:c,label:s("preview")}),(0,ut.jsx)(oe.ActionButton,{primary:!0,onClick:u,label:s("useSuggestion")})]})]})},IE=AL;var Fa=x(w()),OL=({contentType:e,lines:t,suggestions:n})=>{let r=Rt(),o=L(xi),i=a=>{r.send(Og,{state:o,suggestion:a,contentType:e})},s=(a,l)=>{r.send(Ln,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,Fa.jsx)(Fa.Fragment,{children:n.map(a=>(0,Fa.jsx)(IE,{suggestion:a,lines:t,onEdit:l=>i(l),onUse:l=>s(l,a)},a.text||a.url||a.message))})},LE=OL;var vh={};Ce(vh,{enUS:()=>NL,nlNL:()=>ML});var NL={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},ML={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var AE={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 Sh=x(w()),OE=()=>(0,Sh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Sh.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 xh=x(w()),NE=()=>(0,xh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,xh.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 z=x(w()),Ed=(e,t)=>{let n=L(Vt);(0,DE.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},DL=()=>{let e=j(vh),t=B(),n=D("isEmbedded"),r=k("Widget",AE),o=D("showAutoflows"),i=D("showCustomMessages"),s=D("showPersonalCollectionLink"),a=D("showSummaryCommand"),l=D("showKnowledgeSearch"),u=D("showSearch"),c=L(ki),f=L(td),d=L(Q1),y=L(ed),S=L(tE),h=L(yc),g=L(li),m=L(Vt),p=L(hc),v=L(pE),_=L(xi),C=Rt(),E=L(lw),b=L(uE("/admin/personal-collection")),R=D("adminUrl");if(Ed(()=>(t(Ma(p)),t(sE(p)),()=>{t(aE(p))}),[t,g,i,p]),Ed(()=>(t(jn(p)),t(Y1(p)),()=>{t(Z1(p))}),[t,g,o,p]),Ed(()=>{f.forEach(({type:N})=>{t(N==="entities"?Wt():Rn(N))})},[t,g,h,c]),Ed(()=>(t(ch()),()=>{t(dE())}),[t,g,s,h]),g===!1)return(0,z.jsx)("div",{className:r.stateText,children:(0,z.jsx)("div",{children:(0,z.jsx)("p",{children:e("notSupported")})})},"supported");if(m===!1)return(0,z.jsx)("div",{className:r.loginText,children:(0,z.jsx)("div",{children:(0,z.jsx)(od,{isEmbedded:n,loginUrl:R})})},"login");if(!c||!p||m===null||E||v)return(0,z.jsx)("div",{className:r.stateText,children:(0,z.jsx)("div",{children:(0,z.jsx)("p",{children:e("waiting")})})},"waiting");let P=u||a||l||b;return(0,z.jsx)("div",{className:(0,ME.default)(r.root),"data-testid":"widget",children:(0,z.jsxs)(Sl,{className:r.sectionList,children:[P&&(0,z.jsx)(zn,{title:e("actions"),type:"shortcuts",children:(0,z.jsxs)("div",{className:r.shortcutList,children:[u&&(0,z.jsxs)("button",{className:r.shortcut,"data-testid":"shortcut-search",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0}),children:[(0,z.jsx)(vi,{}),e("linkSearch")]}),a&&(0,z.jsxs)("button",{className:r.shortcut,"data-testid":"shortcut-summary",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,z.jsx)(NE,{}),e("linkSummary")]}),l&&(0,z.jsxs)("button",{className:r.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,z.jsx)(OE,{}),e("linkKnowledgeSearch")]}),b&&(0,z.jsxs)("a",{className:r.shortcut,target:"_blank",href:b,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[(0,z.jsx)(PE,{}),e("linkPersonalcollection")]})]})}),i&&S.length>0&&(0,z.jsx)(zn,{type:"custom-messages","data-testid":"custom-messages",children:(0,z.jsx)(ht,{withDivider:!0,children:S.map(N=>(0,z.jsx)(kE,{suggestion:N},N.text))})}),o&&d.length>0&&(0,z.jsx)(zn,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,z.jsx)(ht,{withDivider:!0,children:(0,z.jsx)(EE,{})})}),f.map(({type:N,title:G,amount:V,lines:He})=>{var cn;switch(N){case"entities":return y&&y.length>0&&(0,z.jsx)(zn,{type:N,title:G,"data-testid":`type-${N}`,children:(0,z.jsx)(bE,{entities:y})},N);default:return((cn=_[N])==null?void 0:cn.fetchState)==="done"&&_[N].suggestions.length>0&&(0,z.jsx)(zn,{type:N,title:G,"data-testid":`type-${N}`,children:(0,z.jsx)(ht,{withDivider:!0,children:(0,z.jsx)(LE,{lines:He,contentType:N,suggestions:_[N].suggestions.slice(0,V)||[]})})},N)}})]})})},FE=DL;function Fi(e){let t=new Range;return t.selectNodeContents(e),t}function jE(e,t,n){try{return Lr(e,t,n),!0}catch{return!1}}function Cd(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function bd(e){return"tagName"in e&&e.tagName==="BR"}var ja=/[\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,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(l))return u;for(let d=0;d<=l.length;d++)if(f.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(ja,""),f=o+c.length,d=t>=o&&t<=f,y=n>=o&&n<=f;if(d){let S=s(u,t-o);S===0&&!y?r.setStartBefore(l):r.setStart(l,S)}y&&(r.setEnd(l,s(u,n-o)),i=!0),o=f;break}case Node.ELEMENT_NODE:{if(bd(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;Cd(l)&&u&&!Cd(u)&&!bd(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Ha(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(f){let d=f===n,y=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let S=f.textContent;d&&(a=u+S.substring(0,r).replace(ja,"").length),y&&(l=u+S.substring(0,i).replace(ja,"").length),u+=S.replace(ja,"").length;break}case Node.ELEMENT_NODE:{let S=f.nextSibling===null;bd(f)&&!S&&u++;for(let h=0;h<f.childNodes.length;h++){let g=d&&h===r,m=y&&h===i;if(g&&(a=u),m&&(l=u),l!==void 0||((!g||!s)&&c(f.childNodes[h]),y&&h===i-1&&(l=u),l!==void 0))break}!y&&Cd(f)&&!S&&u++,y&&(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 Ba(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,f=u===o;switch(c&&s++,u.nodeType){case Node.TEXT_NODE:{if(s!==0)return;let d=c?r:0,y=f?i:void 0,S=u.textContent.replace(ja,"");d===0&&y===void 0?a+=S:a+=S.substring(d,y);break}case Node.ELEMENT_NODE:{let d=u.nextSibling===null;s===0&&bd(u)&&!d&&(a+=`
20
20
  `);for(let y=c?r:0;y<(f?Math.min(i,u.childNodes.length):u.childNodes.length)&&(l(u.childNodes[y]),s!==1);y++);!f&&s===0&&Cd(u)&&!d&&(a+=`
21
- `);break}default:break}f&&s++}return l(e),a}function HE(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var fo=class extends Tn{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let t=new Range;return t.selectNodeContents(this.element),Ba(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!HE(n)&&(t.insertNode(this.element.ownerDocument.createTextNode("\u2060")),n=t.getBoundingClientRect(),t.deleteContents(),!HE(n))?null:{top:n.top+n.height,left:n.left}}getSelection(){let t=this.getRange();if(t)return Ha(this.element,t);let n=this.lastKnownSelection;if(n&&jE(this.element,n.start,n.end))return n;let r=Fi(this.element);return r.collapse(!1),Ha(this.element,r)}getSelectedText(){let{start:t,end:n}=this.getSelection();return Ba(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()}};var _h=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()}},wh=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.iframe=this.createIframe(),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];createIframe(){let t=`deepdesk-iframe-${this.name}`,n=document.getElementById(t);if(n)return n;let r=document.createElement("iframe"),o=`${this.targetOrigin}/v2/widget/liveengage/channel.html`,i=new URLSearchParams({channel:this.name,host:window.location.origin});return this.options.debug&&i.set("debug","1"),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=t,r.title=`iframe-${this.name}`,r.src=`${o}?${i.toString()}`,r}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()}},Eh=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),U.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 wh(t,this.deepdeskUrl,{debug:!0}):new _h(t),r=o=>{var i,s;o.origin===this.deepdeskUrl&&o.data.type==="event"&&o.data.channel===t&&(U.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 o,i,s;if(!this.sessionId)return;U.info("broadcast event",{sessionId:this.sessionId,name:t,payload:n});let r={type:"event",name:t,payload:n};(i=(o=this.eventMap)[t])==null||i.call(o,n),(s=this.channel)==null||s.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)}},BE=Eh;var ji=class extends Error{constructor(n,r){super(n);this.body=r}name="CustomError"};var Ch=e=>new Promise(t=>{setTimeout(t,e)});var Hi=class extends ji{name="ClientError"},bh=class extends ji{name="ServerError"},qt=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:f=!0,retryOnError:d=_=>_ instanceof TypeError,retryOnResponse:y=_=>_.status>=500,version:S="v1",...h}=n,g={credentials:"include",...h,headers:{"Content-Type":"application/json",...h.headers}};n.method!==void 0&&n.method!=="GET"&&this.csrfToken&&(g.headers={...g.headers,"X-CSRFToken":this.csrfToken}),typeof S=="string"&&(g.headers={...g.headers,"X-Deepdesk-API-Version":S});let m=u,p=!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 v=async()=>(m--,a(s,g).then(async _=>y(_)&&!i.isAborted&&m>0?(await Ch(c),v()):_.status===401&&f===!0&&p===!1?(p=!0,await this.refreshToken(),v()):_).catch(async _=>{if(d(_)&&!i.isAborted&&m>0)return await Ch(c),v();throw _}));v().then(_=>_.json().catch(()=>null).then(C=>{_.status>=500?o(new bh("Server Error",C)):_.status===401?o(new Hi("Unauthorized",C)):_.status===403?o(new Hi("Forbidden",C)):_.status===404?o(new Hi("Not Found",C)):_.status>=400&&o(new Hi("Bad Request",C)),delete this.latestRequestByUrl[s],r(C)})).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 FL;(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||={})})(FL||={});function Td(e){return{...re(e),tags:e.tags}}var Bn=class e{constructor(t,n={}){this.options=n;this.client=new qt(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(),U.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=await this.client.post("/api/conversations",{...we(t),tags:t.tags},{version:"v2"});return Td(n)}async getProfile(t){let n=await this.client.get(`/apis/admin/profiles/${t}/`,{version:null});return re(n)}async getContentTypes(){let t=await this.client.get("/apis/admin/content-types/",{version:null});return re(t)}async getPlatformConfig(){let{config:t}=await this.client.get("/platform/config/",{version:null});return re(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(),U.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 Td(i)}async isConversationSupported(t,n={}){U.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=we(n);n.tags&&(r.tags=n.tags);let o=await this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Td(o)}async postMessages(t,n){return(await this.client.post(`/api/conversations/${t}/messages`,n.map(o=>({...we(o),tags:o.tags})),{version:"v2"})).map(o=>Td(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",we({...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:we({...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 U.warn(`Invalid token '${t}'`),n})}async authenticateWithKey(t,n){await this.client.post("/apis/admin/session/api-key/",we(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}`,we(n),{abortLatest:!0})).map(i=>({...re(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`,we(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 re(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",we(t),{abortLatest:!0});return re(n)}async search(t){let n=await this.client.post(`/api/profiles/${t.profile}/search`,we(t),{version:"v2"});return re(n)}async knowledgeAssist(t,n,r){let o=await this.client.post("/api/knowledge-search/search",we({question:t.question,promptInstruction:t.promptInstruction,profile:r,chatHistory:n.map(i=>({question:i.question,answer:i.answer.answer}))}),{version:"v2"});return re(o)}async requestLoginByEmail(t){let n=await this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return re(n)}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 re(n)}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Ry);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&U.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};var Ua=class{constructor(t,n){this.url=t;this.options={timeout:25e3,...n}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(t){this.eventSource.addEventListener(Tg(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,re(o))}catch{U.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 jL;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||={})})(jL||={});var za=class{constructor(t,n={}){this.apiUrl=t;this.client=new qt(t,n)}client;streams={};logger=U;async getCustomMessages(t){let n=await this.client.get(`/sessions/${t}/suggestions`);return re(n.suggestions)}async sendCustomMessage(t,n){let r=await this.client.post(`/sessions/${t}/messages`,we(n));return re(r)}async answerCustomMessage(t,n){await this.client.post(`/sessions/${t}/answers`,we(n))}async getAutoflows(t){let n=await this.client.get(`/sessions/${t}/autoflows`);return re(n.autoflows)}async startAutoflowSession(t){let n=await this.client.post("/autoflow-sessions",we(t));return re(n)}async stopAutoflowSession(t){await this.client.delete(`/autoflow-sessions/${t}`)}openStream(t){return this.streams[t]||(this.streams[t]=new Ua(`${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 UE={startTime:null,stopTime:null},zE=H({name:"handlingTime",initialState:UE,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(J,()=>UE)}}),{handlingTimeStart:VE,handlingTimeStop:kd,handlingTimeReset:KE}=zE.actions,WE=zE.reducer;var $E=(e={})=>{let t={onAuthError:Ei(!1),...e};return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Pd={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var po=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 Pd.list;if(!i)throw new Error("No current conversation to fetch pinned messages");return n.getStyleSuggestions({profileCode:i,message:e})}),HL=H({name:"styleSuggestions",initialState:Pd,reducers:{},extraReducers:e=>{e.addCase(po.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(po.rejected,t=>{t.fetchState="error"}).addCase(po.fulfilled,(t,n)=>{t.fetchState="done",gr(t.list,n.payload)||(t.list=n.payload)}).addCase(to,t=>{t.list=Pd.list}).addCase(J,()=>Pd)}}),qE=HL.reducer;var GE=(e={})=>{let t,n=!0,r={getStyleSuggestions:po,debounce:500,...e};return o=>i=>s=>{var y;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(!((y=u.conversation.current)==null?void 0:y.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 BL(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var XE=(e={})=>{let t={getTextSuggestions:Rn,getAutocompleteSuggestions:wa,debounce:200,check:Ri,...e},n;return r=>o=>i=>{var h;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,f=(h=l.conversation.current)==null?void 0:h.id,d=i.type===Yc.toString();if(!f||!u&&!c)return a;let{input:{userCommitted:y}}=l;return BL(y,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let g=ui(l);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var QE=po.fulfilled.toString();function UL(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 YE=e=>t=>n=>r=>{var u;if(r.type!==QE){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=UL(o,s);r.type===QE&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var zL=Bu({activeSuggestion:vw,answer:l1,auth:Lw,autoflows:J1,conversation:Yx,contentTypes:$w,customMessages:lE,exchangeToken:fE,entities:Qw,handlingTime:WE,info:W_,input:tg.reducer,overlayInput:Xe.reducer,settings:zx,profile:d1,search:Y_,summary:n1,styleSuggestions:qE,ui:ww,textSuggestions:pw});function ZE(e){return G0({reducer:zL,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),$E(),XE({debounce:200}),GE({debounce:500}),YE(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var VL=e=>{var t;return((t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())??"unknown"},KL=e=>t=>n=>r=>{var a;let o=t.getState(),i=Xm("inlineSuggestions")(o);switch(r.type){case In.toString():{let l=aw(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 Ei.toString():{!r.payload&&e.emit("logout",void 0);break}case Ht.toString():{let{start:l,end:u}=o.input.selection;e.emit("select-suggestion",{type:VL(r.payload.suggestion),...r.payload,replace:r.payload.replace==="selection"?{start:l,end:u}:{start:0,end:u}},{mayApplyChanges:!0});break}case Cc.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 aa.toString():{let l=t.getState(),{text:u,selection:c}=l.input.userCommitted;e.emit("reset",{text:u,selectionAfter:c},{mayApplyChanges:!0});break}case Pc.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 Wt.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:o.conversation.current.id,data:{entities:r.payload}});break;case An.fulfilled.toString():e.sendEvent("conversation summarized",{conversationId:o.conversation.current.id,data:{summary:r.payload.summary}});break;case st.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 bc.toString():e.handleKeyDown(r.payload);break;case to.toString():e.logSendMessage(r.payload);break;case Tc.toString():e.logSendEditSuggestionMessage(r.payload);break;case kc.toString():e.handleInputChanged(r.payload);break;default:break}let s=n(r);switch(r.type){case to.toString():e.handleAfterSendMessage(r.payload);break;case Ea.toString():e.onUpdateShowTabHint(r.payload);break;case kd.toString():e.logHandlingTime();break;case Ht.toString():{i&&(t.dispatch(Cn([])),t.dispatch(yr()));break}default:break}return s},JE=KL;function Th(e){return e.toISOString().replace("T"," ").replace("Z","")}function eC(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:Th(n),timeStop:Th(r)}}function kh(e,t,n){var b,R,P;let{text:r,metrics:{numCharsTyped:o,numCharsPasted:i,numCharsCut:s,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:u,externalTimeTotalSeconds:c,pastes:f,cuts:d,deletions:y,textSuggestions:S,offeredTextSuggestions:h}}=t[e],g=r.length,p=S.reduce((N,{text:G,searchTerm:V})=>N+G.length-(V?V.length:0),0),v=u??Date.now(),_=(Date.now()-v)/1e3+(c||0),C=o/_,E=S.reduce((N,{searchTerm:G})=>N+(G?G.length:0),0);return{conversationId:t.conversation.current.id,source:"agent",text:r,clientVersion:n.version,pastes:f,cuts:d,deletions:y,lenTextTyped:o+E,lenTextTotal:g,lenTextAssisted:p,lenTextPasted:i,lenTextCut:s,lenTextDeleted:a,timeTotalSeconds:_,charsPerSecond:C,numPastes:l,textSuggestionsV2:S,suggestionsCounters:[{source:"gpt",countOffered:h.filter(N=>N.source==="gpt").length}],agentId:(b=t.info.agentInfo)==null?void 0:b.agentId,agentName:(R=t.info.agentInfo)==null?void 0:R.agentName,agentEmail:(P=t.info.agentInfo)==null?void 0:P.agentEmail}}function tC(e,t){let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;return r instanceof HTMLElement?tC(r,t):null}function nC(e,t){return tC(e,t)}function rC(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function WL(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Rd(e){return WL(e)&&(an(e)||jc(e))}var oC=(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{U.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function $L(e){return e.offsetParent!==null}function iC(e){if(!$L(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 Id(e,t,n=100){let r=iC(e);t({isVisible:r});let o=setInterval(()=>{let i=iC(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var je=x(w()),sC=oC("showTabHint",!0),Va=class e{static version="10.3.1-beta.3";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 Bn(u,{token:i,fetch:s}),this.version=r,this.instanceId=e.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[JE({emit:(f,d,y)=>this.emit(f,d,y),handleAfterSendMessage:f=>this.handleAfterSendMessage(f),handleInputChanged:f=>this.handleInputChanged(f),handleKeyDown:f=>this.handleKeyDown(f),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:f=>this.logSendMessage(f),logSendEditSuggestionMessage:f=>this.logSendEditMessage(f),onUpdateShowTabHint:f=>sC.update(f),sendEvent:(f,d)=>this.deepdeskApi.sendEvent(f,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new za(n)}),this.store=ZE(c),this.broadcastEvents=new BE({debug:!0,deepdeskUrl:u,eventMap:Aw(this.store),createCustomChannel:l}),this.store.dispatch(ia),this.store.dispatch(Ea(sC.value())),this.store.dispatch(ia({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?(U.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(U.warn("Profile has not been loaded (yet)"),!0):(U.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Ei(null)),this.store.dispatch(br()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();Vt(r)&&bw(r)!=="loading"&&t()});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return this.deepdeskApi.isLoggedIn()}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){U.warn("Failed to attach user:",n)}}async isConversationSupported(t,n){return(await this.store.dispatch(Jm({sessionId:t,options:n}))).payload}async createConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(vc(t))).payload}async getConversationBySessionId(t,n){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(await this.store.dispatch(Sc({sessionId:t,options:n}))).payload}async upsertConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(eg(t))).payload}async postMessages(t){return(await this.store.dispatch(_c(t))).payload}async updateConversation(t){return(await this.store.dispatch(xc(t))).payload}resetConversation(){this.store.dispatch(J()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let t=await this.store.dispatch(An());if(t.error)throw new Error(t.error.message);return t.payload.summary}configure(t){this.store.dispatch(ia(t))}setVisitorInfo(t){this.store.dispatch(K_(t))}async setAgentInfo(t){await this.store.dispatch(va(t))}async setAgentSettings(t){await this.store.dispatch(kg(t))}async getAgentSettings(){return(await this.store.dispatch(Pg())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let t=[];return this.store.dispatch(Yc()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})}notifyInputChanged(t){this.store.dispatch(kc(t))}notifyKeyDown(t){this.store.dispatch(bc(t))}notifyPaste(t,n){this.store.dispatch(l_({text:t,selectionText:n}))}notifyCut(t){this.store.dispatch(s_(t))}notifyExternalSuggestion(t){this.store.dispatch(Ht(t)),this.store.dispatch(yr())}notifyEditSuggestion(t){this.store.dispatch(dw(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(e_({text:t,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Cn([])))}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(a_(Ec(t))),t.key!=="Tab"&&!this.settings.showTextSuggestions)return;let u=()=>{n||!a||i&&(t.shiftKey||(this.store.dispatch(r_()),s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault()))},c=()=>{if(n||!a||!i||t.shiftKey)return;this.store.dispatch(i_());let{selectedSuggestionIndex:f}=this.state.input;f===-1?this.store.dispatch(aa()):s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault()};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(la(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(la(-1)),this.store.dispatch(aa()),t.preventDefault()):n||(this.store.dispatch(Cr({collapse:!0})),this.store.dispatch(xw(!0)),t.preventDefault());return}case"Tab":{let{userCommitted:f}=this.state.input,d=f.text.substring(0,f.selection.end),{tabCompletionSuggestion:y}=this.state.input;this.store.dispatch(Ea(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):this.settings.showTabCompletion&&y&&y.text.startsWith(d)&&(this.store.dispatch(Ht({text:y.text,suggestion:y,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(yr())),t.preventDefault();break}default:}}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(u_()),this.store.dispatch(Cn([]))}handlingTimeStart(){this.state.handlingTime.startTime||(U.info("Start handling time"),this.store.dispatch(VE()))}handlingTimeStop(){this.state.handlingTime.startTime&&(U.info("Stop handling time"),this.store.dispatch(kd()))}logSendMessage(t){let n=kh("input",this.state,{version:this.version});t&&Object.assign(n,{text:t}),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n)}logSendEditMessage(t){let n=kh("overlayInput",this.state,{version:this.version});t&&Object.assign(n,{text:t}),this.store.dispatch(n_(this.state.overlayInput.metrics))}logHandlingTime(){let t=eC(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(KE())}notifySubmit(t={}){this.shouldAbort()||(this.store.dispatch(yr()),this.store.dispatch(to(t.text??this.state.input.text)))}stageSelectedSuggestion(t){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:r}=this.state.input;this.store.dispatch(Ht({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){U.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),U.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]=so(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,Gt.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]=so(i,{appendTo:document.body});a.dataset.testid=n,a.style.zIndex="2",a.appendChild(r),this.unmountHandlers.push(()=>{(0,Gt.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 io(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,Gt.unmountComponentAtNode)(o),o.remove()}),o}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Rd(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:f,detectSubmit:d,insertLink:y,inputMediator:S,closestScrollSelector:h,appendOverlayTo:g,inlineSuggestions:m}=n;if(this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:y,isEmbedded:f,inlineSuggestions:m}),n.automaticHandlingTime&&this.setupHandlingTime(t),io(t),this.inputMediator=S||(an(t)?new kn(t):new fo(t)),this.inputMediator.on("change",({plainText:v})=>{this.notifyInputChanged(v)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(c_({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",v=>{this.notifyKeyDown(v)}),this.inputMediator.on("paste",({pastedText:v,selectionText:_})=>{this.notifyPaste(v,_)}),this.inputMediator.on("cut",({selectionText:v})=>{this.notifyCut(v)}),m){if(an(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let v=this.createInlineContainer(t,"deepdesk-caret");(0,Gt.render)((0,je.jsx)(Oi,{store:this.store,customStyles:r,children:(0,je.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,je.jsx)(C1,{})})}),v),this.inputMediator.on("caret",_=>{this.store.dispatch(Cn([])),_?(v.style.display="block",v.style.top=`${_.top}px`,v.style.left=`${_.left}px`):v.style.display="none"})}else{let v=h&&nC(t,h)||void 0,_=this.overlayContainerFactory("deepdesk-tab-completion",v||t,{appendTo:g,closestScrollElement:v,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",v||t,{appendTo:g},r==null?void 0:r.suggestionsRootNode);(0,Gt.render)((0,je.jsx)(Oi,{store:this.store,customStyles:r,children:(0,je.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,je.jsx)(q1,{inputElement:t})})}),_),(0,Gt.render)((0,je.jsx)(Oi,{store:this.store,customStyles:r,children:(0,je.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,je.jsx)(sd,{})})}),C)}(0,Gt.render)((0,je.jsx)(Oi,{store:this.store,customStyles:r,children:(0,je.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,je.jsx)(h1,{})})}),this.createContainer("deepdesk-overlays"));let p;this.inputMediator.on("selection",v=>{clearTimeout(p),v===null?p=setTimeout(()=>{v!==null&&this.store.dispatch(ng(v))},500):this.store.dispatch(ng(v))}),this.inputMediator.on("disabled",()=>{var v;(v=this.inputMediator)==null||v.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(_i(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(_i(!0))),this.store.dispatch(t_({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var v;this.refresh(),this.broadcastEvents.setSessionId((v=this.state.conversation.current)==null?void 0:v.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&&U.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,showPersonalCollectionLink:i,isEmbedded:s}=n;this.widgetRoot=t,this.configure({showImages:o,showPersonalCollectionLink:i,isEmbedded:s}),(0,Gt.render)((0,je.jsx)(Oi,{store:this.store,customStyles:r,children:(0,je.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,je.jsx)(FE,{})})}),t),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Gt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Id(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){rC(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(La());let t=ki(this.state);t&&this.store.dispatch(ia({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:t.knowledgeAssistForAgents,recommendTextSuggestions:t.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(t){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(U.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;U.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=td(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(Wt()):this.store.dispatch(Rn(r))})}catch(r){this.handleError(r)}}};async function aC(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 lC(e,t,n={}){let r=n.replace?Lr(e,n.replace.start,n.replace.end):Fi(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(`
21
+ `);break}default:break}f&&s++}return l(e),a}function HE(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var fo=class extends Tn{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let t=new Range;return t.selectNodeContents(this.element),Ba(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!HE(n)&&(t.insertNode(this.element.ownerDocument.createTextNode("\u2060")),n=t.getBoundingClientRect(),t.deleteContents(),!HE(n))?null:{top:n.top+n.height,left:n.left}}getSelection(){let t=this.getRange();if(t)return Ha(this.element,t);let n=this.lastKnownSelection;if(n&&jE(this.element,n.start,n.end))return n;let r=Fi(this.element);return r.collapse(!1),Ha(this.element,r)}getSelectedText(){let{start:t,end:n}=this.getSelection();return Ba(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()}};var _h=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()}},wh=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.iframe=this.createIframe(),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];createIframe(){let t=`deepdesk-iframe-${this.name}`,n=document.getElementById(t);if(n)return n;let r=document.createElement("iframe"),o=`${this.targetOrigin}/v2/widget/liveengage/channel.html`,i=new URLSearchParams({channel:this.name,host:window.location.origin});return this.options.debug&&i.set("debug","1"),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=t,r.title=`iframe-${this.name}`,r.src=`${o}?${i.toString()}`,r}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()}},Eh=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),U.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 wh(t,this.deepdeskUrl,{debug:!0}):new _h(t),r=o=>{var i,s;o.origin===this.deepdeskUrl&&o.data.type==="event"&&o.data.channel===t&&(U.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 o,i,s;if(!this.sessionId)return;U.info("broadcast event",{sessionId:this.sessionId,name:t,payload:n});let r={type:"event",name:t,payload:n};(i=(o=this.eventMap)[t])==null||i.call(o,n),(s=this.channel)==null||s.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)}},BE=Eh;var ji=class extends Error{constructor(n,r){super(n);this.body=r}name="CustomError"};var Ch=e=>new Promise(t=>{setTimeout(t,e)});var Hi=class extends ji{name="ClientError"},bh=class extends ji{name="ServerError"},qt=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:f=!0,retryOnError:d=_=>_ instanceof TypeError,retryOnResponse:y=_=>_.status>=500,version:S="v1",...h}=n,g={credentials:"include",...h,headers:{"Content-Type":"application/json",...h.headers}};n.method!==void 0&&n.method!=="GET"&&this.csrfToken&&(g.headers={...g.headers,"X-CSRFToken":this.csrfToken}),typeof S=="string"&&(g.headers={...g.headers,"X-Deepdesk-API-Version":S});let m=u,p=!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 v=async()=>(m--,a(s,g).then(async _=>y(_)&&!i.isAborted&&m>0?(await Ch(c),v()):_.status===401&&f===!0&&p===!1?(p=!0,await this.refreshToken(),v()):_).catch(async _=>{if(d(_)&&!i.isAborted&&m>0)return await Ch(c),v();throw _}));v().then(_=>_.json().catch(()=>null).then(C=>{_.status>=500?o(new bh("Server Error",C)):_.status===401?o(new Hi("Unauthorized",C)):_.status===403?o(new Hi("Forbidden",C)):_.status===404?o(new Hi("Not Found",C)):_.status>=400&&o(new Hi("Bad Request",C)),delete this.latestRequestByUrl[s],r(C)})).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 FL;(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||={})})(FL||={});function Td(e){return{...re(e),tags:e.tags}}var Bn=class e{constructor(t,n={}){this.options=n;this.client=new qt(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(),U.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=await this.client.post("/api/conversations",{...we(t),tags:t.tags},{version:"v2"});return Td(n)}async getProfile(t){let n=await this.client.get(`/apis/admin/profiles/${t}/`,{version:null});return re(n)}async getContentTypes(){let t=await this.client.get("/apis/admin/content-types/",{version:null});return re(t)}async getPlatformConfig(){let{config:t}=await this.client.get("/platform/config/",{version:null});return re(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(),U.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 Td(i)}async isConversationSupported(t,n={}){U.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=we(n);n.tags&&(r.tags=n.tags);let o=await this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Td(o)}async postMessages(t,n){return(await this.client.post(`/api/conversations/${t}/messages`,n.map(o=>({...we(o),tags:o.tags})),{version:"v2"})).map(o=>Td(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",we({...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:we({...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 U.warn(`Invalid token '${t}'`),n})}async authenticateWithKey(t,n){await this.client.post("/apis/admin/session/api-key/",we(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}`,we(n),{abortLatest:!0})).map(i=>({...re(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`,we(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 re(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",we(t),{abortLatest:!0});return re(n)}async search(t){let n=await this.client.post(`/api/profiles/${t.profile}/search`,we(t),{version:"v2"});return re(n)}async knowledgeAssist(t,n,r){let o=await this.client.post("/api/knowledge-search/search",we({question:t.question,promptInstruction:t.promptInstruction,profile:r,chatHistory:n.map(i=>({question:i.question,answer:i.answer.answer}))}),{version:"v2"});return re(o)}async requestLoginByEmail(t){let n=await this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return re(n)}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 re(n)}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Ry);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&U.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};var Ua=class{constructor(t,n){this.url=t;this.options={timeout:25e3,...n}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(t){this.eventSource.addEventListener(Tg(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,re(o))}catch{U.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 jL;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||={})})(jL||={});var za=class{constructor(t,n={}){this.apiUrl=t;this.client=new qt(t,n)}client;streams={};logger=U;async getCustomMessages(t){let n=await this.client.get(`/sessions/${t}/suggestions`);return re(n.suggestions)}async sendCustomMessage(t,n){let r=await this.client.post(`/sessions/${t}/messages`,we(n));return re(r)}async answerCustomMessage(t,n){await this.client.post(`/sessions/${t}/answers`,we(n))}async getAutoflows(t){let n=await this.client.get(`/sessions/${t}/autoflows`);return re(n.autoflows)}async startAutoflowSession(t){let n=await this.client.post("/autoflow-sessions",we(t));return re(n)}async stopAutoflowSession(t){await this.client.delete(`/autoflow-sessions/${t}`)}openStream(t){return this.streams[t]||(this.streams[t]=new Ua(`${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 UE={startTime:null,stopTime:null},zE=H({name:"handlingTime",initialState:UE,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(J,()=>UE)}}),{handlingTimeStart:VE,handlingTimeStop:kd,handlingTimeReset:KE}=zE.actions,WE=zE.reducer;var $E=(e={})=>{let t={onAuthError:Ei(!1),...e};return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Pd={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var po=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 Pd.list;if(!i)throw new Error("No current conversation to fetch pinned messages");return n.getStyleSuggestions({profileCode:i,message:e})}),HL=H({name:"styleSuggestions",initialState:Pd,reducers:{},extraReducers:e=>{e.addCase(po.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(po.rejected,t=>{t.fetchState="error"}).addCase(po.fulfilled,(t,n)=>{t.fetchState="done",gr(t.list,n.payload)||(t.list=n.payload)}).addCase(to,t=>{t.list=Pd.list}).addCase(J,()=>Pd)}}),qE=HL.reducer;var GE=(e={})=>{let t,n=!0,r={getStyleSuggestions:po,debounce:500,...e};return o=>i=>s=>{var y;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(!((y=u.conversation.current)==null?void 0:y.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 BL(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var XE=(e={})=>{let t={getTextSuggestions:Rn,getAutocompleteSuggestions:wa,debounce:200,check:Ri,...e},n;return r=>o=>i=>{var h;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,f=(h=l.conversation.current)==null?void 0:h.id,d=i.type===Yc.toString();if(!f||!u&&!c)return a;let{input:{userCommitted:y}}=l;return BL(y,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let g=ui(l);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var QE=po.fulfilled.toString();function UL(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 YE=e=>t=>n=>r=>{var u;if(r.type!==QE){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=UL(o,s);r.type===QE&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var zL=Bu({activeSuggestion:vw,answer:l1,auth:Lw,autoflows:J1,conversation:Yx,contentTypes:$w,customMessages:lE,exchangeToken:fE,entities:Qw,handlingTime:WE,info:W_,input:tg.reducer,overlayInput:Xe.reducer,settings:zx,profile:d1,search:Y_,summary:n1,styleSuggestions:qE,ui:ww,textSuggestions:pw});function ZE(e){return G0({reducer:zL,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),$E(),XE({debounce:200}),GE({debounce:500}),YE(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var VL=e=>{var t;return((t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())??"unknown"},KL=e=>t=>n=>r=>{var a;let o=t.getState(),i=Xm("inlineSuggestions")(o);switch(r.type){case In.toString():{let l=aw(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 Ei.toString():{!r.payload&&e.emit("logout",void 0);break}case Ht.toString():{let{start:l,end:u}=o.input.selection;e.emit("select-suggestion",{type:VL(r.payload.suggestion),...r.payload,replace:r.payload.replace==="selection"?{start:l,end:u}:{start:0,end:u}},{mayApplyChanges:!0});break}case Cc.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 aa.toString():{let l=t.getState(),{text:u,selection:c}=l.input.userCommitted;e.emit("reset",{text:u,selectionAfter:c},{mayApplyChanges:!0});break}case Pc.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 Wt.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:o.conversation.current.id,data:{entities:r.payload}});break;case An.fulfilled.toString():e.sendEvent("conversation summarized",{conversationId:o.conversation.current.id,data:{summary:r.payload.summary}});break;case st.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 bc.toString():e.handleKeyDown(r.payload);break;case to.toString():e.logSendMessage(r.payload);break;case Tc.toString():e.logSendEditSuggestionMessage(r.payload);break;case kc.toString():e.handleInputChanged(r.payload);break;default:break}let s=n(r);switch(r.type){case to.toString():e.handleAfterSendMessage(r.payload);break;case Ea.toString():e.onUpdateShowTabHint(r.payload);break;case kd.toString():e.logHandlingTime();break;case Ht.toString():{i&&(t.dispatch(Cn([])),t.dispatch(yr()));break}default:break}return s},JE=KL;function Th(e){return e.toISOString().replace("T"," ").replace("Z","")}function eC(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:Th(n),timeStop:Th(r)}}function kh(e,t,n){var b,R,P;let{text:r,metrics:{numCharsTyped:o,numCharsPasted:i,numCharsCut:s,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:u,externalTimeTotalSeconds:c,pastes:f,cuts:d,deletions:y,textSuggestions:S,offeredTextSuggestions:h}}=t[e],g=r.length,p=S.reduce((N,{text:G,searchTerm:V})=>N+G.length-(V?V.length:0),0),v=u??Date.now(),_=(Date.now()-v)/1e3+(c||0),C=o/_,E=S.reduce((N,{searchTerm:G})=>N+(G?G.length:0),0);return{conversationId:t.conversation.current.id,source:"agent",text:r,clientVersion:n.version,pastes:f,cuts:d,deletions:y,lenTextTyped:o+E,lenTextTotal:g,lenTextAssisted:p,lenTextPasted:i,lenTextCut:s,lenTextDeleted:a,timeTotalSeconds:_,charsPerSecond:C,numPastes:l,textSuggestionsV2:S,suggestionsCounters:[{source:"gpt",countOffered:h.filter(N=>N.source==="gpt").length}],agentId:(b=t.info.agentInfo)==null?void 0:b.agentId,agentName:(R=t.info.agentInfo)==null?void 0:R.agentName,agentEmail:(P=t.info.agentInfo)==null?void 0:P.agentEmail}}function tC(e,t){let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;return r instanceof HTMLElement?tC(r,t):null}function nC(e,t){return tC(e,t)}function rC(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function WL(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Rd(e){return WL(e)&&(an(e)||jc(e))}var oC=(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{U.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function $L(e){return e.offsetParent!==null}function iC(e){if(!$L(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 Id(e,t,n=100){let r=iC(e);t({isVisible:r});let o=setInterval(()=>{let i=iC(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var je=x(w()),sC=oC("showTabHint",!0),Va=class e{static version="10.3.1-beta.4";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 Bn(u,{token:i,fetch:s}),this.version=r,this.instanceId=e.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[JE({emit:(f,d,y)=>this.emit(f,d,y),handleAfterSendMessage:f=>this.handleAfterSendMessage(f),handleInputChanged:f=>this.handleInputChanged(f),handleKeyDown:f=>this.handleKeyDown(f),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:f=>this.logSendMessage(f),logSendEditSuggestionMessage:f=>this.logSendEditMessage(f),onUpdateShowTabHint:f=>sC.update(f),sendEvent:(f,d)=>this.deepdeskApi.sendEvent(f,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new za(n)}),this.store=ZE(c),this.broadcastEvents=new BE({debug:!0,deepdeskUrl:u,eventMap:Aw(this.store),createCustomChannel:l}),this.store.dispatch(ia),this.store.dispatch(Ea(sC.value())),this.store.dispatch(ia({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?(U.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(U.warn("Profile has not been loaded (yet)"),!0):(U.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Ei(null)),this.store.dispatch(br()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();Vt(r)&&bw(r)!=="loading"&&t()});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return this.deepdeskApi.isLoggedIn()}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){U.warn("Failed to attach user:",n)}}async isConversationSupported(t,n){return(await this.store.dispatch(Jm({sessionId:t,options:n}))).payload}async createConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(vc(t))).payload}async getConversationBySessionId(t,n){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(await this.store.dispatch(Sc({sessionId:t,options:n}))).payload}async upsertConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(eg(t))).payload}async postMessages(t){return(await this.store.dispatch(_c(t))).payload}async updateConversation(t){return(await this.store.dispatch(xc(t))).payload}resetConversation(){this.store.dispatch(J()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let t=await this.store.dispatch(An());if(t.error)throw new Error(t.error.message);return t.payload.summary}configure(t){this.store.dispatch(ia(t))}setVisitorInfo(t){this.store.dispatch(K_(t))}async setAgentInfo(t){await this.store.dispatch(va(t))}async setAgentSettings(t){await this.store.dispatch(kg(t))}async getAgentSettings(){return(await this.store.dispatch(Pg())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let t=[];return this.store.dispatch(Yc()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})}notifyInputChanged(t){this.store.dispatch(kc(t))}notifyKeyDown(t){this.store.dispatch(bc(t))}notifyPaste(t,n){this.store.dispatch(l_({text:t,selectionText:n}))}notifyCut(t){this.store.dispatch(s_(t))}notifyExternalSuggestion(t){this.store.dispatch(Ht(t)),this.store.dispatch(yr())}notifyEditSuggestion(t){this.store.dispatch(dw(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(e_({text:t,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Cn([])))}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(a_(Ec(t))),t.key!=="Tab"&&!this.settings.showTextSuggestions)return;let u=()=>{n||!a||i&&(t.shiftKey||(this.store.dispatch(r_()),s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault()))},c=()=>{if(n||!a||!i||t.shiftKey)return;this.store.dispatch(i_());let{selectedSuggestionIndex:f}=this.state.input;t.preventDefault(),!s&&(f===-1?this.store.dispatch(aa()):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(la(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(la(-1)),this.store.dispatch(aa()),t.preventDefault()):n||(this.store.dispatch(Cr({collapse:!0})),this.store.dispatch(xw(!0)),t.preventDefault());return}case"Tab":{let{userCommitted:f}=this.state.input,d=f.text.substring(0,f.selection.end),{tabCompletionSuggestion:y}=this.state.input;this.store.dispatch(Ea(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!s&&this.settings.showTabCompletion&&y&&y.text.startsWith(d)&&(this.store.dispatch(Ht({text:y.text,suggestion:y,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(yr())),t.preventDefault();break}default:}}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(u_()),this.store.dispatch(Cn([]))}handlingTimeStart(){this.state.handlingTime.startTime||(U.info("Start handling time"),this.store.dispatch(VE()))}handlingTimeStop(){this.state.handlingTime.startTime&&(U.info("Stop handling time"),this.store.dispatch(kd()))}logSendMessage(t){let n=kh("input",this.state,{version:this.version});t&&Object.assign(n,{text:t}),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n)}logSendEditMessage(t){let n=kh("overlayInput",this.state,{version:this.version});t&&Object.assign(n,{text:t}),this.store.dispatch(n_(this.state.overlayInput.metrics))}logHandlingTime(){let t=eC(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(KE())}notifySubmit(t={}){this.shouldAbort()||(this.store.dispatch(yr()),this.store.dispatch(to(t.text??this.state.input.text)))}stageSelectedSuggestion(t){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:r}=this.state.input;this.store.dispatch(Ht({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){U.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),U.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]=so(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,Gt.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]=so(i,{appendTo:document.body});a.dataset.testid=n,a.style.zIndex="2",a.appendChild(r),this.unmountHandlers.push(()=>{(0,Gt.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 io(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,Gt.unmountComponentAtNode)(o),o.remove()}),o}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Rd(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:f,detectSubmit:d,insertLink:y,inputMediator:S,closestScrollSelector:h,appendOverlayTo:g,inlineSuggestions:m}=n;if(this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:y,isEmbedded:f,inlineSuggestions:m}),n.automaticHandlingTime&&this.setupHandlingTime(t),io(t),this.inputMediator=S||(an(t)?new kn(t):new fo(t)),this.inputMediator.on("change",({plainText:v})=>{this.notifyInputChanged(v)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(c_({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",v=>{this.notifyKeyDown(v)}),this.inputMediator.on("paste",({pastedText:v,selectionText:_})=>{this.notifyPaste(v,_)}),this.inputMediator.on("cut",({selectionText:v})=>{this.notifyCut(v)}),m){if(an(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let v=this.createInlineContainer(t,"deepdesk-caret");(0,Gt.render)((0,je.jsx)(Oi,{store:this.store,customStyles:r,children:(0,je.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,je.jsx)(C1,{})})}),v),this.inputMediator.on("caret",_=>{this.store.dispatch(Cn([])),_?(v.style.display="block",v.style.top=`${_.top}px`,v.style.left=`${_.left}px`):v.style.display="none"})}else{let v=h&&nC(t,h)||void 0,_=this.overlayContainerFactory("deepdesk-tab-completion",v||t,{appendTo:g,closestScrollElement:v,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",v||t,{appendTo:g},r==null?void 0:r.suggestionsRootNode);(0,Gt.render)((0,je.jsx)(Oi,{store:this.store,customStyles:r,children:(0,je.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,je.jsx)(q1,{inputElement:t})})}),_),(0,Gt.render)((0,je.jsx)(Oi,{store:this.store,customStyles:r,children:(0,je.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,je.jsx)(sd,{})})}),C)}(0,Gt.render)((0,je.jsx)(Oi,{store:this.store,customStyles:r,children:(0,je.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,je.jsx)(h1,{})})}),this.createContainer("deepdesk-overlays"));let p;this.inputMediator.on("selection",v=>{clearTimeout(p),v===null?p=setTimeout(()=>{v!==null&&this.store.dispatch(ng(v))},500):this.store.dispatch(ng(v))}),this.inputMediator.on("disabled",()=>{var v;(v=this.inputMediator)==null||v.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(_i(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(_i(!0))),this.store.dispatch(t_({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var v;this.refresh(),this.broadcastEvents.setSessionId((v=this.state.conversation.current)==null?void 0:v.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&&U.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,showPersonalCollectionLink:i,isEmbedded:s}=n;this.widgetRoot=t,this.configure({showImages:o,showPersonalCollectionLink:i,isEmbedded:s}),(0,Gt.render)((0,je.jsx)(Oi,{store:this.store,customStyles:r,children:(0,je.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,je.jsx)(FE,{})})}),t),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Gt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Id(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){rC(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(La());let t=ki(this.state);t&&this.store.dispatch(ia({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:t.knowledgeAssistForAgents,recommendTextSuggestions:t.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(t){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(U.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;U.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=td(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(Wt()):this.store.dispatch(Rn(r))})}catch(r){this.handleError(r)}}};async function aC(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 lC(e,t,n={}){let r=n.replace?Lr(e,n.replace.start,n.replace.end):Fi(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(`
22
22
  `).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()}})}async function uC(e,t){let n;e.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0}));let r=()=>{let i=(e.ownerDocument.defaultView??window).getSelection();if(!i)return;let s=i.getRangeAt(0);s&&(s.deleteContents(),n=document.createElement("span"),s.insertNode(n),t.split(`
23
23
  `).reverse().forEach((a,l)=>{l>0&&s.insertNode(document.createElement("br")),s.insertNode(document.createTextNode(a))}),s.collapse(!1))};return Promise.resolve(r()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!n)try{n.scrollIntoView&&n.scrollIntoView({block:"nearest",inline:"nearest"})}finally{n&&n.remove()}})}function cC(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function dC(e,t,n){await new Bn(e).authenticateWithKey(t,n)}async function fC(e){let n=await new qt(e).get("/platform/config/",{version:null});return re(n)}async function qL(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 pC(e,t){let n=await qL(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 SC(GL);})();
24
24
  /*! Bundled license information: