@deepdesk/deepdesk-sdk 14.1.1-beta.10 → 14.1.1-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,15 +16,15 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
16
16
  `);return o=o.replace(/\n{3,}/g,`
17
17
 
18
18
 
19
- `),o=o.replace(/\n/g,"<br/>"),o}createContainer(t){var n;let o=(typeof global!="undefined"&&global.INTERWEAVE_SSR_POLYFILL||xO)();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(vO)||(s.innerHTML=this.convertLineBreaks(this.props.escapeHtml?(0,HE.default)(t):t)),s}extractAttributes(t){let{allowAttributes:n}=this.props,r={},o=0;return t.nodeType!==FE||!t.attributes||([...t.attributes].forEach(i=>{let{name:s,value:a}=i,l=s.toLowerCase(),u=Dd[l]||Dd[s];if(!this.isSafe(t)||!l.match(SO)&&(!n&&(!u||u===Ah)||l.startsWith("on")||a.replace(/(\s|\0|&#x0([9AD]);)/,"").match(/(javascript|vbscript|livescript|xss):/i)))return;let c=l==="style"?this.extractStyleAttribute(t):a;u===Zr?c=!0:u===Fo?c=Number.parseFloat(String(c)):u!==_d&&(c=String(c)),r[Lh[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 il[t]?I(T(T({},n),il[t]),{tagName:t}):n}isSafe(t){if(typeof HTMLAnchorElement!="undefined"&&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===FE){let d=c.nodeName.toLowerCase(),p=this.getTagConfig(d);u&&(l.push(u),u="");let v=this.applyNodeFilters(d,c);if(!v)return;let y;if(s&&!(a&&!this.isTagAllowed(d))){this.keyIndex+=1;let m=this.keyIndex;y=this.parseNode(v,p);let g=s(v,y,p);if(g===null)return;if(typeof g!="undefined"){l.push(Uo.default.cloneElement(g,{key:m}));return}this.keyIndex=m-1}if(this.banned.has(d))return;if(!(r||o&&d!=="br")&&this.isTagAllowed(d)&&(i||this.canRenderChild(n,p))){var f;this.keyIndex+=1;let m=this.extractAttributes(v),g={tagName:d};m&&(g.attributes=m),p.void&&(g.selfClose=p.void),l.push(Uo.default.createElement(Fd,I(T({},g),{key:this.keyIndex}),(f=y)!==null&&f!==void 0?f:this.parseNode(v,p)))}else l=[...l,...this.parseNode(v,p.tagName?p:n)]}else if(c.nodeType===yO){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(wO);){let[s,a]=i,l=i.index,u=s.includes("/");l>0&&(r.push(o.slice(0,l)),o=o.slice(l));let{children:c,matcher:f,props:d}=n[a],p;if(u)p=s.length,r.push(f.createElement(c,d));else{let v=o.match(new RegExp(`{{{/${a}}}}`));p=v.index+v[0].length,r.push(f.createElement(this.replaceTokens(o.slice(s.length,v.index),n),d))}o=o.slice(p)}return o.length>0&&r.push(o),r.length===0?"":r.length===1&&typeof r[0]=="string"?r[0]:r}};function EO(e){var t;let{attributes:n,className:r,containerTagName:o,content:i,emptyContent:s,parsedContent:a,tagName:l,noWrap:u}=e,c=(t=o!=null?o:l)!==null&&t!==void 0?t:"span",f=c==="fragment"?!0:u,d;if(a)d=a;else{let p=new Hd(i!=null?i:"",e).parse();p.length>0&&(d=p)}return d||(d=s),f?Uo.default.createElement(Uo.default.Fragment,null,d):Uo.default.createElement(Fd,{attributes:n,className:r,tagName:c},d)}function ls(e){let k=e,{attributes:t,className:n,content:r="",disableFilters:o=!1,disableMatchers:i=!1,emptyContent:s=null,filters:a=[],matchers:l=[],onAfterParse:u=null,onBeforeParse:c=null,tagName:f="span",noWrap:d=!1}=k,p=ee(k,["attributes","className","content","disableFilters","disableMatchers","emptyContent","filters","matchers","onAfterParse","onBeforeParse","tagName","noWrap"]),v=i?[]:l,y=o?[]:a,m=c?[c]:[],g=u?[u]:[];v.forEach(C=>{C.onBeforeParse&&m.push(C.onBeforeParse.bind(C)),C.onAfterParse&&g.push(C.onAfterParse.bind(C))});let h=m.reduce((C,R)=>R(C,e),r!=null?r:""),S=new Hd(h,p,v,y),x=g.reduce((C,R)=>R(C,e),S.parse());return Uo.default.createElement(EO,{attributes:t,className:n,containerTagName:e.containerTagName,emptyContent:s,noWrap:d,parsedContent:x.length===0?void 0:x,tagName:f})}var WE=w(U());var bO=/[.*+?^${}()|[\]\\]/g,CO=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function TO(e){return e.replace(bO,"\\$&")}function kO(e,t){let n=e.split("").findIndex((r,o)=>r!==t[o]);return n>-1?n:Math.min(e.length,t.length)}function PO(e){return e.search(CO)}function UE(e,t=[]){let n=e;return t.forEach(r=>{if(!r)return;let o=new RegExp(`\\b(${TO(r)})\\b`,"gi");n=n.replace(o,"<strong>$1</strong>")}),n}function zE(e){return e.replace(iu,'<mark data-type="placeholder">$1</mark>')}function us(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function RO(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 Oh(e,t,n={}){if(t){let r=kO(t.toLowerCase(),e.toLowerCase()),o=us(e.substring(r,e.length));if(n.stripAgentPart){let l=e.substring(0,r),u=PO(l);return`<span style="opacity: 0.5">${l.substring(u+1)}</span>${o}`}let s=t.split(t0).length>3||t.length>30?RO(t.trim(),r):0;return`${`${s>0?"\u2026":""}${us(e.substring(s,r))}`}<strong>${o}</strong>`}return e}var AO=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function Ud(e){return AO.test(e)}function BE(e){var n;let t=document.createElement("template");return t.innerHTML=e,(n=t.content.textContent)!=null?n:""}var zd=w(U()),KE=w(b()),jE=zd.default.createContext(void 0);function Jr(){let e=zd.default.useContext(jE);if(e===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return e}var VE=({children:e,page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i})=>{let s=zd.default.useMemo(()=>({page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i}),[n,t,o]);return(0,KE.jsx)(jE.Provider,{value:s,children:e})};var Yt=w(b()),LO=3,$E=({children:e})=>{let t=L("CommandPalette",Ot);return(0,Yt.jsx)("div",{className:t.listItemActions,children:e})};function Nh(d){var p=d,{closeOnSelect:e=!0,lineClamp:t,children:n,onClick:r,extra:o,onSourceClick:i,description:s,sources:a,id:l,styles:u,defaultSourcesAmount:c=LO}=p,f=ee(p,["closeOnSelect","lineClamp","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var k;let v=q(er),[y,m]=(0,WE.useState)(!1),{selected:g,onChangeOpen:h}=Jr(),S=L("CommandPalette",Ot);function x(C){r(C),e&&h(!1)}return(0,Yt.jsxs)("div",{className:(0,cs.default)(S.listItem,l===g&&S.listItemSelected),children:[(0,Yt.jsx)("button",I(T({type:"button",className:(0,cs.default)(S.listItemAction,S.listItemPrimaryAction),"aria-disabled":(k=f.disabled)!=null?k:!1,onClick:x,"data-command-palette-item":!0,"data-item-id":l},f),{children:(0,Yt.jsxs)("div",{className:S.listItemContent,children:[typeof n=="string"?(0,Yt.jsx)("p",{className:(0,cs.default)(S.listItemText,S.truncate,u==null?void 0:u.title),children:n}):n,s&&(0,Yt.jsx)(ls,{tagName:"p",allowList:[],content:Ud(s)?BE(s):s,className:(0,cs.default)(S.listItemDescription,u==null?void 0:u.description,t?S.lineClamp:S.truncate)})]})})),o,a&&a.length>0&&(0,Yt.jsxs)("div",{className:S.sources,children:[(0,Yt.jsx)("span",{className:S.sourcesTitle,children:v("sources")}),a.slice(0,y?a.length:c).map(C=>(0,Yt.jsx)("a",{className:S.source,href:C.url,target:"_blank",title:C.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i&&i(C),children:C.name},C.url)),!y&&a.length>c&&(0,Yt.jsx)("button",{className:(0,cs.default)(S.source,S.sourceShowMore),type:"button",onClick:()=>m(!0),children:v("showMore",{amount:a.length-c})})]})]})}var sl=w(b()),qE=()=>(0,sl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,sl.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,sl.jsx)("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});var zo=w(b());function Mh({children:e,title:t,id:n,onDismiss:r}){let o=q(er),i=L("CommandPalette",Ot),{page:s}=Jr();return s!==n?null:(0,zo.jsxs)("div",{className:i.page,id:`page_${n}`,tabIndex:-1,children:[r&&(0,zo.jsxs)("div",{className:i.pageNav,children:[(0,zo.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:r,children:[(0,zo.jsx)(qE,{}),o("back")]}),t&&(0,zo.jsx)("h3",{className:i.pageTitle,children:t})]}),e]})}var GE=w(U());var al=w(b()),ds=()=>(0,al.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,al.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,al.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 mn=w(b());function IO({onChange:e,onChangeType:t,placeholder:n,typePlaceholder:r,types:o,value:i,selectedType:s},a){let l=L("CommandPalette",Ot);return(0,mn.jsxs)("div",{className:l.search,children:[(0,mn.jsx)("div",{className:l.searchIcon,children:(0,mn.jsx)(ds,{})}),(0,mn.jsxs)("div",{className:l.searchInputWrapper,children:[(0,mn.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:u=>{e(u.currentTarget.value)},onFocus:u=>{u.currentTarget.select()},className:l.searchInput,placeholder:n,value:i,type:"text",id:"command-palette-search-input",autoFocus:!0}),o&&o.length>0&&(0,mn.jsx)("div",{className:l.selectWrapper,children:(0,mn.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,mn.jsx)("option",{children:r}),o.map(u=>(0,mn.jsx)("option",{value:u.value,children:u.label},u.value))]})})]})]})}var QE=(0,GE.forwardRef)(IO);var _h=w(oe());var Bd=w(b()),OO=o=>{var i=o,{onClick:e,shortKeys:t,children:n}=i,r=ee(i,["onClick","shortKeys","children"]);let s=L("CommandPalette",Ot);return(0,Bd.jsxs)("button",I(T({type:"button"},r),{onClick:e,className:(0,_h.default)(s.actionButton,r.className,{[s.hasShortKeys]:t&&t.length>0}),children:[n,t&&t.map(a=>(0,Bd.jsx)("span",{className:(0,_h.default)(s.actionShortcut,a===8629&&s.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},YE=OO;var ll=w(b()),NO="[data-command-palette-item]";function Bo({placeholder:e="Start typing to search...",typePlaceholder:t="All types",defaultPage:n="search",page:r,onChangePage:o,onChangeSearch:i,onChangeType:s,onChangeOpen:a,selectedType:l,types:u,children:c,isOpen:f,search:d}){let[p,v]=(0,rr.useState)(),y=(0,rr.useRef)(null),m=()=>{o&&o(n),s(void 0),i(""),a(!1)},g=()=>{var D;if(r!==n&&o){o(n);return}if(l&&s){s(void 0),(D=y.current)==null||D.focus();return}if(d.length>0){i("");return}a(!1)},h=()=>{let D=S();D.length!==0&&v(D[0].dataset.itemId)},S=()=>Array.from(document.querySelectorAll(NO)||[]),x=D=>document.querySelector(`[data-item-id=${D}]`),k=D=>{let G=x(D);G&&v(G.dataset.itemId)},C=D=>{let G=x(D);G&&G.scrollIntoView({behavior:"smooth"})},R=()=>{if(!p)return;let D=S(),G=x(p);if(!G)return;let Z=D.indexOf(G),ie=D[Z+1];ie&&ie.dataset.itemId?k(ie.dataset.itemId):h()},N=()=>{if(!p)return;let D=S(),G=x(p);if(!G)return;let Z=D.indexOf(G),ie=D[Z-1];ie&&ie.dataset.itemId?k(ie.dataset.itemId):k(D[D.length-1].dataset.itemId)},_=(0,rr.useCallback)(D=>{switch(D.key){case"ArrowDown":{D.preventDefault(),R();break}case"ArrowUp":{D.preventDefault(),N();break}case"Enter":{if(p){let G=x(p);G==null||G.click()}break}}},[p]);return(0,rr.useEffect)(()=>{h()},[d,r,l,f]),(0,rr.useEffect)(()=>{p&&C(p)},[p]),(0,ll.jsx)(Ad,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:f,onBack:g,onClose:m,onKeyDown:_,children:(0,ll.jsxs)(VE,{selected:p,setSelected:v,isOpen:f,onChangeOpen:a,page:r,children:[r===n&&(0,ll.jsx)(QE,{ref:y,onChange:i,onChangeType:s,placeholder:e,value:d,selectedType:l,types:u,typePlaceholder:t}),c]})})}Bo.Page=Mh;Bo.List=bh;Bo.Image=IE;Bo.ListItem=Nh;Bo.ListItemActions=$E;Bo.Button=YE;var me=Bo;var XE=w(U());function ZE(e,t){(0,XE.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 ul=w(U());var JE={data:null,fetchState:"idle"},jd=e=>{var i,s,a,l;let t=[],{visitorName:n}=(i=e.info.visitorInfo)!=null?i:{},{agentName:r,agentNickname:o}=(s=e.info.agentInfo)!=null?s:{};return r&&r!==n&&t.push(r),o&&o!==n&&t.push(o),(l=(a=e.entities.data)==null?void 0:a.filter(u=>!t.includes(u.text)))!=null?l:null},gn=K("entities/getEntities",(e,t)=>P(void 0,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra;if(!r.conversationQuery)return Promise.resolve([]);let o=r.conversationQuery,i=yield o();return i.length===0?Promise.resolve([]):n.getEntities(i)})),MO=e=>e.filter((t,n)=>n===e.findIndex(r=>r.text===t.text)),_O=X({name:"entities",initialState:JE,reducers:{},extraReducers:e=>{e.addCase(gn.pending,t=>{t.fetchState="loading"}).addCase(gn.rejected,t=>{t.fetchState="error"}).addCase(gn.fulfilled,(t,n)=>{t.fetchState="done",t.data=MO(t.data?[...t.data,...n.payload]:n.payload)}).addCase(de,()=>JE)}}),eb=_O.reducer;var Dh={};Qe(Dh,{enUS:()=>DO,nlNL:()=>FO});var DO={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},FO={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var tb={root:"dd-TYTKs",empty:"dd-AU7uT"};var fs=w(b()),HO=({onCopy:e})=>{let t=(0,ul.useRef)(null),n=L("EntitiesList",tb),r=M(jd),{setSelected:o}=Jr(),i=q(Dh),s=Q();return(0,ul.useEffect)(()=>{s(gn())},[]),(0,ul.useEffect)(()=>{t.current&&(t.current.focus(),o("entity-0"))},[t]),(0,fs.jsxs)("div",{className:n.root,ref:t,tabIndex:-1,children:[r&&r.length>0&&(0,fs.jsx)(me.List,{children:r.map((a,l)=>(0,fs.jsx)(me.ListItem,{id:`entity-${l}`,closeOnSelect:!0,onClick:()=>e(a),children:a.text},a.text))},"entities"),r&&r.length===0&&(0,fs.jsx)("p",{className:n.empty,children:i("noResults")})]})},nb=HO;var Xt=w(U());var Fh={outputs:[],fetchState:"idle"},rb=e=>{var t;return(t=e.assistants)==null?void 0:t.outputs},UO=be("assistants/resetOutputs"),Vd=be("assistants/callToAction"),ps=K("assistants/getSummary",(e,t)=>P(void 0,null,function*(){var i,s,a;let n=t.getState();if(!n.profile.data)throw new Error("No Profile is loaded");let{summarizerAssistantNew:r}=n.profile.data;if(!r){let{deepdeskAPI:l,dynamicThunkObject:u}=t.extra,c=t.getState(),f=(i=c.conversation.current)==null?void 0:i.sessionId,d=(a=(s=c.info)==null?void 0:s.agentInfo)==null?void 0:a.agentId,p=c.profile.data;if(!p)throw new Error("Profile is not defined");if(!u.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let v=u.conversationQuery,y=yield v(),m=yield l.getSummary(y,{externalConversationId:f,agentId:d,promptInstruction:p.summarizerPromptInstruction,model:p.summarizerModel});return m.summary?m.summary:Promise.reject(new Error("Summary is not provided"))}let o=yield t.dispatch(eo(T({assistantCode:r,transcript:"in-memory-transcript",skipState:!0},e)));if(o.error)throw new Error(o.error.message);if(typeof o.payload!="string")throw H.warn("Unexpected summary output",o),new Error("Unexpected summary output");return o.payload})),eo=K("assistants/evaluate",(e,t)=>P(void 0,null,function*(){var f;let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra,{transcript:o,input:i={}}=e,s=t.getState(),{platformVariables:a}=s.info,l=(f=s.conversation.current)==null?void 0:f.sessionId,u;if(o==="in-memory-transcript"){if(!r.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");u=yield r.conversationQuery()}else if(o==="stored-transcript"){if(!s.conversation.current)throw new Error("Can't include stored-transcript, no current conversation");u=s.conversation.current.messages.map(d=>({text:d.text,source:d.source}))}else Array.isArray(o)&&(u=o);if(e.includeTags){if(!s.conversation.current)throw new Error("Can't include tags, no current conversation");let{tags:d}=s.conversation.current;Object.assign(i,{tags:d})}let c=yield n.evaluateAssistant(e.assistantCode,{input:i,transcript:u,conversationId:l});return a&&(c=Array.isArray(c)?c.map(d=>I(T({},d),{name:rt(d.name,a),response:rt(d.response,a)})):rt(c,a)),c})),ob=X({name:"assistants",initialState:Fh,reducers:{removeOutputByCode(e,t){e.outputs=e.outputs.filter(n=>n.code!==t.payload.code)}},extraReducers:e=>{e.addCase(eo.pending,(t,n)=>{n.meta.arg.skipState||(t.fetchState="loading")}).addCase(eo.rejected,(t,n)=>{n.meta.arg.skipState||(t.fetchState="error")}).addCase(eo.fulfilled,(t,n)=>{if(n.meta.arg.skipState)return;if(!Array.isArray(n.payload))throw H.warn("Unexpected assistant output",n.payload),new Error("Unexpected assistant output");let r=n.payload.map(i=>i.code),o=t.outputs.filter(i=>!r.includes(i.code));t.fetchState="done",t.outputs=[...n.payload,...o]}).addCase(de,()=>Fh).addCase(UO.toString(),()=>Fh)}}),{removeOutputByCode:ib}=ob.actions,sb=ob.reducer;var Hh={};Qe(Hh,{enUS:()=>zO,nlNL:()=>BO});var zO={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."}]},BO={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 ab={root:"dd-60NZr",actions:"dd-No1g3",main:"dd-l-xEF",textInput:"dd-nAaiV",loading:"dd-ciFNi",error:"dd-yNp2D"};var Kd=w(oe()),db=w(U());var Uh=w(b()),zh=e=>(0,Uh.jsx)("svg",I(T({width:"16",height:"16",fill:"#000000"},e),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Uh.jsx)("path",{fillRule:"evenodd",d:"M6.57086468,14.9173453 C6.38997052,14.9711236 6.19835748,15 6,15 L4,15 C2.8954305,15 2,14.1045695 2,13 L2,4 C2,2.8954305 2.8954305,2 4,2 L6,2 C6.68685475,2 7.29284112,2.34623869 7.65294381,2.87370078 C7.95642355,2.67736738 8.29504785,2.51351337 8.66312366,2.3818197 C9.50544052,2.08044754 10.3408482,1.9879107 10.9989281,1.99971266 C11.0150698,2.00005426 13.3487605,2.00015005 18,2 C20.7551411,2 22,6.05643086 22,12 C22,13.6824804 20.8695981,15 19,15 L15.9269768,15 C15.9359266,15.0245465 15.9451954,15.0497804 15.9547911,15.0757271 C16.007193,15.2174219 16.2391583,15.8256341 16.2970775,15.9810953 C16.4872151,16.4914441 16.6259612,16.9026411 16.7382242,17.3098712 C16.9079007,17.9253665 17,18.4798886 17,19 C17,20.4720069 16.091867,21.3862822 14.748281,21.777514 C14.1422801,21.9539723 13.6147967,22.0000922 13.0076976,22.0000008 L12.5204954,22 L12.2202699,21.6261158 C11.2556275,20.4248034 7.64562469,16.4822788 6.57086468,14.9173453 Z M8,13 C8,13.2401953 8.04443154,13.4528921 8.14171093,13.6800176 C8.40663864,14.2985643 11.914268,18.1371493 13.4599624,19.9848695 C13.7113931,19.9660111 13.9483736,19.9273712 14.1891338,19.8572655 C14.7621788,19.6904035 15,19.4509737 15,19 C15,18.6834183 14.9359344,18.2976852 14.8101464,17.8413935 C14.7161494,17.500423 14.5944107,17.1396301 14.4229225,16.6793379 C14.3689242,16.5344009 14.1358033,15.923159 14.0789589,15.7694517 C13.9489218,15.4178313 13.8632547,15.1589343 13.8046536,14.9236885 C13.5555377,13.9236468 13.8054549,13 15,13 L19,13 C19.6912225,13 20,12.6401099 20,12 C20,7.20925475 19.015127,4 18,4 C15.9322103,4 15.9322103,4 10.9655994,3.99940813 C10.5253746,3.99154158 9.91062406,4.05963657 9.33687634,4.2649175 C8.45196659,4.58152894 8,5.09776992 8,6 L8,13 Z M4,4 L4,13 L6,13 L6,4 L4,4 Z"})}));var Bh=w(b()),lb=e=>(0,Bh.jsx)("svg",I(T({width:"16",height:"16",fill:"#000000"},e),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Bh.jsx)("path",{fillRule:"evenodd",d:"M7.65336736,21.1256786 C7.2933164,21.6534897 6.68712411,22 6,22 L4,22 C2.8954305,22 2,21.1045695 2,20 L2,11 C2,9.8954305 2.8954305,9 4,9 L6,9 C6.198171,9 6.38961023,9.02882212 6.57035446,9.08250314 C7.6444817,7.51807482 11.2554748,3.57449216 12.2202699,2.37298955 L12.5204954,1.99910538 L13,1.99910538 C13.6147967,1.99901314 14.1422801,2.04513312 14.748281,2.22159137 C16.091867,2.61282321 17,3.52709845 17,4.99910538 C17,5.51921677 16.9079007,6.07373891 16.7382242,6.68923415 C16.6259612,7.09646424 16.4872151,7.50766133 16.2970775,8.01801005 C16.2391583,8.17347129 16.007193,8.78168345 15.9547911,8.92337824 C15.9451954,8.94932503 15.9359266,8.9745589 15.9269768,8.99910538 L19,8.99910538 C20.8695981,8.99910538 22,10.316625 22,11.9991054 C22,17.9426745 20.7551411,21.9991054 18,21.9991054 L11.0344006,21.9985135 C10.3408482,22.0111947 9.50544052,21.9186578 8.66312366,21.6172857 C8.29521907,21.4856533 7.9567386,21.3218904 7.65336736,21.1256786 Z M8,17.9991054 C8,18.9013355 8.45196659,19.4175764 9.33687634,19.7341879 C9.91062406,19.9394688 10.5253746,20.0075638 10.963066,19.9997143 C10.9703499,19.9995545 10.9703499,19.9995545 11,19.9991054 L18,19.9991054 C19.015127,19.9991054 20,16.7898506 20,11.9991054 C20,11.3589955 19.6912225,10.9991054 19,10.9991054 L15,10.9991054 C13.8054549,10.9991054 13.5555377,10.0754586 13.8046536,9.07541689 C13.8632547,8.84017106 13.9489218,8.5812741 14.0789589,8.22965366 C14.1358033,8.07594642 14.3689242,7.46470447 14.4229225,7.31976744 C14.5944107,6.85947528 14.7161494,6.4986824 14.8101464,6.1577119 C14.9359344,5.70142019 15,5.31568707 15,4.99910538 C15,4.54813166 14.7621788,4.30870189 14.1891338,4.1418399 C13.9483736,4.07173418 13.7113931,4.0330943 13.4599624,4.01423587 C11.914268,5.86195611 8.40663864,9.70054105 8.14171093,10.3190878 C8.04443154,10.5462133 8,10.7589101 8,10.9991054 L8,17.9991054 Z M4,11 L4,20 L6,20 L6,11 L4,11 Z"})}));function ms(e,t){var o;let n=e.cloneNode(!0);n.style.top=`${e.offsetTop}px`,n.style.left=`${e.offsetLeft}px`,n.style.position="absolute",t.split(" ").forEach(i=>{n.classList.add(i)}),n.addEventListener("animationend",()=>n.remove()),(o=e.parentElement)==null||o.appendChild(n)}var jh={};Qe(jh,{enUS:()=>jO,nlNL:()=>VO});var jO={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},VO={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};function ub(e){return K("analytics/logEvent",(t,n)=>{var i,s,a;let r=(s=(i=n.getState())==null?void 0:i.conversation.current)==null?void 0:s.id,o=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(t.name,I(T({conversationId:r},o),{data:t.data}))})(e)}function gs(){let e=Q();return(t,n)=>P(this,null,function*(){yield e(ub({name:t,data:n}))})}var cb={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};var hs=e=>t=>{let{passwordlessToken:{token:n},settings:{isEmbedded:r,adminUrl:o}}=t;return o?r?n?`${o}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(e)}`:null:`${o}${e}`:null};var or=w(b()),KO=({eventName:e,eventData:t,feedbackType:n,feedbackText:r})=>{let o=L("FeedbackThumbs",cb),i=B("enableFeedbackForm"),s=M(Gr),a=M(hs(`/admin/feedback?conversationId=${s}&type=${n}&text=${r}&data=${JSON.stringify(t)}`)),l=q(jh),u=gs(),[c,f]=(0,db.useState)(null),d=v=>{v.stopPropagation(),ms(v.target,o.fadeup),f("up"),u(e,I(T({},t),{rating:"up"}))},p=v=>{v.stopPropagation(),ms(v.target,o.fadedown),f("down"),u(e,I(T({},t),{rating:"down"}))};return(0,or.jsxs)("div",{className:o.thumbs,children:[(0,or.jsx)(re.Button,{title:l("thumbsUp"),onClick:d,icon:(0,or.jsx)(lb,{}),className:(0,Kd.default)(o.thumbsUp,c==="up"&&o.selected),disabled:!!c}),i&&a?(0,or.jsx)(re.Button,{as:"a",title:l("thumbsDown"),href:a,target:"_blank",rel:"noreferrer",onClick:p,icon:(0,or.jsx)(zh,{}),className:(0,Kd.default)(o.thumbsDown,c==="down"&&o.selected),disabled:!!c}):(0,or.jsx)(re.Button,{title:l("thumbsDown"),onClick:p,icon:(0,or.jsx)(zh,{}),className:(0,Kd.default)(o.thumbsDown,c==="down"&&o.selected),disabled:!!c})]})},ys=KO;var WO={data:null,fetchState:"idle"},hn=e=>e.profile.data,Wd=e=>e.profile.data?e.profile.data.uiConfig.widget.types.filter(t=>t.isActive):[],fb=e=>e.profile.data?!!e.profile.data.uiConfig.widget.types.find(t=>t.type==="custom-data"):!1,cl=K("profile/getProfile",(e,t)=>P(void 0,null,function*(){var i;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");return((i=r.profile.data)==null?void 0:i.code)===o.profileCode?r.profile.data:n.getProfile(o.profileCode)})),$O=X({name:"profile",initialState:WO,reducers:{},extraReducers:e=>{e.addCase(cl.pending,t=>{t.fetchState="loading"}).addCase(cl.rejected,t=>{t.fetchState="error"}).addCase(cl.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),pb=$O.reducer;var In=w(b()),qO=({onCopy:e})=>{let t=(0,Xt.useRef)(null),n=L("SummaryForm",ab),[r,o]=(0,Xt.useState)(""),[i,s]=(0,Xt.useState)(""),[a,l]=(0,Xt.useState)(!1),u=M(hn),c=q(Hh),f=Q(),d=()=>{f(ut({name:"summary copied to clipboard",data:{originalText:r,finalText:i},options:{includeConversationData:!0}})),e(i)},p=()=>{let v=document.getSelection();v&&f(ut({name:"summary copied to clipboard",data:{originalText:r,finalText:v==null?void 0:v.toString(),assistant:u==null?void 0:u.summarizerAssistantNew},options:{includeConversationData:!0}}))};return(0,Xt.useEffect)(()=>{f(ps({})).then(v=>{if(v.error){l(!0);return}o(v.payload||""),s(v.payload||"")})},[]),(0,Xt.useEffect)(()=>{t.current&&r&&t.current.focus()},[t,r]),(0,Xt.useEffect)(()=>{let v=y=>{y.key==="Enter"&&y.shiftKey&&d()};return document.addEventListener("keydown",v),()=>{document.removeEventListener("keydown",v)}},[i]),(0,In.jsx)("div",{className:n.root,tabIndex:-1,children:a?(0,In.jsx)("p",{className:n.error,children:c("error")}):(0,In.jsxs)(Xt.Fragment,{children:[(0,In.jsx)("div",{className:n.main,children:(0,In.jsx)("textarea",{placeholder:r?void 0:c("loading"),disabled:!r,className:n.textInput,ref:t,value:i,onCopy:p,onChange:v=>s(v.target.value)})}),(0,In.jsxs)("div",{className:n.actions,children:[(0,In.jsx)(ys,{feedbackText:r||"",feedbackType:"summary",eventName:"summary feedback",eventData:{summary:r}}),(0,In.jsx)(me.Button,{shortKeys:[8679,8629],onClick:d,children:c("copy")})]})]})})},mb=qO;var dl={};Qe(dl,{enUS:()=>GO,nlNL:()=>QO});var GO={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},QO={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var ir=w(U());var Vh={};Qe(Vh,{enUS:()=>YO,nlNL:()=>XO});var YO={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"}]},XO={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 gb={root:"dd-fxP4c",title:"dd-vDbMh",empty:"dd-sB0lz",status:"dd--oZ1C",form:"dd-t0hnD",input:"dd-i1v3W",submit:"dd-oo2Oa",question:"dd-WvK17",answer:"dd-HAHcU",alignRight:"dd-oxrX3",listItemFeedback:"dd-POUal"};var ZO={data:null,fetchState:"idle"},hb=e=>{var t;return(t=e.knowledgeAssistant)==null?void 0:t.data},fl=K("knowledgeAssistant/getKnowledgeAssistant",(e,t)=>P(void 0,null,function*(){var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");let i=(s=r.profile.data)==null?void 0:s.knowledgeAssistant;return i?n.getKnowledgeAssistant(i):null})),JO=X({name:"knowledgeAssistant",initialState:ZO,reducers:{},extraReducers:e=>{e.addCase(fl.pending,t=>{t.fetchState="loading"}).addCase(fl.rejected,t=>{t.fetchState="error"}).addCase(fl.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),yb=JO.reducer;var Kh={data:[],fetchState:"idle"},vb=e=>{var t;return(t=e.answer)==null?void 0:t.data},Sb=e=>e.answer.fetchState,vs=be("answer/resetKnowledgeSearch"),pl=K("answer/getAnswer",(e,t)=>P(void 0,null,function*(){var u,c,f;let{deepdeskAPI:n}=t.extra,r=t.getState().answer.data,{platformVariables:o}=t.getState().info,i=hb(t.getState()),s=(u=t.getState().conversation.current)==null?void 0:u.sessionId,a=(f=(c=t.getState().info)==null?void 0:c.agentInfo)==null?void 0:f.agentId;if(!i)throw new Error("KnowledgeAssistant is not defined");let l=yield n.knowledgeAssist({customerInstruction:i.customerInstruction,doNotKnowAnswer:i.doNotKnowAnswer,question:e},r,i.code,{agentId:a,conversationId:s});return o&&(l.answer=rt(l.answer,o)),{question:e,answer:l}})),eN=X({name:"answer",initialState:Kh,reducers:{},extraReducers:e=>{e.addCase(pl.pending,t=>{t.fetchState="loading"}).addCase(pl.rejected,t=>{t.fetchState="error"}).addCase(pl.fulfilled,(t,n)=>{t.fetchState="done",t.data=[...t.data,n.payload]}).addCase(de,()=>Kh).addCase(vs,()=>Kh)}}),wb=eN.reducer;var ml=w(b()),xb=()=>(0,ml.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,ml.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,ml.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 ct=w(b()),tN=({onUse:e,onResetQuestion:t,question:n})=>{let[r,o]=ir.default.useState(""),[i,s]=ir.default.useState(!1),{setSelected:a}=Jr(),l=(0,ir.useRef)(null),u=L("KnowledgeSearchStyles",gb),c=q(Vh),f=Q(),d=M(vb),p=M(Sb),v=g=>P(void 0,null,function*(){s(!0),yield f(pl(g)),l.current&&s(!1)}),y=g=>P(void 0,null,function*(){g.preventDefault(),g.stopPropagation(),r!==""&&v(r)}),m=(g,h)=>{f(ut({name:"knowledge assist source viewed",data:{question:h,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return(0,ir.useEffect)(()=>{var g;n&&p==="idle"?v(n):(g=l.current)==null||g.focus()},[l,p]),(0,ir.useEffect)(()=>{p==="done"&&(f(ut({name:"knowledge assist question answered",data:{question:r||n,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),a(`knowledge-assist-${d.length-1}`),o(""))},[p,d]),(0,ir.useEffect)(()=>{l.current&&l.current.scrollIntoView({behavior:"smooth"})},[l,d]),(0,ct.jsxs)("div",{className:u.root,children:[d.length>0&&(0,ct.jsx)("div",{className:u.alignRight,children:(0,ct.jsx)(me.Button,{onClick:t,children:c("reset")})}),d.map(({question:g,answer:h},S)=>(0,ct.jsx)(me.List,{children:(0,ct.jsx)(me.ListItem,{id:`knowledge-assist-${S}`,"data-testid":"knowledge-search-answer",description:h.answer,closeOnSelect:!0,onClick:()=>e(h.answer),onSourceClick:x=>m(x,g),sources:h.sources,styles:{title:u.question,description:u.answer},extra:(0,ct.jsx)("div",{className:u.listItemFeedback,children:(0,ct.jsx)(ys,{feedbackText:h.answer,feedbackType:"knowledge-assist-answer",eventName:"knowledge assist feedback",eventData:T({question:g,isAgent:n!==g,isFollowUpQuestion:d.length>1},h)})}),children:g})},`${h.answer}_${S}`)),p==="loading"&&(0,ct.jsx)("p",{className:u.status,children:c("loading")}),p==="error"&&(0,ct.jsx)("p",{className:u.status,children:c("error")}),(0,ct.jsxs)("form",{className:u.form,onSubmit:y,children:[(0,ct.jsx)("input",{ref:l,placeholder:c("anotherQuestion"),className:u.input,type:"text",value:r,onFocus:()=>{a(void 0)},onChange:g=>{a(void 0),o(g.target.value)}}),(0,ct.jsx)("button",{type:"submit",className:u.submit,disabled:i,children:(0,ct.jsx)(xb,{})})]})]})},Eb=tN;var Ib=w(U());var nN=["{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}"],rN=new RegExp(nN.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function bb(e,t){let n=e.split(rN),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],l=i===n.length-2;r+=s.length;let u=r;if(l){let f=a.charAt(0),d=0;do u=f?t.indexOf(f,u+1):-1,d+=1;while(u!==-1&&a.indexOf(t.slice(u))!==0);if(u===-1&&d>2)return e}else u=a&&a!==""?t.indexOf(a,r):-1;let c=u===-1?t.slice(r):t.slice(r,u);o.push(c),r=u}return o.join("")}function Cb(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var kb={suggestions:[],fetchState:"idle"},Tb={default:kb},Pb=e=>t=>{var n,r;return(r=(n=t.textSuggestions[e])==null?void 0:n.suggestions)!=null?r:[]},$d=e=>e.textSuggestions,Rb=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},qd=be("textSuggestions/refresh"),yn=K("textSuggestions/recommendations",(e,t)=>P(void 0,null,function*(){var c;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(c=r.conversation.current)==null?void 0:c.id,{platformVariables:i}=r.info,{textSuggestionsCount:s,inlineSuggestions:a}=r.settings,l=is(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let u=yield n.getTextSuggestions(o,qa(r),e);if(i&&(u=u.map(f=>T(I(T({},f),{text:rt(f.text,i)}),f.title?{title:rt(f.title,i)}:{}))),e==="default"){let f=a?u.filter(Rb(l)):u;t.dispatch(Qr(f.slice(0,s)))}return u})),gl=K("textSuggestions/autocompletions",(e,t)=>P(void 0,null,function*(){var c;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(c=r.conversation.current)==null?void 0:c.id,{platformVariables:i}=r.info,{textSuggestionsCount:s,deanonymize:a,inlineSuggestions:l}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let u=yield n.getAutocompleteSuggestions(o,I(T({},qa(r)),{input:e}));if(!t.getState().input.text)throw new Error("Abort");return l&&(u=u.filter(Rb(e))),i&&(u=u.map(f=>I(T({},f),{text:rt(f.text,i)}))),a&&(u=u.map(f=>I(T({},f),{text:f.source!=="trie-with-typos"?bb(f.text,e):f.text}))),u=Cb(u,s),t.dispatch(Qr(u)),u})),Ab=X({name:"textSuggestions",initialState:Tb,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}}}}},extraReducers:e=>{e.addCase(yn.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||kb;return I(T({},t),{[r]:I(T({},o),{fetchState:"loading"})})}).addCase(yn.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(yn.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(gl.pending,t=>{t.default.fetchState="loading"}).addCase(gl.rejected,t=>{t.default.fetchState="error"}).addCase(gl.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(de,()=>Tb)}}),{setTextSuggestions:T7}=Ab.actions,Lb=Ab.reducer;var jo=w(b()),oN=({commands:e,onClick:t})=>{var a,l,u;let n=Q(),r=q(dl),o=M(hn),i=M($d),s=((u=(l=(a=o==null?void 0:o.uiConfig)==null?void 0:a.search)==null?void 0:l.initialTypes)==null?void 0:u.filter(({isActive:c})=>c))||[];return(0,Ib.useEffect)(()=>{s.forEach(({type:c})=>{(!i[c]||i[c].suggestions.length===0)&&n(yn(c))})},[]),(0,jo.jsxs)("div",{children:[e.length>0&&(0,jo.jsx)(me.List,{heading:r("commands"),children:e.map((c,f)=>(0,jo.jsx)(me.ListItem,{id:`command-${f}`,closeOnSelect:!1,onClick:c.onClick,children:c.label},c.label))}),s.map(({type:c,title:f})=>{var d;return(0,jo.jsx)(me.List,{heading:f,orientation:"vertical",children:(d=i[c])==null?void 0:d.suggestions.map((p,v)=>(0,jo.jsx)(me.ListItem,{id:`${c}-${v}`,closeOnSelect:!1,description:p.text,onClick:()=>t(p.text,p),"data-testid":"search-overlay-suggestion",children:p.title},`${p.id}-${p.text}`))},c)})]})},Ob=oN;var qe=w(U()),Nb=w(oe());var Wh={root:"dd-uVyL0",trigger:"dd-KIzQa",content:"dd-Ly3zO",contentOpen:"dd-O-8fR",contentTop:"dd-q3fGa",contentBottom:"dd-SFrvc",item:"dd-HZNy-"};var Vo=w(b()),iN=0,Mb=qe.default.createContext(null),sN=()=>{let e=(0,qe.useContext)(Mb);if(!e)throw new Error("Invalid DropdownContext");return e},_b=({trigger:e,children:t,position:n="bottom"})=>{let r=(0,qe.useMemo)(()=>++iN,[]),o=(0,qe.useRef)(null),i=(0,qe.useRef)(null),s=L("Dropdown",Wh),[a,l]=(0,qe.useState)(!1),[u,c]=(0,qe.useState)(n),f=p=>{p.preventDefault(),p.stopPropagation(),l(!a)},d=(0,qe.useCallback)(([p])=>{!p.isIntersecting&&a&&c(u==="top"?"bottom":"top")},[a]);return(0,qe.useEffect)(()=>{let p=v=>{o.current&&!o.current.contains(v.target)&&l(!1)};return document.addEventListener("click",p),()=>{document.removeEventListener("click",p)}},[]),(0,qe.useEffect)(()=>{if(!i.current&&!a)return()=>{};let p=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return i.current&&p.observe(i.current),()=>{i.current&&p.unobserve(i.current)}},[i,a]),(0,Vo.jsx)(Mb.Provider,{value:{setIsOpen:l},children:(0,Vo.jsxs)("div",{ref:o,className:s.root,children:[(0,Vo.jsx)("button",{id:`dropdown-${r}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:s.trigger,onClick:f,children:e}),(0,Vo.jsx)("div",{"data-testid":"dropdown-content",ref:i,"aria-hidden":!a,"aria-labelledby":`dropdown-${r}`,className:(0,Nb.default)(s.content,{[s.contentOpen]:a,[s.contentTop]:u==="top",[s.contentBottom]:u==="bottom"}),children:t})]})})};function aN(o){var i=o,{as:e,children:t,onClick:n}=i,r=ee(i,["as","children","onClick"]);let s=e||"button",a=L("Dropdown",Wh),{setIsOpen:l}=sN(),u=c=>{l(!1),n(c),c.stopPropagation()};return(0,Vo.jsx)(s,I(T({type:"button",className:a.item,onClick:u},r),{children:t}))}_b.Item=aN;var $h=_b;var qh=w(b()),Db=e=>(0,qh.jsx)("svg",I(T({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},e),{children:(0,qh.jsx)("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})}));var Ko={};Qe(Ko,{enUS:()=>lN,nlNL:()=>uN});var lN={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},uN={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var Gd=w(b()),cN=({suggestion:e,source:t,context:n})=>{let r=q(Ko),o=M(Gr),i=Q(),s=B("enableSuggestionFeedback"),a=`${e.text}`,l=M(hs(`/admin/feedback?conversationId=${o}&type=${t}&text=${a}&data=${JSON.stringify({context:n})}`)),u=()=>{i(ut({name:"suggestion feedback",data:{text:e.text,source:t,context:n},options:{includeConversationData:!0}}))};return!s||!l?null:(0,Gd.jsx)($h,{trigger:(0,Gd.jsx)(Db,{"data-testid":"feedback-dropdown-trigger"}),children:(0,Gd.jsx)($h.Item,{as:"a",onClick:u,target:"_blank",href:l,children:r("giveFeedback")})})},Qd=cN;var De=w(b()),fN=200,pN=5,mN=4,Fb=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),gN=()=>{let e=Q(),t=Qt(),n=q(dl),[r,o]=(0,Nt.useState)(!1),[i,s]=(0,Nt.useState)(""),a=M(J1),l=M(hn),[u,c]=(0,Nt.useState)(),f=M(lt),d=B("showSearch"),p=B("enableSuggestionFeedback"),v=B("showEntitiesCommand"),y=B("showSummaryCommand"),m=B("showKnowledgeSearch"),g=B("showImageSearch"),h=B("searchTriggerKey"),S=M(RE),x=M(eE),k=M(tE),C=M(Z1),R=V=>vr(x.filter(Te=>Te.type===V.toUpperCase()),V),N=[{value:"PERSONAL",label:n("personalSuggestions"),list:R("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:n("urlSuggestions"),list:R("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:R("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:R("IMAGE"),listOrientation:"horizontal",shouldShow:g}].filter(V=>V.shouldShow),_=[{label:n("entitiesClipboard"),onClick:()=>e(cn("entities")),shouldShow:v&&Fb(n("entitiesClipboard"),i)},{label:n("summaryClipboard"),onClick:()=>e(cn("summary")),shouldShow:y&&Fb(n("summaryClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(cn("knowledgeAssist")),shouldShow:m}].filter(V=>V.shouldShow),D=(S==null?void 0:S.map(V=>({value:V.code.toUpperCase(),label:`${V.name}s`,list:R(V.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],G=(0,Nt.useCallback)((0,Hb.default)((V,Te)=>{e(No({query:V,type:Te,tags:["search-overlay"],size:u?50:20}))},fN),[u]),Z=(0,Nt.useCallback)((V,Te)=>{switch(Te.type){case"IMAGE":t.send(uh,{suggestion:Te});break;default:t.send(Yr,{text:V,suggestion:Te})}e(Lt(!1))},[e]),ie=V=>{Jn(V.text),e(ut({name:"entity copied",data:{entity:V,type:"copy"}})),e(Lt(!1))},yr=V=>{t.send(Yr,{text:V,suggestion:{source:"knowledge-assist",text:V}}),e(ut({name:"answer used",data:{originalText:V},options:{includeConversationData:!0}})),s(""),e(cn("search")),e(vs()),e(Lt(!1))},_t=V=>{Jn(V),e(Lt(!1))};function vr(V,Te){return V.slice(0,u?10:Te.toLowerCase()==="image"?mN:pN)}function Dt(V){return Te=>{r?window.confirm(n("warning"))&&(V(Te),o(!1)):V(Te)}}return(0,Nt.useEffect)(()=>{i?G(i,u):e(pd())},[i,u]),(0,Nt.useEffect)(()=>{a==="search"&&e(vs())},[a]),(0,Nt.useEffect)(()=>{f&&e(tl())},[f]),ZE(h,()=>e(Lt(!0))),!d||!l?null:(0,De.jsxs)(me,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Dt(V=>e(Lt(V))),onChangeType:V=>c(V),onChangePage:Dt(V=>e(cn(V))),selectedType:u,search:i,page:a,isOpen:C,types:[...D,...N],children:[(0,De.jsxs)(me.Page,{id:"search",children:[i.length===0&&(0,De.jsx)(Ob,{commands:_,onClick:Z}),i.length>0&&(0,De.jsxs)(Nt.Fragment,{children:[_.length>0&&(0,De.jsx)(me.List,{heading:n("commands"),children:_.map((V,Te)=>(0,De.jsx)(me.ListItem,{closeOnSelect:!1,onClick:V.onClick,id:`commands-${Te}`,children:V.label},V.label))}),[...D,...N].map(({value:V,label:Te,list:ve,lineClamp:Sr,listOrientation:Se})=>(0,De.jsx)(me.List,{heading:Te,orientation:Se==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(V),hasMore:!u&&k[V.toLowerCase()]>vr(ve,V).length,children:vr(ve,V).map(ke=>(0,De.jsx)(me.ListItem,{id:`${V}-${ke.id}`,closeOnSelect:!1,lineClamp:Sr,onClick:()=>Z(ke.text,ke),description:V!=="IMAGE"?ke.title&&ke.text:void 0,extra:p&&(0,De.jsx)(me.ListItemActions,{children:(0,De.jsx)(Qd,{context:i,source:"search",suggestion:ke})}),children:V==="IMAGE"?(0,De.jsx)(me.Image,{title:ke.title||ke.text,src:ke.image}):ke.title||ke.text},`${ke.id}-${ke.text}`))},V))]})]}),(0,De.jsx)(me.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Dt(()=>{e(cn("search"))}),children:(0,De.jsx)(nb,{onCopy:ie})}),(0,De.jsx)(me.Page,{id:"summary",title:n("summaryTitle"),onDismiss:Dt(()=>{e(cn("search"))}),children:(0,De.jsx)(mb,{onCopy:_t})}),(0,De.jsx)(me.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Dt(()=>{e(vs()),e(cn("search"))}),children:(0,De.jsx)(Eb,{question:i,onUse:yr,onResetQuestion:()=>{e(vs()),s("")}})})]})},Ub=gN;var hl=w(b()),hN=()=>{let e=B("showSearch"),t=B("isEmbedded");return(0,hl.jsxs)(zb.Fragment,{children:[e&&(0,hl.jsx)(Ub,{}),t&&(0,hl.jsx)(bE,{})]})},Bb=hN;var Wb=w(oe());var Yd=w(b()),jb=({className:e})=>(0,Yd.jsx)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:e,children:(0,Yd.jsx)("g",{children:(0,Yd.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
19
+ `),o=o.replace(/\n/g,"<br/>"),o}createContainer(t){var n;let o=(typeof global!="undefined"&&global.INTERWEAVE_SSR_POLYFILL||xO)();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(vO)||(s.innerHTML=this.convertLineBreaks(this.props.escapeHtml?(0,HE.default)(t):t)),s}extractAttributes(t){let{allowAttributes:n}=this.props,r={},o=0;return t.nodeType!==FE||!t.attributes||([...t.attributes].forEach(i=>{let{name:s,value:a}=i,l=s.toLowerCase(),u=Dd[l]||Dd[s];if(!this.isSafe(t)||!l.match(SO)&&(!n&&(!u||u===Ah)||l.startsWith("on")||a.replace(/(\s|\0|&#x0([9AD]);)/,"").match(/(javascript|vbscript|livescript|xss):/i)))return;let c=l==="style"?this.extractStyleAttribute(t):a;u===Zr?c=!0:u===Fo?c=Number.parseFloat(String(c)):u!==_d&&(c=String(c)),r[Lh[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 il[t]?I(T(T({},n),il[t]),{tagName:t}):n}isSafe(t){if(typeof HTMLAnchorElement!="undefined"&&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===FE){let d=c.nodeName.toLowerCase(),p=this.getTagConfig(d);u&&(l.push(u),u="");let v=this.applyNodeFilters(d,c);if(!v)return;let y;if(s&&!(a&&!this.isTagAllowed(d))){this.keyIndex+=1;let m=this.keyIndex;y=this.parseNode(v,p);let g=s(v,y,p);if(g===null)return;if(typeof g!="undefined"){l.push(Uo.default.cloneElement(g,{key:m}));return}this.keyIndex=m-1}if(this.banned.has(d))return;if(!(r||o&&d!=="br")&&this.isTagAllowed(d)&&(i||this.canRenderChild(n,p))){var f;this.keyIndex+=1;let m=this.extractAttributes(v),g={tagName:d};m&&(g.attributes=m),p.void&&(g.selfClose=p.void),l.push(Uo.default.createElement(Fd,I(T({},g),{key:this.keyIndex}),(f=y)!==null&&f!==void 0?f:this.parseNode(v,p)))}else l=[...l,...this.parseNode(v,p.tagName?p:n)]}else if(c.nodeType===yO){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(wO);){let[s,a]=i,l=i.index,u=s.includes("/");l>0&&(r.push(o.slice(0,l)),o=o.slice(l));let{children:c,matcher:f,props:d}=n[a],p;if(u)p=s.length,r.push(f.createElement(c,d));else{let v=o.match(new RegExp(`{{{/${a}}}}`));p=v.index+v[0].length,r.push(f.createElement(this.replaceTokens(o.slice(s.length,v.index),n),d))}o=o.slice(p)}return o.length>0&&r.push(o),r.length===0?"":r.length===1&&typeof r[0]=="string"?r[0]:r}};function EO(e){var t;let{attributes:n,className:r,containerTagName:o,content:i,emptyContent:s,parsedContent:a,tagName:l,noWrap:u}=e,c=(t=o!=null?o:l)!==null&&t!==void 0?t:"span",f=c==="fragment"?!0:u,d;if(a)d=a;else{let p=new Hd(i!=null?i:"",e).parse();p.length>0&&(d=p)}return d||(d=s),f?Uo.default.createElement(Uo.default.Fragment,null,d):Uo.default.createElement(Fd,{attributes:n,className:r,tagName:c},d)}function ls(e){let k=e,{attributes:t,className:n,content:r="",disableFilters:o=!1,disableMatchers:i=!1,emptyContent:s=null,filters:a=[],matchers:l=[],onAfterParse:u=null,onBeforeParse:c=null,tagName:f="span",noWrap:d=!1}=k,p=ee(k,["attributes","className","content","disableFilters","disableMatchers","emptyContent","filters","matchers","onAfterParse","onBeforeParse","tagName","noWrap"]),v=i?[]:l,y=o?[]:a,m=c?[c]:[],g=u?[u]:[];v.forEach(C=>{C.onBeforeParse&&m.push(C.onBeforeParse.bind(C)),C.onAfterParse&&g.push(C.onAfterParse.bind(C))});let h=m.reduce((C,R)=>R(C,e),r!=null?r:""),S=new Hd(h,p,v,y),x=g.reduce((C,R)=>R(C,e),S.parse());return Uo.default.createElement(EO,{attributes:t,className:n,containerTagName:e.containerTagName,emptyContent:s,noWrap:d,parsedContent:x.length===0?void 0:x,tagName:f})}var WE=w(U());var bO=/[.*+?^${}()|[\]\\]/g,CO=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function TO(e){return e.replace(bO,"\\$&")}function kO(e,t){let n=e.split("").findIndex((r,o)=>r!==t[o]);return n>-1?n:Math.min(e.length,t.length)}function PO(e){return e.search(CO)}function UE(e,t=[]){let n=e;return t.forEach(r=>{if(!r)return;let o=new RegExp(`\\b(${TO(r)})\\b`,"gi");n=n.replace(o,"<strong>$1</strong>")}),n}function zE(e){return e.replace(iu,'<mark data-type="placeholder">$1</mark>')}function us(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function RO(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 Oh(e,t,n={}){if(t){let r=kO(t.toLowerCase(),e.toLowerCase()),o=us(e.substring(r,e.length));if(n.stripAgentPart){let l=e.substring(0,r),u=PO(l);return`<span style="opacity: 0.5">${l.substring(u+1)}</span>${o}`}let s=t.split(t0).length>3||t.length>30?RO(t.trim(),r):0;return`${`${s>0?"\u2026":""}${us(e.substring(s,r))}`}<strong>${o}</strong>`}return e}var AO=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function Ud(e){return AO.test(e)}function BE(e){var n;let t=document.createElement("template");return t.innerHTML=e,(n=t.content.textContent)!=null?n:""}var zd=w(U()),KE=w(b()),jE=zd.default.createContext(void 0);function Jr(){let e=zd.default.useContext(jE);if(e===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return e}var VE=({children:e,page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i})=>{let s=zd.default.useMemo(()=>({page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i}),[n,t,o]);return(0,KE.jsx)(jE.Provider,{value:s,children:e})};var Yt=w(b()),LO=3,$E=({children:e})=>{let t=L("CommandPalette",Ot);return(0,Yt.jsx)("div",{className:t.listItemActions,children:e})};function Nh(d){var p=d,{closeOnSelect:e=!0,lineClamp:t,children:n,onClick:r,extra:o,onSourceClick:i,description:s,sources:a,id:l,styles:u,defaultSourcesAmount:c=LO}=p,f=ee(p,["closeOnSelect","lineClamp","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var k;let v=q(er),[y,m]=(0,WE.useState)(!1),{selected:g,onChangeOpen:h}=Jr(),S=L("CommandPalette",Ot);function x(C){r(C),e&&h(!1)}return(0,Yt.jsxs)("div",{className:(0,cs.default)(S.listItem,l===g&&S.listItemSelected),children:[(0,Yt.jsx)("button",I(T({type:"button",className:(0,cs.default)(S.listItemAction,S.listItemPrimaryAction),"aria-disabled":(k=f.disabled)!=null?k:!1,onClick:x,"data-command-palette-item":!0,"data-item-id":l},f),{children:(0,Yt.jsxs)("div",{className:S.listItemContent,children:[typeof n=="string"?(0,Yt.jsx)("p",{className:(0,cs.default)(S.listItemText,S.truncate,u==null?void 0:u.title),children:n}):n,s&&(0,Yt.jsx)(ls,{tagName:"p",allowList:[],content:Ud(s)?BE(s):s,className:(0,cs.default)(S.listItemDescription,u==null?void 0:u.description,t?S.lineClamp:S.truncate)})]})})),o,a&&a.length>0&&(0,Yt.jsxs)("div",{className:S.sources,children:[(0,Yt.jsx)("span",{className:S.sourcesTitle,children:v("sources")}),a.slice(0,y?a.length:c).map(C=>(0,Yt.jsx)("a",{className:S.source,href:C.url,target:"_blank",title:C.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i&&i(C),children:C.name},C.url)),!y&&a.length>c&&(0,Yt.jsx)("button",{className:(0,cs.default)(S.source,S.sourceShowMore),type:"button",onClick:()=>m(!0),children:v("showMore",{amount:a.length-c})})]})]})}var sl=w(b()),qE=()=>(0,sl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,sl.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,sl.jsx)("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});var zo=w(b());function Mh({children:e,title:t,id:n,onDismiss:r}){let o=q(er),i=L("CommandPalette",Ot),{page:s}=Jr();return s!==n?null:(0,zo.jsxs)("div",{className:i.page,id:`page_${n}`,tabIndex:-1,children:[r&&(0,zo.jsxs)("div",{className:i.pageNav,children:[(0,zo.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:r,children:[(0,zo.jsx)(qE,{}),o("back")]}),t&&(0,zo.jsx)("h3",{className:i.pageTitle,children:t})]}),e]})}var GE=w(U());var al=w(b()),ds=()=>(0,al.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,al.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,al.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 mn=w(b());function IO({onChange:e,onChangeType:t,placeholder:n,typePlaceholder:r,types:o,value:i,selectedType:s},a){let l=L("CommandPalette",Ot);return(0,mn.jsxs)("div",{className:l.search,children:[(0,mn.jsx)("div",{className:l.searchIcon,children:(0,mn.jsx)(ds,{})}),(0,mn.jsxs)("div",{className:l.searchInputWrapper,children:[(0,mn.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:u=>{e(u.currentTarget.value)},onFocus:u=>{u.currentTarget.select()},className:l.searchInput,placeholder:n,value:i,type:"text",id:"command-palette-search-input",autoFocus:!0}),o&&o.length>0&&(0,mn.jsx)("div",{className:l.selectWrapper,children:(0,mn.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,mn.jsx)("option",{children:r}),o.map(u=>(0,mn.jsx)("option",{value:u.value,children:u.label},u.value))]})})]})]})}var QE=(0,GE.forwardRef)(IO);var _h=w(oe());var Bd=w(b()),OO=o=>{var i=o,{onClick:e,shortKeys:t,children:n}=i,r=ee(i,["onClick","shortKeys","children"]);let s=L("CommandPalette",Ot);return(0,Bd.jsxs)("button",I(T({type:"button"},r),{onClick:e,className:(0,_h.default)(s.actionButton,r.className,{[s.hasShortKeys]:t&&t.length>0}),children:[n,t&&t.map(a=>(0,Bd.jsx)("span",{className:(0,_h.default)(s.actionShortcut,a===8629&&s.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},YE=OO;var ll=w(b()),NO="[data-command-palette-item]";function Bo({placeholder:e="Start typing to search...",typePlaceholder:t="All types",defaultPage:n="search",page:r,onChangePage:o,onChangeSearch:i,onChangeType:s,onChangeOpen:a,selectedType:l,types:u,children:c,isOpen:f,search:d}){let[p,v]=(0,rr.useState)(),y=(0,rr.useRef)(null),m=()=>{o&&o(n),s(void 0),i(""),a(!1)},g=()=>{var D;if(r!==n&&o){o(n);return}if(l&&s){s(void 0),(D=y.current)==null||D.focus();return}if(d.length>0){i("");return}a(!1)},h=()=>{let D=S();D.length!==0&&v(D[0].dataset.itemId)},S=()=>Array.from(document.querySelectorAll(NO)||[]),x=D=>document.querySelector(`[data-item-id=${D}]`),k=D=>{let G=x(D);G&&v(G.dataset.itemId)},C=D=>{let G=x(D);G&&G.scrollIntoView({behavior:"smooth"})},R=()=>{if(!p)return;let D=S(),G=x(p);if(!G)return;let Z=D.indexOf(G),ie=D[Z+1];ie&&ie.dataset.itemId?k(ie.dataset.itemId):h()},N=()=>{if(!p)return;let D=S(),G=x(p);if(!G)return;let Z=D.indexOf(G),ie=D[Z-1];ie&&ie.dataset.itemId?k(ie.dataset.itemId):k(D[D.length-1].dataset.itemId)},_=(0,rr.useCallback)(D=>{switch(D.key){case"ArrowDown":{D.preventDefault(),R();break}case"ArrowUp":{D.preventDefault(),N();break}case"Enter":{if(p){let G=x(p);G==null||G.click()}break}}},[p]);return(0,rr.useEffect)(()=>{h()},[d,r,l,f]),(0,rr.useEffect)(()=>{p&&C(p)},[p]),(0,ll.jsx)(Ad,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:f,onBack:g,onClose:m,onKeyDown:_,children:(0,ll.jsxs)(VE,{selected:p,setSelected:v,isOpen:f,onChangeOpen:a,page:r,children:[r===n&&(0,ll.jsx)(QE,{ref:y,onChange:i,onChangeType:s,placeholder:e,value:d,selectedType:l,types:u,typePlaceholder:t}),c]})})}Bo.Page=Mh;Bo.List=bh;Bo.Image=IE;Bo.ListItem=Nh;Bo.ListItemActions=$E;Bo.Button=YE;var me=Bo;var XE=w(U());function ZE(e,t){(0,XE.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 ul=w(U());var JE={data:null,fetchState:"idle"},jd=e=>{var i,s,a,l;let t=[],{visitorName:n}=(i=e.info.visitorInfo)!=null?i:{},{agentName:r,agentNickname:o}=(s=e.info.agentInfo)!=null?s:{};return r&&r!==n&&t.push(r),o&&o!==n&&t.push(o),(l=(a=e.entities.data)==null?void 0:a.filter(u=>!t.includes(u.text)))!=null?l:null},gn=K("entities/getEntities",(e,t)=>P(void 0,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra;if(!r.conversationQuery)return Promise.resolve([]);let o=r.conversationQuery,i=yield o();return i.length===0?Promise.resolve([]):n.getEntities(i)})),MO=e=>e.filter((t,n)=>n===e.findIndex(r=>r.text===t.text)),_O=X({name:"entities",initialState:JE,reducers:{},extraReducers:e=>{e.addCase(gn.pending,t=>{t.fetchState="loading"}).addCase(gn.rejected,t=>{t.fetchState="error"}).addCase(gn.fulfilled,(t,n)=>{t.fetchState="done",t.data=MO(t.data?[...t.data,...n.payload]:n.payload)}).addCase(de,()=>JE)}}),eb=_O.reducer;var Dh={};Qe(Dh,{enUS:()=>DO,nlNL:()=>FO});var DO={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},FO={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var tb={root:"dd-TYTKs",empty:"dd-AU7uT"};var fs=w(b()),HO=({onCopy:e})=>{let t=(0,ul.useRef)(null),n=L("EntitiesList",tb),r=M(jd),{setSelected:o}=Jr(),i=q(Dh),s=Q();return(0,ul.useEffect)(()=>{s(gn())},[]),(0,ul.useEffect)(()=>{t.current&&(t.current.focus(),o("entity-0"))},[t]),(0,fs.jsxs)("div",{className:n.root,ref:t,tabIndex:-1,children:[r&&r.length>0&&(0,fs.jsx)(me.List,{children:r.map((a,l)=>(0,fs.jsx)(me.ListItem,{id:`entity-${l}`,closeOnSelect:!0,onClick:()=>e(a),children:a.text},a.text))},"entities"),r&&r.length===0&&(0,fs.jsx)("p",{className:n.empty,children:i("noResults")})]})},nb=HO;var Xt=w(U());var Fh={outputs:[],fetchState:"idle"},rb=e=>{var t;return(t=e.assistants)==null?void 0:t.outputs},UO=be("assistants/resetOutputs"),Vd=be("assistants/callToAction"),ps=K("assistants/getSummary",(e,t)=>P(void 0,null,function*(){var i,s,a;let n=t.getState();if(!n.profile.data)throw new Error("No Profile is loaded");let{summarizerAssistantNew:r}=n.profile.data;if(!r){let{deepdeskAPI:l,dynamicThunkObject:u}=t.extra,c=t.getState(),f=(i=c.conversation.current)==null?void 0:i.sessionId,d=(a=(s=c.info)==null?void 0:s.agentInfo)==null?void 0:a.agentId,p=c.profile.data;if(!p)throw new Error("Profile is not defined");if(!u.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let v=u.conversationQuery,y=yield v(),m=yield l.getSummary(y,{externalConversationId:f,agentId:d,promptInstruction:p.summarizerPromptInstruction,model:p.summarizerModel});return m.summary?m.summary:Promise.reject(new Error("Summary is not provided"))}let o=yield t.dispatch(eo(T({assistantCode:r,transcript:"in-memory-transcript",skipState:!0},e)));if(o.error)throw new Error(o.error.message);if(typeof o.payload!="string")throw H.warn("Unexpected summary output",o),new Error("Unexpected summary output");return o.payload})),eo=K("assistants/evaluate",(e,t)=>P(void 0,null,function*(){var f;let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra,{transcript:o,input:i={}}=e,s=t.getState(),{platformVariables:a}=s.info,l=(f=s.conversation.current)==null?void 0:f.sessionId,u;if(o==="in-memory-transcript"){if(!r.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");u=yield r.conversationQuery()}else if(o==="stored-transcript"){if(!s.conversation.current)throw new Error("Can't include stored-transcript, no current conversation");u=s.conversation.current.messages.map(d=>({text:d.text,source:d.source}))}else Array.isArray(o)&&(u=o);if(e.includeTags){if(!s.conversation.current)throw new Error("Can't include tags, no current conversation");let{tags:d}=s.conversation.current;Object.assign(i,{tags:d})}let c=yield n.evaluateAssistant(e.assistantCode,{input:i,transcript:u,conversationId:l});return a&&(c=Array.isArray(c)?c.map(d=>I(T({},d),{name:rt(d.name,a),response:rt(d.response,a)})):rt(c,a)),c})),ob=X({name:"assistants",initialState:Fh,reducers:{removeOutputByCode(e,t){e.outputs=e.outputs.filter(n=>n.code!==t.payload.code)}},extraReducers:e=>{e.addCase(eo.pending,(t,n)=>{n.meta.arg.skipState||(t.fetchState="loading")}).addCase(eo.rejected,(t,n)=>{n.meta.arg.skipState||(t.fetchState="error")}).addCase(eo.fulfilled,(t,n)=>{if(n.meta.arg.skipState)return;if(!Array.isArray(n.payload))throw H.warn("Unexpected assistant output",n.payload),new Error("Unexpected assistant output");let r=n.payload.map(i=>i.code),o=t.outputs.filter(i=>!r.includes(i.code));t.fetchState="done",t.outputs=[...n.payload,...o]}).addCase(de,()=>Fh).addCase(UO.toString(),()=>Fh)}}),{removeOutputByCode:ib}=ob.actions,sb=ob.reducer;var Hh={};Qe(Hh,{enUS:()=>zO,nlNL:()=>BO});var zO={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."}]},BO={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 ab={root:"dd-60NZr",actions:"dd-No1g3",main:"dd-l-xEF",textInput:"dd-nAaiV",loading:"dd-ciFNi",error:"dd-yNp2D"};var Kd=w(oe()),db=w(U());var Uh=w(b()),zh=e=>(0,Uh.jsx)("svg",I(T({width:"16",height:"16",fill:"#000000"},e),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Uh.jsx)("path",{fillRule:"evenodd",d:"M6.57086468,14.9173453 C6.38997052,14.9711236 6.19835748,15 6,15 L4,15 C2.8954305,15 2,14.1045695 2,13 L2,4 C2,2.8954305 2.8954305,2 4,2 L6,2 C6.68685475,2 7.29284112,2.34623869 7.65294381,2.87370078 C7.95642355,2.67736738 8.29504785,2.51351337 8.66312366,2.3818197 C9.50544052,2.08044754 10.3408482,1.9879107 10.9989281,1.99971266 C11.0150698,2.00005426 13.3487605,2.00015005 18,2 C20.7551411,2 22,6.05643086 22,12 C22,13.6824804 20.8695981,15 19,15 L15.9269768,15 C15.9359266,15.0245465 15.9451954,15.0497804 15.9547911,15.0757271 C16.007193,15.2174219 16.2391583,15.8256341 16.2970775,15.9810953 C16.4872151,16.4914441 16.6259612,16.9026411 16.7382242,17.3098712 C16.9079007,17.9253665 17,18.4798886 17,19 C17,20.4720069 16.091867,21.3862822 14.748281,21.777514 C14.1422801,21.9539723 13.6147967,22.0000922 13.0076976,22.0000008 L12.5204954,22 L12.2202699,21.6261158 C11.2556275,20.4248034 7.64562469,16.4822788 6.57086468,14.9173453 Z M8,13 C8,13.2401953 8.04443154,13.4528921 8.14171093,13.6800176 C8.40663864,14.2985643 11.914268,18.1371493 13.4599624,19.9848695 C13.7113931,19.9660111 13.9483736,19.9273712 14.1891338,19.8572655 C14.7621788,19.6904035 15,19.4509737 15,19 C15,18.6834183 14.9359344,18.2976852 14.8101464,17.8413935 C14.7161494,17.500423 14.5944107,17.1396301 14.4229225,16.6793379 C14.3689242,16.5344009 14.1358033,15.923159 14.0789589,15.7694517 C13.9489218,15.4178313 13.8632547,15.1589343 13.8046536,14.9236885 C13.5555377,13.9236468 13.8054549,13 15,13 L19,13 C19.6912225,13 20,12.6401099 20,12 C20,7.20925475 19.015127,4 18,4 C15.9322103,4 15.9322103,4 10.9655994,3.99940813 C10.5253746,3.99154158 9.91062406,4.05963657 9.33687634,4.2649175 C8.45196659,4.58152894 8,5.09776992 8,6 L8,13 Z M4,4 L4,13 L6,13 L6,4 L4,4 Z"})}));var Bh=w(b()),lb=e=>(0,Bh.jsx)("svg",I(T({width:"16",height:"16",fill:"#000000"},e),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Bh.jsx)("path",{fillRule:"evenodd",d:"M7.65336736,21.1256786 C7.2933164,21.6534897 6.68712411,22 6,22 L4,22 C2.8954305,22 2,21.1045695 2,20 L2,11 C2,9.8954305 2.8954305,9 4,9 L6,9 C6.198171,9 6.38961023,9.02882212 6.57035446,9.08250314 C7.6444817,7.51807482 11.2554748,3.57449216 12.2202699,2.37298955 L12.5204954,1.99910538 L13,1.99910538 C13.6147967,1.99901314 14.1422801,2.04513312 14.748281,2.22159137 C16.091867,2.61282321 17,3.52709845 17,4.99910538 C17,5.51921677 16.9079007,6.07373891 16.7382242,6.68923415 C16.6259612,7.09646424 16.4872151,7.50766133 16.2970775,8.01801005 C16.2391583,8.17347129 16.007193,8.78168345 15.9547911,8.92337824 C15.9451954,8.94932503 15.9359266,8.9745589 15.9269768,8.99910538 L19,8.99910538 C20.8695981,8.99910538 22,10.316625 22,11.9991054 C22,17.9426745 20.7551411,21.9991054 18,21.9991054 L11.0344006,21.9985135 C10.3408482,22.0111947 9.50544052,21.9186578 8.66312366,21.6172857 C8.29521907,21.4856533 7.9567386,21.3218904 7.65336736,21.1256786 Z M8,17.9991054 C8,18.9013355 8.45196659,19.4175764 9.33687634,19.7341879 C9.91062406,19.9394688 10.5253746,20.0075638 10.963066,19.9997143 C10.9703499,19.9995545 10.9703499,19.9995545 11,19.9991054 L18,19.9991054 C19.015127,19.9991054 20,16.7898506 20,11.9991054 C20,11.3589955 19.6912225,10.9991054 19,10.9991054 L15,10.9991054 C13.8054549,10.9991054 13.5555377,10.0754586 13.8046536,9.07541689 C13.8632547,8.84017106 13.9489218,8.5812741 14.0789589,8.22965366 C14.1358033,8.07594642 14.3689242,7.46470447 14.4229225,7.31976744 C14.5944107,6.85947528 14.7161494,6.4986824 14.8101464,6.1577119 C14.9359344,5.70142019 15,5.31568707 15,4.99910538 C15,4.54813166 14.7621788,4.30870189 14.1891338,4.1418399 C13.9483736,4.07173418 13.7113931,4.0330943 13.4599624,4.01423587 C11.914268,5.86195611 8.40663864,9.70054105 8.14171093,10.3190878 C8.04443154,10.5462133 8,10.7589101 8,10.9991054 L8,17.9991054 Z M4,11 L4,20 L6,20 L6,11 L4,11 Z"})}));function ms(e,t){var o;let n=e.cloneNode(!0);n.style.top=`${e.offsetTop}px`,n.style.left=`${e.offsetLeft}px`,n.style.position="absolute",t.split(" ").forEach(i=>{n.classList.add(i)}),n.addEventListener("animationend",()=>n.remove()),(o=e.parentElement)==null||o.appendChild(n)}var jh={};Qe(jh,{enUS:()=>jO,nlNL:()=>VO});var jO={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},VO={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};function ub(e){return K("analytics/logEvent",(t,n)=>{var i,s,a;let r=(s=(i=n.getState())==null?void 0:i.conversation.current)==null?void 0:s.id,o=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(t.name,I(T({conversationId:r},o),{data:t.data}))})(e)}function gs(){let e=Q();return(t,n)=>P(this,null,function*(){yield e(ub({name:t,data:n}))})}var cb={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};var hs=e=>t=>{let{passwordlessToken:{token:n},settings:{isEmbedded:r,adminUrl:o}}=t,i=o||window.location.origin;return r&&!n?null:r&&n?`${i}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(e)}`:`${i}${e}`};var or=w(b()),KO=({eventName:e,eventData:t,feedbackType:n,feedbackText:r})=>{let o=L("FeedbackThumbs",cb),i=B("enableFeedbackForm"),s=M(Gr),a=M(hs(`/admin/feedback?conversationId=${s}&type=${n}&text=${r}&data=${JSON.stringify(t)}`)),l=q(jh),u=gs(),[c,f]=(0,db.useState)(null),d=v=>{v.stopPropagation(),ms(v.target,o.fadeup),f("up"),u(e,I(T({},t),{rating:"up"}))},p=v=>{v.stopPropagation(),ms(v.target,o.fadedown),f("down"),u(e,I(T({},t),{rating:"down"}))};return(0,or.jsxs)("div",{className:o.thumbs,children:[(0,or.jsx)(re.Button,{title:l("thumbsUp"),onClick:d,icon:(0,or.jsx)(lb,{}),className:(0,Kd.default)(o.thumbsUp,c==="up"&&o.selected),disabled:!!c}),i&&a?(0,or.jsx)(re.Button,{as:"a",title:l("thumbsDown"),href:a,target:"_blank",rel:"noreferrer",onClick:p,icon:(0,or.jsx)(zh,{}),className:(0,Kd.default)(o.thumbsDown,c==="down"&&o.selected),disabled:!!c}):(0,or.jsx)(re.Button,{title:l("thumbsDown"),onClick:p,icon:(0,or.jsx)(zh,{}),className:(0,Kd.default)(o.thumbsDown,c==="down"&&o.selected),disabled:!!c})]})},ys=KO;var WO={data:null,fetchState:"idle"},hn=e=>e.profile.data,Wd=e=>e.profile.data?e.profile.data.uiConfig.widget.types.filter(t=>t.isActive):[],fb=e=>e.profile.data?!!e.profile.data.uiConfig.widget.types.find(t=>t.type==="custom-data"):!1,cl=K("profile/getProfile",(e,t)=>P(void 0,null,function*(){var i;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");return((i=r.profile.data)==null?void 0:i.code)===o.profileCode?r.profile.data:n.getProfile(o.profileCode)})),$O=X({name:"profile",initialState:WO,reducers:{},extraReducers:e=>{e.addCase(cl.pending,t=>{t.fetchState="loading"}).addCase(cl.rejected,t=>{t.fetchState="error"}).addCase(cl.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),pb=$O.reducer;var In=w(b()),qO=({onCopy:e})=>{let t=(0,Xt.useRef)(null),n=L("SummaryForm",ab),[r,o]=(0,Xt.useState)(""),[i,s]=(0,Xt.useState)(""),[a,l]=(0,Xt.useState)(!1),u=M(hn),c=q(Hh),f=Q(),d=()=>{f(ut({name:"summary copied to clipboard",data:{originalText:r,finalText:i},options:{includeConversationData:!0}})),e(i)},p=()=>{let v=document.getSelection();v&&f(ut({name:"summary copied to clipboard",data:{originalText:r,finalText:v==null?void 0:v.toString(),assistant:u==null?void 0:u.summarizerAssistantNew},options:{includeConversationData:!0}}))};return(0,Xt.useEffect)(()=>{f(ps({})).then(v=>{if(v.error){l(!0);return}o(v.payload||""),s(v.payload||"")})},[]),(0,Xt.useEffect)(()=>{t.current&&r&&t.current.focus()},[t,r]),(0,Xt.useEffect)(()=>{let v=y=>{y.key==="Enter"&&y.shiftKey&&d()};return document.addEventListener("keydown",v),()=>{document.removeEventListener("keydown",v)}},[i]),(0,In.jsx)("div",{className:n.root,tabIndex:-1,children:a?(0,In.jsx)("p",{className:n.error,children:c("error")}):(0,In.jsxs)(Xt.Fragment,{children:[(0,In.jsx)("div",{className:n.main,children:(0,In.jsx)("textarea",{placeholder:r?void 0:c("loading"),disabled:!r,className:n.textInput,ref:t,value:i,onCopy:p,onChange:v=>s(v.target.value)})}),(0,In.jsxs)("div",{className:n.actions,children:[(0,In.jsx)(ys,{feedbackText:r||"",feedbackType:"summary",eventName:"summary feedback",eventData:{summary:r}}),(0,In.jsx)(me.Button,{shortKeys:[8679,8629],onClick:d,children:c("copy")})]})]})})},mb=qO;var dl={};Qe(dl,{enUS:()=>GO,nlNL:()=>QO});var GO={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},QO={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var ir=w(U());var Vh={};Qe(Vh,{enUS:()=>YO,nlNL:()=>XO});var YO={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"}]},XO={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 gb={root:"dd-fxP4c",title:"dd-vDbMh",empty:"dd-sB0lz",status:"dd--oZ1C",form:"dd-t0hnD",input:"dd-i1v3W",submit:"dd-oo2Oa",question:"dd-WvK17",answer:"dd-HAHcU",alignRight:"dd-oxrX3",listItemFeedback:"dd-POUal"};var ZO={data:null,fetchState:"idle"},hb=e=>{var t;return(t=e.knowledgeAssistant)==null?void 0:t.data},fl=K("knowledgeAssistant/getKnowledgeAssistant",(e,t)=>P(void 0,null,function*(){var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");let i=(s=r.profile.data)==null?void 0:s.knowledgeAssistant;return i?n.getKnowledgeAssistant(i):null})),JO=X({name:"knowledgeAssistant",initialState:ZO,reducers:{},extraReducers:e=>{e.addCase(fl.pending,t=>{t.fetchState="loading"}).addCase(fl.rejected,t=>{t.fetchState="error"}).addCase(fl.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),yb=JO.reducer;var Kh={data:[],fetchState:"idle"},vb=e=>{var t;return(t=e.answer)==null?void 0:t.data},Sb=e=>e.answer.fetchState,vs=be("answer/resetKnowledgeSearch"),pl=K("answer/getAnswer",(e,t)=>P(void 0,null,function*(){var u,c,f;let{deepdeskAPI:n}=t.extra,r=t.getState().answer.data,{platformVariables:o}=t.getState().info,i=hb(t.getState()),s=(u=t.getState().conversation.current)==null?void 0:u.sessionId,a=(f=(c=t.getState().info)==null?void 0:c.agentInfo)==null?void 0:f.agentId;if(!i)throw new Error("KnowledgeAssistant is not defined");let l=yield n.knowledgeAssist({customerInstruction:i.customerInstruction,doNotKnowAnswer:i.doNotKnowAnswer,question:e},r,i.code,{agentId:a,conversationId:s});return o&&(l.answer=rt(l.answer,o)),{question:e,answer:l}})),eN=X({name:"answer",initialState:Kh,reducers:{},extraReducers:e=>{e.addCase(pl.pending,t=>{t.fetchState="loading"}).addCase(pl.rejected,t=>{t.fetchState="error"}).addCase(pl.fulfilled,(t,n)=>{t.fetchState="done",t.data=[...t.data,n.payload]}).addCase(de,()=>Kh).addCase(vs,()=>Kh)}}),wb=eN.reducer;var ml=w(b()),xb=()=>(0,ml.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,ml.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,ml.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 ct=w(b()),tN=({onUse:e,onResetQuestion:t,question:n})=>{let[r,o]=ir.default.useState(""),[i,s]=ir.default.useState(!1),{setSelected:a}=Jr(),l=(0,ir.useRef)(null),u=L("KnowledgeSearchStyles",gb),c=q(Vh),f=Q(),d=M(vb),p=M(Sb),v=g=>P(void 0,null,function*(){s(!0),yield f(pl(g)),l.current&&s(!1)}),y=g=>P(void 0,null,function*(){g.preventDefault(),g.stopPropagation(),r!==""&&v(r)}),m=(g,h)=>{f(ut({name:"knowledge assist source viewed",data:{question:h,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return(0,ir.useEffect)(()=>{var g;n&&p==="idle"?v(n):(g=l.current)==null||g.focus()},[l,p]),(0,ir.useEffect)(()=>{p==="done"&&(f(ut({name:"knowledge assist question answered",data:{question:r||n,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),a(`knowledge-assist-${d.length-1}`),o(""))},[p,d]),(0,ir.useEffect)(()=>{l.current&&l.current.scrollIntoView({behavior:"smooth"})},[l,d]),(0,ct.jsxs)("div",{className:u.root,children:[d.length>0&&(0,ct.jsx)("div",{className:u.alignRight,children:(0,ct.jsx)(me.Button,{onClick:t,children:c("reset")})}),d.map(({question:g,answer:h},S)=>(0,ct.jsx)(me.List,{children:(0,ct.jsx)(me.ListItem,{id:`knowledge-assist-${S}`,"data-testid":"knowledge-search-answer",description:h.answer,closeOnSelect:!0,onClick:()=>e(h.answer),onSourceClick:x=>m(x,g),sources:h.sources,styles:{title:u.question,description:u.answer},extra:(0,ct.jsx)("div",{className:u.listItemFeedback,children:(0,ct.jsx)(ys,{feedbackText:h.answer,feedbackType:"knowledge-assist-answer",eventName:"knowledge assist feedback",eventData:T({question:g,isAgent:n!==g,isFollowUpQuestion:d.length>1},h)})}),children:g})},`${h.answer}_${S}`)),p==="loading"&&(0,ct.jsx)("p",{className:u.status,children:c("loading")}),p==="error"&&(0,ct.jsx)("p",{className:u.status,children:c("error")}),(0,ct.jsxs)("form",{className:u.form,onSubmit:y,children:[(0,ct.jsx)("input",{ref:l,placeholder:c("anotherQuestion"),className:u.input,type:"text",value:r,onFocus:()=>{a(void 0)},onChange:g=>{a(void 0),o(g.target.value)}}),(0,ct.jsx)("button",{type:"submit",className:u.submit,disabled:i,children:(0,ct.jsx)(xb,{})})]})]})},Eb=tN;var Ib=w(U());var nN=["{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}"],rN=new RegExp(nN.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function bb(e,t){let n=e.split(rN),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],l=i===n.length-2;r+=s.length;let u=r;if(l){let f=a.charAt(0),d=0;do u=f?t.indexOf(f,u+1):-1,d+=1;while(u!==-1&&a.indexOf(t.slice(u))!==0);if(u===-1&&d>2)return e}else u=a&&a!==""?t.indexOf(a,r):-1;let c=u===-1?t.slice(r):t.slice(r,u);o.push(c),r=u}return o.join("")}function Cb(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var kb={suggestions:[],fetchState:"idle"},Tb={default:kb},Pb=e=>t=>{var n,r;return(r=(n=t.textSuggestions[e])==null?void 0:n.suggestions)!=null?r:[]},$d=e=>e.textSuggestions,Rb=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},qd=be("textSuggestions/refresh"),yn=K("textSuggestions/recommendations",(e,t)=>P(void 0,null,function*(){var c;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(c=r.conversation.current)==null?void 0:c.id,{platformVariables:i}=r.info,{textSuggestionsCount:s,inlineSuggestions:a}=r.settings,l=is(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let u=yield n.getTextSuggestions(o,qa(r),e);if(i&&(u=u.map(f=>T(I(T({},f),{text:rt(f.text,i)}),f.title?{title:rt(f.title,i)}:{}))),e==="default"){let f=a?u.filter(Rb(l)):u;t.dispatch(Qr(f.slice(0,s)))}return u})),gl=K("textSuggestions/autocompletions",(e,t)=>P(void 0,null,function*(){var c;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(c=r.conversation.current)==null?void 0:c.id,{platformVariables:i}=r.info,{textSuggestionsCount:s,deanonymize:a,inlineSuggestions:l}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let u=yield n.getAutocompleteSuggestions(o,I(T({},qa(r)),{input:e}));if(!t.getState().input.text)throw new Error("Abort");return l&&(u=u.filter(Rb(e))),i&&(u=u.map(f=>I(T({},f),{text:rt(f.text,i)}))),a&&(u=u.map(f=>I(T({},f),{text:f.source!=="trie-with-typos"?bb(f.text,e):f.text}))),u=Cb(u,s),t.dispatch(Qr(u)),u})),Ab=X({name:"textSuggestions",initialState:Tb,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}}}}},extraReducers:e=>{e.addCase(yn.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||kb;return I(T({},t),{[r]:I(T({},o),{fetchState:"loading"})})}).addCase(yn.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(yn.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(gl.pending,t=>{t.default.fetchState="loading"}).addCase(gl.rejected,t=>{t.default.fetchState="error"}).addCase(gl.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(de,()=>Tb)}}),{setTextSuggestions:T7}=Ab.actions,Lb=Ab.reducer;var jo=w(b()),oN=({commands:e,onClick:t})=>{var a,l,u;let n=Q(),r=q(dl),o=M(hn),i=M($d),s=((u=(l=(a=o==null?void 0:o.uiConfig)==null?void 0:a.search)==null?void 0:l.initialTypes)==null?void 0:u.filter(({isActive:c})=>c))||[];return(0,Ib.useEffect)(()=>{s.forEach(({type:c})=>{(!i[c]||i[c].suggestions.length===0)&&n(yn(c))})},[]),(0,jo.jsxs)("div",{children:[e.length>0&&(0,jo.jsx)(me.List,{heading:r("commands"),children:e.map((c,f)=>(0,jo.jsx)(me.ListItem,{id:`command-${f}`,closeOnSelect:!1,onClick:c.onClick,children:c.label},c.label))}),s.map(({type:c,title:f})=>{var d;return(0,jo.jsx)(me.List,{heading:f,orientation:"vertical",children:(d=i[c])==null?void 0:d.suggestions.map((p,v)=>(0,jo.jsx)(me.ListItem,{id:`${c}-${v}`,closeOnSelect:!1,description:p.text,onClick:()=>t(p.text,p),"data-testid":"search-overlay-suggestion",children:p.title},`${p.id}-${p.text}`))},c)})]})},Ob=oN;var qe=w(U()),Nb=w(oe());var Wh={root:"dd-uVyL0",trigger:"dd-KIzQa",content:"dd-Ly3zO",contentOpen:"dd-O-8fR",contentTop:"dd-q3fGa",contentBottom:"dd-SFrvc",item:"dd-HZNy-"};var Vo=w(b()),iN=0,Mb=qe.default.createContext(null),sN=()=>{let e=(0,qe.useContext)(Mb);if(!e)throw new Error("Invalid DropdownContext");return e},_b=({trigger:e,children:t,position:n="bottom"})=>{let r=(0,qe.useMemo)(()=>++iN,[]),o=(0,qe.useRef)(null),i=(0,qe.useRef)(null),s=L("Dropdown",Wh),[a,l]=(0,qe.useState)(!1),[u,c]=(0,qe.useState)(n),f=p=>{p.preventDefault(),p.stopPropagation(),l(!a)},d=(0,qe.useCallback)(([p])=>{!p.isIntersecting&&a&&c(u==="top"?"bottom":"top")},[a]);return(0,qe.useEffect)(()=>{let p=v=>{o.current&&!o.current.contains(v.target)&&l(!1)};return document.addEventListener("click",p),()=>{document.removeEventListener("click",p)}},[]),(0,qe.useEffect)(()=>{if(!i.current&&!a)return()=>{};let p=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return i.current&&p.observe(i.current),()=>{i.current&&p.unobserve(i.current)}},[i,a]),(0,Vo.jsx)(Mb.Provider,{value:{setIsOpen:l},children:(0,Vo.jsxs)("div",{ref:o,className:s.root,children:[(0,Vo.jsx)("button",{id:`dropdown-${r}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:s.trigger,onClick:f,children:e}),(0,Vo.jsx)("div",{"data-testid":"dropdown-content",ref:i,"aria-hidden":!a,"aria-labelledby":`dropdown-${r}`,className:(0,Nb.default)(s.content,{[s.contentOpen]:a,[s.contentTop]:u==="top",[s.contentBottom]:u==="bottom"}),children:t})]})})};function aN(o){var i=o,{as:e,children:t,onClick:n}=i,r=ee(i,["as","children","onClick"]);let s=e||"button",a=L("Dropdown",Wh),{setIsOpen:l}=sN(),u=c=>{l(!1),n(c),c.stopPropagation()};return(0,Vo.jsx)(s,I(T({type:"button",className:a.item,onClick:u},r),{children:t}))}_b.Item=aN;var $h=_b;var qh=w(b()),Db=e=>(0,qh.jsx)("svg",I(T({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},e),{children:(0,qh.jsx)("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})}));var Ko={};Qe(Ko,{enUS:()=>lN,nlNL:()=>uN});var lN={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},uN={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var Gd=w(b()),cN=({suggestion:e,source:t,context:n})=>{let r=q(Ko),o=M(Gr),i=Q(),s=B("enableSuggestionFeedback"),a=`${e.text}`,l=M(hs(`/admin/feedback?conversationId=${o}&type=${t}&text=${a}&data=${JSON.stringify({context:n})}`)),u=()=>{i(ut({name:"suggestion feedback",data:{text:e.text,source:t,context:n},options:{includeConversationData:!0}}))};return!s||!l?null:(0,Gd.jsx)($h,{trigger:(0,Gd.jsx)(Db,{"data-testid":"feedback-dropdown-trigger"}),children:(0,Gd.jsx)($h.Item,{as:"a",onClick:u,target:"_blank",href:l,children:r("giveFeedback")})})},Qd=cN;var De=w(b()),fN=200,pN=5,mN=4,Fb=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),gN=()=>{let e=Q(),t=Qt(),n=q(dl),[r,o]=(0,Nt.useState)(!1),[i,s]=(0,Nt.useState)(""),a=M(J1),l=M(hn),[u,c]=(0,Nt.useState)(),f=M(lt),d=B("showSearch"),p=B("enableSuggestionFeedback"),v=B("showEntitiesCommand"),y=B("showSummaryCommand"),m=B("showKnowledgeSearch"),g=B("showImageSearch"),h=B("searchTriggerKey"),S=M(RE),x=M(eE),k=M(tE),C=M(Z1),R=V=>vr(x.filter(Te=>Te.type===V.toUpperCase()),V),N=[{value:"PERSONAL",label:n("personalSuggestions"),list:R("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:n("urlSuggestions"),list:R("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:R("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:R("IMAGE"),listOrientation:"horizontal",shouldShow:g}].filter(V=>V.shouldShow),_=[{label:n("entitiesClipboard"),onClick:()=>e(cn("entities")),shouldShow:v&&Fb(n("entitiesClipboard"),i)},{label:n("summaryClipboard"),onClick:()=>e(cn("summary")),shouldShow:y&&Fb(n("summaryClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(cn("knowledgeAssist")),shouldShow:m}].filter(V=>V.shouldShow),D=(S==null?void 0:S.map(V=>({value:V.code.toUpperCase(),label:`${V.name}s`,list:R(V.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],G=(0,Nt.useCallback)((0,Hb.default)((V,Te)=>{e(No({query:V,type:Te,tags:["search-overlay"],size:u?50:20}))},fN),[u]),Z=(0,Nt.useCallback)((V,Te)=>{switch(Te.type){case"IMAGE":t.send(uh,{suggestion:Te});break;default:t.send(Yr,{text:V,suggestion:Te})}e(Lt(!1))},[e]),ie=V=>{Jn(V.text),e(ut({name:"entity copied",data:{entity:V,type:"copy"}})),e(Lt(!1))},yr=V=>{t.send(Yr,{text:V,suggestion:{source:"knowledge-assist",text:V}}),e(ut({name:"answer used",data:{originalText:V},options:{includeConversationData:!0}})),s(""),e(cn("search")),e(vs()),e(Lt(!1))},_t=V=>{Jn(V),e(Lt(!1))};function vr(V,Te){return V.slice(0,u?10:Te.toLowerCase()==="image"?mN:pN)}function Dt(V){return Te=>{r?window.confirm(n("warning"))&&(V(Te),o(!1)):V(Te)}}return(0,Nt.useEffect)(()=>{i?G(i,u):e(pd())},[i,u]),(0,Nt.useEffect)(()=>{a==="search"&&e(vs())},[a]),(0,Nt.useEffect)(()=>{f&&e(tl())},[f]),ZE(h,()=>e(Lt(!0))),!d||!l?null:(0,De.jsxs)(me,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Dt(V=>e(Lt(V))),onChangeType:V=>c(V),onChangePage:Dt(V=>e(cn(V))),selectedType:u,search:i,page:a,isOpen:C,types:[...D,...N],children:[(0,De.jsxs)(me.Page,{id:"search",children:[i.length===0&&(0,De.jsx)(Ob,{commands:_,onClick:Z}),i.length>0&&(0,De.jsxs)(Nt.Fragment,{children:[_.length>0&&(0,De.jsx)(me.List,{heading:n("commands"),children:_.map((V,Te)=>(0,De.jsx)(me.ListItem,{closeOnSelect:!1,onClick:V.onClick,id:`commands-${Te}`,children:V.label},V.label))}),[...D,...N].map(({value:V,label:Te,list:ve,lineClamp:Sr,listOrientation:Se})=>(0,De.jsx)(me.List,{heading:Te,orientation:Se==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(V),hasMore:!u&&k[V.toLowerCase()]>vr(ve,V).length,children:vr(ve,V).map(ke=>(0,De.jsx)(me.ListItem,{id:`${V}-${ke.id}`,closeOnSelect:!1,lineClamp:Sr,onClick:()=>Z(ke.text,ke),description:V!=="IMAGE"?ke.title&&ke.text:void 0,extra:p&&(0,De.jsx)(me.ListItemActions,{children:(0,De.jsx)(Qd,{context:i,source:"search",suggestion:ke})}),children:V==="IMAGE"?(0,De.jsx)(me.Image,{title:ke.title||ke.text,src:ke.image}):ke.title||ke.text},`${ke.id}-${ke.text}`))},V))]})]}),(0,De.jsx)(me.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Dt(()=>{e(cn("search"))}),children:(0,De.jsx)(nb,{onCopy:ie})}),(0,De.jsx)(me.Page,{id:"summary",title:n("summaryTitle"),onDismiss:Dt(()=>{e(cn("search"))}),children:(0,De.jsx)(mb,{onCopy:_t})}),(0,De.jsx)(me.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Dt(()=>{e(vs()),e(cn("search"))}),children:(0,De.jsx)(Eb,{question:i,onUse:yr,onResetQuestion:()=>{e(vs()),s("")}})})]})},Ub=gN;var hl=w(b()),hN=()=>{let e=B("showSearch"),t=B("isEmbedded");return(0,hl.jsxs)(zb.Fragment,{children:[e&&(0,hl.jsx)(Ub,{}),t&&(0,hl.jsx)(bE,{})]})},Bb=hN;var Wb=w(oe());var Yd=w(b()),jb=({className:e})=>(0,Yd.jsx)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:e,children:(0,Yd.jsx)("g",{children:(0,Yd.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
20
20
  c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
21
21
  c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
22
22
  c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
23
23
  c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Gh=w(b()),yN={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Vb=({className:e,color:t})=>(0,Gh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Gh.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:yN[t||"pink"]})});var Kb={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var Qh={};Qe(Qh,{enUS:()=>vN,nlNL:()=>SN});var vN={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},SN={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Wo=w(b()),$b=({onLogIn:e})=>{let t=q(Qh),n=B("floatingMenu"),r=B("productName"),o=Q(),i=M(lt),s=L("FloatingMenu",Kb);if(i===null||n===!1)return null;let a=()=>{i===!0?o(Lt(!0)):e()};return(0,Wo.jsxs)("button",{className:(0,Wb.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,Wo.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,Wo.jsxs)("div",{className:s.icon,children:[(0,Wo.jsx)(Vb,{className:s.logo,color:"pink"}),i===!1&&(0,Wo.jsx)(jb,{className:s.lock})]})]})};var tf=w(U());var qb=w(U());function to(e){(0,qb.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function $o(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}function On(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input;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 wN={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Xd=({ui:e})=>e.overlayCollapsed,Gb=X({name:"ui",initialState:wN,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputFocus(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:yl,setInputFocus:Zd,setOverlayCollapsed:no,setOpenOverlayWhenTyping:Qb,setOverlayCollapsedUserOverwrite:Yb}=Gb.actions,Xb=Gb.reducer;var Jd=w(U());var Ss=w(U());var Zb=w(U());function Jb(e,t,n){(0,Zb.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var eC={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var qo=w(b()),EN=["search","personal-collection-search","search-autocomplete"];function bN(e,t,n,r={}){var i;let o="";return EN.includes(t)?o=UE(Oh(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=Oh(e,n,r),r.placeholders===!0&&(o=zE(o)),o}var CN=()=>{},TN=({selected:e,suggestion:t})=>{let n=B("inlineSuggestions"),r=M(is),o=B("enableSuggestionFeedback"),i=M(c=>c.input.text),s=Q(),a=L("TextSuggestion",eC),l=(0,Ss.useRef)(null);(0,Ss.useEffect)(()=>{let c=setTimeout(()=>{s(_1({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(c)}},[t]),Jb(l,"click",()=>{s(un({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,Ss.useMemo)(()=>bN(t.text,t.source,r,{stripAgentPart:n,placeholders:!0,searchKeywords:t.searchKeywords}),[n,t.text,t.source,r,t.searchKeywords]);return t.source==="gpt"&&!n?null:(0,qo.jsxs)("div",{className:a.root,children:[(0,qo.jsx)(re,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:CN,children:(0,qo.jsx)(ls,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),o&&(0,qo.jsx)("div",{className:a.actions,children:(0,qo.jsx)(Qd,{source:"overlay",context:i,suggestion:t})})]})},tC=TN;var Yh=w(b()),kN=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,Jd.useMemo)(()=>{let o=e.map((i,s)=>(0,Yh.jsx)(tC,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,Yh.jsx)(Jd.Fragment,{children:r})},ef=kN;var nC={root:"dd-PfvRI",paper:"dd-HYlyY"};var vl=w(b()),PN=({textSuggestions:e,selectedIndex:t})=>{let n=(0,tf.useRef)(null),r=L("InlineSuggestionsOverlay",nC),o=M(On),i=Q(),s=M(lt),a=M(os),l=M(Xd),u=B("showTextSuggestions");return to(()=>{setTimeout(()=>{i(no({collapse:!0,skipWhenInputFocus:!0}))})}),(0,tf.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let f=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-f.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,vl.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,vl.jsx)("div",{ref:n,className:r.paper,children:(0,vl.jsx)(St,{children:(0,vl.jsx)(ef,{suggestions:e,selectedIndex:t})})})})},RN=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),rC=Yn(RN)(PN);var Sl=w(b()),AN=({children:e})=>{let n=B("locale").replace("-","");return(0,Sl.jsx)(yh.Provider,{value:n,children:e})},LN=({store:e,customStyles:t={},children:n})=>(0,Sl.jsx)(Yg,{store:e,children:(0,Sl.jsx)(AN,{children:(0,Sl.jsx)(Ds.Provider,{value:t,children:n})})}),Go=LN;var rf=w(oe()),ws=w(U());var oC=w(U());function iC(e,t){let[n,r]=(0,oC.useState)(()=>{if(typeof window=="undefined")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!="undefined"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){H.error(s)}}]}var sC=()=>/Mac/i.test(navigator.platform);var lC=w(oe()),sr=w(U());var Xh={};Qe(Xh,{enUS:()=>IN,nlNL:()=>ON});var IN={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"}]}]},ON={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 aC={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var ro=w(b()),Zh=(e,t,n)=>r=>(0,ro.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),NN=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=q(Xh),s=Qt(),a=L("Login",aC),l=B("productName"),u=(0,sr.useCallback)(m=>{m.preventDefault(),r&&r(parseInt(m.target.value,10))},[]),c=(0,sr.useCallback)(m=>{m.preventDefault(),s.send(as,!0)},[t]),f=(0,sr.useMemo)(()=>m=>(0,ro.jsx)("a",{onClick:h=>{h.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:m},"login"),[t]),d=(0,sr.useCallback)(m=>(0,ro.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:m},"prompt"),[c]),{min:p,hour:v,day:y}=(0,sr.useMemo)(()=>({min:Zh(a,60*10,u),hour:Zh(a,60*60,u),day:Zh(a,60*60*12,u)}),[]);return(0,ro.jsxs)("div",{className:(0,lC.default)(e,a.root),children:[i("loginPlease",{login:n?d:f,productName:l}),r&&(0,ro.jsxs)(sr.Fragment,{children:[(0,ro.jsx)("br",{}),i("snooze",{min:p,hour:v,day:y})]})]})},nf=NN;var uC={root:"dd-DoQhb",text:"dd-Jwnev"};var wl=w(b()),MN=({title:e})=>{let t=L("SearchTrigger",uC),n=Q();return(0,wl.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(Lt(!0)),children:[(0,wl.jsx)(ds,{}),(0,wl.jsx)("span",{className:t.text,children:e})]})},cC=MN;var Jh={};Qe(Jh,{enUS:()=>_N,nlNL:()=>DN});var _N={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"}]},DN={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 dC={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2"};var Ce=w(b()),FN=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=L("SuggestionsOverlay",dC),o=q(Jh),i=M(On),s=M1(),a=Q(),l=(0,ws.useRef)(null),u=B("searchTriggerKey"),c=B("productName"),f=M(Xd),d=M(lt),p=M(os),[v,y]=(0,ws.useState)(null),m=B("showSearch"),g=B("showTextSuggestions"),h=B("adminUrl"),S=B("isEmbedded"),[x,k]=iC("dd-snooze-until-ms",0),C=f||x>Date.now(),R=e.filter(D=>D.source!=="gpt").length,N=()=>{C&&k(0),a(Yb(!C))},_=D=>{let G=Date.now()+D*1e3;k(G),H.info(`Snooze until: ${new Date(G)}`),a(no({collapse:!0}))};return(0,ws.useEffect)(()=>{R===0&&y(null)},[e,R]),to(()=>{a(no({collapse:!0,skipWhenInputFocus:!0}))}),d===null||p===!1?null:d===!1?(0,Ce.jsxs)("div",{ref:l,className:(0,rf.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,Ce.jsxs)("div",{className:r.triggers,children:[(0,Ce.jsx)("div",{style:{flex:1}}),(0,Ce.jsx)("div",{className:r.triggersRight,children:(0,Ce.jsx)(mo,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})})]}),(0,Ce.jsx)("div",{className:r.toggleButtonWrapper,children:(0,Ce.jsx)(mo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),(0,Ce.jsx)("div",{className:r.collapsible,children:(0,Ce.jsx)(nf,{loginUrl:h,isEmbedded:S,onLogIn:n,onSnooze:_})})]}):!s||!i?null:(0,Ce.jsxs)("div",{ref:l,className:(0,rf.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,Ce.jsxs)("div",{className:r.triggers,children:[(0,Ce.jsx)("div",{style:{flex:1},children:m&&(0,Ce.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>y(o(sC()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>y(null),children:(0,Ce.jsx)(cC,{title:o("search")})})}),(0,Ce.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,Ce.jsx)("div",{className:(0,rf.default)(!v&&r.hintsHidden,r.hints),children:v}),(0,Ce.jsx)(mo,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})]})]}),(0,Ce.jsx)("div",{className:r.toggleButtonWrapper,children:(0,Ce.jsx)(mo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),R>0&&g&&(0,Ce.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,Ce.jsx)(St,{children:(0,Ce.jsx)(ef,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},HN=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),fC=Yn(HN)(FN);var Sf=w(oe());var cr=w(U());var xs=w(U());function of(e){return e.contentEditable==="true"}function UN(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 pC(e){let{selectionStart:t,selectionEnd:n}=of(e)?UN(e):e;return[t,n]}function mC(e){let[,t]=(0,xs.useState)(),n=(0,xs.useRef)(null);return n.current=pC(e),(0,xs.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=pC(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 gC(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(iu);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 hC=w(U()),zN=["div","span","mark","strong","b","i","u","em"];function ey(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(zN.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,hC.cloneElement)(r,{children:ey(s,t,n+1)})]}return[...e,...t]}function oo(e){return e.tagName.toLowerCase()==="textarea"}var yC={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var PC=w(oe());var mf=w(U());var Es=w(U());function vC(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function sf(e){let t=(0,Es.useRef)(null),[n,r]=(0,Es.useState)(!1);return(0,Es.useEffect)(()=>{var c;let o=!1,i=parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[s,a]=vC((f,d)=>{let p=t.current;if(!p)return;let v=f/i,y=d/i,m=p.getBoundingClientRect(),g=v>m.x&&v<m.x+m.width&&y>m.y&&y<m.y+m.height;g&&!o?(o=!0,r(!0)):!g&&o&&(o=!1,r(!1))},({clientX:f,clientY:d})=>[f,d]),[l,u]=vC(()=>{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]}function SC(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function af(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function wC(e){return e!=null}var ny=w(oe()),Zt=w(U());var lf=w(U()),BN=["bottom","height","left","right","top","width"],jN=(e={},t={})=>BN.some(n=>e[n]!==t[n]),ar=new Map,xC,EC=()=>{let e=[],t=[];ar.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();jN(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{ar.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),xC=window.requestAnimationFrame(EC)};function VN(e,t){return{observe(){let n=ar.size===0;if(ar.has(e)){let r=ar.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else ar.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&EC()},unobserve(){let n=ar.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||ar.delete(e),ar.size||cancelAnimationFrame(xC)}}}}function ty(e){let[t,n]=(0,lf.useState)(null);return(0,lf.useLayoutEffect)(()=>{if(!e.current)return;let r=VN(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var bs=w(U()),CC=w(Sc());var bC={root:"dd-r-dgo"};var TC=({children:e,parentNode:t})=>{let[n,r]=(0,bs.useState)(null),o=(0,bs.useContext)(Ds);return(0,bs.useLayoutEffect)(()=>{let i=document.createElement("div");return $o(i),i.classList.add(bC.root),o!=null&&o.portalRootNode&&i.classList.add(o==null?void 0:o.portalRootNode),(t||document.body).appendChild(i),r(i),()=>{i.isConnected&&i.remove()}},[]),n?(0,CC.createPortal)(e,n):null};var Nn={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};var uf=w(b()),cf=(e=!1)=>{let[t,n]=(0,Zt.useState)(e),r=(0,Zt.useCallback)(()=>n(!0),[]),o=(0,Zt.useCallback)(()=>n(!1),[]),i=(0,Zt.useCallback)(()=>n(a=>!a),[]),s=(0,Zt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function ry(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 Cs=u=>{var c=u,{className:e,triggerRef:t,boundaryRef:n=(0,Zt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=ry,parentNode:a}=c,l=ee(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let f=ty(t),d=ty(n),p=(0,Zt.useMemo)(()=>s(f,d,0),[f,d]);return(0,uf.jsx)(TC,{parentNode:a,children:(0,uf.jsx)("div",I(T({className:(0,ny.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:p},l),{role:"dialog",children:(0,uf.jsx)("div",{className:(0,ny.default)(e,Nn.root),children:i})}))})};var kC=w(oe()),df=w(U());var lr={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var oy=w(b()),ff=(0,df.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=ee(i,["className","children"]);let s=(0,df.useRef)(null),a=L("TabCompletion",lr);return(0,oy.jsx)("div",I(T({ref:af([s,r]),className:(0,kC.default)(e,a.popoverContentContainer)},n),{children:(0,oy.jsx)("div",{className:a.popoverContent,children:t})}))});var io=w(b()),KN=e=>t=>{let n=ry(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},WN=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=L("TabCompletion",lr),s=cf(),a=(0,mf.useMemo)(()=>KN(e.getBoundingClientRect()),[e]),[l,u]=sf(e);return(0,mf.useEffect)(()=>{u?s.open():s.close()},[u]),(0,io.jsxs)("span",{children:[(0,io.jsx)("mark",{ref:af([l,s.triggerRef]),className:(0,PC.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,io.jsx)(Cs,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,io.jsx)(ff,{style:n,children:(0,io.jsx)("div",{className:i.hintText,children:o})})})]})},pf=class extends tr{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,r){return r.keywordMatches&&r.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=r.keywordMatches.map(o=>I(T({},o),{keywordRegex:new RegExp(`\\b${SC(o.keyword)}\\b`,"i")})),this.keywordMatches=r.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let r=this.preparedKeywordMatches.map(i=>{if(this.usedKeywordMatches.has(i))return null;let s=n.match(i.keywordRegex);if(!s)return null;let a=n.charAt(s.index-1),l=n.charAt(s.index+i.keyword.length);return a==="{"&&l==="}"?null:{index:s.index,length:s[0].length,match:s[0],matchString:s[0],suggestion:i.suggestion,preparedKeywordMatch:i,valid:!0}}).filter(wC);if(r.length===0)return null;let o=r.reduce((i,s)=>s.index<i.index?s:i);return this.usedKeywordMatches.add(o.preparedKeywordMatch),o}replaceWith(n,r){return(0,io.jsx)(WN,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var RC=w(oe());var iy=w(b()),$N=({inputElement:e,children:t})=>{let n=L("TabCompletion",lr),[r,o]=sf(e);return(0,iy.jsx)("mark",{ref:r,className:(0,RC.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},gf=class extends tr{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,iy.jsx)($N,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var yf=w(oe());var ft=w(U());var sy=w(b()),AC=()=>(0,sy.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,sy.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 so=w(U());var IC=w(Eh());var LC={root:"dd-ky-Bv",content:"dd-kV5e1"};function hf(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(i){return null}}function ay(e){return e.replace("https://www.","").replace("https://","")}var Jt=w(b()),qN=3,GN=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),QN=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=qN})=>{let i=L("LinkSearch",LC),[s,a]=(0,so.useState)(""),l=Q(),u=M(Pb("url")),c=M(nE("URL",GN)),[f,d]=(0,so.useState)(c.length-1),p=B("fallbackImage"),v=h=>{let S=h.target;a(S.value)},y=(h,S)=>{h.stopPropagation(),h.preventDefault(),window.open(S,"_blank")},m=h=>{var k;let S=f-1<0?c.length-1:f-1,x=f+1===c.length?0:f+1;h.code==="Escape"&&(a(""),t()),h.code==="ArrowUp"&&d(S),h.code==="ArrowDown"&&d(x),h.code==="Enter"&&e(((k=c[f])==null?void 0:k.text)||s)},g=(0,so.useCallback)((0,IC.default)(h=>{l(No({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,so.useEffect)(()=>{s&&g(s)},[s]),(0,so.useEffect)(()=>()=>{l(pd())},[]),(0,Jt.jsxs)("div",{className:i.root,children:[(0,Jt.jsx)(St,{withDivider:!0,children:(s?c:u).slice(0,o).map((h,S)=>(0,Jt.jsx)(re,{selected:f===S,onClick:()=>e(h.text),"data-testid":"linksearch-suggestion",children:(0,Jt.jsxs)(ge,{children:[(0,Jt.jsx)(ge.Image,{src:hf(h,"small",p||void 0),title:h.title||h.text}),(0,Jt.jsxs)(ge.Content,{className:i.content,cropText:!0,children:[(0,Jt.jsx)(ge.Title,{children:h.title||ay(h.text)}),h.title&&ay(h.text)]}),(0,Jt.jsx)(re.Actions,{children:(0,Jt.jsx)(re.ActionButton,{label:r,onClick:x=>y(x,h.text)})})]})},h.text))}),(0,Jt.jsx)(el,{value:s,onChange:v,autoFocus:!0,placeholder:n,onKeyUp:m})]})},OC=QN;var ly={};Qe(ly,{enUS:()=>YN,nlNL:()=>XN});var YN={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},XN={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var dt=w(b()),ZN=(0,ft.forwardRef)((e,t)=>{let n=L("TabCompletion",lr);return(0,dt.jsx)("mark",{ref:t,className:(0,yf.default)(n.matchSelection)},"selection-start")}),JN=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=q(ly),s=L("TabCompletion",lr),a=(0,ft.useRef)(null),l=(0,ft.useRef)(null),[u,c]=(0,ft.useState)(null),f=Q(),d=cf(document.activeElement===r),[p]=(0,ft.useState)(()=>document.createRange());d.triggerRef.current=p,(0,ft.useEffect)(()=>()=>p.detach(),[]),(0,ft.useEffect)(()=>{let y=e.current,m=a.current;!y||!m||(p.setStart(y,0),p.setEnd(m,0))},[e.current,a.current]),to(()=>{d.close()});let v=(0,ft.useCallback)(y=>{let m=p.toString(),g=/^http(s?):\/\//.test(y)?y:`https://${y}`;f(ad({text:`[${m}](${g})`,replace:"selection"}))},[]);return(0,dt.jsxs)("span",{children:[(0,dt.jsx)("mark",{ref:a,className:(0,yf.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,dt.jsx)(Cs,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,dt.jsxs)(ff,{style:n,ref:l,children:[(0,dt.jsx)("div",{className:(0,yf.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,dt.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,dt.jsx)(AC,{}),(0,dt.jsx)("span",{children:"\xA0"}),(0,dt.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,dt.jsx)(OC,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:v,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},vf=class extends tr{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,r){return this.props=r,this.charCount=0,this.startRef=(0,ft.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[r,o]=this.props.selection;if(r===o)return null;let i=this.foundIndex===0?r:o,s=i>=this.charCount&&i<=this.charCount+n.length?{index:i-this.charCount,length:0,match:"",valid:!0}:null;s&&this.foundIndex++;let a=this.foundIndex===1;return s&&a?this.charCount+=i-this.charCount:this.charCount+=n.length,s?T({isStart:a},s):null}replaceWith(n,r){return r.isStart?(0,dt.jsx)(ZN,{ref:this.startRef}):(0,dt.jsx)(JN,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var ur=w(b()),eM=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=L("TabCompletion",yC),c=B("insertLink"),f=B("showMidSentenceSuggestions"),d=B("inlineSuggestions"),p=mC(a),v=(0,cr.useRef)(null),y=M(lt);(0,cr.useEffect)(()=>{oo(a)&&p&&gC(a,p)},[p]);let m=(0,cr.useCallback)(S=>{if(!o||!n)return S;let x=[(0,ur.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,ur.jsx)("span",{"data-testid":"tab-completion",className:(0,Sf.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&x.push((0,ur.jsx)("span",{className:(0,Sf.default)(u.hint,u.resetIndent),children:(0,ur.jsx)(tu,{keyCode:"tab"},"tabHint")})),ey(S,x)},[o,n,r]),g=(0,cr.useMemo)(()=>{let S=[];return c&&S.push(new vf("selection")),S.push(new gf("placeholders")),i&&S.push(new pf("keywords")),S},[d,c,i]),h=(0,cr.useMemo)(()=>{let S=window.getComputedStyle(a);return{"--dd-color":S.color,"--dd-font-size":S.fontSize,"--dd-font-family":S.fontFamily,"--dd-font-variant":S.fontVariant}},[]);return!e||!y?null:(0,ur.jsxs)("div",{ref:S=>{S!=null&&S.parentElement&&(v.current=S==null?void 0:S.parentElement)},className:u.root,style:h,children:[(0,ur.jsx)(ls,{tagName:"span",containerTagName:"div",className:(0,Sf.default)(u.container,u.agentText),disableLineBreaks:oo(a),content:t||"\u200B",onAfterParse:m,matchers:g,selection:p,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:v,inlineSuggestionsOnlyAtEnd:!f}),(0,ur.jsx)("br",{})]})},tM=e=>{var m,g,h;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=ss({input:t}),a=(s==null?void 0:s.text)||"",l=(s==null?void 0:s.source)||"",u=(m=t.html)!=null?m:us(t.text),c=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:f}=n,{isSupported:d}=i,{showTabCompletion:p,visible:v,showStyleSuggestions:y}=r;return{showTabHint:f,showStyleSuggestions:y,showTabCompletion:p&&On(e),content:u,tabText:c,source:l,keywordMatches:(h=(g=o.list)==null?void 0:g.keywordMatches)!=null?h:[],enabled:v&&d!==!1}},NC=Yn(tM)(eM);var YT=w(oe()),Ts=w(U());var MC={list:[],fetchState:"idle"},DC=e=>e.autoflows.list||[],_C=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},dr=K("autoflows/getAll",(e,t)=>P(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)})),uy=K("autoflows/start",(e,t)=>P(void 0,null,function*(){let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");yield r.startAutoflowSession(e),yield n(dr(e.platformSessionId))})),cy=K("autoflows/stop",(e,t)=>P(void 0,null,function*(){let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");yield r.stopAutoflowSession(e.platformSessionId),yield n(dr(e.platformSessionId))})),nM=X({name:"autoflows",initialState:MC,reducers:{},extraReducers:e=>{e.addCase(uy.pending,(t,n)=>{let r=_C(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(cy.pending,(t,n)=>{let r=_C(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(dr.pending,t=>{t.fetchState="loading"}),e.addCase(dr.rejected,t=>{t.fetchState="error"}),e.addCase(dr.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(de,()=>MC)}}),FC=K("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(dr(e))}),o.on("sessionCompleted",()=>{n(dr(e))})}),HC=K("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),UC=nM.reducer;var zC={list:[],fetchState:"idle",sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},BC=e=>e.customMessages.list,jC=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),VC=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),KC=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),xl=K("customMessages/getAll",(e,t)=>P(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)})),wf=K("customMessages/send",(e,t)=>P(void 0,null,function*(){let{platformSessionId:n,suggestion:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");yield o.sendCustomMessage(n,r)})),xf=K("customMessages/answer",(e,t)=>P(void 0,null,function*(){let{platformSessionId:n,reply:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");yield o.answerCustomMessage(n,r)})),WC=X({name:"customMessages",initialState:zC,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(xl.pending,t=>{t.fetchState="loading"}).addCase(xl.rejected,t=>{t.fetchState="error"}).addCase(xl.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(wf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(wf.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(xf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(xf.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(de,()=>zC)}}),$C=K("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(WC.actions.onCustomMessage(i))})}),qC=K("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),GC=WC.reducer;var rM={token:null,interval:null},dy=K("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>P(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),fy=K("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(dy()),setInterval(()=>r(dy()),n)}),QC=X({name:"passwordlessToken",initialState:rM,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(dy.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(fy.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:YC}=QC.actions,XC=QC.reducer;var ZC={excludeFromWidget:!1},py={cues:[],fetchState:"idle"},JC=e=>{var t;return(t=e.rules)==null?void 0:t.cues},oM=be("rules/resetCues"),Qo=K("rules/evaluate",(e,t)=>P(void 0,null,function*(){var n,r;try{let{deepdeskAPI:o}=t.extra,i=t.getState(),{platformVariables:s}=i.info,a=(n=i.conversation.current)==null?void 0:n.id;if(!a)throw new Error("No current conversation to evaluate rules");if(!(yield o.getAccount()).ruleEngine)throw new Error("Rule engine is not enabled for this account");if(!(yield o.getRules()).filter(d=>d.isEnabled).some(d=>d.label===e.label))throw new Error(`No enabled rules found with label: ${e.label}`);let f=yield o.evaluateRule(e.label,a,T({tags:((r=i.conversation.current)==null?void 0:r.tags)||void 0},e.params));return s&&(f=f.map(d=>I(T({},d),{title:rt(d.title,s),text:rt(d.text,s)}))),{cues:f,options:e.options}}catch(o){let i=o.message;return H.warn(i),t.rejectWithValue(i)}})),eT=X({name:"answer",initialState:py,reducers:{removeCue(e,t){e.cues=e.cues.filter(n=>n.rule.id!==t.payload.id)}},extraReducers:e=>{e.addCase(Qo.pending,t=>{t.fetchState="loading"}).addCase(Qo.rejected,t=>{t.fetchState="error"}).addCase(Qo.fulfilled,(t,n)=>{var i;if((i=n.payload.options)!=null&&i.excludeFromWidget){t.fetchState="done";return}let r=n.payload.cues.map(s=>s.rule.id),o=t.cues.filter(s=>!r.includes(s.rule.id));t.fetchState="done",t.cues=[...n.payload.cues,...o]}).addCase(de,()=>py).addCase(oM.toString(),()=>py)}}),{removeCue:tT}=eT.actions,nT=eT.reducer;function iM(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var rT=e=>{let t=JC(e),r=rb(e).map(o=>({text:o.response,title:o.name,callToAction:o.callToAction,rule:{id:iM(o.code),label:o.code,name:o.name,description:o.name}}));return[...t,...r]};var fT=w(U());var uT=w(oe()),cT=w(U());var iT=w(oe());var oT={root:"dd-uszkm"};var aT=w(b()),sM=({className:e,children:t})=>{let n=L("Unicode",oT);return(0,aT.jsx)("span",{className:(0,iT.default)(e,n.root),children:t})},sT=sM;var lT={isDisabled:"dd-Sp--t",root:"dd-maqTG",buttonStop:"dd-rcq8w",stateBadge:"dd-zOnkT",isCompleted:"dd-GA-rt",isStarted:"dd-PZwtX",isAborted:"dd-PAXSE"};var my={};Qe(my,{enUS:()=>aM,nlNL:()=>lM});var aM={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"}]},lM={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 Mt=w(b()),cM=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=L("Autoflow",lT),a=q(my),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,Mt.jsxs)(re,{className:(0,uT.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,Mt.jsx)(ge,{children:(0,Mt.jsxs)(ge.Content,{children:[(0,Mt.jsxs)(ge.Title,{children:[t&&(0,Mt.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,Mt.jsx)("span",{children:r})]})}),(0,Mt.jsx)(re.Actions,{fixed:t==="Started",children:(0,Mt.jsx)(re.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,Mt.jsxs)(cT.Fragment,{children:[(0,Mt.jsx)(sT,{children:u})," ",(0,Mt.jsx)("span",{children:a(l)})]})})})]})},dT=cM;var gy=w(b()),dM=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},fM=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,gy.jsx)(fT.Fragment,{children:e.map(o=>(0,gy.jsx)(dT,{displayName:o.displayName,description:o.description,disabled:o.isBusy||dM(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),pM=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},mM={onStartAutoflow:uy,onStopAutoflow:cy},pT=Yn(pM,mM)(fM);var mT=w(oe()),hy=w(U());var fr={root:"dd-ERsBr",title:"dd-b36p6",isUsed:"dd-fp2IX",quickReplies:"dd--VrvP",quickReply:"dd-wFhWh",label:"dd-R9sND",errorIcon:"dd-8cdcH"};var Ct=w(b()),gM=({suggestion:e})=>{let t=q(Ko),n=Q(),r=M(jC(e.text)),o=M(VC(e.text)),i=M(KC(e.text)),s=M(rs),{replyOptions:a}=e,l=(0,hy.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(wf({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,hy.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let f=parseInt(c.target.dataset.index,10),d=a[f];n(xf({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,Ct.jsxs)(re,{onClick:l,className:(0,mT.default)(fr.root,{[fr.isUsed]:r,[fr.hasError]:i}),children:[(0,Ct.jsx)(ge,{children:(0,Ct.jsxs)(ge.Content,{children:[(0,Ct.jsxs)(ge.Title,{className:fr.title,children:[e.text," ",(0,Ct.jsx)(nu,{className:fr.label,children:"analyse tool"})," ",i&&(0,Ct.jsx)("span",{className:fr.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,Ct.jsx)("ul",{className:fr.quickReplies,children:a.map(c=>(0,Ct.jsx)("li",{className:fr.quickReply,children:c.title},c.title))})]})}),(0,Ct.jsxs)(re.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,Ct.jsx)(re.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,f)=>(0,Ct.jsx)(re.DropdownItem,{index:f,label:c.title,onClick:u},c.title))}),(0,Ct.jsx)(re.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},gT=gM;var Ef=w(U());var vy=w(oe());var yy=w(b()),El=()=>(0,yy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,yy.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 hT={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var Mn=w(b()),hM=({entities:e})=>{let t=L("EntitiesWidgetList",hT),[n,r]=(0,Ef.useState)(void 0),o=Q(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Jn(a.text),o(ut({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Ef.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,Mn.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,Mn.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,Mn.jsx)("span",{className:t.entityText,children:a.text}),(0,Mn.jsxs)("span",{className:t.iconWrapper,children:[(0,Mn.jsx)("span",{className:(0,vy.default)(t.icon),children:(0,Mn.jsx)(El,{})}),(0,Mn.jsx)("span",{className:(0,vy.default)(t.icon,n===l&&t.iconClicked),children:(0,Mn.jsx)(El,{})})]})]},a.text))})},yT=hM;var Sy=w(b()),vT=()=>(0,Sy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Sy.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 wy=w(b()),ST=()=>(0,wy.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,wy.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 xy=w(b()),wT=()=>(0,xy.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,xy.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 zT=w(U());var{entries:LT,setPrototypeOf:xT,isFrozen:yM,getPrototypeOf:vM,getOwnPropertyDescriptor:SM}=Object,{freeze:mt,seal:en,create:IT}=Object,{apply:Py,construct:Ry}=typeof Reflect!="undefined"&&Reflect;mt||(mt=function(t){return t});en||(en=function(t){return t});Py||(Py=function(t,n,r){return t.apply(n,r)});Ry||(Ry=function(t,n){return new t(...n)});var bf=Tt(Array.prototype.forEach),ET=Tt(Array.prototype.pop),bl=Tt(Array.prototype.push),kf=Tt(String.prototype.toLowerCase),Ey=Tt(String.prototype.toString),bT=Tt(String.prototype.match),Cl=Tt(String.prototype.replace),wM=Tt(String.prototype.indexOf),xM=Tt(String.prototype.trim),vn=Tt(Object.prototype.hasOwnProperty),pt=Tt(RegExp.prototype.test),Tl=EM(TypeError),CT=Tt(Number.isNaN);function Tt(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Py(e,t,r)}}function EM(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ry(e,n)}}function J(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kf;xT&&xT(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let i=n(o);i!==o&&(yM(t)||(t[r]=i),o=i)}e[o]=!0}return e}function bM(e){for(let t=0;t<e.length;t++)vn(e,t)||(e[t]=null);return e}function Xo(e){let t=IT(null);for(let[n,r]of LT(e))vn(e,n)&&(Array.isArray(r)?t[n]=bM(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Xo(r):t[n]=r);return t}function Cf(e,t){for(;e!==null;){let r=SM(e,t);if(r){if(r.get)return Tt(r.get);if(typeof r.value=="function")return Tt(r.value)}e=vM(e)}function n(){return null}return n}var TT=mt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),by=mt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Cy=mt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),CM=mt(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ty=mt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),TM=mt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),kT=mt(["#text"]),PT=mt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),ky=mt(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),RT=mt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Tf=mt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),kM=en(/\{\{[\w\W]*|[\w\W]*\}\}/gm),PM=en(/<%[\w\W]*|[\w\W]*%>/gm),RM=en(/\${[\w\W]*}/gm),AM=en(/^data-[\-\w.\u00B7-\uFFFF]/),LM=en(/^aria-[\-\w]+$/),OT=en(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),IM=en(/^(?:\w+script|data):/i),OM=en(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),NT=en(/^html$/i),NM=en(/^[a-z][.\w]*(-[.\w]+)+$/i),AT=Object.freeze({__proto__:null,MUSTACHE_EXPR:kM,ERB_EXPR:PM,TMPLIT_EXPR:RM,DATA_ATTR:AM,ARIA_ATTR:LM,IS_ALLOWED_URI:OT,IS_SCRIPT_OR_DATA:IM,ATTR_WHITESPACE:OM,DOCTYPE_NAME:NT,CUSTOM_ELEMENT:NM}),Yo={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},MM=function(){return typeof window=="undefined"?null:window},_M=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));let i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function MT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:MM(),t=j=>MT(j);if(t.version="3.1.3",t.removed=[],!e||!e.document||e.document.nodeType!==Yo.document)return t.isSupported=!1,t;let{document:n}=e,r=n,o=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:s,Node:a,Element:l,NodeFilter:u,NamedNodeMap:c=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:f,DOMParser:d,trustedTypes:p}=e,v=l.prototype,y=Cf(v,"cloneNode"),m=Cf(v,"nextSibling"),g=Cf(v,"childNodes"),h=Cf(v,"parentNode");if(typeof s=="function"){let j=n.createElement("template");j.content&&j.content.ownerDocument&&(n=j.content.ownerDocument)}let S,x="",{implementation:k,createNodeIterator:C,createDocumentFragment:R,getElementsByTagName:N}=n,{importNode:_}=r,D={};t.isSupported=typeof LT=="function"&&typeof h=="function"&&k&&k.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:G,ERB_EXPR:Z,TMPLIT_EXPR:ie,DATA_ATTR:yr,ARIA_ATTR:_t,IS_SCRIPT_OR_DATA:vr,ATTR_WHITESPACE:Dt,CUSTOM_ELEMENT:V}=AT,{IS_ALLOWED_URI:Te}=AT,ve=null,Sr=J({},[...TT,...by,...Cy,...Ty,...kT]),Se=null,ke=J({},[...PT,...ky,...RT,...Tf]),we=Object.seal(IT(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ni=null,uo=null,ri=!0,oi=!0,Ul=!1,co=!0,xn=!1,zl=!0,He=!1,Fn=!1,Hf=!1,ii=!1,Bl=!1,jl=!1,Vy=!0,Ky=!1,Bk="user-content-",Uf=!0,Is=!1,si={},ai=null,Wy=J({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),$y=null,qy=J({},["audio","video","img","source","image","track"]),zf=null,Gy=J({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Vl="http://www.w3.org/1998/Math/MathML",Kl="http://www.w3.org/2000/svg",Hn="http://www.w3.org/1999/xhtml",li=Hn,Bf=!1,jf=null,jk=J({},[Vl,Kl,Hn],Ey),Os=null,Vk=["application/xhtml+xml","text/html"],Kk="text/html",Ue=null,ui=null,Qy=255,Wk=n.createElement("form"),Yy=function(E){return E instanceof RegExp||E instanceof Function},Vf=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ui&&ui===E)){if((!E||typeof E!="object")&&(E={}),E=Xo(E),Os=Vk.indexOf(E.PARSER_MEDIA_TYPE)===-1?Kk:E.PARSER_MEDIA_TYPE,Ue=Os==="application/xhtml+xml"?Ey:kf,ve=vn(E,"ALLOWED_TAGS")?J({},E.ALLOWED_TAGS,Ue):Sr,Se=vn(E,"ALLOWED_ATTR")?J({},E.ALLOWED_ATTR,Ue):ke,jf=vn(E,"ALLOWED_NAMESPACES")?J({},E.ALLOWED_NAMESPACES,Ey):jk,zf=vn(E,"ADD_URI_SAFE_ATTR")?J(Xo(Gy),E.ADD_URI_SAFE_ATTR,Ue):Gy,$y=vn(E,"ADD_DATA_URI_TAGS")?J(Xo(qy),E.ADD_DATA_URI_TAGS,Ue):qy,ai=vn(E,"FORBID_CONTENTS")?J({},E.FORBID_CONTENTS,Ue):Wy,ni=vn(E,"FORBID_TAGS")?J({},E.FORBID_TAGS,Ue):{},uo=vn(E,"FORBID_ATTR")?J({},E.FORBID_ATTR,Ue):{},si=vn(E,"USE_PROFILES")?E.USE_PROFILES:!1,ri=E.ALLOW_ARIA_ATTR!==!1,oi=E.ALLOW_DATA_ATTR!==!1,Ul=E.ALLOW_UNKNOWN_PROTOCOLS||!1,co=E.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xn=E.SAFE_FOR_TEMPLATES||!1,zl=E.SAFE_FOR_XML!==!1,He=E.WHOLE_DOCUMENT||!1,ii=E.RETURN_DOM||!1,Bl=E.RETURN_DOM_FRAGMENT||!1,jl=E.RETURN_TRUSTED_TYPE||!1,Hf=E.FORCE_BODY||!1,Vy=E.SANITIZE_DOM!==!1,Ky=E.SANITIZE_NAMED_PROPS||!1,Uf=E.KEEP_CONTENT!==!1,Is=E.IN_PLACE||!1,Te=E.ALLOWED_URI_REGEXP||OT,li=E.NAMESPACE||Hn,we=E.CUSTOM_ELEMENT_HANDLING||{},E.CUSTOM_ELEMENT_HANDLING&&Yy(E.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(we.tagNameCheck=E.CUSTOM_ELEMENT_HANDLING.tagNameCheck),E.CUSTOM_ELEMENT_HANDLING&&Yy(E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(we.attributeNameCheck=E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),E.CUSTOM_ELEMENT_HANDLING&&typeof E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(we.allowCustomizedBuiltInElements=E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),xn&&(oi=!1),Bl&&(ii=!0),si&&(ve=J({},kT),Se=[],si.html===!0&&(J(ve,TT),J(Se,PT)),si.svg===!0&&(J(ve,by),J(Se,ky),J(Se,Tf)),si.svgFilters===!0&&(J(ve,Cy),J(Se,ky),J(Se,Tf)),si.mathMl===!0&&(J(ve,Ty),J(Se,RT),J(Se,Tf))),E.ADD_TAGS&&(ve===Sr&&(ve=Xo(ve)),J(ve,E.ADD_TAGS,Ue)),E.ADD_ATTR&&(Se===ke&&(Se=Xo(Se)),J(Se,E.ADD_ATTR,Ue)),E.ADD_URI_SAFE_ATTR&&J(zf,E.ADD_URI_SAFE_ATTR,Ue),E.FORBID_CONTENTS&&(ai===Wy&&(ai=Xo(ai)),J(ai,E.FORBID_CONTENTS,Ue)),Uf&&(ve["#text"]=!0),He&&J(ve,["html","head","body"]),ve.table&&(J(ve,["tbody"]),delete ni.tbody),E.TRUSTED_TYPES_POLICY){if(typeof E.TRUSTED_TYPES_POLICY.createHTML!="function")throw Tl('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof E.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Tl('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=E.TRUSTED_TYPES_POLICY,x=S.createHTML("")}else S===void 0&&(S=_M(p,o)),S!==null&&typeof x=="string"&&(x=S.createHTML(""));mt&&mt(E),ui=E}},Xy=J({},["mi","mo","mn","ms","mtext"]),Zy=J({},["foreignobject","annotation-xml"]),$k=J({},["title","style","font","a","script"]),Jy=J({},[...by,...Cy,...CM]),ev=J({},[...Ty,...TM]),qk=function(E){let A=h(E);(!A||!A.tagName)&&(A={namespaceURI:li,tagName:"template"});let z=kf(E.tagName),Y=kf(A.tagName);return jf[E.namespaceURI]?E.namespaceURI===Kl?A.namespaceURI===Hn?z==="svg":A.namespaceURI===Vl?z==="svg"&&(Y==="annotation-xml"||Xy[Y]):!!Jy[z]:E.namespaceURI===Vl?A.namespaceURI===Hn?z==="math":A.namespaceURI===Kl?z==="math"&&Zy[Y]:!!ev[z]:E.namespaceURI===Hn?A.namespaceURI===Kl&&!Zy[Y]||A.namespaceURI===Vl&&!Xy[Y]?!1:!ev[z]&&($k[z]||!Jy[z]):!!(Os==="application/xhtml+xml"&&jf[E.namespaceURI]):!1},Ft=function(E){bl(t.removed,{element:E});try{E.parentNode.removeChild(E)}catch(A){E.remove()}},Wl=function(E,A){try{bl(t.removed,{attribute:A.getAttributeNode(E),from:A})}catch(z){bl(t.removed,{attribute:null,from:A})}if(A.removeAttribute(E),E==="is"&&!Se[E])if(ii||Bl)try{Ft(A)}catch(z){}else try{A.setAttribute(E,"")}catch(z){}},tv=function(E){let A=null,z=null;if(Hf)E="<remove></remove>"+E;else{let je=bT(E,/^[\r\n\t ]+/);z=je&&je[0]}Os==="application/xhtml+xml"&&li===Hn&&(E='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+E+"</body></html>");let Y=S?S.createHTML(E):E;if(li===Hn)try{A=new d().parseFromString(Y,Os)}catch(je){}if(!A||!A.documentElement){A=k.createDocument(li,"template",null);try{A.documentElement.innerHTML=Bf?x:Y}catch(je){}}let Ge=A.body||A.documentElement;return E&&z&&Ge.insertBefore(n.createTextNode(z),Ge.childNodes[0]||null),li===Hn?N.call(A,He?"html":"body")[0]:He?A.documentElement:Ge},nv=function(E){return C.call(E.ownerDocument||E,E,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},rv=function(E){return E instanceof f&&(typeof E.__depth!="undefined"&&typeof E.__depth!="number"||typeof E.__removalCount!="undefined"&&typeof E.__removalCount!="number"||typeof E.nodeName!="string"||typeof E.textContent!="string"||typeof E.removeChild!="function"||!(E.attributes instanceof c)||typeof E.removeAttribute!="function"||typeof E.setAttribute!="function"||typeof E.namespaceURI!="string"||typeof E.insertBefore!="function"||typeof E.hasChildNodes!="function")},ov=function(E){return typeof a=="function"&&E instanceof a},Un=function(E,A,z){D[E]&&bf(D[E],Y=>{Y.call(t,A,z,ui)})},iv=function(E){let A=null;if(Un("beforeSanitizeElements",E,null),rv(E))return Ft(E),!0;let z=Ue(E.nodeName);if(Un("uponSanitizeElement",E,{tagName:z,allowedTags:ve}),E.hasChildNodes()&&!ov(E.firstElementChild)&&pt(/<[/\w]/g,E.innerHTML)&&pt(/<[/\w]/g,E.textContent)||E.nodeType===Yo.progressingInstruction||zl&&E.nodeType===Yo.comment&&pt(/<[/\w]/g,E.data))return Ft(E),!0;if(!ve[z]||ni[z]){if(!ni[z]&&av(z)&&(we.tagNameCheck instanceof RegExp&&pt(we.tagNameCheck,z)||we.tagNameCheck instanceof Function&&we.tagNameCheck(z)))return!1;if(Uf&&!ai[z]){let Y=h(E)||E.parentNode,Ge=g(E)||E.childNodes;if(Ge&&Y){let je=Ge.length;for(let gt=je-1;gt>=0;--gt){let ht=y(Ge[gt],!0);ht.__removalCount=(E.__removalCount||0)+1,Y.insertBefore(ht,m(E))}}}return Ft(E),!0}return E instanceof l&&!qk(E)||(z==="noscript"||z==="noembed"||z==="noframes")&&pt(/<\/no(script|embed|frames)/i,E.innerHTML)?(Ft(E),!0):(xn&&E.nodeType===Yo.text&&(A=E.textContent,bf([G,Z,ie],Y=>{A=Cl(A,Y," ")}),E.textContent!==A&&(bl(t.removed,{element:E.cloneNode()}),E.textContent=A)),Un("afterSanitizeElements",E,null),!1)},sv=function(E,A,z){if(Vy&&(A==="id"||A==="name")&&(z in n||z in Wk||z==="__depth"||z==="__removalCount"))return!1;if(!(oi&&!uo[A]&&pt(yr,A))){if(!(ri&&pt(_t,A))){if(!Se[A]||uo[A]){if(!(av(E)&&(we.tagNameCheck instanceof RegExp&&pt(we.tagNameCheck,E)||we.tagNameCheck instanceof Function&&we.tagNameCheck(E))&&(we.attributeNameCheck instanceof RegExp&&pt(we.attributeNameCheck,A)||we.attributeNameCheck instanceof Function&&we.attributeNameCheck(A))||A==="is"&&we.allowCustomizedBuiltInElements&&(we.tagNameCheck instanceof RegExp&&pt(we.tagNameCheck,z)||we.tagNameCheck instanceof Function&&we.tagNameCheck(z))))return!1}else if(!zf[A]){if(!pt(Te,Cl(z,Dt,""))){if(!((A==="src"||A==="xlink:href"||A==="href")&&E!=="script"&&wM(z,"data:")===0&&$y[E])){if(!(Ul&&!pt(vr,Cl(z,Dt,"")))){if(z)return!1}}}}}}return!0},av=function(E){return E!=="annotation-xml"&&bT(E,V)},lv=function(E){Un("beforeSanitizeAttributes",E,null);let{attributes:A}=E;if(!A)return;let z={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Se},Y=A.length;for(;Y--;){let Ge=A[Y],{name:je,namespaceURI:gt,value:ht}=Ge,Ns=Ue(je),it=je==="value"?ht:xM(ht);if(z.attrName=Ns,z.attrValue=it,z.keepAttr=!0,z.forceKeepAttr=void 0,Un("uponSanitizeAttribute",E,z),it=z.attrValue,z.forceKeepAttr||(Wl(je,E),!z.keepAttr))continue;if(!co&&pt(/\/>/i,it)){Wl(je,E);continue}if(zl&&pt(/((--!?|])>)|<\/(style|title)/i,it)){Wl(je,E);continue}xn&&bf([G,Z,ie],cv=>{it=Cl(it,cv," ")});let uv=Ue(E.nodeName);if(sv(uv,Ns,it)){if(Ky&&(Ns==="id"||Ns==="name")&&(Wl(je,E),it=Bk+it),S&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!gt)switch(p.getAttributeType(uv,Ns)){case"TrustedHTML":{it=S.createHTML(it);break}case"TrustedScriptURL":{it=S.createScriptURL(it);break}}try{gt?E.setAttributeNS(gt,je,it):E.setAttribute(je,it),rv(E)?Ft(E):ET(t.removed)}catch(cv){}}}Un("afterSanitizeAttributes",E,null)},Gk=function j(E){let A=null,z=nv(E);for(Un("beforeSanitizeShadowDOM",E,null);A=z.nextNode();){if(Un("uponSanitizeShadowNode",A,null),iv(A))continue;let Y=h(A);A.nodeType===Yo.element&&(Y&&Y.__depth?A.__depth=(A.__removalCount||0)+Y.__depth+1:A.__depth=1),(A.__depth>=Qy||A.__depth<0||CT(A.__depth))&&Ft(A),A.content instanceof i&&(A.content.__depth=A.__depth,j(A.content)),lv(A)}Un("afterSanitizeShadowDOM",E,null)};return t.sanitize=function(j){let E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},A=null,z=null,Y=null,Ge=null;if(Bf=!j,Bf&&(j="<!-->"),typeof j!="string"&&!ov(j))if(typeof j.toString=="function"){if(j=j.toString(),typeof j!="string")throw Tl("dirty is not a string, aborting")}else throw Tl("toString is not a function");if(!t.isSupported)return j;if(Fn||Vf(E),t.removed=[],typeof j=="string"&&(Is=!1),Is){if(j.nodeName){let ht=Ue(j.nodeName);if(!ve[ht]||ni[ht])throw Tl("root node is forbidden and cannot be sanitized in-place")}}else if(j instanceof a)A=tv("<!---->"),z=A.ownerDocument.importNode(j,!0),z.nodeType===Yo.element&&z.nodeName==="BODY"||z.nodeName==="HTML"?A=z:A.appendChild(z);else{if(!ii&&!xn&&!He&&j.indexOf("<")===-1)return S&&jl?S.createHTML(j):j;if(A=tv(j),!A)return ii?null:jl?x:""}A&&Hf&&Ft(A.firstChild);let je=nv(Is?j:A);for(;Y=je.nextNode();){if(iv(Y))continue;let ht=h(Y);Y.nodeType===Yo.element&&(ht&&ht.__depth?Y.__depth=(Y.__removalCount||0)+ht.__depth+1:Y.__depth=1),(Y.__depth>=Qy||Y.__depth<0||CT(Y.__depth))&&Ft(Y),Y.content instanceof i&&(Y.content.__depth=Y.__depth,Gk(Y.content)),lv(Y)}if(Is)return j;if(ii){if(Bl)for(Ge=R.call(A.ownerDocument);A.firstChild;)Ge.appendChild(A.firstChild);else Ge=A;return(Se.shadowroot||Se.shadowrootmode)&&(Ge=_.call(r,Ge,!0)),Ge}let gt=He?A.outerHTML:A.innerHTML;return He&&ve["!doctype"]&&A.ownerDocument&&A.ownerDocument.doctype&&A.ownerDocument.doctype.name&&pt(NT,A.ownerDocument.doctype.name)&&(gt="<!DOCTYPE "+A.ownerDocument.doctype.name+`>
24
24
  `+gt),xn&&bf([G,Z,ie],ht=>{gt=Cl(gt,ht," ")}),S&&jl?S.createHTML(gt):gt},t.setConfig=function(){let j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Vf(j),Fn=!0},t.clearConfig=function(){ui=null,Fn=!1},t.isValidAttribute=function(j,E,A){ui||Vf({});let z=Ue(j),Y=Ue(E);return sv(z,Y,A)},t.addHook=function(j,E){typeof E=="function"&&(D[j]=D[j]||[],bl(D[j],E))},t.removeHook=function(j){if(D[j])return ET(D[j])},t.removeHooks=function(j){D[j]&&(D[j]=[])},t.removeAllHooks=function(){D={}},t}var _T=MT();var pr=w(U());var DM={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function DT(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function kl(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Pl(e,t){var n,r,o,i,s,a=/((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,l=[],u="",c=t||{},f=0;function d(v){var y=DM[v[1]||""],m=l[l.length-1]==v;return y?y[1]?(m?l.pop():l.push(v),y[0|m]):y[0]:v}function p(){for(var v="";l.length;)v+=d(l[l.length-1]);return v}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(v,y,m){return c[y.toLowerCase()]=m,""}).replace(/^\n+|\n+$/g,"");o=a.exec(e);)r=e.substring(f,o.index),f=a.lastIndex,n=o[0],r.match(/[^\\](\\\\)*\\$/)||((s=o[3]||o[4])?n='<pre class="code '+(o[4]?"poetry":o[2].toLowerCase())+'"><code'+(o[2]?' class="language-'+o[2].toLowerCase()+'"':"")+">"+DT(kl(s).replace(/^\n+|\n+$/g,""))+"</code></pre>":(s=o[6])?(s.match(/\./)&&(o[5]=o[5].replace(/^\d+/gm,"")),i=Pl(DT(o[5].replace(/^\s*[>*+.-]/gm,""))),s==">"?s="blockquote":(s=s.match(/\./)?"ol":"ul",i=i.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),n="<"+s+">"+i+"</"+s+">"):o[8]?n='<img src="'+kl(o[8])+'" alt="'+kl(o[7])+'">':o[10]?(u=u.replace("<a>",'<a href="'+kl(o[11]||c[r.toLowerCase()])+'">'),n=p()+"</a>"):o[9]?n="<a>":o[12]||o[14]?n="<"+(s="h"+(o[14]?o[14].length:o[13]>"="?1:2))+">"+Pl(o[12]||o[15],c)+"</"+s+">":o[16]?n="<code>"+kl(o[16])+"</code>":(o[17]||o[1])&&(n=d(o[17]||"--"))),u+=r,u+=n;return(u+e.substring(f)+p()).replace(/^\n+|\n+$/g,"")}var FT={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};var Sn=w(b());function FM(e){return`<button type="button" data-copy-icon class=${e}><svg version="1.1" x="0px" y="0px" viewBox="0 0 115.77 122.88" width="10px" height="10px" fill="black"><g><path d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"/></g></svg></button>`}function Ay(e){var n;let t=e.cloneNode(!0);return t.querySelectorAll("div,button").forEach(r=>r.remove()),(n=t.textContent)!=null?n:""}function HM(e){return e.replace(/\r\n/g,`
25
- `)}function UM(e){return e.replace(new RegExp("(?<!\\]\\()(https?:\\/\\/[^\\s]+)","g"),"[$1]($1)")}var zM=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=L("Markdown",FT),s=(0,pr.useRef)(null),[a,l]=(0,pr.useState)(null),u=(0,pr.useMemo)(()=>{let y=Pl(UM(HM(e)));return _T.sanitize(y).replaceAll("</code>",`${FM(i.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[e]),c=y=>{var h;let m=y.target,g=!!((h=s.current)!=null&&h.querySelector("code"));if(["A","BUTTON"].includes(m.tagName)){l(null);return}a||g&&m.tagName!=="CODE"||!g&&m!==s.current||(m.addEventListener("mouseleave",()=>l(null),{once:!0}),l(m))},f=()=>{if(!a)return;l(null);let y=a.querySelector("button");y&&(ms(y,i.fadeup),r(Ay(a)))},d=y=>{let m=y.target;if(m.tagName==="A"){y.stopPropagation();return}"copyIcon"in m.dataset&&(ms(m,i.fadeup),r(Ay(m.parentElement)))},p=()=>{!a||!o||(l(null),o(Ay(a)))},v=y=>{if(y===null)return;let m=y.getBoundingClientRect();m.left<0?y.style.transform=`translateX(${-m.left+2}px)`:m.right>window.innerWidth&&(y.style.transform=`translateX(${window.innerWidth-m.right-2}px)`)};return(0,Sn.jsxs)(pr.Fragment,{children:[a&&(0,Sn.jsxs)(Cs,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,Sn.jsxs)("div",{className:i.options,ref:v,children:[(0,Sn.jsx)("button",{type:"button",className:i.option,onClick:f,children:n}),o&&(0,Sn.jsxs)(pr.Fragment,{children:[(0,Sn.jsx)("div",{className:i.divider}),(0,Sn.jsx)("button",{type:"button",className:i.option,onClick:p,children:t})]})]}),(0,Sn.jsx)("div",{className:i.arrow})]}),(0,Sn.jsx)("div",{ref:s,className:i.root,dangerouslySetInnerHTML:{__html:u},onMouseOver:c,onClick:d})]})},HT=zM;var Ly={};Qe(Ly,{enUS:()=>BM,nlNL:()=>jM});var BM={useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},jM={useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var UT={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l"};var tn=w(b()),VM=({cue:e,onCallToAction:t,onRemove:n,onCopy:r,onUse:o})=>{let i=L("WidgetCue",UT),s=q(Ly),a=gs(),l=B("hasKeyboardInput"),u=()=>{t&&t(e),n(e)},c=p=>{r&&r(p,e)},f=p=>{o&&o(p,e)},d=p=>{p.preventDefault(),p.stopPropagation(),n(e)};return(0,zT.useEffect)(()=>{a("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,tn.jsxs)(re,{"data-testid":"cue",children:[(0,tn.jsx)(ge,{children:(0,tn.jsxs)(ge.Content,{children:[e.title&&(0,tn.jsx)(ge.Title,{className:i.title,"data-testid":"widget-cue-title",children:e.title}),(0,tn.jsx)(HT,{content:e.text,useLabel:s("useCue"),copyLabel:s("copyCue"),onCopy:c,onUse:l?f:void 0})]})}),(0,tn.jsxs)(re.ButtonsContainer,{children:[(0,tn.jsxs)("div",{className:i.actions,children:[e.callToAction&&(0,tn.jsx)(re.Button,{onClick:u,children:e.callToAction.label}),(0,tn.jsx)(re.Button,{onClick:d,children:s("removeCue")})]}),(0,tn.jsx)(ys,{eventName:"Assistant response feedback",eventData:{name:e.rule.name,group:e.rule.label,description:e.rule.description,cueText:e.text},feedbackText:e.text,feedbackType:"assistant"})]})]})},BT=VM;var Rl=w(b()),KM=({cues:e})=>{let t=Q(),n=Qt(),r=gs(),o=l=>{t(tT({id:l.rule.id})),t(ib({code:l.rule.label})),r("Assistant response closed",{name:l.rule.name,group:l.rule.label,description:l.rule.description,cueText:l.text})},i=(l,u)=>{Jn(l),r("Assistant response copied",{name:u.rule.name,group:u.rule.label,description:u.rule.description,copiedText:l})},s=l=>{l.callToAction&&(t(Vd(l)),r("Assistant call to action",{name:l.rule.name,group:l.rule.label,description:l.rule.description,eventName:l.callToAction.event,value:l.callToAction.value}))},a=(l,u)=>{n.send(Yr,{text:l,suggestion:{source:"cue",sourceText:l}}),r("Assistant response used",{name:u.rule.name,group:u.rule.label,description:u.rule.description,usedText:l})};return(0,Rl.jsx)(Rl.Fragment,{children:e.map(l=>(0,Rl.jsx)(BT,{cue:l,onCallToAction:s,onRemove:o,onCopy:i,onUse:a},l.rule.id))})},jT=KM;var Pf=w(U());var VT={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var wn=w(b());function WM(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var KT=({data:e,schema:t})=>{let n=L("WidgetCustomData",VT),r=o=>{Jn(o)};return(0,Pf.useEffect)(()=>{H.info("Custom data",e,t)},[e]),(0,wn.jsx)("dl",{className:n.root,children:t.map(o=>{let i=WM(e,o.path);return(0,wn.jsxs)(Pf.Fragment,{children:[(0,wn.jsx)("dt",{className:n.label,children:o.label}),(0,wn.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,wn.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,wn.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,wn.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,wn.jsx)("span",{className:n.copyButtonText,children:i}),(0,wn.jsx)(El,{})]}):"-"})]},o.label)})})};var $T=w(U());var $M=/(https?:\/\/[^\s]+)/,WT=e=>e.split(" ").find(t=>$M.test(t));var nn=w(b()),qM=({suggestion:e,lines:t,onUse:n})=>{var f;let r=e.text||e.url||e.message,o=WT(r),i=q(Ko),s=B("showImages"),a=B("fallbackImage"),l=B("hasKeyboardInput"),u=d=>{d.preventDefault(),d.stopPropagation(),l&&n(r)},c=(0,$T.useCallback)(d=>{window.open(o,"_blank"),d.stopPropagation(),d.preventDefault()},[o]);return(0,nn.jsxs)(re,{onClick:l?u:void 0,"data-testid":"edit-suggestion",children:[(0,nn.jsxs)(ge,{children:[s&&e.image&&(0,nn.jsx)(ge.Image,{src:hf(e,"small",a||void 0),title:e.title}),(0,nn.jsxs)(ge.Content,{children:[e.title&&(0,nn.jsx)(ge.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((f=e.searchKeywords)==null?void 0:f.length)>0&&(0,nn.jsx)(re.Labels,{labels:e.searchKeywords}),(0,nn.jsx)(ge.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,nn.jsxs)(re.Actions,{children:[o&&(0,nn.jsx)(re.ActionButton,{onClick:c,label:i("visitUrl")}),l&&(0,nn.jsx)(re.ActionButton,{primary:!0,onClick:u,label:i("useSuggestion")})]})]})},qT=qM;var Al=w(b()),GM=({lines:e,suggestions:t})=>{let n=Qt(),r=(o,i)=>{n.send(Yr,{text:o,suggestion:I(T({},i),{source:i.source,sourceText:i.text})})};return(0,Al.jsx)(Al.Fragment,{children:t.map(o=>(0,Al.jsx)(qT,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},GT=GM;var Ll={};Qe(Ll,{enUS:()=>QM,nlNL:()=>YM});var QM={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},YM={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Il={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",sectionList:"dd-bF9pF",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",link:"dd-DRo0x"};var $=w(b()),Rf=(e,t)=>{let n=M(lt);(0,Ts.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},XM=({onLogIn:e})=>{let t=L("Widget",Il),n=B("isEmbedded"),r=B("adminUrl");return(0,$.jsx)("div",{className:t.loginText,children:(0,$.jsx)("div",{children:(0,$.jsx)(nf,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},QT=({text:e})=>{let t=L("Widget",Il);return(0,$.jsx)("div",{className:t.stateText,children:(0,$.jsx)("div",{children:(0,$.jsx)("p",{children:e})})},"notification")},ZM=()=>{let e=q(Ll),t=Q(),n=L("Widget",Il),r=B("showSearch"),o=B("showSummaryCommand"),i=B("showKnowledgeSearch"),s=M(hs("/admin/")),a=Qt(),l=B("productName"),u=B("hasKeyboardInput"),c=r||o||i||s;return Rf(()=>(t(fy()),()=>{t(YC())}),[t]),!c||!u?null:(0,$.jsx)(En,{title:e("actions"),type:"shortcuts",children:(0,$.jsxs)("div",{className:n.shortcutList,children:[r&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":e("linkSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0}),children:[(0,$.jsx)(ds,{}),e("linkSearch")]}),o&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":e("linkSummary"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,$.jsx)(wT,{}),e("linkSummary")]}),i&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":e("linkKnowledgeSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,$.jsx)(ST,{}),e("linkKnowledgeSearch")]}),s&&(0,$.jsxs)("a",{className:n.shortcut,target:"_blank",href:s,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:l}),rel:"noreferrer",children:[(0,$.jsx)(vT,{}),e("linkStudioLogin",{productName:l})]})]})})},JM=()=>{let e=Q(),t=B("showCustomMessages"),n=M(BC),r=M(rs);return Rf(()=>(e(xl(r)),e($C(r)),()=>{e(qC(r))}),[e,t,r]),!t||n.length===0?null:(0,$.jsx)(En,{type:"custom-messages","data-testid":"custom-messages",children:(0,$.jsx)(St,{withDivider:!0,children:n.map(o=>(0,$.jsx)(gT,{suggestion:o},o.text))})})},e_=()=>{let e=q(Ll),t=Q(),n=B("showAutoflows"),r=M(DC),o=M(rs);return Rf(()=>(t(dr(o)),t(FC(o)),()=>{t(HC(o))}),[t,n,o]),!n||r.length===0?null:(0,$.jsx)(En,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)(pT,{})})})},t_=()=>{let e=Q(),t=M(Wd),n=M(fb),r=M(rT),o=M($1),i=M(jd),s=M($d),a=M(hn),l=M(Gr);return(0,Ts.useEffect)(()=>{!!o&&!n&&H.warn("Custom data provided, but no schema.")},[o,n]),Rf(()=>{t.forEach(({type:u})=>{u==="entities"?e(gn()):su.includes(u)||e(yn(u))})},[e,l,a]),(0,Ts.useEffect)(()=>{r.length>0&&!t.some(u=>u.type==="cues")&&H.warn("Received cues, but cues are not configured in widget.")},[t,r]),(0,$.jsx)(Ts.Fragment,{children:t.map(({type:u,title:c,amount:f,lines:d,schema:p})=>{var v,y;switch(u){case"entities":return i&&i.length>0&&(0,$.jsx)(En,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(yT,{entities:i})},u);case"cues":return r&&r.length>0&&(0,$.jsx)(En,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)(jT,{cues:r})})},u);case"custom-data":return o&&p&&(0,$.jsx)(En,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)(KT,{data:o,schema:p})})},u);default:return((y=(v=s[u])==null?void 0:v.suggestions)==null?void 0:y.length)>0&&(0,$.jsx)(En,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)(GT,{lines:d,contentType:u,suggestions:s[u].suggestions.slice(0,f)||[]})})},u)}})})},n_=({onLogIn:e})=>{let t=q(Ll),n=L("Widget",Il),r=M(os),o=M(lt),i=M(rs),s=M(hn);return r===!1?(0,$.jsx)(QT,{text:t("notSupported")}):o===!1?(0,$.jsx)(XM,{onLogIn:e}):!s||!i||o===null?(0,$.jsx)(QT,{text:t("waiting")}):(0,$.jsx)("div",{className:(0,YT.default)(n.root),"data-testid":"widget",children:(0,$.jsxs)(ru,{className:n.sectionList,children:[(0,$.jsx)(ZM,{}),(0,$.jsx)(JM,{}),(0,$.jsx)(e_,{}),(0,$.jsx)(t_,{})]})})},XT=n_;function ks(e){let t=new Range;return t.selectNodeContents(e),t}function ZT(e,t,n){try{return ao(e,t,n),!0}catch(r){return!1}}function Af(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Lf(e){return"tagName"in e&&e.tagName==="BR"}var Ol=/[\u200B-\u200D\uFEFF]/g;function ao(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(l))return u;for(let d=0;d<=l.length;d++)if(f.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(Ol,""),f=o+c.length,d=t>=o&&t<=f,p=n>=o&&n<=f;if(d){let v=s(u,t-o);v===0&&!p?r.setStartBefore(l):r.setStart(l,v)}p&&(r.setEnd(l,s(u,n-o)),i=!0),o=f;break}case Node.ELEMENT_NODE:{if(Lf(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let c=0;c<l.childNodes.length&&(a(l.childNodes[c]),!i);c++);let u=l.lastChild;Af(l)&&u&&!Af(u)&&!Lf(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Nl(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(f){let d=f===e,p=f===n,v=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let y=f.textContent;p&&(a=u+y.substring(0,r).replace(Ol,"").length),v&&(l=u+y.substring(0,i).replace(Ol,"").length),u+=y.replace(Ol,"").length;break}case Node.ELEMENT_NODE:{if(Lf(f)&&f.nextSibling){u++;break}!d&&Af(f)&&f.previousSibling&&u++;for(let y=0;y<f.childNodes.length;y++){let m=p&&y===r,g=v&&y===i;if(m&&(a=u),g&&(l=u),l!==void 0||((!m||!s)&&c(f.childNodes[y]),v&&y===i-1&&(l=u),l!==void 0))break}v&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:l,end:l}}function Ml(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a=0,l="";function u(c){let f=c===e,d=c===n,p=c===o;switch(d&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let v=d?r:0,y=p?i:void 0;l+=c.textContent.replace(Ol,"").substring(v,y);break}case Node.ELEMENT_NODE:{if(!s&&a===1&&Lf(c)&&c.nextSibling){l+=`
25
+ `)}function UM(e){return e.replace(new RegExp("(?<!\\]\\()(https?:\\/\\/[^\\s]+)","g"),"[$1]($1)")}var zM=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=L("Markdown",FT),s=(0,pr.useRef)(null),[a,l]=(0,pr.useState)(null),u=(0,pr.useMemo)(()=>{let y=Pl(UM(HM(e)));return _T.sanitize(y).replaceAll("</code>",`${FM(i.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[e]),c=y=>{var h;let m=y.target,g=!!((h=s.current)!=null&&h.querySelector("code"));if(["A","BUTTON"].includes(m.tagName)){l(null);return}a||g&&m.tagName!=="CODE"||!g&&m!==s.current||(m.addEventListener("mouseleave",()=>l(null),{once:!0}),l(m))},f=()=>{if(!a)return;l(null);let y=a.querySelector("button");y&&(ms(y,i.fadeup),r(Ay(a)))},d=y=>{let m=y.target;if(m.tagName==="A"){y.stopPropagation();return}"copyIcon"in m.dataset&&(ms(m,i.fadeup),r(Ay(m.parentElement)))},p=()=>{!a||!o||(l(null),o(Ay(a)))},v=y=>{if(y===null)return;let m=y.getBoundingClientRect();m.left<0?y.style.transform=`translateX(${-m.left+2}px)`:m.right>window.innerWidth&&(y.style.transform=`translateX(${window.innerWidth-m.right-2}px)`)};return(0,Sn.jsxs)(pr.Fragment,{children:[a&&(0,Sn.jsxs)(Cs,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,Sn.jsxs)("div",{className:i.options,ref:v,children:[(0,Sn.jsx)("button",{type:"button",className:i.option,onClick:f,children:n}),o&&(0,Sn.jsxs)(pr.Fragment,{children:[(0,Sn.jsx)("div",{className:i.divider}),(0,Sn.jsx)("button",{type:"button",className:i.option,onClick:p,children:t})]})]}),(0,Sn.jsx)("div",{className:i.arrow})]}),(0,Sn.jsx)("div",{ref:s,className:i.root,dangerouslySetInnerHTML:{__html:u},onMouseOver:c,onClick:d})]})},HT=zM;var Ly={};Qe(Ly,{enUS:()=>BM,nlNL:()=>jM});var BM={useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},jM={useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var UT={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l"};var tn=w(b()),VM=({cue:e,onCallToAction:t,onRemove:n,onCopy:r,onUse:o})=>{let i=L("WidgetCue",UT),s=q(Ly),a=gs(),l=B("hasKeyboardInput"),u=()=>{t&&t(e),n(e)},c=p=>{r&&r(p,e)},f=p=>{o&&o(p,e)},d=p=>{p.preventDefault(),p.stopPropagation(),n(e)};return(0,zT.useEffect)(()=>{a("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,tn.jsxs)(re,{"data-testid":"cue",children:[(0,tn.jsx)(ge,{children:(0,tn.jsxs)(ge.Content,{children:[e.title&&(0,tn.jsx)(ge.Title,{className:i.title,"data-testid":"widget-cue-title",children:e.title}),(0,tn.jsx)(HT,{content:e.text,useLabel:s("useCue"),copyLabel:s("copyCue"),onCopy:c,onUse:l?f:void 0})]})}),(0,tn.jsxs)(re.ButtonsContainer,{children:[(0,tn.jsxs)("div",{className:i.actions,children:[e.callToAction&&(0,tn.jsx)(re.Button,{onClick:u,children:e.callToAction.label}),(0,tn.jsx)(re.Button,{onClick:d,children:s("removeCue")})]}),(0,tn.jsx)(ys,{eventName:"Assistant response feedback",eventData:{name:e.rule.name,group:e.rule.label,description:e.rule.description,cueText:e.text},feedbackText:e.text,feedbackType:"assistant"})]})]})},BT=VM;var Rl=w(b()),KM=({cues:e})=>{let t=Q(),n=Qt(),r=gs(),o=l=>{t(tT({id:l.rule.id})),t(ib({code:l.rule.label})),r("Assistant response closed",{name:l.rule.name,group:l.rule.label,description:l.rule.description,cueText:l.text})},i=(l,u)=>{Jn(l),r("Assistant response copied",{name:u.rule.name,group:u.rule.label,description:u.rule.description,copiedText:l})},s=l=>{l.callToAction&&(t(Vd(l)),r("Assistant call to action",{name:l.rule.name,group:l.rule.label,description:l.rule.description,eventName:l.callToAction.event,value:l.callToAction.value}))},a=(l,u)=>{n.send(Yr,{text:l,suggestion:{source:"cue",sourceText:l}}),r("Assistant response used",{name:u.rule.name,group:u.rule.label,description:u.rule.description,usedText:l})};return(0,Rl.jsx)(Rl.Fragment,{children:e.map(l=>(0,Rl.jsx)(BT,{cue:l,onCallToAction:s,onRemove:o,onCopy:i,onUse:a},l.rule.id))})},jT=KM;var Pf=w(U());var VT={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var wn=w(b());function WM(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var KT=({data:e,schema:t})=>{let n=L("WidgetCustomData",VT),r=o=>{Jn(o)};return(0,Pf.useEffect)(()=>{H.info("Custom data",e,t)},[e]),(0,wn.jsx)("dl",{className:n.root,children:t.map(o=>{let i=WM(e,o.path);return(0,wn.jsxs)(Pf.Fragment,{children:[(0,wn.jsx)("dt",{className:n.label,children:o.label}),(0,wn.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,wn.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,wn.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,wn.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,wn.jsx)("span",{className:n.copyButtonText,children:i}),(0,wn.jsx)(El,{})]}):"-"})]},o.label)})})};var $T=w(U());var $M=/(https?:\/\/[^\s]+)/,WT=e=>e.split(" ").find(t=>$M.test(t));var nn=w(b()),qM=({suggestion:e,lines:t,onUse:n})=>{var f;let r=e.text||e.url||e.message,o=WT(r),i=q(Ko),s=B("showImages"),a=B("fallbackImage"),l=B("hasKeyboardInput"),u=d=>{d.preventDefault(),d.stopPropagation(),l&&n(r)},c=(0,$T.useCallback)(d=>{window.open(o,"_blank"),d.stopPropagation(),d.preventDefault()},[o]);return(0,nn.jsxs)(re,{onClick:l?u:void 0,"data-testid":"edit-suggestion",children:[(0,nn.jsxs)(ge,{children:[s&&e.image&&(0,nn.jsx)(ge.Image,{src:hf(e,"small",a||void 0),title:e.title}),(0,nn.jsxs)(ge.Content,{children:[e.title&&(0,nn.jsx)(ge.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((f=e.searchKeywords)==null?void 0:f.length)>0&&(0,nn.jsx)(re.Labels,{labels:e.searchKeywords}),(0,nn.jsx)(ge.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,nn.jsxs)(re.Actions,{children:[o&&(0,nn.jsx)(re.ActionButton,{onClick:c,label:i("visitUrl")}),l&&(0,nn.jsx)(re.ActionButton,{primary:!0,onClick:u,label:i("useSuggestion")})]})]})},qT=qM;var Al=w(b()),GM=({lines:e,suggestions:t})=>{let n=Qt(),r=(o,i)=>{n.send(Yr,{text:o,suggestion:I(T({},i),{source:i.source,sourceText:i.text})})};return(0,Al.jsx)(Al.Fragment,{children:t.map(o=>(0,Al.jsx)(qT,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},GT=GM;var Ll={};Qe(Ll,{enUS:()=>QM,nlNL:()=>YM});var QM={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},YM={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Il={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",sectionList:"dd-bF9pF",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",link:"dd-DRo0x"};var $=w(b()),Rf=(e,t)=>{let n=M(lt);(0,Ts.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},XM=({onLogIn:e})=>{let t=L("Widget",Il),n=B("isEmbedded"),r=B("adminUrl");return(0,$.jsx)("div",{className:t.loginText,children:(0,$.jsx)("div",{children:(0,$.jsx)(nf,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},QT=({text:e})=>{let t=L("Widget",Il);return(0,$.jsx)("div",{className:t.stateText,children:(0,$.jsx)("div",{children:(0,$.jsx)("p",{children:e})})},"notification")},ZM=()=>{let e=q(Ll),t=Q(),n=L("Widget",Il),r=B("showSearch"),o=B("showSummaryCommand"),i=B("showKnowledgeSearch"),s=B("isEmbedded"),a=M(hs("/admin/")),l=Qt(),u=B("productName"),c=B("hasKeyboardInput"),f=r||o||i||a;return Rf(()=>{if(s)return t(fy()),()=>{t(YC())}},[t,s]),!f||!c?null:(0,$.jsx)(En,{title:e("actions"),type:"shortcuts",children:(0,$.jsxs)("div",{className:n.shortcutList,children:[r&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":e("linkSearch"),onClick:()=>l.send("ShowCommandPalette",{isOpen:!0}),children:[(0,$.jsx)(ds,{}),e("linkSearch")]}),o&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":e("linkSummary"),onClick:()=>l.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,$.jsx)(wT,{}),e("linkSummary")]}),i&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":e("linkKnowledgeSearch"),onClick:()=>l.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,$.jsx)(ST,{}),e("linkKnowledgeSearch")]}),a&&(0,$.jsxs)("a",{className:n.shortcut,target:"_blank",href:a,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:u}),rel:"noreferrer",children:[(0,$.jsx)(vT,{}),e("linkStudioLogin",{productName:u})]})]})})},JM=()=>{let e=Q(),t=B("showCustomMessages"),n=M(BC),r=M(rs);return Rf(()=>(e(xl(r)),e($C(r)),()=>{e(qC(r))}),[e,t,r]),!t||n.length===0?null:(0,$.jsx)(En,{type:"custom-messages","data-testid":"custom-messages",children:(0,$.jsx)(St,{withDivider:!0,children:n.map(o=>(0,$.jsx)(gT,{suggestion:o},o.text))})})},e_=()=>{let e=q(Ll),t=Q(),n=B("showAutoflows"),r=M(DC),o=M(rs);return Rf(()=>(t(dr(o)),t(FC(o)),()=>{t(HC(o))}),[t,n,o]),!n||r.length===0?null:(0,$.jsx)(En,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)(pT,{})})})},t_=()=>{let e=Q(),t=M(Wd),n=M(fb),r=M(rT),o=M($1),i=M(jd),s=M($d),a=M(hn),l=M(Gr);return(0,Ts.useEffect)(()=>{!!o&&!n&&H.warn("Custom data provided, but no schema.")},[o,n]),Rf(()=>{t.forEach(({type:u})=>{u==="entities"?e(gn()):su.includes(u)||e(yn(u))})},[e,l,a]),(0,Ts.useEffect)(()=>{r.length>0&&!t.some(u=>u.type==="cues")&&H.warn("Received cues, but cues are not configured in widget.")},[t,r]),(0,$.jsx)(Ts.Fragment,{children:t.map(({type:u,title:c,amount:f,lines:d,schema:p})=>{var v,y;switch(u){case"entities":return i&&i.length>0&&(0,$.jsx)(En,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(yT,{entities:i})},u);case"cues":return r&&r.length>0&&(0,$.jsx)(En,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)(jT,{cues:r})})},u);case"custom-data":return o&&p&&(0,$.jsx)(En,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)(KT,{data:o,schema:p})})},u);default:return((y=(v=s[u])==null?void 0:v.suggestions)==null?void 0:y.length)>0&&(0,$.jsx)(En,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)(GT,{lines:d,contentType:u,suggestions:s[u].suggestions.slice(0,f)||[]})})},u)}})})},n_=({onLogIn:e})=>{let t=q(Ll),n=L("Widget",Il),r=M(os),o=M(lt),i=M(rs),s=M(hn);return r===!1?(0,$.jsx)(QT,{text:t("notSupported")}):o===!1?(0,$.jsx)(XM,{onLogIn:e}):!s||!i||o===null?(0,$.jsx)(QT,{text:t("waiting")}):(0,$.jsx)("div",{className:(0,YT.default)(n.root),"data-testid":"widget",children:(0,$.jsxs)(ru,{className:n.sectionList,children:[(0,$.jsx)(ZM,{}),(0,$.jsx)(JM,{}),(0,$.jsx)(e_,{}),(0,$.jsx)(t_,{})]})})},XT=n_;function ks(e){let t=new Range;return t.selectNodeContents(e),t}function ZT(e,t,n){try{return ao(e,t,n),!0}catch(r){return!1}}function Af(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Lf(e){return"tagName"in e&&e.tagName==="BR"}var Ol=/[\u200B-\u200D\uFEFF]/g;function ao(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(l))return u;for(let d=0;d<=l.length;d++)if(f.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(Ol,""),f=o+c.length,d=t>=o&&t<=f,p=n>=o&&n<=f;if(d){let v=s(u,t-o);v===0&&!p?r.setStartBefore(l):r.setStart(l,v)}p&&(r.setEnd(l,s(u,n-o)),i=!0),o=f;break}case Node.ELEMENT_NODE:{if(Lf(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let c=0;c<l.childNodes.length&&(a(l.childNodes[c]),!i);c++);let u=l.lastChild;Af(l)&&u&&!Af(u)&&!Lf(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Nl(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(f){let d=f===e,p=f===n,v=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let y=f.textContent;p&&(a=u+y.substring(0,r).replace(Ol,"").length),v&&(l=u+y.substring(0,i).replace(Ol,"").length),u+=y.replace(Ol,"").length;break}case Node.ELEMENT_NODE:{if(Lf(f)&&f.nextSibling){u++;break}!d&&Af(f)&&f.previousSibling&&u++;for(let y=0;y<f.childNodes.length;y++){let m=p&&y===r,g=v&&y===i;if(m&&(a=u),g&&(l=u),l!==void 0||((!m||!s)&&c(f.childNodes[y]),v&&y===i-1&&(l=u),l!==void 0))break}v&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:l,end:l}}function Ml(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a=0,l="";function u(c){let f=c===e,d=c===n,p=c===o;switch(d&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let v=d?r:0,y=p?i:void 0;l+=c.textContent.replace(Ol,"").substring(v,y);break}case Node.ELEMENT_NODE:{if(!s&&a===1&&Lf(c)&&c.nextSibling){l+=`
26
26
  `;break}!f&&!s&&a===1&&Af(c)&&c.previousSibling&&(l+=`
27
- `);let v=d?r:0,y=p?Math.min(i,c.childNodes.length):c.childNodes.length;for(let m=v;m<y&&(u(c.childNodes[m]),a!==2);m++);break}default:break}p&&(a=2)}return u(e),l}var JT=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(JT||{}),mr=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}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)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.cachedCaretPosition===null;if(!this.isActive||(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText?(this.cachedText=t,this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,o=!0,this.emit("selection",r)),!o))return;let i=this.getCaretPosition();qr(i,this.cachedCaretPosition)||(this.cachedCaretPosition=i,this.emit("caretposition",i))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(JT).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.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.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function ek(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Zo=class extends mr{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Ml(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var s;let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o="getComposedRanges"in r&&n instanceof ShadowRoot?(s=r.getComposedRanges(n))==null?void 0:s[0]:r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let i=this.element.ownerDocument.createRange();return i.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),i.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!i||!this.element.contains(i.startContainer)||!this.element.contains(i.endContainer)?null:i}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!ek(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!ek(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Nl(this.element,n);let r=this.lastKnownSelection;if(r&&ZT(this.element,r.start,r.end))return r;let o=ks(this.element);return o.collapse(!1),Nl(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Ml(this.element,ao(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(i=>{var s,a;i.length===2&&i[0].addedNodes.length===1&&((s=i[0].addedNodes[0])==null?void 0:s.textContent)==="\u2060"&&((a=i[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var Jo=class extends mr{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return null}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function tk(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let i=document.createElement("iframe"),s=new URL(t);return Object.entries(n).forEach(([a,l])=>{s.searchParams.append(a,l)}),i.style.position="absolute",i.style.left="-999em",i.style.width="0px",i.style.height="0px",i.tabIndex=-1,i.id=r,i.title=`iframe-${e}`,i.src=s.toString(),window.document.body.appendChild(i),i}function r_(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var Iy=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},Oy=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=tk(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},Ny=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),H.info("Set sessionId",t),this.sessionId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new Oy(t,this.deepdeskUrl,{debug:!0}):new Iy(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=r_(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(H.info("Received broadcast event",this.sessionId,o),(a=(s=this.eventMap)[i.name])==null||a.call(s,i.payload))};return n.onMessage(r),n}send(t,n,r){var s,a;H.info("Broadcast event",{sessionId:this.sessionId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(s=this.eventMap)[t])==null||a.call(s,n));let i=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;i==null||i.postMessage(I(T({},o),{channel:this.sessionId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),delete this.channel,t&&((r=this.defaultChannel)==null||r.close(),delete this.defaultChannel)}},nk=Ny;var Ps=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var My=e=>new Promise(t=>{setTimeout(t,e)});var Rs=class extends Ps{constructor(){super(...arguments);this.name="ClientError"}},Dy=class extends Ps{constructor(){super(...arguments);this.name="ServerError"}},_y=new Map;function o_(e){return P(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(H.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var lo=class lo{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",C=n,{useCache:u=!1,abortLatest:c=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:v=R=>R instanceof TypeError,retryOnResponse:y=R=>R.status>=500,version:m=null}=C,g=ee(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u)if(l){if(_y.has(s)){r(_y.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h=I(T({credentials:"include"},g),{headers:T({Accept:"application/json","Content-Type":"application/json"},g.headers)});!l&&this.csrfToken&&(h.headers=I(T({},h.headers),{"X-CSRFToken":this.csrfToken})),typeof m=="string"&&(h.headers=I(T({},h.headers),{"X-Deepdesk-API-Version":m}));let S=f,x=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let k=()=>P(this,null,function*(){return S--,a(s,h).then(R=>P(this,null,function*(){return y(R)&&!i.isAborted&&S>0?(yield My(d),k()):R.status===401&&p===!0&&x===!1?(x=!0,yield this.refreshToken(),k()):R})).catch(R=>P(this,null,function*(){if(v(R)&&!i.isAborted&&S>0)return yield My(d),k();throw R}))});k().then(R=>P(this,null,function*(){let N=yield o_(R);if(delete this.latestRequestByUrl[s],R.status>=500){o(new Dy("Server Error",N));return}else if(R.status===401){o(new Rs("Unauthorized",N));return}else if(R.status===403){o(new Rs("Forbidden",N));return}else if(R.status===404){o(new Rs("Not Found",N));return}else if(R.status>=400){o(new Rs("Bad Request",N));return}u&&_y.set(s,N),r(N)})).catch(R=>{o(R)})})}validateToken(){return P(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)try{yield this.refreshToken()}catch(r){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/");return!!n})}refreshToken(){return lo.refreshingToken||(lo.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{lo.refreshingToken=null},1e3*60)})),lo.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,T({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,T({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,T({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,T({method:"DELETE"},n))}};lo.refreshingToken=null;var gr=lo;var rk;(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||(t.EventType={}))})(rk||(rk={}));function If(e){return I(T({},te(e)),{tags:e.tags})}var ei=class ei{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new gr(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>P(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return P(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(ei.exchangeTokenPromise||(ei.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),ei.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return P(this,null,function*(){yield this.preflight(),H.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",I(T({},Ie(t)),{tags:t.tags}),{version:"v2"});return If(n)})}getMe(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return te(t)})}patchMe(t){return P(this,null,function*(){let n=yield this.client.patch("/apis/admin/session/me/",Ie(t));return te(n)})}getProfile(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return te(n)})}getKnowledgeAssistant(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return te(n)})}getContentTypes(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return te(t)})}getAccount(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return te(t)})}getPlatformConfig(t){return P(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return te(r)})}checkUserExists(t){return P(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationBySessionId(r){return P(this,arguments,function*(t,n={}){yield this.preflight(),H.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:i=1e3}=n,s=yield this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return H.info(`Successfully retrieved conversation ${s.id} for session ${t}`),If(s)})}isConversationSupported(r){return P(this,arguments,function*(t,n={}){H.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:i=1e3}=n;return(yield this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"})).has_active_profile})}updateConversation(t,n){return P(this,null,function*(){let r=Ie(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return If(o)})}postMessages(t,n){return P(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>I(T({},Ie(o)),{tags:o.tags})),{version:"v2"})).map(o=>If(o))})}sendEvent(t,n){return P(this,null,function*(){let s=n,{data:r}=s,o=ee(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>I(T({},a),{[l]:u}),{});return this.client.post("/api/events",Ie(I(T(T({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return P(this,null,function*(){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>I(T({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:Ie(T(T({},n),r))},{version:"v1"})})}getEntities(t){return P(this,null,function*(){return(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)},{version:"v1"})).entities})}getTemporaryExchangeToken(){return P(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(t){return P(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw H.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return P(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Ie(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return P(this,arguments,function*(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,Ie(n),{abortLatest:!0,version:"v1"})).map(s=>I(T({},te(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(u=>u.text===s.text))})}isLoggedIn(){return P(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return P(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/autocomplete`,Ie(n),{abortLatest:!0,version:"v1"})).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))})}getPinnedMessages(t){return P(this,null,function*(){let n=yield this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0,version:"v1"});return te(n).map(r=>I(T({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return P(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",Ie(t),{abortLatest:!0,version:"v1"});return te(n)})}search(t){return P(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,Ie(t),{version:"v2"});return te(n)})}knowledgeAssist(i,s,a){return P(this,arguments,function*(t,n,r,o={}){let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Ie({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(u=>({question:u.question,answer:u.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return te(l)})}requestLoginByEmail(t){return P(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return te(n)})}requestPasswordlessToken(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return te(t.token)})}getCsrfToken(){return P(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return P(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return te(n)})}evaluateRule(i,s,a){return P(this,arguments,function*(t,n,r,o={}){let l=new URLSearchParams;o.raiseForFailingConditions&&l.set("raise_for_failing_conditions","true");let u=yield this.client.post(`/api/conversations/${n}/rules/${t}/evaluate?${l.toString()}`,r,{version:"v2"});return u?te(u.cues):[]})}getSummary(r){return P(this,arguments,function*(t,n={}){let o=yield this.client.post("/api/summary",{conversation:{messages:t.filter(i=>i.text&&i.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model},{version:"v1"});return te(o)})}evaluateAssistant(t,n){return P(this,null,function*(){var i;let r=new URLSearchParams;r.append("enforce_cues_schema","true"),n.conversationId&&r.append("conversation_id",n.conversationId);let o=yield this.client.post(`/api/v2/assistants/${t}/evaluate?${r.toString()}`,{input:(i=n.input)!=null?i:{},conversation:n.transcript});return te(o.output)})}getRules(){return P(this,null,function*(){let t=new URLSearchParams,n=yield this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{useCache:!0});return te(n)})}translateMessages(t){return P(this,null,function*(){let n=yield this.client.post("/api/translate",Ie(t),{version:"v2"});return te(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(n0);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})}};ei.exchangeTokenPromise=null;var hr=ei;var _l=class{constructor(t,n){this.url=t;this.eventListeners={};this.options=T({timeout:25e3},n)}proxyEvent(t){this.eventSource.addEventListener(oh(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,te(o))}catch(o){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 ok;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||(t.AutoflowSessionState={}))})(ok||(ok={}));var Dl=class{constructor(t,n={}){this.apiUrl=t;this.streams={};this.logger=H;this.client=new gr(t,n)}getCustomMessages(t){return P(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/suggestions`);return te(n.suggestions)})}sendCustomMessage(t,n){return P(this,null,function*(){let r=yield this.client.post(`/sessions/${t}/messages`,Ie(n));return te(r)})}answerCustomMessage(t,n){return P(this,null,function*(){yield this.client.post(`/sessions/${t}/answers`,Ie(n))})}getAutoflows(t){return P(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/autoflows`);return te(n.autoflows)})}startAutoflowSession(t){return P(this,null,function*(){let n=yield this.client.post("/autoflow-sessions",Ie(t));return te(n)})}stopAutoflowSession(t){return P(this,null,function*(){yield this.client.delete(`/autoflow-sessions/${t}`)})}openStream(t){return this.streams[t]||(this.streams[t]=new _l(`${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 ik={startTime:null,stopTime:null},sk=X({name:"handlingTime",initialState:ik,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(de,()=>ik)}}),{handlingTimeStart:ak,handlingTimeStop:Of,handlingTimeReset:lk}=sk.actions,uk=sk.reducer;var ck=(e={})=>{let t=T({onAuthError:ns(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Nf={list:{keywordMatches:[]},fetchState:"idle"};var ti=K("styleSuggestions/getAll",(n,r)=>P(void 0,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(l=i.conversation.current)==null?void 0:l.profileCode;if(!s)return Nf.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),i_=X({name:"styleSuggestions",initialState:Nf,reducers:{},extraReducers:e=>{e.addCase(ti.pending,t=>{t.fetchState="loading"}).addCase(ti.rejected,t=>{t.fetchState="error"}).addCase(ti.fulfilled,(t,n)=>{t.fetchState="done",qr(t.list,n.payload)||(t.list=n.payload)}).addCase(Oo,t=>{t.list=Nf.list}).addCase(de,()=>Nf)}}),dk=i_.reducer;var fk=(e={})=>{let t,n=!0,r=T({getStyleSuggestions:ti,debounce:500},e);return o=>i=>s=>{var p;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(!((p=u.conversation.current)==null?void 0:p.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 s_(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var pk=(e={})=>{let t=T({getTextSuggestions:yn,getAutocompleteSuggestions:gl,debounce:200,check:On},e),n;return r=>o=>i=>{var y;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,f=(y=l.conversation.current)==null?void 0:y.id,d=i.type===qd.toString();if(!f||!u&&!c)return a;let{input:p}=l;return s_(p,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let m=is(l);m===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(m))},d?0:t.debounce)),a}};var mk=ti.fulfilled.toString();function a_(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 gk=e=>t=>n=>r=>{var u;if(r.type!==mk){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(u=i.conversation)==null?void 0:u.current;if(o===s)return;let l=a_(o,s);r.type===mk&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var l_=kc({assistants:sb,answer:wb,auth:E1,autoflows:UC,conversation:O1,contentTypes:AE,customMessages:GC,passwordlessToken:XC,entities:eb,knowledgeAssistant:yb,handlingTime:uk,info:X1,input:K1,settings:g1,profile:pb,search:oE,styleSuggestions:dk,ui:Xb,rules:nT,textSuggestions:Lb});function hk(e){return xx({reducer:l_,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),ck(),pk({debounce:200}),fk({debounce:500}),gk(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var u_=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},c_=e=>t=>n=>r=>{var a,l,u,c,f,d,p;let o=t.getState(),i=Zg("inlineSuggestions")(o);switch(r.type){case ns.toString():{!r.payload&&e.emit("logout",void 0);break}case gn.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(a=o.conversation.current)==null?void 0:a.id,data:{entities:r.payload}});break;case ut.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((u=o.conversation.current)==null?void 0:u.id),data:r.payload.data});break;case Oo.toString():e.logSendMessage(r.payload);break;case Qo.fulfilled.toString():r.isBroadcasted||e.broadcast(ah,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;case Vd.toString():e.emit("call-to-action",{cue:r.payload});break;case eo.fulfilled.toString():r.isBroadcasted||e.broadcast(lh,r,!1);break;default:break}let s=n(r);switch(r.type){case Oo.toString():e.handleAfterSendMessage(r.payload);break;case yl.toString():e.onUpdateShowTabHint(r.payload);break;case Of.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case ad.toString():{let{start:v,end:y}=o.input.selection;e.emit("replace",I(T({},r.payload),{replace:r.payload.replace==="selection"?{start:v,end:y}:{start:0,end:y}}));break}case un.toString():{let{start:v,end:y}=o.input.selection;e.emit("select-suggestion",I(T({type:u_(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:v,end:y}:{start:0,end:y}})),i&&t.dispatch(Qr([]));break}case ld.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Qr.toString():{i&&r.payload.length>0&&t.dispatch(ud(0));break}case ps.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload,assistant:(p=t.getState().profile.data)==null?void 0:p.summarizerAssistantNew}});break}default:break}return s},yk=c_;function Fy(e){return e.toISOString().replace("T"," ").replace("Z","")}function vk(e,t){var i,s,a,l;let n=(i=e.conversation.current)==null?void 0:i.id;if(!n)return H.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:o}=e.handlingTime;return!r||!o?(H.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:n,clientVersion:t.version,agentId:(s=e.info.agentInfo)==null?void 0:s.agentId,agentName:(a=e.info.agentInfo)==null?void 0:a.agentName,agentEmail:(l=e.info.agentInfo)==null?void 0:l.agentEmail,timeStart:Fy(r),timeStop:Fy(o)}}function Sk(e,t,n){var N,_,D,G;let r=(N=t.conversation.current)==null?void 0:N.id;if(!r)return H.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:u,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:f,pastes:d,cuts:p,deletions:v,textSuggestions:y,offeredTextSuggestions:m}}=t[e],g=o.length,S=y.reduce((Z,{text:ie,searchTerm:yr})=>Z+ie.length-(yr?yr.length:0),0),x=c!=null?c:Date.now(),k=(Date.now()-x)/1e3+(f||0),C=i/k,R=y.reduce((Z,{searchTerm:ie})=>Z+(ie?ie.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:p,deletions:v,lenTextTyped:i+R,lenTextTotal:g,lenTextAssisted:S,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:k,charsPerSecond:C,numPastes:u,textSuggestionsV2:y,suggestionsCounters:[{source:"gpt",countOffered:m.filter(Z=>Z.source==="gpt").length}],agentId:(_=t.info.agentInfo)==null?void 0:_.agentId,agentName:(D=t.info.agentInfo)==null?void 0:D.agentName,agentEmail:(G=t.info.agentInfo)==null?void 0:G.agentEmail}}function Hy(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return Hy(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?Hy(o,t):null}function wk(e,t){return Hy(e,t)}function xk(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function d_(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Mf(e){return d_(e)&&(oo(e)||of(e))}var bk,_n=new Map,f_=["bottom","height","left","right","top","width"],Ek=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:f_.some(n=>e[n]!==t[n]);function Ck(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...Ck(t)]:[]}function Tk(e,t){return!e||!t?null:I(T({},e),{top:e.top+t.top,left:e.left+t.left})}var _f=!1,kk=()=>{_f=!0;let e=[];if(_n.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),_n.delete(n);return}let r=n.getBoundingClientRect();Ek(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(Tk,t.rect):t.rect;Ek(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),_n.size===0){_f=!1;return}bk=window.requestAnimationFrame(kk)};function Uy(e,t){let n=Ck(e),r=[],o=n.map((i,s)=>Uy(i,a=>{r[s]=a;let l=_n.get(e);if(!l)return;let u=r.reduce(Tk,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),_n.has(e)){let s=_n.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else _n.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!_f&&kk()},unobserve(){o.forEach(s=>s.unobserve());let i=_n.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||_n.delete(e),_n.size||(cancelAnimationFrame(bk),_f=!1)}}}}var Pk,Dn=new Map,Rk=()=>{Dn.forEach((e,t)=>{if(!t.isConnected){Dn.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)))}),Dn.size!==0&&(Pk=window.requestAnimationFrame(Rk))};function Ak(e,t){return{observe(){let n=Dn.size===0;Dn.has(e)?Dn.get(e).callbacks.push(t):Dn.set(e,{visible:void 0,callbacks:[t]}),n&&Rk()},unobserve(){let n=Dn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Dn.delete(e),Dn.size||cancelAnimationFrame(Pk)}}}}var zy=["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 By(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function As(e){return parseFloat(e)}function Df(e){return Math.round(e*1e6)}function Lk(e){return e/1e6}function jy(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=As(e.width),i=As(e.borderLeftWidth),s=As(e.borderRightWidth),a=As(e.paddingRight),l=Lk(Df(o)-Df(i)-Df(s)),u=Lk(Df(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function Fl(e,t={}){var c,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=t.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",$o(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};By(r,n,zy),jy(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=Ak(e,()=>{By(r,n,zy),jy(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Uy(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(By(r,n,zy),jy(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),v=window.getComputedStyle(t.closestScrollElement),y=As(v.borderTopWidth),m=As(v.borderBottomWidth),g=p.top+y-d.top,h=d.top+d.height+-(p.top+p.height-m);n.style.clipPath=`inset(${g}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var Ik=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){H.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function p_(e){return e.offsetParent!==null}function Ok(e){if(!p_(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 Ff(e,t,n=100){let r=Ok(e);t({isVisible:r});let o=setInterval(()=>{let i=Ok(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Fe=w(b());var Nk=Ik("showTabHint",!0),Ls=class Ls{constructor({deepdeskUrl:t,brokerUrl:n,version:r=Ls.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let u=t.replace(/\/api$/,"");this.deepdeskApi=new hr(u,{token:i,fetch:s}),this.version=r,this.instanceId=Ls.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[yk({broadcast:(f,d,p)=>{this.broadcastEvents.send(f,d,p)},emit:(f,d)=>this.emit(f,d),handleAfterSendMessage:f=>this.handleAfterSendMessage(f),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:f=>this.logSendMessage(f),onUpdateShowTabHint:f=>Nk.update(f),sendEvent:(f,d)=>this.deepdeskApi.sendEvent(f,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new Dl(n)}),this.store=hk(c),this.broadcastEvents=new nk({debug:!0,deepdeskUrl:u,eventMap:iE(this.store),createCustomChannel:l}),this.store.dispatch(yl(Nk.value())),this.store.dispatch(td({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t: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(ns(null)),this.store.dispatch(Xn()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();lt(r)&&h1(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return P(this,null,function*(){return(yield this.store.dispatch(Xn())).payload})}isConversationSupported(t,n){return P(this,null,function*(){return(yield this.store.dispatch(th({sessionId:t,options:n}))).payload})}createConversation(t){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(rd(t))).payload})}getConversationBySessionId(t,n){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(od({sessionId:t,options:n}))).payload})}upsertConversation(t){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(nh(t))).payload})}postMessages(t){return P(this,null,function*(){return(yield this.store.dispatch(sd(t))).payload})}updateConversation(t){return P(this,null,function*(){return(yield this.store.dispatch(id(t))).payload})}resetConversation(){this.store.dispatch(de()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(td(t))}setVisitorInfo(t){this.store.dispatch(G1(t))}setCustomData(t){this.store.dispatch(Q1(t))}setAgentInfo(t){return P(this,null,function*(){yield this.store.dispatch($a(t))})}setAgentSettings(t){return P(this,null,function*(){yield this.store.dispatch(ih(t))})}getAgentSettings(){return P(this,null,function*(){return(yield this.store.dispatch(sh())).payload})}refresh(){return P(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(cd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(qd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(un(t))}evaluateRule(o){return P(this,arguments,function*(t,n={},r=ZC){return(yield this.store.dispatch(Qo({label:t,params:n,options:r}))).payload.cues})}evaluateAssistant(r){return P(this,arguments,function*(t,n={}){let c=n,{input:o={},transcript:i,showCuesInWidget:s=!0,includeTags:a}=c,l=ee(c,["input","transcript","showCuesInWidget","includeTags"]);Object.assign(o,l);let u=yield this.store.dispatch(eo({assistantCode:t,transcript:i,includeTags:a,input:o,skipState:!s}));if(u.error)throw new Error(u.error.message);return u.payload})}evaluateConversationAssistant(t,n){return P(this,null,function*(){yield this.loadProfileConfig();let r={accepted:"conversationAcceptedAssistant","new-message":"conversationNewMessageAssistant",ended:"conversationEndedAssistant"},o=this.state.profile.data[r[t]];if(!o){H.warn(`No assistant set in profile for conversation event "${t}"`);return}yield this.evaluateAssistant(o,T({transcript:"stored-transcript",includeTags:!0},n))})}getSummary(){return P(this,null,function*(){var n;if(!this.hasConversation())return H.warn("No conversation to create summary for."),null;(n=this.state.profile.data)!=null&&n.summarizerAssistantNew||H.warn("No profile loaded yet, or no summarizer assistant set in profile");let t=yield this.store.dispatch(ps({}));if(t.error)throw new Error(t.error.message);return t.payload})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:l}=this.state.settings,u=a?"below":"above",c=o.length>0;if(!On(this.state)||(this.store.dispatch(F1(rh(t))),t.key!=="Tab"&&!l))return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(z1()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(B1()),t.preventDefault()))};switch(t.key){case"ArrowUp":u==="below"?d():f();break;case"ArrowDown":{u==="below"?f():d();break}case"Escape":{n||(this.store.dispatch(ud(-1)),this.store.dispatch(no({collapse:!0})),this.store.dispatch(Qb(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let p=ss(this.state);if(!p)return;this.store.dispatch(yl(!1)),this.store.dispatch(un({text:p.text,suggestion:p,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.state.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let p=ss(this.state);if(!p)return;this.store.dispatch(un({text:p.text,suggestion:p,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.state.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let p=ss(this.state);if(!p)return;this.store.dispatch(un({text:p.text,suggestion:p,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(no({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Qr([]))}handlingTimeStart(){this.state.handlingTime.startTime||(H.info("Start handling time"),this.store.dispatch(ak()))}handlingTimeStop(){this.state.handlingTime.startTime&&(H.info("Stop handling time"),this.store.dispatch(Of()))}logSendMessage(t){let n=Sk("input",this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let t=vk(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(lk()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Oo((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(V1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){H.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),H.error(i)}})}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}setPlatformVariables(t){this.store.dispatch(Y1(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]=Fl(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,rn.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i?i.ownerDocument.defaultView:null;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=Fl(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,rn.unmountComponentAtNode)(o),u()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return $o(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,rn.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),H.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(H.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(j1(r.metrics))):H.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Mf(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:f,detectSubmit:d,insertLink:p,inputMediator:v,closestScrollSelector:y,appendOverlayTo:m,inlineSuggestions:g,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:p,isEmbedded:f,inlineSuggestions:g,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),$o(t),this.inputMediator=v||(oo(t)?new Jo(t):new Zo(t)),this.inputMediator.on("change",({plainText:k,rawHTML:C})=>{this.store.dispatch(cd({text:k,html:C}))}),this.inputMediator.on("keyup",k=>{this.store.dispatch(H1(rh(k)))}),this.inputMediator.on("keydown",k=>{this.handleKeyDown(k)}),this.inputMediator.on("paste",({pastedText:k,selectionText:C})=>{this.store.dispatch(U1({text:k,selectionText:C}))}),this.inputMediator.on("cut",({selectionText:k})=>{this.store.dispatch(D1(k))});let S;this.inputMediator.on("selection",k=>{clearTimeout(S),k===null?S=setTimeout(()=>{k!==null&&this.store.dispatch(dd(k))},500):this.store.dispatch(dd(k))}),this.inputMediator.on("disabled",()=>{var k;(k=this.inputMediator)==null||k.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(Zd(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Zd(!0))});let x=y&&wk(t,y)||void 0;if(g){let{customStyles:k,appendOverlayTo:C}=n;if(oo(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let R=this.createInlineContainer(t,"deepdesk-caret");(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:k,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(rC,{})})}),R),this.inputMediator.on("caretposition",_=>{_?(R.style.display="block",R.style.top=`${_.top}px`,R.style.left=`${_.left}px`):R.style.display="none"});let N=this.overlayContainerFactory("floating-menu",x||t,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:C},k==null?void 0:k.floatingMenuRootNode);(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:k,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)($b,{onLogIn:()=>this.loginViaPopup().catch(_=>H.warn(_.message))})})}),N)}else{let k=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:m,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:m},r==null?void 0:r.suggestionsRootNode);(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(NC,{inputElement:t})})}),k),(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(fC,{onLogIn:()=>this.loginViaPopup().catch(R=>H.warn(R.message))})})}),C)}(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(Bb,{})})}),this.createContainer("deepdesk-overlays")),this.store.dispatch(cd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(dd(this.inputMediator.getSelection())),this.store.dispatch(Zd(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var k;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((k=this.state.conversation.current)==null?void 0:k.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&H.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(XT,{onLogIn:()=>this.loginViaPopup().catch(s=>H.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,rn.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Ff(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){xk(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>P(this,null,function*(){yield this.store.dispatch(cl());let t=hn(this.state);t&&(yield this.store.dispatch(fl()),this.store.dispatch(td({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:!!t.summarizerAssistantNew||t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))})),this.loadProfileConfigPromise)}loginViaPopup(t){return P(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.state.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,u=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",f),clearInterval(d)};i.onmessage=p=>P(this,null,function*(){var v,y;if((v=p.data)!=null&&v.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=p.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Ga),l=!0,o.port1.close(),n()}catch(m){console.error(m),r(m)}finally{l=!0,u()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let f=p=>P(this,null,function*(){var v;if(p.origin===a.origin)switch((v=p.data)==null?void 0:v.type){case"deepdesk-popup-loaded":{try{let y=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(y,a.origin,[o.port2])}catch(y){H.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{u(),p.data.message==="Timeout"&&H.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{c&&!c.closed||(u(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(u)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return P(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(H.info("Trial is active"),!(yield 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}})}refreshWidgetSuggestions(){return P(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Wd(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(gn()):su.includes(r)||this.store.dispatch(yn(r))})}catch(r){this.handleError(r)}})}};Ls.version="14.1.1-beta.10",Ls.count=0;var Hl=Ls;function m_(e){return P(this,null,function*(){var o,i,s;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(s=(i=e.mimeType)!=null?i:n.headers.get("Content-Type"))!=null?s:"image/jpeg"})})}function Mk(e,t){return P(this,null,function*(){let n=yield m_(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}})}function _k(e,t,n){return P(this,null,function*(){yield new hr(e).authenticateWithKey(t,n)})}function Dk(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Fk(r,o){return P(this,arguments,function*(e,t,n={}){var f,d;let{value:i}=e,{start:s,end:a}=(f=n.replace)!=null?f:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,u=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(c()).then(()=>{e.selectionStart=u.start,e.selectionEnd=u.end,e.blur(),e.focus()})})}function Hk(r,o){return P(this,arguments,function*(e,t,n={}){let i=n.replace?ao(e,n.replace.start,n.replace.end):ks(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
27
+ `);let v=d?r:0,y=p?Math.min(i,c.childNodes.length):c.childNodes.length;for(let m=v;m<y&&(u(c.childNodes[m]),a!==2);m++);break}default:break}p&&(a=2)}return u(e),l}var JT=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(JT||{}),mr=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}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)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.cachedCaretPosition===null;if(!this.isActive||(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText?(this.cachedText=t,this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,o=!0,this.emit("selection",r)),!o))return;let i=this.getCaretPosition();qr(i,this.cachedCaretPosition)||(this.cachedCaretPosition=i,this.emit("caretposition",i))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(JT).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.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.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function ek(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Zo=class extends mr{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Ml(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var s;let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o="getComposedRanges"in r&&n instanceof ShadowRoot?(s=r.getComposedRanges(n))==null?void 0:s[0]:r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let i=this.element.ownerDocument.createRange();return i.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),i.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!i||!this.element.contains(i.startContainer)||!this.element.contains(i.endContainer)?null:i}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!ek(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!ek(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Nl(this.element,n);let r=this.lastKnownSelection;if(r&&ZT(this.element,r.start,r.end))return r;let o=ks(this.element);return o.collapse(!1),Nl(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Ml(this.element,ao(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(i=>{var s,a;i.length===2&&i[0].addedNodes.length===1&&((s=i[0].addedNodes[0])==null?void 0:s.textContent)==="\u2060"&&((a=i[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var Jo=class extends mr{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return null}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function tk(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let i=document.createElement("iframe"),s=new URL(t);return Object.entries(n).forEach(([a,l])=>{s.searchParams.append(a,l)}),i.style.position="absolute",i.style.left="-999em",i.style.width="0px",i.style.height="0px",i.tabIndex=-1,i.id=r,i.title=`iframe-${e}`,i.src=s.toString(),window.document.body.appendChild(i),i}function r_(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var Iy=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},Oy=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=tk(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},Ny=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),H.info("Set sessionId",t),this.sessionId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new Oy(t,this.deepdeskUrl,{debug:!0}):new Iy(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=r_(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(H.info("Received broadcast event",this.sessionId,o),(a=(s=this.eventMap)[i.name])==null||a.call(s,i.payload))};return n.onMessage(r),n}send(t,n,r){var s,a;H.info("Broadcast event",{sessionId:this.sessionId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(s=this.eventMap)[t])==null||a.call(s,n));let i=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;i==null||i.postMessage(I(T({},o),{channel:this.sessionId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),delete this.channel,t&&((r=this.defaultChannel)==null||r.close(),delete this.defaultChannel)}},nk=Ny;var Ps=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var My=e=>new Promise(t=>{setTimeout(t,e)});var Rs=class extends Ps{constructor(){super(...arguments);this.name="ClientError"}},Dy=class extends Ps{constructor(){super(...arguments);this.name="ServerError"}},_y=new Map;function o_(e){return P(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(H.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var lo=class lo{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",C=n,{useCache:u=!1,abortLatest:c=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:v=R=>R instanceof TypeError,retryOnResponse:y=R=>R.status>=500,version:m=null}=C,g=ee(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u)if(l){if(_y.has(s)){r(_y.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h=I(T({credentials:"include"},g),{headers:T({Accept:"application/json","Content-Type":"application/json"},g.headers)});!l&&this.csrfToken&&(h.headers=I(T({},h.headers),{"X-CSRFToken":this.csrfToken})),typeof m=="string"&&(h.headers=I(T({},h.headers),{"X-Deepdesk-API-Version":m}));let S=f,x=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let k=()=>P(this,null,function*(){return S--,a(s,h).then(R=>P(this,null,function*(){return y(R)&&!i.isAborted&&S>0?(yield My(d),k()):R.status===401&&p===!0&&x===!1?(x=!0,yield this.refreshToken(),k()):R})).catch(R=>P(this,null,function*(){if(v(R)&&!i.isAborted&&S>0)return yield My(d),k();throw R}))});k().then(R=>P(this,null,function*(){let N=yield o_(R);if(delete this.latestRequestByUrl[s],R.status>=500){o(new Dy("Server Error",N));return}else if(R.status===401){o(new Rs("Unauthorized",N));return}else if(R.status===403){o(new Rs("Forbidden",N));return}else if(R.status===404){o(new Rs("Not Found",N));return}else if(R.status>=400){o(new Rs("Bad Request",N));return}u&&_y.set(s,N),r(N)})).catch(R=>{o(R)})})}validateToken(){return P(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)try{yield this.refreshToken()}catch(r){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/");return!!n})}refreshToken(){return lo.refreshingToken||(lo.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{lo.refreshingToken=null},1e3*60)})),lo.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,T({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,T({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,T({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,T({method:"DELETE"},n))}};lo.refreshingToken=null;var gr=lo;var rk;(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||(t.EventType={}))})(rk||(rk={}));function If(e){return I(T({},te(e)),{tags:e.tags})}var ei=class ei{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new gr(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>P(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return P(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(ei.exchangeTokenPromise||(ei.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),ei.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return P(this,null,function*(){yield this.preflight(),H.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",I(T({},Ie(t)),{tags:t.tags}),{version:"v2"});return If(n)})}getMe(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return te(t)})}patchMe(t){return P(this,null,function*(){let n=yield this.client.patch("/apis/admin/session/me/",Ie(t));return te(n)})}getProfile(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return te(n)})}getKnowledgeAssistant(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return te(n)})}getContentTypes(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return te(t)})}getAccount(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return te(t)})}getPlatformConfig(t){return P(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return te(r)})}checkUserExists(t){return P(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationBySessionId(r){return P(this,arguments,function*(t,n={}){yield this.preflight(),H.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:i=1e3}=n,s=yield this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return H.info(`Successfully retrieved conversation ${s.id} for session ${t}`),If(s)})}isConversationSupported(r){return P(this,arguments,function*(t,n={}){H.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:i=1e3}=n;return(yield this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"})).has_active_profile})}updateConversation(t,n){return P(this,null,function*(){let r=Ie(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return If(o)})}postMessages(t,n){return P(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>I(T({},Ie(o)),{tags:o.tags})),{version:"v2"})).map(o=>If(o))})}sendEvent(t,n){return P(this,null,function*(){let s=n,{data:r}=s,o=ee(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>I(T({},a),{[l]:u}),{});return this.client.post("/api/events",Ie(I(T(T({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return P(this,null,function*(){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>I(T({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:Ie(T(T({},n),r))},{version:"v1"})})}getEntities(t){return P(this,null,function*(){return(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)},{version:"v1"})).entities})}getTemporaryExchangeToken(){return P(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(t){return P(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw H.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return P(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Ie(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return P(this,arguments,function*(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,Ie(n),{abortLatest:!0,version:"v1"})).map(s=>I(T({},te(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(u=>u.text===s.text))})}isLoggedIn(){return P(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return P(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/autocomplete`,Ie(n),{abortLatest:!0,version:"v1"})).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))})}getPinnedMessages(t){return P(this,null,function*(){let n=yield this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0,version:"v1"});return te(n).map(r=>I(T({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return P(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",Ie(t),{abortLatest:!0,version:"v1"});return te(n)})}search(t){return P(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,Ie(t),{version:"v2"});return te(n)})}knowledgeAssist(i,s,a){return P(this,arguments,function*(t,n,r,o={}){let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Ie({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(u=>({question:u.question,answer:u.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return te(l)})}requestLoginByEmail(t){return P(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return te(n)})}requestPasswordlessToken(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return te(t.token)})}getCsrfToken(){return P(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return P(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return te(n)})}evaluateRule(i,s,a){return P(this,arguments,function*(t,n,r,o={}){let l=new URLSearchParams;o.raiseForFailingConditions&&l.set("raise_for_failing_conditions","true");let u=yield this.client.post(`/api/conversations/${n}/rules/${t}/evaluate?${l.toString()}`,r,{version:"v2"});return u?te(u.cues):[]})}getSummary(r){return P(this,arguments,function*(t,n={}){let o=yield this.client.post("/api/summary",{conversation:{messages:t.filter(i=>i.text&&i.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model},{version:"v1"});return te(o)})}evaluateAssistant(t,n){return P(this,null,function*(){var i;let r=new URLSearchParams;r.append("enforce_cues_schema","true"),n.conversationId&&r.append("conversation_id",n.conversationId);let o=yield this.client.post(`/api/v2/assistants/${t}/evaluate?${r.toString()}`,{input:(i=n.input)!=null?i:{},conversation:n.transcript});return te(o.output)})}getRules(){return P(this,null,function*(){let t=new URLSearchParams,n=yield this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{useCache:!0});return te(n)})}translateMessages(t){return P(this,null,function*(){let n=yield this.client.post("/api/translate",Ie(t),{version:"v2"});return te(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(n0);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})}};ei.exchangeTokenPromise=null;var hr=ei;var _l=class{constructor(t,n){this.url=t;this.eventListeners={};this.options=T({timeout:25e3},n)}proxyEvent(t){this.eventSource.addEventListener(oh(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,te(o))}catch(o){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 ok;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||(t.AutoflowSessionState={}))})(ok||(ok={}));var Dl=class{constructor(t,n={}){this.apiUrl=t;this.streams={};this.logger=H;this.client=new gr(t,n)}getCustomMessages(t){return P(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/suggestions`);return te(n.suggestions)})}sendCustomMessage(t,n){return P(this,null,function*(){let r=yield this.client.post(`/sessions/${t}/messages`,Ie(n));return te(r)})}answerCustomMessage(t,n){return P(this,null,function*(){yield this.client.post(`/sessions/${t}/answers`,Ie(n))})}getAutoflows(t){return P(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/autoflows`);return te(n.autoflows)})}startAutoflowSession(t){return P(this,null,function*(){let n=yield this.client.post("/autoflow-sessions",Ie(t));return te(n)})}stopAutoflowSession(t){return P(this,null,function*(){yield this.client.delete(`/autoflow-sessions/${t}`)})}openStream(t){return this.streams[t]||(this.streams[t]=new _l(`${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 ik={startTime:null,stopTime:null},sk=X({name:"handlingTime",initialState:ik,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(de,()=>ik)}}),{handlingTimeStart:ak,handlingTimeStop:Of,handlingTimeReset:lk}=sk.actions,uk=sk.reducer;var ck=(e={})=>{let t=T({onAuthError:ns(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Nf={list:{keywordMatches:[]},fetchState:"idle"};var ti=K("styleSuggestions/getAll",(n,r)=>P(void 0,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(l=i.conversation.current)==null?void 0:l.profileCode;if(!s)return Nf.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),i_=X({name:"styleSuggestions",initialState:Nf,reducers:{},extraReducers:e=>{e.addCase(ti.pending,t=>{t.fetchState="loading"}).addCase(ti.rejected,t=>{t.fetchState="error"}).addCase(ti.fulfilled,(t,n)=>{t.fetchState="done",qr(t.list,n.payload)||(t.list=n.payload)}).addCase(Oo,t=>{t.list=Nf.list}).addCase(de,()=>Nf)}}),dk=i_.reducer;var fk=(e={})=>{let t,n=!0,r=T({getStyleSuggestions:ti,debounce:500},e);return o=>i=>s=>{var p;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(!((p=u.conversation.current)==null?void 0:p.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 s_(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var pk=(e={})=>{let t=T({getTextSuggestions:yn,getAutocompleteSuggestions:gl,debounce:200,check:On},e),n;return r=>o=>i=>{var y;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,f=(y=l.conversation.current)==null?void 0:y.id,d=i.type===qd.toString();if(!f||!u&&!c)return a;let{input:p}=l;return s_(p,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let m=is(l);m===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(m))},d?0:t.debounce)),a}};var mk=ti.fulfilled.toString();function a_(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 gk=e=>t=>n=>r=>{var u;if(r.type!==mk){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(u=i.conversation)==null?void 0:u.current;if(o===s)return;let l=a_(o,s);r.type===mk&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var l_=kc({assistants:sb,answer:wb,auth:E1,autoflows:UC,conversation:O1,contentTypes:AE,customMessages:GC,passwordlessToken:XC,entities:eb,knowledgeAssistant:yb,handlingTime:uk,info:X1,input:K1,settings:g1,profile:pb,search:oE,styleSuggestions:dk,ui:Xb,rules:nT,textSuggestions:Lb});function hk(e){return xx({reducer:l_,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),ck(),pk({debounce:200}),fk({debounce:500}),gk(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var u_=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},c_=e=>t=>n=>r=>{var a,l,u,c,f,d,p;let o=t.getState(),i=Zg("inlineSuggestions")(o);switch(r.type){case ns.toString():{!r.payload&&e.emit("logout",void 0);break}case gn.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(a=o.conversation.current)==null?void 0:a.id,data:{entities:r.payload}});break;case ut.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((u=o.conversation.current)==null?void 0:u.id),data:r.payload.data});break;case Oo.toString():e.logSendMessage(r.payload);break;case Qo.fulfilled.toString():r.isBroadcasted||e.broadcast(ah,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;case Vd.toString():e.emit("call-to-action",{cue:r.payload});break;case eo.fulfilled.toString():r.isBroadcasted||e.broadcast(lh,r,!1);break;default:break}let s=n(r);switch(r.type){case Oo.toString():e.handleAfterSendMessage(r.payload);break;case yl.toString():e.onUpdateShowTabHint(r.payload);break;case Of.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case ad.toString():{let{start:v,end:y}=o.input.selection;e.emit("replace",I(T({},r.payload),{replace:r.payload.replace==="selection"?{start:v,end:y}:{start:0,end:y}}));break}case un.toString():{let{start:v,end:y}=o.input.selection;e.emit("select-suggestion",I(T({type:u_(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:v,end:y}:{start:0,end:y}})),i&&t.dispatch(Qr([]));break}case ld.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Qr.toString():{i&&r.payload.length>0&&t.dispatch(ud(0));break}case ps.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload,assistant:(p=t.getState().profile.data)==null?void 0:p.summarizerAssistantNew}});break}default:break}return s},yk=c_;function Fy(e){return e.toISOString().replace("T"," ").replace("Z","")}function vk(e,t){var i,s,a,l;let n=(i=e.conversation.current)==null?void 0:i.id;if(!n)return H.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:o}=e.handlingTime;return!r||!o?(H.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:n,clientVersion:t.version,agentId:(s=e.info.agentInfo)==null?void 0:s.agentId,agentName:(a=e.info.agentInfo)==null?void 0:a.agentName,agentEmail:(l=e.info.agentInfo)==null?void 0:l.agentEmail,timeStart:Fy(r),timeStop:Fy(o)}}function Sk(e,t,n){var N,_,D,G;let r=(N=t.conversation.current)==null?void 0:N.id;if(!r)return H.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:u,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:f,pastes:d,cuts:p,deletions:v,textSuggestions:y,offeredTextSuggestions:m}}=t[e],g=o.length,S=y.reduce((Z,{text:ie,searchTerm:yr})=>Z+ie.length-(yr?yr.length:0),0),x=c!=null?c:Date.now(),k=(Date.now()-x)/1e3+(f||0),C=i/k,R=y.reduce((Z,{searchTerm:ie})=>Z+(ie?ie.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:p,deletions:v,lenTextTyped:i+R,lenTextTotal:g,lenTextAssisted:S,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:k,charsPerSecond:C,numPastes:u,textSuggestionsV2:y,suggestionsCounters:[{source:"gpt",countOffered:m.filter(Z=>Z.source==="gpt").length}],agentId:(_=t.info.agentInfo)==null?void 0:_.agentId,agentName:(D=t.info.agentInfo)==null?void 0:D.agentName,agentEmail:(G=t.info.agentInfo)==null?void 0:G.agentEmail}}function Hy(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return Hy(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?Hy(o,t):null}function wk(e,t){return Hy(e,t)}function xk(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function d_(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Mf(e){return d_(e)&&(oo(e)||of(e))}var bk,_n=new Map,f_=["bottom","height","left","right","top","width"],Ek=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:f_.some(n=>e[n]!==t[n]);function Ck(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...Ck(t)]:[]}function Tk(e,t){return!e||!t?null:I(T({},e),{top:e.top+t.top,left:e.left+t.left})}var _f=!1,kk=()=>{_f=!0;let e=[];if(_n.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),_n.delete(n);return}let r=n.getBoundingClientRect();Ek(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(Tk,t.rect):t.rect;Ek(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),_n.size===0){_f=!1;return}bk=window.requestAnimationFrame(kk)};function Uy(e,t){let n=Ck(e),r=[],o=n.map((i,s)=>Uy(i,a=>{r[s]=a;let l=_n.get(e);if(!l)return;let u=r.reduce(Tk,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),_n.has(e)){let s=_n.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else _n.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!_f&&kk()},unobserve(){o.forEach(s=>s.unobserve());let i=_n.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||_n.delete(e),_n.size||(cancelAnimationFrame(bk),_f=!1)}}}}var Pk,Dn=new Map,Rk=()=>{Dn.forEach((e,t)=>{if(!t.isConnected){Dn.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)))}),Dn.size!==0&&(Pk=window.requestAnimationFrame(Rk))};function Ak(e,t){return{observe(){let n=Dn.size===0;Dn.has(e)?Dn.get(e).callbacks.push(t):Dn.set(e,{visible:void 0,callbacks:[t]}),n&&Rk()},unobserve(){let n=Dn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Dn.delete(e),Dn.size||cancelAnimationFrame(Pk)}}}}var zy=["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 By(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function As(e){return parseFloat(e)}function Df(e){return Math.round(e*1e6)}function Lk(e){return e/1e6}function jy(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=As(e.width),i=As(e.borderLeftWidth),s=As(e.borderRightWidth),a=As(e.paddingRight),l=Lk(Df(o)-Df(i)-Df(s)),u=Lk(Df(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function Fl(e,t={}){var c,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=t.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",$o(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};By(r,n,zy),jy(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=Ak(e,()=>{By(r,n,zy),jy(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Uy(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(By(r,n,zy),jy(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),v=window.getComputedStyle(t.closestScrollElement),y=As(v.borderTopWidth),m=As(v.borderBottomWidth),g=p.top+y-d.top,h=d.top+d.height+-(p.top+p.height-m);n.style.clipPath=`inset(${g}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var Ik=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){H.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function p_(e){return e.offsetParent!==null}function Ok(e){if(!p_(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 Ff(e,t,n=100){let r=Ok(e);t({isVisible:r});let o=setInterval(()=>{let i=Ok(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Fe=w(b());var Nk=Ik("showTabHint",!0),Ls=class Ls{constructor({deepdeskUrl:t,brokerUrl:n,version:r=Ls.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let u=t.replace(/\/api$/,"");this.deepdeskApi=new hr(u,{token:i,fetch:s}),this.version=r,this.instanceId=Ls.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[yk({broadcast:(f,d,p)=>{this.broadcastEvents.send(f,d,p)},emit:(f,d)=>this.emit(f,d),handleAfterSendMessage:f=>this.handleAfterSendMessage(f),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:f=>this.logSendMessage(f),onUpdateShowTabHint:f=>Nk.update(f),sendEvent:(f,d)=>this.deepdeskApi.sendEvent(f,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new Dl(n)}),this.store=hk(c),this.broadcastEvents=new nk({debug:!0,deepdeskUrl:u,eventMap:iE(this.store),createCustomChannel:l}),this.store.dispatch(yl(Nk.value())),this.store.dispatch(td({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t: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(ns(null)),this.store.dispatch(Xn()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();lt(r)&&h1(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return P(this,null,function*(){return(yield this.store.dispatch(Xn())).payload})}isConversationSupported(t,n){return P(this,null,function*(){return(yield this.store.dispatch(th({sessionId:t,options:n}))).payload})}createConversation(t){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(rd(t))).payload})}getConversationBySessionId(t,n){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(od({sessionId:t,options:n}))).payload})}upsertConversation(t){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(nh(t))).payload})}postMessages(t){return P(this,null,function*(){return(yield this.store.dispatch(sd(t))).payload})}updateConversation(t){return P(this,null,function*(){return(yield this.store.dispatch(id(t))).payload})}resetConversation(){this.store.dispatch(de()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(td(t))}setVisitorInfo(t){this.store.dispatch(G1(t))}setCustomData(t){this.store.dispatch(Q1(t))}setAgentInfo(t){return P(this,null,function*(){yield this.store.dispatch($a(t))})}setAgentSettings(t){return P(this,null,function*(){yield this.store.dispatch(ih(t))})}getAgentSettings(){return P(this,null,function*(){return(yield this.store.dispatch(sh())).payload})}refresh(){return P(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(cd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(qd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(un(t))}evaluateRule(o){return P(this,arguments,function*(t,n={},r=ZC){return(yield this.store.dispatch(Qo({label:t,params:n,options:r}))).payload.cues})}evaluateAssistant(r){return P(this,arguments,function*(t,n={}){let c=n,{input:o={},transcript:i,showCuesInWidget:s=!0,includeTags:a}=c,l=ee(c,["input","transcript","showCuesInWidget","includeTags"]);Object.assign(o,l);let u=yield this.store.dispatch(eo({assistantCode:t,transcript:i,includeTags:a,input:o,skipState:!s}));if(u.error)throw new Error(u.error.message);return u.payload})}evaluateConversationAssistant(t,n){return P(this,null,function*(){yield this.loadProfileConfig();let r={accepted:"conversationAcceptedAssistant","new-message":"conversationNewMessageAssistant",ended:"conversationEndedAssistant"},o=this.state.profile.data[r[t]];if(!o){H.warn(`No assistant set in profile for conversation event "${t}"`);return}yield this.evaluateAssistant(o,T({transcript:"stored-transcript",includeTags:!0},n))})}getSummary(){return P(this,null,function*(){var n;if(!this.hasConversation())return H.warn("No conversation to create summary for."),null;(n=this.state.profile.data)!=null&&n.summarizerAssistantNew||H.warn("No profile loaded yet, or no summarizer assistant set in profile");let t=yield this.store.dispatch(ps({}));if(t.error)throw new Error(t.error.message);return t.payload})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:l}=this.state.settings,u=a?"below":"above",c=o.length>0;if(!On(this.state)||(this.store.dispatch(F1(rh(t))),t.key!=="Tab"&&!l))return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(z1()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(B1()),t.preventDefault()))};switch(t.key){case"ArrowUp":u==="below"?d():f();break;case"ArrowDown":{u==="below"?f():d();break}case"Escape":{n||(this.store.dispatch(ud(-1)),this.store.dispatch(no({collapse:!0})),this.store.dispatch(Qb(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let p=ss(this.state);if(!p)return;this.store.dispatch(yl(!1)),this.store.dispatch(un({text:p.text,suggestion:p,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.state.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let p=ss(this.state);if(!p)return;this.store.dispatch(un({text:p.text,suggestion:p,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.state.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let p=ss(this.state);if(!p)return;this.store.dispatch(un({text:p.text,suggestion:p,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(no({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Qr([]))}handlingTimeStart(){this.state.handlingTime.startTime||(H.info("Start handling time"),this.store.dispatch(ak()))}handlingTimeStop(){this.state.handlingTime.startTime&&(H.info("Stop handling time"),this.store.dispatch(Of()))}logSendMessage(t){let n=Sk("input",this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let t=vk(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(lk()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Oo((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(V1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){H.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),H.error(i)}})}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}setPlatformVariables(t){this.store.dispatch(Y1(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]=Fl(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,rn.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i?i.ownerDocument.defaultView:null;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=Fl(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,rn.unmountComponentAtNode)(o),u()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return $o(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,rn.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),H.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(H.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(j1(r.metrics))):H.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Mf(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:f,detectSubmit:d,insertLink:p,inputMediator:v,closestScrollSelector:y,appendOverlayTo:m,inlineSuggestions:g,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:p,isEmbedded:f,inlineSuggestions:g,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),$o(t),this.inputMediator=v||(oo(t)?new Jo(t):new Zo(t)),this.inputMediator.on("change",({plainText:k,rawHTML:C})=>{this.store.dispatch(cd({text:k,html:C}))}),this.inputMediator.on("keyup",k=>{this.store.dispatch(H1(rh(k)))}),this.inputMediator.on("keydown",k=>{this.handleKeyDown(k)}),this.inputMediator.on("paste",({pastedText:k,selectionText:C})=>{this.store.dispatch(U1({text:k,selectionText:C}))}),this.inputMediator.on("cut",({selectionText:k})=>{this.store.dispatch(D1(k))});let S;this.inputMediator.on("selection",k=>{clearTimeout(S),k===null?S=setTimeout(()=>{k!==null&&this.store.dispatch(dd(k))},500):this.store.dispatch(dd(k))}),this.inputMediator.on("disabled",()=>{var k;(k=this.inputMediator)==null||k.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(Zd(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Zd(!0))});let x=y&&wk(t,y)||void 0;if(g){let{customStyles:k,appendOverlayTo:C}=n;if(oo(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let R=this.createInlineContainer(t,"deepdesk-caret");(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:k,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(rC,{})})}),R),this.inputMediator.on("caretposition",_=>{_?(R.style.display="block",R.style.top=`${_.top}px`,R.style.left=`${_.left}px`):R.style.display="none"});let N=this.overlayContainerFactory("floating-menu",x||t,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:C},k==null?void 0:k.floatingMenuRootNode);(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:k,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)($b,{onLogIn:()=>this.loginViaPopup().catch(_=>H.warn(_.message))})})}),N)}else{let k=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:m,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:m},r==null?void 0:r.suggestionsRootNode);(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(NC,{inputElement:t})})}),k),(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(fC,{onLogIn:()=>this.loginViaPopup().catch(R=>H.warn(R.message))})})}),C)}(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(Bb,{})})}),this.createContainer("deepdesk-overlays")),this.store.dispatch(cd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(dd(this.inputMediator.getSelection())),this.store.dispatch(Zd(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var k;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((k=this.state.conversation.current)==null?void 0:k.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&H.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,rn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(XT,{onLogIn:()=>this.loginViaPopup().catch(s=>H.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,rn.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Ff(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){xk(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>P(this,null,function*(){yield this.store.dispatch(cl());let t=hn(this.state);t&&(yield this.store.dispatch(fl()),this.store.dispatch(td({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:!!t.summarizerAssistantNew||t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))})),this.loadProfileConfigPromise)}loginViaPopup(t){return P(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.state.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,u=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",f),clearInterval(d)};i.onmessage=p=>P(this,null,function*(){var v,y;if((v=p.data)!=null&&v.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=p.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Ga),l=!0,o.port1.close(),n()}catch(m){console.error(m),r(m)}finally{l=!0,u()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let f=p=>P(this,null,function*(){var v;if(p.origin===a.origin)switch((v=p.data)==null?void 0:v.type){case"deepdesk-popup-loaded":{try{let y=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(y,a.origin,[o.port2])}catch(y){H.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{u(),p.data.message==="Timeout"&&H.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{c&&!c.closed||(u(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(u)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return P(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(H.info("Trial is active"),!(yield 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}})}refreshWidgetSuggestions(){return P(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Wd(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(gn()):su.includes(r)||this.store.dispatch(yn(r))})}catch(r){this.handleError(r)}})}};Ls.version="14.1.1-beta.11",Ls.count=0;var Hl=Ls;function m_(e){return P(this,null,function*(){var o,i,s;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(s=(i=e.mimeType)!=null?i:n.headers.get("Content-Type"))!=null?s:"image/jpeg"})})}function Mk(e,t){return P(this,null,function*(){let n=yield m_(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}})}function _k(e,t,n){return P(this,null,function*(){yield new hr(e).authenticateWithKey(t,n)})}function Dk(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Fk(r,o){return P(this,arguments,function*(e,t,n={}){var f,d;let{value:i}=e,{start:s,end:a}=(f=n.replace)!=null?f:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,u=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(c()).then(()=>{e.selectionStart=u.start,e.selectionEnd=u.end,e.blur(),e.focus()})})}function Hk(r,o){return P(this,arguments,function*(e,t,n={}){let i=n.replace?ao(e,n.replace.start,n.replace.end):ks(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
28
28
  `).reverse().forEach((l,u)=>{u>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(l))}):i.insertNode(document.createTextNode(t))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let l=n.selectionAfter?ao(e,n.selectionAfter.start,n.selectionAfter.end):(i.collapse(!1),i),u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(l)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}function g_(e){let t=document.createElement("template");return t.innerHTML=e.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),t.content}function h_(e){let t=document.createDocumentFragment();return e.split(`
29
29
  `).forEach((n,r)=>{r>0&&t.appendChild(document.createElement("br"));let o={index:0},i=0;for(;o=n.slice(i).match(/(\[([^\]]+)])\(([^)]+)\)/);){let s=document.createElement("a");s.href=o[3],s.setAttribute("target","_blank"),s.setAttribute("rel","noopener noreferrer"),s.appendChild(document.createTextNode(o[2])),t.appendChild(document.createTextNode(n.slice(i,i+o.index))),t.appendChild(s),i=i+o.index+o[0].length}t.appendChild(document.createTextNode(n.slice(i)))}),t}function Uk(e,t){let n=e.parentElement;if(!n){console.warn("No insert point found");return}let{display:r}=window.getComputedStyle(n);r.includes("block")||r==="table-cell"?n==null||n.insertBefore(t,e.nextSibling):Uk(n,t)}function zk(o,i){return P(this,arguments,function*(e,t,{isBlock:n,isHTML:r}={}){let s;e.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0}));let a=()=>{var d;let l=(d=e.ownerDocument.defaultView)!=null?d:window,u=l.getSelection();if((!u||u.rangeCount===0)&&(e.focus(),u=l.getSelection()),!u||u.rangeCount===0)return;let c=u.getRangeAt(0);if(!c)return;s=document.createElement("span"),c.insertNode(s);let f=r?g_(t):h_(t);n?Uk(c.startContainer,f):(c.insertNode(f),c.collapse(!1))};return Promise.resolve(a()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}return tP(y_);})();
30
30
  /*! Bundled license information: