@deepdesk/deepdesk-sdk 11.6.0 → 11.6.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +3 -3
- package/dist/index.esm.js +3 -3
- package/dist/index.iife.js +3 -3
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -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<"u"&&global.INTERWEAVE_SSR_POLYFILL||rO)();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(eO)||(s.innerHTML=this.convertLineBreaks(this.props.escapeHtml?(0,EE.default)(t):t)),s}extractAttributes(t){let{allowAttributes:n}=this.props,r={},o=0;return t.nodeType!==wE||!t.attributes||([...t.attributes].forEach(i=>{let{name:s,value:a}=i,l=s.toLowerCase(),u=kd[l]||kd[s];if(!this.isSafe(t)||!l.match(tO)&&(!n&&(!u||u===hh)||l.startsWith("on")||a.replace(/(\s|\0|�([9AD]);)/,"").match(/(javascript|vbscript|livescript|xss):/i)))return;let c=l==="style"?this.extractStyleAttribute(t):a;u===Gr?c=!0:u===Mo?c=Number.parseFloat(String(c)):u!==Td&&(c=String(c)),r[yh[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 qa[t]?{...n,...qa[t],tagName:t}:n}isSafe(t){if(typeof HTMLAnchorElement<"u"&&t instanceof HTMLAnchorElement){let n=t.getAttribute("href");if(n!=null&&n.startsWith("#"))return!0;let r=t.protocol.toLowerCase();return r===":"||r==="http:"||r==="https:"||r==="mailto:"||r==="tel:"}return!0}isTagAllowed(t){return this.banned.has(t)||this.blocked.has(t)?!1:this.props.allowElements||this.allowed.has(t)}parse(){return this.container?this.parseNode(this.container,this.getTagConfig(this.container.nodeName.toLowerCase())):[]}parseNode(t,n){let{noHtml:r,noHtmlExceptMatchers:o,allowElements:i,transform:s,transformOnlyAllowList:a}=this.props,l=[],u="";return[...t.childNodes].forEach(c=>{if(c.nodeType===wE){let d=c.nodeName.toLowerCase(),m=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 g=this.keyIndex;y=this.parseNode(v,m);let f=s(v,y,m);if(f===null)return;if(typeof f<"u"){l.push(_o.default.cloneElement(f,{key:g}));return}this.keyIndex=g-1}if(this.banned.has(d))return;if(!(r||o&&d!=="br")&&this.isTagAllowed(d)&&(i||this.canRenderChild(n,m))){var p;this.keyIndex+=1;let g=this.extractAttributes(v),f={tagName:d};g&&(f.attributes=g),m.void&&(f.selfClose=m.void),l.push(_o.default.createElement(Pd,{...f,key:this.keyIndex},(p=y)!==null&&p!==void 0?p:this.parseNode(v,m)))}else l=[...l,...this.parseNode(v,m.tagName?m:n)]}else if(c.nodeType===JI){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(nO);){let[s,a]=i,l=i.index,u=s.includes("/");l>0&&(r.push(o.slice(0,l)),o=o.slice(l));let{children:c,matcher:p,props:d}=n[a],m;if(u)m=s.length,r.push(p.createElement(c,d));else{let v=o.match(new RegExp(`{{{/${a}}}}`));m=v.index+v[0].length,r.push(p.createElement(this.replaceTokens(o.slice(s.length,v.index),n),d))}o=o.slice(m)}return o.length>0&&r.push(o),r.length===0?"":r.length===1&&typeof r[0]=="string"?r[0]:r}};function oO(e){var t;let{attributes:n,className:r,containerTagName:o,content:i,emptyContent:s,parsedContent:a,tagName:l,noWrap:u}=e,c=(t=o??l)!==null&&t!==void 0?t:"span",p=c==="fragment"?!0:u,d;if(a)d=a;else{let m=new Rd(i??"",e).parse();m.length>0&&(d=m)}return d||(d=s),p?_o.default.createElement(_o.default.Fragment,null,d):_o.default.createElement(Pd,{attributes:n,className:r,tagName:c},d)}function Qi(e){let{attributes:t,className:n,content:r="",disableFilters:o=!1,disableMatchers:i=!1,emptyContent:s=null,filters:a=[],matchers:l=[],onAfterParse:u=null,onBeforeParse:c=null,tagName:p="span",noWrap:d=!1,...m}=e,v=i?[]:l,y=o?[]:a,g=c?[c]:[],f=u?[u]:[];v.forEach(T=>{T.onBeforeParse&&g.push(T.onBeforeParse.bind(T)),T.onAfterParse&&f.push(T.onAfterParse.bind(T))});let h=g.reduce((T,b)=>b(T,e),r??""),S=new Rd(h,m,v,y),w=f.reduce((T,b)=>b(T,e),S.parse());return _o.default.createElement(oO,{attributes:t,className:n,containerTagName:e.containerTagName,emptyContent:s,noWrap:d,parsedContent:w.length===0?void 0:w,tagName:p})}var AE=x(_());var iO=/[.*+?^${}()|[\]\\]/g,sO=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function aO(e){return e.replace(iO,"\\$&")}function lO(e,t){let n=e.split("").findIndex((r,o)=>r!==t[o]);return n>-1?n:Math.min(e.length,t.length)}function uO(e){return e.search(sO)}function CE(e,t=[]){let n=e;return t.forEach(r=>{if(!r)return;let o=new RegExp(`\\b(${aO(r)})\\b`,"gi");n=n.replace(o,"<strong>$1</strong>")}),n}function bE(e){return e.replace(Xl,'<mark data-type="placeholder">$1</mark>')}function Zi(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function cO(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 Sh(e,t,n={}){if(t){let r=lO(t.toLowerCase(),e.toLowerCase()),o=Zi(e.substring(r,e.length));if(n.stripAgentPart){let l=e.substring(0,r),u=uO(l);return`<span style="opacity: 0.5">${l.substring(u+1)}</span>${o}`}let s=t.split(Hv).length>3||t.length>30?cO(t.trim(),r):0;return`${`${s>0?"\u2026":""}${Zi(e.substring(s,r))}`}<strong>${o}</strong>`}return e}var dO=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function Ad(e){return dO.test(e)}function TE(e){let t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}var Ld=x(_()),RE=x(C()),kE=Ld.default.createContext(void 0);function Xr(){let e=Ld.default.useContext(kE);if(e===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return e}var PE=({children:e,page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i})=>{let s=Ld.default.useMemo(()=>({page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i}),[n,t,o]);return(0,RE.jsx)(kE.Provider,{value:s,children:e})};var jt=x(C()),fO=3,LE=({children:e})=>{let t=P("CommandPalette",Et);return(0,jt.jsx)("div",{className:t.listItemActions,children:e})};function xh({closeOnSelect:e=!0,lineClamp:t,children:n,onClick:r,extra:o,onSourceClick:i,description:s,sources:a,id:l,styles:u,defaultSourcesAmount:c=fO,...p}){let d=K(qn),[m,v]=(0,AE.useState)(!1),{selected:y,onChangeOpen:g}=Xr(),f=P("CommandPalette",Et);function h(S){r(S),e&&g(!1)}return(0,jt.jsxs)("div",{className:(0,Ji.default)(f.listItem,l===y&&f.listItemSelected),children:[(0,jt.jsx)("button",{type:"button",className:(0,Ji.default)(f.listItemAction,f.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:h,"data-command-palette-item":!0,"data-item-id":l,...p,children:(0,jt.jsxs)("div",{className:f.listItemContent,children:[typeof n=="string"?(0,jt.jsx)("p",{className:(0,Ji.default)(f.listItemText,f.truncate,u==null?void 0:u.title),children:n}):n,s&&(0,jt.jsx)(Qi,{tagName:"p",allowList:[],content:Ad(s)?TE(s):s,className:(0,Ji.default)(f.listItemDescription,u==null?void 0:u.description,t?f.lineClamp:f.truncate)})]})}),o,a&&a.length>0&&(0,jt.jsxs)("div",{className:f.sources,children:[(0,jt.jsx)("span",{className:f.sourcesTitle,children:d("sources")}),a.slice(0,m?a.length:c).map(S=>(0,jt.jsx)("a",{className:f.source,href:S.url,target:"_blank",title:S.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i&&i(S),children:S.name},S.url)),!m&&a.length>c&&(0,jt.jsx)("button",{className:(0,Ji.default)(f.source,f.sourceShowMore),type:"button",onClick:()=>v(!0),children:d("showMore",{amount:a.length-c})})]})]})}var Ga=x(C()),IE=()=>(0,Ga.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Ga.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Ga.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 Do=x(C());function wh({children:e,title:t,id:n,onDismiss:r}){let o=K(qn),i=P("CommandPalette",Et),{page:s}=Xr();return s!==n?null:(0,Do.jsxs)("div",{className:i.page,id:`page_${n}`,tabIndex:-1,children:[r&&(0,Do.jsxs)("div",{className:i.pageNav,children:[(0,Do.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:r,children:[(0,Do.jsx)(IE,{}),o("back")]}),t&&(0,Do.jsx)("h3",{className:i.pageTitle,children:t})]}),e]})}var OE=x(_());var Xa=x(C()),es=()=>(0,Xa.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Xa.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Xa.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});var rn=x(C());function pO({onChange:e,onChangeType:t,placeholder:n,typePlaceholder:r,types:o,value:i,selectedType:s},a){let l=P("CommandPalette",Et);return(0,rn.jsxs)("div",{className:l.search,children:[(0,rn.jsx)("div",{className:l.searchIcon,children:(0,rn.jsx)(es,{})}),(0,rn.jsxs)("div",{className:l.searchInputWrapper,children:[(0,rn.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,rn.jsx)("div",{className:l.selectWrapper,children:(0,rn.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,rn.jsx)("option",{children:r}),o.map(u=>(0,rn.jsx)("option",{value:u.value,children:u.label},u.value))]})})]})]})}var ME=(0,OE.forwardRef)(pO);var Eh=x(te());var Id=x(C()),mO=({onClick:e,shortKeys:t,children:n,...r})=>{let o=P("CommandPalette",Et);return(0,Id.jsxs)("button",{type:"button",...r,onClick:e,className:(0,Eh.default)(o.actionButton,r.className,{[o.hasShortKeys]:t&&t.length>0}),children:[n,t&&t.map(i=>(0,Id.jsx)("span",{className:(0,Eh.default)(o.actionShortcut,i===8629&&o.actionShortcutFixKerning),children:typeof i=="number"?String.fromCharCode(i):i},i))]})},NE=mO;var Ya=x(C()),gO="[data-command-palette-item]";function Fo({placeholder:e="Start typing to search...",typePlaceholder:t="All types",defaultPage:n="search",page:r,onChangePage:o,onChangeSearch:i,onChangeType:s,onChangeOpen:a,selectedType:l,types:u,children:c,isOpen:p,search:d}){let[m,v]=(0,Yn.useState)(),y=(0,Yn.useRef)(null),g=()=>{o&&o(n),s(void 0),i(""),a(!1)},f=()=>{var M;if(r!==n&&o){o(n);return}if(l&&s){s(void 0),(M=y.current)==null||M.focus();return}if(d.length>0){i("");return}a(!1)},h=()=>{let M=S();M.length!==0&&v(M[0].dataset.itemId)},S=()=>Array.from(document.querySelectorAll(gO)||[]),w=M=>document.querySelector(`[data-item-id=${M}]`),T=M=>{let W=w(M);W&&v(W.dataset.itemId)},b=M=>{let W=w(M);W&&W.scrollIntoView({behavior:"smooth"})},k=()=>{if(!m)return;let M=S(),W=w(m);if(!W)return;let X=M.indexOf(W),ne=M[X+1];ne&&ne.dataset.itemId?T(ne.dataset.itemId):h()},I=()=>{if(!m)return;let M=S(),W=w(m);if(!W)return;let X=M.indexOf(W),ne=M[X-1];ne&&ne.dataset.itemId?T(ne.dataset.itemId):T(M[M.length-1].dataset.itemId)},O=(0,Yn.useCallback)(M=>{switch(M.key){case"ArrowDown":{M.preventDefault(),k();break}case"ArrowUp":{M.preventDefault(),I();break}case"Enter":{if(m){let W=w(m);W==null||W.click()}break}}},[m]);return(0,Yn.useEffect)(()=>{h()},[d,r,l,p]),(0,Yn.useEffect)(()=>{m&&b(m)},[m]),(0,Ya.jsx)(Sd,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:f,onClose:g,onKeyDown:O,children:(0,Ya.jsxs)(PE,{selected:m,setSelected:v,isOpen:p,onChangeOpen:a,page:r,children:[r===n&&(0,Ya.jsx)(ME,{ref:y,onChange:i,onChangeType:s,placeholder:e,value:d,selectedType:l,types:u,typePlaceholder:t}),c]})})}Fo.Page=wh;Fo.List=ch;Fo.Image=gE;Fo.ListItem=xh;Fo.ListItemActions=LE;Fo.Button=NE;var fe=Fo;var _E=x(_());function DE(e,t){(0,_E.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 Qa=x(_());var FE={data:null,fetchState:"idle"},Od=e=>{var i;let t=[],{visitorName:n}=e.info.visitorInfo??{},{agentName:r,agentNickname:o}=e.info.agentInfo??{};return r&&r!==n&&t.push(r),o&&o!==n&&t.push(o),((i=e.entities.data)==null?void 0:i.filter(s=>!t.includes(s.text)))??null},on=B("entities/getEntities",async(e,t)=>{let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra;if(!r.conversationQuery)return Promise.resolve([]);let o=r.conversationQuery,i=await o();return i.length===0?Promise.resolve([]):n.getEntities(i)}),hO=e=>e.filter((t,n)=>n===e.findIndex(r=>r.text===t.text)),yO=G({name:"entities",initialState:FE,reducers:{},extraReducers:e=>{e.addCase(on.pending,t=>{t.fetchState="loading"}).addCase(on.rejected,t=>{t.fetchState="error"}).addCase(on.fulfilled,(t,n)=>{t.fetchState="done",t.data=hO(t.data?[...t.data,...n.payload]:n.payload)}).addCase(le,()=>FE)}}),HE=yO.reducer;var Ch={};je(Ch,{enUS:()=>vO,nlNL:()=>SO});var vO={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},SO={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var UE={root:"dd-TYTKs",empty:"dd-AU7uT"};var ts=x(C()),xO=({onCopy:e})=>{let t=(0,Qa.useRef)(null),n=P("EntitiesList",UE),r=L(Od),{setSelected:o}=Xr(),i=K(Ch),s=$();return(0,Qa.useEffect)(()=>{s(on())},[]),(0,Qa.useEffect)(()=>{t.current&&(t.current.focus(),o("entity-0"))},[t]),(0,ts.jsxs)("div",{className:n.root,ref:t,tabIndex:-1,children:[r&&r.length>0&&(0,ts.jsx)(fe.List,{children:r.map((a,l)=>(0,ts.jsx)(fe.ListItem,{id:`entity-${l}`,closeOnSelect:!0,onClick:()=>e(a),children:a.text},a.text))},"entities"),r&&r.length===0&&(0,ts.jsx)("p",{className:n.empty,children:i("noResults")})]})},zE=xO;var sn=x(_());var BE={data:null,fetchState:"idle"},jE=e=>e.summary.data,VE=e=>e.summary.fetchState==="error",KE=e=>e.summary.model,Qn=B("summary/getSummary",async(e,t)=>{var c,p,d;let n=t.getState().profile.data,r=(c=t.getState().conversation.current)==null?void 0:c.sessionId,o=(d=(p=t.getState().info)==null?void 0:p.agentInfo)==null?void 0:d.agentId;if(!n)throw new Error("Profile is not defined");let{deepdeskAPI:i,dynamicThunkObject:s}=t.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let a=s.conversationQuery,l=await a();if(l.length===0)return Promise.reject(new Error("No messages are included"));let u=await i.getSummary(l,{externalConversationId:r,agentId:o,promptInstruction:n.summarizerPromptInstruction,model:n.summarizerModel});return u.summary?u:Promise.reject(new Error("Summary is not provided"))}),wO=G({name:"summary",initialState:BE,reducers:{},extraReducers:e=>{e.addCase(Qn.pending,t=>{t.data=null,t.fetchState="loading"}).addCase(Qn.rejected,t=>{t.data=null,t.fetchState="error"}).addCase(Qn.fulfilled,(t,n)=>{t.fetchState="done",n.payload&&(t.data=n.payload.summary,t.model=n.payload.model)}).addCase(le,()=>BE)}}),WE=wO.reducer;var bh={};je(bh,{enUS:()=>EO,nlNL:()=>CO});var EO={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."}]},CO={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 $E={root:"dd-60NZr",actions:"dd-No1g3",main:"dd-l-xEF",textInput:"dd-nAaiV",loading:"dd-ciFNi",error:"dd-yNp2D"};var Md=x(te()),YE=x(_());var Th=x(C()),kh=e=>(0,Th.jsx)("svg",{width:"16",height:"16",fill:"#000000",...e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Th.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 Ph=x(C()),qE=e=>(0,Ph.jsx)("svg",{width:"16",height:"16",fill:"#000000",...e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Ph.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 ns(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 Rh={};je(Rh,{enUS:()=>bO,nlNL:()=>TO});var bO={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},TO={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};function GE(e){return B("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,{conversationId:r,...o,data:t.data})})(e)}function rs(){let e=$();return async(t,n)=>{await e(GE({name:t,data:n}))}}var XE={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};var os=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=${e}`:null:`${o}${e}`:null};var Zn=x(C()),kO=({eventName:e,eventData:t,feedbackType:n,feedbackText:r})=>{let o=P("FeedbackThumbs",XE),i=z("enableFeedbackForm"),s=L(Vr),a=L(os(`/admin/feedback?conversationId=${s}&type=${n}&text=${r}&data=${JSON.stringify(t)}`)),l=K(Rh),u=rs(),[c,p]=(0,YE.useState)(null),d=v=>{v.stopPropagation(),ns(v.target,o.fadeup),p("up"),u(e,{...t,rating:"up"})},m=v=>{v.stopPropagation(),ns(v.target,o.fadedown),p("down"),u(e,{...t,rating:"down"})};return(0,Zn.jsxs)("div",{className:o.thumbs,children:[(0,Zn.jsx)(ee.IconButton,{title:l("thumbsUp"),onClick:d,icon:(0,Zn.jsx)(qE,{}),className:(0,Md.default)(o.thumbsUp,c==="up"&&o.selected),disabled:!!c}),i&&a?(0,Zn.jsx)(ee.IconButton,{as:"a",title:l("thumbsDown"),href:a,target:"_blank",rel:"noreferrer",onClick:m,icon:(0,Zn.jsx)(kh,{}),className:(0,Md.default)(o.thumbsDown,c==="down"&&o.selected),disabled:!!c}):(0,Zn.jsx)(ee.IconButton,{title:l("thumbsDown"),onClick:m,icon:(0,Zn.jsx)(kh,{}),className:(0,Md.default)(o.thumbsDown,c==="down"&&o.selected),disabled:!!c})]})},is=kO;var bn=x(C()),PO=({onCopy:e})=>{let t=(0,sn.useRef)(null),n=P("SummaryForm",$E),[r,o]=(0,sn.useState)(""),i=K(bh),s=L(KE),a=L(jE),l=L(VE),u=$(),c=()=>{u(et({name:"summary copied to clipboard",data:{originalText:a,finalText:r,model:s},options:{includeConversationData:!0}})),e(r)},p=()=>{let d=document.getSelection();d&&u(et({name:"summary copied to clipboard",data:{originalText:a,finalText:d==null?void 0:d.toString(),model:s},options:{includeConversationData:!0}}))};return(0,sn.useEffect)(()=>{u(Qn())},[]),(0,sn.useEffect)(()=>{o(a||"")},[a]),(0,sn.useEffect)(()=>{t.current&&a&&t.current.focus()},[t,a]),(0,sn.useEffect)(()=>{let d=m=>{m.key==="Enter"&&m.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r]),(0,bn.jsx)("div",{className:n.root,tabIndex:-1,children:l?(0,bn.jsx)("p",{className:n.error,children:i("error")}):(0,bn.jsxs)(sn.Fragment,{children:[(0,bn.jsx)("div",{className:n.main,children:(0,bn.jsx)("textarea",{placeholder:a?void 0:i("loading"),disabled:!a,className:n.textInput,ref:t,value:r,onCopy:p,onChange:d=>o(d.target.value)})}),(0,bn.jsxs)("div",{className:n.actions,children:[(0,bn.jsx)(is,{feedbackText:a||"",feedbackType:"summary",eventName:"summary feedback",eventData:{summary:a}}),(0,bn.jsx)(fe.Button,{shortKeys:[8679,8629],onClick:c,children:i("copy")})]})]})})},QE=PO;var Za={};je(Za,{enUS:()=>RO,nlNL:()=>AO});var RO={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?"}]},AO={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 Jn=x(_());var Ah={};je(Ah,{enUS:()=>LO,nlNL:()=>IO});var LO={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"}]},IO={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 ZE={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 OO={data:null,fetchState:"idle"},JE=e=>{var t;return(t=e.knowledgeAssistant)==null?void 0:t.data},Ja=B("knowledgeAssistant/getKnowledgeAssistant",async(e,t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");let i=(s=r.profile.data)==null?void 0:s.knowledgeAssistant;return i?n.getKnowledgeAssistant(i):null}),MO=G({name:"knowledgeAssistant",initialState:OO,reducers:{},extraReducers:e=>{e.addCase(Ja.pending,t=>{t.fetchState="loading"}).addCase(Ja.rejected,t=>{t.fetchState="error"}).addCase(Ja.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),eC=MO.reducer;var Lh={data:[],fetchState:"idle"},tC=e=>{var t;return(t=e.answer)==null?void 0:t.data},nC=e=>e.answer.fetchState,ss=xe("answer/resetKnowledgeSearch"),el=B("answer/getAnswer",async(e,t)=>{var l,u,c;let{deepdeskAPI:n}=t.extra,r=t.getState().answer.data,o=JE(t.getState()),i=(l=t.getState().conversation.current)==null?void 0:l.sessionId,s=(c=(u=t.getState().info)==null?void 0:u.agentInfo)==null?void 0:c.agentId;if(!o)throw new Error("KnowledgeAssistant is not defined");let a=await n.knowledgeAssist({customerInstruction:o.customerInstruction,doNotKnowAnswer:o.doNotKnowAnswer,question:e},r,o.code,{agentId:s,conversationId:i});return{question:e,answer:a}}),NO=G({name:"answer",initialState:Lh,reducers:{},extraReducers:e=>{e.addCase(el.pending,t=>{t.fetchState="loading"}).addCase(el.rejected,t=>{t.fetchState="error"}).addCase(el.fulfilled,(t,n)=>{t.fetchState="done",t.data=[...t.data,n.payload]}).addCase(le,()=>Lh).addCase(ss,()=>Lh)}}),rC=NO.reducer;var tl=x(C()),oC=()=>(0,tl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,tl.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,tl.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 tt=x(C()),_O=({onUse:e,onResetQuestion:t,question:n})=>{let[r,o]=Jn.default.useState(""),[i,s]=Jn.default.useState(!1),{setSelected:a}=Xr(),l=(0,Jn.useRef)(null),u=P("KnowledgeSearchStyles",ZE),c=K(Ah),p=$(),d=L(tC),m=L(nC),v=async f=>{s(!0),await p(el(f)),l.current&&s(!1)},y=async f=>{f.preventDefault(),f.stopPropagation(),r!==""&&v(r)},g=(f,h)=>{p(et({name:"knowledge assist source viewed",data:{question:h,sourceViewed:f.url||f.name},options:{includeConversationData:!0}}))};return(0,Jn.useEffect)(()=>{var f;n&&m==="idle"?v(n):(f=l.current)==null||f.focus()},[l,m]),(0,Jn.useEffect)(()=>{m==="done"&&(p(et({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(""))},[m,d]),(0,Jn.useEffect)(()=>{l.current&&l.current.scrollIntoView({behavior:"smooth"})},[l,d]),(0,tt.jsxs)("div",{className:u.root,children:[d.length>0&&(0,tt.jsx)("div",{className:u.alignRight,children:(0,tt.jsx)(fe.Button,{onClick:t,children:c("reset")})}),d.map(({question:f,answer:h},S)=>(0,tt.jsx)(fe.List,{children:(0,tt.jsx)(fe.ListItem,{id:`knowledge-assist-${S}`,"data-testid":"knowledge-search-answer",description:h.answer,closeOnSelect:!0,onClick:()=>e(h.answer),onSourceClick:w=>g(w,f),sources:h.sources,styles:{title:u.question,description:u.answer},extra:(0,tt.jsx)("div",{className:u.listItemFeedback,children:(0,tt.jsx)(is,{feedbackText:h.answer,feedbackType:"knowledge-assist-answer",eventName:"knowledge assist feedback",eventData:{question:f,isAgent:n!==f,isFollowUpQuestion:d.length>1,...h}})}),children:f})},`${h.answer}_${S}`)),m==="loading"&&(0,tt.jsx)("p",{className:u.status,children:c("loading")}),m==="error"&&(0,tt.jsx)("p",{className:u.status,children:c("error")}),(0,tt.jsxs)("form",{className:u.form,onSubmit:y,children:[(0,tt.jsx)("input",{ref:l,placeholder:c("anotherQuestion"),className:u.input,type:"text",value:r,onFocus:()=>{a(void 0)},onChange:f=>{a(void 0),o(f.target.value)}}),(0,tt.jsx)("button",{type:"submit",className:u.submit,disabled:i,children:(0,tt.jsx)(oC,{})})]})]})},iC=_O;var DO={data:null,fetchState:"idle"},er=e=>e.profile.data,Nd=e=>e.profile.data?e.profile.data.uiConfig.widget.types.filter(t=>t.isActive):[],sC=e=>e.profile.data?!!e.profile.data.uiConfig.widget.types.find(t=>t.type==="custom-data"):!1,nl=B("profile/getProfile",async(e,t)=>{var i;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");return((i=r.profile.data)==null?void 0:i.code)===o.profileCode?r.profile.data:n.getProfile(o.profileCode)}),FO=G({name:"profile",initialState:DO,reducers:{},extraReducers:e=>{e.addCase(nl.pending,t=>{t.fetchState="loading"}).addCase(nl.rejected,t=>{t.fetchState="error"}).addCase(nl.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),aC=FO.reducer;var hC=x(_());var HO=["{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}"],UO=new RegExp(HO.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function lC(e,t){let n=e.split(UO),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],l=i===n.length-2;r+=s.length;let u=r;if(l){let p=a.charAt(0),d=0;do u=p?t.indexOf(p,u+1):-1,d+=1;while(u!==-1&&a.indexOf(t.slice(u))!==0);if(u===-1&&d>2)return e}else u=a&&a!==""?t.indexOf(a,r):-1;let c=u===-1?t.slice(r):t.slice(r,u);o.push(c),r=u}return o.join("")}function uC(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var dC={suggestions:[],fetchState:"idle"},cC={default:dC},fC=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)??[]},_d=e=>e.textSuggestions,pC=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},Dd=xe("textSuggestions/refresh"),an=B("textSuggestions/recommendations",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,inlineSuggestions:s}=r.settings,a=Xi(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getTextSuggestions(o,_a(r),e);if(e==="default"){let c=s?l.filter(pC(a)):l;t.dispatch(En(c.slice(0,i)))}return l}),rl=B("textSuggestions/autocompletions",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,deanonymize:s,inlineSuggestions:a}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getAutocompleteSuggestions(o,{..._a(r),input:e});if(!t.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(pC(e))),s&&(l=l.map(c=>({...c,text:c.source!=="trie-with-typos"?lC(c.text,e):c.text}))),l=uC(l,i),t.dispatch(En(l)),l}),mC=G({name:"textSuggestions",initialState:cC,reducers:{setTextSuggestions:{reducer(e,t){let{contentType:n}=t.payload;e[n].fetchState="done",e[n].suggestions=t.payload.suggestions},prepare(e,t){return{payload:{contentType:e,suggestions:t}}}},setSuggestionState(e,t){return t.payload}},extraReducers:e=>{e.addCase(an.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||dC;return{...t,[r]:{...o,fetchState:"loading"}}}).addCase(an.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(an.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(rl.pending,t=>{t.default.fetchState="loading"}).addCase(rl.rejected,t=>{t.default.fetchState="error"}).addCase(rl.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(le,()=>cC)}}),{setTextSuggestions:x8,setSuggestionState:w8}=mC.actions,gC=mC.reducer;var Ho=x(C()),zO=({commands:e,onClick:t})=>{var a,l,u;let n=$(),r=K(Za),o=L(er),i=L(_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,hC.useEffect)(()=>{s.forEach(({type:c})=>{(!i[c]||i[c].suggestions.length===0)&&n(an(c))})},[]),(0,Ho.jsxs)("div",{children:[e.length>0&&(0,Ho.jsx)(fe.List,{heading:r("commands"),children:e.map((c,p)=>(0,Ho.jsx)(fe.ListItem,{id:`command-${p}`,closeOnSelect:!1,onClick:c.onClick,children:c.label},c.label))}),s.map(({type:c,title:p})=>{var d;return(0,Ho.jsx)(fe.List,{heading:p,orientation:"vertical",children:(d=i[c])==null?void 0:d.suggestions.map((m,v)=>(0,Ho.jsx)(fe.ListItem,{id:`${c}-${v}`,closeOnSelect:!1,description:m.text,onClick:()=>t(m.text,m),"data-testid":"search-overlay-suggestion",children:m.title},`${m.id}-${m.text}`))},c)})]})},yC=zO;var Ue=x(_()),vC=x(te());var Ih={root:"dd-uVyL0",trigger:"dd-KIzQa",content:"dd-Ly3zO",contentOpen:"dd-O-8fR",contentTop:"dd-q3fGa",contentBottom:"dd-SFrvc",item:"dd-HZNy-"};var Uo=x(C()),BO=0,SC=Ue.default.createContext(null),jO=()=>{let e=(0,Ue.useContext)(SC);if(!e)throw new Error("Invalid DropdownContext");return e},xC=({trigger:e,children:t,position:n="bottom"})=>{let r=(0,Ue.useMemo)(()=>++BO,[]),o=(0,Ue.useRef)(null),i=(0,Ue.useRef)(null),s=P("Dropdown",Ih),[a,l]=(0,Ue.useState)(!1),[u,c]=(0,Ue.useState)(n),p=m=>{m.preventDefault(),m.stopPropagation(),l(!a)},d=(0,Ue.useCallback)(([m])=>{!m.isIntersecting&&a&&c(u==="top"?"bottom":"top")},[a]);return(0,Ue.useEffect)(()=>{let m=v=>{o.current&&!o.current.contains(v.target)&&l(!1)};return document.addEventListener("click",m),()=>{document.removeEventListener("click",m)}},[]),(0,Ue.useEffect)(()=>{if(!i.current&&!a)return()=>{};let m=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return i.current&&m.observe(i.current),()=>{i.current&&m.unobserve(i.current)}},[i,a]),(0,Uo.jsx)(SC.Provider,{value:{setIsOpen:l},children:(0,Uo.jsxs)("div",{ref:o,className:s.root,children:[(0,Uo.jsx)("button",{id:`dropdown-${r}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:s.trigger,onClick:p,children:e}),(0,Uo.jsx)("div",{"data-testid":"dropdown-content",ref:i,"aria-hidden":!a,"aria-labelledby":`dropdown-${r}`,className:(0,vC.default)(s.content,{[s.contentOpen]:a,[s.contentTop]:u==="top",[s.contentBottom]:u==="bottom"}),children:t})]})})};function VO({as:e,children:t,onClick:n,...r}){let o=e||"button",i=P("Dropdown",Ih),{setIsOpen:s}=jO(),a=l=>{s(!1),n(l),l.stopPropagation()};return(0,Uo.jsx)(o,{type:"button",className:i.item,onClick:a,...r,children:t})}xC.Item=VO;var Oh=xC;var Mh=x(C()),wC=e=>(0,Mh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...e,children:(0,Mh.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 zo={};je(zo,{enUS:()=>KO,nlNL:()=>WO});var KO={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"}]},WO={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 Fd=x(C()),$O=({suggestion:e,source:t,context:n})=>{let r=K(zo),o=L(Vr),i=$(),s=z("enableSuggestionFeedback"),a=`${e.text}`,l=L(os(`/admin/feedback?conversationId=${o}&type=${t}&text=${a}&data=${JSON.stringify({context:n})}`)),u=()=>{i(et({name:"suggestion feedback",data:{text:e.text,source:t,context:n},options:{includeConversationData:!0}}))};return!s||!l?null:(0,Fd.jsx)(Oh,{trigger:(0,Fd.jsx)(wC,{"data-testid":"feedback-dropdown-trigger"}),children:(0,Fd.jsx)(Oh.Item,{as:"a",onClick:u,target:"_blank",href:l,children:r("giveFeedback")})})},Hd=$O;var Le=x(C()),GO=200,XO=5,YO=4,EC=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),QO=()=>{let e=$(),t=Bt(),n=K(Za),[r,o]=(0,Ct.useState)(!1),[i,s]=(0,Ct.useState)(""),a=L(F1),l=L(er),[u,c]=(0,Ct.useState)(),p=L(Je),d=z("showSearch"),m=z("enableSuggestionFeedback"),v=z("showEntitiesCommand"),y=z("showSummaryCommand"),g=z("showKnowledgeSearch"),f=z("showImageSearch"),h=z("searchTriggerKey"),S=L(fE),w=L(H1),T=L(U1),b=L(D1),k=H=>dr(w.filter(Y=>Y.type===H.toUpperCase()),H),I=[{value:"PERSONAL",label:n("personalSuggestions"),list:k("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:n("urlSuggestions"),list:k("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:k("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:k("IMAGE"),listOrientation:"horizontal",shouldShow:f}].filter(H=>H.shouldShow),O=[{label:n("entitiesClipboard"),onClick:()=>e(Jt("entities")),shouldShow:v&&EC(n("entitiesClipboard"),i)},{label:n("summaryClipboard"),onClick:()=>e(Jt("summary")),shouldShow:y&&EC(n("summaryClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(Jt("knowledgeAssist")),shouldShow:g}].filter(H=>H.shouldShow),M=(S==null?void 0:S.map(H=>({value:H.code.toUpperCase(),label:`${H.name}s`,list:k(H.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],W=(0,Ct.useCallback)((0,CC.default)((H,Y)=>{e(Ao({query:H,type:Y,tags:["search-overlay"],size:u?50:20}))},GO),[u]),X=(0,Ct.useCallback)((H,Y)=>{switch(Y.type){case"IMAGE":t.send(Yg,{suggestion:Y});break;default:t.send($r,{text:H,suggestion:Y})}e(xt(!1))},[e]),ne=H=>{$n(H.text),e(et({name:"entity copied",data:{entity:H,type:"copy"}})),e(xt(!1))},cr=H=>{t.send($r,{text:H,suggestion:{source:"knowledge-assist",text:H}}),e(et({name:"answer used",data:{originalText:H},options:{includeConversationData:!0}})),s(""),e(Jt("search")),e(ss()),e(xt(!1))},Pt=H=>{$n(H),e(xt(!1))};function dr(H,Y){return H.slice(0,u?10:Y.toLowerCase()==="image"?YO:XO)}function Rt(H){return Y=>{r?window.confirm(n("warning"))&&(H(Y),o(!1)):H(Y)}}return(0,Ct.useEffect)(()=>{i?W(i,u):e(rd())},[i,u]),(0,Ct.useEffect)(()=>{a==="search"&&e(ss())},[a]),(0,Ct.useEffect)(()=>{p&&e(Va())},[p]),DE(h,()=>e(xt(!0))),!d||!l?null:(0,Le.jsxs)(fe,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Rt(H=>e(xt(H))),onChangeType:H=>c(H),onChangePage:Rt(H=>e(Jt(H))),selectedType:u,search:i,page:a,isOpen:b,types:[...M,...I],children:[(0,Le.jsxs)(fe.Page,{id:"search",children:[i.length===0&&(0,Le.jsx)(yC,{commands:O,onClick:X}),i.length>0&&(0,Le.jsxs)(Ct.Fragment,{children:[O.length>0&&(0,Le.jsx)(fe.List,{heading:n("commands"),children:O.map((H,Y)=>(0,Le.jsx)(fe.ListItem,{closeOnSelect:!1,onClick:H.onClick,id:`commands-${Y}`,children:H.label},H.label))}),[...M,...I].map(({value:H,label:Y,list:fr,lineClamp:he,listOrientation:pr})=>(0,Le.jsx)(fe.List,{heading:Y,orientation:pr==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(H),hasMore:!u&&T[H.toLowerCase()]>dr(fr,H).length,children:dr(fr,H).map(q=>(0,Le.jsx)(fe.ListItem,{id:`${H}-${q.id}`,closeOnSelect:!1,lineClamp:he,onClick:()=>X(q.text,q),description:H!=="IMAGE"?q.title&&q.text:void 0,extra:m&&(0,Le.jsx)(fe.ListItemActions,{children:(0,Le.jsx)(Hd,{context:i,source:"search",suggestion:q})}),children:H==="IMAGE"?(0,Le.jsx)(fe.Image,{title:q.title||q.text,src:q.image}):q.title||q.text},`${q.id}-${q.text}`))},H))]})]}),(0,Le.jsx)(fe.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Rt(()=>{e(Jt("search"))}),children:(0,Le.jsx)(zE,{onCopy:ne})}),(0,Le.jsx)(fe.Page,{id:"summary",title:n("summaryTitle"),onDismiss:Rt(()=>{e(Jt("search"))}),children:(0,Le.jsx)(QE,{onCopy:Pt})}),(0,Le.jsx)(fe.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Rt(()=>{e(ss()),e(Jt("search"))}),children:(0,Le.jsx)(iC,{question:i,onUse:cr,onResetQuestion:()=>{e(ss()),s("")}})})]})},bC=QO;var ol=x(C()),ZO=()=>{let e=z("showSearch"),t=z("isEmbedded");return(0,ol.jsxs)(TC.Fragment,{children:[e&&(0,ol.jsx)(bC,{}),t&&(0,ol.jsx)(aE,{})]})},kC=ZO;var LC=x(te());var Ud=x(C()),PC=({className:e})=>(0,Ud.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,Ud.jsx)("g",{children:(0,Ud.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<"u"&&global.INTERWEAVE_SSR_POLYFILL||rO)();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(eO)||(s.innerHTML=this.convertLineBreaks(this.props.escapeHtml?(0,EE.default)(t):t)),s}extractAttributes(t){let{allowAttributes:n}=this.props,r={},o=0;return t.nodeType!==wE||!t.attributes||([...t.attributes].forEach(i=>{let{name:s,value:a}=i,l=s.toLowerCase(),u=kd[l]||kd[s];if(!this.isSafe(t)||!l.match(tO)&&(!n&&(!u||u===hh)||l.startsWith("on")||a.replace(/(\s|\0|�([9AD]);)/,"").match(/(javascript|vbscript|livescript|xss):/i)))return;let c=l==="style"?this.extractStyleAttribute(t):a;u===Gr?c=!0:u===Mo?c=Number.parseFloat(String(c)):u!==Td&&(c=String(c)),r[yh[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 qa[t]?{...n,...qa[t],tagName:t}:n}isSafe(t){if(typeof HTMLAnchorElement<"u"&&t instanceof HTMLAnchorElement){let n=t.getAttribute("href");if(n!=null&&n.startsWith("#"))return!0;let r=t.protocol.toLowerCase();return r===":"||r==="http:"||r==="https:"||r==="mailto:"||r==="tel:"}return!0}isTagAllowed(t){return this.banned.has(t)||this.blocked.has(t)?!1:this.props.allowElements||this.allowed.has(t)}parse(){return this.container?this.parseNode(this.container,this.getTagConfig(this.container.nodeName.toLowerCase())):[]}parseNode(t,n){let{noHtml:r,noHtmlExceptMatchers:o,allowElements:i,transform:s,transformOnlyAllowList:a}=this.props,l=[],u="";return[...t.childNodes].forEach(c=>{if(c.nodeType===wE){let d=c.nodeName.toLowerCase(),m=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 g=this.keyIndex;y=this.parseNode(v,m);let f=s(v,y,m);if(f===null)return;if(typeof f<"u"){l.push(_o.default.cloneElement(f,{key:g}));return}this.keyIndex=g-1}if(this.banned.has(d))return;if(!(r||o&&d!=="br")&&this.isTagAllowed(d)&&(i||this.canRenderChild(n,m))){var p;this.keyIndex+=1;let g=this.extractAttributes(v),f={tagName:d};g&&(f.attributes=g),m.void&&(f.selfClose=m.void),l.push(_o.default.createElement(Pd,{...f,key:this.keyIndex},(p=y)!==null&&p!==void 0?p:this.parseNode(v,m)))}else l=[...l,...this.parseNode(v,m.tagName?m:n)]}else if(c.nodeType===JI){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(nO);){let[s,a]=i,l=i.index,u=s.includes("/");l>0&&(r.push(o.slice(0,l)),o=o.slice(l));let{children:c,matcher:p,props:d}=n[a],m;if(u)m=s.length,r.push(p.createElement(c,d));else{let v=o.match(new RegExp(`{{{/${a}}}}`));m=v.index+v[0].length,r.push(p.createElement(this.replaceTokens(o.slice(s.length,v.index),n),d))}o=o.slice(m)}return o.length>0&&r.push(o),r.length===0?"":r.length===1&&typeof r[0]=="string"?r[0]:r}};function oO(e){var t;let{attributes:n,className:r,containerTagName:o,content:i,emptyContent:s,parsedContent:a,tagName:l,noWrap:u}=e,c=(t=o??l)!==null&&t!==void 0?t:"span",p=c==="fragment"?!0:u,d;if(a)d=a;else{let m=new Rd(i??"",e).parse();m.length>0&&(d=m)}return d||(d=s),p?_o.default.createElement(_o.default.Fragment,null,d):_o.default.createElement(Pd,{attributes:n,className:r,tagName:c},d)}function Qi(e){let{attributes:t,className:n,content:r="",disableFilters:o=!1,disableMatchers:i=!1,emptyContent:s=null,filters:a=[],matchers:l=[],onAfterParse:u=null,onBeforeParse:c=null,tagName:p="span",noWrap:d=!1,...m}=e,v=i?[]:l,y=o?[]:a,g=c?[c]:[],f=u?[u]:[];v.forEach(T=>{T.onBeforeParse&&g.push(T.onBeforeParse.bind(T)),T.onAfterParse&&f.push(T.onAfterParse.bind(T))});let h=g.reduce((T,b)=>b(T,e),r??""),S=new Rd(h,m,v,y),w=f.reduce((T,b)=>b(T,e),S.parse());return _o.default.createElement(oO,{attributes:t,className:n,containerTagName:e.containerTagName,emptyContent:s,noWrap:d,parsedContent:w.length===0?void 0:w,tagName:p})}var AE=x(_());var iO=/[.*+?^${}()|[\]\\]/g,sO=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function aO(e){return e.replace(iO,"\\$&")}function lO(e,t){let n=e.split("").findIndex((r,o)=>r!==t[o]);return n>-1?n:Math.min(e.length,t.length)}function uO(e){return e.search(sO)}function CE(e,t=[]){let n=e;return t.forEach(r=>{if(!r)return;let o=new RegExp(`\\b(${aO(r)})\\b`,"gi");n=n.replace(o,"<strong>$1</strong>")}),n}function bE(e){return e.replace(Xl,'<mark data-type="placeholder">$1</mark>')}function Zi(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function cO(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 Sh(e,t,n={}){if(t){let r=lO(t.toLowerCase(),e.toLowerCase()),o=Zi(e.substring(r,e.length));if(n.stripAgentPart){let l=e.substring(0,r),u=uO(l);return`<span style="opacity: 0.5">${l.substring(u+1)}</span>${o}`}let s=t.split(Hv).length>3||t.length>30?cO(t.trim(),r):0;return`${`${s>0?"\u2026":""}${Zi(e.substring(s,r))}`}<strong>${o}</strong>`}return e}var dO=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function Ad(e){return dO.test(e)}function TE(e){let t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}var Ld=x(_()),RE=x(C()),kE=Ld.default.createContext(void 0);function Xr(){let e=Ld.default.useContext(kE);if(e===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return e}var PE=({children:e,page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i})=>{let s=Ld.default.useMemo(()=>({page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i}),[n,t,o]);return(0,RE.jsx)(kE.Provider,{value:s,children:e})};var jt=x(C()),fO=3,LE=({children:e})=>{let t=P("CommandPalette",Et);return(0,jt.jsx)("div",{className:t.listItemActions,children:e})};function xh({closeOnSelect:e=!0,lineClamp:t,children:n,onClick:r,extra:o,onSourceClick:i,description:s,sources:a,id:l,styles:u,defaultSourcesAmount:c=fO,...p}){let d=K(qn),[m,v]=(0,AE.useState)(!1),{selected:y,onChangeOpen:g}=Xr(),f=P("CommandPalette",Et);function h(S){r(S),e&&g(!1)}return(0,jt.jsxs)("div",{className:(0,Ji.default)(f.listItem,l===y&&f.listItemSelected),children:[(0,jt.jsx)("button",{type:"button",className:(0,Ji.default)(f.listItemAction,f.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:h,"data-command-palette-item":!0,"data-item-id":l,...p,children:(0,jt.jsxs)("div",{className:f.listItemContent,children:[typeof n=="string"?(0,jt.jsx)("p",{className:(0,Ji.default)(f.listItemText,f.truncate,u==null?void 0:u.title),children:n}):n,s&&(0,jt.jsx)(Qi,{tagName:"p",allowList:[],content:Ad(s)?TE(s):s,className:(0,Ji.default)(f.listItemDescription,u==null?void 0:u.description,t?f.lineClamp:f.truncate)})]})}),o,a&&a.length>0&&(0,jt.jsxs)("div",{className:f.sources,children:[(0,jt.jsx)("span",{className:f.sourcesTitle,children:d("sources")}),a.slice(0,m?a.length:c).map(S=>(0,jt.jsx)("a",{className:f.source,href:S.url,target:"_blank",title:S.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i&&i(S),children:S.name},S.url)),!m&&a.length>c&&(0,jt.jsx)("button",{className:(0,Ji.default)(f.source,f.sourceShowMore),type:"button",onClick:()=>v(!0),children:d("showMore",{amount:a.length-c})})]})]})}var Ga=x(C()),IE=()=>(0,Ga.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Ga.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Ga.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 Do=x(C());function wh({children:e,title:t,id:n,onDismiss:r}){let o=K(qn),i=P("CommandPalette",Et),{page:s}=Xr();return s!==n?null:(0,Do.jsxs)("div",{className:i.page,id:`page_${n}`,tabIndex:-1,children:[r&&(0,Do.jsxs)("div",{className:i.pageNav,children:[(0,Do.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:r,children:[(0,Do.jsx)(IE,{}),o("back")]}),t&&(0,Do.jsx)("h3",{className:i.pageTitle,children:t})]}),e]})}var OE=x(_());var Xa=x(C()),es=()=>(0,Xa.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Xa.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Xa.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});var rn=x(C());function pO({onChange:e,onChangeType:t,placeholder:n,typePlaceholder:r,types:o,value:i,selectedType:s},a){let l=P("CommandPalette",Et);return(0,rn.jsxs)("div",{className:l.search,children:[(0,rn.jsx)("div",{className:l.searchIcon,children:(0,rn.jsx)(es,{})}),(0,rn.jsxs)("div",{className:l.searchInputWrapper,children:[(0,rn.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,rn.jsx)("div",{className:l.selectWrapper,children:(0,rn.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,rn.jsx)("option",{children:r}),o.map(u=>(0,rn.jsx)("option",{value:u.value,children:u.label},u.value))]})})]})]})}var ME=(0,OE.forwardRef)(pO);var Eh=x(te());var Id=x(C()),mO=({onClick:e,shortKeys:t,children:n,...r})=>{let o=P("CommandPalette",Et);return(0,Id.jsxs)("button",{type:"button",...r,onClick:e,className:(0,Eh.default)(o.actionButton,r.className,{[o.hasShortKeys]:t&&t.length>0}),children:[n,t&&t.map(i=>(0,Id.jsx)("span",{className:(0,Eh.default)(o.actionShortcut,i===8629&&o.actionShortcutFixKerning),children:typeof i=="number"?String.fromCharCode(i):i},i))]})},NE=mO;var Ya=x(C()),gO="[data-command-palette-item]";function Fo({placeholder:e="Start typing to search...",typePlaceholder:t="All types",defaultPage:n="search",page:r,onChangePage:o,onChangeSearch:i,onChangeType:s,onChangeOpen:a,selectedType:l,types:u,children:c,isOpen:p,search:d}){let[m,v]=(0,Yn.useState)(),y=(0,Yn.useRef)(null),g=()=>{o&&o(n),s(void 0),i(""),a(!1)},f=()=>{var M;if(r!==n&&o){o(n);return}if(l&&s){s(void 0),(M=y.current)==null||M.focus();return}if(d.length>0){i("");return}a(!1)},h=()=>{let M=S();M.length!==0&&v(M[0].dataset.itemId)},S=()=>Array.from(document.querySelectorAll(gO)||[]),w=M=>document.querySelector(`[data-item-id=${M}]`),T=M=>{let W=w(M);W&&v(W.dataset.itemId)},b=M=>{let W=w(M);W&&W.scrollIntoView({behavior:"smooth"})},k=()=>{if(!m)return;let M=S(),W=w(m);if(!W)return;let X=M.indexOf(W),ne=M[X+1];ne&&ne.dataset.itemId?T(ne.dataset.itemId):h()},I=()=>{if(!m)return;let M=S(),W=w(m);if(!W)return;let X=M.indexOf(W),ne=M[X-1];ne&&ne.dataset.itemId?T(ne.dataset.itemId):T(M[M.length-1].dataset.itemId)},O=(0,Yn.useCallback)(M=>{switch(M.key){case"ArrowDown":{M.preventDefault(),k();break}case"ArrowUp":{M.preventDefault(),I();break}case"Enter":{if(m){let W=w(m);W==null||W.click()}break}}},[m]);return(0,Yn.useEffect)(()=>{h()},[d,r,l,p]),(0,Yn.useEffect)(()=>{m&&b(m)},[m]),(0,Ya.jsx)(Sd,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:f,onClose:g,onKeyDown:O,children:(0,Ya.jsxs)(PE,{selected:m,setSelected:v,isOpen:p,onChangeOpen:a,page:r,children:[r===n&&(0,Ya.jsx)(ME,{ref:y,onChange:i,onChangeType:s,placeholder:e,value:d,selectedType:l,types:u,typePlaceholder:t}),c]})})}Fo.Page=wh;Fo.List=ch;Fo.Image=gE;Fo.ListItem=xh;Fo.ListItemActions=LE;Fo.Button=NE;var fe=Fo;var _E=x(_());function DE(e,t){(0,_E.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 Qa=x(_());var FE={data:null,fetchState:"idle"},Od=e=>{var i;let t=[],{visitorName:n}=e.info.visitorInfo??{},{agentName:r,agentNickname:o}=e.info.agentInfo??{};return r&&r!==n&&t.push(r),o&&o!==n&&t.push(o),((i=e.entities.data)==null?void 0:i.filter(s=>!t.includes(s.text)))??null},on=B("entities/getEntities",async(e,t)=>{let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra;if(!r.conversationQuery)return Promise.resolve([]);let o=r.conversationQuery,i=await o();return i.length===0?Promise.resolve([]):n.getEntities(i)}),hO=e=>e.filter((t,n)=>n===e.findIndex(r=>r.text===t.text)),yO=G({name:"entities",initialState:FE,reducers:{},extraReducers:e=>{e.addCase(on.pending,t=>{t.fetchState="loading"}).addCase(on.rejected,t=>{t.fetchState="error"}).addCase(on.fulfilled,(t,n)=>{t.fetchState="done",t.data=hO(t.data?[...t.data,...n.payload]:n.payload)}).addCase(le,()=>FE)}}),HE=yO.reducer;var Ch={};je(Ch,{enUS:()=>vO,nlNL:()=>SO});var vO={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},SO={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var UE={root:"dd-TYTKs",empty:"dd-AU7uT"};var ts=x(C()),xO=({onCopy:e})=>{let t=(0,Qa.useRef)(null),n=P("EntitiesList",UE),r=L(Od),{setSelected:o}=Xr(),i=K(Ch),s=$();return(0,Qa.useEffect)(()=>{s(on())},[]),(0,Qa.useEffect)(()=>{t.current&&(t.current.focus(),o("entity-0"))},[t]),(0,ts.jsxs)("div",{className:n.root,ref:t,tabIndex:-1,children:[r&&r.length>0&&(0,ts.jsx)(fe.List,{children:r.map((a,l)=>(0,ts.jsx)(fe.ListItem,{id:`entity-${l}`,closeOnSelect:!0,onClick:()=>e(a),children:a.text},a.text))},"entities"),r&&r.length===0&&(0,ts.jsx)("p",{className:n.empty,children:i("noResults")})]})},zE=xO;var sn=x(_());var BE={data:null,fetchState:"idle"},jE=e=>e.summary.data,VE=e=>e.summary.fetchState==="error",KE=e=>e.summary.model,Qn=B("summary/getSummary",async(e,t)=>{var c,p,d;let n=t.getState().profile.data,r=(c=t.getState().conversation.current)==null?void 0:c.sessionId,o=(d=(p=t.getState().info)==null?void 0:p.agentInfo)==null?void 0:d.agentId;if(!n)throw new Error("Profile is not defined");let{deepdeskAPI:i,dynamicThunkObject:s}=t.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let a=s.conversationQuery,l=await a();if(l.length===0)return Promise.reject(new Error("No messages are included"));let u=await i.getSummary(l,{externalConversationId:r,agentId:o,promptInstruction:n.summarizerPromptInstruction,model:n.summarizerModel});return u.summary?u:Promise.reject(new Error("Summary is not provided"))}),wO=G({name:"summary",initialState:BE,reducers:{},extraReducers:e=>{e.addCase(Qn.pending,t=>{t.data=null,t.fetchState="loading"}).addCase(Qn.rejected,t=>{t.data=null,t.fetchState="error"}).addCase(Qn.fulfilled,(t,n)=>{t.fetchState="done",n.payload&&(t.data=n.payload.summary,t.model=n.payload.model)}).addCase(le,()=>BE)}}),WE=wO.reducer;var bh={};je(bh,{enUS:()=>EO,nlNL:()=>CO});var EO={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."}]},CO={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 $E={root:"dd-60NZr",actions:"dd-No1g3",main:"dd-l-xEF",textInput:"dd-nAaiV",loading:"dd-ciFNi",error:"dd-yNp2D"};var Md=x(te()),YE=x(_());var Th=x(C()),kh=e=>(0,Th.jsx)("svg",{width:"16",height:"16",fill:"#000000",...e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Th.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 Ph=x(C()),qE=e=>(0,Ph.jsx)("svg",{width:"16",height:"16",fill:"#000000",...e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Ph.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 ns(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 Rh={};je(Rh,{enUS:()=>bO,nlNL:()=>TO});var bO={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},TO={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};function GE(e){return B("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,{conversationId:r,...o,data:t.data})})(e)}function rs(){let e=$();return async(t,n)=>{await e(GE({name:t,data:n}))}}var XE={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};var os=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 Zn=x(C()),kO=({eventName:e,eventData:t,feedbackType:n,feedbackText:r})=>{let o=P("FeedbackThumbs",XE),i=z("enableFeedbackForm"),s=L(Vr),a=L(os(`/admin/feedback?conversationId=${s}&type=${n}&text=${r}&data=${JSON.stringify(t)}`)),l=K(Rh),u=rs(),[c,p]=(0,YE.useState)(null),d=v=>{v.stopPropagation(),ns(v.target,o.fadeup),p("up"),u(e,{...t,rating:"up"})},m=v=>{v.stopPropagation(),ns(v.target,o.fadedown),p("down"),u(e,{...t,rating:"down"})};return(0,Zn.jsxs)("div",{className:o.thumbs,children:[(0,Zn.jsx)(ee.IconButton,{title:l("thumbsUp"),onClick:d,icon:(0,Zn.jsx)(qE,{}),className:(0,Md.default)(o.thumbsUp,c==="up"&&o.selected),disabled:!!c}),i&&a?(0,Zn.jsx)(ee.IconButton,{as:"a",title:l("thumbsDown"),href:a,target:"_blank",rel:"noreferrer",onClick:m,icon:(0,Zn.jsx)(kh,{}),className:(0,Md.default)(o.thumbsDown,c==="down"&&o.selected),disabled:!!c}):(0,Zn.jsx)(ee.IconButton,{title:l("thumbsDown"),onClick:m,icon:(0,Zn.jsx)(kh,{}),className:(0,Md.default)(o.thumbsDown,c==="down"&&o.selected),disabled:!!c})]})},is=kO;var bn=x(C()),PO=({onCopy:e})=>{let t=(0,sn.useRef)(null),n=P("SummaryForm",$E),[r,o]=(0,sn.useState)(""),i=K(bh),s=L(KE),a=L(jE),l=L(VE),u=$(),c=()=>{u(et({name:"summary copied to clipboard",data:{originalText:a,finalText:r,model:s},options:{includeConversationData:!0}})),e(r)},p=()=>{let d=document.getSelection();d&&u(et({name:"summary copied to clipboard",data:{originalText:a,finalText:d==null?void 0:d.toString(),model:s},options:{includeConversationData:!0}}))};return(0,sn.useEffect)(()=>{u(Qn())},[]),(0,sn.useEffect)(()=>{o(a||"")},[a]),(0,sn.useEffect)(()=>{t.current&&a&&t.current.focus()},[t,a]),(0,sn.useEffect)(()=>{let d=m=>{m.key==="Enter"&&m.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r]),(0,bn.jsx)("div",{className:n.root,tabIndex:-1,children:l?(0,bn.jsx)("p",{className:n.error,children:i("error")}):(0,bn.jsxs)(sn.Fragment,{children:[(0,bn.jsx)("div",{className:n.main,children:(0,bn.jsx)("textarea",{placeholder:a?void 0:i("loading"),disabled:!a,className:n.textInput,ref:t,value:r,onCopy:p,onChange:d=>o(d.target.value)})}),(0,bn.jsxs)("div",{className:n.actions,children:[(0,bn.jsx)(is,{feedbackText:a||"",feedbackType:"summary",eventName:"summary feedback",eventData:{summary:a}}),(0,bn.jsx)(fe.Button,{shortKeys:[8679,8629],onClick:c,children:i("copy")})]})]})})},QE=PO;var Za={};je(Za,{enUS:()=>RO,nlNL:()=>AO});var RO={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?"}]},AO={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 Jn=x(_());var Ah={};je(Ah,{enUS:()=>LO,nlNL:()=>IO});var LO={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"}]},IO={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 ZE={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 OO={data:null,fetchState:"idle"},JE=e=>{var t;return(t=e.knowledgeAssistant)==null?void 0:t.data},Ja=B("knowledgeAssistant/getKnowledgeAssistant",async(e,t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");let i=(s=r.profile.data)==null?void 0:s.knowledgeAssistant;return i?n.getKnowledgeAssistant(i):null}),MO=G({name:"knowledgeAssistant",initialState:OO,reducers:{},extraReducers:e=>{e.addCase(Ja.pending,t=>{t.fetchState="loading"}).addCase(Ja.rejected,t=>{t.fetchState="error"}).addCase(Ja.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),eC=MO.reducer;var Lh={data:[],fetchState:"idle"},tC=e=>{var t;return(t=e.answer)==null?void 0:t.data},nC=e=>e.answer.fetchState,ss=xe("answer/resetKnowledgeSearch"),el=B("answer/getAnswer",async(e,t)=>{var l,u,c;let{deepdeskAPI:n}=t.extra,r=t.getState().answer.data,o=JE(t.getState()),i=(l=t.getState().conversation.current)==null?void 0:l.sessionId,s=(c=(u=t.getState().info)==null?void 0:u.agentInfo)==null?void 0:c.agentId;if(!o)throw new Error("KnowledgeAssistant is not defined");let a=await n.knowledgeAssist({customerInstruction:o.customerInstruction,doNotKnowAnswer:o.doNotKnowAnswer,question:e},r,o.code,{agentId:s,conversationId:i});return{question:e,answer:a}}),NO=G({name:"answer",initialState:Lh,reducers:{},extraReducers:e=>{e.addCase(el.pending,t=>{t.fetchState="loading"}).addCase(el.rejected,t=>{t.fetchState="error"}).addCase(el.fulfilled,(t,n)=>{t.fetchState="done",t.data=[...t.data,n.payload]}).addCase(le,()=>Lh).addCase(ss,()=>Lh)}}),rC=NO.reducer;var tl=x(C()),oC=()=>(0,tl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,tl.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,tl.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 tt=x(C()),_O=({onUse:e,onResetQuestion:t,question:n})=>{let[r,o]=Jn.default.useState(""),[i,s]=Jn.default.useState(!1),{setSelected:a}=Xr(),l=(0,Jn.useRef)(null),u=P("KnowledgeSearchStyles",ZE),c=K(Ah),p=$(),d=L(tC),m=L(nC),v=async f=>{s(!0),await p(el(f)),l.current&&s(!1)},y=async f=>{f.preventDefault(),f.stopPropagation(),r!==""&&v(r)},g=(f,h)=>{p(et({name:"knowledge assist source viewed",data:{question:h,sourceViewed:f.url||f.name},options:{includeConversationData:!0}}))};return(0,Jn.useEffect)(()=>{var f;n&&m==="idle"?v(n):(f=l.current)==null||f.focus()},[l,m]),(0,Jn.useEffect)(()=>{m==="done"&&(p(et({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(""))},[m,d]),(0,Jn.useEffect)(()=>{l.current&&l.current.scrollIntoView({behavior:"smooth"})},[l,d]),(0,tt.jsxs)("div",{className:u.root,children:[d.length>0&&(0,tt.jsx)("div",{className:u.alignRight,children:(0,tt.jsx)(fe.Button,{onClick:t,children:c("reset")})}),d.map(({question:f,answer:h},S)=>(0,tt.jsx)(fe.List,{children:(0,tt.jsx)(fe.ListItem,{id:`knowledge-assist-${S}`,"data-testid":"knowledge-search-answer",description:h.answer,closeOnSelect:!0,onClick:()=>e(h.answer),onSourceClick:w=>g(w,f),sources:h.sources,styles:{title:u.question,description:u.answer},extra:(0,tt.jsx)("div",{className:u.listItemFeedback,children:(0,tt.jsx)(is,{feedbackText:h.answer,feedbackType:"knowledge-assist-answer",eventName:"knowledge assist feedback",eventData:{question:f,isAgent:n!==f,isFollowUpQuestion:d.length>1,...h}})}),children:f})},`${h.answer}_${S}`)),m==="loading"&&(0,tt.jsx)("p",{className:u.status,children:c("loading")}),m==="error"&&(0,tt.jsx)("p",{className:u.status,children:c("error")}),(0,tt.jsxs)("form",{className:u.form,onSubmit:y,children:[(0,tt.jsx)("input",{ref:l,placeholder:c("anotherQuestion"),className:u.input,type:"text",value:r,onFocus:()=>{a(void 0)},onChange:f=>{a(void 0),o(f.target.value)}}),(0,tt.jsx)("button",{type:"submit",className:u.submit,disabled:i,children:(0,tt.jsx)(oC,{})})]})]})},iC=_O;var DO={data:null,fetchState:"idle"},er=e=>e.profile.data,Nd=e=>e.profile.data?e.profile.data.uiConfig.widget.types.filter(t=>t.isActive):[],sC=e=>e.profile.data?!!e.profile.data.uiConfig.widget.types.find(t=>t.type==="custom-data"):!1,nl=B("profile/getProfile",async(e,t)=>{var i;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");return((i=r.profile.data)==null?void 0:i.code)===o.profileCode?r.profile.data:n.getProfile(o.profileCode)}),FO=G({name:"profile",initialState:DO,reducers:{},extraReducers:e=>{e.addCase(nl.pending,t=>{t.fetchState="loading"}).addCase(nl.rejected,t=>{t.fetchState="error"}).addCase(nl.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),aC=FO.reducer;var hC=x(_());var HO=["{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}"],UO=new RegExp(HO.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function lC(e,t){let n=e.split(UO),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],l=i===n.length-2;r+=s.length;let u=r;if(l){let p=a.charAt(0),d=0;do u=p?t.indexOf(p,u+1):-1,d+=1;while(u!==-1&&a.indexOf(t.slice(u))!==0);if(u===-1&&d>2)return e}else u=a&&a!==""?t.indexOf(a,r):-1;let c=u===-1?t.slice(r):t.slice(r,u);o.push(c),r=u}return o.join("")}function uC(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var dC={suggestions:[],fetchState:"idle"},cC={default:dC},fC=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)??[]},_d=e=>e.textSuggestions,pC=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},Dd=xe("textSuggestions/refresh"),an=B("textSuggestions/recommendations",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,inlineSuggestions:s}=r.settings,a=Xi(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getTextSuggestions(o,_a(r),e);if(e==="default"){let c=s?l.filter(pC(a)):l;t.dispatch(En(c.slice(0,i)))}return l}),rl=B("textSuggestions/autocompletions",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,deanonymize:s,inlineSuggestions:a}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getAutocompleteSuggestions(o,{..._a(r),input:e});if(!t.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(pC(e))),s&&(l=l.map(c=>({...c,text:c.source!=="trie-with-typos"?lC(c.text,e):c.text}))),l=uC(l,i),t.dispatch(En(l)),l}),mC=G({name:"textSuggestions",initialState:cC,reducers:{setTextSuggestions:{reducer(e,t){let{contentType:n}=t.payload;e[n].fetchState="done",e[n].suggestions=t.payload.suggestions},prepare(e,t){return{payload:{contentType:e,suggestions:t}}}},setSuggestionState(e,t){return t.payload}},extraReducers:e=>{e.addCase(an.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||dC;return{...t,[r]:{...o,fetchState:"loading"}}}).addCase(an.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(an.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(rl.pending,t=>{t.default.fetchState="loading"}).addCase(rl.rejected,t=>{t.default.fetchState="error"}).addCase(rl.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(le,()=>cC)}}),{setTextSuggestions:x8,setSuggestionState:w8}=mC.actions,gC=mC.reducer;var Ho=x(C()),zO=({commands:e,onClick:t})=>{var a,l,u;let n=$(),r=K(Za),o=L(er),i=L(_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,hC.useEffect)(()=>{s.forEach(({type:c})=>{(!i[c]||i[c].suggestions.length===0)&&n(an(c))})},[]),(0,Ho.jsxs)("div",{children:[e.length>0&&(0,Ho.jsx)(fe.List,{heading:r("commands"),children:e.map((c,p)=>(0,Ho.jsx)(fe.ListItem,{id:`command-${p}`,closeOnSelect:!1,onClick:c.onClick,children:c.label},c.label))}),s.map(({type:c,title:p})=>{var d;return(0,Ho.jsx)(fe.List,{heading:p,orientation:"vertical",children:(d=i[c])==null?void 0:d.suggestions.map((m,v)=>(0,Ho.jsx)(fe.ListItem,{id:`${c}-${v}`,closeOnSelect:!1,description:m.text,onClick:()=>t(m.text,m),"data-testid":"search-overlay-suggestion",children:m.title},`${m.id}-${m.text}`))},c)})]})},yC=zO;var Ue=x(_()),vC=x(te());var Ih={root:"dd-uVyL0",trigger:"dd-KIzQa",content:"dd-Ly3zO",contentOpen:"dd-O-8fR",contentTop:"dd-q3fGa",contentBottom:"dd-SFrvc",item:"dd-HZNy-"};var Uo=x(C()),BO=0,SC=Ue.default.createContext(null),jO=()=>{let e=(0,Ue.useContext)(SC);if(!e)throw new Error("Invalid DropdownContext");return e},xC=({trigger:e,children:t,position:n="bottom"})=>{let r=(0,Ue.useMemo)(()=>++BO,[]),o=(0,Ue.useRef)(null),i=(0,Ue.useRef)(null),s=P("Dropdown",Ih),[a,l]=(0,Ue.useState)(!1),[u,c]=(0,Ue.useState)(n),p=m=>{m.preventDefault(),m.stopPropagation(),l(!a)},d=(0,Ue.useCallback)(([m])=>{!m.isIntersecting&&a&&c(u==="top"?"bottom":"top")},[a]);return(0,Ue.useEffect)(()=>{let m=v=>{o.current&&!o.current.contains(v.target)&&l(!1)};return document.addEventListener("click",m),()=>{document.removeEventListener("click",m)}},[]),(0,Ue.useEffect)(()=>{if(!i.current&&!a)return()=>{};let m=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return i.current&&m.observe(i.current),()=>{i.current&&m.unobserve(i.current)}},[i,a]),(0,Uo.jsx)(SC.Provider,{value:{setIsOpen:l},children:(0,Uo.jsxs)("div",{ref:o,className:s.root,children:[(0,Uo.jsx)("button",{id:`dropdown-${r}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:s.trigger,onClick:p,children:e}),(0,Uo.jsx)("div",{"data-testid":"dropdown-content",ref:i,"aria-hidden":!a,"aria-labelledby":`dropdown-${r}`,className:(0,vC.default)(s.content,{[s.contentOpen]:a,[s.contentTop]:u==="top",[s.contentBottom]:u==="bottom"}),children:t})]})})};function VO({as:e,children:t,onClick:n,...r}){let o=e||"button",i=P("Dropdown",Ih),{setIsOpen:s}=jO(),a=l=>{s(!1),n(l),l.stopPropagation()};return(0,Uo.jsx)(o,{type:"button",className:i.item,onClick:a,...r,children:t})}xC.Item=VO;var Oh=xC;var Mh=x(C()),wC=e=>(0,Mh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...e,children:(0,Mh.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 zo={};je(zo,{enUS:()=>KO,nlNL:()=>WO});var KO={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"}]},WO={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 Fd=x(C()),$O=({suggestion:e,source:t,context:n})=>{let r=K(zo),o=L(Vr),i=$(),s=z("enableSuggestionFeedback"),a=`${e.text}`,l=L(os(`/admin/feedback?conversationId=${o}&type=${t}&text=${a}&data=${JSON.stringify({context:n})}`)),u=()=>{i(et({name:"suggestion feedback",data:{text:e.text,source:t,context:n},options:{includeConversationData:!0}}))};return!s||!l?null:(0,Fd.jsx)(Oh,{trigger:(0,Fd.jsx)(wC,{"data-testid":"feedback-dropdown-trigger"}),children:(0,Fd.jsx)(Oh.Item,{as:"a",onClick:u,target:"_blank",href:l,children:r("giveFeedback")})})},Hd=$O;var Le=x(C()),GO=200,XO=5,YO=4,EC=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),QO=()=>{let e=$(),t=Bt(),n=K(Za),[r,o]=(0,Ct.useState)(!1),[i,s]=(0,Ct.useState)(""),a=L(F1),l=L(er),[u,c]=(0,Ct.useState)(),p=L(Je),d=z("showSearch"),m=z("enableSuggestionFeedback"),v=z("showEntitiesCommand"),y=z("showSummaryCommand"),g=z("showKnowledgeSearch"),f=z("showImageSearch"),h=z("searchTriggerKey"),S=L(fE),w=L(H1),T=L(U1),b=L(D1),k=H=>dr(w.filter(Y=>Y.type===H.toUpperCase()),H),I=[{value:"PERSONAL",label:n("personalSuggestions"),list:k("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:n("urlSuggestions"),list:k("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:k("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:k("IMAGE"),listOrientation:"horizontal",shouldShow:f}].filter(H=>H.shouldShow),O=[{label:n("entitiesClipboard"),onClick:()=>e(Jt("entities")),shouldShow:v&&EC(n("entitiesClipboard"),i)},{label:n("summaryClipboard"),onClick:()=>e(Jt("summary")),shouldShow:y&&EC(n("summaryClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(Jt("knowledgeAssist")),shouldShow:g}].filter(H=>H.shouldShow),M=(S==null?void 0:S.map(H=>({value:H.code.toUpperCase(),label:`${H.name}s`,list:k(H.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],W=(0,Ct.useCallback)((0,CC.default)((H,Y)=>{e(Ao({query:H,type:Y,tags:["search-overlay"],size:u?50:20}))},GO),[u]),X=(0,Ct.useCallback)((H,Y)=>{switch(Y.type){case"IMAGE":t.send(Yg,{suggestion:Y});break;default:t.send($r,{text:H,suggestion:Y})}e(xt(!1))},[e]),ne=H=>{$n(H.text),e(et({name:"entity copied",data:{entity:H,type:"copy"}})),e(xt(!1))},cr=H=>{t.send($r,{text:H,suggestion:{source:"knowledge-assist",text:H}}),e(et({name:"answer used",data:{originalText:H},options:{includeConversationData:!0}})),s(""),e(Jt("search")),e(ss()),e(xt(!1))},Pt=H=>{$n(H),e(xt(!1))};function dr(H,Y){return H.slice(0,u?10:Y.toLowerCase()==="image"?YO:XO)}function Rt(H){return Y=>{r?window.confirm(n("warning"))&&(H(Y),o(!1)):H(Y)}}return(0,Ct.useEffect)(()=>{i?W(i,u):e(rd())},[i,u]),(0,Ct.useEffect)(()=>{a==="search"&&e(ss())},[a]),(0,Ct.useEffect)(()=>{p&&e(Va())},[p]),DE(h,()=>e(xt(!0))),!d||!l?null:(0,Le.jsxs)(fe,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Rt(H=>e(xt(H))),onChangeType:H=>c(H),onChangePage:Rt(H=>e(Jt(H))),selectedType:u,search:i,page:a,isOpen:b,types:[...M,...I],children:[(0,Le.jsxs)(fe.Page,{id:"search",children:[i.length===0&&(0,Le.jsx)(yC,{commands:O,onClick:X}),i.length>0&&(0,Le.jsxs)(Ct.Fragment,{children:[O.length>0&&(0,Le.jsx)(fe.List,{heading:n("commands"),children:O.map((H,Y)=>(0,Le.jsx)(fe.ListItem,{closeOnSelect:!1,onClick:H.onClick,id:`commands-${Y}`,children:H.label},H.label))}),[...M,...I].map(({value:H,label:Y,list:fr,lineClamp:he,listOrientation:pr})=>(0,Le.jsx)(fe.List,{heading:Y,orientation:pr==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(H),hasMore:!u&&T[H.toLowerCase()]>dr(fr,H).length,children:dr(fr,H).map(q=>(0,Le.jsx)(fe.ListItem,{id:`${H}-${q.id}`,closeOnSelect:!1,lineClamp:he,onClick:()=>X(q.text,q),description:H!=="IMAGE"?q.title&&q.text:void 0,extra:m&&(0,Le.jsx)(fe.ListItemActions,{children:(0,Le.jsx)(Hd,{context:i,source:"search",suggestion:q})}),children:H==="IMAGE"?(0,Le.jsx)(fe.Image,{title:q.title||q.text,src:q.image}):q.title||q.text},`${q.id}-${q.text}`))},H))]})]}),(0,Le.jsx)(fe.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Rt(()=>{e(Jt("search"))}),children:(0,Le.jsx)(zE,{onCopy:ne})}),(0,Le.jsx)(fe.Page,{id:"summary",title:n("summaryTitle"),onDismiss:Rt(()=>{e(Jt("search"))}),children:(0,Le.jsx)(QE,{onCopy:Pt})}),(0,Le.jsx)(fe.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Rt(()=>{e(ss()),e(Jt("search"))}),children:(0,Le.jsx)(iC,{question:i,onUse:cr,onResetQuestion:()=>{e(ss()),s("")}})})]})},bC=QO;var ol=x(C()),ZO=()=>{let e=z("showSearch"),t=z("isEmbedded");return(0,ol.jsxs)(TC.Fragment,{children:[e&&(0,ol.jsx)(bC,{}),t&&(0,ol.jsx)(aE,{})]})},kC=ZO;var LC=x(te());var Ud=x(C()),PC=({className:e})=>(0,Ud.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,Ud.jsx)("g",{children:(0,Ud.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
|
-
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Nh=x(C()),JO={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},RC=({className:e,color:t})=>(0,Nh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Nh.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:JO[t||"pink"]})});var AC={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var _h={};je(_h,{enUS:()=>eM,nlNL:()=>tM});var eM={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},tM={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Bo=x(C()),IC=({onLogIn:e})=>{let t=K(_h),n=z("floatingMenu"),r=z("productName"),o=$(),i=L(Je),s=P("FloatingMenu",AC);if(i===null||n===!1)return null;let a=()=>{i===!0?o(xt(!0)):e()};return(0,Bo.jsxs)("button",{className:(0,LC.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,Bo.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,Bo.jsxs)("div",{className:s.icon,children:[(0,Bo.jsx)(RC,{className:s.logo,color:"pink"}),i===!1&&(0,Bo.jsx)(PC,{className:s.lock})]})]})};var Vd=x(_());var OC=x(_());function Yr(e){(0,OC.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function jo(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}function as(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input.userCommitted;return i.start!==i.end?!1:i.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(i.end))||r&&new RegExp(r).test(o.substring(0,i.end))?!0:n===!1&&r===!1:!1}var nM={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var zd=({ui:e})=>e.overlayCollapsed;var MC=G({name:"ui",initialState:nM,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputHasFocus(e,t){e.overlayCollapsedUserOverwrite!==!0&&(t.payload===!0&&(e.overlayCollapsed=!1),e.inputHasFocus=t.payload)},setOverlayCollapsed(e,t){t.payload.collapse===!1&&(e.openOverlayWhenTyping=!1),!(t.payload.skipWhenInputFocus&&e.inputHasFocus)&&(e.overlayCollapsed=t.payload.collapse)},setOpenOverlayWhenTyping(e,t){e.openOverlayWhenTyping=t.payload},setOverlayCollapsedUserOverwrite(e,t){e.overlayCollapsedUserOverwrite=t.payload,e.overlayCollapsed=t.payload}}}),{setShowTabHint:il,setInputHasFocus:Dh,setOverlayCollapsed:Qr,setOpenOverlayWhenTyping:NC,setOverlayCollapsedUserOverwrite:_C}=MC.actions,DC=MC.reducer;var Bd=x(_());var ls=x(_());var FC=x(_());function HC(e,t,n){(0,FC.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var UC={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var Vo=x(C()),oM=["search","personal-collection-search","search-autocomplete"];function iM(e,t,n,r={}){let o="";return oM.includes(t)?o=CE(Sh(e,n,{stripAgentPart:!0}),r.searchKeywords??[n]):o=Sh(e,n,r),r.placeholders===!0&&(o=bE(o)),o}var sM=()=>{},aM=({index:e,selected:t,suggestion:n})=>{let r=z("inlineSuggestions"),o=L(Xi),i=z("enableSuggestionFeedback"),s=L(p=>p.input.text),a=$(),l=P("TextSuggestion",UC),u=(0,ls.useRef)(null);(0,ls.useEffect)(()=>{let p=setTimeout(()=>{a(w1({text:n.text,suggestion:n}))},500);return()=>{clearTimeout(p)}},[n]),HC(u,"click",()=>{a(Wr(e)),a(Cn({suggestion:n,text:n.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,ls.useMemo)(()=>iM(n.text,n.source,o,{stripAgentPart:r,placeholders:!0,searchKeywords:n.searchKeywords}),[r,n.text,n.source,o,n.searchKeywords]);return n.source==="gpt"&&!r?null:(0,Vo.jsxs)("div",{className:l.root,onMouseEnter:()=>a(Wr(e)),children:[(0,Vo.jsx)(ee,{ref:u,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:sM,children:(0,Vo.jsx)(Qi,{containerTagName:"div",noWrap:!1,tagName:"span",className:l.formattedText,content:c})}),t&&i&&(0,Vo.jsx)("div",{className:l.actions,children:(0,Vo.jsx)(Hd,{source:"overlay",context:s,suggestion:n})})]})},zC=aM;var Fh=x(C()),lM=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,Bd.useMemo)(()=>{let o=e.map((i,s)=>(0,Fh.jsx)(zC,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,Fh.jsx)(Bd.Fragment,{children:r})},jd=lM;var BC={root:"dd-PfvRI",paper:"dd-HYlyY"};var sl=x(C()),uM=({textSuggestions:e,selectedIndex:t})=>{let n=(0,Vd.useRef)(null),r=P("InlineSuggestionsOverlay",BC),o=L(as),i=$(),s=L(Je),a=L(Gi),l=L(zd),u=z("showTextSuggestions");return Yr(()=>{setTimeout(()=>{i(Qr({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Vd.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let p=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,sl.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,sl.jsx)("div",{ref:n,className:r.paper,children:(0,sl.jsx)(ct,{children:(0,sl.jsx)(jd,{suggestions:e,selectedIndex:t})})})})},cM=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),jC=jn(cM)(uM);var al=x(C()),dM=({children:e})=>{let n=z("locale").replace("-","");return(0,al.jsx)(oh.Provider,{value:n,children:e})},fM=({store:e,customStyles:t={},children:n})=>(0,al.jsx)(Fg,{store:e,children:(0,al.jsx)(dM,{children:(0,al.jsx)(Cs.Provider,{value:t,children:n})})}),Ko=fM;var Wd=x(te()),us=x(_());var VC=x(_());function KC(e,t){let[n,r]=(0,VC.useState)(()=>{if(typeof window>"u")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return F.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window<"u"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){F.error(s)}}]}var WC=()=>/Mac/i.test(navigator.platform);var qC=x(te()),tr=x(_());var Hh={};je(Hh,{enUS:()=>pM,nlNL:()=>mM});var pM={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"}]}]},mM={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 $C={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var Zr=x(C()),Uh=(e,t,n)=>r=>(0,Zr.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),gM=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=K(Hh),s=Bt(),a=P("Login",$C),l=z("productName"),u=(0,tr.useCallback)(g=>{g.preventDefault(),r&&r(parseInt(g.target.value,10))},[]),c=(0,tr.useCallback)(g=>{g.preventDefault(),s.send(Yi,!0)},[t]),p=(0,tr.useMemo)(()=>g=>(0,Zr.jsx)("a",{onClick:h=>{h.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[t]),d=(0,tr.useCallback)(g=>(0,Zr.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:m,hour:v,day:y}=(0,tr.useMemo)(()=>({min:Uh(a,60*10,u),hour:Uh(a,60*60,u),day:Uh(a,60*60*12,u)}),[]);return(0,Zr.jsxs)("div",{className:(0,qC.default)(e,a.root),children:[i("loginPlease",{login:n?d:p,productName:l}),r&&(0,Zr.jsxs)(tr.Fragment,{children:[(0,Zr.jsx)("br",{}),i("snooze",{min:m,hour:v,day:y})]})]})},Kd=gM;var GC={root:"dd-DoQhb",text:"dd-Jwnev"};var ll=x(C()),hM=({title:e})=>{let t=P("SearchTrigger",GC),n=$();return(0,ll.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(xt(!0)),children:[(0,ll.jsx)(es,{}),(0,ll.jsx)("span",{className:t.text,children:e})]})},XC=hM;var zh={};je(zh,{enUS:()=>yM,nlNL:()=>vM});var yM={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"}]},vM={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 YC={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 Se=x(C()),SM=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=P("SuggestionsOverlay",YC),o=K(zh),i=L(as),s=y1(),a=$(),l=(0,us.useRef)(null),u=z("searchTriggerKey"),c=z("productName"),p=L(zd),d=L(Je),m=L(Gi),[v,y]=(0,us.useState)(null),g=z("showSearch"),f=z("showTextSuggestions"),h=z("adminUrl"),S=z("isEmbedded"),[w,T]=KC("dd-snooze-until-ms",0),b=p||w>Date.now(),k=e.filter(M=>M.source!=="gpt").length,I=()=>{b&&T(0),a(_C(!b))},O=M=>{let W=Date.now()+M*1e3;T(W),F.info(`Snooze until: ${new Date(W)}`),a(Qr({collapse:!0}))};return(0,us.useEffect)(()=>{k===0&&y(null)},[e,k]),Yr(()=>{a(Qr({collapse:!0,skipWhenInputFocus:!0}))}),d===null||m===!1?null:d===!1?(0,Se.jsxs)("div",{ref:l,className:(0,Wd.default)(r.root,{[r.isCollapsed]:b}),children:[!b&&(0,Se.jsxs)("div",{className:r.triggers,children:[(0,Se.jsx)("div",{style:{flex:1}}),(0,Se.jsx)("div",{className:r.triggersRight,children:(0,Se.jsx)(uo,{className:r.toggleButton,title:o("collapse"),onClick:I,isCollapsed:!1})})]}),(0,Se.jsx)("div",{className:r.toggleButtonWrapper,children:(0,Se.jsx)(uo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:I,isCollapsed:!0})}),(0,Se.jsx)("div",{className:r.collapsible,children:(0,Se.jsx)(Kd,{loginUrl:h,isEmbedded:S,onLogIn:n,onSnooze:O})})]}):!s||!i?null:(0,Se.jsxs)("div",{ref:l,className:(0,Wd.default)(r.root,{[r.isCollapsed]:b}),children:[!b&&(0,Se.jsxs)("div",{className:r.triggers,children:[(0,Se.jsx)("div",{style:{flex:1},children:g&&(0,Se.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>y(o(WC()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>y(null),children:(0,Se.jsx)(XC,{title:o("search")})})}),(0,Se.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,Se.jsx)("div",{className:(0,Wd.default)(!v&&r.hintsHidden,r.hints),children:v}),(0,Se.jsx)(uo,{className:r.toggleButton,title:o("collapse"),onClick:I,isCollapsed:!1})]})]}),(0,Se.jsx)("div",{className:r.toggleButtonWrapper,children:(0,Se.jsx)(uo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:I,isCollapsed:!0})}),k>0&&f&&(0,Se.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,Se.jsx)(ct,{children:(0,Se.jsx)(jd,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},xM=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),QC=jn(xM)(SM);var af=x(te());var ir=x(_());var cs=x(_());function $d(e){return e.contentEditable==="true"}function wM(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 ZC(e){let{selectionStart:t,selectionEnd:n}=$d(e)?wM(e):e;return[t,n]}function JC(e){let[,t]=(0,cs.useState)(),n=(0,cs.useRef)(null);return n.current=ZC(e),(0,cs.useEffect)(()=>{let r=()=>{let[o,i]=n.current??[],s=ZC(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 eb(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(Xl);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 tb=x(_()),EM=["div","span","mark","strong","b","i","u","em"];function Bh(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(EM.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,tb.cloneElement)(r,{children:Bh(s,t,n+1)})]}return[...e,...t]}function Jr(e){return e.tagName.toLowerCase()==="textarea"}var nb={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 fb=x(te());var tf=x(_());var ds=x(_());function rb(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function qd(e){let t=(0,ds.useRef)(null),[n,r]=(0,ds.useState)(!1);return(0,ds.useEffect)(()=>{let o=!1,i=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[s,a]=rb((c,p)=>{let d=t.current;if(!d)return;let m=c/i,v=p/i,y=d.getBoundingClientRect(),g=m>y.x&&m<y.x+y.width&&v>y.y&&v<y.y+y.height;g&&!o?(o=!0,r(!0)):!g&&o&&(o=!1,r(!1))},({clientX:c,clientY:p})=>[c,p]),[l,u]=rb(()=>{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 ob(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Gd(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function ib(e){return e!=null}var Vh=x(te()),Vt=x(_());var Xd=x(_()),CM=["bottom","height","left","right","top","width"],bM=(e={},t={})=>CM.some(n=>e[n]!==t[n]),nr=new Map,sb,ab=()=>{let e=[],t=[];nr.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();bM(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{nr.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),sb=window.requestAnimationFrame(ab)};function TM(e,t){return{observe(){let n=nr.size===0;if(nr.has(e)){let r=nr.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else nr.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&ab()},unobserve(){let n=nr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||nr.delete(e),nr.size||cancelAnimationFrame(sb)}}}}function jh(e){let[t,n]=(0,Xd.useState)(null);return(0,Xd.useLayoutEffect)(()=>{if(!e.current)return;let r=TM(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var fs=x(_()),ub=x(uc());var lb={root:"dd-r-dgo"};var cb=({children:e,parentNode:t})=>{let[n,r]=(0,fs.useState)(null),o=(0,fs.useContext)(Cs);return(0,fs.useLayoutEffect)(()=>{let i=document.createElement("div");return jo(i),i.classList.add(lb.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,ub.createPortal)(e,n):null};var Tn={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 Yd=x(C()),Qd=(e=!1)=>{let[t,n]=(0,Vt.useState)(e),r=(0,Vt.useCallback)(()=>n(!0),[]),o=(0,Vt.useCallback)(()=>n(!1),[]),i=(0,Vt.useCallback)(()=>n(a=>!a),[]),s=(0,Vt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function Kh(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 ps=({className:e,triggerRef:t,boundaryRef:n=(0,Vt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=Kh,parentNode:a,...l})=>{let u=jh(t),c=jh(n),p=(0,Vt.useMemo)(()=>s(u,c,0),[u,c]);return(0,Yd.jsx)(cb,{parentNode:a,children:(0,Yd.jsx)("div",{className:(0,Vh.default)(Tn.ref,{[Tn.positionAbove]:r==="above",[Tn.positionBelow]:r==="below",[Tn.positionLeft]:r==="left",[Tn.positionRight]:r==="right",[Tn.alignStart]:o==="start",[Tn.alignCenter]:o==="center",[Tn.alignEnd]:o==="end"}),style:p,...l,role:"dialog",children:(0,Yd.jsx)("div",{className:(0,Vh.default)(e,Tn.root),children:i})})})};var db=x(te()),Zd=x(_());var rr={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 Wh=x(C()),Jd=(0,Zd.forwardRef)(({className:e,children:t,...n},r)=>{let o=(0,Zd.useRef)(null),i=P("TabCompletion",rr);return(0,Wh.jsx)("div",{ref:Gd([o,r]),className:(0,db.default)(e,i.popoverContentContainer),...n,children:(0,Wh.jsx)("div",{className:i.popoverContent,children:t})})});var eo=x(C()),kM=e=>t=>{let n=Kh(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},PM=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=P("TabCompletion",rr),s=Qd(),a=(0,tf.useMemo)(()=>kM(e.getBoundingClientRect()),[e]),[l,u]=qd(e);return(0,tf.useEffect)(()=>{u?s.open():s.close()},[u]),(0,eo.jsxs)("span",{children:[(0,eo.jsx)("mark",{ref:Gd([l,s.triggerRef]),className:(0,fb.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,eo.jsx)(ps,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,eo.jsx)(Jd,{style:n,children:(0,eo.jsx)("div",{className:i.hintText,children:o})})})]})},ef=class extends Gn{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(t,n){return n.keywordMatches&&n.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=n.keywordMatches.map(r=>({...r,keywordRegex:new RegExp(`\\b${ob(r.keyword)}\\b`,"i")})),this.keywordMatches=n.keywordMatches),this.usedKeywordMatches.clear(),t}match(t){let n=this.preparedKeywordMatches.map(o=>{if(this.usedKeywordMatches.has(o))return null;let i=t.match(o.keywordRegex);if(!i)return null;let s=t.charAt(i.index-1),a=t.charAt(i.index+o.keyword.length);return s==="{"&&a==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:o.suggestion,preparedKeywordMatch:o,valid:!0}}).filter(ib);if(n.length===0)return null;let r=n.reduce((o,i)=>i.index<o.index?i:o);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(t,n){return(0,eo.jsx)(PM,{inputElement:n.inputElement,suggestion:n.suggestion,inputStyle:n.inputStyle,boundaryRef:n.boundaryRef,children:t},`keyword_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var pb=x(te());var $h=x(C()),RM=({inputElement:e,children:t})=>{let n=P("TabCompletion",rr),[r,o]=qd(e);return(0,$h.jsx)("mark",{ref:r,className:(0,pb.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},nf=class extends Gn{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,$h.jsx)(RM,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var of=x(te());var rt=x(_());var qh=x(C()),mb=()=>(0,qh.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,qh.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 to=x(_());var hb=x(uh());var gb={root:"dd-ky-Bv",content:"dd-kV5e1"};function rf(e,t,n){var o;let r=((o=e.imageSizes)==null?void 0:o[t])||e.image||n;if(!r)return null;try{return new URL(r).toString()}catch{return null}}function Gh(e){return e.replace("https://www.","").replace("https://","")}var Kt=x(C()),AM=3,LM=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),IM=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=AM})=>{let i=P("LinkSearch",gb),[s,a]=(0,to.useState)(""),l=$(),u=L(fC("url")),c=L(z1("URL",LM)),[p,d]=(0,to.useState)(c.length-1),m=z("fallbackImage"),v=h=>{let S=h.target;a(S.value)},y=(h,S)=>{h.stopPropagation(),h.preventDefault(),window.open(S,"_blank")},g=h=>{var T;let S=p-1<0?c.length-1:p-1,w=p+1===c.length?0:p+1;h.code==="Escape"&&(a(""),t()),h.code==="ArrowUp"&&d(S),h.code==="ArrowDown"&&d(w),h.code==="Enter"&&e(((T=c[p])==null?void 0:T.text)||s)},f=(0,to.useCallback)((0,hb.default)(h=>{l(Ao({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,to.useEffect)(()=>{s&&f(s)},[s]),(0,to.useEffect)(()=>()=>{l(rd())},[]),(0,Kt.jsxs)("div",{className:i.root,children:[(0,Kt.jsx)(ct,{withDivider:!0,children:(s?c:u).slice(0,o).map((h,S)=>(0,Kt.jsx)(ee,{selected:p===S,onClick:()=>e(h.text),"data-testid":"linksearch-suggestion",children:(0,Kt.jsxs)(pe,{children:[(0,Kt.jsx)(pe.Image,{src:rf(h,"small",m||void 0),title:h.title||h.text}),(0,Kt.jsxs)(pe.Content,{className:i.content,cropText:!0,children:[(0,Kt.jsx)(pe.Title,{children:h.title||Gh(h.text)}),h.title&&Gh(h.text)]}),(0,Kt.jsx)(ee.Actions,{children:(0,Kt.jsx)(ee.ActionButton,{label:r,onClick:w=>y(w,h.text)})})]})},h.text))}),(0,Kt.jsx)(ja,{value:s,onChange:v,autoFocus:!0,placeholder:n,onKeyUp:g})]})},yb=IM;var Xh={};je(Xh,{enUS:()=>OM,nlNL:()=>MM});var OM={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},MM={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var nt=x(C()),NM=(0,rt.forwardRef)((e,t)=>{let n=P("TabCompletion",rr);return(0,nt.jsx)("mark",{ref:t,className:(0,of.default)(n.matchSelection)},"selection-start")}),_M=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=K(Xh),s=P("TabCompletion",rr),a=(0,rt.useRef)(null),l=(0,rt.useRef)(null),[u,c]=(0,rt.useState)(null),p=$(),d=Qd(document.activeElement===r),[m]=(0,rt.useState)(()=>document.createRange());d.triggerRef.current=m,(0,rt.useEffect)(()=>()=>m.detach(),[]),(0,rt.useEffect)(()=>{let y=e.current,g=a.current;!y||!g||(m.setStart(y,0),m.setEnd(g,0))},[e.current,a.current]),Yr(()=>{d.close()});let v=(0,rt.useCallback)(y=>{let g=m.toString(),f=/^http(s?):\/\//.test(y)?y:`https://${y}`;p(Zc({text:`[${g}](${f})`,replace:"selection"}))},[]);return(0,nt.jsxs)("span",{children:[(0,nt.jsx)("mark",{ref:a,className:(0,of.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,nt.jsx)(ps,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,nt.jsxs)(Jd,{style:n,ref:l,children:[(0,nt.jsx)("div",{className:(0,of.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,nt.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,nt.jsx)(mb,{}),(0,nt.jsx)("span",{children:"\xA0"}),(0,nt.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,nt.jsx)(yb,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:v,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},sf=class extends Gn{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(t,n){return this.props=n,this.charCount=0,this.startRef=(0,rt.createRef)(),this.foundIndex=0,t}match(t){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[n,r]=this.props.selection;if(n===r)return null;let o=this.foundIndex===0?n:r,i=o>=this.charCount&&o<=this.charCount+t.length?{index:o-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let s=this.foundIndex===1;return i&&s?this.charCount+=o-this.charCount:this.charCount+=t.length,i?{isStart:s,...i}:null}replaceWith(t,n){return n.isStart?(0,nt.jsx)(NM,{ref:this.startRef}):(0,nt.jsx)(_M,{inputElement:n.inputElement,startRef:this.startRef,boundaryRef:n.boundaryRef,inputStyle:n.inputStyle})}asTag(){return"mark"}};var or=x(C()),DM=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=P("TabCompletion",nb),c=z("insertLink"),p=z("showMidSentenceSuggestions"),d=z("inlineSuggestions"),m=JC(a),v=(0,ir.useRef)(null),y=L(Je);(0,ir.useEffect)(()=>{Jr(a)&&m&&eb(a,m)},[m]);let g=(0,ir.useCallback)(S=>{if(!o||!n)return S;let w=[(0,or.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,or.jsx)("span",{"data-testid":"tab-completion",className:(0,af.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&w.push((0,or.jsx)("span",{className:(0,af.default)(u.hint,u.resetIndent),children:(0,or.jsx)(Wl,{keyCode:"tab"},"tabHint")})),Bh(S,w)},[o,n,r]),f=(0,ir.useMemo)(()=>{let S=[];return c&&S.push(new sf("selection")),S.push(new nf("placeholders")),i&&S.push(new ef("keywords")),S},[d,c,i]),h=(0,ir.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,or.jsxs)("div",{ref:S=>{S!=null&&S.parentElement&&(v.current=S==null?void 0:S.parentElement)},className:u.root,style:h,children:[(0,or.jsx)(Qi,{tagName:"span",containerTagName:"div",className:(0,af.default)(u.container,u.agentText),disableLineBreaks:Jr(a),content:t||"\u200B",onAfterParse:g,matchers:f,selection:m,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:v,inlineSuggestionsOnlyAtEnd:!p}),(0,or.jsx)("br",{})]})},FM=({input:e,ui:t,settings:n,styleSuggestions:r,conversation:o})=>{var y;let{tabCompletionSuggestion:i}=e,s=(i==null?void 0:i.text)||"",a=(i==null?void 0:i.source)||"",l=e.html??Zi(e.text),u=s.indexOf(e.text)===0?s.slice(e.text.length):"",{showTabHint:c}=t,{isSupported:p}=o,{showTabCompletion:d,visible:m,showStyleSuggestions:v}=n;return{showTabHint:c,showStyleSuggestions:v,showTabCompletion:d,content:l,tabText:u,source:a,keywordMatches:((y=r.list)==null?void 0:y.keywordMatches)??[],enabled:m&&p!==!1}},vb=jn(FM)(DM);var MT=x(te()),wl=x(_());var Sb={list:[],fetchState:"idle"},wb=e=>e.autoflows.list||[],xb=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},sr=B("autoflows/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)}),Yh=B("autoflows/start",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.startAutoflowSession(e),await n(sr(e.platformSessionId))}),Qh=B("autoflows/stop",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.stopAutoflowSession(e.platformSessionId),await n(sr(e.platformSessionId))}),HM=G({name:"autoflows",initialState:Sb,reducers:{},extraReducers:e=>{e.addCase(Yh.pending,(t,n)=>{let r=xb(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(Qh.pending,(t,n)=>{let r=xb(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(sr.pending,t=>{t.fetchState="loading"}),e.addCase(sr.rejected,t=>{t.fetchState="error"}),e.addCase(sr.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(le,()=>Sb)}}),Eb=B("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(sr(e))}),o.on("sessionCompleted",()=>{n(sr(e))})}),Cb=B("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),bb=HM.reducer;var Tb={list:[],fetchState:"idle",sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},kb=e=>e.customMessages.list,Pb=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),Rb=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),Ab=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),ul=B("customMessages/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)}),lf=B("customMessages/send",async(e,t)=>{let{platformSessionId:n,suggestion:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.sendCustomMessage(n,r)}),uf=B("customMessages/answer",async(e,t)=>{let{platformSessionId:n,reply:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.answerCustomMessage(n,r)}),Lb=G({name:"customMessages",initialState:Tb,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(ul.pending,t=>{t.fetchState="loading"}).addCase(ul.rejected,t=>{t.fetchState="error"}).addCase(ul.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(lf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(lf.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(uf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(uf.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(le,()=>Tb)}}),Ib=B("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(Lb.actions.onCustomMessage(i))})}),Ob=B("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),Mb=Lb.reducer;var UM={token:null,interval:null},Zh=B("passwordlessToken/getTemporaryPasswordlessToken",async(e,t)=>{let{deepdeskAPI:n}=t.extra;return{token:await n.requestPasswordlessToken()}}),Jh=B("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(Zh()),setInterval(()=>r(Zh()),n)}),Nb=G({name:"passwordlessToken",initialState:UM,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(Zh.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(Jh.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:_b}=Nb.actions,Db=Nb.reducer;var Fb={shouldEmit:!0},ey={cues:[],fetchState:"idle"},Hb=e=>{var t;return(t=e.rules)==null?void 0:t.cues},zM=xe("rules/resetCues"),Wo=B("rules/evaluate",async(e,t)=>{var n,r;try{let{deepdeskAPI:o}=t.extra,i=t.getState(),s=(n=i.conversation.current)==null?void 0:n.id;if(!s)throw new Error("No current conversation to evaluate rules");if(!(await o.getAccount()).ruleEngine)throw new Error("Rule engine is not enabled for this account");if(!(await o.getRules()).filter(p=>p.isEnabled).some(p=>p.label===e.label))throw new Error(`No enabled rules found with label: ${e.label}`);return{cues:await o.evaluateRule(e.label,s,{tags:((r=i.conversation.current)==null?void 0:r.tags)||void 0,...e.params}),options:e.options}}catch(o){return F.info(o.message),{cues:[],options:e.options}}}),Ub=G({name:"answer",initialState:ey,reducers:{removeCue(e,t){e.cues=e.cues.filter(n=>n.rule.id!==t.payload.id)}},extraReducers:e=>{e.addCase(Wo.pending,t=>{t.fetchState="loading"}).addCase(Wo.rejected,t=>{t.fetchState="error"}).addCase(Wo.fulfilled,(t,n)=>{let r=n.payload.cues.map(i=>i.rule.id),o=t.cues.filter(i=>!r.includes(i.rule.id));t.fetchState="done",t.cues=[...n.payload.cues,...o]}).addCase(le,()=>ey).addCase(zM.toString(),()=>ey)}}),{removeCue:zb}=Ub.actions,Bb=Ub.reducer;var Yb=x(_());var qb=x(te()),Gb=x(_());var Vb=x(te());var jb={root:"dd-uszkm"};var Wb=x(C()),BM=({className:e,children:t})=>{let n=P("Unicode",jb);return(0,Wb.jsx)("span",{className:(0,Vb.default)(e,n.root),children:t})},Kb=BM;var $b={isDisabled:"dd-Sp--t",root:"dd-maqTG",buttonStop:"dd-rcq8w",stateBadge:"dd-zOnkT",isCompleted:"dd-GA-rt",isStarted:"dd-PZwtX",isAborted:"dd-PAXSE"};var ty={};je(ty,{enUS:()=>jM,nlNL:()=>VM});var jM={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"}]},VM={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 bt=x(C()),WM=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=P("Autoflow",$b),a=K(ty),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,bt.jsxs)(ee,{className:(0,qb.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,bt.jsx)(pe,{children:(0,bt.jsxs)(pe.Content,{children:[(0,bt.jsxs)(pe.Title,{children:[t&&(0,bt.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,bt.jsx)("span",{children:r})]})}),(0,bt.jsx)(ee.Actions,{fixed:t==="Started",children:(0,bt.jsx)(ee.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,bt.jsxs)(Gb.Fragment,{children:[(0,bt.jsx)(Kb,{children:u})," ",(0,bt.jsx)("span",{children:a(l)})]})})})]})},Xb=WM;var ny=x(C()),$M=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},qM=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,ny.jsx)(Yb.Fragment,{children:e.map(o=>(0,ny.jsx)(Xb,{displayName:o.displayName,description:o.description,disabled:o.isBusy||$M(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),GM=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},XM={onStartAutoflow:Yh,onStopAutoflow:Qh},Qb=jn(GM,XM)(qM);var Zb=x(te()),ry=x(_());var ar={root:"dd-ERsBr",title:"dd-b36p6",isUsed:"dd-fp2IX",quickReplies:"dd--VrvP",quickReply:"dd-wFhWh",label:"dd-R9sND",errorIcon:"dd-8cdcH"};var gt=x(C()),YM=({suggestion:e})=>{let t=K(zo),n=$(),r=L(Pb(e.text)),o=L(Rb(e.text)),i=L(Ab(e.text)),s=L(qi),{replyOptions:a}=e,l=(0,ry.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(lf({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,ry.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let p=parseInt(c.target.dataset.index,10),d=a[p];n(uf({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,gt.jsxs)(ee,{onClick:l,className:(0,Zb.default)(ar.root,{[ar.isUsed]:r,[ar.hasError]:i}),children:[(0,gt.jsx)(pe,{children:(0,gt.jsxs)(pe.Content,{children:[(0,gt.jsxs)(pe.Title,{className:ar.title,children:[e.text," ",(0,gt.jsx)($l,{className:ar.label,children:"analyse tool"})," ",i&&(0,gt.jsx)("span",{className:ar.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,gt.jsx)("ul",{className:ar.quickReplies,children:a.map(c=>(0,gt.jsx)("li",{className:ar.quickReply,children:c.title},c.title))})]})}),(0,gt.jsxs)(ee.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,gt.jsx)(ee.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,p)=>(0,gt.jsx)(ee.DropdownItem,{index:p,label:c.title,onClick:u},c.title))}),(0,gt.jsx)(ee.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},Jb=YM;var cf=x(_());var iy=x(te());var oy=x(C()),cl=()=>(0,oy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,oy.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 eT={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var kn=x(C()),QM=({entities:e})=>{let t=P("EntitiesWidgetList",eT),[n,r]=(0,cf.useState)(void 0),o=$(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),$n(a.text),o(et({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,cf.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,kn.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,kn.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,kn.jsx)("span",{className:t.entityText,children:a.text}),(0,kn.jsxs)("span",{className:t.iconWrapper,children:[(0,kn.jsx)("span",{className:(0,iy.default)(t.icon),children:(0,kn.jsx)(cl,{})}),(0,kn.jsx)("span",{className:(0,iy.default)(t.icon,n===l&&t.iconClicked),children:(0,kn.jsx)(cl,{})})]})]},a.text))})},tT=QM;var sy=x(C()),nT=()=>(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 ay=x(C()),rT=()=>(0,ay.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ay.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 ly=x(C()),oT=()=>(0,ly.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ly.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 CT=x(_());var dl=x(C()),iT=({className:e})=>(0,dl.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:e,children:[(0,dl.jsx)("line",{x1:"2",y1:"10",x2:"10",y2:"2",stroke:"black",strokeWidth:"1"}),(0,dl.jsx)("line",{x1:"2",y1:"2",x2:"10",y2:"10",stroke:"black",strokeWidth:"1"})]});var{entries:pT,setPrototypeOf:sT,isFrozen:ZM,getPrototypeOf:JM,getOwnPropertyDescriptor:eN}=Object,{freeze:ot,seal:un,create:mT}=Object,{apply:my,construct:gy}=typeof Reflect<"u"&&Reflect;ot||(ot=function(t){return t});un||(un=function(t){return t});my||(my=function(t,n,r){return t.apply(n,r)});gy||(gy=function(t,n){return new t(...n)});var df=kt(Array.prototype.forEach),aT=kt(Array.prototype.pop),fl=kt(Array.prototype.push),mf=kt(String.prototype.toLowerCase),uy=kt(String.prototype.toString),tN=kt(String.prototype.match),pl=kt(String.prototype.replace),nN=kt(String.prototype.indexOf),rN=kt(String.prototype.trim),ln=kt(Object.prototype.hasOwnProperty),Tt=kt(RegExp.prototype.test),ml=oN(TypeError);function kt(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 my(e,t,r)}}function oN(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return gy(e,n)}}function Q(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mf;sT&&sT(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let i=n(o);i!==o&&(ZM(t)||(t[r]=i),o=i)}e[o]=!0}return e}function iN(e){for(let t=0;t<e.length;t++)ln(e,t)||(e[t]=null);return e}function $o(e){let t=mT(null);for(let[n,r]of pT(e))ln(e,n)&&(Array.isArray(r)?t[n]=iN(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=$o(r):t[n]=r);return t}function ff(e,t){for(;e!==null;){let r=eN(e,t);if(r){if(r.get)return kt(r.get);if(typeof r.value=="function")return kt(r.value)}e=JM(e)}function n(){return null}return n}var lT=ot(["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"]),cy=ot(["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"]),dy=ot(["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"]),sN=ot(["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"]),fy=ot(["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"]),aN=ot(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),uT=ot(["#text"]),cT=ot(["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","xmlns","slot"]),py=ot(["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"]),dT=ot(["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"]),pf=ot(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),lN=un(/\{\{[\w\W]*|[\w\W]*\}\}/gm),uN=un(/<%[\w\W]*|[\w\W]*%>/gm),cN=un(/\${[\w\W]*}/gm),dN=un(/^data-[\-\w.\u00B7-\uFFFF]/),fN=un(/^aria-[\-\w]+$/),gT=un(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),pN=un(/^(?:\w+script|data):/i),mN=un(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),hT=un(/^html$/i),fT=Object.freeze({__proto__:null,MUSTACHE_EXPR:lN,ERB_EXPR:uN,TMPLIT_EXPR:cN,DATA_ATTR:dN,ARIA_ATTR:fN,IS_ALLOWED_URI:gT,IS_SCRIPT_OR_DATA:pN,ATTR_WHITESPACE:mN,DOCTYPE_NAME:hT}),gN=function(){return typeof window>"u"?null:window},hN=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{return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function yT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gN(),t=U=>yT(U);if(t.version="3.0.9",t.removed=[],!e||!e.document||e.document.nodeType!==9)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:p,DOMParser:d,trustedTypes:m}=e,v=l.prototype,y=ff(v,"cloneNode"),g=ff(v,"nextSibling"),f=ff(v,"childNodes"),h=ff(v,"parentNode");if(typeof s=="function"){let U=n.createElement("template");U.content&&U.content.ownerDocument&&(n=U.content.ownerDocument)}let S,w="",{implementation:T,createNodeIterator:b,createDocumentFragment:k,getElementsByTagName:I}=n,{importNode:O}=r,M={};t.isSupported=typeof pT=="function"&&typeof h=="function"&&T&&T.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:W,ERB_EXPR:X,TMPLIT_EXPR:ne,DATA_ATTR:cr,ARIA_ATTR:Pt,IS_SCRIPT_OR_DATA:dr,ATTR_WHITESPACE:Rt}=fT,{IS_ALLOWED_URI:H}=fT,Y=null,fr=Q({},[...lT,...cy,...dy,...fy,...uT]),he=null,pr=Q({},[...cT,...py,...dT,...pf]),q=Object.seal(mT(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}})),mr=null,Al=null,Yo=!0,oo=!0,vs=!1,Ll=!0,qt=!1,Gt=!1,Il=!1,it=!1,At=!1,Ol=!1,Ml=!1,Ly=!0,Iy=!1,Ck="user-content-",kf=!0,Ss=!1,Qo={},Zo=null,Oy=Q({},["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"]),My=null,Ny=Q({},["audio","video","img","source","image","track"]),Pf=null,_y=Q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Nl="http://www.w3.org/1998/Math/MathML",_l="http://www.w3.org/2000/svg",Ln="http://www.w3.org/1999/xhtml",Jo=Ln,Rf=!1,Af=null,bk=Q({},[Nl,_l,Ln],uy),xs=null,Tk=["application/xhtml+xml","text/html"],kk="text/html",Oe=null,ei=null,Pk=n.createElement("form"),Dy=function(E){return E instanceof RegExp||E instanceof Function},Lf=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ei&&ei===E)){if((!E||typeof E!="object")&&(E={}),E=$o(E),xs=Tk.indexOf(E.PARSER_MEDIA_TYPE)===-1?kk:E.PARSER_MEDIA_TYPE,Oe=xs==="application/xhtml+xml"?uy:mf,Y=ln(E,"ALLOWED_TAGS")?Q({},E.ALLOWED_TAGS,Oe):fr,he=ln(E,"ALLOWED_ATTR")?Q({},E.ALLOWED_ATTR,Oe):pr,Af=ln(E,"ALLOWED_NAMESPACES")?Q({},E.ALLOWED_NAMESPACES,uy):bk,Pf=ln(E,"ADD_URI_SAFE_ATTR")?Q($o(_y),E.ADD_URI_SAFE_ATTR,Oe):_y,My=ln(E,"ADD_DATA_URI_TAGS")?Q($o(Ny),E.ADD_DATA_URI_TAGS,Oe):Ny,Zo=ln(E,"FORBID_CONTENTS")?Q({},E.FORBID_CONTENTS,Oe):Oy,mr=ln(E,"FORBID_TAGS")?Q({},E.FORBID_TAGS,Oe):{},Al=ln(E,"FORBID_ATTR")?Q({},E.FORBID_ATTR,Oe):{},Qo=ln(E,"USE_PROFILES")?E.USE_PROFILES:!1,Yo=E.ALLOW_ARIA_ATTR!==!1,oo=E.ALLOW_DATA_ATTR!==!1,vs=E.ALLOW_UNKNOWN_PROTOCOLS||!1,Ll=E.ALLOW_SELF_CLOSE_IN_ATTR!==!1,qt=E.SAFE_FOR_TEMPLATES||!1,Gt=E.WHOLE_DOCUMENT||!1,At=E.RETURN_DOM||!1,Ol=E.RETURN_DOM_FRAGMENT||!1,Ml=E.RETURN_TRUSTED_TYPE||!1,it=E.FORCE_BODY||!1,Ly=E.SANITIZE_DOM!==!1,Iy=E.SANITIZE_NAMED_PROPS||!1,kf=E.KEEP_CONTENT!==!1,Ss=E.IN_PLACE||!1,H=E.ALLOWED_URI_REGEXP||gT,Jo=E.NAMESPACE||Ln,q=E.CUSTOM_ELEMENT_HANDLING||{},E.CUSTOM_ELEMENT_HANDLING&&Dy(E.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(q.tagNameCheck=E.CUSTOM_ELEMENT_HANDLING.tagNameCheck),E.CUSTOM_ELEMENT_HANDLING&&Dy(E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(q.attributeNameCheck=E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),E.CUSTOM_ELEMENT_HANDLING&&typeof E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(q.allowCustomizedBuiltInElements=E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),qt&&(oo=!1),Ol&&(At=!0),Qo&&(Y=Q({},uT),he=[],Qo.html===!0&&(Q(Y,lT),Q(he,cT)),Qo.svg===!0&&(Q(Y,cy),Q(he,py),Q(he,pf)),Qo.svgFilters===!0&&(Q(Y,dy),Q(he,py),Q(he,pf)),Qo.mathMl===!0&&(Q(Y,fy),Q(he,dT),Q(he,pf))),E.ADD_TAGS&&(Y===fr&&(Y=$o(Y)),Q(Y,E.ADD_TAGS,Oe)),E.ADD_ATTR&&(he===pr&&(he=$o(he)),Q(he,E.ADD_ATTR,Oe)),E.ADD_URI_SAFE_ATTR&&Q(Pf,E.ADD_URI_SAFE_ATTR,Oe),E.FORBID_CONTENTS&&(Zo===Oy&&(Zo=$o(Zo)),Q(Zo,E.FORBID_CONTENTS,Oe)),kf&&(Y["#text"]=!0),Gt&&Q(Y,["html","head","body"]),Y.table&&(Q(Y,["tbody"]),delete mr.tbody),E.TRUSTED_TYPES_POLICY){if(typeof E.TRUSTED_TYPES_POLICY.createHTML!="function")throw ml('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof E.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ml('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=E.TRUSTED_TYPES_POLICY,w=S.createHTML("")}else S===void 0&&(S=hN(m,o)),S!==null&&typeof w=="string"&&(w=S.createHTML(""));ot&&ot(E),ei=E}},Fy=Q({},["mi","mo","mn","ms","mtext"]),Hy=Q({},["foreignobject","desc","title","annotation-xml"]),Rk=Q({},["title","style","font","a","script"]),Uy=Q({},[...cy,...dy,...sN]),zy=Q({},[...fy,...aN]),Ak=function(E){let A=h(E);(!A||!A.tagName)&&(A={namespaceURI:Jo,tagName:"template"});let D=mf(E.tagName),ce=mf(A.tagName);return Af[E.namespaceURI]?E.namespaceURI===_l?A.namespaceURI===Ln?D==="svg":A.namespaceURI===Nl?D==="svg"&&(ce==="annotation-xml"||Fy[ce]):!!Uy[D]:E.namespaceURI===Nl?A.namespaceURI===Ln?D==="math":A.namespaceURI===_l?D==="math"&&Hy[ce]:!!zy[D]:E.namespaceURI===Ln?A.namespaceURI===_l&&!Hy[ce]||A.namespaceURI===Nl&&!Fy[ce]?!1:!zy[D]&&(Rk[D]||!Uy[D]):!!(xs==="application/xhtml+xml"&&Af[E.namespaceURI]):!1},io=function(E){fl(t.removed,{element:E});try{E.parentNode.removeChild(E)}catch{E.remove()}},If=function(E,A){try{fl(t.removed,{attribute:A.getAttributeNode(E),from:A})}catch{fl(t.removed,{attribute:null,from:A})}if(A.removeAttribute(E),E==="is"&&!he[E])if(At||Ol)try{io(A)}catch{}else try{A.setAttribute(E,"")}catch{}},By=function(E){let A=null,D=null;if(it)E="<remove></remove>"+E;else{let Be=tN(E,/^[\r\n\t ]+/);D=Be&&Be[0]}xs==="application/xhtml+xml"&&Jo===Ln&&(E='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+E+"</body></html>");let ce=S?S.createHTML(E):E;if(Jo===Ln)try{A=new d().parseFromString(ce,xs)}catch{}if(!A||!A.documentElement){A=T.createDocument(Jo,"template",null);try{A.documentElement.innerHTML=Rf?w:ce}catch{}}let ze=A.body||A.documentElement;return E&&D&&ze.insertBefore(n.createTextNode(D),ze.childNodes[0]||null),Jo===Ln?I.call(A,Gt?"html":"body")[0]:Gt?A.documentElement:ze},jy=function(E){return b.call(E.ownerDocument||E,E,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null)},Lk=function(E){return E instanceof p&&(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")},Vy=function(E){return typeof a=="function"&&E instanceof a},In=function(E,A,D){M[E]&&df(M[E],ce=>{ce.call(t,A,D,ei)})},Ky=function(E){let A=null;if(In("beforeSanitizeElements",E,null),Lk(E))return io(E),!0;let D=Oe(E.nodeName);if(In("uponSanitizeElement",E,{tagName:D,allowedTags:Y}),E.hasChildNodes()&&!Vy(E.firstElementChild)&&Tt(/<[/\w]/g,E.innerHTML)&&Tt(/<[/\w]/g,E.textContent))return io(E),!0;if(!Y[D]||mr[D]){if(!mr[D]&&$y(D)&&(q.tagNameCheck instanceof RegExp&&Tt(q.tagNameCheck,D)||q.tagNameCheck instanceof Function&&q.tagNameCheck(D)))return!1;if(kf&&!Zo[D]){let ce=h(E)||E.parentNode,ze=f(E)||E.childNodes;if(ze&&ce){let Be=ze.length;for(let st=Be-1;st>=0;--st)ce.insertBefore(y(ze[st],!0),g(E))}}return io(E),!0}return E instanceof l&&!Ak(E)||(D==="noscript"||D==="noembed"||D==="noframes")&&Tt(/<\/no(script|embed|frames)/i,E.innerHTML)?(io(E),!0):(qt&&E.nodeType===3&&(A=E.textContent,df([W,X,ne],ce=>{A=pl(A,ce," ")}),E.textContent!==A&&(fl(t.removed,{element:E.cloneNode()}),E.textContent=A)),In("afterSanitizeElements",E,null),!1)},Wy=function(E,A,D){if(Ly&&(A==="id"||A==="name")&&(D in n||D in Pk))return!1;if(!(oo&&!Al[A]&&Tt(cr,A))){if(!(Yo&&Tt(Pt,A))){if(!he[A]||Al[A]){if(!($y(E)&&(q.tagNameCheck instanceof RegExp&&Tt(q.tagNameCheck,E)||q.tagNameCheck instanceof Function&&q.tagNameCheck(E))&&(q.attributeNameCheck instanceof RegExp&&Tt(q.attributeNameCheck,A)||q.attributeNameCheck instanceof Function&&q.attributeNameCheck(A))||A==="is"&&q.allowCustomizedBuiltInElements&&(q.tagNameCheck instanceof RegExp&&Tt(q.tagNameCheck,D)||q.tagNameCheck instanceof Function&&q.tagNameCheck(D))))return!1}else if(!Pf[A]){if(!Tt(H,pl(D,Rt,""))){if(!((A==="src"||A==="xlink:href"||A==="href")&&E!=="script"&&nN(D,"data:")===0&&My[E])){if(!(vs&&!Tt(dr,pl(D,Rt,"")))){if(D)return!1}}}}}}return!0},$y=function(E){return E!=="annotation-xml"&&E.indexOf("-")>0},qy=function(E){In("beforeSanitizeAttributes",E,null);let{attributes:A}=E;if(!A)return;let D={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:he},ce=A.length;for(;ce--;){let ze=A[ce],{name:Be,namespaceURI:st,value:so}=ze,ws=Oe(Be),at=Be==="value"?so:rN(so);if(D.attrName=ws,D.attrValue=at,D.keepAttr=!0,D.forceKeepAttr=void 0,In("uponSanitizeAttribute",E,D),at=D.attrValue,D.forceKeepAttr||(If(Be,E),!D.keepAttr))continue;if(!Ll&&Tt(/\/>/i,at)){If(Be,E);continue}qt&&df([W,X,ne],Xy=>{at=pl(at,Xy," ")});let Gy=Oe(E.nodeName);if(Wy(Gy,ws,at)){if(Iy&&(ws==="id"||ws==="name")&&(If(Be,E),at=Ck+at),S&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!st)switch(m.getAttributeType(Gy,ws)){case"TrustedHTML":{at=S.createHTML(at);break}case"TrustedScriptURL":{at=S.createScriptURL(at);break}}try{st?E.setAttributeNS(st,Be,at):E.setAttribute(Be,at),aT(t.removed)}catch{}}}In("afterSanitizeAttributes",E,null)},Ik=function U(E){let A=null,D=jy(E);for(In("beforeSanitizeShadowDOM",E,null);A=D.nextNode();)In("uponSanitizeShadowNode",A,null),!Ky(A)&&(A.content instanceof i&&U(A.content),qy(A));In("afterSanitizeShadowDOM",E,null)};return t.sanitize=function(U){let E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},A=null,D=null,ce=null,ze=null;if(Rf=!U,Rf&&(U="<!-->"),typeof U!="string"&&!Vy(U))if(typeof U.toString=="function"){if(U=U.toString(),typeof U!="string")throw ml("dirty is not a string, aborting")}else throw ml("toString is not a function");if(!t.isSupported)return U;if(Il||Lf(E),t.removed=[],typeof U=="string"&&(Ss=!1),Ss){if(U.nodeName){let so=Oe(U.nodeName);if(!Y[so]||mr[so])throw ml("root node is forbidden and cannot be sanitized in-place")}}else if(U instanceof a)A=By("<!---->"),D=A.ownerDocument.importNode(U,!0),D.nodeType===1&&D.nodeName==="BODY"||D.nodeName==="HTML"?A=D:A.appendChild(D);else{if(!At&&!qt&&!Gt&&U.indexOf("<")===-1)return S&&Ml?S.createHTML(U):U;if(A=By(U),!A)return At?null:Ml?w:""}A&&it&&io(A.firstChild);let Be=jy(Ss?U:A);for(;ce=Be.nextNode();)Ky(ce)||(ce.content instanceof i&&Ik(ce.content),qy(ce));if(Ss)return U;if(At){if(Ol)for(ze=k.call(A.ownerDocument);A.firstChild;)ze.appendChild(A.firstChild);else ze=A;return(he.shadowroot||he.shadowrootmode)&&(ze=O.call(r,ze,!0)),ze}let st=Gt?A.outerHTML:A.innerHTML;return Gt&&Y["!doctype"]&&A.ownerDocument&&A.ownerDocument.doctype&&A.ownerDocument.doctype.name&&Tt(hT,A.ownerDocument.doctype.name)&&(st="<!DOCTYPE "+A.ownerDocument.doctype.name+`>
|
|
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 Nh=x(C()),JO={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},RC=({className:e,color:t})=>(0,Nh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Nh.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:JO[t||"pink"]})});var AC={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var _h={};je(_h,{enUS:()=>eM,nlNL:()=>tM});var eM={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},tM={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Bo=x(C()),IC=({onLogIn:e})=>{let t=K(_h),n=z("floatingMenu"),r=z("productName"),o=$(),i=L(Je),s=P("FloatingMenu",AC);if(i===null||n===!1)return null;let a=()=>{i===!0?o(xt(!0)):e()};return(0,Bo.jsxs)("button",{className:(0,LC.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,Bo.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,Bo.jsxs)("div",{className:s.icon,children:[(0,Bo.jsx)(RC,{className:s.logo,color:"pink"}),i===!1&&(0,Bo.jsx)(PC,{className:s.lock})]})]})};var Vd=x(_());var OC=x(_());function Yr(e){(0,OC.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function jo(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}function as(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input.userCommitted;return i.start!==i.end?!1:i.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(i.end))||r&&new RegExp(r).test(o.substring(0,i.end))?!0:n===!1&&r===!1:!1}var nM={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var zd=({ui:e})=>e.overlayCollapsed;var MC=G({name:"ui",initialState:nM,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputHasFocus(e,t){e.overlayCollapsedUserOverwrite!==!0&&(t.payload===!0&&(e.overlayCollapsed=!1),e.inputHasFocus=t.payload)},setOverlayCollapsed(e,t){t.payload.collapse===!1&&(e.openOverlayWhenTyping=!1),!(t.payload.skipWhenInputFocus&&e.inputHasFocus)&&(e.overlayCollapsed=t.payload.collapse)},setOpenOverlayWhenTyping(e,t){e.openOverlayWhenTyping=t.payload},setOverlayCollapsedUserOverwrite(e,t){e.overlayCollapsedUserOverwrite=t.payload,e.overlayCollapsed=t.payload}}}),{setShowTabHint:il,setInputHasFocus:Dh,setOverlayCollapsed:Qr,setOpenOverlayWhenTyping:NC,setOverlayCollapsedUserOverwrite:_C}=MC.actions,DC=MC.reducer;var Bd=x(_());var ls=x(_());var FC=x(_());function HC(e,t,n){(0,FC.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var UC={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var Vo=x(C()),oM=["search","personal-collection-search","search-autocomplete"];function iM(e,t,n,r={}){let o="";return oM.includes(t)?o=CE(Sh(e,n,{stripAgentPart:!0}),r.searchKeywords??[n]):o=Sh(e,n,r),r.placeholders===!0&&(o=bE(o)),o}var sM=()=>{},aM=({index:e,selected:t,suggestion:n})=>{let r=z("inlineSuggestions"),o=L(Xi),i=z("enableSuggestionFeedback"),s=L(p=>p.input.text),a=$(),l=P("TextSuggestion",UC),u=(0,ls.useRef)(null);(0,ls.useEffect)(()=>{let p=setTimeout(()=>{a(w1({text:n.text,suggestion:n}))},500);return()=>{clearTimeout(p)}},[n]),HC(u,"click",()=>{a(Wr(e)),a(Cn({suggestion:n,text:n.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,ls.useMemo)(()=>iM(n.text,n.source,o,{stripAgentPart:r,placeholders:!0,searchKeywords:n.searchKeywords}),[r,n.text,n.source,o,n.searchKeywords]);return n.source==="gpt"&&!r?null:(0,Vo.jsxs)("div",{className:l.root,onMouseEnter:()=>a(Wr(e)),children:[(0,Vo.jsx)(ee,{ref:u,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:sM,children:(0,Vo.jsx)(Qi,{containerTagName:"div",noWrap:!1,tagName:"span",className:l.formattedText,content:c})}),t&&i&&(0,Vo.jsx)("div",{className:l.actions,children:(0,Vo.jsx)(Hd,{source:"overlay",context:s,suggestion:n})})]})},zC=aM;var Fh=x(C()),lM=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,Bd.useMemo)(()=>{let o=e.map((i,s)=>(0,Fh.jsx)(zC,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,Fh.jsx)(Bd.Fragment,{children:r})},jd=lM;var BC={root:"dd-PfvRI",paper:"dd-HYlyY"};var sl=x(C()),uM=({textSuggestions:e,selectedIndex:t})=>{let n=(0,Vd.useRef)(null),r=P("InlineSuggestionsOverlay",BC),o=L(as),i=$(),s=L(Je),a=L(Gi),l=L(zd),u=z("showTextSuggestions");return Yr(()=>{setTimeout(()=>{i(Qr({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Vd.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let p=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,sl.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,sl.jsx)("div",{ref:n,className:r.paper,children:(0,sl.jsx)(ct,{children:(0,sl.jsx)(jd,{suggestions:e,selectedIndex:t})})})})},cM=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),jC=jn(cM)(uM);var al=x(C()),dM=({children:e})=>{let n=z("locale").replace("-","");return(0,al.jsx)(oh.Provider,{value:n,children:e})},fM=({store:e,customStyles:t={},children:n})=>(0,al.jsx)(Fg,{store:e,children:(0,al.jsx)(dM,{children:(0,al.jsx)(Cs.Provider,{value:t,children:n})})}),Ko=fM;var Wd=x(te()),us=x(_());var VC=x(_());function KC(e,t){let[n,r]=(0,VC.useState)(()=>{if(typeof window>"u")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return F.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window<"u"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){F.error(s)}}]}var WC=()=>/Mac/i.test(navigator.platform);var qC=x(te()),tr=x(_());var Hh={};je(Hh,{enUS:()=>pM,nlNL:()=>mM});var pM={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"}]}]},mM={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 $C={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var Zr=x(C()),Uh=(e,t,n)=>r=>(0,Zr.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),gM=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=K(Hh),s=Bt(),a=P("Login",$C),l=z("productName"),u=(0,tr.useCallback)(g=>{g.preventDefault(),r&&r(parseInt(g.target.value,10))},[]),c=(0,tr.useCallback)(g=>{g.preventDefault(),s.send(Yi,!0)},[t]),p=(0,tr.useMemo)(()=>g=>(0,Zr.jsx)("a",{onClick:h=>{h.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[t]),d=(0,tr.useCallback)(g=>(0,Zr.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:m,hour:v,day:y}=(0,tr.useMemo)(()=>({min:Uh(a,60*10,u),hour:Uh(a,60*60,u),day:Uh(a,60*60*12,u)}),[]);return(0,Zr.jsxs)("div",{className:(0,qC.default)(e,a.root),children:[i("loginPlease",{login:n?d:p,productName:l}),r&&(0,Zr.jsxs)(tr.Fragment,{children:[(0,Zr.jsx)("br",{}),i("snooze",{min:m,hour:v,day:y})]})]})},Kd=gM;var GC={root:"dd-DoQhb",text:"dd-Jwnev"};var ll=x(C()),hM=({title:e})=>{let t=P("SearchTrigger",GC),n=$();return(0,ll.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(xt(!0)),children:[(0,ll.jsx)(es,{}),(0,ll.jsx)("span",{className:t.text,children:e})]})},XC=hM;var zh={};je(zh,{enUS:()=>yM,nlNL:()=>vM});var yM={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"}]},vM={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 YC={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 Se=x(C()),SM=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=P("SuggestionsOverlay",YC),o=K(zh),i=L(as),s=y1(),a=$(),l=(0,us.useRef)(null),u=z("searchTriggerKey"),c=z("productName"),p=L(zd),d=L(Je),m=L(Gi),[v,y]=(0,us.useState)(null),g=z("showSearch"),f=z("showTextSuggestions"),h=z("adminUrl"),S=z("isEmbedded"),[w,T]=KC("dd-snooze-until-ms",0),b=p||w>Date.now(),k=e.filter(M=>M.source!=="gpt").length,I=()=>{b&&T(0),a(_C(!b))},O=M=>{let W=Date.now()+M*1e3;T(W),F.info(`Snooze until: ${new Date(W)}`),a(Qr({collapse:!0}))};return(0,us.useEffect)(()=>{k===0&&y(null)},[e,k]),Yr(()=>{a(Qr({collapse:!0,skipWhenInputFocus:!0}))}),d===null||m===!1?null:d===!1?(0,Se.jsxs)("div",{ref:l,className:(0,Wd.default)(r.root,{[r.isCollapsed]:b}),children:[!b&&(0,Se.jsxs)("div",{className:r.triggers,children:[(0,Se.jsx)("div",{style:{flex:1}}),(0,Se.jsx)("div",{className:r.triggersRight,children:(0,Se.jsx)(uo,{className:r.toggleButton,title:o("collapse"),onClick:I,isCollapsed:!1})})]}),(0,Se.jsx)("div",{className:r.toggleButtonWrapper,children:(0,Se.jsx)(uo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:I,isCollapsed:!0})}),(0,Se.jsx)("div",{className:r.collapsible,children:(0,Se.jsx)(Kd,{loginUrl:h,isEmbedded:S,onLogIn:n,onSnooze:O})})]}):!s||!i?null:(0,Se.jsxs)("div",{ref:l,className:(0,Wd.default)(r.root,{[r.isCollapsed]:b}),children:[!b&&(0,Se.jsxs)("div",{className:r.triggers,children:[(0,Se.jsx)("div",{style:{flex:1},children:g&&(0,Se.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>y(o(WC()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>y(null),children:(0,Se.jsx)(XC,{title:o("search")})})}),(0,Se.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,Se.jsx)("div",{className:(0,Wd.default)(!v&&r.hintsHidden,r.hints),children:v}),(0,Se.jsx)(uo,{className:r.toggleButton,title:o("collapse"),onClick:I,isCollapsed:!1})]})]}),(0,Se.jsx)("div",{className:r.toggleButtonWrapper,children:(0,Se.jsx)(uo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:I,isCollapsed:!0})}),k>0&&f&&(0,Se.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,Se.jsx)(ct,{children:(0,Se.jsx)(jd,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},xM=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),QC=jn(xM)(SM);var af=x(te());var ir=x(_());var cs=x(_());function $d(e){return e.contentEditable==="true"}function wM(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 ZC(e){let{selectionStart:t,selectionEnd:n}=$d(e)?wM(e):e;return[t,n]}function JC(e){let[,t]=(0,cs.useState)(),n=(0,cs.useRef)(null);return n.current=ZC(e),(0,cs.useEffect)(()=>{let r=()=>{let[o,i]=n.current??[],s=ZC(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 eb(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(Xl);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 tb=x(_()),EM=["div","span","mark","strong","b","i","u","em"];function Bh(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(EM.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,tb.cloneElement)(r,{children:Bh(s,t,n+1)})]}return[...e,...t]}function Jr(e){return e.tagName.toLowerCase()==="textarea"}var nb={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 fb=x(te());var tf=x(_());var ds=x(_());function rb(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function qd(e){let t=(0,ds.useRef)(null),[n,r]=(0,ds.useState)(!1);return(0,ds.useEffect)(()=>{let o=!1,i=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[s,a]=rb((c,p)=>{let d=t.current;if(!d)return;let m=c/i,v=p/i,y=d.getBoundingClientRect(),g=m>y.x&&m<y.x+y.width&&v>y.y&&v<y.y+y.height;g&&!o?(o=!0,r(!0)):!g&&o&&(o=!1,r(!1))},({clientX:c,clientY:p})=>[c,p]),[l,u]=rb(()=>{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 ob(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Gd(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function ib(e){return e!=null}var Vh=x(te()),Vt=x(_());var Xd=x(_()),CM=["bottom","height","left","right","top","width"],bM=(e={},t={})=>CM.some(n=>e[n]!==t[n]),nr=new Map,sb,ab=()=>{let e=[],t=[];nr.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();bM(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{nr.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),sb=window.requestAnimationFrame(ab)};function TM(e,t){return{observe(){let n=nr.size===0;if(nr.has(e)){let r=nr.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else nr.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&ab()},unobserve(){let n=nr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||nr.delete(e),nr.size||cancelAnimationFrame(sb)}}}}function jh(e){let[t,n]=(0,Xd.useState)(null);return(0,Xd.useLayoutEffect)(()=>{if(!e.current)return;let r=TM(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var fs=x(_()),ub=x(uc());var lb={root:"dd-r-dgo"};var cb=({children:e,parentNode:t})=>{let[n,r]=(0,fs.useState)(null),o=(0,fs.useContext)(Cs);return(0,fs.useLayoutEffect)(()=>{let i=document.createElement("div");return jo(i),i.classList.add(lb.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,ub.createPortal)(e,n):null};var Tn={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 Yd=x(C()),Qd=(e=!1)=>{let[t,n]=(0,Vt.useState)(e),r=(0,Vt.useCallback)(()=>n(!0),[]),o=(0,Vt.useCallback)(()=>n(!1),[]),i=(0,Vt.useCallback)(()=>n(a=>!a),[]),s=(0,Vt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function Kh(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 ps=({className:e,triggerRef:t,boundaryRef:n=(0,Vt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=Kh,parentNode:a,...l})=>{let u=jh(t),c=jh(n),p=(0,Vt.useMemo)(()=>s(u,c,0),[u,c]);return(0,Yd.jsx)(cb,{parentNode:a,children:(0,Yd.jsx)("div",{className:(0,Vh.default)(Tn.ref,{[Tn.positionAbove]:r==="above",[Tn.positionBelow]:r==="below",[Tn.positionLeft]:r==="left",[Tn.positionRight]:r==="right",[Tn.alignStart]:o==="start",[Tn.alignCenter]:o==="center",[Tn.alignEnd]:o==="end"}),style:p,...l,role:"dialog",children:(0,Yd.jsx)("div",{className:(0,Vh.default)(e,Tn.root),children:i})})})};var db=x(te()),Zd=x(_());var rr={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 Wh=x(C()),Jd=(0,Zd.forwardRef)(({className:e,children:t,...n},r)=>{let o=(0,Zd.useRef)(null),i=P("TabCompletion",rr);return(0,Wh.jsx)("div",{ref:Gd([o,r]),className:(0,db.default)(e,i.popoverContentContainer),...n,children:(0,Wh.jsx)("div",{className:i.popoverContent,children:t})})});var eo=x(C()),kM=e=>t=>{let n=Kh(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},PM=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=P("TabCompletion",rr),s=Qd(),a=(0,tf.useMemo)(()=>kM(e.getBoundingClientRect()),[e]),[l,u]=qd(e);return(0,tf.useEffect)(()=>{u?s.open():s.close()},[u]),(0,eo.jsxs)("span",{children:[(0,eo.jsx)("mark",{ref:Gd([l,s.triggerRef]),className:(0,fb.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,eo.jsx)(ps,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,eo.jsx)(Jd,{style:n,children:(0,eo.jsx)("div",{className:i.hintText,children:o})})})]})},ef=class extends Gn{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(t,n){return n.keywordMatches&&n.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=n.keywordMatches.map(r=>({...r,keywordRegex:new RegExp(`\\b${ob(r.keyword)}\\b`,"i")})),this.keywordMatches=n.keywordMatches),this.usedKeywordMatches.clear(),t}match(t){let n=this.preparedKeywordMatches.map(o=>{if(this.usedKeywordMatches.has(o))return null;let i=t.match(o.keywordRegex);if(!i)return null;let s=t.charAt(i.index-1),a=t.charAt(i.index+o.keyword.length);return s==="{"&&a==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:o.suggestion,preparedKeywordMatch:o,valid:!0}}).filter(ib);if(n.length===0)return null;let r=n.reduce((o,i)=>i.index<o.index?i:o);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(t,n){return(0,eo.jsx)(PM,{inputElement:n.inputElement,suggestion:n.suggestion,inputStyle:n.inputStyle,boundaryRef:n.boundaryRef,children:t},`keyword_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var pb=x(te());var $h=x(C()),RM=({inputElement:e,children:t})=>{let n=P("TabCompletion",rr),[r,o]=qd(e);return(0,$h.jsx)("mark",{ref:r,className:(0,pb.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},nf=class extends Gn{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,$h.jsx)(RM,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var of=x(te());var rt=x(_());var qh=x(C()),mb=()=>(0,qh.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,qh.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 to=x(_());var hb=x(uh());var gb={root:"dd-ky-Bv",content:"dd-kV5e1"};function rf(e,t,n){var o;let r=((o=e.imageSizes)==null?void 0:o[t])||e.image||n;if(!r)return null;try{return new URL(r).toString()}catch{return null}}function Gh(e){return e.replace("https://www.","").replace("https://","")}var Kt=x(C()),AM=3,LM=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),IM=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=AM})=>{let i=P("LinkSearch",gb),[s,a]=(0,to.useState)(""),l=$(),u=L(fC("url")),c=L(z1("URL",LM)),[p,d]=(0,to.useState)(c.length-1),m=z("fallbackImage"),v=h=>{let S=h.target;a(S.value)},y=(h,S)=>{h.stopPropagation(),h.preventDefault(),window.open(S,"_blank")},g=h=>{var T;let S=p-1<0?c.length-1:p-1,w=p+1===c.length?0:p+1;h.code==="Escape"&&(a(""),t()),h.code==="ArrowUp"&&d(S),h.code==="ArrowDown"&&d(w),h.code==="Enter"&&e(((T=c[p])==null?void 0:T.text)||s)},f=(0,to.useCallback)((0,hb.default)(h=>{l(Ao({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,to.useEffect)(()=>{s&&f(s)},[s]),(0,to.useEffect)(()=>()=>{l(rd())},[]),(0,Kt.jsxs)("div",{className:i.root,children:[(0,Kt.jsx)(ct,{withDivider:!0,children:(s?c:u).slice(0,o).map((h,S)=>(0,Kt.jsx)(ee,{selected:p===S,onClick:()=>e(h.text),"data-testid":"linksearch-suggestion",children:(0,Kt.jsxs)(pe,{children:[(0,Kt.jsx)(pe.Image,{src:rf(h,"small",m||void 0),title:h.title||h.text}),(0,Kt.jsxs)(pe.Content,{className:i.content,cropText:!0,children:[(0,Kt.jsx)(pe.Title,{children:h.title||Gh(h.text)}),h.title&&Gh(h.text)]}),(0,Kt.jsx)(ee.Actions,{children:(0,Kt.jsx)(ee.ActionButton,{label:r,onClick:w=>y(w,h.text)})})]})},h.text))}),(0,Kt.jsx)(ja,{value:s,onChange:v,autoFocus:!0,placeholder:n,onKeyUp:g})]})},yb=IM;var Xh={};je(Xh,{enUS:()=>OM,nlNL:()=>MM});var OM={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},MM={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var nt=x(C()),NM=(0,rt.forwardRef)((e,t)=>{let n=P("TabCompletion",rr);return(0,nt.jsx)("mark",{ref:t,className:(0,of.default)(n.matchSelection)},"selection-start")}),_M=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=K(Xh),s=P("TabCompletion",rr),a=(0,rt.useRef)(null),l=(0,rt.useRef)(null),[u,c]=(0,rt.useState)(null),p=$(),d=Qd(document.activeElement===r),[m]=(0,rt.useState)(()=>document.createRange());d.triggerRef.current=m,(0,rt.useEffect)(()=>()=>m.detach(),[]),(0,rt.useEffect)(()=>{let y=e.current,g=a.current;!y||!g||(m.setStart(y,0),m.setEnd(g,0))},[e.current,a.current]),Yr(()=>{d.close()});let v=(0,rt.useCallback)(y=>{let g=m.toString(),f=/^http(s?):\/\//.test(y)?y:`https://${y}`;p(Zc({text:`[${g}](${f})`,replace:"selection"}))},[]);return(0,nt.jsxs)("span",{children:[(0,nt.jsx)("mark",{ref:a,className:(0,of.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,nt.jsx)(ps,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,nt.jsxs)(Jd,{style:n,ref:l,children:[(0,nt.jsx)("div",{className:(0,of.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,nt.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,nt.jsx)(mb,{}),(0,nt.jsx)("span",{children:"\xA0"}),(0,nt.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,nt.jsx)(yb,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:v,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},sf=class extends Gn{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(t,n){return this.props=n,this.charCount=0,this.startRef=(0,rt.createRef)(),this.foundIndex=0,t}match(t){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[n,r]=this.props.selection;if(n===r)return null;let o=this.foundIndex===0?n:r,i=o>=this.charCount&&o<=this.charCount+t.length?{index:o-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let s=this.foundIndex===1;return i&&s?this.charCount+=o-this.charCount:this.charCount+=t.length,i?{isStart:s,...i}:null}replaceWith(t,n){return n.isStart?(0,nt.jsx)(NM,{ref:this.startRef}):(0,nt.jsx)(_M,{inputElement:n.inputElement,startRef:this.startRef,boundaryRef:n.boundaryRef,inputStyle:n.inputStyle})}asTag(){return"mark"}};var or=x(C()),DM=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=P("TabCompletion",nb),c=z("insertLink"),p=z("showMidSentenceSuggestions"),d=z("inlineSuggestions"),m=JC(a),v=(0,ir.useRef)(null),y=L(Je);(0,ir.useEffect)(()=>{Jr(a)&&m&&eb(a,m)},[m]);let g=(0,ir.useCallback)(S=>{if(!o||!n)return S;let w=[(0,or.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,or.jsx)("span",{"data-testid":"tab-completion",className:(0,af.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&w.push((0,or.jsx)("span",{className:(0,af.default)(u.hint,u.resetIndent),children:(0,or.jsx)(Wl,{keyCode:"tab"},"tabHint")})),Bh(S,w)},[o,n,r]),f=(0,ir.useMemo)(()=>{let S=[];return c&&S.push(new sf("selection")),S.push(new nf("placeholders")),i&&S.push(new ef("keywords")),S},[d,c,i]),h=(0,ir.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,or.jsxs)("div",{ref:S=>{S!=null&&S.parentElement&&(v.current=S==null?void 0:S.parentElement)},className:u.root,style:h,children:[(0,or.jsx)(Qi,{tagName:"span",containerTagName:"div",className:(0,af.default)(u.container,u.agentText),disableLineBreaks:Jr(a),content:t||"\u200B",onAfterParse:g,matchers:f,selection:m,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:v,inlineSuggestionsOnlyAtEnd:!p}),(0,or.jsx)("br",{})]})},FM=({input:e,ui:t,settings:n,styleSuggestions:r,conversation:o})=>{var y;let{tabCompletionSuggestion:i}=e,s=(i==null?void 0:i.text)||"",a=(i==null?void 0:i.source)||"",l=e.html??Zi(e.text),u=s.indexOf(e.text)===0?s.slice(e.text.length):"",{showTabHint:c}=t,{isSupported:p}=o,{showTabCompletion:d,visible:m,showStyleSuggestions:v}=n;return{showTabHint:c,showStyleSuggestions:v,showTabCompletion:d,content:l,tabText:u,source:a,keywordMatches:((y=r.list)==null?void 0:y.keywordMatches)??[],enabled:m&&p!==!1}},vb=jn(FM)(DM);var MT=x(te()),wl=x(_());var Sb={list:[],fetchState:"idle"},wb=e=>e.autoflows.list||[],xb=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},sr=B("autoflows/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)}),Yh=B("autoflows/start",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.startAutoflowSession(e),await n(sr(e.platformSessionId))}),Qh=B("autoflows/stop",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.stopAutoflowSession(e.platformSessionId),await n(sr(e.platformSessionId))}),HM=G({name:"autoflows",initialState:Sb,reducers:{},extraReducers:e=>{e.addCase(Yh.pending,(t,n)=>{let r=xb(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(Qh.pending,(t,n)=>{let r=xb(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(sr.pending,t=>{t.fetchState="loading"}),e.addCase(sr.rejected,t=>{t.fetchState="error"}),e.addCase(sr.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(le,()=>Sb)}}),Eb=B("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(sr(e))}),o.on("sessionCompleted",()=>{n(sr(e))})}),Cb=B("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),bb=HM.reducer;var Tb={list:[],fetchState:"idle",sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},kb=e=>e.customMessages.list,Pb=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),Rb=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),Ab=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),ul=B("customMessages/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)}),lf=B("customMessages/send",async(e,t)=>{let{platformSessionId:n,suggestion:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.sendCustomMessage(n,r)}),uf=B("customMessages/answer",async(e,t)=>{let{platformSessionId:n,reply:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.answerCustomMessage(n,r)}),Lb=G({name:"customMessages",initialState:Tb,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(ul.pending,t=>{t.fetchState="loading"}).addCase(ul.rejected,t=>{t.fetchState="error"}).addCase(ul.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(lf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(lf.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(uf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(uf.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(le,()=>Tb)}}),Ib=B("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(Lb.actions.onCustomMessage(i))})}),Ob=B("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),Mb=Lb.reducer;var UM={token:null,interval:null},Zh=B("passwordlessToken/getTemporaryPasswordlessToken",async(e,t)=>{let{deepdeskAPI:n}=t.extra;return{token:await n.requestPasswordlessToken()}}),Jh=B("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(Zh()),setInterval(()=>r(Zh()),n)}),Nb=G({name:"passwordlessToken",initialState:UM,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(Zh.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(Jh.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:_b}=Nb.actions,Db=Nb.reducer;var Fb={shouldEmit:!0},ey={cues:[],fetchState:"idle"},Hb=e=>{var t;return(t=e.rules)==null?void 0:t.cues},zM=xe("rules/resetCues"),Wo=B("rules/evaluate",async(e,t)=>{var n,r;try{let{deepdeskAPI:o}=t.extra,i=t.getState(),s=(n=i.conversation.current)==null?void 0:n.id;if(!s)throw new Error("No current conversation to evaluate rules");if(!(await o.getAccount()).ruleEngine)throw new Error("Rule engine is not enabled for this account");if(!(await o.getRules()).filter(p=>p.isEnabled).some(p=>p.label===e.label))throw new Error(`No enabled rules found with label: ${e.label}`);return{cues:await o.evaluateRule(e.label,s,{tags:((r=i.conversation.current)==null?void 0:r.tags)||void 0,...e.params}),options:e.options}}catch(o){let i=o.message;return F.warn(i),t.rejectWithValue(i)}}),Ub=G({name:"answer",initialState:ey,reducers:{removeCue(e,t){e.cues=e.cues.filter(n=>n.rule.id!==t.payload.id)}},extraReducers:e=>{e.addCase(Wo.pending,t=>{t.fetchState="loading"}).addCase(Wo.rejected,t=>{t.fetchState="error"}).addCase(Wo.fulfilled,(t,n)=>{let r=n.payload.cues.map(i=>i.rule.id),o=t.cues.filter(i=>!r.includes(i.rule.id));t.fetchState="done",t.cues=[...n.payload.cues,...o]}).addCase(le,()=>ey).addCase(zM.toString(),()=>ey)}}),{removeCue:zb}=Ub.actions,Bb=Ub.reducer;var Yb=x(_());var qb=x(te()),Gb=x(_());var Vb=x(te());var jb={root:"dd-uszkm"};var Wb=x(C()),BM=({className:e,children:t})=>{let n=P("Unicode",jb);return(0,Wb.jsx)("span",{className:(0,Vb.default)(e,n.root),children:t})},Kb=BM;var $b={isDisabled:"dd-Sp--t",root:"dd-maqTG",buttonStop:"dd-rcq8w",stateBadge:"dd-zOnkT",isCompleted:"dd-GA-rt",isStarted:"dd-PZwtX",isAborted:"dd-PAXSE"};var ty={};je(ty,{enUS:()=>jM,nlNL:()=>VM});var jM={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"}]},VM={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 bt=x(C()),WM=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=P("Autoflow",$b),a=K(ty),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,bt.jsxs)(ee,{className:(0,qb.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,bt.jsx)(pe,{children:(0,bt.jsxs)(pe.Content,{children:[(0,bt.jsxs)(pe.Title,{children:[t&&(0,bt.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,bt.jsx)("span",{children:r})]})}),(0,bt.jsx)(ee.Actions,{fixed:t==="Started",children:(0,bt.jsx)(ee.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,bt.jsxs)(Gb.Fragment,{children:[(0,bt.jsx)(Kb,{children:u})," ",(0,bt.jsx)("span",{children:a(l)})]})})})]})},Xb=WM;var ny=x(C()),$M=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},qM=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,ny.jsx)(Yb.Fragment,{children:e.map(o=>(0,ny.jsx)(Xb,{displayName:o.displayName,description:o.description,disabled:o.isBusy||$M(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),GM=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},XM={onStartAutoflow:Yh,onStopAutoflow:Qh},Qb=jn(GM,XM)(qM);var Zb=x(te()),ry=x(_());var ar={root:"dd-ERsBr",title:"dd-b36p6",isUsed:"dd-fp2IX",quickReplies:"dd--VrvP",quickReply:"dd-wFhWh",label:"dd-R9sND",errorIcon:"dd-8cdcH"};var gt=x(C()),YM=({suggestion:e})=>{let t=K(zo),n=$(),r=L(Pb(e.text)),o=L(Rb(e.text)),i=L(Ab(e.text)),s=L(qi),{replyOptions:a}=e,l=(0,ry.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(lf({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,ry.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let p=parseInt(c.target.dataset.index,10),d=a[p];n(uf({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,gt.jsxs)(ee,{onClick:l,className:(0,Zb.default)(ar.root,{[ar.isUsed]:r,[ar.hasError]:i}),children:[(0,gt.jsx)(pe,{children:(0,gt.jsxs)(pe.Content,{children:[(0,gt.jsxs)(pe.Title,{className:ar.title,children:[e.text," ",(0,gt.jsx)($l,{className:ar.label,children:"analyse tool"})," ",i&&(0,gt.jsx)("span",{className:ar.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,gt.jsx)("ul",{className:ar.quickReplies,children:a.map(c=>(0,gt.jsx)("li",{className:ar.quickReply,children:c.title},c.title))})]})}),(0,gt.jsxs)(ee.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,gt.jsx)(ee.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,p)=>(0,gt.jsx)(ee.DropdownItem,{index:p,label:c.title,onClick:u},c.title))}),(0,gt.jsx)(ee.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},Jb=YM;var cf=x(_());var iy=x(te());var oy=x(C()),cl=()=>(0,oy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,oy.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 eT={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var kn=x(C()),QM=({entities:e})=>{let t=P("EntitiesWidgetList",eT),[n,r]=(0,cf.useState)(void 0),o=$(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),$n(a.text),o(et({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,cf.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,kn.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,kn.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,kn.jsx)("span",{className:t.entityText,children:a.text}),(0,kn.jsxs)("span",{className:t.iconWrapper,children:[(0,kn.jsx)("span",{className:(0,iy.default)(t.icon),children:(0,kn.jsx)(cl,{})}),(0,kn.jsx)("span",{className:(0,iy.default)(t.icon,n===l&&t.iconClicked),children:(0,kn.jsx)(cl,{})})]})]},a.text))})},tT=QM;var sy=x(C()),nT=()=>(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 ay=x(C()),rT=()=>(0,ay.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ay.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 ly=x(C()),oT=()=>(0,ly.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ly.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 CT=x(_());var dl=x(C()),iT=({className:e})=>(0,dl.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:e,children:[(0,dl.jsx)("line",{x1:"2",y1:"10",x2:"10",y2:"2",stroke:"black",strokeWidth:"1"}),(0,dl.jsx)("line",{x1:"2",y1:"2",x2:"10",y2:"10",stroke:"black",strokeWidth:"1"})]});var{entries:pT,setPrototypeOf:sT,isFrozen:ZM,getPrototypeOf:JM,getOwnPropertyDescriptor:eN}=Object,{freeze:ot,seal:un,create:mT}=Object,{apply:my,construct:gy}=typeof Reflect<"u"&&Reflect;ot||(ot=function(t){return t});un||(un=function(t){return t});my||(my=function(t,n,r){return t.apply(n,r)});gy||(gy=function(t,n){return new t(...n)});var df=kt(Array.prototype.forEach),aT=kt(Array.prototype.pop),fl=kt(Array.prototype.push),mf=kt(String.prototype.toLowerCase),uy=kt(String.prototype.toString),tN=kt(String.prototype.match),pl=kt(String.prototype.replace),nN=kt(String.prototype.indexOf),rN=kt(String.prototype.trim),ln=kt(Object.prototype.hasOwnProperty),Tt=kt(RegExp.prototype.test),ml=oN(TypeError);function kt(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 my(e,t,r)}}function oN(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return gy(e,n)}}function Q(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mf;sT&&sT(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let i=n(o);i!==o&&(ZM(t)||(t[r]=i),o=i)}e[o]=!0}return e}function iN(e){for(let t=0;t<e.length;t++)ln(e,t)||(e[t]=null);return e}function $o(e){let t=mT(null);for(let[n,r]of pT(e))ln(e,n)&&(Array.isArray(r)?t[n]=iN(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=$o(r):t[n]=r);return t}function ff(e,t){for(;e!==null;){let r=eN(e,t);if(r){if(r.get)return kt(r.get);if(typeof r.value=="function")return kt(r.value)}e=JM(e)}function n(){return null}return n}var lT=ot(["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"]),cy=ot(["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"]),dy=ot(["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"]),sN=ot(["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"]),fy=ot(["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"]),aN=ot(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),uT=ot(["#text"]),cT=ot(["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","xmlns","slot"]),py=ot(["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"]),dT=ot(["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"]),pf=ot(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),lN=un(/\{\{[\w\W]*|[\w\W]*\}\}/gm),uN=un(/<%[\w\W]*|[\w\W]*%>/gm),cN=un(/\${[\w\W]*}/gm),dN=un(/^data-[\-\w.\u00B7-\uFFFF]/),fN=un(/^aria-[\-\w]+$/),gT=un(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),pN=un(/^(?:\w+script|data):/i),mN=un(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),hT=un(/^html$/i),fT=Object.freeze({__proto__:null,MUSTACHE_EXPR:lN,ERB_EXPR:uN,TMPLIT_EXPR:cN,DATA_ATTR:dN,ARIA_ATTR:fN,IS_ALLOWED_URI:gT,IS_SCRIPT_OR_DATA:pN,ATTR_WHITESPACE:mN,DOCTYPE_NAME:hT}),gN=function(){return typeof window>"u"?null:window},hN=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{return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function yT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gN(),t=U=>yT(U);if(t.version="3.0.9",t.removed=[],!e||!e.document||e.document.nodeType!==9)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:p,DOMParser:d,trustedTypes:m}=e,v=l.prototype,y=ff(v,"cloneNode"),g=ff(v,"nextSibling"),f=ff(v,"childNodes"),h=ff(v,"parentNode");if(typeof s=="function"){let U=n.createElement("template");U.content&&U.content.ownerDocument&&(n=U.content.ownerDocument)}let S,w="",{implementation:T,createNodeIterator:b,createDocumentFragment:k,getElementsByTagName:I}=n,{importNode:O}=r,M={};t.isSupported=typeof pT=="function"&&typeof h=="function"&&T&&T.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:W,ERB_EXPR:X,TMPLIT_EXPR:ne,DATA_ATTR:cr,ARIA_ATTR:Pt,IS_SCRIPT_OR_DATA:dr,ATTR_WHITESPACE:Rt}=fT,{IS_ALLOWED_URI:H}=fT,Y=null,fr=Q({},[...lT,...cy,...dy,...fy,...uT]),he=null,pr=Q({},[...cT,...py,...dT,...pf]),q=Object.seal(mT(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}})),mr=null,Al=null,Yo=!0,oo=!0,vs=!1,Ll=!0,qt=!1,Gt=!1,Il=!1,it=!1,At=!1,Ol=!1,Ml=!1,Ly=!0,Iy=!1,Ck="user-content-",kf=!0,Ss=!1,Qo={},Zo=null,Oy=Q({},["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"]),My=null,Ny=Q({},["audio","video","img","source","image","track"]),Pf=null,_y=Q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Nl="http://www.w3.org/1998/Math/MathML",_l="http://www.w3.org/2000/svg",Ln="http://www.w3.org/1999/xhtml",Jo=Ln,Rf=!1,Af=null,bk=Q({},[Nl,_l,Ln],uy),xs=null,Tk=["application/xhtml+xml","text/html"],kk="text/html",Oe=null,ei=null,Pk=n.createElement("form"),Dy=function(E){return E instanceof RegExp||E instanceof Function},Lf=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ei&&ei===E)){if((!E||typeof E!="object")&&(E={}),E=$o(E),xs=Tk.indexOf(E.PARSER_MEDIA_TYPE)===-1?kk:E.PARSER_MEDIA_TYPE,Oe=xs==="application/xhtml+xml"?uy:mf,Y=ln(E,"ALLOWED_TAGS")?Q({},E.ALLOWED_TAGS,Oe):fr,he=ln(E,"ALLOWED_ATTR")?Q({},E.ALLOWED_ATTR,Oe):pr,Af=ln(E,"ALLOWED_NAMESPACES")?Q({},E.ALLOWED_NAMESPACES,uy):bk,Pf=ln(E,"ADD_URI_SAFE_ATTR")?Q($o(_y),E.ADD_URI_SAFE_ATTR,Oe):_y,My=ln(E,"ADD_DATA_URI_TAGS")?Q($o(Ny),E.ADD_DATA_URI_TAGS,Oe):Ny,Zo=ln(E,"FORBID_CONTENTS")?Q({},E.FORBID_CONTENTS,Oe):Oy,mr=ln(E,"FORBID_TAGS")?Q({},E.FORBID_TAGS,Oe):{},Al=ln(E,"FORBID_ATTR")?Q({},E.FORBID_ATTR,Oe):{},Qo=ln(E,"USE_PROFILES")?E.USE_PROFILES:!1,Yo=E.ALLOW_ARIA_ATTR!==!1,oo=E.ALLOW_DATA_ATTR!==!1,vs=E.ALLOW_UNKNOWN_PROTOCOLS||!1,Ll=E.ALLOW_SELF_CLOSE_IN_ATTR!==!1,qt=E.SAFE_FOR_TEMPLATES||!1,Gt=E.WHOLE_DOCUMENT||!1,At=E.RETURN_DOM||!1,Ol=E.RETURN_DOM_FRAGMENT||!1,Ml=E.RETURN_TRUSTED_TYPE||!1,it=E.FORCE_BODY||!1,Ly=E.SANITIZE_DOM!==!1,Iy=E.SANITIZE_NAMED_PROPS||!1,kf=E.KEEP_CONTENT!==!1,Ss=E.IN_PLACE||!1,H=E.ALLOWED_URI_REGEXP||gT,Jo=E.NAMESPACE||Ln,q=E.CUSTOM_ELEMENT_HANDLING||{},E.CUSTOM_ELEMENT_HANDLING&&Dy(E.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(q.tagNameCheck=E.CUSTOM_ELEMENT_HANDLING.tagNameCheck),E.CUSTOM_ELEMENT_HANDLING&&Dy(E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(q.attributeNameCheck=E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),E.CUSTOM_ELEMENT_HANDLING&&typeof E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(q.allowCustomizedBuiltInElements=E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),qt&&(oo=!1),Ol&&(At=!0),Qo&&(Y=Q({},uT),he=[],Qo.html===!0&&(Q(Y,lT),Q(he,cT)),Qo.svg===!0&&(Q(Y,cy),Q(he,py),Q(he,pf)),Qo.svgFilters===!0&&(Q(Y,dy),Q(he,py),Q(he,pf)),Qo.mathMl===!0&&(Q(Y,fy),Q(he,dT),Q(he,pf))),E.ADD_TAGS&&(Y===fr&&(Y=$o(Y)),Q(Y,E.ADD_TAGS,Oe)),E.ADD_ATTR&&(he===pr&&(he=$o(he)),Q(he,E.ADD_ATTR,Oe)),E.ADD_URI_SAFE_ATTR&&Q(Pf,E.ADD_URI_SAFE_ATTR,Oe),E.FORBID_CONTENTS&&(Zo===Oy&&(Zo=$o(Zo)),Q(Zo,E.FORBID_CONTENTS,Oe)),kf&&(Y["#text"]=!0),Gt&&Q(Y,["html","head","body"]),Y.table&&(Q(Y,["tbody"]),delete mr.tbody),E.TRUSTED_TYPES_POLICY){if(typeof E.TRUSTED_TYPES_POLICY.createHTML!="function")throw ml('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof E.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ml('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=E.TRUSTED_TYPES_POLICY,w=S.createHTML("")}else S===void 0&&(S=hN(m,o)),S!==null&&typeof w=="string"&&(w=S.createHTML(""));ot&&ot(E),ei=E}},Fy=Q({},["mi","mo","mn","ms","mtext"]),Hy=Q({},["foreignobject","desc","title","annotation-xml"]),Rk=Q({},["title","style","font","a","script"]),Uy=Q({},[...cy,...dy,...sN]),zy=Q({},[...fy,...aN]),Ak=function(E){let A=h(E);(!A||!A.tagName)&&(A={namespaceURI:Jo,tagName:"template"});let D=mf(E.tagName),ce=mf(A.tagName);return Af[E.namespaceURI]?E.namespaceURI===_l?A.namespaceURI===Ln?D==="svg":A.namespaceURI===Nl?D==="svg"&&(ce==="annotation-xml"||Fy[ce]):!!Uy[D]:E.namespaceURI===Nl?A.namespaceURI===Ln?D==="math":A.namespaceURI===_l?D==="math"&&Hy[ce]:!!zy[D]:E.namespaceURI===Ln?A.namespaceURI===_l&&!Hy[ce]||A.namespaceURI===Nl&&!Fy[ce]?!1:!zy[D]&&(Rk[D]||!Uy[D]):!!(xs==="application/xhtml+xml"&&Af[E.namespaceURI]):!1},io=function(E){fl(t.removed,{element:E});try{E.parentNode.removeChild(E)}catch{E.remove()}},If=function(E,A){try{fl(t.removed,{attribute:A.getAttributeNode(E),from:A})}catch{fl(t.removed,{attribute:null,from:A})}if(A.removeAttribute(E),E==="is"&&!he[E])if(At||Ol)try{io(A)}catch{}else try{A.setAttribute(E,"")}catch{}},By=function(E){let A=null,D=null;if(it)E="<remove></remove>"+E;else{let Be=tN(E,/^[\r\n\t ]+/);D=Be&&Be[0]}xs==="application/xhtml+xml"&&Jo===Ln&&(E='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+E+"</body></html>");let ce=S?S.createHTML(E):E;if(Jo===Ln)try{A=new d().parseFromString(ce,xs)}catch{}if(!A||!A.documentElement){A=T.createDocument(Jo,"template",null);try{A.documentElement.innerHTML=Rf?w:ce}catch{}}let ze=A.body||A.documentElement;return E&&D&&ze.insertBefore(n.createTextNode(D),ze.childNodes[0]||null),Jo===Ln?I.call(A,Gt?"html":"body")[0]:Gt?A.documentElement:ze},jy=function(E){return b.call(E.ownerDocument||E,E,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null)},Lk=function(E){return E instanceof p&&(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")},Vy=function(E){return typeof a=="function"&&E instanceof a},In=function(E,A,D){M[E]&&df(M[E],ce=>{ce.call(t,A,D,ei)})},Ky=function(E){let A=null;if(In("beforeSanitizeElements",E,null),Lk(E))return io(E),!0;let D=Oe(E.nodeName);if(In("uponSanitizeElement",E,{tagName:D,allowedTags:Y}),E.hasChildNodes()&&!Vy(E.firstElementChild)&&Tt(/<[/\w]/g,E.innerHTML)&&Tt(/<[/\w]/g,E.textContent))return io(E),!0;if(!Y[D]||mr[D]){if(!mr[D]&&$y(D)&&(q.tagNameCheck instanceof RegExp&&Tt(q.tagNameCheck,D)||q.tagNameCheck instanceof Function&&q.tagNameCheck(D)))return!1;if(kf&&!Zo[D]){let ce=h(E)||E.parentNode,ze=f(E)||E.childNodes;if(ze&&ce){let Be=ze.length;for(let st=Be-1;st>=0;--st)ce.insertBefore(y(ze[st],!0),g(E))}}return io(E),!0}return E instanceof l&&!Ak(E)||(D==="noscript"||D==="noembed"||D==="noframes")&&Tt(/<\/no(script|embed|frames)/i,E.innerHTML)?(io(E),!0):(qt&&E.nodeType===3&&(A=E.textContent,df([W,X,ne],ce=>{A=pl(A,ce," ")}),E.textContent!==A&&(fl(t.removed,{element:E.cloneNode()}),E.textContent=A)),In("afterSanitizeElements",E,null),!1)},Wy=function(E,A,D){if(Ly&&(A==="id"||A==="name")&&(D in n||D in Pk))return!1;if(!(oo&&!Al[A]&&Tt(cr,A))){if(!(Yo&&Tt(Pt,A))){if(!he[A]||Al[A]){if(!($y(E)&&(q.tagNameCheck instanceof RegExp&&Tt(q.tagNameCheck,E)||q.tagNameCheck instanceof Function&&q.tagNameCheck(E))&&(q.attributeNameCheck instanceof RegExp&&Tt(q.attributeNameCheck,A)||q.attributeNameCheck instanceof Function&&q.attributeNameCheck(A))||A==="is"&&q.allowCustomizedBuiltInElements&&(q.tagNameCheck instanceof RegExp&&Tt(q.tagNameCheck,D)||q.tagNameCheck instanceof Function&&q.tagNameCheck(D))))return!1}else if(!Pf[A]){if(!Tt(H,pl(D,Rt,""))){if(!((A==="src"||A==="xlink:href"||A==="href")&&E!=="script"&&nN(D,"data:")===0&&My[E])){if(!(vs&&!Tt(dr,pl(D,Rt,"")))){if(D)return!1}}}}}}return!0},$y=function(E){return E!=="annotation-xml"&&E.indexOf("-")>0},qy=function(E){In("beforeSanitizeAttributes",E,null);let{attributes:A}=E;if(!A)return;let D={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:he},ce=A.length;for(;ce--;){let ze=A[ce],{name:Be,namespaceURI:st,value:so}=ze,ws=Oe(Be),at=Be==="value"?so:rN(so);if(D.attrName=ws,D.attrValue=at,D.keepAttr=!0,D.forceKeepAttr=void 0,In("uponSanitizeAttribute",E,D),at=D.attrValue,D.forceKeepAttr||(If(Be,E),!D.keepAttr))continue;if(!Ll&&Tt(/\/>/i,at)){If(Be,E);continue}qt&&df([W,X,ne],Xy=>{at=pl(at,Xy," ")});let Gy=Oe(E.nodeName);if(Wy(Gy,ws,at)){if(Iy&&(ws==="id"||ws==="name")&&(If(Be,E),at=Ck+at),S&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!st)switch(m.getAttributeType(Gy,ws)){case"TrustedHTML":{at=S.createHTML(at);break}case"TrustedScriptURL":{at=S.createScriptURL(at);break}}try{st?E.setAttributeNS(st,Be,at):E.setAttribute(Be,at),aT(t.removed)}catch{}}}In("afterSanitizeAttributes",E,null)},Ik=function U(E){let A=null,D=jy(E);for(In("beforeSanitizeShadowDOM",E,null);A=D.nextNode();)In("uponSanitizeShadowNode",A,null),!Ky(A)&&(A.content instanceof i&&U(A.content),qy(A));In("afterSanitizeShadowDOM",E,null)};return t.sanitize=function(U){let E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},A=null,D=null,ce=null,ze=null;if(Rf=!U,Rf&&(U="<!-->"),typeof U!="string"&&!Vy(U))if(typeof U.toString=="function"){if(U=U.toString(),typeof U!="string")throw ml("dirty is not a string, aborting")}else throw ml("toString is not a function");if(!t.isSupported)return U;if(Il||Lf(E),t.removed=[],typeof U=="string"&&(Ss=!1),Ss){if(U.nodeName){let so=Oe(U.nodeName);if(!Y[so]||mr[so])throw ml("root node is forbidden and cannot be sanitized in-place")}}else if(U instanceof a)A=By("<!---->"),D=A.ownerDocument.importNode(U,!0),D.nodeType===1&&D.nodeName==="BODY"||D.nodeName==="HTML"?A=D:A.appendChild(D);else{if(!At&&!qt&&!Gt&&U.indexOf("<")===-1)return S&&Ml?S.createHTML(U):U;if(A=By(U),!A)return At?null:Ml?w:""}A&&it&&io(A.firstChild);let Be=jy(Ss?U:A);for(;ce=Be.nextNode();)Ky(ce)||(ce.content instanceof i&&Ik(ce.content),qy(ce));if(Ss)return U;if(At){if(Ol)for(ze=k.call(A.ownerDocument);A.firstChild;)ze.appendChild(A.firstChild);else ze=A;return(he.shadowroot||he.shadowrootmode)&&(ze=O.call(r,ze,!0)),ze}let st=Gt?A.outerHTML:A.innerHTML;return Gt&&Y["!doctype"]&&A.ownerDocument&&A.ownerDocument.doctype&&A.ownerDocument.doctype.name&&Tt(hT,A.ownerDocument.doctype.name)&&(st="<!DOCTYPE "+A.ownerDocument.doctype.name+`>
|
|
24
24
|
`+st),qt&&df([W,X,ne],so=>{st=pl(st,so," ")}),S&&Ml?S.createHTML(st):st},t.setConfig=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Lf(U),Il=!0},t.clearConfig=function(){ei=null,Il=!1},t.isValidAttribute=function(U,E,A){ei||Lf({});let D=Oe(U),ce=Oe(E);return Wy(D,ce,A)},t.addHook=function(U,E){typeof E=="function"&&(M[U]=M[U]||[],fl(M[U],E))},t.removeHook=function(U){if(M[U])return aT(M[U])},t.removeHooks=function(U){M[U]&&(M[U]=[])},t.removeAllHooks=function(){M={}},t}var vT=yT();var no=x(_());var yN={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function ST(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function gl(e){return(e+"").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function hl(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||{},p=0;function d(v){var y=yN[v[1]||""],g=l[l.length-1]==v;return y?y[1]?(g?l.pop():l.push(v),y[0|g]):y[0]:v}function m(){for(var v="";l.length;)v+=d(l[l.length-1]);return v}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(v,y,g){return c[y.toLowerCase()]=g,""}).replace(/^\n+|\n+$/g,"");o=a.exec(e);)r=e.substring(p,o.index),p=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()+'"':"")+">"+ST(gl(s).replace(/^\n+|\n+$/g,""))+"</code></pre>":(s=o[6])?(s.match(/\./)&&(o[5]=o[5].replace(/^\d+/gm,"")),i=hl(ST(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="'+gl(o[8])+'" alt="'+gl(o[7])+'">':o[10]?(u=u.replace("<a>",'<a href="'+gl(o[11]||c[r.toLowerCase()])+'">'),n=m()+"</a>"):o[9]?n="<a>":o[12]||o[14]?n="<"+(s="h"+(o[14]?o[14].length:o[13]>"="?1:2))+">"+hl(o[12]||o[15],c)+"</"+s+">":o[16]?n="<code>"+gl(o[16])+"</code>":(o[17]||o[1])&&(n=d(o[17]||"--"))),u+=r,u+=n;return(u+e.substring(p)+m()).replace(/^\n+|\n+$/g,"")}var xT={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 Pn=x(C());function vN(e){return`<button type="button" 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 hy(e){let t=e.cloneNode(!0);return t.querySelectorAll("div,button").forEach(n=>n.remove()),t.textContent??""}function SN(e){return e.replace(/\r\n/g,`
|
|
25
25
|
`)}var xN=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=P("Markdown",xT),s=(0,no.useRef)(null),[a,l]=(0,no.useState)(null),u=(0,no.useMemo)(()=>{let y=hl(SN(e));return vT.sanitize(y).replace(/<\/code>/g,`${vN(i.copyIcon)}</code>`)},[e]),c=y=>{var h;let g=y.target,f=!!((h=s.current)!=null&&h.querySelector("code"));a||f&&g.tagName!=="CODE"||!f&&g!==s.current||(g.addEventListener("mouseleave",()=>l(null),{once:!0}),l(g))},p=()=>{if(!a)return;l(null);let y=a.querySelector("button");y&&(ns(y,i.fadeup),r(hy(a)))},d=y=>{y.target.tagName.toLowerCase()==="button"&&(ns(y.target,i.fadeup),r(hy(y.target.parentElement)))},m=()=>{a&&(l(null),o(hy(a)))},v=y=>{if(y===null)return;let g=y.getBoundingClientRect();g.left<0?y.style.transform=`translateX(${-g.left+2}px)`:g.right>window.innerWidth&&(y.style.transform=`translateX(${window.innerWidth-g.right-2}px)`)};return(0,Pn.jsxs)(no.Fragment,{children:[a&&(0,Pn.jsxs)(ps,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,Pn.jsxs)("div",{className:i.options,ref:v,children:[(0,Pn.jsx)("button",{type:"button",className:i.option,onClick:p,children:n}),(0,Pn.jsx)("div",{className:i.divider}),(0,Pn.jsx)("button",{type:"button",className:i.option,onClick:m,children:t})]}),(0,Pn.jsx)("div",{className:i.arrow})]}),(0,Pn.jsx)("div",{ref:s,className:i.root,dangerouslySetInnerHTML:{__html:u},onMouseOver:c,onClick:d})]})},wT=xN;var yy={};je(yy,{enUS:()=>wN,nlNL:()=>EN});var wN={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"}]},EN={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 ET={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l"};var cn=x(C()),CN=({cue:e,onRemove:t,onCopy:n,onUse:r})=>{let o=P("WidgetCue",ET),i=K(yy),s=rs(),a=c=>{n&&n(c,e)},l=c=>{r&&r(c,e)},u=c=>{c.preventDefault(),c.stopPropagation(),t(e)};return(0,CT.useEffect)(()=>{s("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,cn.jsxs)(ee,{"data-testid":"cue",children:[(0,cn.jsx)(pe,{children:(0,cn.jsxs)(pe.Content,{children:[e.title&&(0,cn.jsx)(pe.Title,{className:o.title,"data-testid":"widget-cue-title",children:e.title}),(0,cn.jsx)(wT,{content:e.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:a,onUse:l})]})}),(0,cn.jsxs)(ee.IconButtonContainer,{children:[(0,cn.jsx)(is,{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"}),(0,cn.jsx)(ee.IconButton,{title:i("removeCue"),onClick:u,icon:(0,cn.jsx)(iT,{})})]})]})},bT=CN;var yl=x(C()),bN=({cues:e})=>{let t=$(),n=Bt(),r=rs(),o=a=>{t(zb({id:a.rule.id})),r("Assistant response closed",{name:a.rule.name,group:a.rule.label,description:a.rule.description,cueText:a.text})},i=(a,l)=>{$n(a),r("Assistant response copied",{name:l.rule.name,group:l.rule.label,description:l.rule.description,copiedText:a})},s=(a,l)=>{n.send($r,{text:a,suggestion:{source:"cue",sourceText:a}}),r("Assistant response used",{name:l.rule.name,group:l.rule.label,description:l.rule.description,usedText:a})};return(0,yl.jsx)(yl.Fragment,{children:e.map(a=>(0,yl.jsx)(bT,{cue:a,onRemove:o,onCopy:i,onUse:s},a.rule.id))})},TT=bN;var gf=x(_());var kT={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var dn=x(C());function TN(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var PT=({data:e,schema:t})=>{let n=P("WidgetCustomData",kT),r=o=>{$n(o)};return(0,gf.useEffect)(()=>{F.info("Custom data",e,t)},[e]),(0,dn.jsx)("dl",{className:n.root,children:t.map(o=>{let i=TN(e,o.path);return(0,dn.jsxs)(gf.Fragment,{children:[(0,dn.jsx)("dt",{className:n.label,children:o.label}),(0,dn.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,dn.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,dn.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,dn.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,dn.jsx)("span",{children:i}),(0,dn.jsx)(cl,{})]}):"-"})]},o.label)})})};var AT=x(_());var kN=/(https?:\/\/[^\s]+)/,RT=e=>e.split(" ").find(t=>kN.test(t));var Wt=x(C()),PN=({suggestion:e,lines:t,onUse:n})=>{var c;let r=e.text||e.url||e.message,o=RT(r),i=K(zo),s=z("showImages"),a=z("fallbackImage"),l=p=>{p.preventDefault(),p.stopPropagation(),n(r)},u=(0,AT.useCallback)(p=>{window.open(o,"_blank"),p.stopPropagation(),p.preventDefault()},[o]);return(0,Wt.jsxs)(ee,{onClick:l,"data-testid":"edit-suggestion",children:[(0,Wt.jsxs)(pe,{children:[s&&e.image&&(0,Wt.jsx)(pe.Image,{src:rf(e,"small",a||void 0),title:e.title}),(0,Wt.jsxs)(pe.Content,{children:[e.title&&(0,Wt.jsx)(pe.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((c=e.searchKeywords)==null?void 0:c.length)>0&&(0,Wt.jsx)(ee.Labels,{labels:e.searchKeywords}),(0,Wt.jsx)(pe.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,Wt.jsxs)(ee.Actions,{children:[o&&(0,Wt.jsx)(ee.ActionButton,{onClick:u,label:i("visitUrl")}),(0,Wt.jsx)(ee.ActionButton,{primary:!0,onClick:l,label:i("useSuggestion")})]})]})},LT=PN;var vl=x(C()),RN=({lines:e,suggestions:t})=>{let n=Bt(),r=(o,i)=>{n.send($r,{text:o,suggestion:{...i,source:i.source,sourceText:i.text}})};return(0,vl.jsx)(vl.Fragment,{children:t.map(o=>(0,vl.jsx)(LT,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},IT=RN;var Sl={};je(Sl,{enUS:()=>AN,nlNL:()=>LN});var AN={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"}]},LN={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 xl={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",sectionList:"dd-bF9pF",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",link:"dd-DRo0x"};var V=x(C()),hf=(e,t)=>{let n=L(Je);(0,wl.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},IN=({onLogIn:e})=>{let t=P("Widget",xl),n=z("isEmbedded"),r=z("adminUrl");return(0,V.jsx)("div",{className:t.loginText,children:(0,V.jsx)("div",{children:(0,V.jsx)(Kd,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},OT=({text:e})=>{let t=P("Widget",xl);return(0,V.jsx)("div",{className:t.stateText,children:(0,V.jsx)("div",{children:(0,V.jsx)("p",{children:e})})},"notification")},ON=()=>{let e=K(Sl),t=$(),n=P("Widget",xl),r=z("showSearch"),o=z("showSummaryCommand"),i=z("showKnowledgeSearch"),s=L(os("/admin/")),a=Bt(),l=z("productName"),u=r||o||i||s;return hf(()=>(t(Jh()),()=>{t(_b())}),[t]),u?(0,V.jsx)(pn,{title:e("actions"),type:"shortcuts",children:(0,V.jsxs)("div",{className:n.shortcutList,children:[r&&(0,V.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":e("linkSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0}),children:[(0,V.jsx)(es,{}),e("linkSearch")]}),o&&(0,V.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,V.jsx)(oT,{}),e("linkSummary")]}),i&&(0,V.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,V.jsx)(rT,{}),e("linkKnowledgeSearch")]}),s&&(0,V.jsxs)("a",{className:n.shortcut,target:"_blank",href:s,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:l}),rel:"noreferrer",children:[(0,V.jsx)(nT,{}),e("linkStudioLogin",{productName:l})]})]})}):null},MN=()=>{let e=$(),t=z("showCustomMessages"),n=L(kb),r=L(qi);return hf(()=>(e(ul(r)),e(Ib(r)),()=>{e(Ob(r))}),[e,t,r]),!t||n.length===0?null:(0,V.jsx)(pn,{type:"custom-messages","data-testid":"custom-messages",children:(0,V.jsx)(ct,{withDivider:!0,children:n.map(o=>(0,V.jsx)(Jb,{suggestion:o},o.text))})})},NN=()=>{let e=K(Sl),t=$(),n=z("showAutoflows"),r=L(wb),o=L(qi);return hf(()=>(t(sr(o)),t(Eb(o)),()=>{t(Cb(o))}),[t,n,o]),!n||r.length===0?null:(0,V.jsx)(pn,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,V.jsx)(ct,{withDivider:!0,children:(0,V.jsx)(Qb,{})})})},_N=()=>{let e=$(),t=L(Nd),n=L(sC),r=L(Hb),o=L(I1),i=L(Od),s=L(_d),a=L(er),l=L(Vr);return(0,wl.useEffect)(()=>{!!o&&!n&&F.warn("Custom data provided, but no schema.")},[o,n]),hf(()=>{t.forEach(({type:u})=>{u==="entities"?e(on()):Yl.includes(u)||e(an(u))})},[e,l,a]),(0,V.jsx)(wl.Fragment,{children:t.map(({type:u,title:c,amount:p,lines:d,schema:m})=>{var v,y;switch(u){case"entities":return i&&i.length>0&&(0,V.jsx)(pn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,V.jsx)(tT,{entities:i})},u);case"cues":return r&&r.length>0&&(0,V.jsx)(pn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,V.jsx)(ct,{withDivider:!0,children:(0,V.jsx)(TT,{cues:r})})},u);case"custom-data":return o&&m&&(0,V.jsx)(pn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,V.jsx)(ct,{withDivider:!0,children:(0,V.jsx)(PT,{data:o,schema:m})})},u);default:return((y=(v=s[u])==null?void 0:v.suggestions)==null?void 0:y.length)>0&&(0,V.jsx)(pn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,V.jsx)(ct,{withDivider:!0,children:(0,V.jsx)(IT,{lines:d,contentType:u,suggestions:s[u].suggestions.slice(0,p)||[]})})},u)}})})},DN=({onLogIn:e})=>{let t=K(Sl),n=P("Widget",xl),r=L(Gi),o=L(Je),i=L(qi),s=L(er);return r===!1?(0,V.jsx)(OT,{text:t("notSupported")}):o===!1?(0,V.jsx)(IN,{onLogIn:e}):!s||!i||o===null?(0,V.jsx)(OT,{text:t("waiting")}):(0,V.jsx)("div",{className:(0,MT.default)(n.root),"data-testid":"widget",children:(0,V.jsxs)(ql,{className:n.sectionList,children:[(0,V.jsx)(ON,{}),(0,V.jsx)(MN,{}),(0,V.jsx)(NN,{}),(0,V.jsx)(_N,{})]})})},NT=DN;function ms(e){let t=new Range;return t.selectNodeContents(e),t}function _T(e,t,n){try{return ro(e,t,n),!0}catch{return!1}}function yf(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function vf(e){return"tagName"in e&&e.tagName==="BR"}var El=/[\u200B-\u200D\uFEFF]/g;function ro(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(l))return u;for(let d=0;d<=l.length;d++)if(p.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(El,""),p=o+c.length,d=t>=o&&t<=p,m=n>=o&&n<=p;if(d){let v=s(u,t-o);v===0&&!m?r.setStartBefore(l):r.setStart(l,v)}m&&(r.setEnd(l,s(u,n-o)),i=!0),o=p;break}case Node.ELEMENT_NODE:{if(vf(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;yf(l)&&u&&!yf(u)&&!vf(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Cl(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(p){let d=p===n,m=p===o;switch(p.nodeType){case Node.TEXT_NODE:{let v=p.textContent;d&&(a=u+v.substring(0,r).replace(El,"").length),m&&(l=u+v.substring(0,i).replace(El,"").length),u+=v.replace(El,"").length;break}case Node.ELEMENT_NODE:{let v=p.nextSibling===null;vf(p)&&!v&&u++;for(let y=0;y<p.childNodes.length;y++){let g=d&&y===r,f=m&&y===i;if(g&&(a=u),f&&(l=u),l!==void 0||((!g||!s)&&c(p.childNodes[y]),m&&y===i-1&&(l=u),l!==void 0))break}!m&&yf(p)&&!v&&u++,m&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function bl(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i}=t,s=-1,a="";function l(u){let c=u===n,p=u===o;switch(c&&s++,u.nodeType){case Node.TEXT_NODE:{if(s!==0)return;let d=c?r:0,m=p?i:void 0,v=u.textContent.replace(El,"");d===0&&m===void 0?a+=v:a+=v.substring(d,m);break}case Node.ELEMENT_NODE:{let d=u.nextSibling===null;s===0&&vf(u)&&!d&&(a+=`
|
|
26
26
|
`);for(let m=c?r:0;m<(p?Math.min(i,u.childNodes.length):u.childNodes.length)&&(l(u.childNodes[m]),s!==1);m++);!p&&s===0&&yf(u)&&!d&&(a+=`
|
|
27
|
-
`);break}default:break}p&&s++}return l(e),a}var DT=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(DT||{}),lr=class{constructor(t){this.element=t;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}triggerChange(){let t=this.getText(),n=this.getHTML(),r=t!==this.currentText;this.isActive&&(t===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&r&&!this.isSubmitting&&this.emit("change",{plainText:t}),r&&(this.currentSelection=this.getSelection()),this.currentText=t,this.isSubmitting=!1,(this.currentHTML!==n||n===null&&r)&&(this.emit("updated",{plainText:t}),this.triggerCaretPosition(),this.currentHTML=n))}triggerSelection(){let t=this.getSelection();(t.start!==this.currentSelection.start||t.end!==this.currentSelection.end)&&(this.currentSelection=t,this.emit("selection",t),this.triggerCaretPosition())}triggerCaretPosition(){let t=this.getCaretPosition();jr(t,this.currentCaret)||(this.currentCaret=t,this.emit("caret",t))}handleKeyUp(t){let{key:n,shiftKey:r}=t;(n==="Enter"&&r===!0||n==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(DT).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(t={shouldObserve:!0}){this.addEventListener("keydown",r=>this.handleKeyDown(r)),this.addEventListener("keyup",r=>this.handleKeyUp(r)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",r=>this.handlePaste(r)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let n=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t!=null&&t.shouldObserve&&n.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{n.disconnect()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function FT(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var qo=class extends lr{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let t=new Range;return t.selectNodeContents(this.element),bl(this.element,t)}getHTML(){return this.element.innerHTML||""}getRange(){var i;let t=this.getRootNode();if(t.activeElement!==this.element)return null;let n="getSelection"in t?t.getSelection():window.getSelection();if(!n)return null;let r="getComposedRanges"in n&&t instanceof ShadowRoot?(i=n.getComposedRanges(t))==null?void 0:i[0]:n.rangeCount>0?n.getRangeAt(0):null;if(!r)return null;let o=this.element.ownerDocument.createRange();return o.setStart(r==null?void 0:r.startContainer,r==null?void 0:r.startOffset),o.setEnd(r==null?void 0:r.endContainer,r==null?void 0:r.endOffset),!o||!this.element.contains(o.startContainer)||!this.element.contains(o.endContainer)?null:o}getCaretPosition(){let t=this.getRange();if(!t||!t.collapsed||!("getBoundingClientRect"in t))return null;let n=t.getBoundingClientRect();return!FT(n)&&(t.insertNode(this.element.ownerDocument.createTextNode("\u2060")),n=t.getBoundingClientRect(),t.deleteContents(),!FT(n))?null:{top:n.top+n.height,left:n.left}}getSelection(){let t=this.getRange();if(t)return Cl(this.element,t);let n=this.lastKnownSelection;if(n&&_T(this.element,n.start,n.end))return n;let r=ms(this.element);return r.collapse(!1),Cl(this.element,r)}getSelectedText(){let{start:t,end:n}=this.getSelection();return bl(this.element,ro(this.element,t,n))}applyChanges(t){var o;if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);return(o=this.observer)==null||o.takeRecords(),Promise.resolve(r).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(t={shouldObserve:!0}){super.listen(t),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),t!=null&&t.shouldObserve&&this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let n=this.element.isContentEditable,r=new MutationObserver(()=>{this.element.isContentEditable!==n&&(n=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>r.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var Go=class extends lr{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:t,selectionEnd:n}=this.element;return{start:t,end:n}}getSelectedText(){let t=this.getSelection();return t?this.getText().slice(t.start,t.end):""}getCaretPosition(){return null}applyChanges(t){if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);return Promise.resolve(r).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let t=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var o;return(o=t==null?void 0:t.get)==null?void 0:o.call(this.element)},set:o=>{var i;(i=t==null?void 0:t.set)==null||i.call(this.element,o),this.triggerChange()}});let n=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==n&&(n=this.element.disabled,this.emit(n?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};function HT(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 FN(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}var vy=class{constructor(t){this.name=t;this.broadcastChannel=new BroadcastChannel(t)}broadcastChannel;disposeHandlers=[];onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},Sy=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.iframe=HT(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},xy=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),F.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 Sy(t,this.deepdeskUrl,{debug:!0}):new vy(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=FN(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(F.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;F.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({...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)}},UT=xy;var gs=class extends Error{constructor(n,r){super(n);this.body=r}name="CustomError"};var wy=e=>new Promise(t=>{setTimeout(t,e)});var hs=class extends gs{name="ClientError"},Cy=class extends gs{name="ServerError"},Ey=new Map;async function HN(e){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=await e.text();return n===""?null:(F.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))}var fn=class e{constructor(t="",n={}){this.baseUrl=t;this.options=n;n.fetch&&(this.fetch=n.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",{useCache:u=!1,abortLatest:c=!1,attempts:p=1,retryDelay:d=500,refreshTokenOn401:m=!0,retryOnError:v=b=>b instanceof TypeError,retryOnResponse:y=b=>b.status>=500,version:g="v1",...f}=n;if(u)if(l){if(Ey.has(s)){r(Ey.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h={credentials:"include",...f,headers:{"Content-Type":"application/json",...f.headers}};!l&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof g=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":g});let S=p,w=!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 T=async()=>(S--,a(s,h).then(async b=>y(b)&&!i.isAborted&&S>0?(await wy(d),T()):b.status===401&&m===!0&&w===!1?(w=!0,await this.refreshToken(),T()):b).catch(async b=>{if(v(b)&&!i.isAborted&&S>0)return await wy(d),T();throw b}));T().then(async b=>{let k=await HN(b);if(delete this.latestRequestByUrl[s],b.status>=500){o(new Cy("Server Error",k));return}else if(b.status===401){o(new hs("Unauthorized",k));return}else if(b.status===403){o(new hs("Forbidden",k));return}else if(b.status===404){o(new hs("Not Found",k));return}else if(b.status>=400){o(new hs("Bad Request",k));return}u&&Ey.set(s,k),r(k)}).catch(b=>{o(b)})})}async validateToken(){let{has_valid_access_token:t}=await this.get("/auth/validate");if(!t)return!1;let{is_logged_in:n}=await this.get("/apis/admin/session/validate/",{version:null});return!!n}refreshToken(){return e.refreshingToken||(e.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{e.refreshingToken=null},1e3*60)})),e.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,{method:"POST",body:JSON.stringify(n),...r})}patch(t,n,r){return this.request(t,{method:"PATCH",body:JSON.stringify(n),...r})}put(t,n,r){return this.request(t,{method:"PUT",body:JSON.stringify(n),...r})}delete(t,n){return this.request(t,{method:"DELETE",...n})}};var UN;(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||={})})(UN||={});function Sf(e){return{...J(e),tags:e.tags}}var ur=class e{constructor(t,n={}){this.options=n;this.client=new fn(t,{fetch:n.fetch}),this.client.patchFetch(r=>async(o,i)=>{let s=await r(o,i);return this.handleDeepdeskVersionHeaders(s),s})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=await this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(e.exchangeTokenPromise||(e.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),e.exchangeTokenPromise):Promise.resolve()}async createConversation(t){await this.preflight(),F.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=await this.client.post("/api/conversations",{...Re(t),tags:t.tags},{version:"v2"});return Sf(n)}async getProfile(t){let n=await this.client.get(`/apis/admin/profiles/${t}/`,{version:null,useCache:!0});return J(n)}async getKnowledgeAssistant(t){let n=await this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{version:null,useCache:!0});return J(n)}async getContentTypes(){let t=await this.client.get("/apis/admin/content-types/",{version:null,useCache:!0});return J(t)}async getAccount(){let t=await this.client.get("/apis/admin/account/",{version:null,useCache:!0});return J(t)}async getPlatformConfig(){let{config:t}=await this.client.get("/platform/config/",{version:null,useCache:!0});return J(t)}async checkUserExists(t){let{exists:n}=await this.client.get(`/apis/admin/users/exists?external_id=${t}`);return n}async getConversationBySessionId(t,n={}){await this.preflight(),F.info(`Getting conversation for session ${t}`);let{attempts:r=1,retryDelay:o=1e3}=n,i=await this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"});return F.info(`Successfully retrieved conversation ${i.id} for session ${t}`),Sf(i)}async isConversationSupported(t,n={}){F.info(`Check if conversation for session ${t} is supported`);let{attempts:r=1,retryDelay:o=1e3}=n;return(await this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"})).has_active_profile}async updateConversation(t,n){let r=Re(n);n.tags&&(r.tags=n.tags);let o=await this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Sf(o)}async postMessages(t,n){return(await this.client.post(`/api/conversations/${t}/messages`,n.map(o=>({...Re(o),tags:o.tags})),{version:"v2"})).map(o=>Sf(o))}async sendEvent(t,n){let{data:r,...o}=n,i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[a,l])=>({...s,[a]:l}),{});return this.client.post("/api/events",Re({...i,...o,data:r,name:t}),{version:"v2"})}async sendEventV1(t,n){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>({...o,[i]:s}),{});return this.client.post("/api/events",{event:t,data:Re({...n,...r})})}async getEntities(t){return(await this.client.post("/api/entities",{messages:t.filter(r=>r.text)})).entities}async getSummary(t,n={}){let r=await this.client.post("/api/summary",{conversation:{messages:t.filter(o=>o.text&&o.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model});return J(r)}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(t){return this.client.post("/apis/admin/session/jwt/",{jwt:t},{version:null}).catch(n=>{throw F.warn(`Invalid token '${t}'`),n})}async authenticateWithKey(t,n){await this.preflight(),await this.client.post("/apis/admin/session/api-key/",Re(n),{version:null,refreshTokenOn401:!1,headers:{apikey:t}})}async getTextSuggestions(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(await this.client.post(`/api/conversations/${t}/recommend/${r}`,Re(n),{abortLatest:!0})).map(i=>({...J(i),text:i.text||i.url||i.message,source:r,type:r})).filter((i,s,a)=>s===a.findIndex(l=>l.text===i.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(t,n){return(await this.client.post(`/api/conversations/${t}/autocomplete`,Re(n),{abortLatest:!0})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))}async getPinnedMessages(t){let n=await this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0});return J(n).map(r=>({...r,text:r.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(t){let n=await this.client.post("/api/style-suggestions",Re(t),{abortLatest:!0});return J(n)}async search(t){let n=await this.client.post(`/api/profiles/${t.profile}/search`,Re(t),{version:"v2"});return J(n)}async knowledgeAssist(t,n,r,o={}){let i=await this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Re({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(s=>({question:s.question,answer:s.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return J(i)}async requestLoginByEmail(t){let n=await this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return J(n)}async requestPasswordlessToken(){let t=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return J(t.token)}async getCsrfToken(){let{token:t}=await this.client.get("/apis/admin/session/csrf/",{version:null});return t}async verifyLoginToken(t){let n=await this.client.post("/apis/admin/session/passwordless/login/",{token:t},{version:null});return J(n)}async evaluateRule(t,n,r,o={}){let i=new URLSearchParams;o.raiseForFailingConditions&&i.set("raise_for_failing_conditions","true");let s=await this.client.post(`/api/conversations/${n}/rules/${t}/evaluate?${i.toString()}`,r,{version:"v2"});return J(s.cues)}async getRules(){let t=new URLSearchParams,n=await this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{version:null,useCache:!0});return J(n)}async translateMessages(t){let n=await this.client.post("/api/translate",Re(t),{version:"v2"});return J(n)}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Uv);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&F.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};var Tl=class{constructor(t,n){this.url=t;this.options={timeout:25e3,...n}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(t){this.eventSource.addEventListener($g(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,J(o))}catch{F.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 zN;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||={})})(zN||={});var kl=class{constructor(t,n={}){this.apiUrl=t;this.client=new fn(t,n)}client;streams={};logger=F;async getCustomMessages(t){let n=await this.client.get(`/sessions/${t}/suggestions`);return J(n.suggestions)}async sendCustomMessage(t,n){let r=await this.client.post(`/sessions/${t}/messages`,Re(n));return J(r)}async answerCustomMessage(t,n){await this.client.post(`/sessions/${t}/answers`,Re(n))}async getAutoflows(t){let n=await this.client.get(`/sessions/${t}/autoflows`);return J(n.autoflows)}async startAutoflowSession(t){let n=await this.client.post("/autoflow-sessions",Re(t));return J(n)}async stopAutoflowSession(t){await this.client.delete(`/autoflow-sessions/${t}`)}openStream(t){return this.streams[t]||(this.streams[t]=new Tl(`${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 zT={startTime:null,stopTime:null},BT=G({name:"handlingTime",initialState:zT,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(le,()=>zT)}}),{handlingTimeStart:jT,handlingTimeStop:xf,handlingTimeReset:VT}=BT.actions,KT=BT.reducer;var WT=(e={})=>{let t={onAuthError:$i(!1),...e};return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var wf={list:{keywordMatches:[]},fetchState:"idle"};var Xo=B("styleSuggestions/getAll",async({text:e},t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),{showStyleSuggestions:o}=r.settings,i=(s=r.conversation.current)==null?void 0:s.profileCode;if(!o)return wf.list;if(!i)throw new Error("No current conversation to fetch pinned messages");return n.getStyleSuggestions({profileCode:i,message:e})}),BN=G({name:"styleSuggestions",initialState:wf,reducers:{},extraReducers:e=>{e.addCase(Xo.pending,t=>{t.fetchState="loading"}).addCase(Xo.rejected,t=>{t.fetchState="error"}).addCase(Xo.fulfilled,(t,n)=>{t.fetchState="done",jr(t.list,n.payload)||(t.list=n.payload)}).addCase(Ro,t=>{t.list=wf.list}).addCase(le,()=>wf)}}),$T=BN.reducer;var qT=(e={})=>{let t,n=!0,r={getStyleSuggestions:Xo,debounce:500,...e};return o=>i=>s=>{var m;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(!((m=u.conversation.current)==null?void 0:m.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 jN(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var GT=(e={})=>{let t={getTextSuggestions:an,getAutocompleteSuggestions:rl,debounce:200,check:as,...e},n;return r=>o=>i=>{var y;let{input:{userCommitted:s}}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,p=(y=l.conversation.current)==null?void 0:y.id,d=i.type===Dd.toString();if(!p||!u&&!c)return a;let{input:{userCommitted:m}}=l;return jN(m,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let g=Xi(l);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var XT=Xo.fulfilled.toString();function VN(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 YT=e=>t=>n=>r=>{var u;if(r.type!==XT){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=VN(o,s);r.type===XT&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var KN=hc({answer:rC,auth:i1,autoflows:bb,conversation:m1,contentTypes:pE,customMessages:Mb,passwordlessToken:Db,entities:HE,knowledgeAssistant:eC,handlingTime:KT,info:_1,input:A1,settings:Zw,profile:aC,search:j1,summary:WE,styleSuggestions:$T,ui:DC,rules:Bb,textSuggestions:gC});function QT(e){return ow({reducer:KN,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),WT(),GT({debounce:200}),qT({debounce:500}),YT(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var WN=e=>{var t;return((t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())??"unknown"},$N=e=>t=>n=>r=>{var a,l,u,c,p,d;let o=t.getState(),i=Ug("inlineSuggestions")(o);switch(r.type){case $i.toString():{!r.payload&&e.emit("logout",void 0);break}case on.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 et.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 Jc.toString():e.handleKeyDown(r.payload);break;case Ro.toString():e.logSendMessage(r.payload);break;case ed.toString():e.handleInputChanged(r.payload);break;case Wo.fulfilled.toString():r.isBroadcasted||e.broadcast(Xg,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;default:break}let s=n(r);switch(r.type){case Ro.toString():e.handleAfterSendMessage(r.payload);break;case il.toString():e.onUpdateShowTabHint(r.payload);break;case xf.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case Cn.toString():{let{start:m,end:v}=o.input.selection;e.emit("select-suggestion",{type:WN(r.payload.suggestion),...r.payload,replace:r.payload.replace==="selection"?{start:m,end:v}:{start:0,end:v}},{mayApplyChanges:!0}),i&&(t.dispatch(En([])),t.dispatch(Wn()));break}case Zc.toString():{let{start:m,end:v}=o.input.selection;e.emit("replace",{...r.payload,replace:r.payload.replace==="selection"?{start:m,end:v}:{start:0,end:v}},{mayApplyChanges:!0});break}case Ma.toString():{let m=t.getState(),{text:v,selection:y}=m.input.userCommitted;e.emit("reset",{text:v,selectionAfter:y},{mayApplyChanges:!0});break}case td.toString():e.emit("select-image",r.payload,{mayApplyChanges:!0}),e.sendEvent("Image attached",{conversationId:(p=o.conversation.current)==null?void 0:p.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case En.toString():{i&&r.payload.length>0&&t.dispatch(Wr(0));break}case Qn.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload.summary,model:t.getState().summary.model}});break}default:break}return s},ZT=$N;function by(e){return e.toISOString().replace("T"," ").replace("Z","")}function JT(e,t){var i,s,a,l;let n=(i=e.conversation.current)==null?void 0:i.id;if(!n)return F.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:o}=e.handlingTime;return!r||!o?(F.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:by(r),timeStop:by(o)}}function ek(e,t,n){var I,O,M,W;let r=(I=t.conversation.current)==null?void 0:I.id;if(!r)return F.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:p,pastes:d,cuts:m,deletions:v,textSuggestions:y,offeredTextSuggestions:g}}=t[e],f=o.length,S=y.reduce((X,{text:ne,searchTerm:cr})=>X+ne.length-(cr?cr.length:0),0),w=c??Date.now(),T=(Date.now()-w)/1e3+(p||0),b=i/T,k=y.reduce((X,{searchTerm:ne})=>X+(ne?ne.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:m,deletions:v,lenTextTyped:i+k,lenTextTotal:f,lenTextAssisted:S,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:T,charsPerSecond:b,numPastes:u,textSuggestionsV2:y,suggestionsCounters:[{source:"gpt",countOffered:g.filter(X=>X.source==="gpt").length}],agentId:(O=t.info.agentInfo)==null?void 0:O.agentId,agentName:(M=t.info.agentInfo)==null?void 0:M.agentName,agentEmail:(W=t.info.agentInfo)==null?void 0:W.agentEmail}}function Ty(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return Ty(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?Ty(o,t):null}function tk(e,t){return Ty(e,t)}function nk(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function qN(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Ef(e){return qN(e)&&(Jr(e)||$d(e))}var ok,Rn=new Map,GN=["bottom","height","left","right","top","width"],rk=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:GN.some(n=>e[n]!==t[n]);function ik(e){var n,r;if(e.ownerDocument===document)return[];let t=((r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)??null;return t?[t,...ik(t)]:[]}function sk(e,t){return!e||!t?null:{...e,top:e.top+t.top,left:e.left+t.left}}var Cf=!1,ak=()=>{Cf=!0;let e=[];if(Rn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Rn.delete(n);return}let r=n.getBoundingClientRect();rk(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(sk,t.rect):t.rect;rk(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Rn.size===0){Cf=!1;return}ok=window.requestAnimationFrame(ak)};function ky(e,t){let n=ik(e),r=[],o=n.map((i,s)=>ky(i,a=>{r[s]=a;let l=Rn.get(e);if(!l)return;let u=r.reduce(sk,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Rn.has(e)){let s=Rn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Rn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Cf&&ak()},unobserve(){o.forEach(s=>s.unobserve());let i=Rn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Rn.delete(e),Rn.size||(cancelAnimationFrame(ok),Cf=!1)}}}}var lk,An=new Map,uk=()=>{An.forEach((e,t)=>{if(!t.isConnected){An.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(i=>i(e.visible)))}),An.size!==0&&(lk=window.requestAnimationFrame(uk))};function ck(e,t){return{observe(){let n=An.size===0;An.has(e)?An.get(e).callbacks.push(t):An.set(e,{visible:void 0,callbacks:[t]}),n&&uk()},unobserve(){let n=An.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||An.delete(e),An.size||cancelAnimationFrame(lk)}}}}var Py=["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 Ry(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ys(e){return parseFloat(e)}function bf(e){return Math.round(e*1e6)}function dk(e){return e/1e6}function Ay(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=ys(e.width),i=ys(e.borderLeftWidth),s=ys(e.borderRightWidth),a=ys(e.paddingRight),l=dk(bf(o)-bf(i)-bf(s)),u=dk(bf(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function Pl(e,t={}){var c;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=t.position??"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",jo(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};Ry(r,n,Py),Ay(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=ck(e,()=>{Ry(r,n,Py),Ay(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=ky(e,p=>{if(p===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),p.height===0&&p.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(Ry(r,n,Py),Ay(r,e,n),i(),n.style.top=`${p.top}px`,n.style.left=`${p.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let d=t.closestScrollElement.getBoundingClientRect(),m=window.getComputedStyle(t.closestScrollElement),v=ys(m.borderTopWidth),y=ys(m.borderBottomWidth),g=d.top+v-p.top,f=p.top+p.height+-(d.top+d.height-y);n.style.clipPath=`inset(${g}px 0px ${f}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(c=e.parentElement)==null||c.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var fk=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch{return t}}catch{return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch{F.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function XN(e){return e.offsetParent!==null}function pk(e){if(!XN(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 Tf(e,t,n=100){let r=pk(e);t({isVisible:r});let o=setInterval(()=>{let i=pk(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Ie=x(C());var mk=fk("showTabHint",!0),Rl=class e{static version="11.6.0";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:t,brokerUrl:n,version:r=e.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){let u=t.replace(/\/api$/,"");this.deepdeskApi=new ur(u,{token:i,fetch:s}),this.version=r,this.instanceId=e.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[ZT({broadcast:(p,d,m)=>{this.broadcastEvents.send(p,d,m)},emit:(p,d,m)=>this.emit(p,d,m),handleAfterSendMessage:p=>this.handleAfterSendMessage(p),handleInputChanged:p=>this.handleInputChanged(p),handleKeyDown:p=>this.handleKeyDown(p),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:p=>this.logSendMessage(p),onUpdateShowTabHint:p=>mk.update(p),sendEvent:(p,d)=>this.deepdeskApi.sendEvent(p,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new kl(n)}),this.store=QT(c),this.broadcastEvents=new UT({debug:!0,deepdeskUrl:u,eventMap:V1(this.store),createCustomChannel:l}),this.store.dispatch(il(mk.value())),this.store.dispatch(Wc({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(F.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(F.warn("Profile has not been loaded (yet)"),!0):(F.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch($i(null)),this.store.dispatch(Vn()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();Je(r)&&Jw(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}async isLoggedIn(){return(await this.store.dispatch(Vn())).payload}async setPlatformAgentId(t){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:t}),version:null})}catch(n){F.warn("Failed to attach user:",n)}}async isConversationSupported(t,n){return(await this.store.dispatch(Vg({sessionId:t,options:n}))).payload}async createConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(qc(t))).payload}async getConversationBySessionId(t,n){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(await this.store.dispatch(Gc({sessionId:t,options:n}))).payload}async upsertConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(Kg(t))).payload}async postMessages(t){return(await this.store.dispatch(Yc(t))).payload}async updateConversation(t){return(await this.store.dispatch(Xc(t))).payload}resetConversation(){this.store.dispatch(le()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let t=await this.store.dispatch(Qn());if(t.error)throw new Error(t.error.message);return t.payload.summary}configure(t){this.store.dispatch(Wc(t))}setVisitorInfo(t){this.store.dispatch(M1(t))}setCustomData(t){this.store.dispatch(N1(t))}async setAgentInfo(t){await this.store.dispatch(Na(t))}async setAgentSettings(t){await this.store.dispatch(qg(t))}async getAgentSettings(){return(await this.store.dispatch(Gg())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let t=[];return this.store.dispatch(Dd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})}notifyInputChanged(t){this.store.dispatch(ed(t))}notifyKeyDown(t){this.store.dispatch(Jc(t))}notifyPaste(t,n){this.store.dispatch(T1({text:t,selectionText:n}))}notifyCut(t){this.store.dispatch(C1(t))}notifyExternalSuggestion(t){this.store.dispatch(Cn(t)),this.store.dispatch(Wn())}async evaluateRule(t,n={},r=Fb){let{payload:o,error:i}=await this.store.dispatch(Wo({label:t,params:n,options:r}));if(i)throw new Error(i.message);return o.cues}handleInputChanged(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui;n&&r&&this.store.dispatch(Qr({collapse:!1})),this.inputMediator&&this.store.dispatch(v1({text:t,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(En([])))}handleKeyDown(t){let{overlayCollapsed:n}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:o,selection:i}=this.state.input,{inlineSuggestions:s}=this.state.settings,a=r.length>0,l=o!==-1;if(this.store.dispatch(b1(g1(t))),t.key!=="Tab"&&!this.settings.showTextSuggestions)return;let u=()=>{n||!a||i&&(t.shiftKey||(this.store.dispatch(x1()),s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault()))},c=()=>{n||!a||s&&o<=0||i&&(t.shiftKey||(this.store.dispatch(E1()),t.preventDefault(),!s&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(Ma()):this.stageSelectedSuggestion({inputType:"arrow"}))))};switch(t.key){case"Up":case"ArrowUp":s?c():u();return;case"Down":case"ArrowDown":{s?u():c();return}case"Esc":case"Escape":{s&&l&&this.store.dispatch(Wr(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Wr(-1)),this.store.dispatch(Ma()),t.preventDefault()):n||(this.store.dispatch(Qr({collapse:!0})),this.store.dispatch(NC(!0)),t.preventDefault());return}case"Tab":{let{userCommitted:p}=this.state.input,d=p.text.substring(0,p.selection.end),{tabCompletionSuggestion:m}=this.state.input;this.store.dispatch(il(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!s&&this.settings.showTabCompletion&&m&&m.text.startsWith(d)&&(this.store.dispatch(Cn({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Wn())),t.preventDefault();break}default:}}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(k1()),this.store.dispatch(En([]))}handlingTimeStart(){this.state.handlingTime.startTime||(F.info("Start handling time"),this.store.dispatch(jT()))}handlingTimeStop(){this.state.handlingTime.startTime&&(F.info("Stop handling time"),this.store.dispatch(xf()))}logSendMessage(t){let n=ek("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=JT(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(VT()))}notifySubmit(t={}){this.shouldAbort()||(this.store.dispatch(Wn()),this.store.dispatch(Ro(t.text??this.state.input.text)))}stageSelectedSuggestion(t){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:r}=this.state.input;this.store.dispatch(Cn({text:r[n].text,suggestion:r[n],eventMetrics:t,replace:"until-selection-end"}))}emit(t,n,r={}){let o=()=>{let i=this.eventListeners[t];i&&i.forEach(s=>{try{s(n)}catch(a){F.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),F.error(a)}})};this.inputMediator&&r.mayApplyChanges?this.inputMediator.applyChanges(o):o()}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=Pl(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,$t.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var s;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;if(i){let[a,l]=Pl(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});a.dataset.testid=n,a.style.zIndex="2",a.appendChild(r),this.unmountHandlers.push(()=>{(0,$t.unmountComponentAtNode)(o),l()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return jo(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,$t.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),F.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(F.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(R1(r.metrics))):F.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch{}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Ef(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:p,detectSubmit:d,insertLink:m,inputMediator:v,closestScrollSelector:y,appendOverlayTo:g,inlineSuggestions:f,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:m,isEmbedded:p,inlineSuggestions:f,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),jo(t),this.inputMediator=v||(Jr(t)?new Go(t):new qo(t)),this.inputMediator.on("change",({plainText:T})=>{this.notifyInputChanged(T)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(P1({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",T=>{this.notifyKeyDown(T)}),this.inputMediator.on("paste",({pastedText:T,selectionText:b})=>{this.notifyPaste(T,b)}),this.inputMediator.on("cut",({selectionText:T})=>{this.notifyCut(T)});let S=y&&tk(t,y)||void 0;if(f){let{customStyles:T,appendOverlayTo:b}=n;if(Jr(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let k=this.createInlineContainer(t,"deepdesk-caret");(0,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:T,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(jC,{})})}),k),this.inputMediator.on("caret",O=>{this.store.dispatch(En([])),O?(k.style.display="block",k.style.top=`${O.top}px`,k.style.left=`${O.left}px`):k.style.display="none"});let I=this.overlayContainerFactory("floating-menu",S||t,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:b},T==null?void 0:T.floatingMenuRootNode);(0,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:T,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(IC,{onLogIn:()=>this.loginViaPopup().catch(O=>F.warn(O.message))})})}),I)}else{let T=this.overlayContainerFactory("deepdesk-tab-completion",S||t,{appendTo:g,closestScrollElement:S,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),b=this.overlayContainerFactory("deepdesk-suggestions-overlay",S||t,{appendTo:g},r==null?void 0:r.suggestionsRootNode);(0,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:r,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(vb,{inputElement:t})})}),T),(0,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:r,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(QC,{onLogIn:()=>this.loginViaPopup().catch(k=>F.warn(k.message))})})}),b)}(0,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:r,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(kC,{})})}),this.createContainer("deepdesk-overlays"));let w;this.inputMediator.on("selection",T=>{clearTimeout(w),T===null?w=setTimeout(()=>{T!==null&&this.store.dispatch(Wg(T))},500):this.store.dispatch(Wg(T))}),this.inputMediator.on("disabled",()=>{var T;(T=this.inputMediator)==null||T.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(Dh(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Dh(!0))),this.store.dispatch(S1({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(Wn()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var T;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((T=this.state.conversation.current)==null?void 0:T.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&&F.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,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:r,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(NT,{onLogIn:()=>this.loginViaPopup().catch(s=>F.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,$t.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Tf(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){nk(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(nl());let t=er(this.state);t&&(await this.store.dispatch(Ja()),this.store.dispatch(Wc({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(t){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",p),clearInterval(d)};i.onmessage=async m=>{var v,y;if((v=m.data)!=null&&v.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((y=m.data)==null?void 0:y.jwt),await this.isLoggedIn(),this.broadcastEvents.send(Da),l=!0,o.port1.close(),n()}catch(g){console.error(g),r(g)}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 p=async m=>{var v;if(m.origin===a.origin)switch((v=m.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){F.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{u(),m.data.message==="Timeout"&&F.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(m.data.message));break}}};window.addEventListener("message",p);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)}async checkForTrialMode(t){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(F.info("Trial is active"),!await this.deepdeskApi.checkUserExists(t))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;F.info(r),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Nd(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(on()):Yl.includes(r)||this.store.dispatch(an(r))})}catch(r){this.handleError(r)}}};async function gk(e,t,n={}){let{value:r}=e,{start:o,end:i}=n.replace??{start:0,end:r.length},s=`${r.slice(0,o)}${t}${r.slice(i)}`,a=n.selectionAfter??{start:o+t.length,end:o+t.length},l=()=>{if(n.setValue)return n.setValue(s);e.value=s};return Promise.resolve(l()).then(()=>{e.selectionStart=a.start,e.selectionEnd=a.end,e.blur(),e.focus()})}async function hk(e,t,n={}){let r=n.replace?ro(e,n.replace.start,n.replace.end):ms(e),o,i=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),o=document.createElement("span"),r.insertNode(o),n.insertBRs!==!1?t.split(`
|
|
27
|
+
`);break}default:break}p&&s++}return l(e),a}var DT=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(DT||{}),lr=class{constructor(t){this.element=t;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}triggerChange(){let t=this.getText(),n=this.getHTML(),r=t!==this.currentText;this.isActive&&(t===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&r&&!this.isSubmitting&&this.emit("change",{plainText:t}),r&&(this.currentSelection=this.getSelection()),this.currentText=t,this.isSubmitting=!1,(this.currentHTML!==n||n===null&&r)&&(this.emit("updated",{plainText:t}),this.triggerCaretPosition(),this.currentHTML=n))}triggerSelection(){let t=this.getSelection();(t.start!==this.currentSelection.start||t.end!==this.currentSelection.end)&&(this.currentSelection=t,this.emit("selection",t),this.triggerCaretPosition())}triggerCaretPosition(){let t=this.getCaretPosition();jr(t,this.currentCaret)||(this.currentCaret=t,this.emit("caret",t))}handleKeyUp(t){let{key:n,shiftKey:r}=t;(n==="Enter"&&r===!0||n==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(DT).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(t={shouldObserve:!0}){this.addEventListener("keydown",r=>this.handleKeyDown(r)),this.addEventListener("keyup",r=>this.handleKeyUp(r)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",r=>this.handlePaste(r)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let n=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t!=null&&t.shouldObserve&&n.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{n.disconnect()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function FT(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var qo=class extends lr{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let t=new Range;return t.selectNodeContents(this.element),bl(this.element,t)}getHTML(){return this.element.innerHTML||""}getRange(){var i;let t=this.getRootNode();if(t.activeElement!==this.element)return null;let n="getSelection"in t?t.getSelection():window.getSelection();if(!n)return null;let r="getComposedRanges"in n&&t instanceof ShadowRoot?(i=n.getComposedRanges(t))==null?void 0:i[0]:n.rangeCount>0?n.getRangeAt(0):null;if(!r)return null;let o=this.element.ownerDocument.createRange();return o.setStart(r==null?void 0:r.startContainer,r==null?void 0:r.startOffset),o.setEnd(r==null?void 0:r.endContainer,r==null?void 0:r.endOffset),!o||!this.element.contains(o.startContainer)||!this.element.contains(o.endContainer)?null:o}getCaretPosition(){let t=this.getRange();if(!t||!t.collapsed||!("getBoundingClientRect"in t))return null;let n=t.getBoundingClientRect();return!FT(n)&&(t.insertNode(this.element.ownerDocument.createTextNode("\u2060")),n=t.getBoundingClientRect(),t.deleteContents(),!FT(n))?null:{top:n.top+n.height,left:n.left}}getSelection(){let t=this.getRange();if(t)return Cl(this.element,t);let n=this.lastKnownSelection;if(n&&_T(this.element,n.start,n.end))return n;let r=ms(this.element);return r.collapse(!1),Cl(this.element,r)}getSelectedText(){let{start:t,end:n}=this.getSelection();return bl(this.element,ro(this.element,t,n))}applyChanges(t){var o;if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);return(o=this.observer)==null||o.takeRecords(),Promise.resolve(r).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(t={shouldObserve:!0}){super.listen(t),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),t!=null&&t.shouldObserve&&this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let n=this.element.isContentEditable,r=new MutationObserver(()=>{this.element.isContentEditable!==n&&(n=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>r.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var Go=class extends lr{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:t,selectionEnd:n}=this.element;return{start:t,end:n}}getSelectedText(){let t=this.getSelection();return t?this.getText().slice(t.start,t.end):""}getCaretPosition(){return null}applyChanges(t){if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);return Promise.resolve(r).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let t=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var o;return(o=t==null?void 0:t.get)==null?void 0:o.call(this.element)},set:o=>{var i;(i=t==null?void 0:t.set)==null||i.call(this.element,o),this.triggerChange()}});let n=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==n&&(n=this.element.disabled,this.emit(n?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};function HT(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 FN(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}var vy=class{constructor(t){this.name=t;this.broadcastChannel=new BroadcastChannel(t)}broadcastChannel;disposeHandlers=[];onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},Sy=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.iframe=HT(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},xy=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),F.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 Sy(t,this.deepdeskUrl,{debug:!0}):new vy(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=FN(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(F.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;F.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({...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)}},UT=xy;var gs=class extends Error{constructor(n,r){super(n);this.body=r}name="CustomError"};var wy=e=>new Promise(t=>{setTimeout(t,e)});var hs=class extends gs{name="ClientError"},Cy=class extends gs{name="ServerError"},Ey=new Map;async function HN(e){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=await e.text();return n===""?null:(F.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))}var fn=class e{constructor(t="",n={}){this.baseUrl=t;this.options=n;n.fetch&&(this.fetch=n.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",{useCache:u=!1,abortLatest:c=!1,attempts:p=1,retryDelay:d=500,refreshTokenOn401:m=!0,retryOnError:v=b=>b instanceof TypeError,retryOnResponse:y=b=>b.status>=500,version:g="v1",...f}=n;if(u)if(l){if(Ey.has(s)){r(Ey.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h={credentials:"include",...f,headers:{"Content-Type":"application/json",...f.headers}};!l&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof g=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":g});let S=p,w=!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 T=async()=>(S--,a(s,h).then(async b=>y(b)&&!i.isAborted&&S>0?(await wy(d),T()):b.status===401&&m===!0&&w===!1?(w=!0,await this.refreshToken(),T()):b).catch(async b=>{if(v(b)&&!i.isAborted&&S>0)return await wy(d),T();throw b}));T().then(async b=>{let k=await HN(b);if(delete this.latestRequestByUrl[s],b.status>=500){o(new Cy("Server Error",k));return}else if(b.status===401){o(new hs("Unauthorized",k));return}else if(b.status===403){o(new hs("Forbidden",k));return}else if(b.status===404){o(new hs("Not Found",k));return}else if(b.status>=400){o(new hs("Bad Request",k));return}u&&Ey.set(s,k),r(k)}).catch(b=>{o(b)})})}async validateToken(){let{has_valid_access_token:t}=await this.get("/auth/validate");if(!t)return!1;let{is_logged_in:n}=await this.get("/apis/admin/session/validate/",{version:null});return!!n}refreshToken(){return e.refreshingToken||(e.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{e.refreshingToken=null},1e3*60)})),e.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,{method:"POST",body:JSON.stringify(n),...r})}patch(t,n,r){return this.request(t,{method:"PATCH",body:JSON.stringify(n),...r})}put(t,n,r){return this.request(t,{method:"PUT",body:JSON.stringify(n),...r})}delete(t,n){return this.request(t,{method:"DELETE",...n})}};var UN;(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||={})})(UN||={});function Sf(e){return{...J(e),tags:e.tags}}var ur=class e{constructor(t,n={}){this.options=n;this.client=new fn(t,{fetch:n.fetch}),this.client.patchFetch(r=>async(o,i)=>{let s=await r(o,i);return this.handleDeepdeskVersionHeaders(s),s})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=await this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(e.exchangeTokenPromise||(e.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),e.exchangeTokenPromise):Promise.resolve()}async createConversation(t){await this.preflight(),F.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=await this.client.post("/api/conversations",{...Re(t),tags:t.tags},{version:"v2"});return Sf(n)}async getProfile(t){let n=await this.client.get(`/apis/admin/profiles/${t}/`,{version:null,useCache:!0});return J(n)}async getKnowledgeAssistant(t){let n=await this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{version:null,useCache:!0});return J(n)}async getContentTypes(){let t=await this.client.get("/apis/admin/content-types/",{version:null,useCache:!0});return J(t)}async getAccount(){let t=await this.client.get("/apis/admin/account/",{version:null,useCache:!0});return J(t)}async getPlatformConfig(){let{config:t}=await this.client.get("/platform/config/",{version:null,useCache:!0});return J(t)}async checkUserExists(t){let{exists:n}=await this.client.get(`/apis/admin/users/exists?external_id=${t}`);return n}async getConversationBySessionId(t,n={}){await this.preflight(),F.info(`Getting conversation for session ${t}`);let{attempts:r=1,retryDelay:o=1e3}=n,i=await this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"});return F.info(`Successfully retrieved conversation ${i.id} for session ${t}`),Sf(i)}async isConversationSupported(t,n={}){F.info(`Check if conversation for session ${t} is supported`);let{attempts:r=1,retryDelay:o=1e3}=n;return(await this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"})).has_active_profile}async updateConversation(t,n){let r=Re(n);n.tags&&(r.tags=n.tags);let o=await this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Sf(o)}async postMessages(t,n){return(await this.client.post(`/api/conversations/${t}/messages`,n.map(o=>({...Re(o),tags:o.tags})),{version:"v2"})).map(o=>Sf(o))}async sendEvent(t,n){let{data:r,...o}=n,i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[a,l])=>({...s,[a]:l}),{});return this.client.post("/api/events",Re({...i,...o,data:r,name:t}),{version:"v2"})}async sendEventV1(t,n){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>({...o,[i]:s}),{});return this.client.post("/api/events",{event:t,data:Re({...n,...r})})}async getEntities(t){return(await this.client.post("/api/entities",{messages:t.filter(r=>r.text)})).entities}async getSummary(t,n={}){let r=await this.client.post("/api/summary",{conversation:{messages:t.filter(o=>o.text&&o.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model});return J(r)}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(t){return this.client.post("/apis/admin/session/jwt/",{jwt:t},{version:null}).catch(n=>{throw F.warn(`Invalid token '${t}'`),n})}async authenticateWithKey(t,n){await this.preflight(),await this.client.post("/apis/admin/session/api-key/",Re(n),{version:null,refreshTokenOn401:!1,headers:{apikey:t}})}async getTextSuggestions(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(await this.client.post(`/api/conversations/${t}/recommend/${r}`,Re(n),{abortLatest:!0})).map(i=>({...J(i),text:i.text||i.url||i.message,source:r,type:r})).filter((i,s,a)=>s===a.findIndex(l=>l.text===i.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(t,n){return(await this.client.post(`/api/conversations/${t}/autocomplete`,Re(n),{abortLatest:!0})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))}async getPinnedMessages(t){let n=await this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0});return J(n).map(r=>({...r,text:r.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(t){let n=await this.client.post("/api/style-suggestions",Re(t),{abortLatest:!0});return J(n)}async search(t){let n=await this.client.post(`/api/profiles/${t.profile}/search`,Re(t),{version:"v2"});return J(n)}async knowledgeAssist(t,n,r,o={}){let i=await this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Re({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(s=>({question:s.question,answer:s.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return J(i)}async requestLoginByEmail(t){let n=await this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return J(n)}async requestPasswordlessToken(){let t=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return J(t.token)}async getCsrfToken(){let{token:t}=await this.client.get("/apis/admin/session/csrf/",{version:null});return t}async verifyLoginToken(t){let n=await this.client.post("/apis/admin/session/passwordless/login/",{token:t},{version:null});return J(n)}async evaluateRule(t,n,r,o={}){let i=new URLSearchParams;o.raiseForFailingConditions&&i.set("raise_for_failing_conditions","true");let s=await this.client.post(`/api/conversations/${n}/rules/${t}/evaluate?${i.toString()}`,r,{version:"v2"});return J(s.cues)}async getRules(){let t=new URLSearchParams,n=await this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{version:null,useCache:!0});return J(n)}async translateMessages(t){let n=await this.client.post("/api/translate",Re(t),{version:"v2"});return J(n)}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Uv);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&F.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};var Tl=class{constructor(t,n){this.url=t;this.options={timeout:25e3,...n}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(t){this.eventSource.addEventListener($g(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,J(o))}catch{F.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 zN;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||={})})(zN||={});var kl=class{constructor(t,n={}){this.apiUrl=t;this.client=new fn(t,n)}client;streams={};logger=F;async getCustomMessages(t){let n=await this.client.get(`/sessions/${t}/suggestions`);return J(n.suggestions)}async sendCustomMessage(t,n){let r=await this.client.post(`/sessions/${t}/messages`,Re(n));return J(r)}async answerCustomMessage(t,n){await this.client.post(`/sessions/${t}/answers`,Re(n))}async getAutoflows(t){let n=await this.client.get(`/sessions/${t}/autoflows`);return J(n.autoflows)}async startAutoflowSession(t){let n=await this.client.post("/autoflow-sessions",Re(t));return J(n)}async stopAutoflowSession(t){await this.client.delete(`/autoflow-sessions/${t}`)}openStream(t){return this.streams[t]||(this.streams[t]=new Tl(`${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 zT={startTime:null,stopTime:null},BT=G({name:"handlingTime",initialState:zT,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(le,()=>zT)}}),{handlingTimeStart:jT,handlingTimeStop:xf,handlingTimeReset:VT}=BT.actions,KT=BT.reducer;var WT=(e={})=>{let t={onAuthError:$i(!1),...e};return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var wf={list:{keywordMatches:[]},fetchState:"idle"};var Xo=B("styleSuggestions/getAll",async({text:e},t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),{showStyleSuggestions:o}=r.settings,i=(s=r.conversation.current)==null?void 0:s.profileCode;if(!o)return wf.list;if(!i)throw new Error("No current conversation to fetch pinned messages");return n.getStyleSuggestions({profileCode:i,message:e})}),BN=G({name:"styleSuggestions",initialState:wf,reducers:{},extraReducers:e=>{e.addCase(Xo.pending,t=>{t.fetchState="loading"}).addCase(Xo.rejected,t=>{t.fetchState="error"}).addCase(Xo.fulfilled,(t,n)=>{t.fetchState="done",jr(t.list,n.payload)||(t.list=n.payload)}).addCase(Ro,t=>{t.list=wf.list}).addCase(le,()=>wf)}}),$T=BN.reducer;var qT=(e={})=>{let t,n=!0,r={getStyleSuggestions:Xo,debounce:500,...e};return o=>i=>s=>{var m;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(!((m=u.conversation.current)==null?void 0:m.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 jN(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var GT=(e={})=>{let t={getTextSuggestions:an,getAutocompleteSuggestions:rl,debounce:200,check:as,...e},n;return r=>o=>i=>{var y;let{input:{userCommitted:s}}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,p=(y=l.conversation.current)==null?void 0:y.id,d=i.type===Dd.toString();if(!p||!u&&!c)return a;let{input:{userCommitted:m}}=l;return jN(m,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let g=Xi(l);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var XT=Xo.fulfilled.toString();function VN(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 YT=e=>t=>n=>r=>{var u;if(r.type!==XT){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=VN(o,s);r.type===XT&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var KN=hc({answer:rC,auth:i1,autoflows:bb,conversation:m1,contentTypes:pE,customMessages:Mb,passwordlessToken:Db,entities:HE,knowledgeAssistant:eC,handlingTime:KT,info:_1,input:A1,settings:Zw,profile:aC,search:j1,summary:WE,styleSuggestions:$T,ui:DC,rules:Bb,textSuggestions:gC});function QT(e){return ow({reducer:KN,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),WT(),GT({debounce:200}),qT({debounce:500}),YT(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var WN=e=>{var t;return((t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())??"unknown"},$N=e=>t=>n=>r=>{var a,l,u,c,p,d;let o=t.getState(),i=Ug("inlineSuggestions")(o);switch(r.type){case $i.toString():{!r.payload&&e.emit("logout",void 0);break}case on.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 et.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 Jc.toString():e.handleKeyDown(r.payload);break;case Ro.toString():e.logSendMessage(r.payload);break;case ed.toString():e.handleInputChanged(r.payload);break;case Wo.fulfilled.toString():r.isBroadcasted||e.broadcast(Xg,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;default:break}let s=n(r);switch(r.type){case Ro.toString():e.handleAfterSendMessage(r.payload);break;case il.toString():e.onUpdateShowTabHint(r.payload);break;case xf.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case Cn.toString():{let{start:m,end:v}=o.input.selection;e.emit("select-suggestion",{type:WN(r.payload.suggestion),...r.payload,replace:r.payload.replace==="selection"?{start:m,end:v}:{start:0,end:v}},{mayApplyChanges:!0}),i&&(t.dispatch(En([])),t.dispatch(Wn()));break}case Zc.toString():{let{start:m,end:v}=o.input.selection;e.emit("replace",{...r.payload,replace:r.payload.replace==="selection"?{start:m,end:v}:{start:0,end:v}},{mayApplyChanges:!0});break}case Ma.toString():{let m=t.getState(),{text:v,selection:y}=m.input.userCommitted;e.emit("reset",{text:v,selectionAfter:y},{mayApplyChanges:!0});break}case td.toString():e.emit("select-image",r.payload,{mayApplyChanges:!0}),e.sendEvent("Image attached",{conversationId:(p=o.conversation.current)==null?void 0:p.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case En.toString():{i&&r.payload.length>0&&t.dispatch(Wr(0));break}case Qn.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload.summary,model:t.getState().summary.model}});break}default:break}return s},ZT=$N;function by(e){return e.toISOString().replace("T"," ").replace("Z","")}function JT(e,t){var i,s,a,l;let n=(i=e.conversation.current)==null?void 0:i.id;if(!n)return F.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:o}=e.handlingTime;return!r||!o?(F.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:by(r),timeStop:by(o)}}function ek(e,t,n){var I,O,M,W;let r=(I=t.conversation.current)==null?void 0:I.id;if(!r)return F.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:p,pastes:d,cuts:m,deletions:v,textSuggestions:y,offeredTextSuggestions:g}}=t[e],f=o.length,S=y.reduce((X,{text:ne,searchTerm:cr})=>X+ne.length-(cr?cr.length:0),0),w=c??Date.now(),T=(Date.now()-w)/1e3+(p||0),b=i/T,k=y.reduce((X,{searchTerm:ne})=>X+(ne?ne.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:m,deletions:v,lenTextTyped:i+k,lenTextTotal:f,lenTextAssisted:S,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:T,charsPerSecond:b,numPastes:u,textSuggestionsV2:y,suggestionsCounters:[{source:"gpt",countOffered:g.filter(X=>X.source==="gpt").length}],agentId:(O=t.info.agentInfo)==null?void 0:O.agentId,agentName:(M=t.info.agentInfo)==null?void 0:M.agentName,agentEmail:(W=t.info.agentInfo)==null?void 0:W.agentEmail}}function Ty(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return Ty(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?Ty(o,t):null}function tk(e,t){return Ty(e,t)}function nk(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function qN(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Ef(e){return qN(e)&&(Jr(e)||$d(e))}var ok,Rn=new Map,GN=["bottom","height","left","right","top","width"],rk=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:GN.some(n=>e[n]!==t[n]);function ik(e){var n,r;if(e.ownerDocument===document)return[];let t=((r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)??null;return t?[t,...ik(t)]:[]}function sk(e,t){return!e||!t?null:{...e,top:e.top+t.top,left:e.left+t.left}}var Cf=!1,ak=()=>{Cf=!0;let e=[];if(Rn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Rn.delete(n);return}let r=n.getBoundingClientRect();rk(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(sk,t.rect):t.rect;rk(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Rn.size===0){Cf=!1;return}ok=window.requestAnimationFrame(ak)};function ky(e,t){let n=ik(e),r=[],o=n.map((i,s)=>ky(i,a=>{r[s]=a;let l=Rn.get(e);if(!l)return;let u=r.reduce(sk,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Rn.has(e)){let s=Rn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Rn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Cf&&ak()},unobserve(){o.forEach(s=>s.unobserve());let i=Rn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Rn.delete(e),Rn.size||(cancelAnimationFrame(ok),Cf=!1)}}}}var lk,An=new Map,uk=()=>{An.forEach((e,t)=>{if(!t.isConnected){An.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(i=>i(e.visible)))}),An.size!==0&&(lk=window.requestAnimationFrame(uk))};function ck(e,t){return{observe(){let n=An.size===0;An.has(e)?An.get(e).callbacks.push(t):An.set(e,{visible:void 0,callbacks:[t]}),n&&uk()},unobserve(){let n=An.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||An.delete(e),An.size||cancelAnimationFrame(lk)}}}}var Py=["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 Ry(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ys(e){return parseFloat(e)}function bf(e){return Math.round(e*1e6)}function dk(e){return e/1e6}function Ay(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=ys(e.width),i=ys(e.borderLeftWidth),s=ys(e.borderRightWidth),a=ys(e.paddingRight),l=dk(bf(o)-bf(i)-bf(s)),u=dk(bf(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function Pl(e,t={}){var c;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=t.position??"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",jo(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};Ry(r,n,Py),Ay(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=ck(e,()=>{Ry(r,n,Py),Ay(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=ky(e,p=>{if(p===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),p.height===0&&p.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(Ry(r,n,Py),Ay(r,e,n),i(),n.style.top=`${p.top}px`,n.style.left=`${p.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let d=t.closestScrollElement.getBoundingClientRect(),m=window.getComputedStyle(t.closestScrollElement),v=ys(m.borderTopWidth),y=ys(m.borderBottomWidth),g=d.top+v-p.top,f=p.top+p.height+-(d.top+d.height-y);n.style.clipPath=`inset(${g}px 0px ${f}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(c=e.parentElement)==null||c.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var fk=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch{return t}}catch{return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch{F.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function XN(e){return e.offsetParent!==null}function pk(e){if(!XN(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 Tf(e,t,n=100){let r=pk(e);t({isVisible:r});let o=setInterval(()=>{let i=pk(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Ie=x(C());var mk=fk("showTabHint",!0),Rl=class e{static version="11.6.1-beta.1";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:t,brokerUrl:n,version:r=e.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){let u=t.replace(/\/api$/,"");this.deepdeskApi=new ur(u,{token:i,fetch:s}),this.version=r,this.instanceId=e.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[ZT({broadcast:(p,d,m)=>{this.broadcastEvents.send(p,d,m)},emit:(p,d,m)=>this.emit(p,d,m),handleAfterSendMessage:p=>this.handleAfterSendMessage(p),handleInputChanged:p=>this.handleInputChanged(p),handleKeyDown:p=>this.handleKeyDown(p),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:p=>this.logSendMessage(p),onUpdateShowTabHint:p=>mk.update(p),sendEvent:(p,d)=>this.deepdeskApi.sendEvent(p,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new kl(n)}),this.store=QT(c),this.broadcastEvents=new UT({debug:!0,deepdeskUrl:u,eventMap:V1(this.store),createCustomChannel:l}),this.store.dispatch(il(mk.value())),this.store.dispatch(Wc({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(F.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(F.warn("Profile has not been loaded (yet)"),!0):(F.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch($i(null)),this.store.dispatch(Vn()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();Je(r)&&Jw(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}async isLoggedIn(){return(await this.store.dispatch(Vn())).payload}async setPlatformAgentId(t){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:t}),version:null})}catch(n){F.warn("Failed to attach user:",n)}}async isConversationSupported(t,n){return(await this.store.dispatch(Vg({sessionId:t,options:n}))).payload}async createConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(qc(t))).payload}async getConversationBySessionId(t,n){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(await this.store.dispatch(Gc({sessionId:t,options:n}))).payload}async upsertConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(Kg(t))).payload}async postMessages(t){return(await this.store.dispatch(Yc(t))).payload}async updateConversation(t){return(await this.store.dispatch(Xc(t))).payload}resetConversation(){this.store.dispatch(le()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let t=await this.store.dispatch(Qn());if(t.error)throw new Error(t.error.message);return t.payload.summary}configure(t){this.store.dispatch(Wc(t))}setVisitorInfo(t){this.store.dispatch(M1(t))}setCustomData(t){this.store.dispatch(N1(t))}async setAgentInfo(t){await this.store.dispatch(Na(t))}async setAgentSettings(t){await this.store.dispatch(qg(t))}async getAgentSettings(){return(await this.store.dispatch(Gg())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let t=[];return this.store.dispatch(Dd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})}notifyInputChanged(t){this.store.dispatch(ed(t))}notifyKeyDown(t){this.store.dispatch(Jc(t))}notifyPaste(t,n){this.store.dispatch(T1({text:t,selectionText:n}))}notifyCut(t){this.store.dispatch(C1(t))}notifyExternalSuggestion(t){this.store.dispatch(Cn(t)),this.store.dispatch(Wn())}async evaluateRule(t,n={},r=Fb){return(await this.store.dispatch(Wo({label:t,params:n,options:r}))).payload.cues}handleInputChanged(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui;n&&r&&this.store.dispatch(Qr({collapse:!1})),this.inputMediator&&this.store.dispatch(v1({text:t,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(En([])))}handleKeyDown(t){let{overlayCollapsed:n}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:o,selection:i}=this.state.input,{inlineSuggestions:s}=this.state.settings,a=r.length>0,l=o!==-1;if(this.store.dispatch(b1(g1(t))),t.key!=="Tab"&&!this.settings.showTextSuggestions)return;let u=()=>{n||!a||i&&(t.shiftKey||(this.store.dispatch(x1()),s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault()))},c=()=>{n||!a||s&&o<=0||i&&(t.shiftKey||(this.store.dispatch(E1()),t.preventDefault(),!s&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(Ma()):this.stageSelectedSuggestion({inputType:"arrow"}))))};switch(t.key){case"Up":case"ArrowUp":s?c():u();return;case"Down":case"ArrowDown":{s?u():c();return}case"Esc":case"Escape":{s&&l&&this.store.dispatch(Wr(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Wr(-1)),this.store.dispatch(Ma()),t.preventDefault()):n||(this.store.dispatch(Qr({collapse:!0})),this.store.dispatch(NC(!0)),t.preventDefault());return}case"Tab":{let{userCommitted:p}=this.state.input,d=p.text.substring(0,p.selection.end),{tabCompletionSuggestion:m}=this.state.input;this.store.dispatch(il(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!s&&this.settings.showTabCompletion&&m&&m.text.startsWith(d)&&(this.store.dispatch(Cn({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Wn())),t.preventDefault();break}default:}}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(k1()),this.store.dispatch(En([]))}handlingTimeStart(){this.state.handlingTime.startTime||(F.info("Start handling time"),this.store.dispatch(jT()))}handlingTimeStop(){this.state.handlingTime.startTime&&(F.info("Stop handling time"),this.store.dispatch(xf()))}logSendMessage(t){let n=ek("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=JT(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(VT()))}notifySubmit(t={}){this.shouldAbort()||(this.store.dispatch(Wn()),this.store.dispatch(Ro(t.text??this.state.input.text)))}stageSelectedSuggestion(t){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:r}=this.state.input;this.store.dispatch(Cn({text:r[n].text,suggestion:r[n],eventMetrics:t,replace:"until-selection-end"}))}emit(t,n,r={}){let o=()=>{let i=this.eventListeners[t];i&&i.forEach(s=>{try{s(n)}catch(a){F.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),F.error(a)}})};this.inputMediator&&r.mayApplyChanges?this.inputMediator.applyChanges(o):o()}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=Pl(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,$t.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var s;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;if(i){let[a,l]=Pl(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});a.dataset.testid=n,a.style.zIndex="2",a.appendChild(r),this.unmountHandlers.push(()=>{(0,$t.unmountComponentAtNode)(o),l()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return jo(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,$t.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),F.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(F.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(R1(r.metrics))):F.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch{}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Ef(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:p,detectSubmit:d,insertLink:m,inputMediator:v,closestScrollSelector:y,appendOverlayTo:g,inlineSuggestions:f,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:m,isEmbedded:p,inlineSuggestions:f,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),jo(t),this.inputMediator=v||(Jr(t)?new Go(t):new qo(t)),this.inputMediator.on("change",({plainText:T})=>{this.notifyInputChanged(T)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(P1({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",T=>{this.notifyKeyDown(T)}),this.inputMediator.on("paste",({pastedText:T,selectionText:b})=>{this.notifyPaste(T,b)}),this.inputMediator.on("cut",({selectionText:T})=>{this.notifyCut(T)});let S=y&&tk(t,y)||void 0;if(f){let{customStyles:T,appendOverlayTo:b}=n;if(Jr(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let k=this.createInlineContainer(t,"deepdesk-caret");(0,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:T,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(jC,{})})}),k),this.inputMediator.on("caret",O=>{this.store.dispatch(En([])),O?(k.style.display="block",k.style.top=`${O.top}px`,k.style.left=`${O.left}px`):k.style.display="none"});let I=this.overlayContainerFactory("floating-menu",S||t,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:b},T==null?void 0:T.floatingMenuRootNode);(0,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:T,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(IC,{onLogIn:()=>this.loginViaPopup().catch(O=>F.warn(O.message))})})}),I)}else{let T=this.overlayContainerFactory("deepdesk-tab-completion",S||t,{appendTo:g,closestScrollElement:S,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),b=this.overlayContainerFactory("deepdesk-suggestions-overlay",S||t,{appendTo:g},r==null?void 0:r.suggestionsRootNode);(0,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:r,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(vb,{inputElement:t})})}),T),(0,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:r,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(QC,{onLogIn:()=>this.loginViaPopup().catch(k=>F.warn(k.message))})})}),b)}(0,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:r,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(kC,{})})}),this.createContainer("deepdesk-overlays"));let w;this.inputMediator.on("selection",T=>{clearTimeout(w),T===null?w=setTimeout(()=>{T!==null&&this.store.dispatch(Wg(T))},500):this.store.dispatch(Wg(T))}),this.inputMediator.on("disabled",()=>{var T;(T=this.inputMediator)==null||T.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(Dh(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Dh(!0))),this.store.dispatch(S1({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(Wn()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var T;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((T=this.state.conversation.current)==null?void 0:T.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&&F.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,$t.render)((0,Ie.jsx)(Ko,{store:this.store,customStyles:r,children:(0,Ie.jsx)(Lo,{broadcastEvents:this.broadcastEvents,children:(0,Ie.jsx)(NT,{onLogIn:()=>this.loginViaPopup().catch(s=>F.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,$t.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Tf(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){nk(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(nl());let t=er(this.state);t&&(await this.store.dispatch(Ja()),this.store.dispatch(Wc({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(t){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",p),clearInterval(d)};i.onmessage=async m=>{var v,y;if((v=m.data)!=null&&v.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((y=m.data)==null?void 0:y.jwt),await this.isLoggedIn(),this.broadcastEvents.send(Da),l=!0,o.port1.close(),n()}catch(g){console.error(g),r(g)}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 p=async m=>{var v;if(m.origin===a.origin)switch((v=m.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){F.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{u(),m.data.message==="Timeout"&&F.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(m.data.message));break}}};window.addEventListener("message",p);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)}async checkForTrialMode(t){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(F.info("Trial is active"),!await this.deepdeskApi.checkUserExists(t))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;F.info(r),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Nd(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(on()):Yl.includes(r)||this.store.dispatch(an(r))})}catch(r){this.handleError(r)}}};async function gk(e,t,n={}){let{value:r}=e,{start:o,end:i}=n.replace??{start:0,end:r.length},s=`${r.slice(0,o)}${t}${r.slice(i)}`,a=n.selectionAfter??{start:o+t.length,end:o+t.length},l=()=>{if(n.setValue)return n.setValue(s);e.value=s};return Promise.resolve(l()).then(()=>{e.selectionStart=a.start,e.selectionEnd=a.end,e.blur(),e.focus()})}async function hk(e,t,n={}){let r=n.replace?ro(e,n.replace.start,n.replace.end):ms(e),o,i=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),o=document.createElement("span"),r.insertNode(o),n.insertBRs!==!1?t.split(`
|
|
28
28
|
`).reverse().forEach((s,a)=>{a>0&&r.insertNode(document.createElement("br")),r.insertNode(document.createTextNode(s))}):r.insertNode(document.createTextNode(t))};return Promise.resolve(i()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let s=n.selectionAfter?ro(e,n.selectionAfter.start,n.selectionAfter.end):(r.collapse(!1),r),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(s)}if(!o)return;o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}function YN(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 QN(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 yk(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):yk(n,t)}async function vk(e,t,{isBlock:n,isHTML:r}={}){let o;e.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0}));let i=()=>{let s=e.ownerDocument.defaultView??window,a=s.getSelection();if((!a||a.rangeCount===0)&&(e.focus(),a=s.getSelection()),!a||a.rangeCount===0)return;let l=a.getRangeAt(0);if(!l)return;o=document.createElement("span"),l.insertNode(o);let u=r?YN(t):QN(t);n?yk(l.startContainer,u):(l.insertNode(u),l.collapse(!1))};return Promise.resolve(i()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!o)try{o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}function Sk(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function xk(e,t,n){await new ur(e).authenticateWithKey(t,n)}async function wk(e){let n=await new fn(e).get("/platform/config/",{version:null,useCache:!0});return J(n)}async function ZN(e){let n=await(e.fetch??window.fetch)(e.url),r=await n.blob();return new File([r],e.name,{type:e.mimeType??n.headers.get("Content-Type")??"image/jpeg"})}async function Ek(e,t){let n=await ZN(t),r=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(e,"files",{configurable:!0,get:()=>[n]}),e.dispatchEvent(r)}finally{Object.hasOwn(e,"files")&&delete e.files}}return Fk(JN);})();
|
|
30
30
|
/*! Bundled license information:
|