@deepdesk/deepdesk-sdk 10.1.0 → 10.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -18,7 +18,7 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
|
18
18
|
|
|
19
19
|
`),o=o.replace(/\n/g,"<br/>"),o}createContainer(t){var n;let o=(typeof global<"u"&&global.INTERWEAVE_SSR_POLYFILL||NP)();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(LP)||(s.innerHTML=this.convertLineBreaks(this.props.escapeHtml?(0,U0.default)(t):t)),s}extractAttributes(t){let{allowAttributes:n}=this.props,r={},o=0;return t.nodeType!==B0||!t.attributes||([...t.attributes].forEach(i=>{let{name:s,value:a}=i,l=s.toLowerCase(),u=wc[l]||wc[s];if(!this.isSafe(t)||!l.match(AP)&&(!n&&(!u||u===Qm)||l.startsWith("on")||a.replace(/(\s|\0|�([9AD]);)/,"").match(/(javascript|vbscript|livescript|xss):/i)))return;let c=l==="style"?this.extractStyleAttribute(t):a;u===mr?c=!0:u===Wr?c=Number.parseFloat(String(c)):u!==Sc&&(c=String(c)),r[Ym[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 oa[t]?{...n,...oa[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===B0){let d=c.nodeName.toLowerCase(),h=this.getTagConfig(d);u&&(l.push(u),u="");let y=this.applyNodeFilters(d,c);if(!y)return;let v;if(s&&!(a&&!this.isTagAllowed(d))){this.keyIndex+=1;let g=this.keyIndex;v=this.parseNode(y,h);let m=s(y,v,h);if(m===null)return;if(typeof m<"u"){l.push(qr.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,h))){var p;this.keyIndex+=1;let g=this.extractAttributes(y),m={tagName:d};g&&(m.attributes=g),h.void&&(m.selfClose=h.void),l.push(qr.default.createElement(xc,{...m,key:this.keyIndex},(p=v)!==null&&p!==void 0?p:this.parseNode(y,h)))}else l=[...l,...this.parseNode(y,h.tagName?h:n)]}else if(c.nodeType===IP){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(OP);){let[s,a]=i,l=i.index,u=s.includes("/");l>0&&(r.push(o.slice(0,l)),o=o.slice(l));let{children:c,matcher:p,props:d}=n[a],h;if(u)h=s.length,r.push(p.createElement(c,d));else{let y=o.match(new RegExp(`{{{/${a}}}}`));h=y.index+y[0].length,r.push(p.createElement(this.replaceTokens(o.slice(s.length,y.index),n),d))}o=o.slice(h)}return o.length>0&&r.push(o),r.length===0?"":r.length===1&&typeof r[0]=="string"?r[0]:r}};function MP(e){var t;let{attributes:n,className:r,containerTagName:o,content:i,emptyContent:s,parsedContent:a,tagName:l,noWrap:u}=e,c=(t=o??l)!==null&&t!==void 0?t:"span",p=c==="fragment"?!0:u,d;if(a)d=a;else{let h=new Ec(i??"",e).parse();h.length>0&&(d=h)}return d||(d=s),p?qr.default.createElement(qr.default.Fragment,null,d):qr.default.createElement(xc,{attributes:n,className:r,tagName:c},d)}function oi(e){let{attributes:t,className:n,content:r="",disableFilters:o=!1,disableMatchers:i=!1,emptyContent:s=null,filters:a=[],matchers:l=[],onAfterParse:u=null,onBeforeParse:c=null,tagName:p="span",noWrap:d=!1,...h}=e,y=i?[]:l,v=o?[]:a,g=c?[c]:[],m=u?[u]:[];y.forEach(T=>{T.onBeforeParse&&g.push(T.onBeforeParse.bind(T)),T.onAfterParse&&m.push(T.onAfterParse.bind(T))});let f=g.reduce((T,E)=>E(T,e),r??""),w=new Ec(f,h,y,v),x=m.reduce((T,E)=>E(T,e),w.parse());return qr.default.createElement(MP,{attributes:t,className:n,containerTagName:e.containerTagName,emptyContent:s,noWrap:d,parsedContent:x.length===0?void 0:x,tagName:p})}var sg=S(Q());var Jm={root:"_root_7hhs4_1",agentText:"_agentText_7hhs4_3",textInput:"_textInput_7hhs4_8",textInputWrapper:"_textInputWrapper_7hhs4_27",alert:"_alert_7hhs4_31",alertText:"_alertText_7hhs4_50",warning:"_warning_7hhs4_60",success:"_success_7hhs4_69"};var V0=S(Q());var ii=S(O());function z0(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function Cc(e){let t=(0,ii.useRef)(null),[n,r]=(0,ii.useState)(!1);return(0,ii.useEffect)(()=>{let o=!1,i=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[s,a]=z0((c,p)=>{let d=t.current;if(!d)return;let h=c/i,y=p/i,v=d.getBoundingClientRect(),g=h>v.x&&h<v.x+v.width&&y>v.y&&y<v.y+v.height;g&&!o?(o=!0,r(!0)):!g&&o&&(o=!1,r(!1))},({clientX:c,clientY:p})=>[c,p]),[l,u]=z0(()=>{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 Ct={root:"_root_kpc8q_1",agentText:"_agentText_kpc8q_4",tabText:"_tabText_kpc8q_9",hint:"_hint_kpc8q_10",matchSelection:"_matchSelection_kpc8q_14",focus:"_focus_kpc8q_20",resetIndent:"_resetIndent_kpc8q_24",matchKeyword:"_matchKeyword_kpc8q_28",matchPlaceholder:"_matchPlaceholder_kpc8q_29",hover:"_hover_kpc8q_35",hintText:"_hintText_kpc8q_67",popover:"_popover_kpc8q_75",popoverRoot:"_popoverRoot_kpc8q_80",popoverContentContainer:"_popoverContentContainer_kpc8q_84",popoverContent:"_popoverContent_kpc8q_84",selectionOptions:"_selectionOptions_kpc8q_110",selectionOptionsIsHidden:"_selectionOptionsIsHidden_kpc8q_115",selectionOptionsButton:"_selectionOptionsButton_kpc8q_119",caret:"_caret_kpc8q_135",popoverSuggestionsRoot:"_popoverSuggestionsRoot_kpc8q_139",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_kpc8q_144"};var eg=S(C()),DP=({inputElement:e,children:t})=>{let n=P("TabCompletion",Ct),[r,o]=Cc(e);return(0,eg.jsx)("mark",{ref:r,className:(0,V0.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},si=class extends jt{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,eg.jsx)(DP,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var ai=S(O());function Tc(e){return e.contentEditable==="true"}function FP(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 K0(e){let{selectionStart:t,selectionEnd:n}=Tc(e)?FP(e):e;return[t,n]}function _c(e){let[,t]=(0,ai.useState)(),n=(0,ai.useRef)(null);return n.current=K0(e),(0,ai.useEffect)(()=>{let r=()=>{let[o,i]=n.current??[],s=K0(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(lo);if(!s||s.length===0)return;let a=0;s.find(l=>{let u=r.indexOf(l,a);return o>u&&i<u+l.length?(n.selectionStart=u,n.selectionEnd=u+l.length,!0):(a=u+l.length,!1)})}var W0=S(O());function li(e){(0,W0.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function Gr(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}var $0,Jt=new Map,jP=["bottom","height","left","right","top","width"],HP=(e={},t={})=>jP.some(n=>e[n]!==t[n]),q0=()=>{let e=[];Jt.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Jt.delete(n);return}let r=n.getBoundingClientRect();HP(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{t.callbacks.forEach(n=>n(t.rect))}),Jt.size!==0&&($0=window.requestAnimationFrame(q0))};function G0(e,t){return{observe(){let n=Jt.size===0;if(Jt.has(e)){let r=Jt.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else Jt.set(e,{rect:void 0,callbacks:[t]});n&&q0()},unobserve(){let n=Jt.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Jt.delete(e),Jt.size||cancelAnimationFrame($0)}}}}var X0,en=new Map,Q0=()=>{en.forEach((e,t)=>{if(!t.isConnected){en.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)))}),en.size!==0&&(X0=window.requestAnimationFrame(Q0))};function Y0(e,t){return{observe(){let n=en.size===0;en.has(e)?en.get(e).callbacks.push(t):en.set(e,{visible:void 0,callbacks:[t]}),n&&Q0()},unobserve(){let n=en.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||en.delete(e),en.size||cancelAnimationFrame(X0)}}}}var tg=["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 ng(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ui(e){return parseFloat(e)}function kc(e){return Math.round(e*1e6)}function Z0(e){return e/1e6}function rg(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=ui(e.width),i=ui(e.borderLeftWidth),s=ui(e.borderRightWidth),a=ui(e.paddingRight),l=Z0(kc(o)-kc(i)-kc(s)),u=Z0(kc(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function ci(e,t={}){var l;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position="fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",Gr(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};ng(r,n,tg),rg(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=Y0(e,()=>{ng(r,n,tg),rg(r,e,n),i(),setTimeout(i,0)}),a=G0(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(ng(r,n,tg),rg(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(),p=window.getComputedStyle(t.closestScrollElement),d=ui(p.borderTopWidth),h=ui(p.borderBottomWidth),y=c.top+d-u.top,v=u.top+u.height+-(c.top+c.height-h);n.style.clipPath=`inset(${y}px 0px ${v}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 og={};Te(og,{enUS:()=>BP,nlNL:()=>UP});var BP={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"}]},UP={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 ia=S(C()),J0=()=>(0,ia.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,ia.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,ia.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 ig=S(C()),ex=()=>(0,ig.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,ig.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var tx=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(tx||{}),vn=class{constructor(t){this.element=t;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentHTML="";currentSelection=null;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,rawHtml:n}),this.currentText=t,this.isSubmitting=!1,(this.currentHTML!==n||n===null&&r)&&(this.emit("updated",{plainText:t,rawHtml:n}),this.currentHTML=n))}handleKeyUp(t){let{key:n,shiftKey:r}=t;(n==="Enter"&&r===!0||n==="Backspace")&&this.triggerChange()}handleFocus(){this.isFocused||this.emit("focus"),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(tx).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleCut(){let t=this.currentSelection;this.isPossibleClearInputAction=!0,t&&this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){let n=(t.clipboardData||window.clipboardData).getData("text");this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){let t=()=>{let r=document.activeElement===this.element?this.getSelection():null;cr(this.currentSelection,r)||(this.currentSelection=r,this.emit("selection",r))};document.addEventListener("selectionchange",t),this.disposeHandlers.push(()=>{window.document&&document.removeEventListener("selectionchange",t)}),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)),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let n=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});n.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{n.disconnect()})}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 Sn=class extends vn{getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:t,selectionEnd:n}=this.element;return{start:t,end:n}}getSelectedText(){return this.currentSelection?this.getText().slice(this.currentSelection.start,this.currentSelection.end):""}applyChanges(t){if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);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 Xe=S(C()),zP=({value:e,onUse:t,...n})=>{var c;let r=j(og),o=K(),i=P("EditSuggestionTextInput",Jm),[s,a]=(0,Tt.useState)(null),l=(0,Tt.useRef)(null),u=((c=e.match(lo))==null?void 0:c.length)||0;return(0,Tt.useEffect)(()=>{let p;return l.current&&(a(l.current),p=new Sn(l.current),p.on("change",({plainText:d})=>{o(Ge.actions.userInput({text:d,selection:p.getSelection()}))}),p.on("keydown",d=>{o(Ge.actions.registerKeyDown($u(d))),d.code==="Enter"&&d.shiftKey&&t(p.getText())}),p.on("paste",({pastedText:d,selectionText:h})=>{o(Ge.actions.registerPaste({text:d,selectionText:h}))}),p.on("cut",({selectionText:d})=>{o(Ge.actions.registerCut(d))})),()=>{o(Ge.actions.reset()),p.dispose(),p.deactivate()}},[l]),(0,Tt.useEffect)(()=>{e&&l.current&&(l.current.value=e)},[e,l]),(0,Tt.useEffect)(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let p=l.current.value.length;l.current.setSelectionRange(p,p),l.current.focus()},0)},[l]),(0,Xe.jsxs)("div",{className:i.textInputWrapper,children:[(0,Xe.jsx)("textarea",{...n,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:e,onChange:()=>{}}),s&&(0,Xe.jsx)(VP,{inputElement:l.current,value:e}),(0,Xe.jsxs)("div",{className:(0,sg.default)(i.alert,u===0?i.success:i.warning),children:[(0,Xe.jsx)("div",{className:i.alertText,children:r("placeholders",{placeholderSize:u})}),u===0?(0,Xe.jsx)(J0,{}):(0,Xe.jsx)(ex,{})]})]})},VP=({inputElement:e,value:t})=>{let n=P("EditSuggestionTextInput",Jm),r=(0,Tt.useRef)(null),o=_c(e);return(0,Tt.useEffect)(()=>{bc(e,o)},[o,e]),(0,Xe.jsx)(KP,{inputElement:e,children:(0,Xe.jsxs)("div",{ref:r,className:(0,sg.default)(n.root,n.agentText),children:[(0,Xe.jsx)(oi,{tagName:"span",disableLineBreaks:!0,content:t,matchers:[new si("placeholders")],inputElement:e,boundaryRef:r}),(0,Xe.jsx)("br",{})]})})},KP=({inputElement:e,children:t})=>{let n=(0,Tt.useRef)(null);return(0,Tt.useEffect)(()=>{if(!n.current)return()=>{};let[r,o]=ci(e,{overlayContainer:n.current,mirrorOverflow:!0});return()=>{o()}},[n.current]),(0,Xe.jsx)("div",{ref:n,children:t})},nx=zP;var pi=S(O());var Qe={root:"_root_m5usm_1",list:"_list_m5usm_2",listWrapper:"_listWrapper_m5usm_6",listHorizontal:"_listHorizontal_m5usm_10",page:"_page_m5usm_19",search:"_search_m5usm_25",pageNav:"_pageNav_m5usm_33",pageTitle:"_pageTitle_m5usm_41",pageBackButton:"_pageBackButton_m5usm_48",listHeading:"_listHeading_m5usm_62",listItem:"_listItem_m5usm_70",listItemContent:"_listItemContent_m5usm_79",listItemText:"_listItemText_m5usm_97",listItemDescription:"_listItemDescription_m5usm_105",truncate:"_truncate_m5usm_112",lineClamp:"_lineClamp_m5usm_118",listItemTitle:"_listItemTitle_m5usm_125",listItemAction:"_listItemAction_m5usm_132",listItemPrimaryAction:"_listItemPrimaryAction_m5usm_146",listItemSelected:"_listItemSelected_m5usm_151",sources:"_sources_m5usm_155",sourcesTitle:"_sourcesTitle_m5usm_162",source:"_source_m5usm_155",icon:"_icon_m5usm_177",searchIcon:"_searchIcon_m5usm_194",searchInputWrapper:"_searchInputWrapper_m5usm_199",searchInput:"_searchInput_m5usm_199",select:"_select_m5usm_220",selectType:"_selectType_m5usm_237",selectWrapper:"_selectWrapper_m5usm_241",image:"_image_m5usm_271",imageSrc:"_imageSrc_m5usm_278",imageTitle:"_imageTitle_m5usm_289",actions:"_actions_m5usm_294",actionsWrapper:"_actionsWrapper_m5usm_298",actionsBar:"_actionsBar_m5usm_304",actionButton:"_actionButton_m5usm_313",actionShortcut:"_actionShortcut_m5usm_331",actionShortcutFixKerning:"_actionShortcutFixKerning_m5usm_338"};var sa=S(C()),WP=({src:e,title:t})=>{let n=P("CommandPalette",Qe);return(0,sa.jsxs)("div",{className:n.image,children:[(0,sa.jsx)("img",{src:e,alt:t,className:n.imageSrc}),t&&(0,sa.jsx)("span",{className:n.imageTitle,children:t})]})},rx=WP;var ox=S(O()),ix=S(Q());var aa=S(C());function ag({children:e,heading:t,orientation:n}){let r=P("CommandPalette",Qe);return ox.default.Children.count(e)===0?null:(0,aa.jsxs)("div",{"data-testid":"commandpalette-list",className:r.list,children:[t&&(0,aa.jsx)("h4",{className:r.listHeading,children:t}),(0,aa.jsx)("div",{className:(0,ix.default)(r.listWrapper,n==="horizontal"&&r.listHorizontal),children:e})]})}var la=S(Q());var sx={root:"_root_nkim0_1"};var lg={};Te(lg,{enUS:()=>$P,nlNL:()=>qP});var $P={experimental:[{type:0,value:"Experimental"}]},qP={experimental:[{type:0,value:"Experimenteel"}]};var ug=S(C()),ax=({children:e})=>{let t=P("Chip",sx);return(0,ug.jsx)("span",{className:t.root,children:e})},Pc=()=>{let e=j(lg);return(0,ug.jsx)(ax,{children:e("experimental")})},lx=ax;var Rc=S(O()),dx=S(C()),ux=Rc.default.createContext(void 0);function gr(){let e=Rc.default.useContext(ux);if(e===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return e}var cx=({children:e,page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i})=>{let s=Rc.default.useMemo(()=>({page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i}),[n,t,o]);return(0,dx.jsx)(ux.Provider,{value:s,children:e})};var _t=S(C());function cg({closeOnSelect:e=!0,lineClamp:t,children:n,onClick:r,index:o,isExperimental:i,description:s,sources:a,styles:l,...u}){let{selected:c,onChangeOpen:p}=gr(),d=P("CommandPalette",Qe);function h(y){r(y),e&&p(!1)}return(0,_t.jsxs)("div",{className:(0,la.default)(d.listItem,c===o&&d.listItemSelected),children:[(0,_t.jsxs)("button",{type:"button",className:(0,la.default)("command-palette-list-item",d.listItemAction,d.listItemPrimaryAction),"aria-disabled":u.disabled??!1,onClick:h,...u,children:[(0,_t.jsxs)("div",{className:d.listItemContent,children:[typeof n=="string"?(0,_t.jsx)("p",{className:(0,la.default)(d.listItemText,d.truncate,l==null?void 0:l.title),children:n}):n,s&&(0,_t.jsx)("p",{className:(0,la.default)(d.listItemDescription,l==null?void 0:l.description,t?d.lineClamp:d.truncate),children:s})]}),i&&(0,_t.jsx)(Pc,{})]}),a&&(0,_t.jsxs)("div",{className:d.sources,children:[(0,_t.jsx)("span",{className:d.sourcesTitle,children:"Sources"}),a.map(y=>y.url?(0,_t.jsx)("a",{className:d.source,href:y.url,target:"_blank",title:y.url,rel:"noopener noreferrer",children:y.name},y.url):(0,_t.jsx)("span",{className:d.source,children:y.name},y.name))]})]})}var ua={};Te(ua,{enUS:()=>GP,nlNL:()=>XP});var GP={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}]},XP={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}]};var hr=S(C());function dg({children:e,title:t,id:n,onDismiss:r,isExperimental:o}){let i=j(ua),s=P("CommandPalette",Qe),{page:a}=gr();return a!==n?null:(0,hr.jsxs)("div",{className:s.page,id:`page_${n}`,tabIndex:-1,children:[r&&(0,hr.jsxs)("div",{className:s.pageNav,children:[(0,hr.jsxs)("button",{className:s.pageBackButton,type:"button",onClick:r,children:[(0,hr.jsx)(gc,{}),i("back")]}),t&&(0,hr.jsx)("h3",{className:s.pageTitle,children:t}),o&&(0,hr.jsx)(Pc,{})]}),e]})}var yr=S(O());var Ic=()=>/Mac/i.test(navigator.platform);var QP={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},H=QP;function YP(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function ne(e){return Array.isArray(e)?e.map(ne):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[YP(n)]:ne(e[n])}),{}):e}function fg(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Ee(e){return Array.isArray(e)?e.map(Ee):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[fg(n)]:Ee(e[n])}),{}):e}var ZP={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},da=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)||""}},ca=N("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?ne(r):(await n.client.patch("/apis/admin/session/me/",o,{version:null}),ne(r))}),pg=N("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}),mg=N("info/getAgentSettings",async(e,t)=>{let{deepdeskAPI:n}=t.extra;return(await n.client.get("/apis/admin/session/me/",{version:null})).ui_config}),fx=e=>e.info.agentInfo,px=F({name:"info",initialState:ZP,reducers:{setVisitorInfo(e,t){e.visitorInfo={...e.visitorInfo,...t.payload}}},extraReducers:e=>{e.addCase(ca.pending,(t,n)=>{t.fetchState="loading",t.agentInfo={...t.agentInfo,...n.meta.arg}}).addCase(ca.rejected,t=>{t.fetchState="error"}).addCase(ca.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(pg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(mg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(Z,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:mx}=px.actions,gx=px.reducer;var Lc={list:[],fetchState:"idle",isOpen:!1,page:"search"},hx=e=>e.search.isOpen,yx=e=>e.search.page,vx=e=>e.search.list;function Sx(e,t=n=>n){return n=>n.search.list.filter(r=>r.type===e).map(t)}var Xr=N("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:da(r),tags:e.tags});return i}),wx=F({name:"search",initialState:Lc,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=Lc.fetchState,e.list=Lc.list}},extraReducers:e=>{e.addCase(Xr.pending,t=>{t.fetchState="loading"}).addCase(Xr.rejected,(t,n)=>{t.fetchState="error",H.error(n.error)}).addCase(Xr.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload}).addCase(Z,()=>Lc)}}),{resetSearch:Ac,setIsOpen:ot,setPage:Ue}=wx.actions,xx=wx.reducer;var JP=/(https?:\/\/[^\s]+)/,Oc=e=>e.split(" ").find(t=>JP.test(t));var gg=S(Q());var Nc=S(C()),eR=({onClick:e,shortKeys:t,children:n,...r})=>{let o=P("CommandPalette",Qe);return(0,Nc.jsxs)("button",{type:"button",...r,onClick:e,className:(0,gg.default)(o.actionButton,r.className),children:[n,t&&t.map(i=>(0,Nc.jsx)("span",{className:(0,gg.default)(o.actionShortcut,i===8629&&o.actionShortcutFixKerning),children:typeof i=="number"?String.fromCharCode(i):i},i))]})},di=eR;var wn=S(C()),tR=({children:e,primaryLabel:t,secondaryLabel:n,onPrimary:r,onSecondary:o,list:i})=>{let s=P("CommandPalette",Qe),a=j(ua),{selected:l,setSelected:u}=gr(),c=i[l],p=c&&typeof c.text=="string"&&Oc(c.text),d=(0,yr.useRef)(null);function h(w){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),T=0,E=0;w==="down"?(x.forEach((R,b)=>{b===l&&(T=b)}),E=T===x.length-1?0:T+1):w==="up"?(x.forEach((R,b)=>{b===l&&(T=b)}),E=T?T-1:x.length-1):u(0);let _=x[E];_&&typeof E=="number"&&(u(E),_.scrollIntoView&&_.scrollIntoView({behavior:"smooth",block:E?"center":"end"}))}function y(){if(!d.current)return;let w=d.current.querySelectorAll(".command-palette-list-item"),x=0;w.forEach((E,_)=>{_===l&&(x=_)});let T=w[x];T&&T.click()}let v=()=>{p&&window.open(p,"_blank")},g=()=>{c&&r(c,l)},m=()=>{!c.type||["IMAGE","command"].includes(c.type)||o&&o(c,l)},f=(0,yr.useCallback)(w=>{if(w.key==="Enter"&&w.altKey&&p){v();return}if(w.key==="Enter"&&w.shiftKey){m();return}if(w.key==="ArrowDown"){w.preventDefault(),w.stopPropagation(),h("down");return}if(w.key==="ArrowUp"){w.preventDefault(),w.stopPropagation(),h("up");return}w.key==="Enter"&&l!==-1&&(w.preventDefault(),w.stopPropagation(),y())},[l]);return(0,yr.useEffect)(()=>(window.addEventListener("keyup",f),()=>{window.removeEventListener("keyup",f)}),[f]),(0,wn.jsxs)("div",{className:s.actions,children:[(0,wn.jsx)("div",{className:s.actionsWrapper,ref:d,children:e}),(0,wn.jsxs)("div",{className:s.actionsBar,children:[p&&(0,wn.jsx)(di,{onClick:v,shortKeys:[Ic()?8997:"ALT",8629],children:a("visitUrl")}),c&&(0,wn.jsxs)(yr.Fragment,{children:[o&&c.type&&!["command","image"].includes(c.type.toLowerCase())&&(0,wn.jsx)(di,{onClick:m,shortKeys:[8679,8629],children:n}),(0,wn.jsx)(di,{onClick:g,shortKeys:[8629],children:t})]})]})]})},Cx=tR;var Tx=S(O());var fa=S(C()),fi=()=>(0,fa.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"currentColor",children:[(0,fa.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,fa.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 Ht=S(C());function nR({onChange:e,onChangeType:t,placeholder:n,typePlaceholder:r,types:o,value:i,selectedType:s},a){let l=P("CommandPalette",Qe);return(0,Ht.jsxs)("div",{className:l.search,children:[(0,Ht.jsx)("div",{className:l.searchIcon,children:(0,Ht.jsx)(fi,{})}),(0,Ht.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Ht.jsx)("input",{ref:a,spellCheck:!1,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,Ht.jsx)("div",{className:l.selectWrapper,children:(0,Ht.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,Ht.jsx)("option",{children:r}),o.map(u=>(0,Ht.jsx)("option",{value:u.value,children:u.label},u.value))]})})]})]})}var _x=(0,Tx.forwardRef)(nR);var pa=S(C());function Qr({placeholder:e="Start typing to search...",typePlaceholder:t="All types",defaultPage:n="search",page:r,onChangePage:o,onChangeSearch:i,onChangeType:s,onChangeOpen:a,selectedType:l,types:u,children:c,isOpen:p,search:d}){let[h,y]=(0,pi.useState)(0),v=(0,pi.useRef)(null),g=()=>{o&&o(n),s(void 0),i(""),a(!1)},m=()=>{var f;if(r!==n&&o){o(n);return}if(l&&s){s(void 0),(f=v.current)==null||f.focus();return}if(d.length>0){i("");return}a(!1)};return(0,pi.useEffect)(()=>{y(0)},[d,r]),(0,pa.jsx)(ti,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:m,onClose:g,children:(0,pa.jsxs)(cx,{selected:h,setSelected:y,isOpen:p,onChangeOpen:a,page:r,children:[r===n&&(0,pa.jsx)(_x,{ref:v,onChange:i,onChangeType:s,placeholder:e,value:d,selectedType:l,types:u,typePlaceholder:t}),c]})})}Qr.Page=dg;Qr.List=ag;Qr.Image=rx;Qr.ListItem=cg;Qr.ActionsBar=Cx;Qr.Button=di;var ee=Qr;var je=S(C()),rR=({suggestion:e,onUse:t,onDismiss:n,onTouched:r,onNext:o,onPrevious:i})=>{let s=e.text||e.url||e.message,a=P("EditSuggestionForm",b0),l=K(),u=j(Nm),c=A(y=>y.overlayInput.text);(0,hg.useEffect)(()=>{e&&(l(Ge.actions.reset()),l(Ge.actions.stageSuggestion({text:s,suggestion:e,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Ge.actions.commitSuggestion()))},[e]);let p=y=>{y.preventDefault(),d(c)},d=y=>{l(Xu(y)),t(y)},h=y=>v=>{c!==s?window.confirm(u("warning"))&&y(v):y(v)};return(0,hg.useEffect)(()=>{r&&r(c!==s)},[r,e,c]),(0,je.jsxs)("div",{className:a.root,children:[(0,je.jsxs)("div",{className:a.content,children:[e.title&&(0,je.jsx)("h3",{className:a.title,children:e.title}),e.searchKeywords&&e.searchKeywords.length>0&&(0,je.jsx)(Km,{labels:e.searchKeywords}),(0,je.jsx)(nx,{onUse:d,value:c})]}),(0,je.jsxs)("form",{className:a.actions,onSubmit:p,children:[(0,je.jsxs)("div",{children:[(0,je.jsx)("button",{disabled:!i,className:a.pagination,type:"button",onClick:i&&h(i),children:(0,je.jsx)(gc,{})}),(0,je.jsx)("button",{disabled:!o,className:a.pagination,type:"button",onClick:o&&h(o),children:(0,je.jsx)(D0,{})})]}),(0,je.jsxs)("div",{className:a.primaryButtons,children:[(0,je.jsx)(ee.Button,{onClick:h(n),shortKeys:["esc"],children:u("dismiss")}),(0,je.jsx)(ee.Button,{shortKeys:[8679,8629],type:"submit",children:u("add")})]})]})]})},Mc=rR;var oR=["{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}"],iR=new RegExp(oR.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function bx(e,t){let n=e.split(iR),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],l=i===n.length-2;r+=s.length;let u=r;if(l){let p=a.charAt(0),d=0;do u=p?t.indexOf(p,u+1):-1,d+=1;while(u!==-1&&a.indexOf(t.slice(u))!==0);if(u===-1&&d>2)return e}else u=a&&a!==""?t.indexOf(a,r):-1;let c=u===-1?t.slice(r):t.slice(r,u);o.push(c),r=u}return o.join("")}function kx(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var Rx={suggestions:[],fetchState:"idle",isInitialRequest:null},Px={default:Rx},Ix=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)??[]},Lx=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)??[]},Ax=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")},mi=e=>e.textSuggestions,Ox=e=>t=>t.text.startsWith(e),Dc=fe("textSuggestions/refresh"),xn=N("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=Jo(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getTextSuggestions(o,da(r),e);if(e==="default"){let c=s?l.filter(Ox(a)):l;t.dispatch(fr(c.slice(0,i)))}return l}),ma=N("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,{...da(r),input:e});if(!t.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Ox(e))),s&&(l=l.map(c=>({...c,text:c.source!=="trie-with-typos"?bx(c.text,e):c.text}))),l=kx(l,i),t.dispatch(fr(l)),l}),Nx=F({name:"textSuggestions",initialState:Px,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(xn.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||Rx;return{...t,[r]:{...o,fetchState:"loading",isInitialRequest:o.isInitialRequest===null}}}).addCase(xn.rejected,(t,n)=>{let r=n.meta.arg;t[r].fetchState="error"}).addCase(xn.fulfilled,(t,n)=>{let r=n.meta.arg;t[r].fetchState="done",t[r].suggestions=n.payload}).addCase(ma.pending,t=>{t.default.fetchState="loading"}).addCase(ma.rejected,t=>{t.default.fetchState="error"}).addCase(ma.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(Z,()=>Px)}}),{setTextSuggestions:Mx,setSuggestionState:Dx}=Nx.actions,Fx=Nx.reducer;var jx={contentType:null,suggestion:null},Hx=e=>e.activeSuggestion.suggestion,Bx=e=>e.activeSuggestion.contentType,Ux=F({name:"activeSuggestion",initialState:jx,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(Z,()=>jx)}}),{setActiveSuggestion:En,resetActiveSuggestion:yg}=Ux.actions,zx=Ux.reducer;var vg={};Te(vg,{enUS:()=>sR,nlNL:()=>aR});var sR={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"}]},aR={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 lR={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Vx=({ui:e})=>e.overlayCollapsed;var Kx=F({name:"ui",initialState:lR,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:ga,setInputHasFocus:gi,setOverlayCollapsed:hi,setOpenOverlayWhenTyping:Wx,setOverlayCollapsedUserOverwrite:$x}=Kx.actions,qx=Kx.reducer;var ha=S(O()),Xx=S(C()),Gx=ha.default.createContext(null),ya=({broadcastEvents:e,children:t})=>{let n=ha.default.useMemo(()=>e,[]);return(0,Xx.jsx)(Gx.Provider,{value:n,children:t})},bt=()=>{let e=(0,ha.useContext)(Gx);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var uR={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Cn=e=>e.auth.isLoggedIn,Qx=e=>e.auth.loginFetchState,Yx=e=>e.auth.verifyFetchState,Zx=e=>e.auth.showLoginOverlay,Yr=N("auth/validate",async(e,t)=>t.extra.deepdeskAPI.isLoggedIn()),Jx=N("auth/requestLogin",async({email:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.requestLoginByEmail(e)}),va=N("auth/verifyLoginToken",async({token:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.verifyLoginToken(e)}),eE=F({name:"auth",initialState:uR,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload}},extraReducers:e=>{e.addCase(Yr.pending,t=>{t.loginFetchState="loading"}),e.addCase(Yr.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(Yr.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(va.pending,t=>{t.verifyFetchState="loading"}),e.addCase(va.rejected,t=>{t.verifyFetchState="error"}),e.addCase(va.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:Fc,setShowLoginOverlay:tE}=eE.actions,nE=eE.reducer;var Sg="SetActiveSuggestion",yi="ShowLoginOverlay",wg="UserLoggedIn",Tn="ApplySuggestion",xg="ApplyImageSuggestion",cR="ShowCommandPalette",dR=e=>({[Sg]:t=>{e.dispatch(Dx(t.state)),e.dispatch(En({contentType:t.contentType,suggestion:t.suggestion}))},[cR]:t=>{e.dispatch(ot(t.isOpen)),t.page&&e.dispatch(Ue(t.page))},[yi]:t=>{e.dispatch(tE(t))},[wg]:()=>{e.dispatch(Yr())},[xg]:t=>{e.dispatch(Yu({suggestion:t.suggestion}))},[Tn]:t=>{e.dispatch(Mt({...t,eventMetrics:{inputType:"mouse"},replace:"selection"})),e.dispatch(pr())}}),rE=dR;var Eg=S(C()),fR=()=>{var y;let[e,t]=(0,oE.useState)(!1),n=A(Hx),r=A(Bx),o=A(mi),i=K(),s=bt(),a=j(vg),l=()=>{n!==null&&e?window.confirm(a("warning"))&&u():u()},u=()=>{i(yg()),i(gi(!0)),i(Ge.actions.reset())},c=(v,g)=>{i(yg()),i(gi(!0)),s.send(Tn,{text:v,suggestion:g})};if(n===null||r===null)return null;let p=(y=o[r])==null?void 0:y.suggestions.indexOf(n),d=p===0||p===null?void 0:()=>i(En({contentType:r,suggestion:o[r].suggestions[p-1]})),h=p===o[r].suggestions.length-1||p===null?void 0:()=>i(En({contentType:r,suggestion:o[r].suggestions[p+1]}));return(0,Eg.jsx)(ti,{autoFocus:!0,isOpen:p!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Eg.jsx)(Mc,{onTouched:t,onDismiss:u,onUse:v=>c(v,n),suggestion:n,onNext:h,onPrevious:d})})},iE=fR;var jc=S(Q()),Bt=S(O());var aE=S(Q());var sE={root:"_root_1ukx5_1"};var lE=S(C()),pR=({className:e,value:t,...n})=>{let r=P("TextInput",sE);return(0,lE.jsx)("input",{className:(0,aE.default)(e,r.root),type:"text",value:t,...n})},Sa=pR;var Cg={};Te(Cg,{enUS:()=>mR,nlNL:()=>gR});var mR={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"}]},gR={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 uE={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=S(C());var hR=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch{return e}},yR=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=j(Cg),s=P("LoginTokenDialog",uE),a=A(Yx),l=K(),u=D("productName"),[c,p]=(0,Bt.useState)(e||""),[d,h]=(0,Bt.useState)(0),[y,v]=(0,Bt.useState)(""),g=(0,Bt.useCallback)(async x=>{x.preventDefault(),l(Jx({email:c})),h(1)},[n,c]),m=()=>{v(""),h(0)},f=(0,Bt.useCallback)(async x=>{x.preventDefault();let T=hR(x.target.elements.token.value);if(!T){v(i("verifyCodeError",{login:w}));return}l(va({token:T}))},[n]),w=(0,Bt.useMemo)(()=>x=>(0,he.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:m,children:x},"back-button"),[]);return(0,Bt.useEffect)(()=>{a==="error"&&v(i("verifyCodeError",{login:w})),a==="done"&&r()},[a]),(0,he.jsx)(ti,{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)(Sa,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:c,onChange:x=>p(x.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:f,children:[(0,he.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,he.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,he.jsx)(Sa,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),y&&(0,he.jsx)("div",{className:s.errorMessage,children:y}),(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")})]})]})]})})},cE=yR;var fE=S(C()),vR=()=>{let e=A(Zx),t=A(fx),n=D("adminUrl"),r=bt(),o=()=>r.send(yi,!1),i=()=>{r.send(yi,!1),r.send(wg)};return(0,fE.jsx)(cE,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},dE=vR;var jE=S(bg()),it=S(O());var DR={data:null,fetchState:"idle"},hE=e=>e.contentTypes.data,wa=N("contentTypes/getContentTypes",async(e,t)=>t.extra.deepdeskAPI.getContentTypes()),FR=F({name:"contentTypes",initialState:DR,reducers:{},extraReducers:e=>{e.addCase(wa.pending,t=>{t.fetchState="loading"}).addCase(wa.rejected,t=>{t.fetchState="error"}).addCase(wa.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),yE=FR.reducer;function xa(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 vE=S(O());function SE(e,t){(0,vE.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 Ea=S(O());var wE={data:null,fetchState:"idle"},Hc=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},Ut=N("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)}),jR=e=>e.filter((t,n)=>n===e.findIndex(r=>r.text===t.text)),HR=F({name:"entities",initialState:wE,reducers:{},extraReducers:e=>{e.addCase(Ut.pending,t=>{t.fetchState="loading"}).addCase(Ut.rejected,t=>{t.fetchState="error"}).addCase(Ut.fulfilled,(t,n)=>{t.fetchState="done",t.data=jR(t.data?[...t.data,...n.payload]:n.payload)}).addCase(Z,()=>wE)}}),xE=HR.reducer;var kg={};Te(kg,{enUS:()=>BR,nlNL:()=>UR});var BR={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},UR={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var EE={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Zr=S(C()),zR=({onCopy:e,onUse:t})=>{let n=(0,Ea.useRef)(null),r=P("EntitiesList",EE),o=j(kg),i=A(Hc),s=K();return(0,Ea.useEffect)(()=>{s(Ut())},[]),(0,Ea.useEffect)(()=>{n.current&&n.current.focus()},[n]),(0,Zr.jsxs)("div",{className:r.root,ref:n,tabIndex:-1,children:[i&&i.length>0&&(0,Zr.jsx)(ee.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,Zr.jsx)(ee.List,{children:i.map((a,l)=>(0,Zr.jsx)(ee.ListItem,{index:l,closeOnSelect:!0,onClick:()=>e(a),children:a.text},a.text))},"entities")}),i&&i.length===0&&(0,Zr.jsx)("p",{className:r.empty,children:o("noResults")})]})},CE=zR;var zt=S(O());var TE={data:null,fetchState:"idle"},_E=e=>e.summary.data,bE=e=>e.summary.fetchState==="error",_n=N("summary/getSummary",async(e,t)=>{let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra;if(!r.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let o=r.conversationQuery,i=await o();if(i.length===0)return Promise.reject(new Error("No messages are included"));let s=await n.getSummary(i);return{original:i,summary:s}}),VR=F({name:"summary",initialState:TE,reducers:{},extraReducers:e=>{e.addCase(_n.pending,t=>{t.data=null,t.fetchState="loading"}).addCase(_n.rejected,t=>{t.data=null,t.fetchState="error"}).addCase(_n.fulfilled,(t,n)=>{t.fetchState="done",n.payload&&(t.data=n.payload.summary)}).addCase(Z,()=>TE)}}),kE=VR.reducer;var Pg={};Te(Pg,{enUS:()=>KR,nlNL:()=>WR});var KR={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."}]},WR={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 PE={root:"_root_18y7z_1",actions:"_actions_18y7z_5",main:"_main_18y7z_11",textInput:"_textInput_18y7z_15",loading:"_loading_18y7z_34",error:"_error_18y7z_38"};var bn=S(C()),$R=({onCopy:e})=>{let t=(0,zt.useRef)(null),n=P("SummaryForm",PE),[r,o]=(0,zt.useState)(""),i=j(Pg),s=A(_E),a=A(bE),l=K(),u=()=>{l(Zt({name:"summary copied to clipboard",data:{originalText:s,finalText:r},options:{includeConversationData:!0}})),e(r)},c=()=>{let p=document.getSelection();p&&l(Zt({name:"summary copied to clipboard",data:{originalText:s,finalText:p==null?void 0:p.toString()},options:{includeConversationData:!0}}))};return(0,zt.useEffect)(()=>{l(_n())},[]),(0,zt.useEffect)(()=>{o(s||"")},[s]),(0,zt.useEffect)(()=>{t.current&&s&&t.current.focus()},[t,s]),(0,zt.useEffect)(()=>{let p=d=>{d.key==="Enter"&&d.shiftKey&&u()};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[r]),(0,bn.jsx)("div",{className:n.root,tabIndex:-1,children:a?(0,bn.jsx)("p",{className:n.error,children:i("error")}):(0,bn.jsxs)(zt.Fragment,{children:[(0,bn.jsx)("div",{className:n.main,children:(0,bn.jsx)("textarea",{placeholder:s?void 0:i("loading"),disabled:!s,className:n.textInput,ref:t,value:r,onCopy:c,onChange:p=>o(p.target.value)})}),(0,bn.jsx)("div",{className:n.actions,children:(0,bn.jsx)(ee.Button,{shortKeys:[8679,8629],onClick:u,children:i("copy")})})]})})},RE=$R;var Rg={};Te(Rg,{enUS:()=>qR,nlNL:()=>GR});var qR={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"}],knowledgeSearch:[{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?"}]},GR={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:"Vat gesprek samen"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeSearch:[{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 Jr=S(O());var Ig={};Te(Ig,{enUS:()=>XR,nlNL:()=>QR});var XR={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"}]},QR={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 IE={root:"_root_cnaw4_1",title:"_title_cnaw4_9",empty:"_empty_cnaw4_20",status:"_status_cnaw4_24",form:"_form_cnaw4_30",input:"_input_cnaw4_43",submit:"_submit_cnaw4_55",question:"_question_cnaw4_63",answer:"_answer_cnaw4_67",alignRight:"_alignRight_cnaw4_73"};var Lg={data:[],fetchState:"idle"},LE=e=>{var t;return(t=e.answer)==null?void 0:t.data},AE=e=>e.answer.fetchState,Ca=fe("answer/resetKnowledgeSearch"),vi=N("answer/getAnswer",async(e,t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState().answer.data,o=(s=t.getState().profile.data)==null?void 0:s.code;if(!o)throw new Error("Profile is not defined");let i=await n.knowledgeSearch({promptInstruction:e.promptInstruction,question:e.question},r,o);return{question:e.question,answer:i}}),YR=F({name:"answer",initialState:Lg,reducers:{},extraReducers:e=>{e.addCase(vi.pending,t=>{t.fetchState="loading"}).addCase(vi.rejected,t=>{t.fetchState="error"}).addCase(vi.fulfilled,(t,n)=>{t.fetchState="done",t.data=[...t.data,n.payload]}).addCase(Z,()=>Lg).addCase(Ca,()=>Lg)}}),OE=YR.reducer;var Ta=S(C()),NE=()=>(0,Ta.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Ta.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Ta.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 Ye=S(C()),ZR=({onUse:e,onResetQuestion:t,question:n,promptInstruction:r})=>{let[o,i]=Jr.default.useState(""),{setSelected:s}=gr(),a=(0,Jr.useRef)(null),l=P("EntitiesList",IE),u=j(Ig),c=K(),p=A(LE),d=A(AE),h=async y=>{y.preventDefault(),y.stopPropagation(),o!==""&&c(vi({question:o,promptInstruction:r}))};return(0,Jr.useEffect)(()=>{var y;n&&d==="idle"?c(vi({question:n,promptInstruction:r})):(y=a.current)==null||y.focus()},[a,d]),(0,Jr.useEffect)(()=>{d==="done"&&(s(0),i(""))},[d,p]),(0,Ye.jsxs)("div",{className:l.root,children:[p.length>0&&(0,Ye.jsx)("div",{className:l.alignRight,children:(0,Ye.jsx)(ee.Button,{onClick:t,children:u("reset")})}),(0,Ye.jsxs)(ee.ActionsBar,{list:p.map(({answer:y})=>({text:y.answer,type:"answer"})),primaryLabel:u("use"),onPrimary:y=>e(y.text),children:[p.map(({question:y,answer:v},g)=>(0,Ye.jsx)(ee.List,{children:(0,Ye.jsx)(ee.ListItem,{"data-testid":"knowledge-search-answer",index:g,description:v.answer,closeOnSelect:!0,onClick:()=>e(v.answer),sources:v.sources,styles:{title:l.question,description:l.answer},children:y})},`${v.answer}_${g}`)),d==="loading"&&(0,Ye.jsx)("p",{className:l.status,children:u("loading")}),d==="error"&&(0,Ye.jsx)("p",{className:l.status,children:u("error")}),(0,Ye.jsxs)("form",{className:l.form,onSubmit:h,children:[(0,Ye.jsx)("input",{ref:a,placeholder:u("anotherQuestion"),className:l.input,type:"text",value:o,onFocus:()=>{s(-1)},onChange:y=>{s(-1),i(y.target.value)}}),(0,Ye.jsx)("button",{type:"submit",className:l.submit,children:(0,Ye.jsx)(NE,{})})]})]})]})},ME=ZR;var JR={data:null,fetchState:"idle"},Si=e=>e.profile.data,Bc=e=>e.profile.data?e.profile.data.uiConfig.widget.types.filter(t=>t.isActive):[],_a=N("profile/getProfile",async(e,t)=>{let{deepdeskAPI:n}=t.extra,o=t.getState().conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");return n.getProfile(o.profileCode)}),eI=F({name:"profile",initialState:JR,reducers:{},extraReducers:e=>{e.addCase(_a.pending,t=>{t.fetchState="loading"}).addCase(_a.rejected,t=>{t.fetchState="error"}).addCase(_a.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),DE=eI.reducer;var Ce=S(C()),tI=200,nI=5,rI=4,oI=e=>e.reduce((t,n)=>[...t,...n.list.map(r=>({...r,type:n.value}))],[]),FE=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),iI=()=>{let e=K(),t=bt(),n=j(Rg),[r,o]=(0,it.useState)(!1),[i,s]=(0,it.useState)(""),a=A(yx),l=A(Si),[u,c]=(0,it.useState)(null),[p,d]=(0,it.useState)([]),[h,y]=(0,it.useState)(),v=A(Cn),g=D("showSearch"),m=D("showEntitiesCommand"),f=D("showSummaryCommand"),w=D("showKnowledgeSearch"),x=D("showImageSearch"),T=D("searchTriggerKey"),E=A(hE),_=A(vx),R=A(hx),b=I=>on(_.filter(W=>W.type===I.toUpperCase()),I),B=[{value:"PERSONAL",label:n("personalSuggestions"),list:b("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:n("urlSuggestions"),list:b("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:b("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:b("IMAGE"),listOrientation:"horizontal",shouldShow:x}].filter(I=>I.shouldShow),re=[{label:n("entitiesClipboard"),onClick:()=>e(Ue("entities")),shouldShow:m&&FE(n("entitiesClipboard"),i),experimental:!0},{label:n("summaryClipboard"),onClick:()=>e(Ue("summary")),shouldShow:f&&FE(n("summaryClipboard"),i),experimental:!0},{label:i?`${n("knowledgeSearch")}: ${i}`:n("knowledgeSearch"),onClick:()=>e(Ue("knowledgeSearch")),shouldShow:w,experimental:!0}].filter(I=>I.shouldShow),z=(E==null?void 0:E.map(I=>({value:I.code.toUpperCase(),label:`${I.name}s`,list:b(I.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Pe=(0,it.useCallback)((0,jE.default)((I,W)=>{e(Xr({query:I,type:W,tags:["search-overlay"]}))},tI),[]),so=oI([...z,...B]),Vt=(0,it.useCallback)((I,W)=>{if(!W)return;let It=[...B,...z].find(({value:Dn})=>Dn===W);It&&(e(Ue("edit")),c(I),d(It.list))},[e,u,z]),ao=(0,it.useCallback)((I,W)=>{switch(W.type){case"IMAGE":t.send(xg,{suggestion:W});break;default:t.send(Tn,{text:I,suggestion:W})}e(ot(!1))},[e]),Ii=I=>{xa(I.text),e(Zt({name:"entity copied",data:{entity:I,type:"copy"}})),e(ot(!1))},Tr=I=>{t.send(Tn,{text:I,suggestion:{source:"knowledge-search",text:I}}),e(Zt({name:"answer used",data:{originalText:I},options:{includeConversationData:!0}})),s(""),e(Ue("search")),e(Ca()),e(ot(!1))},Fa=I=>{xa(I),e(ot(!1))},ja=I=>{t.send(Tn,{text:I.text,suggestion:{source:"entity",text:I.text}}),e(ot(!1))},Li=u===null||p.indexOf(u)-1<0?void 0:()=>c(p[p.indexOf(u)-1]),Ai=u===null||p.indexOf(u)===p.length-1?void 0:()=>c(p[p.indexOf(u)+1]);function on(I,W){return I.slice(0,h?10:W.toLowerCase()==="image"?rI:nI)}function Oi(I,W,It){return W.reduce((Dn,sn)=>It&&h===It?sn.length+Dn:on(sn,It).length+Dn,I)}function _r(I){return W=>{r?window.confirm(n("warning"))&&(I(W),o(!1)):I(W)}}return(0,it.useEffect)(()=>{i?Pe(i,h):e(Ac())},[i,h]),(0,it.useEffect)(()=>{v&&e(wa())},[v]),SE(T,()=>e(ot(!0))),!g||!l?null:(0,Ce.jsxs)(ee,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:_r(I=>e(ot(I))),onChangeType:I=>y(I),onChangePage:_r(I=>e(Ue(I))),selectedType:h,search:i,page:a,isOpen:R,types:[...z,...B],children:[(0,Ce.jsx)(ee.Page,{id:"search",children:(0,Ce.jsxs)(ee.ActionsBar,{list:[...re.map(I=>({text:I.label,type:"command"})),...so.map(I=>({text:I.text||I.url||I.message,type:I.type}))],primaryLabel:n("use"),secondaryLabel:n("preview"),onPrimary:({text:I},W)=>ao(I,so[W]),onSecondary:(I,W)=>Vt(so[W],so[W].type),children:[re.length>0&&(0,Ce.jsx)(ee.List,{heading:n("commands"),children:re.map((I,W)=>(0,Ce.jsx)(ee.ListItem,{index:Oi(W,[],"commands"),closeOnSelect:!1,onClick:I.onClick,isExperimental:I.experimental,children:I.label},I.label))}),[...z,...B].map(({value:I,label:W,list:It,lineClamp:Dn,listOrientation:sn},Ni)=>(0,Ce.jsx)(ee.List,{heading:W,orientation:sn==="horizontal"?"horizontal":"vertical",children:on(It,I).map((ut,ct)=>(0,Ce.jsx)(ee.ListItem,{index:Oi(re.length+ct,[...z,...B].slice(0,Ni).map(({list:br})=>br),I),closeOnSelect:!1,lineClamp:Dn,onClick:()=>ao(ut.text,ut),description:I!=="IMAGE"?ut.title&&ut.text:void 0,children:I==="IMAGE"?(0,Ce.jsx)(ee.Image,{title:ut.title||ut.text,src:ut.image}):ut.title||ut.text},`${ut.id}-${ut.text}`))},I))]})}),(0,Ce.jsx)(ee.Page,{id:"edit",onDismiss:_r(()=>{e(Ue("search")),c(null)}),children:u&&(0,Ce.jsx)(Mc,{suggestion:u,onTouched:o,onDismiss:()=>{o(!1),e(Ue("search")),c(null),d([])},onNext:Ai,onPrevious:Li,onUse:I=>{e(Ue("search")),ao(I,u),e(ot(!1)),d([]),c(null)}})}),(0,Ce.jsx)(ee.Page,{id:"entities",title:n("entitiesTitle"),isExperimental:!0,onDismiss:_r(()=>{e(Ue("search"))}),children:(0,Ce.jsx)(CE,{onUse:ja,onCopy:Ii})}),(0,Ce.jsx)(ee.Page,{id:"summary",title:n("summaryTitle"),isExperimental:!0,onDismiss:_r(()=>{e(Ue("search"))}),children:(0,Ce.jsx)(RE,{onCopy:Fa})}),(0,Ce.jsx)(ee.Page,{id:"knowledgeSearch",title:n("knowledgeSearch"),isExperimental:!0,onDismiss:_r(()=>{e(Ca()),e(Ue("search"))}),children:(0,Ce.jsx)(ME,{promptInstruction:l.knowledgeSearchPromptInstruction,question:i,onUse:Tr,onResetQuestion:()=>{e(Ca()),s("")}})})]})},HE=iI;var wi=S(C()),sI=()=>{let e=D("showSearch"),t=D("isEmbedded");return(0,wi.jsxs)(BE.Fragment,{children:[e&&(0,wi.jsx)(HE,{}),(0,wi.jsx)(iE,{}),t&&(0,wi.jsx)(dE,{})]})},UE=sI;var ba=S(C()),aI=({children:e})=>{let n=D("locale").replace("-","");return(0,ba.jsx)(zm.Provider,{value:n,children:e})},lI=({store:e,customStyles:t={},children:n})=>(0,ba.jsx)(Em,{store:e,children:(0,ba.jsx)(aI,{children:(0,ba.jsx)($s.Provider,{value:t,children:n})})}),ka=lI;var Kc=S(Q()),Ci=S(O());var zE=S(O());function VE(e,t){let[n,r]=(0,zE.useState)(()=>{if(typeof window>"u")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return H.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window<"u"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){H.error(s)}}]}function Uc(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 WE=S(Q()),kn=S(O());var Ag={};Te(Ag,{enUS:()=>uI,nlNL:()=>cI});var uI={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"}]}]},cI={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 KE={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var vr=S(C()),Og=(e,t,n)=>r=>(0,vr.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),dI=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r})=>{let o=j(Ag),i=bt(),s=P("Login",KE),a=D("productName"),l=(0,kn.useCallback)(v=>{v.preventDefault(),r&&r(parseInt(v.target.value,10))},[]),u=(0,kn.useCallback)(v=>{v.preventDefault(),i.send(yi,!0)},[t]),c=(0,kn.useMemo)(()=>v=>(0,vr.jsx)("a",{href:t,className:s.anchor,target:"_blank",rel:"noreferrer",children:v},"login"),[t]),p=(0,kn.useCallback)(v=>(0,vr.jsx)("button",{type:"button",className:s.anchorButton,onClick:u,children:v},"prompt"),[u]),{min:d,hour:h,day:y}=(0,kn.useMemo)(()=>({min:Og(s,60*10,l),hour:Og(s,60*60,l),day:Og(s,60*60*12,l)}),[]);return(0,vr.jsxs)("div",{className:(0,WE.default)(e,s.root),children:[o("loginPlease",{login:n?p:c,productName:a}),r&&(0,vr.jsxs)(kn.Fragment,{children:[(0,vr.jsx)("br",{}),o("snooze",{min:d,hour:h,day:y})]})]})},zc=dI;var $E={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var Pa=S(C()),fI=({title:e})=>{let t=P("SearchTrigger",$E),n=K();return(0,Pa.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(ot(!0)),children:[(0,Pa.jsx)(fi,{}),(0,Pa.jsx)("span",{className:t.text,children:e})]})},qE=fI;var XE=S(Q());var GE={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var QE=S(C()),pI=({withDivider:e,children:t})=>{let n=P("SuggestionList",GE);return(0,QE.jsx)("div",{className:(0,XE.default)(n.root,{[n.isWithDivider]:e}),children:t})},tn=pI;var rC=S(O());var Ei=S(O());var YE=S(O());function ZE(e,t,n){(0,YE.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var mI=/[.*+?^${}()|[\]\\]/g,gI=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function hI(e){return e.replace(mI,"\\$&")}function yI(e,t){let n=e.split("").findIndex((r,o)=>r!==t[o]);return n>-1?n:Math.min(e.length,t.length)}function Ng(e){return e.search(gI)}function JE(e,t=[]){let n=e;return t.forEach(r=>{if(!r)return;let o=new RegExp(`\\b(${hI(r)})\\b`,"gi");n=n.replace(o,"<strong>$1</strong>")}),n}function eC(e){return e.replace(lo,'<mark data-type="placeholder">$1</mark>')}function xi(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function vI(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 Mg(e,t,n={}){if(t){let r=yI(t.toLowerCase(),e.toLowerCase()),o=xi(e.substring(r,e.length));if(n.stripAgentPart){let l=e.substring(0,r),u=Ng(l);return`<span style="opacity: 0.5">${l.substring(u+1)}</span>${o}`}let s=t.split(vh).length>3||t.length>30?vI(t.trim(),r):0;return`${`${s>0?"\u2026":""}${xi(e.substring(s,r))}`}<strong>${o}</strong>`}return e}var tC={badge:"_badge_8rv7b_1",formattedText:"_formattedText_8rv7b_5"};var Dg=S(C()),wI=["search","personal-collection-search","studio-search"];function xI(e,t,n,r={}){let o="";return wI.includes(t)?o=JE(Mg(e,n,{stripAgentPart:!0}),r.searchKeywords??[n]):o=Mg(e,n,r),r.placeholders===!0&&(o=eC(o)),o}var EI=()=>{},CI=({index:e,selected:t,suggestion:n})=>{let r=D("inlineSuggestions"),o=A(Jo),i=K(),s=P("TextSuggestion",tC),a=(0,Ei.useRef)(null);(0,Ei.useEffect)(()=>{let u=setTimeout(()=>{i(p0({text:n.text,suggestion:n}))},500);return()=>{clearTimeout(u)}},[n]),ZE(a,"click",()=>{i(Zu(e)),i(Mt({suggestion:n,text:n.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,Ei.useMemo)(()=>xI(n.text,n.source,o,{stripAgentPart:r,placeholders:!0,searchKeywords:n.searchKeywords}),[r,n.text,n.source,o,n.searchKeywords]);return n.source==="gpt"?null:(0,Dg.jsx)(se,{ref:a,as:"button",selected:t,onClick:EI,children:(0,Dg.jsx)(oi,{containerTagName:"div",noWrap:!1,tagName:"span",className:s.formattedText,content:l})})},nC=CI;var Fg=S(C()),TI=({suggestions:e,selectedIndex:t})=>(0,Fg.jsx)(rC.Fragment,{children:e.slice().map((n,r)=>(0,Fg.jsx)(nC,{index:r,selected:r===t,suggestion:n},`${n.text}-${n.source}`)).reverse()}),oC=TI;var sC=S(Q());var iC={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Vc=S(C()),_I=({className:e,isCollapsed:t,title:n,onClick:r})=>{let o=P("ToggleButton",iC);return(0,Vc.jsx)("button",{type:"button",className:(0,sC.default)(o.root,e,{[o.isCollapsed]:t}),onClick:r,title:n,children:(0,Vc.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Vc.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},eo=_I;var jg={};Te(jg,{enUS:()=>bI,nlNL:()=>kI});var bI={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"}]},kI={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 aC={root:"_root_4kcme_1",isInline:"_isInline_4kcme_14",toggleButton:"_toggleButton_4kcme_18",toggleButtonWrapper:"_toggleButtonWrapper_4kcme_22",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_4kcme_29",isCollapsed:"_isCollapsed_4kcme_33",collapsible:"_collapsible_4kcme_33",hints:"_hints_4kcme_41",hintsHidden:"_hintsHidden_4kcme_48",triggers:"_triggers_4kcme_53",triggersRight:"_triggersRight_4kcme_68"};var ue=S(C()),PI=({inline:e=!1,textSuggestions:t,selectedIndex:n})=>{let r=P("SuggestionsOverlay",aC),o=j(jg),i=D("inlineSuggestions"),s=A(Uc),a=l0(),l=K(),u=(0,Ci.useRef)(null),c=D("searchTriggerKey"),p=D("productName"),d=A(Vx),h=A(Cn),y=A(Bu),[v,g]=(0,Ci.useState)(null),m=D("showSearch"),f=D("showTextSuggestions"),w=D("adminUrl"),x=D("isEmbedded"),[T,E]=VE("dd-snooze-until-ms",0),_=d||T>Date.now(),R=t.filter(re=>re.source!=="gpt").length,b=()=>{_&&E(0),l($x(!_))},B=re=>{let z=Date.now()+re*1e3;E(z),H.info(`Snooze until: ${new Date(z)}`),l(hi({collapse:!0}))};return(0,Ci.useEffect)(()=>{R===0&&g(null)},[t,R]),li(()=>{l(hi({collapse:!0,skipWhenInputFocus:!0}))}),i!==e||h===null||y===!1?null:h===!1?(0,ue.jsxs)("div",{ref:u,className:(0,Kc.default)(r.root,{[r.isCollapsed]:_,[r.isInline]:e}),"data-inline":e,children:[!_&&(0,ue.jsxs)("div",{className:r.triggers,children:[(0,ue.jsx)("div",{style:{flex:1}}),(0,ue.jsx)("div",{className:r.triggersRight,children:(0,ue.jsx)(eo,{className:r.toggleButton,title:o("collapse"),onClick:b,isCollapsed:!1})})]}),(0,ue.jsx)("div",{className:r.toggleButtonWrapper,children:(0,ue.jsx)(eo,{className:r.toggleButton,title:o("open",{productName:p}),onClick:b,isCollapsed:!0})}),(0,ue.jsx)("div",{className:r.collapsible,children:(0,ue.jsx)(zc,{loginUrl:w,isEmbedded:x,onSnooze:B})})]}):!a||!s?null:(0,ue.jsxs)("div",{ref:u,className:(0,Kc.default)(r.root,{[r.isCollapsed]:_,[r.isInline]:e}),"data-inline":e,children:[!_&&(0,ue.jsxs)("div",{className:r.triggers,children:[(0,ue.jsx)("div",{style:{flex:1},children:m&&(0,ue.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>g(o(Ic()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>g(null),children:(0,ue.jsx)(qE,{title:o("search")})})}),(0,ue.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,ue.jsx)("div",{className:(0,Kc.default)(!v&&r.hintsHidden,r.hints),children:v}),(0,ue.jsx)(eo,{className:r.toggleButton,title:o("collapse"),onClick:b,isCollapsed:!1})]})]}),(0,ue.jsx)("div",{className:r.toggleButtonWrapper,children:(0,ue.jsx)(eo,{className:r.toggleButton,title:o("open",{productName:p}),onClick:b,isCollapsed:!0})}),R>0&&f&&(0,ue.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,ue.jsx)(tn,{children:(0,ue.jsx)(oC,{suggestions:t,selectedIndex:n})})})]})},RI=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),Wc=Vr(RI)(PI);var ld=S(Q());var In=S(O());var lC=S(O()),II=["div","span","mark","strong","b","i","u","em"];function Hg(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(II.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,lC.cloneElement)(r,{children:Hg(s,t,n+1)})]}return[...e,...t]}function Pn(e){return e.tagName.toLowerCase()==="textarea"}var cC=S(Q());var uC={root:"_root_1s73o_1",isArrowUp:"_isArrowUp_1s73o_22",isArrowDown:"_isArrowDown_1s73o_23",isTab:"_isTab_1s73o_39",isEsc:"_isEsc_1s73o_44",isEnter:"_isEnter_1s73o_49"};var dC=S(C());var LI=({className:e,keyCode:t,children:n,...r})=>{let o=P("KeyboardHint",uC);return(0,dC.jsx)("span",{className:(0,cC.default)(e,o.root,{[o.isArrowUp]:t==="arrow-up",[o.isArrowDown]:t==="arrow-down",[o.isTab]:t==="tab",[o.isEsc]:t==="esc",[o.isEnter]:t==="enter"}),...r,children:n})},$c=LI;var Qc=S(O());var Ug=S(Q()),kt=S(O());var qc=S(O()),AI=["bottom","height","left","right","top","width"],OI=(e={},t={})=>AI.some(n=>e[n]!==t[n]),Rn=new Map,fC,pC=()=>{let e=[],t=[];Rn.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();OI(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{Rn.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),fC=window.requestAnimationFrame(pC)};function NI(e,t){return{observe(){let n=Rn.size===0;if(Rn.has(e)){let r=Rn.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else Rn.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&pC()},unobserve(){let n=Rn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Rn.delete(e),Rn.size||cancelAnimationFrame(fC)}}}}function Bg(e){let[t,n]=(0,qc.useState)(null);return(0,qc.useLayoutEffect)(()=>{if(!e.current)return;let r=NI(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var Ti=S(O()),gC=S(tu());var mC={root:"_root_1jq08_1"};var hC=({children:e})=>{let[t,n]=(0,Ti.useState)(null),r=(0,Ti.useContext)($s);return(0,Ti.useLayoutEffect)(()=>{let o=document.createElement("div");return Gr(o),o.classList.add(mC.root),r!=null&&r.rootNode&&o.classList.add(r==null?void 0:r.rootNode),document.body.appendChild(o),n(o),()=>{o.isConnected&&document.body.removeChild(o)}},[]),t?(0,gC.createPortal)(e,t):null};var nn={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 Gc=S(C()),_i=(e=!1)=>{let[t,n]=(0,kt.useState)(e),r=(0,kt.useCallback)(()=>n(!0),[]),o=(0,kt.useCallback)(()=>n(!1),[]),i=(0,kt.useCallback)(()=>n(a=>!a),[]),s=(0,kt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function zg(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 bi=({className:e,triggerRef:t,boundaryRef:n=(0,kt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=zg,...a})=>{let l=Bg(t),u=Bg(n),c=(0,kt.useMemo)(()=>s(l,u,0),[l,u]);return(0,Gc.jsx)(hC,{children:(0,Gc.jsx)("div",{className:(0,Ug.default)(nn.ref,{[nn.positionAbove]:r==="above",[nn.positionBelow]:r==="below",[nn.positionLeft]:r==="left",[nn.positionRight]:r==="right",[nn.alignStart]:o==="start",[nn.alignCenter]:o==="center",[nn.alignEnd]:o==="end"}),style:c,...a,role:"dialog",children:(0,Gc.jsx)("div",{className:(0,Ug.default)(e,nn.root),children:i})})})};var Sr=S(C()),MI=({inputStyle:e,inputElement:t})=>{let n=P("TabCompletion",Ct),r=_i(document.activeElement===t);return li(()=>r.close()),(0,Qc.useEffect)(()=>{let o=()=>r.open();return t.addEventListener("focus",o),()=>{t.removeEventListener("focus",o)}},[]),(0,Sr.jsxs)(Qc.Fragment,{children:[(0,Sr.jsx)("mark",{className:Ct.caret,ref:r.triggerRef}),r.opened&&(0,Sr.jsx)(bi,{className:n.popoverSuggestionsRoot,triggerRef:r.triggerRef,position:"above",align:"start",children:(0,Sr.jsx)("div",{style:e,className:n.suggestionsOverlayInputStyles,children:(0,Sr.jsx)(Wc,{inline:!0})})})]})},Xc=class extends jt{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=(Pn(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:Ng(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,Sr.jsx)(MI,{inputStyle:n.inputStyle,inputElement:n.inputElement},"caret")}asTag(){return"mark"}};var wC=S(Q());var td=S(O());function yC(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Yc(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function vC(e){return e!=null}var SC=S(Q()),Zc=S(O());var Vg=S(C()),Jc=(0,Zc.forwardRef)(({className:e,children:t,...n},r)=>{let o=(0,Zc.useRef)(null),i=P("TabCompletion",Ct);return(0,Vg.jsx)("div",{ref:Yc([o,r]),className:(0,SC.default)(e,i.popoverContentContainer),...n,children:(0,Vg.jsx)("div",{className:i.popoverContent,children:t})})});var wr=S(C()),DI=e=>t=>{let n=zg(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},FI=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=P("TabCompletion",Ct),s=_i(),a=(0,td.useMemo)(()=>DI(e.getBoundingClientRect()),[e]),[l,u]=Cc(e);return(0,td.useEffect)(()=>{u?s.open():s.close()},[u]),(0,wr.jsxs)("span",{children:[(0,wr.jsx)("mark",{ref:Yc([l,s.triggerRef]),className:(0,wC.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,wr.jsx)(bi,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,wr.jsx)(Jc,{style:n,children:(0,wr.jsx)("div",{className:i.hintText,children:o})})})]})},ed=class extends jt{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${yC(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(vC);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,wr.jsx)(FI,{inputElement:n.inputElement,suggestion:n.suggestion,inputStyle:n.inputStyle,boundaryRef:n.boundaryRef,children:t},`keyword_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var sd=S(Q());var Ve=S(O());var Kg=S(C()),xC=()=>(0,Kg.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,Kg.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 xr=S(O());var _C=S(bg());var nd=S(Q()),Pt=S(O());var EC={root:"_root_vr71j_1"};var to=S(C()),CC=()=>(0,to.jsxs)("svg",{className:EC.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,to.jsx)("defs",{children:(0,to.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,to.jsx)("title",{children:"Failed loading image"}),(0,to.jsx)("path",{className:"cls-1",d:"M15 130.896V16.994c0-1.097.898-1.994 2.007-1.994h150.986A2 2 0 0 1 170 16.994v69.147L133.015 51 87.26 120.377l-35.863-17.758L15 130.896zM2 0C.895 0 0 .887 0 2v166c0 1.105.887 2 2 2h181c1.105 0 2-.887 2-2V2c0-1.105-.887-2-2-2H2zm49 72c11.046 0 20-9.178 20-20.5S62.046 31 51 31s-20 9.178-20 20.5S39.954 72 51 72z",fillRule:"evenodd"})]});var Wg={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};var no=S(C()),rd=(0,Pt.createContext)(Wg),jI=({title:e,src:t})=>{let n=(0,Pt.useContext)(rd),[r,o]=(0,Pt.useState)(!1);return(0,Pt.useEffect)(()=>{o(!1)},[t]),(0,no.jsx)("div",{className:n.imageWrapper,children:t&&!r?(0,no.jsx)("img",{className:n.image,alt:e,src:t,onError:()=>o(!0)}):(0,no.jsx)(CC,{})})},HI=({className:e,lineClamp:t=!1,cropText:n=!1,children:r})=>{let o=(0,Pt.useContext)(rd);return(0,no.jsx)("div",{className:(0,nd.default)(o.content,e,{[o.contentIsCropped]:n,[o.lineClamp]:t}),children:r})},BI=({as:e="h1",cropText:t=!1,className:n,children:r})=>{let o=(0,Pt.useContext)(rd);return Pt.default.createElement(e,{className:(0,nd.default)(o.title,n,{[o.contentIsCropped]:t})},r)},od=({children:e})=>{let t=P("Card",Wg);return(0,no.jsx)("div",{className:(0,nd.default)(t.root),children:(0,no.jsx)(rd.Provider,{value:t,children:e})})};od.Image=jI;od.Content=HI;od.Title=BI;var ge=od;var TC={root:"_root_1muu8_1",content:"_content_1muu8_7"};function id(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 $g(e){return e.replace("https://www.","").replace("https://","")}var Rt=S(C()),UI=3,zI=e=>({image:e.image||"",text:`https://${e.text}`,id:e.id,title:e.title}),VI=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=UI})=>{let i=P("LinkSearch",TC),[s,a]=(0,xr.useState)(""),l=K(),u=A(Ix("url")),c=A(Sx("URL",zI)),[p,d]=(0,xr.useState)(c.length-1),h=D("fallbackImage"),y=f=>{let w=f.target;a(w.value)},v=(f,w)=>{f.stopPropagation(),f.preventDefault(),window.open(w,"_blank")},g=f=>{var T;let w=p-1<0?c.length-1:p-1,x=p+1===c.length?0:p+1;f.code==="Escape"&&(a(""),t()),f.code==="ArrowUp"&&d(w),f.code==="ArrowDown"&&d(x),f.code==="Enter"&&e(((T=c[p])==null?void 0:T.text)||s)},m=(0,xr.useCallback)((0,_C.default)(f=>{l(Xr({query:f,type:"URL",tags:["link-search"]}))},300),[]);return(0,xr.useEffect)(()=>{s&&m(s)},[s]),(0,xr.useEffect)(()=>()=>{l(Ac())},[]),(0,Rt.jsxs)("div",{className:i.root,children:[(0,Rt.jsx)(tn,{withDivider:!0,children:(s?c:u).slice(0,o).map((f,w)=>(0,Rt.jsx)(se,{selected:p===w,onClick:()=>e(f.text),"data-testid":"linksearch-suggestion",children:(0,Rt.jsxs)(ge,{children:[(0,Rt.jsx)(ge.Image,{src:id(f,"small",h||void 0),title:f.title||f.text}),(0,Rt.jsxs)(ge.Content,{className:i.content,cropText:!0,children:[(0,Rt.jsx)(ge.Title,{children:f.title||$g(f.text)}),f.title&&$g(f.text)]}),(0,Rt.jsx)(se.Actions,{children:(0,Rt.jsx)(se.ActionButton,{label:r,onClick:x=>v(x,f.text)})})]})},f.text))}),(0,Rt.jsx)(Sa,{value:s,onChange:y,autoFocus:!0,placeholder:n,onKeyUp:g})]})},bC=VI;var qg={};Te(qg,{enUS:()=>KI,nlNL:()=>WI});var KI={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},WI={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var ze=S(C()),$I=(0,Ve.forwardRef)((e,t)=>{let n=P("TabCompletion",Ct);return(0,ze.jsx)("mark",{ref:t,className:(0,sd.default)(n.matchSelection)},"selection-start")}),qI=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=j(qg),s=P("TabCompletion",Ct),a=(0,Ve.useRef)(null),l=(0,Ve.useRef)(null),[u,c]=(0,Ve.useState)(null),p=K(),d=_i(document.activeElement===r),[h]=(0,Ve.useState)(()=>document.createRange());d.triggerRef.current=h,(0,Ve.useEffect)(()=>()=>h.detach(),[]),(0,Ve.useEffect)(()=>{let v=e.current,g=a.current;!v||!g||(h.setStart(v,0),h.setEnd(g,0))},[e.current,a.current]),li(()=>{d.close()});let y=(0,Ve.useCallback)(v=>{let g=h.toString(),m=/^http(s?):\/\//.test(v)?v:`https://${v}`;p(qu({text:`[${g}](${m})`}))},[]);return(0,ze.jsxs)("span",{children:[(0,ze.jsx)("mark",{ref:a,className:(0,sd.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,ze.jsx)(bi,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,ze.jsxs)(Jc,{style:n,ref:l,children:[(0,ze.jsx)("div",{className:(0,sd.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,ze.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,ze.jsx)(xC,{}),(0,ze.jsx)("span",{children:"\xA0"}),(0,ze.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,ze.jsx)(bC,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:y,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},ad=class extends jt{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(t,n){return this.props=n,this.charCount=0,this.startRef=(0,Ve.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,ze.jsx)($I,{ref:this.startRef}):(0,ze.jsx)(qI,{inputElement:n.inputElement,startRef:this.startRef,boundaryRef:n.boundaryRef,inputStyle:n.inputStyle})}asTag(){return"mark"}};var kC={root:"_root_kpc8q_1",agentText:"_agentText_kpc8q_4",tabText:"_tabText_kpc8q_9",hint:"_hint_kpc8q_10",matchSelection:"_matchSelection_kpc8q_14",focus:"_focus_kpc8q_20",resetIndent:"_resetIndent_kpc8q_24",matchKeyword:"_matchKeyword_kpc8q_28",matchPlaceholder:"_matchPlaceholder_kpc8q_29",hover:"_hover_kpc8q_35",hintText:"_hintText_kpc8q_67",popover:"_popover_kpc8q_75",popoverRoot:"_popoverRoot_kpc8q_80",popoverContentContainer:"_popoverContentContainer_kpc8q_84",popoverContent:"_popoverContent_kpc8q_84",selectionOptions:"_selectionOptions_kpc8q_110",selectionOptionsIsHidden:"_selectionOptionsIsHidden_kpc8q_115",selectionOptionsButton:"_selectionOptionsButton_kpc8q_119",caret:"_caret_kpc8q_135",popoverSuggestionsRoot:"_popoverSuggestionsRoot_kpc8q_139",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_kpc8q_144"};var Er=S(C()),GI=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=P("TabCompletion",kC),c=D("insertLink"),p=D("showMidSentenceSuggestions"),d=D("inlineSuggestions"),h=_c(a),y=(0,In.useRef)(null);(0,In.useEffect)(()=>{Pn(a)&&h&&bc(a,h)},[h]);let v=(0,In.useCallback)(f=>{if(!o||!n)return f;let w=[(0,Er.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,Er.jsx)("span",{className:(0,ld.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&w.push((0,Er.jsx)($c,{className:(0,ld.default)(u.hint,u.resetIndent),keyCode:"tab"},"tabHint")),Hg(f,w)},[o,n,r]),g=(0,In.useMemo)(()=>{let f=[];return d&&f.push(new Xc("inline")),c&&f.push(new ad("selection")),f.push(new si("placeholders")),i&&f.push(new ed("keywords")),f},[d,c,i]),m=(0,In.useMemo)(()=>{let f=window.getComputedStyle(a);return{"--dd-color":f.color,"--dd-font-size":f.fontSize,"--dd-font-family":f.fontFamily,"--dd-font-variant":f.fontVariant}},[]);return e?(0,Er.jsxs)("div",{ref:f=>{f!=null&&f.parentElement&&(y.current=f==null?void 0:f.parentElement)},className:(0,ld.default)(u.root,u.agentText),style:m,children:[(0,Er.jsx)(oi,{tagName:"span",noWrap:!1,containerTagName:"div",disableLineBreaks:Pn(a),content:t||"\u200B",onAfterParse:v,matchers:g,selection:h,keywordMatches:s,inputElement:a,inputStyle:m,boundaryRef:y,inlineSuggestionsOnlyAtEnd:!p}),(0,Er.jsx)("br",{})]}):null},XI=({input:e,ui:t,settings:n,styleSuggestions:r,conversation:o})=>{var v;let{tabCompletionSuggestion:i}=e,s=(i==null?void 0:i.text)||"",a=(i==null?void 0:i.source)||"",l=e.html??xi(e.text),u=s.indexOf(e.text)===0?s.slice(e.text.length):"",{showTabHint:c}=t,{isSupported:p}=o,{showTabCompletion:d,visible:h,showStyleSuggestions:y}=n;return{showTabHint:c,showStyleSuggestions:y,showTabCompletion:d,content:l,tabText:u,source:a,keywordMatches:((v=r.list)==null?void 0:v.keywordMatches)??[],enabled:h&&p!==!1}},PC=Vr(XI)(GI);var TT=S(Q()),_T=S(O());var RC={list:[],fetchState:"idle",isInitialRequest:null},LC=e=>e.autoflows.list||[],IC=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},Ln=N("autoflows/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)}),Gg=N("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(Ln(e.platformSessionId))}),Xg=N("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(Ln(e.platformSessionId))}),QI=F({name:"autoflows",initialState:RC,reducers:{},extraReducers:e=>{e.addCase(Gg.pending,(t,n)=>{let r=IC(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(Xg.pending,(t,n)=>{let r=IC(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(Ln.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}),e.addCase(Ln.rejected,t=>{t.fetchState="error"}),e.addCase(Ln.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(Z,()=>RC)}}),AC=N("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(Ln(e))}),o.on("sessionCompleted",()=>{n(Ln(e))})}),OC=N("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),NC=QI.reducer;var MC={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},DC=e=>e.customMessages.list,FC=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),jC=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),HC=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),Ra=N("customMessages/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)}),ud=N("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)}),cd=N("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)}),BC=F({name:"customMessages",initialState:MC,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(Ra.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(Ra.rejected,t=>{t.fetchState="error"}).addCase(Ra.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(ud.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(ud.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(cd.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(cd.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(Z,()=>MC)}}),UC=N("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(BC.actions.onCustomMessage(i))})}),zC=N("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),VC=BC.reducer;var YI={jwt:null,accountUrl:null,interval:null},KC=e=>t=>{let{exchangeToken:{jwt:n,accountUrl:r}}=t;return n&&r?`${r}/apis/admin/session/jwt/?jwt=${n}&redirect=${e}`:null},Qg=N("exchangeToken/getTemporaryExchangeToken",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=await n.getTemporaryExchangeToken();return{accountUrl:n.client.baseUrl,jwt:r}}),Yg=N("exchangeToken/pollExchangeToken",(e={},t)=>{let{interval:n=1e3*60*30}=e,{dispatch:r}=t;return r(Qg()),setInterval(()=>r(Qg()),n)}),WC=F({name:"exchangeToken",initialState:YI,reducers:{stopPollExchangeToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(Qg.fulfilled,(t,n)=>{t.jwt=n.payload.jwt,t.accountUrl=n.payload.accountUrl}),e.addCase(Yg.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollExchangeToken:$C}=WC.actions,qC=WC.reducer;function GC(e){let{customMessages:t,autoflows:n}=e;return n.fetchState==="loading"&&n.isInitialRequest===!0||t.fetchState==="loading"&&t.isInitialRequest===!0}var rT=S(O());var eT=S(Q()),tT=S(O());var QC=S(Q());var XC={root:"_root_838fd_1"};var ZC=S(C()),ZI=({className:e,children:t})=>{let n=P("Unicode",XC);return(0,ZC.jsx)("span",{className:(0,QC.default)(e,n.root),children:t})},YC=ZI;var JC={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 Zg={};Te(Zg,{enUS:()=>JI,nlNL:()=>eL});var JI={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"}]},eL={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 st=S(C()),nL=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=P("Autoflow",JC),a=j(Zg),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,st.jsxs)(se,{className:(0,eT.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,st.jsx)(ge,{children:(0,st.jsxs)(ge.Content,{children:[(0,st.jsxs)(ge.Title,{children:[t&&(0,st.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,st.jsx)("span",{children:r})]})}),(0,st.jsx)(se.Actions,{fixed:t==="Started",children:(0,st.jsx)(se.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,st.jsxs)(tT.Fragment,{children:[(0,st.jsx)(YC,{children:u})," ",(0,st.jsx)("span",{children:a(l)})]})})})]})},nT=nL;var Jg=S(C()),rL=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},oL=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,Jg.jsx)(rT.Fragment,{children:e.map(o=>(0,Jg.jsx)(nT,{displayName:o.displayName,description:o.description,disabled:o.isBusy||rL(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),iL=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},sL={onStartAutoflow:Gg,onStopAutoflow:Xg},oT=Vr(iL,sL)(oL);var dd=S(O());var nh=S(Q());var eh=S(C()),th=()=>(0,eh.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,eh.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 iT={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 rn=S(C()),aL=({entities:e})=>{let t=P("EntitiesWidgetList",iT),[n,r]=(0,dd.useState)(void 0),o=K(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),xa(a.text),o(Zt({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,dd.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,rn.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,rn.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,rn.jsx)("span",{className:t.entityText,children:a.text}),(0,rn.jsxs)("span",{className:t.iconWrapper,children:[(0,rn.jsx)("span",{className:(0,nh.default)(t.icon),children:(0,rn.jsx)(th,{})}),(0,rn.jsx)("span",{className:(0,nh.default)(t.icon,n===l&&t.iconClicked),children:(0,rn.jsx)(th,{})})]})]},a.text))})},sT=aL;var cT=S(Q()),rh=S(O());var lT=S(Q());var aT={root:"_root_4a08n_1"};var uT=S(C()),lL=({className:e,children:t,...n})=>{let r=P("Label",aT);return(0,uT.jsx)("span",{...n,className:(0,lT.default)(e,r.root),children:t})},fd=lL;var Ia={};Te(Ia,{enUS:()=>uL,nlNL:()=>cL});var uL={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"}]},cL={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 An={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 Ze=S(C()),dL=({suggestion:e})=>{let t=j(Ia),n=K(),r=A(FC(e.text)),o=A(jC(e.text)),i=A(HC(e.text)),s=A(ju),{replyOptions:a}=e,l=(0,rh.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(ud({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,rh.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let p=parseInt(c.target.dataset.index,10),d=a[p];n(cd({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,Ze.jsxs)(se,{onClick:l,className:(0,cT.default)(An.root,{[An.isUsed]:r,[An.hasError]:i}),children:[(0,Ze.jsx)(ge,{children:(0,Ze.jsxs)(ge.Content,{children:[(0,Ze.jsxs)(ge.Title,{className:An.title,children:[e.text," ",(0,Ze.jsx)(fd,{className:An.label,children:"analyse tool"})," ",i&&(0,Ze.jsx)("span",{className:An.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,Ze.jsx)("ul",{className:An.quickReplies,children:a.map(c=>(0,Ze.jsx)("li",{className:An.quickReply,children:c.title},c.title))})]})}),(0,Ze.jsxs)(se.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,Ze.jsx)(se.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,p)=>(0,Ze.jsx)(se.DropdownItem,{index:p,label:c.title,onClick:u},c.title))}),(0,Ze.jsx)(se.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},dT=dL;var oh=S(C()),fT=()=>(0,oh.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,oh.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 pT={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var ki=S(C()),fL=({title:e,children:t,...n})=>{let r=P("Section",pT);return(0,ki.jsxs)("section",{...n,className:r.root,children:[e&&(0,ki.jsx)("div",{className:r.subTitleContainer,children:(0,ki.jsx)("span",{className:r.subtitle,children:e})}),(0,ki.jsx)("div",{className:r.suggestions,children:t})]})},Cr=fL;var gT=S(Q()),hT=S(O());var mT={root:"_root_19wxp_1"};var yT=S(C()),pL=hT.default.forwardRef(({className:e,children:t},n)=>{let r=P("SectionList",mT);return(0,yT.jsx)("div",{ref:n,className:(0,gT.default)(r.root,e),children:t})}),pd=pL;var vT=S(O());var at=S(C()),mL=({suggestion:e,lines:t,onEdit:n,onUse:r})=>{var d;let o=e.text||e.url||e.message,i=Oc(o),s=j(Ia),a=D("showImages"),l=D("fallbackImage"),u=h=>{h.preventDefault(),h.stopPropagation(),r(o)},c=h=>{h.preventDefault(),h.stopPropagation(),n(e)},p=(0,vT.useCallback)(h=>{window.open(i,"_blank"),h.stopPropagation(),h.preventDefault()},[i]);return(0,at.jsxs)(se,{onClick:u,"data-testid":"edit-suggestion",children:[(0,at.jsxs)(ge,{children:[a&&e.image&&(0,at.jsx)(ge.Image,{src:id(e,"small",l||void 0),title:e.title}),(0,at.jsxs)(ge.Content,{children:[e.title&&(0,at.jsx)(ge.Title,{children:e.title}),e.searchKeywords&&((d=e.searchKeywords)==null?void 0:d.length)>0&&(0,at.jsx)(se.Labels,{labels:e.searchKeywords}),(0,at.jsx)(ge.Content,{cropText:t==="single",lineClamp:t==="multiple",children:o})]})]}),(0,at.jsxs)(se.Actions,{children:[i&&(0,at.jsx)(se.ActionButton,{onClick:p,label:s("visitUrl")}),(0,at.jsx)(se.ActionButton,{primary:!0,onClick:c,label:s("preview")}),(0,at.jsx)(se.ActionButton,{primary:!0,onClick:u,label:s("useSuggestion")})]})]})},ST=mL;var La=S(C()),gL=({contentType:e,lines:t,suggestions:n})=>{let r=bt(),o=A(mi),i=a=>{r.send(Sg,{state:o,suggestion:a,contentType:e})},s=(a,l)=>{r.send(Tn,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,La.jsx)(La.Fragment,{children:n.map(a=>(0,La.jsx)(ST,{suggestion:a,lines:t,onEdit:l=>i(l),onUse:l=>s(l,a)},a.text||a.url||a.message))})},wT=gL;var ih={};Te(ih,{enUS:()=>hL,nlNL:()=>yL});var hL={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"}]},yL={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:"Vat gesprek samen"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var xT={root:"_root_oym4o_1",loginText:"_loginText_oym4o_7",stateText:"_stateText_oym4o_8",sectionList:"_sectionList_oym4o_20",links:"_links_oym4o_24",link:"_link_oym4o_24"};var sh=S(C()),ET=()=>(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 ah=S(C()),CT=()=>(0,ah.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ah.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var U=S(C()),md=(e,t)=>{let n=A(Cn);(0,_T.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},vL=()=>{let e=j(ih),t=K(),n=D("isEmbedded"),r=P("Widget",xT),o=D("showAutoflows"),i=D("showCustomMessages"),s=D("showPersonalCollectionLink"),a=D("showSummaryCommand"),l=D("showKnowledgeSearch"),u=D("showSearch"),c=A(Si),p=A(Bc),d=A(LC),h=A(Hc),y=A(DC),v=A(Hu),g=A(Bu),m=A(Cn),f=A(ju),w=A(GC),x=A(mi),T=bt(),E=A(Ax),_=A(KC("/admin/personal-collection")),R=D("adminUrl");return md(()=>(t(Ra(f)),t(UC(f)),()=>{t(zC(f))}),[t,g,i,f]),md(()=>(t(Ln(f)),t(AC(f)),()=>{t(OC(f))}),[t,g,o,f]),md(()=>{p.forEach(({type:b})=>{t(b==="entities"?Ut():xn(b))})},[t,g,v,c]),md(()=>(t(Yg()),()=>{t($C())}),[t,g,s,v]),g===!1?(0,U.jsx)("div",{className:r.stateText,children:(0,U.jsx)("div",{children:(0,U.jsx)("p",{children:e("notSupported")})})},"supported"):m===!1?(0,U.jsx)("div",{className:r.loginText,children:(0,U.jsx)("div",{children:(0,U.jsx)(zc,{isEmbedded:n,loginUrl:R})})},"login"):!c||!f||m===null||E||w?(0,U.jsx)("div",{className:r.stateText,children:(0,U.jsx)("div",{children:(0,U.jsx)("p",{children:e("waiting")})})},"waiting"):(0,U.jsx)("div",{className:(0,TT.default)(r.root),"data-testid":"widget",children:(0,U.jsxs)(pd,{className:r.sectionList,children:[(0,U.jsx)(Cr,{title:e("actions"),children:(0,U.jsxs)("div",{className:r.links,children:[u&&(0,U.jsxs)("button",{className:r.link,onClick:()=>T.send("ShowCommandPalette",{isOpen:!0}),children:[(0,U.jsx)(fi,{}),e("linkSearch")]}),a&&(0,U.jsxs)("button",{className:r.link,onClick:()=>T.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,U.jsx)(CT,{}),e("linkSummary")]}),l&&(0,U.jsxs)("button",{className:r.link,onClick:()=>T.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeSearch"}),children:[(0,U.jsx)(ET,{}),e("linkKnowledgeSearch")]}),_&&(0,U.jsxs)("a",{className:r.link,target:"_blank",href:_,rel:"noreferrer",children:[(0,U.jsx)(fT,{}),e("linkPersonalcollection")]})]})}),i&&y.length>0&&(0,U.jsx)(Cr,{"data-testid":"custom-messages",children:(0,U.jsx)(tn,{withDivider:!0,children:y.map(b=>(0,U.jsx)(dT,{suggestion:b},b.text))})}),o&&d.length>0&&(0,U.jsx)(Cr,{title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,U.jsx)(tn,{withDivider:!0,children:(0,U.jsx)(oT,{})})}),p.map(({type:b,title:B,amount:re,lines:z})=>{var Pe;switch(b){case"entities":return h&&h.length>0&&(0,U.jsx)(Cr,{title:B,"data-testid":`type-${b}`,children:(0,U.jsx)(sT,{entities:h})},b);default:return((Pe=x[b])==null?void 0:Pe.fetchState)==="done"&&x[b].suggestions.length>0&&(0,U.jsx)(Cr,{title:B,"data-testid":`type-${b}`,children:(0,U.jsx)(tn,{withDivider:!0,children:(0,U.jsx)(wT,{lines:z,contentType:b,suggestions:x[b].suggestions.slice(0,re)||[]})})},b)}})]})})},bT=vL;function kT(e){let t=new Range;return t.selectNodeContents(e),t}var Aa=/[\u200B-\u200D\uFEFF]/g;function ro(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(l))return u;for(let d=0;d<=l.length;d++)if(p.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){var u;switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(Aa,""),d=o+p.length,h=t>=o&&t<=d,y=n>=o&&n<=d;if(h){let v=s(c,t-o);v===0&&!y?r.setStartBefore(l):r.setStart(l,v)}y&&(r.setEnd(l,s(c,n-o)),i=!0),o=d;break}case Node.ELEMENT_NODE:{if(l.tagName==="BR"&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let p=0;p<l.childNodes.length&&(a(l.childNodes[p]),!i);p++);let c=(u=l.lastChild)==null?void 0:u.tagName;l.tagName==="DIV"&&c!=="DIV"&&c!=="BR"&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function gd(e,t){if(!e.contains(t.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i}=t,s,a,l=0;function u(c){let p=c===n,d=c===o;switch(c.nodeType){case Node.TEXT_NODE:{let h=c.textContent;p&&(s=l+h.substring(0,r).replace(Aa,"").length),d&&(a=l+h.substring(0,i).replace(Aa,"").length),l+=h.replace(Aa,"").length;break}case Node.ELEMENT_NODE:{let{tagName:h}=c,y=c.nextSibling===null;h==="BR"&&!y&&l++;for(let v=0;v<c.childNodes.length&&(p&&v===r&&(s=l),u(c.childNodes[v]),d&&v===i-1&&(a=l),a===void 0);v++);!d&&h==="DIV"&&!y&&l++,d&&(a=l);break}default:break}}if(u(e),a===void 0)throw new Error("Could not determine start and end");return{start:s??a,end:a}}function Oa(e,t){if(!e.contains(t.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i}=t,s=-1,a="";function l(u){let c=u===n,p=u===o;switch(c&&s++,u.nodeType){case Node.TEXT_NODE:{if(s!==0)return;let d=c?r:0,h=p?i:void 0,y=u.textContent.replace(Aa,"");d===0&&h===void 0?a+=y:a+=y.substring(d,h);break}case Node.ELEMENT_NODE:{let{tagName:d}=u,h=u.nextSibling===null;s===0&&d==="BR"&&!h&&(a+=`
|
|
20
20
|
`);for(let y=c?r:0;y<(p?Math.min(i,u.childNodes.length):u.childNodes.length)&&(l(u.childNodes[y]),s!==1);y++);!p&&s===0&&d==="DIV"&&!h&&(a+=`
|
|
21
|
-
`);break}default:break}p&&s++}return l(e),a}var oo=class extends vn{observer;getText(){let t=new Range;return t.selectNodeContents(this.element),Oa(this.element,t)}getHTML(){return this.element.innerHTML||""}getSelection(){if(document.activeElement!==this.element)return null;let t=window.getSelection();if(!t||t.rangeCount===0)return null;let n=t.getRangeAt(0);return!n||!this.element.contains(n.commonAncestorContainer)?null:gd(this.element,n)}getSelectedText(){if(!this.currentSelection)return"";let{start:t,end:n}=this.currentSelection;return Oa(this.element,ro(this.element,t,n))}applyChanges(t){var o;if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);(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 lh=class{constructor(t){this.name=t;H.warn("BroadcastChannel is not supported")}postMessage(){}addEventListener(){}removeEventListener(){}close(){}},uh=class{constructor(t,n){this.name=t;this.options=n;this.broadcastChannel=new this.options.broadcastChannelConstructor(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()}},ch=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()}},dh=class{sessionId;deepdeskUrl;channel;broadcastChannelConstructor;eventMap;isIntegration;constructor(t){this.deepdeskUrl=t.deepdeskUrl,this.broadcastChannelConstructor=t.broadcastChannelConstructor||window.BroadcastChannel||lh,this.isIntegration=t.deepdeskUrl!==(t.origin||window.location.origin),this.eventMap=t.eventMap,this.setSessionId("deepdesk-general")}setSessionId(t){if(this.sessionId===t)return;this.cleanup(),H.info("Set sessionId",t),this.sessionId=t,this.channel=this.isIntegration?new ch(t,this.deepdeskUrl,{debug:!0}):new uh(t,{broadcastChannelConstructor:this.broadcastChannelConstructor});let n=r=>{var o,i;r.origin===this.deepdeskUrl&&r.data.type==="event"&&(H.info("Received broadcast event",this.sessionId,r),(i=(o=this.eventMap)[r.data.name])==null||i.call(o,r.data.payload))};this.channel.onMessage(n)}send(t,n){var o,i,s;if(!this.sessionId)return;H.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)}cleanup(){var t;(t=this.channel)==null||t.close(),delete this.channel}},PT=dh;var Pi=class extends Error{constructor(n,r){super(n);this.body=r}name="CustomError"};var fh=e=>new Promise(t=>{setTimeout(t,e)});var Ri=class extends Pi{name="ClientError"},ph=class extends Pi{name="ServerError"},On=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}async request(t,n={}){let r={isStale:!1},o=`${this.baseUrl}${t}`,i=this.fetch,{abortLatest:s=!1,attempts:a=1,retryDelay:l=500,refreshTokenOn401:u=!0,retryOnError:c=x=>x instanceof TypeError,retryOnResponse:p=x=>x.status>=500,version:d="v1",...h}=n,y={credentials:"include",...h,headers:{"Content-Type":"application/json",...h.headers}};n.method!==void 0&&n.method!=="GET"&&this.csrfToken&&(y.headers={...y.headers,"X-CSRFToken":this.csrfToken}),typeof d=="string"&&(y.headers={...y.headers,"X-Deepdesk-API-Version":d});let v=a,g=!1;if(!i)throw new Error("fetch is not set");this.latestRequestByUrl[o]&&s&&(this.latestRequestByUrl[o].isStale=!0),this.latestRequestByUrl[o]=r;let m=async()=>(v--,i(o,y).then(async x=>p(x)&&!r.isStale&&v>0?(await fh(l),m()):x.status===401&&u===!0&&g===!1?(g=!0,await this.refreshToken(),m()):x).catch(async x=>{if(c(x)&&!r.isStale&&v>0)return await fh(l),m();throw x})),f=await m(),w=await f.json().catch(()=>null);if(r.isStale)throw new Error("Aborted");if(f.status>=500)throw new ph("Server Error",w);if(f.status===401)throw new Ri("Unauthorized",w);if(f.status===403)throw new Ri("Forbidden",w);if(f.status===404)throw new Ri("Not Found",w);if(f.status>=400)throw new Ri("Bad Request",w);return delete this.latestRequestByUrl[o],w}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 SL;(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||={})})(SL||={});function hd(e){return{...ne(e),tags:e.tags}}var Nn=class e{constructor(t,n={}){this.options=n;this.client=new On(t,{fetch:n.fetch}),this.client.patchFetch(r=>async(o,i)=>{let s=await r(o,i);return this.handleDeepdeskVersionHeaders(s),s})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=await this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(e.exchangeTokenPromise||(e.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),e.exchangeTokenPromise):Promise.resolve()}async createConversation(t){await this.preflight(),H.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=await this.client.post("/api/conversations",{...Ee(t),tags:t.tags},{version:"v2"});return hd(n)}async getProfile(t){let n=await this.client.get(`/apis/admin/profiles/${t}/`,{version:null});return ne(n)}async getContentTypes(){let t=await this.client.get("/apis/admin/content-types/",{version:null});return ne(t)}async getPlatformConfig(){let{config:t}=await this.client.get("/platform/config/",{version:null});return ne(t)}async checkUserExists(t){let{exists:n}=await this.client.get(`/apis/admin/users/exists?external_id=${t}`);return n}async getConversationBySessionId(t,n={}){await this.preflight(),H.info(`Getting conversation for session ${t}`);let{attempts:r=1,retryDelay:o=1e3}=n,i=await this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"});return hd(i)}async isConversationSupported(t,n={}){H.info(`Check if conversation for session ${t} is supported`);let{attempts:r=1,retryDelay:o=1e3}=n;return(await this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"})).has_active_profile}async updateConversation(t,n){let r=Ee(n);n.tags&&(r.tags=n.tags);let o=await this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return hd(o)}async postMessages(t,n){return(await this.client.post(`/api/conversations/${t}/messages`,n.map(o=>({...Ee(o),tags:o.tags})),{version:"v2"})).map(o=>hd(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",Ee({...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:Ee({...n,...r})})}async getEntities(t){return(await this.client.post("/api/entities",{messages:t.filter(r=>r.text)})).entities}async getSummary(t){return(await this.client.post("/api/summary",{conversation:{messages:t.filter(r=>r.text&&r.source)}})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(t){return this.client.get(`/apis/admin/session/jwt/?jwt=${t}`,{version:null}).catch(n=>{throw H.warn(`Invalid token '${t}'`),n})}async authenticateWithKey(t,n){await this.client.post("/apis/admin/session/api-key/",Ee(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}`,Ee(n),{abortLatest:!0})).map(i=>({...ne(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`,Ee(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 ne(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",Ee(t),{abortLatest:!0});return ne(n)}async search(t){let n=await this.client.post(`/api/profiles/${t.profile}/search`,Ee(t),{version:"v2"});return ne(n)}async knowledgeSearch(t,n,r){let o=await this.client.post("/api/knowledge-search/search",Ee({question:t.question,promptInstruction:t.promptInstruction,profile:r,chatHistory:n.map(i=>({question:i.question,answer:i.answer.answer}))}),{version:"v2"});return ne(o)}async requestLoginByEmail(t){let n=await this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return ne(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 ne(n)}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Sh);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&H.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};var Na=class{constructor(t,n){this.url=t;this.options={timeout:25e3,...n}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(t){this.eventSource.addEventListener(fg(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,ne(o))}catch{H.warn(`Invalid JSON for ${t}: ${r}`)}})}connect(){clearTimeout(this.timeoutTimer);let t=new EventSource(this.url,{withCredentials:!0});this.eventSource=t;let n=!1;t.onopen=()=>{n=!0},t.onerror=()=>{n&&t.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{t.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(r=>{this.proxyEvent(r)})}disconnect(){var t;clearTimeout(this.timeoutTimer),this.eventListeners={},(t=this.eventSource)==null||t.close()}emit(t,n){this.eventListeners[t]&&this.eventListeners[t].forEach(r=>r(n))}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),this.proxyEvent(t),()=>{this.off(t,n)}}off(t,n){let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}};var wL;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||={})})(wL||={});var Ma=class{constructor(t,n={}){this.apiUrl=t;this.client=new On(t,n)}client;streams={};logger=H;async getCustomMessages(t){let n=await this.client.get(`/sessions/${t}/suggestions`);return ne(n.suggestions)}async sendCustomMessage(t,n){let r=await this.client.post(`/sessions/${t}/messages`,Ee(n));return ne(r)}async answerCustomMessage(t,n){await this.client.post(`/sessions/${t}/answers`,Ee(n))}async getAutoflows(t){let n=await this.client.get(`/sessions/${t}/autoflows`);return ne(n.autoflows)}async startAutoflowSession(t){let n=await this.client.post("/autoflow-sessions",Ee(t));return ne(n)}async stopAutoflowSession(t){await this.client.delete(`/autoflow-sessions/${t}`)}openStream(t){return this.streams[t]||(this.streams[t]=new Na(`${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 RT={startTime:null,stopTime:null},IT=F({name:"handlingTime",initialState:RT,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(Z,()=>RT)}}),{handlingTimeStart:LT,handlingTimeStop:yd,handlingTimeReset:AT}=IT.actions,OT=IT.reducer;var NT=(e={})=>{let t={onAuthError:Fc(!1),...e};return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var mh={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var io=N("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 mh.list;if(!i)throw new Error("No current conversation to fetch pinned messages");return n.getStyleSuggestions({profileCode:i,message:e})}),xL=F({name:"styleSuggestions",initialState:mh,reducers:{},extraReducers:e=>{e.addCase(io.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(io.rejected,t=>{t.fetchState="error"}).addCase(io.fulfilled,(t,n)=>{t.fetchState="done",cr(t.list,n.payload)||(t.list=n.payload)}).addCase(Z,()=>mh)}}),MT=xL.reducer;var DT=(e={})=>{let t,n=!0,r={getStyleSuggestions:io,debounce:500,...e};return o=>i=>s=>{var h;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(!((h=u.conversation.current)==null?void 0:h.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 EL(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var FT=(e={})=>{let t={getTextSuggestions:xn,getAutocompleteSuggestions:ma,debounce:200,check:Uc,...e},n,r=!0;return o=>i=>s=>{var g;let{input:{userCommitted:a}}=o.getState(),l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{recommendTextSuggestions:c,showTabCompletion:p}=u.settings,d=(g=u.conversation.current)==null?void 0:g.id,h=s.type===Dc.toString();if(!d||!c&&!p)return l;let{input:{userCommitted:y}}=u;return EL(y,a)&&!r&&!h||(clearTimeout(n),!t.check(u))||(n=setTimeout(()=>{r=!1;let m=Jo(u);m===""?o.dispatch(t.getTextSuggestions("default")):o.dispatch(t.getAutocompleteSuggestions(m))},h?0:t.debounce)),l}};var jT=io.fulfilled.toString();function CL(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 HT=e=>t=>n=>r=>{var c;if(r.type!==jT){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(c=i.conversation)==null?void 0:c.current,{agentInfo:l}=i.info;if(o===s)return;let u=CL(o,s);r.type===jT&&u.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,agentId:l.agentId??(a==null?void 0:a.agentId),agentName:l.agentName??(a==null?void 0:a.agentName),agentEmail:l.agentEmail??(a==null?void 0:a.agentEmail),data:{keywordMatches:u}})};var TL=lu({activeSuggestion:zx,answer:OE,auth:nE,autoflows:NC,conversation:s0,contentTypes:yE,customMessages:VC,exchangeToken:qC,entities:xE,handlingTime:OT,info:gx,input:Im.reducer,overlayInput:Ge.reducer,settings:Yw,profile:DE,search:xx,summary:kE,styleSuggestions:MT,ui:qx,textSuggestions:Fx});function BT(e){return rw({reducer:TL,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),NT(),FT({debounce:200}),DT({debounce:500}),HT(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var _L=e=>{var t;return((t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())??"unknown"},bL=e=>t=>n=>r=>{var a;let o=t.getState(),i=Tm("inlineSuggestions")(o);switch(r.type){case En.toString():{let l=Lx(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 Mt.toString():{let{start:l,end:u}=o.input.selection;e.emit("select-suggestion",{type:_L(r.payload.suggestion),...r.payload,replace:r.payload.replace==="selection"?{start:l,end:u}:{start:0,end:u}},{mayApplyChanges:!0});break}case qu.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 Ws.toString():{let l=t.getState(),{text:u,selection:c}=l.input.userCommitted;e.emit("reset",{text:u,selectionAfter:c},{mayApplyChanges:!0});break}case Yu.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 Ut.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:o.conversation.current.id,data:{entities:r.payload}});break;case _n.fulfilled.toString():e.sendEvent("conversation summarized",{conversationId:o.conversation.current.id,data:{inputText:JSON.stringify(r.payload.original),summary:r.payload.summary}});break;case Zt.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 Gu.toString():e.handleKeyDown(r.payload);break;case Ks.toString():e.logSendMessage(r.payload);break;case Xu.toString():e.logSendEditSuggestionMessage(r.payload);break;case Qu.toString():e.handleInputChanged(r.payload);break;default:break}let s=n(r);switch(r.type){case Ks.toString():e.handleAfterSendMessage(r.payload);break;case ga.toString():e.onUpdateShowTabHint(r.payload);break;case yd.toString():e.logHandlingTime();break;case Mt.toString():{i&&(t.dispatch(fr([])),t.dispatch(pr()));break}default:break}return s},UT=bL;function gh(e){return e.toISOString().replace("T"," ").replace("Z","")}function zT(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:gh(n),timeStop:gh(r)}}function hh(e,t,n){var T,E,_;let{text:r,metrics:{numCharsTyped:o,numCharsPasted:i,numCharsCut:s,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:u,pastes:c,cuts:p,deletions:d,textSuggestions:h,offeredTextSuggestions:y}}=t[e],v=r.length,m=h.reduce((R,{text:b,searchTerm:B})=>R+b.length-(B?B.length:0),0),f=u??Date.now(),w=(Date.now()-f)/1e3,x=o/w;return{conversationId:t.conversation.current.id,source:"agent",text:r,clientVersion:n.version,pastes:c,cuts:p,deletions:d,lenTextTyped:o,lenTextTotal:v,lenTextAssisted:m,lenTextPasted:i,lenTextCut:s,lenTextDeleted:a,timeTotalSeconds:w,charsPerSecond:x,numPastes:l,textSuggestionsV2:h,suggestionsCounters:[{source:"gpt",countOffered:y.filter(R=>R.source==="gpt").length}],agentId:(T=t.info.agentInfo)==null?void 0:T.agentId,agentName:(E=t.info.agentInfo)==null?void 0:E.agentName,agentEmail:(_=t.info.agentInfo)==null?void 0:_.agentEmail}}function VT(e,t){let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;return r instanceof HTMLElement?VT(r,t):null}function KT(e,t){return VT(e,t)}function WT(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function vd(e){return e instanceof HTMLElement&&(Pn(e)||Tc(e))}var $T=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch{return t}}catch{return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch{H.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function kL(e){return e.offsetParent!==null}function qT(e){if(!kL(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 Sd(e,t,n=100){let r=qT(e);t({isVisible:r});let o=setInterval(()=>{let i=qT(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var lt=S(C()),GT=$T("showTabHint",!0),Da=class e{static version="10.1.0";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:t,brokerUrl:n,version:r=e.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a}){let l=t.replace(/\/api$/,"");this.deepdeskApi=new Nn(l,{token:i,fetch:s}),this.version=r,this.instanceId=e.count++;let u={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[UT({emit:(c,p,d)=>this.emit(c,p,d),handleAfterSendMessage:c=>this.handleAfterSendMessage(c),handleInputChanged:c=>this.handleInputChanged(c),handleKeyDown:c=>this.handleKeyDown(c),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:c=>this.logSendMessage(c),logSendEditSuggestionMessage:c=>this.logSendEditMessage(c),onUpdateShowTabHint:c=>GT.update(c),sendEvent:(c,p)=>this.deepdeskApi.sendEvent(c,p)})]};n&&Object.assign(u,{deepdeskBrokerAPI:new Ma(n)}),this.store=BT(u),this.broadcastEvents=new PT({debug:!0,deepdeskUrl:l,eventMap:rE(this.store)}),this.store.dispatch(zs),this.store.dispatch(ga(GT.value())),this.store.dispatch(zs({locale:o,adminUrl:l,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(H.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(H.warn("Profile has not been loaded (yet)"),!0):(H.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Fc(null)),this.store.dispatch(Yr()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();Cn(r)&&Qx(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){H.warn("Failed to attach user:",n)}}async isConversationSupported(t,n){return(await this.store.dispatch(Pm({sessionId:t,options:n}))).payload}async createConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(Uu(t))).payload}async getConversationBySessionId(t,n){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(await this.store.dispatch(zu({sessionId:t,options:n}))).payload}async upsertConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(Rm(t))).payload}async postMessages(t){return(await this.store.dispatch(Ku(t))).payload}async updateConversation(t){return(await this.store.dispatch(Vu(t))).payload}resetConversation(){this.store.dispatch(Z()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let t=await this.store.dispatch(_n());if(t.error)throw new Error(t.error.message);return t.payload.summary}configure(t){this.store.dispatch(zs(t))}setVisitorInfo(t){this.store.dispatch(mx(t))}async setAgentInfo(t){await this.store.dispatch(ca(t))}async setAgentSettings(t){await this.store.dispatch(pg(t))}async getAgentSettings(){return(await this.store.dispatch(mg())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();let t=[];return this.store.dispatch(Dc()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})}notifyInputChanged(t){this.store.dispatch(Qu(t))}syncInputHtml(t){this.store.dispatch(S0(t))}notifyKeyDown(t){this.store.dispatch(Gu(t))}notifyPaste(t,n){this.store.dispatch(y0({text:t,selectionText:n}))}notifyCut(t){this.store.dispatch(g0(t))}notifyExternalSuggestion(t){this.store.dispatch(Mt(t)),this.store.dispatch(pr())}notifyEditSuggestion(t){this.store.dispatch(Mx(t.contentType,t.suggestions)),this.store.dispatch(En({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(hi({collapse:!1})),this.inputMediator&&this.store.dispatch(u0({text:t,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(fr([])))}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(h0($u(t))),!(t.key!=="Tab"&&!this.settings.showTextSuggestions))switch(t.key){case"Up":case"ArrowUp":if(n||!a||!i||t.shiftKey)return;this.store.dispatch(f0()),s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault();return;case"Down":case"ArrowDown":{if(n||!a||!i||t.shiftKey)return;this.store.dispatch(m0());let{selectedSuggestionIndex:u}=this.state.input;u===-1?this.store.dispatch(Ws()):s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault();return}case"Esc":case"Escape":{l?(this.store.dispatch(Zu(-1)),this.store.dispatch(Ws()),t.preventDefault()):n||(this.store.dispatch(hi({collapse:!0})),this.store.dispatch(Wx(!0)),t.preventDefault());return}case"Tab":{let{userCommitted:u}=this.state.input,c=u.text.substring(0,u.selection.end),{tabCompletionSuggestion:p}=this.state.input;this.store.dispatch(ga(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):this.settings.showTabCompletion&&p&&p.text.startsWith(c)&&(this.store.dispatch(Mt({text:p.text,suggestion:p,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(pr())),t.preventDefault();break}default:}}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(v0()),this.store.dispatch(fr([]))}handlingTimeStart(){this.state.handlingTime.startTime||(H.info("Start handling time"),this.store.dispatch(LT()))}handlingTimeStop(){this.state.handlingTime.startTime&&(H.info("Stop handling time"),this.store.dispatch(yd()))}logSendMessage(t){let n=hh("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=hh("overlayInput",this.state,{version:"v2"});t&&Object.assign(n,{text:t}),this.store.dispatch(d0(this.state.overlayInput.metrics)),this.deepdeskApi.sendEvent("suggestion edited",{data:n})}logHandlingTime(){let t=zT(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(AT())}notifySubmit(t={}){this.shouldAbort()||(this.store.dispatch(pr()),this.store.dispatch(Ks(t.text??this.state.input.text)))}stageSelectedSuggestion(t){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:r}=this.state.input;this.store.dispatch(Mt({text:r[n].text,suggestion:r[n],eventMetrics:t,replace:"until-selection-end"}))}emit(t,n,r={}){let o=()=>{this.eventListeners[t]&&this.eventListeners[t].forEach(i=>{try{i(n)}catch(s){H.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),H.error(s)}})};this.inputMediator&&r.mayApplyChanges?this.inputMediator.applyChanges(o):o()}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=ci(r,o);return i.dataset.testid=t,n!=null&&n.rootNode&&i.classList.add(n.rootNode),this.unmountHandlers.push(()=>{(0,Mn.unmountComponentAtNode)(i),s(),i.remove()}),i}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return Gr(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,n.appendChild(o),this.unmountHandlers.push(()=>{(0,Mn.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(!vd(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:p,detectSubmit:d,insertLink:h,inputMediator:y,closestScrollSelector:v,appendOverlayTo:g,inlineSuggestions:m}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:h,isEmbedded:p,inlineSuggestions:m});let f=v&&KT(t,v)||void 0,w=this.overlayContainerFactory("deepdesk-tab-completion",r,t,{appendTo:g,closestScrollElement:f,mirrorOverflow:!0,onRemove:()=>this.unmount()}),x=this.overlayContainerFactory("deepdesk-suggestions-overlay",r,f||t,{appendTo:g});n.automaticHandlingTime&&this.setupHandlingTime(t),(0,Mn.render)((0,lt.jsx)(ka,{store:this.store,customStyles:r,children:(0,lt.jsx)(ya,{broadcastEvents:this.broadcastEvents,children:(0,lt.jsx)(PC,{inputElement:t})})}),w),(0,Mn.render)((0,lt.jsx)(ka,{store:this.store,customStyles:r,children:(0,lt.jsx)(ya,{broadcastEvents:this.broadcastEvents,children:(0,lt.jsx)(Wc,{})})}),x),(0,Mn.render)((0,lt.jsx)(ka,{store:this.store,customStyles:r,children:(0,lt.jsx)(ya,{broadcastEvents:this.broadcastEvents,children:(0,lt.jsx)(UE,{})})}),this.createContainer("deepdesk-overlays")),Gr(t),this.inputMediator=y||(Pn(t)?new Sn(t):new oo(t)),this.inputMediator.on("change",({plainText:E})=>{this.notifyInputChanged(E)}),this.inputMediator.on("updated",({rawHtml:E})=>{E!=null&&this.syncInputHtml(E)}),this.inputMediator.on("keydown",E=>{this.notifyKeyDown(E)}),this.inputMediator.on("paste",({pastedText:E,selectionText:_})=>{this.notifyPaste(E,_)}),this.inputMediator.on("cut",({selectionText:E})=>{this.notifyCut(E)});let T;this.inputMediator.on("selection",E=>{clearTimeout(T),E===null?T=setTimeout(()=>{E!==null&&this.store.dispatch(Lm(E))},500):this.store.dispatch(Lm(E))}),this.inputMediator.on("disabled",()=>{var E;(E=this.inputMediator)==null||E.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(gi(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(gi(!0))),this.store.dispatch(c0({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var E;this.broadcastEvents.setSessionId((E=this.state.conversation.current)==null?void 0:E.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&H.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,showPersonalCollectionLink:i,isEmbedded:s}=n;this.widgetRoot=t,this.configure({showImages:o,showPersonalCollectionLink:i,isEmbedded:s}),(0,Mn.render)((0,lt.jsx)(ka,{store:this.store,customStyles:r,children:(0,lt.jsx)(ya,{broadcastEvents:this.broadcastEvents,children:(0,lt.jsx)(bT,{})})}),t),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Mn.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Sd(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){WT(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(_a());let t=Si(this.state);t&&this.store.dispatch(zs({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:t.knowledgeSearch,recommendTextSuggestions:t.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(t){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(H.info("Trial is active"),!await this.deepdeskApi.checkUserExists(t))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;H.info(r),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Bc(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(Ut()):this.store.dispatch(xn(r))})}catch(r){this.handleError(r)}}};async function XT(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 QT(e,t,n={}){let r=n.replace?ro(e,n.replace.start,n.replace.end):kT(e),o,i=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),o=document.createElement("span"),r.insertNode(o),t.split(`
|
|
21
|
+
`);break}default:break}p&&s++}return l(e),a}var oo=class extends vn{observer;getText(){let t=new Range;return t.selectNodeContents(this.element),Oa(this.element,t)}getHTML(){return this.element.innerHTML||""}getSelection(){if(document.activeElement!==this.element)return null;let t=window.getSelection();if(!t||t.rangeCount===0)return null;let n=t.getRangeAt(0);return!n||!this.element.contains(n.commonAncestorContainer)?null:gd(this.element,n)}getSelectedText(){if(!this.currentSelection)return"";let{start:t,end:n}=this.currentSelection;return Oa(this.element,ro(this.element,t,n))}applyChanges(t){var o;if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);(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 lh=class{constructor(t){this.name=t;H.warn("BroadcastChannel is not supported")}postMessage(){}addEventListener(){}removeEventListener(){}close(){}},uh=class{constructor(t,n){this.name=t;this.options=n;this.broadcastChannel=new this.options.broadcastChannelConstructor(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()}},ch=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()}},dh=class{sessionId;deepdeskUrl;channel;broadcastChannelConstructor;eventMap;isIntegration;constructor(t){this.deepdeskUrl=t.deepdeskUrl,this.broadcastChannelConstructor=t.broadcastChannelConstructor||window.BroadcastChannel||lh,this.isIntegration=t.deepdeskUrl!==(t.origin||window.location.origin),this.eventMap=t.eventMap,this.setSessionId("deepdesk-general")}setSessionId(t){if(this.sessionId===t)return;this.cleanup(),H.info("Set sessionId",t),this.sessionId=t,this.channel=this.isIntegration?new ch(t,this.deepdeskUrl,{debug:!0}):new uh(t,{broadcastChannelConstructor:this.broadcastChannelConstructor});let n=r=>{var o,i;r.origin===this.deepdeskUrl&&r.data.type==="event"&&(H.info("Received broadcast event",this.sessionId,r),(i=(o=this.eventMap)[r.data.name])==null||i.call(o,r.data.payload))};this.channel.onMessage(n)}send(t,n){var o,i,s;if(!this.sessionId)return;H.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)}cleanup(){var t;(t=this.channel)==null||t.close(),delete this.channel}},PT=dh;var Pi=class extends Error{constructor(n,r){super(n);this.body=r}name="CustomError"};var fh=e=>new Promise(t=>{setTimeout(t,e)});var Ri=class extends Pi{name="ClientError"},ph=class extends Pi{name="ServerError"},On=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}async request(t,n={}){let r={isStale:!1},o=`${this.baseUrl}${t}`,i=this.fetch,{abortLatest:s=!1,attempts:a=1,retryDelay:l=500,refreshTokenOn401:u=!0,retryOnError:c=x=>x instanceof TypeError,retryOnResponse:p=x=>x.status>=500,version:d="v1",...h}=n,y={credentials:"include",...h,headers:{"Content-Type":"application/json",...h.headers}};n.method!==void 0&&n.method!=="GET"&&this.csrfToken&&(y.headers={...y.headers,"X-CSRFToken":this.csrfToken}),typeof d=="string"&&(y.headers={...y.headers,"X-Deepdesk-API-Version":d});let v=a,g=!1;if(!i)throw new Error("fetch is not set");this.latestRequestByUrl[o]&&s&&(this.latestRequestByUrl[o].isStale=!0),this.latestRequestByUrl[o]=r;let m=async()=>(v--,i(o,y).then(async x=>p(x)&&!r.isStale&&v>0?(await fh(l),m()):x.status===401&&u===!0&&g===!1?(g=!0,await this.refreshToken(),m()):x).catch(async x=>{if(c(x)&&!r.isStale&&v>0)return await fh(l),m();throw x})),f=await m(),w=await f.json().catch(()=>null);if(r.isStale)throw new Error("Aborted");if(f.status>=500)throw new ph("Server Error",w);if(f.status===401)throw new Ri("Unauthorized",w);if(f.status===403)throw new Ri("Forbidden",w);if(f.status===404)throw new Ri("Not Found",w);if(f.status>=400)throw new Ri("Bad Request",w);return delete this.latestRequestByUrl[o],w}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 SL;(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||={})})(SL||={});function hd(e){return{...ne(e),tags:e.tags}}var Nn=class e{constructor(t,n={}){this.options=n;this.client=new On(t,{fetch:n.fetch}),this.client.patchFetch(r=>async(o,i)=>{let s=await r(o,i);return this.handleDeepdeskVersionHeaders(s),s})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=await this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(e.exchangeTokenPromise||(e.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),e.exchangeTokenPromise):Promise.resolve()}async createConversation(t){await this.preflight(),H.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=await this.client.post("/api/conversations",{...Ee(t),tags:t.tags},{version:"v2"});return hd(n)}async getProfile(t){let n=await this.client.get(`/apis/admin/profiles/${t}/`,{version:null});return ne(n)}async getContentTypes(){let t=await this.client.get("/apis/admin/content-types/",{version:null});return ne(t)}async getPlatformConfig(){let{config:t}=await this.client.get("/platform/config/",{version:null});return ne(t)}async checkUserExists(t){let{exists:n}=await this.client.get(`/apis/admin/users/exists?external_id=${t}`);return n}async getConversationBySessionId(t,n={}){await this.preflight(),H.info(`Getting conversation for session ${t}`);let{attempts:r=1,retryDelay:o=1e3}=n,i=await this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"});return hd(i)}async isConversationSupported(t,n={}){H.info(`Check if conversation for session ${t} is supported`);let{attempts:r=1,retryDelay:o=1e3}=n;return(await this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"})).has_active_profile}async updateConversation(t,n){let r=Ee(n);n.tags&&(r.tags=n.tags);let o=await this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return hd(o)}async postMessages(t,n){return(await this.client.post(`/api/conversations/${t}/messages`,n.map(o=>({...Ee(o),tags:o.tags})),{version:"v2"})).map(o=>hd(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",Ee({...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:Ee({...n,...r})})}async getEntities(t){return(await this.client.post("/api/entities",{messages:t.filter(r=>r.text)})).entities}async getSummary(t){return(await this.client.post("/api/summary",{conversation:{messages:t.filter(r=>r.text&&r.source)}})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(t){return this.client.get(`/apis/admin/session/jwt/?jwt=${t}`,{version:null}).catch(n=>{throw H.warn(`Invalid token '${t}'`),n})}async authenticateWithKey(t,n){await this.client.post("/apis/admin/session/api-key/",Ee(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}`,Ee(n),{abortLatest:!0})).map(i=>({...ne(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`,Ee(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 ne(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",Ee(t),{abortLatest:!0});return ne(n)}async search(t){let n=await this.client.post(`/api/profiles/${t.profile}/search`,Ee(t),{version:"v2"});return ne(n)}async knowledgeSearch(t,n,r){let o=await this.client.post("/api/knowledge-search/search",Ee({question:t.question,promptInstruction:t.promptInstruction,profile:r,chatHistory:n.map(i=>({question:i.question,answer:i.answer.answer}))}),{version:"v2"});return ne(o)}async requestLoginByEmail(t){let n=await this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return ne(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 ne(n)}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Sh);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&H.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};var Na=class{constructor(t,n){this.url=t;this.options={timeout:25e3,...n}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(t){this.eventSource.addEventListener(fg(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,ne(o))}catch{H.warn(`Invalid JSON for ${t}: ${r}`)}})}connect(){clearTimeout(this.timeoutTimer);let t=new EventSource(this.url,{withCredentials:!0});this.eventSource=t;let n=!1;t.onopen=()=>{n=!0},t.onerror=()=>{n&&t.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{t.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(r=>{this.proxyEvent(r)})}disconnect(){var t;clearTimeout(this.timeoutTimer),this.eventListeners={},(t=this.eventSource)==null||t.close()}emit(t,n){this.eventListeners[t]&&this.eventListeners[t].forEach(r=>r(n))}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),this.proxyEvent(t),()=>{this.off(t,n)}}off(t,n){let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}};var wL;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||={})})(wL||={});var Ma=class{constructor(t,n={}){this.apiUrl=t;this.client=new On(t,n)}client;streams={};logger=H;async getCustomMessages(t){let n=await this.client.get(`/sessions/${t}/suggestions`);return ne(n.suggestions)}async sendCustomMessage(t,n){let r=await this.client.post(`/sessions/${t}/messages`,Ee(n));return ne(r)}async answerCustomMessage(t,n){await this.client.post(`/sessions/${t}/answers`,Ee(n))}async getAutoflows(t){let n=await this.client.get(`/sessions/${t}/autoflows`);return ne(n.autoflows)}async startAutoflowSession(t){let n=await this.client.post("/autoflow-sessions",Ee(t));return ne(n)}async stopAutoflowSession(t){await this.client.delete(`/autoflow-sessions/${t}`)}openStream(t){return this.streams[t]||(this.streams[t]=new Na(`${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 RT={startTime:null,stopTime:null},IT=F({name:"handlingTime",initialState:RT,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(Z,()=>RT)}}),{handlingTimeStart:LT,handlingTimeStop:yd,handlingTimeReset:AT}=IT.actions,OT=IT.reducer;var NT=(e={})=>{let t={onAuthError:Fc(!1),...e};return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var mh={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var io=N("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 mh.list;if(!i)throw new Error("No current conversation to fetch pinned messages");return n.getStyleSuggestions({profileCode:i,message:e})}),xL=F({name:"styleSuggestions",initialState:mh,reducers:{},extraReducers:e=>{e.addCase(io.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(io.rejected,t=>{t.fetchState="error"}).addCase(io.fulfilled,(t,n)=>{t.fetchState="done",cr(t.list,n.payload)||(t.list=n.payload)}).addCase(Z,()=>mh)}}),MT=xL.reducer;var DT=(e={})=>{let t,n=!0,r={getStyleSuggestions:io,debounce:500,...e};return o=>i=>s=>{var h;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(!((h=u.conversation.current)==null?void 0:h.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 EL(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var FT=(e={})=>{let t={getTextSuggestions:xn,getAutocompleteSuggestions:ma,debounce:200,check:Uc,...e},n,r=!0;return o=>i=>s=>{var g;let{input:{userCommitted:a}}=o.getState(),l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{recommendTextSuggestions:c,showTabCompletion:p}=u.settings,d=(g=u.conversation.current)==null?void 0:g.id,h=s.type===Dc.toString();if(!d||!c&&!p)return l;let{input:{userCommitted:y}}=u;return EL(y,a)&&!r&&!h||(clearTimeout(n),!t.check(u))||(n=setTimeout(()=>{r=!1;let m=Jo(u);m===""?o.dispatch(t.getTextSuggestions("default")):o.dispatch(t.getAutocompleteSuggestions(m))},h?0:t.debounce)),l}};var jT=io.fulfilled.toString();function CL(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 HT=e=>t=>n=>r=>{var c;if(r.type!==jT){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(c=i.conversation)==null?void 0:c.current,{agentInfo:l}=i.info;if(o===s)return;let u=CL(o,s);r.type===jT&&u.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,agentId:l.agentId??(a==null?void 0:a.agentId),agentName:l.agentName??(a==null?void 0:a.agentName),agentEmail:l.agentEmail??(a==null?void 0:a.agentEmail),data:{keywordMatches:u}})};var TL=lu({activeSuggestion:zx,answer:OE,auth:nE,autoflows:NC,conversation:s0,contentTypes:yE,customMessages:VC,exchangeToken:qC,entities:xE,handlingTime:OT,info:gx,input:Im.reducer,overlayInput:Ge.reducer,settings:Yw,profile:DE,search:xx,summary:kE,styleSuggestions:MT,ui:qx,textSuggestions:Fx});function BT(e){return rw({reducer:TL,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),NT(),FT({debounce:200}),DT({debounce:500}),HT(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var _L=e=>{var t;return((t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())??"unknown"},bL=e=>t=>n=>r=>{var a;let o=t.getState(),i=Tm("inlineSuggestions")(o);switch(r.type){case En.toString():{let l=Lx(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 Mt.toString():{let{start:l,end:u}=o.input.selection;e.emit("select-suggestion",{type:_L(r.payload.suggestion),...r.payload,replace:r.payload.replace==="selection"?{start:l,end:u}:{start:0,end:u}},{mayApplyChanges:!0});break}case qu.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 Ws.toString():{let l=t.getState(),{text:u,selection:c}=l.input.userCommitted;e.emit("reset",{text:u,selectionAfter:c},{mayApplyChanges:!0});break}case Yu.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 Ut.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:o.conversation.current.id,data:{entities:r.payload}});break;case _n.fulfilled.toString():e.sendEvent("conversation summarized",{conversationId:o.conversation.current.id,data:{inputText:JSON.stringify(r.payload.original),summary:r.payload.summary}});break;case Zt.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 Gu.toString():e.handleKeyDown(r.payload);break;case Ks.toString():e.logSendMessage(r.payload);break;case Xu.toString():e.logSendEditSuggestionMessage(r.payload);break;case Qu.toString():e.handleInputChanged(r.payload);break;default:break}let s=n(r);switch(r.type){case Ks.toString():e.handleAfterSendMessage(r.payload);break;case ga.toString():e.onUpdateShowTabHint(r.payload);break;case yd.toString():e.logHandlingTime();break;case Mt.toString():{i&&(t.dispatch(fr([])),t.dispatch(pr()));break}default:break}return s},UT=bL;function gh(e){return e.toISOString().replace("T"," ").replace("Z","")}function zT(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:gh(n),timeStop:gh(r)}}function hh(e,t,n){var T,E,_;let{text:r,metrics:{numCharsTyped:o,numCharsPasted:i,numCharsCut:s,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:u,pastes:c,cuts:p,deletions:d,textSuggestions:h,offeredTextSuggestions:y}}=t[e],v=r.length,m=h.reduce((R,{text:b,searchTerm:B})=>R+b.length-(B?B.length:0),0),f=u??Date.now(),w=(Date.now()-f)/1e3,x=o/w;return{conversationId:t.conversation.current.id,source:"agent",text:r,clientVersion:n.version,pastes:c,cuts:p,deletions:d,lenTextTyped:o,lenTextTotal:v,lenTextAssisted:m,lenTextPasted:i,lenTextCut:s,lenTextDeleted:a,timeTotalSeconds:w,charsPerSecond:x,numPastes:l,textSuggestionsV2:h,suggestionsCounters:[{source:"gpt",countOffered:y.filter(R=>R.source==="gpt").length}],agentId:(T=t.info.agentInfo)==null?void 0:T.agentId,agentName:(E=t.info.agentInfo)==null?void 0:E.agentName,agentEmail:(_=t.info.agentInfo)==null?void 0:_.agentEmail}}function VT(e,t){let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;return r instanceof HTMLElement?VT(r,t):null}function KT(e,t){return VT(e,t)}function WT(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function vd(e){return e instanceof HTMLElement&&(Pn(e)||Tc(e))}var $T=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch{return t}}catch{return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch{H.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function kL(e){return e.offsetParent!==null}function qT(e){if(!kL(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 Sd(e,t,n=100){let r=qT(e);t({isVisible:r});let o=setInterval(()=>{let i=qT(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var lt=S(C()),GT=$T("showTabHint",!0),Da=class e{static version="10.1.1";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:t,brokerUrl:n,version:r=e.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a}){let l=t.replace(/\/api$/,"");this.deepdeskApi=new Nn(l,{token:i,fetch:s}),this.version=r,this.instanceId=e.count++;let u={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[UT({emit:(c,p,d)=>this.emit(c,p,d),handleAfterSendMessage:c=>this.handleAfterSendMessage(c),handleInputChanged:c=>this.handleInputChanged(c),handleKeyDown:c=>this.handleKeyDown(c),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:c=>this.logSendMessage(c),logSendEditSuggestionMessage:c=>this.logSendEditMessage(c),onUpdateShowTabHint:c=>GT.update(c),sendEvent:(c,p)=>this.deepdeskApi.sendEvent(c,p)})]};n&&Object.assign(u,{deepdeskBrokerAPI:new Ma(n)}),this.store=BT(u),this.broadcastEvents=new PT({debug:!0,deepdeskUrl:l,eventMap:rE(this.store)}),this.store.dispatch(zs),this.store.dispatch(ga(GT.value())),this.store.dispatch(zs({locale:o,adminUrl:l,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(H.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(H.warn("Profile has not been loaded (yet)"),!0):(H.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Fc(null)),this.store.dispatch(Yr()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();Cn(r)&&Qx(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){H.warn("Failed to attach user:",n)}}async isConversationSupported(t,n){return(await this.store.dispatch(Pm({sessionId:t,options:n}))).payload}async createConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(Uu(t))).payload}async getConversationBySessionId(t,n){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(await this.store.dispatch(zu({sessionId:t,options:n}))).payload}async upsertConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(Rm(t))).payload}async postMessages(t){return(await this.store.dispatch(Ku(t))).payload}async updateConversation(t){return(await this.store.dispatch(Vu(t))).payload}resetConversation(){this.store.dispatch(Z()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let t=await this.store.dispatch(_n());if(t.error)throw new Error(t.error.message);return t.payload.summary}configure(t){this.store.dispatch(zs(t))}setVisitorInfo(t){this.store.dispatch(mx(t))}async setAgentInfo(t){await this.store.dispatch(ca(t))}async setAgentSettings(t){await this.store.dispatch(pg(t))}async getAgentSettings(){return(await this.store.dispatch(mg())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();let t=[];return this.store.dispatch(Dc()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})}notifyInputChanged(t){this.store.dispatch(Qu(t))}syncInputHtml(t){this.store.dispatch(S0(t))}notifyKeyDown(t){this.store.dispatch(Gu(t))}notifyPaste(t,n){this.store.dispatch(y0({text:t,selectionText:n}))}notifyCut(t){this.store.dispatch(g0(t))}notifyExternalSuggestion(t){this.store.dispatch(Mt(t)),this.store.dispatch(pr())}notifyEditSuggestion(t){this.store.dispatch(Mx(t.contentType,t.suggestions)),this.store.dispatch(En({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(hi({collapse:!1})),this.inputMediator&&this.store.dispatch(u0({text:t,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(fr([])))}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(h0($u(t))),!(t.key!=="Tab"&&!this.settings.showTextSuggestions))switch(t.key){case"Up":case"ArrowUp":if(n||!a||!i||t.shiftKey)return;this.store.dispatch(f0()),s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault();return;case"Down":case"ArrowDown":{if(n||!a||!i||t.shiftKey)return;this.store.dispatch(m0());let{selectedSuggestionIndex:u}=this.state.input;u===-1?this.store.dispatch(Ws()):s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault();return}case"Esc":case"Escape":{l?(this.store.dispatch(Zu(-1)),this.store.dispatch(Ws()),t.preventDefault()):n||(this.store.dispatch(hi({collapse:!0})),this.store.dispatch(Wx(!0)),t.preventDefault());return}case"Tab":{let{userCommitted:u}=this.state.input,c=u.text.substring(0,u.selection.end),{tabCompletionSuggestion:p}=this.state.input;this.store.dispatch(ga(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):this.settings.showTabCompletion&&p&&p.text.startsWith(c)&&(this.store.dispatch(Mt({text:p.text,suggestion:p,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(pr())),t.preventDefault();break}default:}}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(v0()),this.store.dispatch(fr([]))}handlingTimeStart(){this.state.handlingTime.startTime||(H.info("Start handling time"),this.store.dispatch(LT()))}handlingTimeStop(){this.state.handlingTime.startTime&&(H.info("Stop handling time"),this.store.dispatch(yd()))}logSendMessage(t){let n=hh("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=hh("overlayInput",this.state,{version:"v2"});t&&Object.assign(n,{text:t}),this.store.dispatch(d0(this.state.overlayInput.metrics)),this.deepdeskApi.sendEvent("suggestion edited",{data:n})}logHandlingTime(){let t=zT(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(AT())}notifySubmit(t={}){this.shouldAbort()||(this.store.dispatch(pr()),this.store.dispatch(Ks(t.text??this.state.input.text)))}stageSelectedSuggestion(t){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:r}=this.state.input;this.store.dispatch(Mt({text:r[n].text,suggestion:r[n],eventMetrics:t,replace:"until-selection-end"}))}emit(t,n,r={}){let o=()=>{this.eventListeners[t]&&this.eventListeners[t].forEach(i=>{try{i(n)}catch(s){H.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),H.error(s)}})};this.inputMediator&&r.mayApplyChanges?this.inputMediator.applyChanges(o):o()}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=ci(r,o);return i.dataset.testid=t,n!=null&&n.rootNode&&i.classList.add(n.rootNode),this.unmountHandlers.push(()=>{(0,Mn.unmountComponentAtNode)(i),s(),i.remove()}),i}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return Gr(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,n.appendChild(o),this.unmountHandlers.push(()=>{(0,Mn.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(!vd(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:p,detectSubmit:d,insertLink:h,inputMediator:y,closestScrollSelector:v,appendOverlayTo:g,inlineSuggestions:m}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:h,isEmbedded:p,inlineSuggestions:m});let f=v&&KT(t,v)||void 0,w=this.overlayContainerFactory("deepdesk-tab-completion",r,t,{appendTo:g,closestScrollElement:f,mirrorOverflow:!0,onRemove:()=>this.unmount()}),x=this.overlayContainerFactory("deepdesk-suggestions-overlay",r,f||t,{appendTo:g});n.automaticHandlingTime&&this.setupHandlingTime(t),(0,Mn.render)((0,lt.jsx)(ka,{store:this.store,customStyles:r,children:(0,lt.jsx)(ya,{broadcastEvents:this.broadcastEvents,children:(0,lt.jsx)(PC,{inputElement:t})})}),w),(0,Mn.render)((0,lt.jsx)(ka,{store:this.store,customStyles:r,children:(0,lt.jsx)(ya,{broadcastEvents:this.broadcastEvents,children:(0,lt.jsx)(Wc,{})})}),x),(0,Mn.render)((0,lt.jsx)(ka,{store:this.store,customStyles:r,children:(0,lt.jsx)(ya,{broadcastEvents:this.broadcastEvents,children:(0,lt.jsx)(UE,{})})}),this.createContainer("deepdesk-overlays")),Gr(t),this.inputMediator=y||(Pn(t)?new Sn(t):new oo(t)),this.inputMediator.on("change",({plainText:E})=>{this.notifyInputChanged(E)}),this.inputMediator.on("updated",({rawHtml:E})=>{E!=null&&this.syncInputHtml(E)}),this.inputMediator.on("keydown",E=>{this.notifyKeyDown(E)}),this.inputMediator.on("paste",({pastedText:E,selectionText:_})=>{this.notifyPaste(E,_)}),this.inputMediator.on("cut",({selectionText:E})=>{this.notifyCut(E)});let T;this.inputMediator.on("selection",E=>{clearTimeout(T),E===null?T=setTimeout(()=>{E!==null&&this.store.dispatch(Lm(E))},500):this.store.dispatch(Lm(E))}),this.inputMediator.on("disabled",()=>{var E;(E=this.inputMediator)==null||E.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(gi(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(gi(!0))),this.store.dispatch(c0({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var E;this.broadcastEvents.setSessionId((E=this.state.conversation.current)==null?void 0:E.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&H.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,showPersonalCollectionLink:i,isEmbedded:s}=n;this.widgetRoot=t,this.configure({showImages:o,showPersonalCollectionLink:i,isEmbedded:s}),(0,Mn.render)((0,lt.jsx)(ka,{store:this.store,customStyles:r,children:(0,lt.jsx)(ya,{broadcastEvents:this.broadcastEvents,children:(0,lt.jsx)(bT,{})})}),t),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Mn.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Sd(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){WT(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(_a());let t=Si(this.state);t&&this.store.dispatch(zs({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:t.knowledgeSearch,recommendTextSuggestions:t.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(t){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(H.info("Trial is active"),!await this.deepdeskApi.checkUserExists(t))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;H.info(r),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Bc(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(Ut()):this.store.dispatch(xn(r))})}catch(r){this.handleError(r)}}};async function XT(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 QT(e,t,n={}){let r=n.replace?ro(e,n.replace.start,n.replace.end):kT(e),o,i=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),o=document.createElement("span"),r.insertNode(o),t.split(`
|
|
22
22
|
`).reverse().forEach((s,a)=>{a>0&&r.insertNode(document.createElement("br")),r.insertNode(document.createTextNode(s))}),r.commonAncestorContainer===e&&r.surroundContents(document.createElement("div"))};return Promise.resolve(i()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let s=n.selectionAfter?ro(e,n.selectionAfter.start,n.selectionAfter.end):(r.collapse(!1),r),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(s)}if(!o)return;o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}function YT(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function ZT(e,t,n){await new Nn(e).authenticateWithKey(t,n)}async function JT(e){let n=await new On(e).get("/platform/config/",{version:null});return ne(n)}async function PL(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 e1(e,t){let n=await PL(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 s1(RL);})();
|
|
23
23
|
/*! Bundled license information:
|
|
24
24
|
|