@deepdesk/deepdesk-sdk 10.1.8 → 10.1.9

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 CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var cd=Object.create;var hn=Object.defineProperty;var pd=Object.getOwnPropertyDescriptor;var ud=Object.getOwnPropertyNames;var dd=Object.getPrototypeOf,gd=Object.prototype.hasOwnProperty;var V=(t,e)=>{for(var o in e)hn(t,o,{get:e[o],enumerable:!0})},Ki=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ud(e))!gd.call(t,s)&&s!==o&&hn(t,s,{get:()=>e[s],enumerable:!(n=pd(e,s))||n.enumerable});return t};var T=(t,e,o)=>(o=t!=null?cd(dd(t)):{},Ki(e||!t||!t.__esModule?hn(o,"default",{value:t,enumerable:!0}):o,t)),md=t=>Ki(hn({},"__esModule",{value:!0}),t);var xf={};V(xf,{Card:()=>F,Chip:()=>ea,ContentEditableInput:()=>Nt,DeepdeskAPI:()=>tt,DeepdeskSDK:()=>mn,HTTPClient:()=>Ie,InputMediator:()=>He,InputType:()=>rt,KeyboardHint:()=>Hn,Label:()=>Bn,Locale:()=>Io,Section:()=>st,SectionList:()=>Fn,Sources:()=>Le,Suggestion:()=>N,SuggestionList:()=>Re,TextAreaInput:()=>Be,ToggleButton:()=>Et,attachFile:()=>Ju,authenticateWithKey:()=>Qu,createOverlayContainer:()=>Zt,createRangeFromOffsets:()=>Ot,escapeHTML:()=>fo,fetchPlatformConfig:()=>Zu,formatTextMarkup:()=>Xu,getRangeOffsets:()=>Qs,getRangeText:()=>un,isSupportedInputElement:()=>tr,updateContentEditable:()=>$u,updateTextArea:()=>Gu,useStyles:()=>y,waitForElementVisibilityChange:()=>or});module.exports=md(xf);var vn=T(require("classnames")),de=T(require("react"));var yn=T(require("react")),Ui=T(require("classnames")),Co=yn.default.createContext({});function y(t,e){let{debug:o,...n}=(0,yn.useContext)(Co),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,Ui.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var zi={root:"_root_vr71j_1"};var Ct=require("react/jsx-runtime"),Sn=()=>(0,Ct.jsxs)("svg",{className:zi.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Ct.jsx)("defs",{children:(0,Ct.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Ct.jsx)("title",{children:"Failed loading image"}),(0,Ct.jsx)("path",{className:"cls-1",d:"M15 130.896V16.994c0-1.097.898-1.994 2.007-1.994h150.986A2 2 0 0 1 170 16.994v69.147L133.015 51 87.26 120.377l-35.863-17.758L15 130.896zM2 0C.895 0 0 .887 0 2v166c0 1.105.887 2 2 2h181c1.105 0 2-.887 2-2V2c0-1.105-.887-2-2-2H2zm49 72c11.046 0 20-9.178 20-20.5S62.046 31 51 31s-20 9.178-20 20.5S39.954 72 51 72z",fillRule:"evenodd"})]});var ir={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};var wt=require("react/jsx-runtime"),_n=(0,de.createContext)(ir),fd=({title:t,src:e})=>{let o=(0,de.useContext)(_n),[n,s]=(0,de.useState)(!1);return(0,de.useEffect)(()=>{s(!1)},[e]),(0,wt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,wt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,wt.jsx)(Sn,{})})},hd=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,de.useContext)(_n);return(0,wt.jsx)("div",{className:(0,vn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},yd=({as:t="h1",cropText:e=!1,className:o,children:n})=>{let s=(0,de.useContext)(_n);return de.default.createElement(t,{className:(0,vn.default)(s.title,o,{[s.contentIsCropped]:e})},n)},xn=({children:t})=>{let e=y("Card",ir);return(0,wt.jsx)("div",{className:(0,vn.default)(e.root),children:(0,wt.jsx)(_n.Provider,{value:e,children:t})})};xn.Image=fd;xn.Content=hd;xn.Title=yd;var F=xn;var ji={root:"_root_nkim0_1"};var Nn=require("react");var ar=function(t,e){return ar=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(o[s]=n[s])},ar(t,e)};function wo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ar(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var re=function(){return re=Object.assign||function(e){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},re.apply(this,arguments)};function Vi(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(o[n[s]]=t[n[s]]);return o}function bn(t,e,o){if(o||arguments.length===2)for(var n=0,s=e.length,r;n<s;n++)(r||!(n in e))&&(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))}var Cn;(function(t){t[t.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",t[t.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",t[t.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",t[t.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",t[t.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",t[t.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",t[t.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",t[t.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",t[t.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",t[t.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",t[t.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",t[t.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",t[t.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",t[t.INVALID_TAG=23]="INVALID_TAG",t[t.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",t[t.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",t[t.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(Cn||(Cn={}));var wn=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var be;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(be||(be={}));var Tn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Tn||(Tn={}));function lr(t){return t.type===be.literal}function qi(t){return t.type===be.argument}function En(t){return t.type===be.number}function kn(t){return t.type===be.date}function Pn(t){return t.type===be.time}function In(t){return t.type===be.select}function Rn(t){return t.type===be.plural}function Wi(t){return t.type===be.pound}function Ln(t){return t.type===be.tag}function An(t){return!!(t&&typeof t=="object"&&t.type===Tn.number)}function To(t){return!!(t&&typeof t=="object"&&t.type===Tn.dateTime)}function cr(t){t.forEach(function(e){if(delete e.location,In(e)||Rn(e))for(var o in e.options)delete e.options[o].location,cr(e.options[o].value);else En(e)&&An(e.style)||(kn(e)||Pn(e))&&To(e.style)?delete e.style.location:Ln(e)&&cr(e.children)})}function Gi(t,e){e===void 0&&(e={}),e=re({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new wn(t,e).parse();if(o.err){var n=SyntaxError(Cn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||cr(o.val),o.val}function Mn(t,e){var o=e&&e.cache?e.cache:Cd,n=e&&e.serializer?e.serializer:bd,s=e&&e.strategy?e.strategy:vd;return s(t,{cache:o,serializer:n})}function Sd(t){return t==null||typeof t=="number"||typeof t=="boolean"}function $i(t,e,o,n){var s=Sd(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Xi(t,e,o){var n=Array.prototype.slice.call(arguments,3),s=o(n),r=e.get(s);return typeof r>"u"&&(r=t.apply(this,n),e.set(s,r)),r}function pr(t,e,o,n,s){return o.bind(e,t,n,s)}function vd(t,e){var o=t.length===1?$i:Xi;return pr(t,this,o,e.cache.create(),e.serializer)}function _d(t,e){return pr(t,this,Xi,e.cache.create(),e.serializer)}function xd(t,e){return pr(t,this,$i,e.cache.create(),e.serializer)}var bd=function(){return JSON.stringify(arguments)};function ur(){this.cache=Object.create(null)}ur.prototype.get=function(t){return this.cache[t]};ur.prototype.set=function(t,e){this.cache[t]=e};var Cd={create:function(){return new ur}},On={variadic:_d,monadic:xd};var Tt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Tt||(Tt={}));var Eo=function(t){wo(e,t);function e(o,n,s){var r=t.call(this,o)||this;return r.code=n,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var dr=function(t){wo(e,t);function e(o,n,s,r){return t.call(this,'Invalid values for "'.concat(o,'": "').concat(n,'". Options are "').concat(Object.keys(s).join('", "'),'"'),Tt.INVALID_VALUE,r)||this}return e}(Eo);var Qi=function(t){wo(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Tt.INVALID_VALUE,s)||this}return e}(Eo);var Zi=function(t){wo(e,t);function e(o,n){return t.call(this,'The intl string context variable "'.concat(o,'" was not provided to the string "').concat(n,'"'),Tt.MISSING_VALUE,n)||this}return e}(Eo);var G;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(G||(G={}));function wd(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==G.literal||o.type!==G.literal?e.push(o):n.value+=o.value,e},[])}function Td(t){return typeof t=="function"}function ko(t,e,o,n,s,r,i){if(t.length===1&&lr(t[0]))return[{type:G.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(lr(p)){a.push({type:G.literal,value:p.value});continue}if(Wi(p)){typeof r=="number"&&a.push({type:G.literal,value:o.getNumberFormat(e).format(r)});continue}var u=p.value;if(!(s&&u in s))throw new Zi(u,i);var d=s[u];if(qi(p)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?G.literal:G.object,value:d});continue}if(kn(p)){var m=typeof p.style=="string"?n.date[p.style]:To(p.style)?p.style.parsedOptions:void 0;a.push({type:G.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(Pn(p)){var m=typeof p.style=="string"?n.time[p.style]:To(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:G.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(En(p)){var m=typeof p.style=="string"?n.number[p.style]:An(p.style)?p.style.parsedOptions:void 0;m&&m.scale&&(d=d*(m.scale||1)),a.push({type:G.literal,value:o.getNumberFormat(e,m).format(d)});continue}if(Ln(p)){var h=p.children,g=p.value,v=s[g];if(!Td(v))throw new Qi(g,"function",i);var k=ko(h,e,o,n,s,r),f=v(k.map(function(w){return w.value}));Array.isArray(f)||(f=[f]),a.push.apply(a,f.map(function(w){return{type:typeof w=="string"?G.literal:G.object,value:w}}))}if(In(p)){var _=p.options[d]||p.options.other;if(!_)throw new dr(p.value,d,Object.keys(p.options),i);a.push.apply(a,ko(_.value,e,o,n,s));continue}if(Rn(p)){var _=p.options["=".concat(d)];if(!_){if(!Intl.PluralRules)throw new Eo(`Intl.PluralRules is not available in this environment.
1
+ "use strict";var cd=Object.create;var hn=Object.defineProperty;var pd=Object.getOwnPropertyDescriptor;var ud=Object.getOwnPropertyNames;var dd=Object.getPrototypeOf,gd=Object.prototype.hasOwnProperty;var V=(t,e)=>{for(var o in e)hn(t,o,{get:e[o],enumerable:!0})},Ki=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ud(e))!gd.call(t,s)&&s!==o&&hn(t,s,{get:()=>e[s],enumerable:!(n=pd(e,s))||n.enumerable});return t};var T=(t,e,o)=>(o=t!=null?cd(dd(t)):{},Ki(e||!t||!t.__esModule?hn(o,"default",{value:t,enumerable:!0}):o,t)),md=t=>Ki(hn({},"__esModule",{value:!0}),t);var xf={};V(xf,{Card:()=>F,Chip:()=>ea,ContentEditableInput:()=>Dt,DeepdeskAPI:()=>tt,DeepdeskSDK:()=>mn,HTTPClient:()=>Ie,InputMediator:()=>He,InputType:()=>rt,KeyboardHint:()=>Hn,Label:()=>Bn,Locale:()=>Io,Section:()=>st,SectionList:()=>Fn,Sources:()=>Ce,Suggestion:()=>N,SuggestionList:()=>Le,TextAreaInput:()=>Be,ToggleButton:()=>Et,attachFile:()=>Ju,authenticateWithKey:()=>Qu,createOverlayContainer:()=>Jt,createRangeFromOffsets:()=>Nt,escapeHTML:()=>ho,fetchPlatformConfig:()=>Zu,formatTextMarkup:()=>Xu,getRangeOffsets:()=>Qs,getRangeText:()=>un,isSupportedInputElement:()=>or,updateContentEditable:()=>$u,updateTextArea:()=>Gu,useStyles:()=>y,waitForElementVisibilityChange:()=>nr});module.exports=md(xf);var vn=T(require("classnames")),de=T(require("react"));var yn=T(require("react")),Ui=T(require("classnames")),wo=yn.default.createContext({});function y(t,e){let{debug:o,...n}=(0,yn.useContext)(wo),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,Ui.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var zi={root:"_root_vr71j_1"};var Ct=require("react/jsx-runtime"),Sn=()=>(0,Ct.jsxs)("svg",{className:zi.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Ct.jsx)("defs",{children:(0,Ct.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Ct.jsx)("title",{children:"Failed loading image"}),(0,Ct.jsx)("path",{className:"cls-1",d:"M15 130.896V16.994c0-1.097.898-1.994 2.007-1.994h150.986A2 2 0 0 1 170 16.994v69.147L133.015 51 87.26 120.377l-35.863-17.758L15 130.896zM2 0C.895 0 0 .887 0 2v166c0 1.105.887 2 2 2h181c1.105 0 2-.887 2-2V2c0-1.105-.887-2-2-2H2zm49 72c11.046 0 20-9.178 20-20.5S62.046 31 51 31s-20 9.178-20 20.5S39.954 72 51 72z",fillRule:"evenodd"})]});var ar={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};var wt=require("react/jsx-runtime"),_n=(0,de.createContext)(ar),fd=({title:t,src:e})=>{let o=(0,de.useContext)(_n),[n,s]=(0,de.useState)(!1);return(0,de.useEffect)(()=>{s(!1)},[e]),(0,wt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,wt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,wt.jsx)(Sn,{})})},hd=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,de.useContext)(_n);return(0,wt.jsx)("div",{className:(0,vn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},yd=({as:t="h1",cropText:e=!1,className:o,children:n})=>{let s=(0,de.useContext)(_n);return de.default.createElement(t,{className:(0,vn.default)(s.title,o,{[s.contentIsCropped]:e})},n)},xn=({children:t})=>{let e=y("Card",ar);return(0,wt.jsx)("div",{className:(0,vn.default)(e.root),children:(0,wt.jsx)(_n.Provider,{value:e,children:t})})};xn.Image=fd;xn.Content=hd;xn.Title=yd;var F=xn;var ji={root:"_root_nkim0_1"};var Nn=require("react");var lr=function(t,e){return lr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(o[s]=n[s])},lr(t,e)};function To(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");lr(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var re=function(){return re=Object.assign||function(e){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},re.apply(this,arguments)};function Vi(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(o[n[s]]=t[n[s]]);return o}function bn(t,e,o){if(o||arguments.length===2)for(var n=0,s=e.length,r;n<s;n++)(r||!(n in e))&&(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))}var Cn;(function(t){t[t.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",t[t.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",t[t.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",t[t.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",t[t.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",t[t.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",t[t.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",t[t.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",t[t.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",t[t.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",t[t.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",t[t.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",t[t.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",t[t.INVALID_TAG=23]="INVALID_TAG",t[t.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",t[t.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",t[t.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(Cn||(Cn={}));var wn=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var be;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(be||(be={}));var Tn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Tn||(Tn={}));function cr(t){return t.type===be.literal}function qi(t){return t.type===be.argument}function En(t){return t.type===be.number}function kn(t){return t.type===be.date}function Pn(t){return t.type===be.time}function Rn(t){return t.type===be.select}function In(t){return t.type===be.plural}function Wi(t){return t.type===be.pound}function Ln(t){return t.type===be.tag}function An(t){return!!(t&&typeof t=="object"&&t.type===Tn.number)}function Eo(t){return!!(t&&typeof t=="object"&&t.type===Tn.dateTime)}function pr(t){t.forEach(function(e){if(delete e.location,Rn(e)||In(e))for(var o in e.options)delete e.options[o].location,pr(e.options[o].value);else En(e)&&An(e.style)||(kn(e)||Pn(e))&&Eo(e.style)?delete e.style.location:Ln(e)&&pr(e.children)})}function Gi(t,e){e===void 0&&(e={}),e=re({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new wn(t,e).parse();if(o.err){var n=SyntaxError(Cn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||pr(o.val),o.val}function Mn(t,e){var o=e&&e.cache?e.cache:Cd,n=e&&e.serializer?e.serializer:bd,s=e&&e.strategy?e.strategy:vd;return s(t,{cache:o,serializer:n})}function Sd(t){return t==null||typeof t=="number"||typeof t=="boolean"}function $i(t,e,o,n){var s=Sd(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Xi(t,e,o){var n=Array.prototype.slice.call(arguments,3),s=o(n),r=e.get(s);return typeof r>"u"&&(r=t.apply(this,n),e.set(s,r)),r}function ur(t,e,o,n,s){return o.bind(e,t,n,s)}function vd(t,e){var o=t.length===1?$i:Xi;return ur(t,this,o,e.cache.create(),e.serializer)}function _d(t,e){return ur(t,this,Xi,e.cache.create(),e.serializer)}function xd(t,e){return ur(t,this,$i,e.cache.create(),e.serializer)}var bd=function(){return JSON.stringify(arguments)};function dr(){this.cache=Object.create(null)}dr.prototype.get=function(t){return this.cache[t]};dr.prototype.set=function(t,e){this.cache[t]=e};var Cd={create:function(){return new dr}},On={variadic:_d,monadic:xd};var Tt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Tt||(Tt={}));var ko=function(t){To(e,t);function e(o,n,s){var r=t.call(this,o)||this;return r.code=n,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var gr=function(t){To(e,t);function e(o,n,s,r){return t.call(this,'Invalid values for "'.concat(o,'": "').concat(n,'". Options are "').concat(Object.keys(s).join('", "'),'"'),Tt.INVALID_VALUE,r)||this}return e}(ko);var Qi=function(t){To(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Tt.INVALID_VALUE,s)||this}return e}(ko);var Zi=function(t){To(e,t);function e(o,n){return t.call(this,'The intl string context variable "'.concat(o,'" was not provided to the string "').concat(n,'"'),Tt.MISSING_VALUE,n)||this}return e}(ko);var G;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(G||(G={}));function wd(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==G.literal||o.type!==G.literal?e.push(o):n.value+=o.value,e},[])}function Td(t){return typeof t=="function"}function Po(t,e,o,n,s,r,i){if(t.length===1&&cr(t[0]))return[{type:G.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(cr(p)){a.push({type:G.literal,value:p.value});continue}if(Wi(p)){typeof r=="number"&&a.push({type:G.literal,value:o.getNumberFormat(e).format(r)});continue}var u=p.value;if(!(s&&u in s))throw new Zi(u,i);var d=s[u];if(qi(p)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?G.literal:G.object,value:d});continue}if(kn(p)){var m=typeof p.style=="string"?n.date[p.style]:Eo(p.style)?p.style.parsedOptions:void 0;a.push({type:G.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(Pn(p)){var m=typeof p.style=="string"?n.time[p.style]:Eo(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:G.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(En(p)){var m=typeof p.style=="string"?n.number[p.style]:An(p.style)?p.style.parsedOptions:void 0;m&&m.scale&&(d=d*(m.scale||1)),a.push({type:G.literal,value:o.getNumberFormat(e,m).format(d)});continue}if(Ln(p)){var h=p.children,g=p.value,v=s[g];if(!Td(v))throw new Qi(g,"function",i);var k=Po(h,e,o,n,s,r),f=v(k.map(function(w){return w.value}));Array.isArray(f)||(f=[f]),a.push.apply(a,f.map(function(w){return{type:typeof w=="string"?G.literal:G.object,value:w}}))}if(Rn(p)){var _=p.options[d]||p.options.other;if(!_)throw new gr(p.value,d,Object.keys(p.options),i);a.push.apply(a,Po(_.value,e,o,n,s));continue}if(In(p)){var _=p.options["=".concat(d)];if(!_){if(!Intl.PluralRules)throw new ko(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,Tt.MISSING_INTL_API,i);var x=o.getPluralRules(e,{type:p.pluralType}).select(d-(p.offset||0));_=p.options[x]||p.options.other}if(!_)throw new dr(p.value,d,Object.keys(p.options),i);a.push.apply(a,ko(_.value,e,o,n,s,d-(p.offset||0)));continue}}return wd(a)}function Ed(t,e){return e?re(re(re({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=re(re({},t[n]),e[n]||{}),o},{})):t}function kd(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Ed(t[n],e[n]),o},re({},t)):t}function gr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Pd(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Mn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,bn([void 0],o,!1)))},{cache:gr(t.number),strategy:On.variadic}),getDateTimeFormat:Mn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,bn([void 0],o,!1)))},{cache:gr(t.dateTime),strategy:On.variadic}),getPluralRules:Mn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,bn([void 0],o,!1)))},{cache:gr(t.pluralRules),strategy:On.variadic})}}var Ji=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var u=p.reduce(function(d,m){return!d.length||m.type!==G.literal||typeof d[d.length-1]!="string"?d.push(m.value):d[d.length-1]+=m.value,d},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(c){return ko(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,l=Vi(i,["formatters"]);this.ast=t.__parse(e,re(re({},l),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=kd(t.formats,n),this.formatters=s&&s.formatters||Pd(this.formatterCache)}return Object.defineProperty(t,"defaultLocale",{get:function(){return t.memoizedDefaultLocale||(t.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),t.memoizedDefaultLocale},enumerable:!1,configurable:!0}),t.memoizedDefaultLocale=null,t.resolveLocale=function(e){if(!(typeof Intl.Locale>"u")){var o=Intl.NumberFormat.supportedLocalesOf(e);return o.length>0?new Intl.Locale(o[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Gi,t.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},t}();function Id(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Rd="dummy",mr=(0,Nn.createContext)(null);function E(t){let e=(0,Nn.useContext)(mr);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let o=t[e]??{};return(n,s)=>{let r=Id(o,n);return r?new Ji(r).format(s):(e!==Rd&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var fr={};V(fr,{enUS:()=>Ld,nlNL:()=>Ad});var Ld={experimental:[{type:0,value:"Experimental"}]},Ad={experimental:[{type:0,value:"Experimenteel"}]};var hr=require("react/jsx-runtime"),Yi=({children:t})=>{let e=y("Chip",ji);return(0,hr.jsx)("span",{className:e.root,children:t})},Dn=()=>{let t=E(fr);return(0,hr.jsx)(Yi,{children:t("experimental")})},ea=Yi;var oa=T(require("classnames"));var ta={root:"_root_cq1yq_1"};var na=require("react/jsx-runtime");var Md={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Od=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",ta);return(0,na.jsx)("span",{"data-key":Md[e],className:(0,oa.default)(t,n.root),...o})},Hn=Od;var ra=T(require("classnames"));var sa={root:"_root_4a08n_1"};var ia=require("react/jsx-runtime"),Nd=({className:t,children:e,...o})=>{let n=y("Label",sa);return(0,ia.jsx)("span",{...o,className:(0,ra.default)(t,n.root),children:e})},Bn=Nd;var aa={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var Ft=require("react/jsx-runtime"),Dd=({title:t,children:e,type:o,...n})=>{let s=y("Section",aa);return(0,Ft.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,Ft.jsx)("div",{className:s.subTitleContainer,children:(0,Ft.jsx)("span",{className:s.subtitle,children:t})}),(0,Ft.jsx)("div",{className:s.suggestions,children:e})]})},st=Dd;var ca=T(require("classnames")),pa=T(require("react"));var la={root:"_root_19wxp_1"};var ua=require("react/jsx-runtime"),Hd=pa.default.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",la);return(0,ua.jsx)("div",{ref:o,className:(0,ca.default)(n.root,t),children:e})}),Fn=Hd;var Po=T(require("classnames")),me=T(require("react"));var yr={root:"_root_9kn3u_10",fadein:"_fadein_9kn3u_1",isClickable:"_isClickable_9kn3u_47",isSelected:"_isSelected_9kn3u_52",actions:"_actions_9kn3u_76",actionsIsFixed:"_actionsIsFixed_9kn3u_98",actionButton:"_actionButton_9kn3u_106",dropdownList:"_dropdownList_9kn3u_127",dropdownButton:"_dropdownButton_9kn3u_142",dropdownItem:"_dropdownItem_9kn3u_152",dropdownItemButton:"_dropdownItemButton_9kn3u_161",actionButtonIsPrimary:"_actionButtonIsPrimary_9kn3u_175",actionButtonIsDisabled:"_actionButtonIsDisabled_9kn3u_179",labels:"_labels_9kn3u_187",label:"_label_9kn3u_187"};var ge=require("react/jsx-runtime"),Kt=(0,me.createContext)(yr),Bd=({fixed:t,children:e,...o})=>{let n=(0,me.useContext)(Kt);return(0,ge.jsx)("div",{...o,className:(0,Po.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Fd=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,me.useContext)(Kt);return(0,ge.jsxs)("div",{className:(0,Po.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,ge.jsx)("ul",{className:r.dropdownList,children:s})]})},Kd=({index:t,label:e,onClick:o})=>{let n=(0,me.useContext)(Kt);return(0,ge.jsx)("li",{className:n.dropdownItem,children:(0,ge.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Ud=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,me.useContext)(Kt);return(0,ge.jsx)("button",{type:"button",className:(0,Po.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Sr=({labels:t})=>{let e=(0,me.useContext)(Kt);return(0,ge.jsx)("div",{className:e.labels,children:t.map(o=>(0,ge.jsx)("span",{className:e.label,children:o},o))})},Ut=me.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",yr),l=(0,me.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,ge.jsx)(s,{...r,ref:i,className:(0,Po.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,ge.jsx)(Kt.Provider,{value:a,children:n})})});Ut.Labels=Sr;Ut.Actions=Bd;Ut.ActionButton=Ud;Ut.DropdownButton=Fd;Ut.DropdownItem=Kd;var N=Ut;var ga=T(require("classnames"));var da={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var ma=require("react/jsx-runtime"),zd=({withDivider:t,children:e})=>{let o=y("SuggestionList",da);return(0,ma.jsx)("div",{className:(0,ga.default)(o.root,{[o.isWithDivider]:t}),children:e})},Re=zd;var ha=T(require("classnames"));var fa={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Kn=require("react/jsx-runtime"),jd=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",fa);return(0,Kn.jsx)("button",{type:"button",className:(0,ha.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,Kn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Kn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Et=jd;var ya=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,zt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Sa=/x-deepdesk-(([a-z0-9\-_])+-version)/,Le=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(Le||{}),rt=(s=>(s.TAB="tab",s.ARROW="arrow",s.HOTKEY="hotkey",s.MOUSE="mouse",s))(rt||{});var ot=require("react-dom");var jc=require("react");var va=require("@reduxjs/toolkit"),_a=require("react-redux");var Io=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Io||{});var Vd={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showPersonalCollectionLink:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,adminUrl:void 0,productName:"Deepdesk"},xa=(0,va.createSlice)({name:"settings",initialState:Vd,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Ro}=xa.actions,vr=t=>e=>e.settings[t],b=t=>(0,_a.useSelector)(vr(t)),ba=xa.reducer;var pc=require("react"),lo=require("react-redux");var Ae=require("@reduxjs/toolkit"),ka=require("diff"),Pa=require("react-redux");function Ca(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function it(t,e,o=10){let n=typeof t,s=typeof e;if(o===0)throw new Error("Max depth deepEqual, possible circular references?");return n!==s?!1:t==null||n==="string"||n==="number"||n==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>it(r,e[i],o-1)):Ca(t)&&Ca(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>it(t[i],e[i],o-1)):!1}function qd(t){return Math.max(...t.map(e=>e.length))}function Wd(t,e){let o=t.reduce((n,s)=>{if(s){let r=n[s]?n[s]+1:1;return{...n,[s]:r}}return n},{});return Object.keys(o).reduce((n,s)=>(o[s]<e&&n.push(s),n),[])}function wa(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<qd(n);s++){let r=Wd(n.map(a=>a[s]),e),i=n.filter(a=>!r.includes(a[s]));if(i.length>=e)n=i;else return{text:n[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Gd=2;function _r(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=wa(t,Gd);return o&&o.text!==e?o:t[0]}var Ce=require("@reduxjs/toolkit"),Ta={current:null,isSupported:null},L=(0,Ce.createAction)("resetConversation"),Un=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},zn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},jn=t=>t.conversation.isSupported,xr=(0,Ce.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Vn=(0,Ce.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),qn=(0,Ce.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Wn=(0,Ce.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=zn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),br=(0,Ce.createAsyncThunk)("conversation/upsert",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId).catch(()=>null).then(n=>{if(!n)return o.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),Gn=(0,Ce.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=zn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),$d=[Vn.rejected,qn.rejected,Wn.rejected,Gn.rejected].map(t=>t==null?void 0:t.toString()),Xd=(0,Ce.createSlice)({name:"conversation",initialState:Ta,reducers:{},extraReducers:t=>{t.addCase(xr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Vn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(qn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(br.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Wn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Gn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(L,()=>Ta).addMatcher(e=>$d.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),Ea=Xd.reducer;var at={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Xn(t){let{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}=t;return{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}}var Qn=(0,Ae.createAction)("input/replaceText"),Zn=(0,Ae.createAction)("input/keyDown"),Lo=(0,Ae.createAction)("input/sendMessage"),Jn=(0,Ae.createAction)("input/sendEditSuggestionMessage"),Yn=(0,Ae.createAction)("input/uiInputChange"),es=(0,Ae.createAction)("input/applyImageSuggestion"),ie=(0,Ae.createAction)("input/sendEvent");function $n(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,u=o==="search"||o==="personal-collection-search",d=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(u||p==="selection")&&(d=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(d=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:d,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:u?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var Ia=t=>(0,Ae.createSlice)({name:t,initialState:at,reducers:{initialInput(e,o){let{text:n,selection:s,html:r}=o.payload;e.text=n,e.selection.start=(s==null?void 0:s.start)??n.length,e.selection.end=(s==null?void 0:s.end)??n.length,e.userCommitted.text=n,e.userCommitted.selection.start=(s==null?void 0:s.start)??n.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??n.length,e.html=r||null},reset(e){Object.assign(e,{...at,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=_r(e.textSuggestions,e.userCommitted.text)},setInputHtml(e,o){e.html=o.payload},changeSelection(e,o){o.payload&&(it(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&$n(e)))},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:u,ctrlKey:d,metaKey:m,altKey:h}=e.previousKeyDownEvent;switch(p){case"Enter":u&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=e,{text:v}=o.payload,k=(0,ka.diffChars)(g,v);g.length-v.length>1&&e.metrics.deletions.push(...k.filter(f=>f.removed).map(f=>f.value)),e.metrics.numCharsDeleted+=g.length-v.length;break}case"C":case"V":case"X":if(!d&&!m){e.metrics.numCharsTyped+=1;let g=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}break;case"Shift":break;default:if(!d&&!m&&!h){e.metrics.numCharsTyped+=1;let g=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=at.metrics,e.textSuggestions=[]),e.text!==o.payload.text&&$n(e);let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end,e.userCommitted.selection.start=r.start,e.userCommitted.selection.end=r.end),e.text=n,e.html=s||null,e.userCommitted.text=n,e.previousKeyDownEvent=null},stageSuggestion(e,o){let{text:n}=o.payload;switch(e.stagedSuggestion=o.payload,e.tabCompletionSuggestion=void 0,o.payload.replace){case"selection":e.text=`${e.text.slice(0,e.selection.start)}${n}${e.text.slice(e.selection.end)}`,e.selection.end=e.selection.start+n.length,e.selection.start+=n.length;break;case"until-selection-end":e.text=`${n}${e.text.slice(e.selection.end)}`,e.selection.start=n.length,e.selection.end=n.length;break;default:throw new Error(`Unknown replace ${o.payload.replace}`)}o.payload.eventMetrics.inputType==="tab"&&$n(e)},commitSuggestion(e){$n(e)},offeredTextSuggestion(e,o){let{text:n,suggestion:{source:s}}=o.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:s})},registerCut(e,o){let{metrics:n}=e,s=o.payload;e.metrics={...e.metrics,numCharsCut:n.numCharsCut+s.length,cuts:[...n.cuts,s]}},registerPaste(e,o){let{metrics:n}=e,{text:s,selectionText:r}=o.payload,i=n.numCharsDeleted+(r&&r.length?r.length:0),a=r&&r.length?[...n.deletions,r]:n.deletions;e.metrics={...e.metrics,numCharsDeleted:i,deletions:a,numCharsPasted:n.numCharsPasted+s.length,numPaste:n.numPaste+1,pastes:[...n.pastes,s]}},registerKeyDown(e,o){e.previousKeyDownEvent=o.payload},nextTextSuggestionIndex(e){let o=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<o-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},previousTextSuggestionIndex(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},setTextSuggestions(e,o){if(e.selectedSuggestionIndex=-1,e.textSuggestions=o.payload,o.payload.length===0)return;let n=e.userCommitted.text.substring(0,e.userCommitted.selection.end),s=_r(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)}},extraReducers:e=>{e.addCase(L,o=>{o.tabCompletionSuggestion=at.tabCompletionSuggestion,o.previousKeyDownEvent=at.previousKeyDownEvent,o.textSuggestions=at.textSuggestions,o.selectedSuggestionIndex=at.selectedSuggestionIndex,o.metrics=at.metrics})}}),Cr=Ia("input"),jt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Qd=t=>t.input.selection,Ra=()=>(0,Pa.useSelector)(Qd),{userInput:La,changeSelection:wr,initialInput:Aa,mergeMetrics:Ma,nextTextSuggestionIndex:Oa,offeredTextSuggestion:Na,previousTextSuggestionIndex:Da,registerCut:Ha,registerKeyDown:Ba,registerPaste:Fa,reset:Ka,resetToCommitted:Ao,setInputHtml:Ua,setSelectedTextSuggestionIndex:ts,setTextSuggestions:lt,stageSuggestion:we,commitSuggestion:ct}=Cr.actions,Y=Ia("overlay");var Vt=require("react");var za={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var Tr=require("react/jsx-runtime"),Zd=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,Vt.useRef)(null),l=(0,Vt.useRef)(null),c=y("Dialog",za);return(0,Vt.useEffect)(()=>{var d,m;let p=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),s())},u=h=>{let g=window.getSelection();g!=null&&g.toString()||h.target===a.current&&t&&n()};return(d=a.current)==null||d.addEventListener("click",u),(m=a.current)==null||m.addEventListener("keyup",p),()=>{var h,g;(h=a.current)==null||h.removeEventListener("click",u),(g=a.current)==null||g.removeEventListener("keyup",p)}},[a,l,s,n]),(0,Vt.useEffect)(()=>{var p,u;!a.current||!t||!e||(u=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||u.focus()},[t,e,a]),t?(0,Tr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,Tr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},qt=Zd;var zr=require("react"),hs=require("react-redux");var Er={};V(Er,{enUS:()=>Jd,nlNL:()=>Yd});var Jd={dismiss:[{type:0,value:"Close"}],add:[{type:0,value:"Add to message"}],next:[{type:0,value:"Next"}],previous:[{type:0,value:"Previous"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},Yd={dismiss:[{type:0,value:"Sluiten"}],add:[{type:0,value:"Toevoegen"}],next:[{type:0,value:"Volgende"}],previous:[{type:0,value:"Vorige"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var ja={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};var Mo=require("react/jsx-runtime"),os=()=>(0,Mo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Mo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Mo.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 Oo=require("react/jsx-runtime"),Va=()=>(0,Oo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,Oo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,Oo.jsx)("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});var he=require("react"),il=require("react-redux"),al=require("interweave"),Or=T(require("classnames"));var kr={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var Wa=require("interweave"),Ga=T(require("classnames"));var Wt=require("react");function qa(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function ns(t){let e=(0,Wt.useRef)(null),[o,n]=(0,Wt.useState)(!1);return(0,Wt.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=qa((p,u)=>{let d=e.current;if(!d)return;let m=p/r,h=u/r,g=d.getBoundingClientRect(),v=m>g.x&&m<g.x+g.width&&h>g.y&&h<g.y+g.height;v&&!s?(s=!0,n(!0)):!v&&s&&(s=!1,n(!1))},({clientX:p,clientY:u})=>[p,u]),[l,c]=qa(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var fe={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};var Pr=require("react/jsx-runtime"),eg=({inputElement:t,children:e})=>{let o=y("TabCompletion",fe),[n,s]=ns(t);return(0,Pr.jsx)("mark",{ref:n,className:(0,Ga.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},Gt=class extends Wa.Matcher{match(e){let o=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return o?{index:o.index,length:o[0].length,match:o[0],matchString:o[0],valid:!0}:null}replaceWith(e,o){return(0,Pr.jsx)(eg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var $t=require("react");function ss(t){return t.contentEditable==="true"}function tg(t){let e=0,o=0,n=window.getSelection();if(n.rangeCount!==0){let s=n.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),o=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:o}}function $a(t){let{selectionStart:e,selectionEnd:o}=ss(t)?tg(t):t;return[e,o]}function rs(t){let[,e]=(0,$t.useState)(),o=(0,$t.useRef)(null);return o.current=$a(t),(0,$t.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=$a(t);(!i||s!==i[0]||r!==i[1])&&(o.current=i,e({}))};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",n)}},[t]),o.current}function is(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(zt);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=n.indexOf(l,a);return s>c&&r<c+l.length?(o.selectionStart=c,o.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}var Xa=require("react");function Xt(t){(0,Xa.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function kt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Qa,Me=new Map,og=["bottom","height","left","right","top","width"],ng=(t={},e={})=>og.some(o=>t[o]!==e[o]),Za=()=>{let t=[];Me.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Me.delete(o);return}let n=o.getBoundingClientRect();ng(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(o=>o(e.rect))}),Me.size!==0&&(Qa=window.requestAnimationFrame(Za))};function Ja(t,e){return{observe(){let o=Me.size===0;if(Me.has(t)){let n=Me.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Me.set(t,{rect:void 0,callbacks:[e]});o&&Za()},unobserve(){let o=Me.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Me.delete(t),Me.size||cancelAnimationFrame(Qa)}}}}var Ya,Oe=new Map,el=()=>{Oe.forEach((t,e)=>{if(!e.isConnected){Oe.delete(e);return}let{clientHeight:o,scrollHeight:n}=e,s=n>o;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),Oe.size!==0&&(Ya=window.requestAnimationFrame(el))};function tl(t,e){return{observe(){let o=Oe.size===0;Oe.has(t)?Oe.get(t).callbacks.push(e):Oe.set(t,{visible:void 0,callbacks:[e]}),o&&el()},unobserve(){let o=Oe.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Oe.delete(t),Oe.size||cancelAnimationFrame(Ya)}}}}var Ir=["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 Rr(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function Qt(t){return parseFloat(t)}function as(t){return Math.round(t*1e6)}function ol(t){return t/1e6}function Lr(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=Qt(t.width),r=Qt(t.borderLeftWidth),i=Qt(t.borderRightWidth),a=Qt(t.paddingRight),l=ol(as(s)-as(r)-as(i)),c=ol(as(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Zt(t,e={}){var l;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position="fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",kt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Rr(n,o,Ir),Lr(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=tl(t,()=>{Rr(n,o,Ir),Lr(n,t,o),r(),setTimeout(r,0)}),a=Ja(t,c=>{if(c===null){e.onRemove&&e.onRemove(),o.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Rr(n,o,Ir),Lr(n,t,o),r(),o.style.top=`${c.top}px`,o.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),d=Qt(u.borderTopWidth),m=Qt(u.borderBottomWidth),h=p.top+d-c.top,g=c.top+c.height+-(p.top+p.height-m);o.style.clipPath=`inset(${h}px 0px ${g}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var Ar={};V(Ar,{enUS:()=>sg,nlNL:()=>rg});var sg={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},rg={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};var No=require("react/jsx-runtime"),nl=()=>(0,No.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,No.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,No.jsx)("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});var Mr=require("react/jsx-runtime"),sl=()=>(0,Mr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Mr.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var rl=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(rl||{}),He=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentHTML="";currentSelection=null;isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e,rawHtml:o}),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e,rawHtml:o}),this.currentHTML=o))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange()}handleFocus(){this.isFocused||this.emit("focus"),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(rl).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){let e=this.currentSelection;this.isPossibleClearInputAction=!0,e&&this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){let o=(e.clipboardData||window.clipboardData).getData("text");this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){let e=()=>{let n=document.activeElement===this.element?this.getSelection():null;it(this.currentSelection,n)||(this.currentSelection=n,this.emit("selection",n))};document.addEventListener("selectionchange",e),this.disposeHandlers.push(()=>{window.document&&document.removeEventListener("selectionchange",e)}),this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let o=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});o.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{o.disconnect()})}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var Be=class extends He{getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){return this.currentSelection?this.getText().slice(this.currentSelection.start,this.currentSelection.end):""}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var ee=require("react/jsx-runtime"),ig=({value:t,onUse:e,...o})=>{var p;let n=E(Ar),s=(0,il.useDispatch)(),r=y("EditSuggestionTextInput",kr),[i,a]=(0,he.useState)(null),l=(0,he.useRef)(null),c=((p=t.match(zt))==null?void 0:p.length)||0;return(0,he.useEffect)(()=>{let u;return l.current&&(a(l.current),u=new Be(l.current),u.on("change",({plainText:d})=>{s(Y.actions.userInput({text:d,selection:u.getSelection()}))}),u.on("keydown",d=>{s(Y.actions.registerKeyDown(Xn(d))),d.code==="Enter"&&d.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:d,selectionText:m})=>{s(Y.actions.registerPaste({text:d,selectionText:m}))}),u.on("cut",({selectionText:d})=>{s(Y.actions.registerCut(d))})),()=>{s(Y.actions.reset()),u.dispose(),u.deactivate()}},[l]),(0,he.useEffect)(()=>{t&&l.current&&(l.current.value=t)},[t,l]),(0,he.useEffect)(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let u=l.current.value.length;l.current.setSelectionRange(u,u),l.current.focus()},0)},[l]),(0,ee.jsxs)("div",{className:r.textInputWrapper,children:[(0,ee.jsx)("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&(0,ee.jsx)(ag,{inputElement:l.current,value:t}),(0,ee.jsxs)("div",{className:(0,Or.default)(r.alert,c===0?r.success:r.warning),children:[(0,ee.jsx)("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?(0,ee.jsx)(nl,{}):(0,ee.jsx)(sl,{})]})]})},ag=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",kr),n=(0,he.useRef)(null),s=rs(t);return(0,he.useEffect)(()=>{is(t,s)},[s,t]),(0,ee.jsx)(lg,{inputElement:t,children:(0,ee.jsxs)("div",{ref:n,className:(0,Or.default)(o.root,o.agentText),children:[(0,ee.jsx)(al.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new Gt("placeholders")],inputElement:t,boundaryRef:n}),(0,ee.jsx)("br",{})]})})},lg=({inputElement:t,children:e})=>{let o=(0,he.useRef)(null);return(0,he.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=Zt(t,{overlayContainer:o.current,mirrorOverflow:!0});return()=>{s()}},[o.current]),(0,ee.jsx)("div",{ref:o,children:e})},ll=ig;var to=require("react");var cl=require("react"),ls=T(require("classnames"));var te={root:"_root_185k9_1",list:"_list_185k9_2",listWrapper:"_listWrapper_185k9_6",listHorizontal:"_listHorizontal_185k9_10",page:"_page_185k9_19",search:"_search_185k9_25",pageNav:"_pageNav_185k9_33",pageTitle:"_pageTitle_185k9_41",pageBackButton:"_pageBackButton_185k9_48",listHeading:"_listHeading_185k9_62",listItem:"_listItem_185k9_70",listItemContent:"_listItemContent_185k9_79",listItemText:"_listItemText_185k9_97",listItemDescription:"_listItemDescription_185k9_105",truncate:"_truncate_185k9_112",lineClamp:"_lineClamp_185k9_118",listItemTitle:"_listItemTitle_185k9_125",listItemAction:"_listItemAction_185k9_132",listItemPrimaryAction:"_listItemPrimaryAction_185k9_146",listItemSelected:"_listItemSelected_185k9_151",sources:"_sources_185k9_155",sourcesTitle:"_sourcesTitle_185k9_162",source:"_source_185k9_155",icon:"_icon_185k9_177",searchIcon:"_searchIcon_185k9_194",searchInputWrapper:"_searchInputWrapper_185k9_199",searchInput:"_searchInput_185k9_199",select:"_select_185k9_220",selectType:"_selectType_185k9_237",selectWrapper:"_selectWrapper_185k9_241",image:"_image_185k9_271",imageSrc:"_imageSrc_185k9_278",imageSrcHidden:"_imageSrcHidden_185k9_289",imageSrcStatus:"_imageSrcStatus_185k9_293",imageTitle:"_imageTitle_185k9_303",actions:"_actions_185k9_308",actionsWrapper:"_actionsWrapper_185k9_312",actionsBar:"_actionsBar_185k9_318",actionButton:"_actionButton_185k9_327",actionShortcut:"_actionShortcut_185k9_345",actionShortcutFixKerning:"_actionShortcutFixKerning_185k9_352"};var Pt={};V(Pt,{enUS:()=>cg,nlNL:()=>pg});var cg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},pg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var pt=require("react/jsx-runtime"),ug=({src:t,title:e})=>{let o=y("CommandPalette",te),[n,s]=(0,cl.useState)("loading"),r=E(Pt);return(0,pt.jsxs)("div",{className:o.image,children:[(0,pt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,ls.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,pt.jsx)("span",{className:(0,ls.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,pt.jsx)("span",{className:(0,ls.default)(o.imageSrc,o.imageSrcStatus),children:(0,pt.jsx)(Sn,{})}),e&&(0,pt.jsx)("span",{className:o.imageTitle,children:e})]})},pl=ug;var ul=T(require("react")),dl=T(require("classnames"));var Do=require("react/jsx-runtime");function Nr({children:t,heading:e,orientation:o}){let n=y("CommandPalette",te);return ul.default.Children.count(t)===0?null:(0,Do.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,Do.jsx)("h4",{className:n.listHeading,children:e}),(0,Do.jsx)("div",{className:(0,dl.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var Ho=T(require("classnames"));var cs=T(require("react")),fl=require("react/jsx-runtime"),gl=cs.default.createContext(void 0);function ut(){let t=cs.default.useContext(gl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var ml=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=cs.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,fl.jsx)(gl.Provider,{value:i,children:t})};var ye=require("react/jsx-runtime");function Dr({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onSourceClick:s,index:r,isExperimental:i,description:a,sources:l,styles:c,...p}){let{selected:u,onChangeOpen:d}=ut(),m=y("CommandPalette",te);function h(g){n(g),t&&d(!1)}return(0,ye.jsxs)("div",{className:(0,Ho.default)(m.listItem,u===r&&m.listItemSelected),children:[(0,ye.jsxs)("button",{type:"button",className:(0,Ho.default)("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:h,...p,children:[(0,ye.jsxs)("div",{className:m.listItemContent,children:[typeof o=="string"?(0,ye.jsx)("p",{className:(0,Ho.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,ye.jsx)("p",{className:(0,Ho.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate),children:a})]}),i&&(0,ye.jsx)(Dn,{})]}),l&&(0,ye.jsxs)("div",{className:m.sources,children:[(0,ye.jsx)("span",{className:m.sourcesTitle,children:"Sources"}),l.map(g=>g.url?(0,ye.jsx)("a",{className:m.source,href:g.url,target:"_blank",title:g.url,rel:"noopener noreferrer",onClick:()=>s&&s(g),children:g.name},g.url):(0,ye.jsx)("span",{className:m.source,children:g.name},g.name))]})]})}var dt=require("react/jsx-runtime");function Hr({children:t,title:e,id:o,onDismiss:n,isExperimental:s}){let r=E(Pt),i=y("CommandPalette",te),{page:a}=ut();return a!==o?null:(0,dt.jsxs)("div",{className:i.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,dt.jsxs)("div",{className:i.pageNav,children:[(0,dt.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:n,children:[(0,dt.jsx)(os,{}),r("back")]}),e&&(0,dt.jsx)("h3",{className:i.pageTitle,children:e}),s&&(0,dt.jsx)(Dn,{})]}),t]})}var gt=require("react");var ps=()=>/Mac/i.test(navigator.platform);var ds=require("@reduxjs/toolkit");var dg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},P=dg;var Jt=require("@reduxjs/toolkit");function gg(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function O(t){return Array.isArray(t)?t.map(O):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[gg(o)]:O(t[o])}),{}):t}function Br(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function z(t){return Array.isArray(t)?t.map(z):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Br(o)]:z(t[o])}),{}):t}var mg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Fo=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},Bo=(0,Jt.createAsyncThunk)("info/setAgentInfo",async(t,e)=>{let{deepdeskAPI:o}=e.extra;if(!t.agentId&&!t.agentNickname)throw new Error("At least provide agentId or agentNickname");let n=await o.client.get("/apis/admin/session/me/",{version:null}),s={};return n.external_id||(s.external_id=t.agentId),n.nickname||(s.nickname=t.agentNickname),!s.external_id&&!s.nickname?O(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),O(n))}),Fr=(0,Jt.createAsyncThunk)("info/setAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.client.get("/apis/admin/session/me/",{version:null}),s={...typeof n.ui_config=="object"?n.ui_config:{},...t};return await o.client.patch("/apis/admin/session/me/",{ui_config:s}),s}),Kr=(0,Jt.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),hl=t=>t.info.agentInfo,yl=(0,Jt.createSlice)({name:"info",initialState:mg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Bo.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Bo.rejected,e=>{e.fetchState="error"}).addCase(Bo.fulfilled,(e,o)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...o.meta.arg,agentId:o.payload.externalId||o.meta.arg.agentId||"",agentNickname:o.payload.nickname||o.meta.arg.agentNickname||""}}).addCase(Fr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(Kr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(L,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Sl}=yl.actions,vl=yl.reducer;var us={list:[],fetchState:"idle",isOpen:!1,page:"search"},_l=t=>t.search.isOpen,xl=t=>t.search.page,bl=t=>t.search.list;function Cl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var It=(0,ds.createAsyncThunk)("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:Fo(n),tags:t.tags});return r.map(a=>({...a,source:a.type==="URL"?"search-url":"search-overlay",searchTerm:t.query}))}),wl=(0,ds.createSlice)({name:"search",initialState:us,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=us.fetchState,t.list=us.list}},extraReducers:t=>{t.addCase(It.pending,e=>{e.fetchState="loading"}).addCase(It.rejected,(e,o)=>{e.fetchState="error",P.error(o.error)}).addCase(It.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(L,()=>us)}}),{resetSearch:gs,setIsOpen:ae,setPage:X}=wl.actions,Tl=wl.reducer;var fg=/(https?:\/\/[^\s]+)/,ms=t=>t.split(" ").find(e=>fg.test(e));var Ur=T(require("classnames"));var fs=require("react/jsx-runtime"),hg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",te);return(0,fs.jsxs)("button",{type:"button",...n,onClick:t,className:(0,Ur.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,fs.jsx)("span",{className:(0,Ur.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},Yt=hg;var Fe=require("react/jsx-runtime"),yg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",te),a=E(Pt),{selected:l,setSelected:c}=ut(),p=r[l],u=p&&typeof p.text=="string"&&ms(p.text),d=(0,gt.useRef)(null);function m(_){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),w=0,C=0;_==="down"?(x.forEach((ue,B)=>{B===l&&(w=B)}),C=w===x.length-1?0:w+1):_==="up"?(x.forEach((ue,B)=>{B===l&&(w=B)}),C=w?w-1:x.length-1):c(0);let D=x[C];D&&typeof C=="number"&&(c(C),D.scrollIntoView&&D.scrollIntoView({behavior:"smooth",block:C?"center":"end"}))}function h(){if(!d.current)return;let _=d.current.querySelectorAll(".command-palette-list-item"),x=0;_.forEach((C,D)=>{D===l&&(x=D)});let w=_[x];w&&w.click()}let g=()=>{u&&window.open(u,"_blank")},v=()=>{p&&n(p,l)},k=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},f=(0,gt.useCallback)(_=>{if(_.key==="Enter"&&_.altKey&&u){g();return}if(_.key==="Enter"&&_.shiftKey){k();return}if(_.key==="ArrowDown"){_.preventDefault(),_.stopPropagation(),m("down");return}if(_.key==="ArrowUp"){_.preventDefault(),_.stopPropagation(),m("up");return}_.key==="Enter"&&l!==-1&&(_.preventDefault(),_.stopPropagation(),h())},[l]);return(0,gt.useEffect)(()=>(window.addEventListener("keyup",f),()=>{window.removeEventListener("keyup",f)}),[f]),(0,Fe.jsxs)("div",{className:i.actions,children:[(0,Fe.jsx)("div",{className:i.actionsWrapper,ref:d,children:t}),(0,Fe.jsxs)("div",{className:i.actionsBar,children:[u&&(0,Fe.jsx)(Yt,{onClick:g,shortKeys:[ps()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Fe.jsxs)(gt.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,Fe.jsx)(Yt,{onClick:k,shortKeys:[8679,8629],children:o}),(0,Fe.jsx)(Yt,{onClick:v,shortKeys:[8629],children:e})]})]})]})},kl=yg;var Pl=require("react");var Ko=require("react/jsx-runtime"),eo=()=>(0,Ko.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Ko.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Ko.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 Te=require("react/jsx-runtime");function Sg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",te);return(0,Te.jsxs)("div",{className:l.search,children:[(0,Te.jsx)("div",{className:l.searchIcon,children:(0,Te.jsx)(eo,{})}),(0,Te.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Te.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&(0,Te.jsx)("div",{className:l.selectWrapper,children:(0,Te.jsxs)("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&&(0,Te.jsx)("option",{children:n}),s.map(c=>(0,Te.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Il=(0,Pl.forwardRef)(Sg);var Uo=require("react/jsx-runtime");function Rt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:u,search:d}){let[m,h]=(0,to.useState)(0),g=(0,to.useRef)(null),v=()=>{s&&s(o),i(void 0),r(""),a(!1)},k=()=>{var f;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(f=g.current)==null||f.focus();return}if(d.length>0){r("");return}a(!1)};return(0,to.useEffect)(()=>{h(0)},[d,n]),(0,Uo.jsx)(qt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:k,onClose:v,children:(0,Uo.jsxs)(ml,{selected:m,setSelected:h,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&(0,Uo.jsx)(Il,{ref:g,onChange:r,onChangeType:i,placeholder:t,value:d,selectedType:l,types:c,typePlaceholder:e}),p]})})}Rt.Page=Hr;Rt.List=Nr;Rt.Image=pl;Rt.ListItem=Dr;Rt.ActionsBar=kl;Rt.Button=Yt;var A=Rt;var $=require("react/jsx-runtime"),vg=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",ja),l=(0,hs.useDispatch)(),c=E(Er),p=(0,hs.useSelector)(h=>h.overlayInput.text);(0,zr.useEffect)(()=>{t&&(l(Y.actions.reset()),l(Y.actions.stageSuggestion({text:i,suggestion:{...t,source:"search-preview"},eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Y.actions.commitSuggestion()))},[t]);let u=h=>{h.preventDefault(),d(p)},d=h=>{l(Jn(h)),e(h)},m=h=>g=>{p!==i?window.confirm(c("warning"))&&h(g):h(g)};return(0,zr.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,$.jsxs)("div",{className:a.root,children:[(0,$.jsxs)("div",{className:a.content,children:[t.title&&(0,$.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,$.jsx)(Sr,{labels:t.searchKeywords}),(0,$.jsx)(ll,{onUse:d,value:p})]}),(0,$.jsxs)("form",{className:a.actions,onSubmit:u,children:[(0,$.jsxs)("div",{children:[(0,$.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&m(r),children:(0,$.jsx)(os,{})}),(0,$.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&m(s),children:(0,$.jsx)(Va,{})})]}),(0,$.jsxs)("div",{className:a.primaryButtons,children:[(0,$.jsx)(A.Button,{onClick:m(o),shortKeys:["esc"],children:c("dismiss")}),(0,$.jsx)(A.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},ys=vg;var Lt=require("@reduxjs/toolkit");var _g=["{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}"],xg=new RegExp(_g.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Rl(t,e){let o=t.split(xg),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let u=a.charAt(0),d=0;do c=u?e.indexOf(u,c+1):-1,d+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&d>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function Ll(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Ml={suggestions:[],fetchState:"idle",isInitialRequest:null},Al={default:Ml},Ol=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},Nl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},Dl=t=>{let e=Object.keys(t.textSuggestions).map(o=>{var n;return(n=t.textSuggestions[o])==null?void 0:n.fetchState});return e.length===0?!0:e.every(o=>o!=="done")},oo=t=>t.textSuggestions,Hl=t=>e=>e.text.startsWith(t),Ss=(0,Lt.createAction)("textSuggestions/refresh"),Ke=(0,Lt.createAsyncThunk)("textSuggestions/recommendations",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,inlineSuggestions:i}=n.settings,a=jt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Fo(n),t);if(t==="default"){let p=i?l.filter(Hl(a)):l;e.dispatch(lt(p.slice(0,r)))}return l}),zo=(0,Lt.createAsyncThunk)("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getAutocompleteSuggestions(s,{...Fo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Hl(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Rl(p.text,t):p.text}))),l=Ll(l,r),e.dispatch(lt(l)),l}),Bl=(0,Lt.createSlice)({name:"textSuggestions",initialState:Al,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:o}=e.payload;t[o].fetchState="done",t[o].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}},setSuggestionState(t,e){return e.payload}},extraReducers:t=>{t.addCase(Ke.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Ml;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Ke.rejected,(e,o)=>{let n=o.meta.arg;e[n].fetchState="error"}).addCase(Ke.fulfilled,(e,o)=>{let n=o.meta.arg;e[n].fetchState="done",e[n].suggestions=o.payload}).addCase(zo.pending,e=>{e.default.fetchState="loading"}).addCase(zo.rejected,e=>{e.default.fetchState="error"}).addCase(zo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(L,()=>Al)}}),{setTextSuggestions:Fl,setSuggestionState:Kl}=Bl.actions,Ul=Bl.reducer;var jl=require("@reduxjs/toolkit");var zl={contentType:null,suggestion:null},Vl=t=>t.activeSuggestion.suggestion,ql=t=>t.activeSuggestion.contentType,Wl=(0,jl.createSlice)({name:"activeSuggestion",initialState:zl,reducers:{setActiveSuggestion(t,e){let{contentType:o,suggestion:n}=e.payload;t.contentType=o,t.suggestion=n},resetActiveSuggestion(t){t.contentType=null,t.suggestion=null}},extraReducers:t=>{t.addCase(L,()=>zl)}}),{setActiveSuggestion:Ue,resetActiveSuggestion:jr}=Wl.actions,Gl=Wl.reducer;var Vr={};V(Vr,{enUS:()=>bg,nlNL:()=>Cg});var bg={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},Cg={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};var $l=require("@reduxjs/toolkit"),wg={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Xl=({ui:t})=>t.overlayCollapsed;var Ql=(0,$l.createSlice)({name:"ui",initialState:wg,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:jo,setInputHasFocus:no,setOverlayCollapsed:so,setOpenOverlayWhenTyping:Zl,setOverlayCollapsedUserOverwrite:Jl}=Ql.actions,Yl=Ql.reducer;var Vo=T(require("react")),tc=require("react/jsx-runtime"),ec=Vo.default.createContext(null),qo=({broadcastEvents:t,children:e})=>{let o=Vo.default.useMemo(()=>t,[]);return(0,tc.jsx)(ec.Provider,{value:o,children:e})},Se=()=>{let t=(0,Vo.useContext)(ec);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var ro=require("@reduxjs/toolkit");var Tg={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ze=t=>t.auth.isLoggedIn,oc=t=>t.auth.loginFetchState,nc=t=>t.auth.verifyFetchState,sc=t=>t.auth.showLoginOverlay,mt=(0,ro.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),rc=(0,ro.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Wo=(0,ro.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),ic=(0,ro.createSlice)({name:"auth",initialState:Tg,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(mt.pending,e=>{e.loginFetchState="loading"}),t.addCase(mt.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(mt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Wo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Wo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Wo.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:io,setShowLoginOverlay:ac}=ic.actions,lc=ic.reducer;var qr="SetActiveSuggestion",ao="ShowLoginOverlay",Wr="UserLoggedIn",Eg="UserLoggedOut",je="ApplySuggestion",Gr="ApplyImageSuggestion",kg="ShowCommandPalette",Pg=t=>({[qr]:e=>{t.dispatch(Kl(e.state)),t.dispatch(Ue({contentType:e.contentType,suggestion:e.suggestion}))},[kg]:e=>{t.dispatch(ae(e.isOpen)),e.page&&t.dispatch(X(e.page))},[ao]:e=>{t.dispatch(ac(e))},[Wr]:()=>{t.dispatch(mt())},[Eg]:()=>{t.dispatch(mt())},[Gr]:e=>{t.dispatch(es({suggestion:e.suggestion}))},[je]:e=>{t.dispatch(we({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(ct())}}),cc=Pg;var $r=require("react/jsx-runtime"),Ig=()=>{var h;let[t,e]=(0,pc.useState)(!1),o=(0,lo.useSelector)(Vl),n=(0,lo.useSelector)(ql),s=(0,lo.useSelector)(oo),r=(0,lo.useDispatch)(),i=Se(),a=E(Vr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(jr()),r(no(!0)),r(Y.actions.reset())},p=(g,v)=>{r(jr()),r(no(!0)),i.send(je,{text:g,suggestion:v})};if(o===null||n===null)return null;let u=(h=s[n])==null?void 0:h.suggestions.indexOf(o),d=u===0||u===null?void 0:()=>r(Ue({contentType:n,suggestion:s[n].suggestions[u-1]})),m=u===s[n].suggestions.length-1||u===null?void 0:()=>r(Ue({contentType:n,suggestion:s[n].suggestions[u+1]}));return(0,$r.jsx)(qt,{autoFocus:!0,isOpen:u!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,$r.jsx)(ys,{onTouched:e,onDismiss:c,onUse:g=>p(g,o),suggestion:o,onNext:m,onPrevious:d})})},uc=Ig;var Qr=require("react-redux");var vs=T(require("classnames")),Ee=require("react"),_s=require("react-redux");var gc=T(require("classnames"));var dc={root:"_root_1ukx5_1"};var mc=require("react/jsx-runtime"),Rg=({className:t,value:e,...o})=>{let n=y("TextInput",dc);return(0,mc.jsx)("input",{className:(0,gc.default)(t,n.root),type:"text",value:e,...o})},Go=Rg;var Xr={};V(Xr,{enUS:()=>Lg,nlNL:()=>Ag});var Lg={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},Ag={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var fc={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};var K=require("react/jsx-runtime");var Mg=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Og=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(Xr),i=y("LoginTokenDialog",fc),a=(0,_s.useSelector)(nc),l=(0,_s.useDispatch)(),c=b("productName"),[p,u]=(0,Ee.useState)(t||""),[d,m]=(0,Ee.useState)(0),[h,g]=(0,Ee.useState)(""),v=(0,Ee.useCallback)(async x=>{x.preventDefault(),l(rc({email:p})),m(1)},[o,p]),k=()=>{g(""),m(0)},f=(0,Ee.useCallback)(async x=>{x.preventDefault();let w=Mg(x.target.elements.token.value);if(!w){g(r("verifyCodeError",{login:_}));return}l(Wo({token:w}))},[o]),_=(0,Ee.useMemo)(()=>x=>(0,K.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:k,children:x},"back-button"),[]);return(0,Ee.useEffect)(()=>{a==="error"&&g(r("verifyCodeError",{login:_})),a==="done"&&n()},[a]),(0,K.jsx)(qt,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,K.jsxs)("div",{className:i.root,children:[(0,K.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),d===0&&(0,K.jsxs)("form",{onSubmit:v,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,K.jsx)(Go,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:x=>u(x.target.value)}),(0,K.jsx)("div",{className:i.actions,children:(0,K.jsx)("button",{type:"submit",className:(0,vs.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),d===1&&(0,K.jsxs)("form",{onSubmit:f,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,K.jsx)(Go,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),h&&(0,K.jsx)("div",{className:i.errorMessage,children:h}),(0,K.jsxs)("div",{className:i.actions,children:[(0,K.jsx)("button",{type:"button",className:(0,vs.default)(i.button),onClick:k,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,vs.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},hc=Og;var Sc=require("react/jsx-runtime"),Ng=()=>{let t=(0,Qr.useSelector)(sc),e=(0,Qr.useSelector)(hl),o=b("adminUrl"),n=Se(),s=()=>n.send(ao,!1),r=()=>{n.send(ao,!1),n.send(Wr)};return(0,Sc.jsx)(hc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},yc=Ng;var Uc=T(require("lodash.debounce")),ne=require("react"),We=require("react-redux");var xs=require("@reduxjs/toolkit");var Dg={data:null,fetchState:"idle"},vc=t=>t.contentTypes.data,$o=(0,xs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Hg=(0,xs.createSlice)({name:"contentTypes",initialState:Dg,reducers:{},extraReducers:t=>{t.addCase($o.pending,e=>{e.fetchState="loading"}).addCase($o.rejected,e=>{e.fetchState="error"}).addCase($o.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),_c=Hg.reducer;function Xo(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}var xc=require("react");function bc(t,e){(0,xc.useEffect)(()=>{let o=n=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?n.metaKey:n.ctrlKey)&&n.key===t&&(n.preventDefault(),n.stopPropagation(),e())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o)}},[])}var Qo=require("react"),ws=require("react-redux");var bs=require("@reduxjs/toolkit");var Cc={data:null,fetchState:"idle"},Cs=t=>{var r;let e=[],{visitorName:o}=t.info.visitorInfo??{},{agentName:n,agentNickname:s}=t.info.agentInfo??{};return n&&n!==o&&e.push(n),s&&s!==o&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},ke=(0,bs.createAsyncThunk)("entities/getEntities",async(t,e)=>{let{deepdeskAPI:o,dynamicThunkObject:n}=e.extra;if(!n.conversationQuery)return Promise.resolve([]);let s=n.conversationQuery,r=await s();return r.length===0?Promise.resolve([]):o.getEntities(r)}),Bg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Fg=(0,bs.createSlice)({name:"entities",initialState:Cc,reducers:{},extraReducers:t=>{t.addCase(ke.pending,e=>{e.fetchState="loading"}).addCase(ke.rejected,e=>{e.fetchState="error"}).addCase(ke.fulfilled,(e,o)=>{e.fetchState="done",e.data=Bg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(L,()=>Cc)}}),wc=Fg.reducer;var Zr={};V(Zr,{enUS:()=>Kg,nlNL:()=>Ug});var Kg={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Ug={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Tc={root:"_root_17kae_1",empty:"_empty_17kae_5"};var At=require("react/jsx-runtime"),zg=({onCopy:t,onUse:e})=>{let o=(0,Qo.useRef)(null),n=y("EntitiesList",Tc),s=E(Zr),r=(0,ws.useSelector)(Cs),i=(0,ws.useDispatch)();return(0,Qo.useEffect)(()=>{i(ke())},[]),(0,Qo.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,At.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,At.jsx)(A.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:(0,At.jsx)(A.List,{children:r.map((a,l)=>(0,At.jsx)(A.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,At.jsx)("p",{className:n.empty,children:s("noResults")})]})},Ec=zg;var Pe=require("react"),Zo=require("react-redux");var Ts=require("@reduxjs/toolkit");var kc={data:null,fetchState:"idle"},Pc=t=>t.summary.data,Ic=t=>t.summary.fetchState==="error",Ve=(0,Ts.createAsyncThunk)("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();if(i.length===0)return Promise.reject(new Error("No messages are included"));let a=await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return{original:i,summary:a}}),jg=(0,Ts.createSlice)({name:"summary",initialState:kc,reducers:{},extraReducers:t=>{t.addCase(Ve.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Ve.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Ve.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(L,()=>kc)}}),Rc=jg.reducer;var Jr={};V(Jr,{enUS:()=>Vg,nlNL:()=>qg});var Vg={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."}]},qg={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 Lc={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var qe=require("react/jsx-runtime"),Wg=({onCopy:t})=>{let e=(0,Pe.useRef)(null),o=y("SummaryForm",Lc),[n,s]=(0,Pe.useState)(""),r=E(Jr),i=(0,Zo.useSelector)(Pc),a=(0,Zo.useSelector)(Ic),l=(0,Zo.useDispatch)(),c=()=>{l(ie({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let u=document.getSelection();u&&l(ie({name:"summary copied to clipboard",data:{originalText:i,finalText:u==null?void 0:u.toString()},options:{includeConversationData:!0}}))};return(0,Pe.useEffect)(()=>{l(Ve())},[]),(0,Pe.useEffect)(()=>{s(i||"")},[i]),(0,Pe.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Pe.useEffect)(()=>{let u=d=>{d.key==="Enter"&&d.shiftKey&&c()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[n]),(0,qe.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,qe.jsx)("p",{className:o.error,children:r("error")}):(0,qe.jsxs)(Pe.Fragment,{children:[(0,qe.jsx)("div",{className:o.main,children:(0,qe.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:u=>s(u.target.value)})}),(0,qe.jsx)("div",{className:o.actions,children:(0,qe.jsx)(A.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Ac=Wg;var Yr={};V(Yr,{enUS:()=>Gg,nlNL:()=>$g});var Gg={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},$g={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Vat gesprek samen"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var ft=T(require("react")),Yo=require("react-redux");var ei={};V(ei,{enUS:()=>Xg,nlNL:()=>Qg});var Xg={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"}]},Qg={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 Mc={root:"_root_cnaw4_1",title:"_title_cnaw4_9",empty:"_empty_cnaw4_20",status:"_status_cnaw4_24",form:"_form_cnaw4_30",input:"_input_cnaw4_43",submit:"_submit_cnaw4_55",question:"_question_cnaw4_63",answer:"_answer_cnaw4_67",alignRight:"_alignRight_cnaw4_73"};var po=require("@reduxjs/toolkit");var ti={data:[],fetchState:"idle"},Oc=t=>{var e;return(e=t.answer)==null?void 0:e.data},Nc=t=>t.answer.fetchState,uo=(0,po.createAction)("answer/resetKnowledgeSearch"),co=(0,po.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(i=e.getState().conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile is not defined");let r=await o.knowledgeSearch({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),Zg=(0,po.createSlice)({name:"answer",initialState:ti,reducers:{},extraReducers:t=>{t.addCase(co.pending,e=>{e.fetchState="loading"}).addCase(co.rejected,e=>{e.fetchState="error"}).addCase(co.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(L,()=>ti).addCase(uo,()=>ti)}}),Dc=Zg.reducer;var Jo=require("react/jsx-runtime"),Hc=()=>(0,Jo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Jo.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Jo.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 oe=require("react/jsx-runtime"),Jg=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=ft.default.useState(""),{setSelected:i}=ut(),a=(0,ft.useRef)(null),l=y("EntitiesList",Mc),c=E(ei),p=(0,Yo.useDispatch)(),u=(0,Yo.useSelector)(Oc),d=(0,Yo.useSelector)(Nc),m=async g=>{g.preventDefault(),g.stopPropagation(),s!==""&&p(co({question:s,promptInstruction:n}))},h=(g,v)=>{p(ie({name:"knowledge assist source viewed",data:{question:v,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return(0,ft.useEffect)(()=>{var g;o&&d==="idle"?p(co({question:o,promptInstruction:n})):(g=a.current)==null||g.focus()},[a,d]),(0,ft.useEffect)(()=>{d==="done"&&(p(ie({name:"knowledge assist question answered",data:{question:s||o,sources:u[u.length-1].answer.sources,isFollowUpQuestion:u.length>1},options:{includeConversationData:!0}})),i(u.length-1),r(""))},[d,u]),(0,ft.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,u]),(0,oe.jsxs)("div",{className:l.root,children:[u.length>0&&(0,oe.jsx)("div",{className:l.alignRight,children:(0,oe.jsx)(A.Button,{onClick:e,children:c("reset")})}),(0,oe.jsxs)(A.ActionsBar,{list:u.map(({answer:g})=>({text:g.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:g=>t(g.text),children:[u.map(({question:g,answer:v},k)=>(0,oe.jsx)(A.List,{children:(0,oe.jsx)(A.ListItem,{"data-testid":"knowledge-search-answer",index:k,description:v.answer,closeOnSelect:!0,onClick:()=>t(v.answer),onSourceClick:f=>h(f,g),sources:v.sources,styles:{title:l.question,description:l.answer},children:g})},`${v.answer}_${k}`)),d==="loading"&&(0,oe.jsx)("p",{className:l.status,children:c("loading")}),d==="error"&&(0,oe.jsx)("p",{className:l.status,children:c("error")}),(0,oe.jsxs)("form",{className:l.form,onSubmit:m,children:[(0,oe.jsx)("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:g=>{i(-1),r(g.target.value)}}),(0,oe.jsx)("button",{type:"submit",className:l.submit,children:(0,oe.jsx)(Hc,{})})]})]})]})},Bc=Jg;var Es=require("@reduxjs/toolkit");var Yg={data:null,fetchState:"idle"},go=t=>t.profile.data,ks=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],en=(0,Es.createAsyncThunk)("profile/getProfile",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=n.profile.data)==null?void 0:r.code)===s.profileCode?n.profile.data:o.getProfile(s.profileCode)}),em=(0,Es.createSlice)({name:"profile",initialState:Yg,reducers:{},extraReducers:t=>{t.addCase(en.pending,e=>{e.fetchState="loading"}).addCase(en.rejected,e=>{e.fetchState="error"}).addCase(en.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Fc=em.reducer;var j=require("react/jsx-runtime"),tm=200,om=5,nm=4,sm=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Kc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),rm=()=>{let t=(0,We.useDispatch)(),e=Se(),o=E(Yr),[n,s]=(0,ne.useState)(!1),[r,i]=(0,ne.useState)(""),a=(0,We.useSelector)(xl),l=(0,We.useSelector)(go),[c,p]=(0,ne.useState)(null),[u,d]=(0,ne.useState)([]),[m,h]=(0,ne.useState)(),g=(0,We.useSelector)(ze),v=b("showSearch"),k=b("showEntitiesCommand"),f=b("showSummaryCommand"),_=b("showKnowledgeSearch"),x=b("showImageSearch"),w=b("searchTriggerKey"),C=(0,We.useSelector)(vc),D=(0,We.useSelector)(bl),ue=(0,We.useSelector)(_l),B=S=>rr(D.filter(M=>M.type===S.toUpperCase()),S),R=[{value:"PERSONAL",label:o("personalSuggestions"),list:B("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:B("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:B("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:B("IMAGE"),listOrientation:"horizontal",shouldShow:x}].filter(S=>S.shouldShow),U=[{label:o("entitiesClipboard"),onClick:()=>t(X("entities")),shouldShow:k&&Kc(o("entitiesClipboard"),r),experimental:!0},{label:o("summaryClipboard"),onClick:()=>t(X("summary")),shouldShow:f&&Kc(o("summaryClipboard"),r),experimental:!0},{label:r?`${o("knowledgeSearch")}: ${r}`:o("knowledgeSearch"),onClick:()=>t(X("knowledgeSearch")),shouldShow:_,experimental:!0}].filter(S=>S.shouldShow),J=(C==null?void 0:C.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:B(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],nr=(0,ne.useCallback)((0,Uc.default)((S,M)=>{t(It({query:S,type:M,tags:["search-overlay"]}))},tm),[]),bt=sm([...J,...R]),Yu=(0,ne.useCallback)((S,M)=>{if(!M)return;let nt=[...R,...J].find(({value:Bt})=>Bt===M);nt&&(t(X("edit")),p({...S,searchTerm:void 0}),d(nt.list))},[t,c,J]),sr=(0,ne.useCallback)((S,M)=>{switch(M.type){case"IMAGE":e.send(Gr,{suggestion:M});break;default:e.send(je,{text:S,suggestion:M})}t(ae(!1))},[t]),ed=S=>{Xo(S.text),t(ie({name:"entity copied",data:{entity:S,type:"copy"}})),t(ae(!1))},td=S=>{e.send(je,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(ie({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(X("search")),t(uo()),t(ae(!1))},od=S=>{Xo(S),t(ae(!1))},nd=S=>{e.send(je,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(ae(!1))},sd=c===null||u.indexOf(c)-1<0?void 0:()=>p(u[u.indexOf(c)-1]),rd=c===null||u.indexOf(c)===u.length-1?void 0:()=>p(u[u.indexOf(c)+1]);function rr(S,M){return S.slice(0,m?10:M.toLowerCase()==="image"?nm:om)}function Fi(S,M,nt){return M.reduce((Bt,fn)=>nt&&m===nt?fn.length+Bt:rr(fn,nt).length+Bt,S)}function Ht(S){return M=>{n?window.confirm(o("warning"))&&(S(M),s(!1)):S(M)}}return(0,ne.useEffect)(()=>{r?nr(r,m):t(gs())},[r,m]),(0,ne.useEffect)(()=>{a==="search"&&t(uo())},[a]),(0,ne.useEffect)(()=>{g&&t($o())},[g]),bc(w,()=>t(ae(!0))),!v||!l?null:(0,j.jsxs)(A,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Ht(S=>t(ae(S))),onChangeType:S=>h(S),onChangePage:Ht(S=>t(X(S))),selectedType:m,search:r,page:a,isOpen:ue,types:[...J,...R],children:[(0,j.jsx)(A.Page,{id:"search",children:(0,j.jsxs)(A.ActionsBar,{list:[...U.map(S=>({text:S.label,type:"command"})),...bt.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},M)=>sr(S,bt[M]),onSecondary:(S,M)=>{Yu(bt[M-U.length],bt[M-U.length].type)},children:[U.length>0&&(0,j.jsx)(A.List,{heading:o("commands"),children:U.map((S,M)=>(0,j.jsx)(A.ListItem,{index:Fi(M,[],"commands"),closeOnSelect:!1,onClick:S.onClick,isExperimental:S.experimental,children:S.label},S.label))}),[...J,...R].map(({value:S,label:M,list:nt,lineClamp:Bt,listOrientation:fn},id)=>(0,j.jsx)(A.List,{heading:M,orientation:fn==="horizontal"?"horizontal":"vertical",children:rr(nt,S).map((xe,ad)=>(0,j.jsx)(A.ListItem,{index:Fi(U.length+ad,[...J,...R].slice(0,id).map(({list:ld})=>ld),S),closeOnSelect:!1,lineClamp:Bt,onClick:()=>sr(xe.text,xe),description:S!=="IMAGE"?xe.title&&xe.text:void 0,children:S==="IMAGE"?(0,j.jsx)(A.Image,{title:xe.title||xe.text,src:xe.image}):xe.title||xe.text},`${xe.id}-${xe.text}`))},S))]})}),(0,j.jsx)(A.Page,{id:"edit",onDismiss:Ht(()=>{t(X("search")),p(null)}),children:c&&(0,j.jsx)(ys,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(X("search")),p(null),d([])},onNext:rd,onPrevious:sd,onUse:S=>{t(X("search")),sr(S,c),t(ae(!1)),d([]),p(null)}})}),(0,j.jsx)(A.Page,{id:"entities",title:o("entitiesTitle"),isExperimental:!0,onDismiss:Ht(()=>{t(X("search"))}),children:(0,j.jsx)(Ec,{onUse:nd,onCopy:ed})}),(0,j.jsx)(A.Page,{id:"summary",title:o("summaryTitle"),isExperimental:!0,onDismiss:Ht(()=>{t(X("search"))}),children:(0,j.jsx)(Ac,{onCopy:od})}),(0,j.jsx)(A.Page,{id:"knowledgeSearch",title:o("knowledgeSearch"),isExperimental:!0,onDismiss:Ht(()=>{t(uo()),t(X("search"))}),children:(0,j.jsx)(Bc,{promptInstruction:l.knowledgeSearchPromptInstruction,question:r,onUse:td,onResetQuestion:()=>{t(uo()),i("")}})})]})},zc=rm;var mo=require("react/jsx-runtime"),im=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,mo.jsxs)(jc.Fragment,{children:[t&&(0,mo.jsx)(zc,{}),(0,mo.jsx)(uc,{}),e&&(0,mo.jsx)(yc,{})]})},Vc=im;var qc=require("react-redux");var tn=require("react/jsx-runtime"),am=({children:t})=>{let o=b("locale").replace("-","");return(0,tn.jsx)(mr.Provider,{value:o,children:t})},lm=({store:t,customStyles:e={},children:o})=>(0,tn.jsx)(qc.Provider,{store:t,children:(0,tn.jsx)(am,{children:(0,tn.jsx)(Co.Provider,{value:e,children:o})})}),on=lm;var Ls=T(require("classnames")),yo=require("react"),$e=require("react-redux");var Wc=require("react");function Gc(t,e){let[o,n]=(0,Wc.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return P.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){P.error(i)}}]}function Ps(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:o,showSuggestionsAfterPattern:n}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?o&&new RegExp(o).test(s.substring(r.end))||n&&new RegExp(n).test(s.substring(0,r.end))?!0:o===!1&&n===!1:!1}var Xc=T(require("classnames")),Ge=require("react");var oi={};V(oi,{enUS:()=>cm,nlNL:()=>pm});var cm={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"}]}]},pm={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:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var ht=require("react/jsx-runtime"),ni=(t,e,o)=>n=>(0,ht.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),um=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=E(oi),r=Se(),i=y("Login",$c),a=b("productName"),l=(0,Ge.useCallback)(g=>{g.preventDefault(),n&&n(parseInt(g.target.value,10))},[]),c=(0,Ge.useCallback)(g=>{g.preventDefault(),r.send(ao,!0)},[e]),p=(0,Ge.useMemo)(()=>g=>(0,ht.jsx)("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),u=(0,Ge.useCallback)(g=>(0,ht.jsx)("button",{type:"button",className:i.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:d,hour:m,day:h}=(0,Ge.useMemo)(()=>({min:ni(i,60*10,l),hour:ni(i,60*60,l),day:ni(i,60*60*12,l)}),[]);return(0,ht.jsxs)("div",{className:(0,Xc.default)(t,i.root),children:[s("loginPlease",{login:o?u:p,productName:a}),n&&(0,ht.jsxs)(Ge.Fragment,{children:[(0,ht.jsx)("br",{}),s("snooze",{min:d,hour:m,day:h})]})]})},Is=um;var Zc=require("react-redux");var Qc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var nn=require("react/jsx-runtime"),dm=({title:t})=>{let e=y("SearchTrigger",Qc),o=(0,Zc.useDispatch)();return(0,nn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ae(!0)),children:[(0,nn.jsx)(eo,{}),(0,nn.jsx)("span",{className:e.text,children:t})]})},Jc=dm;var ip=require("react");var sp=require("interweave"),ho=require("react"),Rs=require("react-redux");var Yc=require("react");function ep(t,e,o){(0,Yc.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var gm=/[.*+?^${}()|[\]\\]/g,mm=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function fm(t){return t.replace(gm,"\\$&")}function hm(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function si(t){return t.search(mm)}function tp(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${fm(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function op(t){return t.replace(zt,'<mark data-type="placeholder">$1</mark>')}function fo(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function ym(t,e){return t.split("").map((i,a)=>({char:i,index:a})).filter(({char:i,index:a})=>/\s/.test(i)&&a<=e).map(({index:i})=>i).reverse()[0]}function ri(t,e,o={}){if(e){let n=hm(e.toLowerCase(),t.toLowerCase()),s=fo(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=si(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(ya).length>3||e.length>30?ym(e.trim(),n):0;return`${`${i>0?"\u2026":""}${fo(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var np={badge:"_badge_8rv7b_1",formattedText:"_formattedText_8rv7b_5"};var ii=require("react/jsx-runtime"),vm=["search","personal-collection-search","search-autocomplete"];function _m(t,e,o,n={}){let s="";return vm.includes(e)?s=tp(ri(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ri(t,o,n),n.placeholders===!0&&(s=op(s)),s}var xm=()=>{},bm=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=(0,Rs.useSelector)(jt),r=(0,Rs.useDispatch)(),i=y("TextSuggestion",np),a=(0,ho.useRef)(null);(0,ho.useEffect)(()=>{let c=setTimeout(()=>{r(Na({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),ep(a,"click",()=>{r(ts(t)),r(we({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,ho.useMemo)(()=>_m(o.text,o.source,s,{stripAgentPart:n,placeholders:!0,searchKeywords:o.searchKeywords}),[n,o.text,o.source,s,o.searchKeywords]);return o.source==="gpt"?null:(0,ii.jsx)(N,{ref:a,as:"button",selected:e,onClick:xm,children:(0,ii.jsx)(sp.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},rp=bm;var ai=require("react/jsx-runtime"),Cm=({suggestions:t,selectedIndex:e})=>(0,ai.jsx)(ip.Fragment,{children:t.slice().map((o,n)=>(0,ai.jsx)(rp,{index:n,selected:n===e,suggestion:o},`${o.text}-${o.source}`)).reverse()}),ap=Cm;var li={};V(li,{enUS:()=>wm,nlNL:()=>Tm});var wm={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"}]},Tm={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 lp={root:"_root_4kcme_1",isInline:"_isInline_4kcme_14",toggleButton:"_toggleButton_4kcme_18",toggleButtonWrapper:"_toggleButtonWrapper_4kcme_22",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_4kcme_29",isCollapsed:"_isCollapsed_4kcme_33",collapsible:"_collapsible_4kcme_33",hints:"_hints_4kcme_41",hintsHidden:"_hintsHidden_4kcme_48",triggers:"_triggers_4kcme_53",triggersRight:"_triggersRight_4kcme_68"};var H=require("react/jsx-runtime"),Em=({inline:t=!1,textSuggestions:e,selectedIndex:o})=>{let n=y("SuggestionsOverlay",lp),s=E(li),r=b("inlineSuggestions"),i=(0,$e.useSelector)(Ps),a=Ra(),l=(0,$e.useDispatch)(),c=(0,yo.useRef)(null),p=b("searchTriggerKey"),u=b("productName"),d=(0,$e.useSelector)(Xl),m=(0,$e.useSelector)(ze),h=(0,$e.useSelector)(jn),[g,v]=(0,yo.useState)(null),k=b("showSearch"),f=b("showTextSuggestions"),_=b("adminUrl"),x=b("isEmbedded"),[w,C]=Gc("dd-snooze-until-ms",0),D=d||w>Date.now(),ue=e.filter(U=>U.source!=="gpt").length,B=()=>{D&&C(0),l(Jl(!D))},R=U=>{let J=Date.now()+U*1e3;C(J),P.info(`Snooze until: ${new Date(J)}`),l(so({collapse:!0}))};return(0,yo.useEffect)(()=>{ue===0&&v(null)},[e,ue]),Xt(()=>{l(so({collapse:!0,skipWhenInputFocus:!0}))}),r!==t||m===null||h===!1?null:m===!1?(0,H.jsxs)("div",{ref:c,className:(0,Ls.default)(n.root,{[n.isCollapsed]:D,[n.isInline]:t}),"data-inline":t,children:[!D&&(0,H.jsxs)("div",{className:n.triggers,children:[(0,H.jsx)("div",{style:{flex:1}}),(0,H.jsx)("div",{className:n.triggersRight,children:(0,H.jsx)(Et,{className:n.toggleButton,title:s("collapse"),onClick:B,isCollapsed:!1})})]}),(0,H.jsx)("div",{className:n.toggleButtonWrapper,children:(0,H.jsx)(Et,{className:n.toggleButton,title:s("open",{productName:u}),onClick:B,isCollapsed:!0})}),(0,H.jsx)("div",{className:n.collapsible,children:(0,H.jsx)(Is,{loginUrl:_,isEmbedded:x,onSnooze:R})})]}):!a||!i?null:(0,H.jsxs)("div",{ref:c,className:(0,Ls.default)(n.root,{[n.isCollapsed]:D,[n.isInline]:t}),"data-inline":t,children:[!D&&(0,H.jsxs)("div",{className:n.triggers,children:[(0,H.jsx)("div",{style:{flex:1},children:k&&(0,H.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>v(s(ps()?"searchHintMac":"searchHintWindows",{searchTriggerKey:p.toUpperCase()})),onMouseLeave:()=>v(null),children:(0,H.jsx)(Jc,{title:s("search")})})}),(0,H.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,H.jsx)("div",{className:(0,Ls.default)(!g&&n.hintsHidden,n.hints),children:g}),(0,H.jsx)(Et,{className:n.toggleButton,title:s("collapse"),onClick:B,isCollapsed:!1})]})]}),(0,H.jsx)("div",{className:n.toggleButtonWrapper,children:(0,H.jsx)(Et,{className:n.toggleButton,title:s("open",{productName:u}),onClick:B,isCollapsed:!0})}),ue>0&&f&&(0,H.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,H.jsx)(Re,{children:(0,H.jsx)(ap,{suggestions:e,selectedIndex:o})})})]})},km=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),As=(0,$e.connect)(km)(Em);var qs=T(require("classnames")),Pp=require("interweave"),Je=require("react"),Ip=require("react-redux");var cp=require("react"),Pm=["div","span","mark","strong","b","i","u","em"];function ci(t,e,o=0){var r;let n=t[t.length-1],s=typeof n=="object"&&n!==null?(r=n.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,n];if(Pm.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,cp.cloneElement)(n,{children:ci(i,e,o+1)})]}return[...t,...e]}function Xe(t){return t.tagName.toLowerCase()==="textarea"}var pp={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};var hp=require("interweave"),Ds=require("react");var ui=T(require("classnames")),ve=require("react");var Ms=require("react"),Im=["bottom","height","left","right","top","width"],Rm=(t={},e={})=>Im.some(o=>t[o]!==e[o]),Qe=new Map,up,dp=()=>{let t=[],e=[];Qe.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Rm(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Qe.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),up=window.requestAnimationFrame(dp)};function Lm(t,e){return{observe(){let o=Qe.size===0;if(Qe.has(t)){let n=Qe.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Qe.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&dp()},unobserve(){let o=Qe.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Qe.delete(t),Qe.size||cancelAnimationFrame(up)}}}}function pi(t){let[e,o]=(0,Ms.useState)(null);return(0,Ms.useLayoutEffect)(()=>{if(!t.current)return;let n=Lm(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var So=require("react"),mp=require("react-dom");var gp={root:"_root_1jq08_1"};var fp=({children:t})=>{let[e,o]=(0,So.useState)(null),n=(0,So.useContext)(Co);return(0,So.useLayoutEffect)(()=>{let s=document.createElement("div");return kt(s),s.classList.add(gp.root),n!=null&&n.rootNode&&s.classList.add(n==null?void 0:n.rootNode),document.body.appendChild(s),o(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?(0,mp.createPortal)(t,e):null};var Ne={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};var Os=require("react/jsx-runtime"),vo=(t=!1)=>{let[e,o]=(0,ve.useState)(t),n=(0,ve.useCallback)(()=>o(!0),[]),s=(0,ve.useCallback)(()=>o(!1),[]),r=(0,ve.useCallback)(()=>o(a=>!a),[]),i=(0,ve.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function di(t,e=null,o=0){if(!t)return{display:"none"};let n=e?t.top-e.top<0||t.top<e.top-o?e.top-o:t.top+t.height>e.top+e.height+o?e.top+e.height+o-t.height:t.top:t.top,s=e?t.left<e.left-o?e.left-o:t.left+t.width>e.left+e.width+o?e.left+e.width+o-t.width:t.left:t.left;return{top:n,left:s,height:t.height,width:t.width}}var _o=({className:t,triggerRef:e,boundaryRef:o=(0,ve.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=di,...a})=>{let l=pi(e),c=pi(o),p=(0,ve.useMemo)(()=>i(l,c,0),[l,c]);return(0,Os.jsx)(fp,{children:(0,Os.jsx)("div",{className:(0,ui.default)(Ne.ref,{[Ne.positionAbove]:n==="above",[Ne.positionBelow]:n==="below",[Ne.positionLeft]:n==="left",[Ne.positionRight]:n==="right",[Ne.alignStart]:s==="start",[Ne.alignCenter]:s==="center",[Ne.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,Os.jsx)("div",{className:(0,ui.default)(t,Ne.root),children:r})})})};var yt=require("react/jsx-runtime"),Am=({inputStyle:t,inputElement:e})=>{let o=y("TabCompletion",fe),n=vo(document.activeElement===e);return Xt(()=>n.close()),(0,Ds.useEffect)(()=>{let s=()=>n.open();return e.addEventListener("focus",s),()=>{e.removeEventListener("focus",s)}},[]),(0,yt.jsxs)(Ds.Fragment,{children:[(0,yt.jsx)("mark",{className:fe.caret,ref:n.triggerRef}),n.opened&&(0,yt.jsx)(_o,{className:o.popoverSuggestionsRoot,triggerRef:n.triggerRef,position:"above",align:"start",children:(0,yt.jsx)("div",{style:t,className:o.suggestionsOverlayInputStyles,children:(0,yt.jsx)(As,{inline:!0})})})]})},Ns=class extends hp.Matcher{charCounter=0;charLength=0;found=!1;onlyAtEnd=!1;props;onBeforeParse(e,o){var n;return this.props=o,this.charCounter=0,this.onlyAtEnd=o.inlineSuggestionsOnlyAtEnd??!1,this.charLength=(Xe(o.inputElement)?o.inputElement.value.length:(n=o.inputElement.textContent)==null?void 0:n.length)??0,this.found=!1,e}match(e){if(this.found||!this.props||this.props.selection===null)return null;let[o,n]=this.props.selection;if(o!==n||this.onlyAtEnd&&o!==this.charLength)return null;let s=o,i=s>=this.charCounter&&s<=this.charCounter+e.length?{index:si(e.slice(0,s))+1-this.charCounter,length:0,match:"",valid:!0}:null;return i&&(this.found=!0),this.charCounter+=e.length,i??null}replaceWith(e,o){return(0,yt.jsx)(Am,{inputStyle:o.inputStyle,inputElement:o.inputElement},"caret")}asTag(){return"mark"}};var _p=T(require("classnames")),xp=require("interweave"),Us=require("react");function yp(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Hs(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Sp(t){return t!=null}var vp=T(require("classnames")),Bs=require("react");var gi=require("react/jsx-runtime"),Fs=(0,Bs.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,Bs.useRef)(null),r=y("TabCompletion",fe);return(0,gi.jsx)("div",{ref:Hs([s,n]),className:(0,vp.default)(t,r.popoverContentContainer),...o,children:(0,gi.jsx)("div",{className:r.popoverContent,children:e})})});var St=require("react/jsx-runtime"),Mm=t=>e=>{let o=di(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Om=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",fe),i=vo(),a=(0,Us.useMemo)(()=>Mm(t.getBoundingClientRect()),[t]),[l,c]=ns(t);return(0,Us.useEffect)(()=>{c?i.open():i.close()},[c]),(0,St.jsxs)("span",{children:[(0,St.jsx)("mark",{ref:Hs([l,i.triggerRef]),className:(0,_p.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,St.jsx)(_o,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,St.jsx)(Fs,{style:o,children:(0,St.jsx)("div",{className:r.hintText,children:s})})})]})},Ks=class extends xp.Matcher{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(n=>({...n,keywordRegex:new RegExp(`\\b${yp(n.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(Sp);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return(0,St.jsx)(Om,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var js=T(require("classnames")),Ep=require("interweave"),Z=require("react"),kp=require("react-redux");var mi=require("react/jsx-runtime"),bp=()=>(0,mi.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,mi.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 vt=require("react"),sn=require("react-redux"),wp=T(require("lodash.debounce"));var Cp={root:"_root_1muu8_1",content:"_content_1muu8_7"};function zs(t,e,o){var s;let n=((s=t.imageSizes)==null?void 0:s[e])||t.image||o;if(!n)return null;try{return new URL(n).toString()}catch{return null}}function fi(t){return t.replace("https://www.","").replace("https://","")}var _e=require("react/jsx-runtime"),Nm=3,Dm=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Hm=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Nm})=>{let r=y("LinkSearch",Cp),[i,a]=(0,vt.useState)(""),l=(0,sn.useDispatch)(),c=(0,sn.useSelector)(Ol("url")),p=(0,sn.useSelector)(Cl("URL",Dm)),[u,d]=(0,vt.useState)(p.length-1),m=b("fallbackImage"),h=f=>{let _=f.target;a(_.value)},g=(f,_)=>{f.stopPropagation(),f.preventDefault(),window.open(_,"_blank")},v=f=>{var w;let _=u-1<0?p.length-1:u-1,x=u+1===p.length?0:u+1;f.code==="Escape"&&(a(""),e()),f.code==="ArrowUp"&&d(_),f.code==="ArrowDown"&&d(x),f.code==="Enter"&&t(((w=p[u])==null?void 0:w.text)||i)},k=(0,vt.useCallback)((0,wp.default)(f=>{l(It({query:f,type:"URL",tags:["link-search"]}))},300),[]);return(0,vt.useEffect)(()=>{i&&k(i)},[i]),(0,vt.useEffect)(()=>()=>{l(gs())},[]),(0,_e.jsxs)("div",{className:r.root,children:[(0,_e.jsx)(Re,{withDivider:!0,children:(i?p:c).slice(0,s).map((f,_)=>(0,_e.jsx)(N,{selected:u===_,onClick:()=>t(f.text),"data-testid":"linksearch-suggestion",children:(0,_e.jsxs)(F,{children:[(0,_e.jsx)(F.Image,{src:zs(f,"small",m||void 0),title:f.title||f.text}),(0,_e.jsxs)(F.Content,{className:r.content,cropText:!0,children:[(0,_e.jsx)(F.Title,{children:f.title||fi(f.text)}),f.title&&fi(f.text)]}),(0,_e.jsx)(N.Actions,{children:(0,_e.jsx)(N.ActionButton,{label:n,onClick:x=>g(x,f.text)})})]})},f.text))}),(0,_e.jsx)(Go,{value:i,onChange:h,autoFocus:!0,placeholder:o,onKeyUp:v})]})},Tp=Hm;var hi={};V(hi,{enUS:()=>Bm,nlNL:()=>Fm});var Bm={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Fm={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Q=require("react/jsx-runtime"),Km=(0,Z.forwardRef)((t,e)=>{let o=y("TabCompletion",fe);return(0,Q.jsx)("mark",{ref:e,className:(0,js.default)(o.matchSelection)},"selection-start")}),Um=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(hi),i=y("TabCompletion",fe),a=(0,Z.useRef)(null),l=(0,Z.useRef)(null),[c,p]=(0,Z.useState)(null),u=(0,kp.useDispatch)(),d=vo(document.activeElement===n),[m]=(0,Z.useState)(()=>document.createRange());d.triggerRef.current=m,(0,Z.useEffect)(()=>()=>m.detach(),[]),(0,Z.useEffect)(()=>{let g=t.current,v=a.current;!g||!v||(m.setStart(g,0),m.setEnd(v,0))},[t.current,a.current]),Xt(()=>{d.close()});let h=(0,Z.useCallback)(g=>{let v=m.toString(),k=/^http(s?):\/\//.test(g)?g:`https://${g}`;u(Qn({text:`[${v}](${k})`,replace:"selection"}))},[]);return(0,Q.jsxs)("span",{children:[(0,Q.jsx)("mark",{ref:a,className:(0,js.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:s}),d.opened&&(0,Q.jsx)(_o,{className:i.popoverRoot,triggerRef:d.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,Q.jsxs)(Fs,{style:o,ref:l,children:[(0,Q.jsx)("div",{className:(0,js.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,Q.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,Q.jsx)(bp,{}),(0,Q.jsx)("span",{children:"\xA0"}),(0,Q.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,Q.jsx)(Tp,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{p(null),d.close()}})]})})]},"selection-end")},Vs=class extends Ep.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,Z.createRef)(),this.foundIndex=0,e}match(e){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,n]=this.props.selection;if(o===n)return null;let s=this.foundIndex===0?o:n,r=s>=this.charCount&&s<=this.charCount+e.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;r&&this.foundIndex++;let i=this.foundIndex===1;return r&&i?this.charCount+=s-this.charCount:this.charCount+=e.length,r?{isStart:i,...r}:null}replaceWith(e,o){return o.isStart?(0,Q.jsx)(Km,{ref:this.startRef}):(0,Q.jsx)(Um,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Ze=require("react/jsx-runtime"),zm=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",pp),p=b("insertLink"),u=b("showMidSentenceSuggestions"),d=b("inlineSuggestions"),m=rs(a),h=(0,Je.useRef)(null);(0,Je.useEffect)(()=>{Xe(a)&&m&&is(a,m)},[m]);let g=(0,Je.useCallback)(f=>{if(!s||!o)return f;let _=[(0,Ze.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,Ze.jsx)("span",{className:(0,qs.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&_.push((0,Ze.jsx)("span",{className:(0,qs.default)(c.hint,c.resetIndent),children:(0,Ze.jsx)(Hn,{keyCode:"tab"},"tabHint")})),ci(f,_)},[s,o,n]),v=(0,Je.useMemo)(()=>{let f=[];return d&&f.push(new Ns("inline")),p&&f.push(new Vs("selection")),f.push(new Gt("placeholders")),r&&f.push(new Ks("keywords")),f},[d,p,r]),k=(0,Je.useMemo)(()=>{let f=window.getComputedStyle(a);return{"--dd-color":f.color,"--dd-font-size":f.fontSize,"--dd-font-family":f.fontFamily,"--dd-font-variant":f.fontVariant}},[]);return t?(0,Ze.jsxs)("div",{ref:f=>{f!=null&&f.parentElement&&(h.current=f==null?void 0:f.parentElement)},className:c.root,style:k,children:[(0,Ze.jsx)(Pp.Interweave,{tagName:"span",containerTagName:"div",className:(0,qs.default)(c.container,c.agentText),disableLineBreaks:Xe(a),content:e||"\u200B",onAfterParse:g,matchers:v,selection:m,keywordMatches:i,inputElement:a,inputStyle:k,boundaryRef:h,inlineSuggestionsOnlyAtEnd:!u}),(0,Ze.jsx)("br",{})]}):null},jm=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var g;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??fo(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:u}=s,{showTabCompletion:d,visible:m,showStyleSuggestions:h}=o;return{showTabHint:p,showStyleSuggestions:h,showTabCompletion:d,content:l,tabText:c,source:a,keywordMatches:((g=n.list)==null?void 0:g.keywordMatches)??[],enabled:m&&u!==!1}},Rp=(0,Ip.connect)(jm)(zm);var xu=T(require("classnames")),bu=require("react"),W=require("react-redux");var _t=require("@reduxjs/toolkit");var Lp={list:[],fetchState:"idle",isInitialRequest:null},Mp=t=>t.autoflows.list||[],Ap=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ye=(0,_t.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),yi=(0,_t.createAsyncThunk)("autoflows/start",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.startAutoflowSession(t),await o(Ye(t.platformSessionId))}),Si=(0,_t.createAsyncThunk)("autoflows/stop",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.stopAutoflowSession(t.platformSessionId),await o(Ye(t.platformSessionId))}),Vm=(0,_t.createSlice)({name:"autoflows",initialState:Lp,reducers:{},extraReducers:t=>{t.addCase(yi.pending,(e,o)=>{let n=Ap(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Si.pending,(e,o)=>{let n=Ap(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Ye.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ye.rejected,e=>{e.fetchState="error"}),t.addCase(Ye.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(L,()=>Lp)}}),Op=(0,_t.createAsyncThunk)("autoflows/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");let s=n.openStream(t);s.on("sessionAborted",()=>{o(Ye(t))}),s.on("sessionCompleted",()=>{o(Ye(t))})}),Np=(0,_t.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Dp=Vm.reducer;var xt=require("@reduxjs/toolkit");var Hp={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Bp=t=>t.customMessages.list,Fp=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Kp=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Up=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),rn=(0,xt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Ws=(0,xt.createAsyncThunk)("customMessages/send",async(t,e)=>{let{platformSessionId:o,suggestion:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.sendCustomMessage(o,n)}),Gs=(0,xt.createAsyncThunk)("customMessages/answer",async(t,e)=>{let{platformSessionId:o,reply:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.answerCustomMessage(o,n)}),zp=(0,xt.createSlice)({name:"customMessages",initialState:Hp,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(rn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(rn.rejected,e=>{e.fetchState="error"}).addCase(rn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Ws.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Ws.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Gs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Gs.rejected,(e,o)=>{let n=e.answeredSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1)),e.answeredSuggestions.splice(n,1)}).addCase(L,()=>Hp)}}),jp=(0,xt.createAsyncThunk)("customMessages/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.openStream(t).on("customMessageSuggestion",r=>{o(zp.actions.onCustomMessage(r))})}),Vp=(0,xt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),qp=zp.reducer;var an=require("@reduxjs/toolkit"),qm={jwt:null,accountUrl:null,interval:null},Wp=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},vi=(0,an.createAsyncThunk)("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),_i=(0,an.createAsyncThunk)("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(vi()),setInterval(()=>n(vi()),o)}),Gp=(0,an.createSlice)({name:"exchangeToken",initialState:qm,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(vi.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(_i.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:$p}=Gp.actions,Xp=Gp.reducer;function Qp(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var ru=require("react"),iu=require("react-redux");var ou=T(require("classnames")),nu=require("react");var Jp=T(require("classnames"));var Zp={root:"_root_838fd_1"};var eu=require("react/jsx-runtime"),Wm=({className:t,children:e})=>{let o=y("Unicode",Zp);return(0,eu.jsx)("span",{className:(0,Jp.default)(t,o.root),children:e})},Yp=Wm;var tu={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var xi={};V(xi,{enUS:()=>Gm,nlNL:()=>$m});var Gm={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"}]},$m={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 le=require("react/jsx-runtime"),Qm=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",tu),a=E(xi),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,le.jsxs)(N,{className:(0,ou.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,le.jsx)(F,{children:(0,le.jsxs)(F.Content,{children:[(0,le.jsxs)(F.Title,{children:[e&&(0,le.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,le.jsx)("span",{children:n})]})}),(0,le.jsx)(N.Actions,{fixed:e==="Started",children:(0,le.jsx)(N.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,le.jsxs)(nu.Fragment,{children:[(0,le.jsx)(Yp,{children:c})," ",(0,le.jsx)("span",{children:a(l)})]})})})]})},su=Qm;var bi=require("react/jsx-runtime"),Zm=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Jm=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,bi.jsx)(ru.Fragment,{children:t.map(s=>(0,bi.jsx)(su,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Zm(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Ym=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},ef={onStartAutoflow:yi,onStopAutoflow:Si},au=(0,iu.connect)(Ym,ef)(Jm);var $s=require("react"),cu=require("react-redux"),Ti=T(require("classnames"));var Ci=require("react/jsx-runtime"),wi=()=>(0,Ci.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,Ci.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 lu={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var De=require("react/jsx-runtime"),tf=({entities:t})=>{let e=y("EntitiesWidgetList",lu),[o,n]=(0,$s.useState)(void 0),s=(0,cu.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Xo(a.text),s(ie({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,$s.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,De.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,De.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,De.jsx)("span",{className:e.entityText,children:a.text}),(0,De.jsxs)("span",{className:e.iconWrapper,children:[(0,De.jsx)("span",{className:(0,Ti.default)(e.icon),children:(0,De.jsx)(wi,{})}),(0,De.jsx)("span",{className:(0,Ti.default)(e.icon,o===l&&e.iconClicked),children:(0,De.jsx)(wi,{})})]})]},a.text))})},pu=tf;var uu=T(require("classnames")),Ei=require("react"),Mt=require("react-redux");var ln={};V(ln,{enUS:()=>of,nlNL:()=>nf});var of={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],answer:[{type:0,value:"Answer"}]},nf={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],answer:[{type:0,value:"Antwoord"}]};var et={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};var se=require("react/jsx-runtime"),sf=({suggestion:t})=>{let e=E(ln),o=(0,Mt.useDispatch)(),n=(0,Mt.useSelector)(Fp(t.text)),s=(0,Mt.useSelector)(Kp(t.text)),r=(0,Mt.useSelector)(Up(t.text)),i=(0,Mt.useSelector)(Un),{replyOptions:a}=t,l=(0,Ei.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Ws({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Ei.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let u=parseInt(p.target.dataset.index,10),d=a[u];o(Gs({platformSessionId:i,reply:d,suggestion:t}))},[t,n,o,i]);return(0,se.jsxs)(N,{onClick:l,className:(0,uu.default)(et.root,{[et.isUsed]:n,[et.hasError]:r}),children:[(0,se.jsx)(F,{children:(0,se.jsxs)(F.Content,{children:[(0,se.jsxs)(F.Title,{className:et.title,children:[t.text," ",(0,se.jsx)(Bn,{className:et.label,children:"analyse tool"})," ",r&&(0,se.jsx)("span",{className:et.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,se.jsx)("ul",{className:et.quickReplies,children:a.map(p=>(0,se.jsx)("li",{className:et.quickReply,children:p.title},p.title))})]})}),(0,se.jsxs)(N.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,se.jsx)(N.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,u)=>(0,se.jsx)(N.DropdownItem,{index:u,label:p.title,onClick:c},p.title))}),(0,se.jsx)(N.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},du=sf;var ki=require("react/jsx-runtime"),gu=()=>(0,ki.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,ki.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 hu=require("react-redux");var mu=require("react");var ce=require("react/jsx-runtime"),rf=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var d;let s=t.text||t.url||t.message,r=ms(s),i=E(ln),a=b("showImages"),l=b("fallbackImage"),c=m=>{m.preventDefault(),m.stopPropagation(),n(s)},p=m=>{m.preventDefault(),m.stopPropagation(),o(t)},u=(0,mu.useCallback)(m=>{window.open(r,"_blank"),m.stopPropagation(),m.preventDefault()},[r]);return(0,ce.jsxs)(N,{onClick:c,"data-testid":"edit-suggestion",children:[(0,ce.jsxs)(F,{children:[a&&t.image&&(0,ce.jsx)(F.Image,{src:zs(t,"small",l||void 0),title:t.title}),(0,ce.jsxs)(F.Content,{children:[t.title&&(0,ce.jsx)(F.Title,{children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&(0,ce.jsx)(N.Labels,{labels:t.searchKeywords}),(0,ce.jsx)(F.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,ce.jsxs)(N.Actions,{children:[r&&(0,ce.jsx)(N.ActionButton,{onClick:u,label:i("visitUrl")}),(0,ce.jsx)(N.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,ce.jsx)(N.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},fu=rf;var cn=require("react/jsx-runtime"),af=({contentType:t,lines:e,suggestions:o})=>{let n=Se(),s=(0,hu.useSelector)(oo),r=a=>{n.send(qr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(je,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,cn.jsx)(cn.Fragment,{children:o.map(a=>(0,cn.jsx)(fu,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},yu=af;var Pi={};V(Pi,{enUS:()=>lf,nlNL:()=>cf});var lf={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},cf={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Vat gesprek samen"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Su={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};var Ii=require("react/jsx-runtime"),vu=()=>(0,Ii.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ii.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 Ri=require("react/jsx-runtime"),_u=()=>(0,Ri.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ri.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 I=require("react/jsx-runtime"),Xs=(t,e)=>{let o=(0,W.useSelector)(ze);(0,bu.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},pf=()=>{let t=E(Pi),e=(0,W.useDispatch)(),o=b("isEmbedded"),n=y("Widget",Su),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=(0,W.useSelector)(go),u=(0,W.useSelector)(ks),d=(0,W.useSelector)(Mp),m=(0,W.useSelector)(Cs),h=(0,W.useSelector)(Bp),g=(0,W.useSelector)(zn),v=(0,W.useSelector)(jn),k=(0,W.useSelector)(ze),f=(0,W.useSelector)(Un),_=(0,W.useSelector)(Qp),x=(0,W.useSelector)(oo),w=Se(),C=(0,W.useSelector)(Dl),D=(0,W.useSelector)(Wp("/admin/personal-collection")),ue=b("adminUrl");if(Xs(()=>(e(rn(f)),e(jp(f)),()=>{e(Vp(f))}),[e,v,r,f]),Xs(()=>(e(Ye(f)),e(Op(f)),()=>{e(Np(f))}),[e,v,s,f]),Xs(()=>{u.forEach(({type:R})=>{e(R==="entities"?ke():Ke(R))})},[e,v,g,p]),Xs(()=>(e(_i()),()=>{e($p())}),[e,v,i,g]),v===!1)return(0,I.jsx)("div",{className:n.stateText,children:(0,I.jsx)("div",{children:(0,I.jsx)("p",{children:t("notSupported")})})},"supported");if(k===!1)return(0,I.jsx)("div",{className:n.loginText,children:(0,I.jsx)("div",{children:(0,I.jsx)(Is,{isEmbedded:o,loginUrl:ue})})},"login");if(!p||!f||k===null||C||_)return(0,I.jsx)("div",{className:n.stateText,children:(0,I.jsx)("div",{children:(0,I.jsx)("p",{children:t("waiting")})})},"waiting");let B=c||a||l||D;return(0,I.jsx)("div",{className:(0,xu.default)(n.root),"data-testid":"widget",children:(0,I.jsxs)(Fn,{className:n.sectionList,children:[B&&(0,I.jsx)(st,{title:t("actions"),type:"shortcuts",children:(0,I.jsxs)("div",{className:n.shortcutList,children:[c&&(0,I.jsxs)("button",{className:n.shortcut,onClick:()=>w.send("ShowCommandPalette",{isOpen:!0}),children:[(0,I.jsx)(eo,{}),t("linkSearch")]}),a&&(0,I.jsxs)("button",{className:n.shortcut,onClick:()=>w.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,I.jsx)(_u,{}),t("linkSummary")]}),l&&(0,I.jsxs)("button",{className:n.shortcut,onClick:()=>w.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeSearch"}),children:[(0,I.jsx)(vu,{}),t("linkKnowledgeSearch")]}),D&&(0,I.jsxs)("a",{className:n.shortcut,target:"_blank",href:D,rel:"noreferrer",children:[(0,I.jsx)(gu,{}),t("linkPersonalcollection")]})]})}),r&&h.length>0&&(0,I.jsx)(st,{type:"custom-messages","data-testid":"custom-messages",children:(0,I.jsx)(Re,{withDivider:!0,children:h.map(R=>(0,I.jsx)(du,{suggestion:R},R.text))})}),s&&d.length>0&&(0,I.jsx)(st,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,I.jsx)(Re,{withDivider:!0,children:(0,I.jsx)(au,{})})}),u.map(({type:R,title:U,amount:J,lines:nr})=>{var bt;switch(R){case"entities":return m&&m.length>0&&(0,I.jsx)(st,{type:R,title:U,"data-testid":`type-${R}`,children:(0,I.jsx)(pu,{entities:m})},R);default:return((bt=x[R])==null?void 0:bt.fetchState)==="done"&&x[R].suggestions.length>0&&(0,I.jsx)(st,{type:R,title:U,"data-testid":`type-${R}`,children:(0,I.jsx)(Re,{withDivider:!0,children:(0,I.jsx)(yu,{lines:nr,contentType:R,suggestions:x[R].suggestions.slice(0,J)||[]})})},R)}})]})})},Cu=pf;function wu(t){let e=new Range;return e.selectNodeContents(t),e}var pn=/[\u200B-\u200D\uFEFF]/g;function Ot(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(l))return c;for(let d=0;d<=l.length;d++)if(u.test(l[d])||p++,p===c)return d;throw new Error("Offset out of range")}function a(l){var c;switch(l.nodeType){case Node.TEXT_NODE:{let p=l.textContent,u=p.replace(pn,""),d=s+u.length,m=e>=s&&e<=d,h=o>=s&&o<=d;if(m){let g=i(p,e-s);g===0&&!h?n.setStartBefore(l):n.setStart(l,g)}h&&(n.setEnd(l,i(p,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(l.tagName==="BR"&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let u=0;u<l.childNodes.length&&(a(l.childNodes[u]),!r);u++);let p=(c=l.lastChild)==null?void 0:c.tagName;l.tagName==="DIV"&&p!=="DIV"&&p!=="BR"&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function Qs(t,e){if(!t.contains(e.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i,a,l=0;function c(p){let u=p===o,d=p===s;switch(p.nodeType){case Node.TEXT_NODE:{let m=p.textContent;u&&(i=l+m.substring(0,n).replace(pn,"").length),d&&(a=l+m.substring(0,r).replace(pn,"").length),l+=m.replace(pn,"").length;break}case Node.ELEMENT_NODE:{let{tagName:m}=p,h=p.nextSibling===null;m==="BR"&&!h&&l++;for(let g=0;g<p.childNodes.length&&(u&&g===n&&(i=l),c(p.childNodes[g]),d&&g===r-1&&(a=l),a===void 0);g++);!d&&m==="DIV"&&!h&&l++,d&&(a=l);break}default:break}}if(c(t),a===void 0)throw new Error("Could not determine start and end");return{start:i??a,end:a}}function un(t,e){if(!t.contains(e.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,u=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let d=p?n:0,m=u?r:void 0,h=c.textContent.replace(pn,"");d===0&&m===void 0?a+=h:a+=h.substring(d,m);break}case Node.ELEMENT_NODE:{let{tagName:d}=c,m=c.nextSibling===null;i===0&&d==="BR"&&!m&&(a+=`
3
+ `,Tt.MISSING_INTL_API,i);var x=o.getPluralRules(e,{type:p.pluralType}).select(d-(p.offset||0));_=p.options[x]||p.options.other}if(!_)throw new gr(p.value,d,Object.keys(p.options),i);a.push.apply(a,Po(_.value,e,o,n,s,d-(p.offset||0)));continue}}return wd(a)}function Ed(t,e){return e?re(re(re({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=re(re({},t[n]),e[n]||{}),o},{})):t}function kd(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Ed(t[n],e[n]),o},re({},t)):t}function mr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Pd(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Mn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,bn([void 0],o,!1)))},{cache:mr(t.number),strategy:On.variadic}),getDateTimeFormat:Mn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,bn([void 0],o,!1)))},{cache:mr(t.dateTime),strategy:On.variadic}),getPluralRules:Mn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,bn([void 0],o,!1)))},{cache:mr(t.pluralRules),strategy:On.variadic})}}var Ji=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var u=p.reduce(function(d,m){return!d.length||m.type!==G.literal||typeof d[d.length-1]!="string"?d.push(m.value):d[d.length-1]+=m.value,d},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(c){return Po(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,l=Vi(i,["formatters"]);this.ast=t.__parse(e,re(re({},l),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=kd(t.formats,n),this.formatters=s&&s.formatters||Pd(this.formatterCache)}return Object.defineProperty(t,"defaultLocale",{get:function(){return t.memoizedDefaultLocale||(t.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),t.memoizedDefaultLocale},enumerable:!1,configurable:!0}),t.memoizedDefaultLocale=null,t.resolveLocale=function(e){if(!(typeof Intl.Locale>"u")){var o=Intl.NumberFormat.supportedLocalesOf(e);return o.length>0?new Intl.Locale(o[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Gi,t.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},t}();function Rd(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Id="dummy",fr=(0,Nn.createContext)(null);function E(t){let e=(0,Nn.useContext)(fr);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let o=t[e]??{};return(n,s)=>{let r=Rd(o,n);return r?new Ji(r).format(s):(e!==Id&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var hr={};V(hr,{enUS:()=>Ld,nlNL:()=>Ad});var Ld={experimental:[{type:0,value:"Experimental"}]},Ad={experimental:[{type:0,value:"Experimenteel"}]};var yr=require("react/jsx-runtime"),Yi=({children:t})=>{let e=y("Chip",ji);return(0,yr.jsx)("span",{className:e.root,children:t})},Dn=()=>{let t=E(hr);return(0,yr.jsx)(Yi,{children:t("experimental")})},ea=Yi;var oa=T(require("classnames"));var ta={root:"_root_cq1yq_1"};var na=require("react/jsx-runtime");var Md={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Od=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",ta);return(0,na.jsx)("span",{"data-key":Md[e],className:(0,oa.default)(t,n.root),...o})},Hn=Od;var ra=T(require("classnames"));var sa={root:"_root_4a08n_1"};var ia=require("react/jsx-runtime"),Nd=({className:t,children:e,...o})=>{let n=y("Label",sa);return(0,ia.jsx)("span",{...o,className:(0,ra.default)(t,n.root),children:e})},Bn=Nd;var aa={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var Kt=require("react/jsx-runtime"),Dd=({title:t,children:e,type:o,...n})=>{let s=y("Section",aa);return(0,Kt.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,Kt.jsx)("div",{className:s.subTitleContainer,children:(0,Kt.jsx)("span",{className:s.subtitle,children:t})}),(0,Kt.jsx)("div",{className:s.suggestions,children:e})]})},st=Dd;var ca=T(require("classnames")),pa=T(require("react"));var la={root:"_root_19wxp_1"};var ua=require("react/jsx-runtime"),Hd=pa.default.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",la);return(0,ua.jsx)("div",{ref:o,className:(0,ca.default)(n.root,t),children:e})}),Fn=Hd;var Ro=T(require("classnames")),me=T(require("react"));var Sr={root:"_root_9kn3u_10",fadein:"_fadein_9kn3u_1",isClickable:"_isClickable_9kn3u_47",isSelected:"_isSelected_9kn3u_52",actions:"_actions_9kn3u_76",actionsIsFixed:"_actionsIsFixed_9kn3u_98",actionButton:"_actionButton_9kn3u_106",dropdownList:"_dropdownList_9kn3u_127",dropdownButton:"_dropdownButton_9kn3u_142",dropdownItem:"_dropdownItem_9kn3u_152",dropdownItemButton:"_dropdownItemButton_9kn3u_161",actionButtonIsPrimary:"_actionButtonIsPrimary_9kn3u_175",actionButtonIsDisabled:"_actionButtonIsDisabled_9kn3u_179",labels:"_labels_9kn3u_187",label:"_label_9kn3u_187"};var ge=require("react/jsx-runtime"),Ut=(0,me.createContext)(Sr),Bd=({fixed:t,children:e,...o})=>{let n=(0,me.useContext)(Ut);return(0,ge.jsx)("div",{...o,className:(0,Ro.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Fd=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,me.useContext)(Ut);return(0,ge.jsxs)("div",{className:(0,Ro.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,ge.jsx)("ul",{className:r.dropdownList,children:s})]})},Kd=({index:t,label:e,onClick:o})=>{let n=(0,me.useContext)(Ut);return(0,ge.jsx)("li",{className:n.dropdownItem,children:(0,ge.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Ud=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,me.useContext)(Ut);return(0,ge.jsx)("button",{type:"button",className:(0,Ro.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},vr=({labels:t})=>{let e=(0,me.useContext)(Ut);return(0,ge.jsx)("div",{className:e.labels,children:t.map(o=>(0,ge.jsx)("span",{className:e.label,children:o},o))})},zt=me.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",Sr),l=(0,me.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,ge.jsx)(s,{...r,ref:i,className:(0,Ro.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,ge.jsx)(Ut.Provider,{value:a,children:n})})});zt.Labels=vr;zt.Actions=Bd;zt.ActionButton=Ud;zt.DropdownButton=Fd;zt.DropdownItem=Kd;var N=zt;var ga=T(require("classnames"));var da={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var ma=require("react/jsx-runtime"),zd=({withDivider:t,children:e})=>{let o=y("SuggestionList",da);return(0,ma.jsx)("div",{className:(0,ga.default)(o.root,{[o.isWithDivider]:t}),children:e})},Le=zd;var ha=T(require("classnames"));var fa={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Kn=require("react/jsx-runtime"),jd=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",fa);return(0,Kn.jsx)("button",{type:"button",className:(0,ha.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,Kn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Kn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Et=jd;var ya=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,jt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Sa=/x-deepdesk-(([a-z0-9\-_])+-version)/,Ce=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(Ce||{}),rt=(s=>(s.TAB="tab",s.ARROW="arrow",s.HOTKEY="hotkey",s.MOUSE="mouse",s))(rt||{});var ot=require("react-dom");var jc=require("react");var va=require("@reduxjs/toolkit"),_a=require("react-redux");var Io=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Io||{});var Vd={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showPersonalCollectionLink:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,adminUrl:void 0,productName:"Deepdesk"},xa=(0,va.createSlice)({name:"settings",initialState:Vd,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Lo}=xa.actions,_r=t=>e=>e.settings[t],b=t=>(0,_a.useSelector)(_r(t)),ba=xa.reducer;var pc=require("react"),co=require("react-redux");var Ae=require("@reduxjs/toolkit"),ka=require("diff"),Pa=require("react-redux");function Ca(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function it(t,e,o=10){let n=typeof t,s=typeof e;if(o===0)throw new Error("Max depth deepEqual, possible circular references?");return n!==s?!1:t==null||n==="string"||n==="number"||n==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>it(r,e[i],o-1)):Ca(t)&&Ca(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>it(t[i],e[i],o-1)):!1}function qd(t){return Math.max(...t.map(e=>e.length))}function Wd(t,e){let o=t.reduce((n,s)=>{if(s){let r=n[s]?n[s]+1:1;return{...n,[s]:r}}return n},{});return Object.keys(o).reduce((n,s)=>(o[s]<e&&n.push(s),n),[])}function wa(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<qd(n);s++){let r=Wd(n.map(a=>a[s]),e),i=n.filter(a=>!r.includes(a[s]));if(i.length>=e)n=i;else return{text:n[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Gd=2;function xr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=wa(t,Gd);return o&&o.text!==e?o:t[0]}var we=require("@reduxjs/toolkit"),Ta={current:null,isSupported:null},L=(0,we.createAction)("resetConversation"),Un=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},zn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},jn=t=>t.conversation.isSupported,br=(0,we.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Vn=(0,we.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),qn=(0,we.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Wn=(0,we.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=zn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Cr=(0,we.createAsyncThunk)("conversation/upsert",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId).catch(()=>null).then(n=>{if(!n)return o.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),Gn=(0,we.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=zn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),$d=[Vn.rejected,qn.rejected,Wn.rejected,Gn.rejected].map(t=>t==null?void 0:t.toString()),Xd=(0,we.createSlice)({name:"conversation",initialState:Ta,reducers:{},extraReducers:t=>{t.addCase(br.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Vn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(qn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Cr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Wn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Gn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(L,()=>Ta).addMatcher(e=>$d.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),Ea=Xd.reducer;var at={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Xn(t){let{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}=t;return{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}}var Qn=(0,Ae.createAction)("input/replaceText"),Zn=(0,Ae.createAction)("input/keyDown"),kt=(0,Ae.createAction)("input/sendMessage"),Jn=(0,Ae.createAction)("input/sendEditSuggestionMessage"),Yn=(0,Ae.createAction)("input/uiInputChange"),es=(0,Ae.createAction)("input/applyImageSuggestion"),ie=(0,Ae.createAction)("input/sendEvent");function $n(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,u=o==="search"||o==="personal-collection-search",d=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(u||p==="selection")&&(d=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(d=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:d,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:u?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var Ra=t=>(0,Ae.createSlice)({name:t,initialState:at,reducers:{initialInput(e,o){let{text:n,selection:s,html:r}=o.payload;e.text=n,e.selection.start=(s==null?void 0:s.start)??n.length,e.selection.end=(s==null?void 0:s.end)??n.length,e.userCommitted.text=n,e.userCommitted.selection.start=(s==null?void 0:s.start)??n.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??n.length,e.html=r||null},reset(e){Object.assign(e,{...at,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=xr(e.textSuggestions,e.userCommitted.text)},setInputHtml(e,o){e.html=o.payload},changeSelection(e,o){o.payload&&(it(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&$n(e)))},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:u,ctrlKey:d,metaKey:m,altKey:h}=e.previousKeyDownEvent;switch(p){case"Enter":u&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=e,{text:v}=o.payload,k=(0,ka.diffChars)(g,v);g.length-v.length>1&&e.metrics.deletions.push(...k.filter(f=>f.removed).map(f=>f.value)),e.metrics.numCharsDeleted+=g.length-v.length;break}case"C":case"V":case"X":if(!d&&!m){e.metrics.numCharsTyped+=1;let g=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}break;case"Shift":break;default:if(!d&&!m&&!h){e.metrics.numCharsTyped+=1;let g=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=at.metrics,e.textSuggestions=[]),e.text!==o.payload.text&&$n(e);let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end,e.userCommitted.selection.start=r.start,e.userCommitted.selection.end=r.end),e.text=n,e.html=s||null,e.userCommitted.text=n,e.previousKeyDownEvent=null},stageSuggestion(e,o){let{text:n}=o.payload;switch(e.stagedSuggestion=o.payload,e.tabCompletionSuggestion=void 0,o.payload.replace){case"selection":e.text=`${e.text.slice(0,e.selection.start)}${n}${e.text.slice(e.selection.end)}`,e.selection.end=e.selection.start+n.length,e.selection.start+=n.length;break;case"until-selection-end":e.text=`${n}${e.text.slice(e.selection.end)}`,e.selection.start=n.length,e.selection.end=n.length;break;default:throw new Error(`Unknown replace ${o.payload.replace}`)}o.payload.eventMetrics.inputType==="tab"&&$n(e)},commitSuggestion(e){$n(e)},offeredTextSuggestion(e,o){let{text:n,suggestion:{source:s}}=o.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:s})},registerCut(e,o){let{metrics:n}=e,s=o.payload;e.metrics={...e.metrics,numCharsCut:n.numCharsCut+s.length,cuts:[...n.cuts,s]}},registerPaste(e,o){let{metrics:n}=e,{text:s,selectionText:r}=o.payload,i=n.numCharsDeleted+(r&&r.length?r.length:0),a=r&&r.length?[...n.deletions,r]:n.deletions;e.metrics={...e.metrics,numCharsDeleted:i,deletions:a,numCharsPasted:n.numCharsPasted+s.length,numPaste:n.numPaste+1,pastes:[...n.pastes,s]}},registerKeyDown(e,o){e.previousKeyDownEvent=o.payload},nextTextSuggestionIndex(e){let o=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<o-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},previousTextSuggestionIndex(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},setTextSuggestions(e,o){if(e.selectedSuggestionIndex=-1,e.textSuggestions=o.payload,o.payload.length===0)return;let n=e.userCommitted.text.substring(0,e.userCommitted.selection.end),s=xr(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)}},extraReducers:e=>{e.addCase(L,o=>{o.tabCompletionSuggestion=at.tabCompletionSuggestion,o.previousKeyDownEvent=at.previousKeyDownEvent,o.textSuggestions=at.textSuggestions,o.selectedSuggestionIndex=at.selectedSuggestionIndex,o.metrics=at.metrics})}}),wr=Ra("input"),Vt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Qd=t=>t.input.selection,Ia=()=>(0,Pa.useSelector)(Qd),{userInput:La,changeSelection:Tr,initialInput:Aa,mergeMetrics:Ma,nextTextSuggestionIndex:Oa,offeredTextSuggestion:Na,previousTextSuggestionIndex:Da,registerCut:Ha,registerKeyDown:Ba,registerPaste:Fa,reset:Ka,resetToCommitted:Ao,setInputHtml:Ua,setSelectedTextSuggestionIndex:ts,setTextSuggestions:lt,stageSuggestion:Te,commitSuggestion:ct}=wr.actions,Y=Ra("overlay");var qt=require("react");var za={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var Er=require("react/jsx-runtime"),Zd=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,qt.useRef)(null),l=(0,qt.useRef)(null),c=y("Dialog",za);return(0,qt.useEffect)(()=>{var d,m;let p=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),s())},u=h=>{let g=window.getSelection();g!=null&&g.toString()||h.target===a.current&&t&&n()};return(d=a.current)==null||d.addEventListener("click",u),(m=a.current)==null||m.addEventListener("keyup",p),()=>{var h,g;(h=a.current)==null||h.removeEventListener("click",u),(g=a.current)==null||g.removeEventListener("keyup",p)}},[a,l,s,n]),(0,qt.useEffect)(()=>{var p,u;!a.current||!t||!e||(u=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||u.focus()},[t,e,a]),t?(0,Er.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,Er.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},Wt=Zd;var jr=require("react"),hs=require("react-redux");var kr={};V(kr,{enUS:()=>Jd,nlNL:()=>Yd});var Jd={dismiss:[{type:0,value:"Close"}],add:[{type:0,value:"Add to message"}],next:[{type:0,value:"Next"}],previous:[{type:0,value:"Previous"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},Yd={dismiss:[{type:0,value:"Sluiten"}],add:[{type:0,value:"Toevoegen"}],next:[{type:0,value:"Volgende"}],previous:[{type:0,value:"Vorige"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var ja={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};var Mo=require("react/jsx-runtime"),os=()=>(0,Mo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Mo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Mo.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 Oo=require("react/jsx-runtime"),Va=()=>(0,Oo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,Oo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,Oo.jsx)("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});var he=require("react"),il=require("react-redux"),al=require("interweave"),Nr=T(require("classnames"));var Pr={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var Wa=require("interweave"),Ga=T(require("classnames"));var Gt=require("react");function qa(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function ns(t){let e=(0,Gt.useRef)(null),[o,n]=(0,Gt.useState)(!1);return(0,Gt.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=qa((p,u)=>{let d=e.current;if(!d)return;let m=p/r,h=u/r,g=d.getBoundingClientRect(),v=m>g.x&&m<g.x+g.width&&h>g.y&&h<g.y+g.height;v&&!s?(s=!0,n(!0)):!v&&s&&(s=!1,n(!1))},({clientX:p,clientY:u})=>[p,u]),[l,c]=qa(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var fe={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};var Rr=require("react/jsx-runtime"),eg=({inputElement:t,children:e})=>{let o=y("TabCompletion",fe),[n,s]=ns(t);return(0,Rr.jsx)("mark",{ref:n,className:(0,Ga.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},$t=class extends Wa.Matcher{match(e){let o=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return o?{index:o.index,length:o[0].length,match:o[0],matchString:o[0],valid:!0}:null}replaceWith(e,o){return(0,Rr.jsx)(eg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Xt=require("react");function ss(t){return t.contentEditable==="true"}function tg(t){let e=0,o=0,n=window.getSelection();if(n.rangeCount!==0){let s=n.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),o=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:o}}function $a(t){let{selectionStart:e,selectionEnd:o}=ss(t)?tg(t):t;return[e,o]}function rs(t){let[,e]=(0,Xt.useState)(),o=(0,Xt.useRef)(null);return o.current=$a(t),(0,Xt.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=$a(t);(!i||s!==i[0]||r!==i[1])&&(o.current=i,e({}))};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",n)}},[t]),o.current}function is(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(jt);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=n.indexOf(l,a);return s>c&&r<c+l.length?(o.selectionStart=c,o.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}var Xa=require("react");function Qt(t){(0,Xa.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Pt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Qa,Me=new Map,og=["bottom","height","left","right","top","width"],ng=(t={},e={})=>og.some(o=>t[o]!==e[o]),Za=()=>{let t=[];Me.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Me.delete(o);return}let n=o.getBoundingClientRect();ng(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(o=>o(e.rect))}),Me.size!==0&&(Qa=window.requestAnimationFrame(Za))};function Ja(t,e){return{observe(){let o=Me.size===0;if(Me.has(t)){let n=Me.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Me.set(t,{rect:void 0,callbacks:[e]});o&&Za()},unobserve(){let o=Me.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Me.delete(t),Me.size||cancelAnimationFrame(Qa)}}}}var Ya,Oe=new Map,el=()=>{Oe.forEach((t,e)=>{if(!e.isConnected){Oe.delete(e);return}let{clientHeight:o,scrollHeight:n}=e,s=n>o;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),Oe.size!==0&&(Ya=window.requestAnimationFrame(el))};function tl(t,e){return{observe(){let o=Oe.size===0;Oe.has(t)?Oe.get(t).callbacks.push(e):Oe.set(t,{visible:void 0,callbacks:[e]}),o&&el()},unobserve(){let o=Oe.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Oe.delete(t),Oe.size||cancelAnimationFrame(Ya)}}}}var Ir=["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 Lr(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function Zt(t){return parseFloat(t)}function as(t){return Math.round(t*1e6)}function ol(t){return t/1e6}function Ar(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=Zt(t.width),r=Zt(t.borderLeftWidth),i=Zt(t.borderRightWidth),a=Zt(t.paddingRight),l=ol(as(s)-as(r)-as(i)),c=ol(as(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Jt(t,e={}){var l;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position="fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Pt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Lr(n,o,Ir),Ar(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=tl(t,()=>{Lr(n,o,Ir),Ar(n,t,o),r(),setTimeout(r,0)}),a=Ja(t,c=>{if(c===null){e.onRemove&&e.onRemove(),o.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Lr(n,o,Ir),Ar(n,t,o),r(),o.style.top=`${c.top}px`,o.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),d=Zt(u.borderTopWidth),m=Zt(u.borderBottomWidth),h=p.top+d-c.top,g=c.top+c.height+-(p.top+p.height-m);o.style.clipPath=`inset(${h}px 0px ${g}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var Mr={};V(Mr,{enUS:()=>sg,nlNL:()=>rg});var sg={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},rg={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};var No=require("react/jsx-runtime"),nl=()=>(0,No.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,No.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,No.jsx)("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});var Or=require("react/jsx-runtime"),sl=()=>(0,Or.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Or.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var rl=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(rl||{}),He=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentHTML="";currentSelection=null;isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e,rawHtml:o}),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e,rawHtml:o}),this.currentHTML=o))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange()}handleFocus(){this.isFocused||this.emit("focus"),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(rl).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){let e=this.currentSelection;this.isPossibleClearInputAction=!0,e&&this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){let o=(e.clipboardData||window.clipboardData).getData("text");this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){let e=()=>{let n=document.activeElement===this.element?this.getSelection():null;it(this.currentSelection,n)||(this.currentSelection=n,this.emit("selection",n))};document.addEventListener("selectionchange",e),this.disposeHandlers.push(()=>{window.document&&document.removeEventListener("selectionchange",e)}),this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let o=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});o.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{o.disconnect()})}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var Be=class extends He{getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){return this.currentSelection?this.getText().slice(this.currentSelection.start,this.currentSelection.end):""}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var ee=require("react/jsx-runtime"),ig=({value:t,onUse:e,...o})=>{var p;let n=E(Mr),s=(0,il.useDispatch)(),r=y("EditSuggestionTextInput",Pr),[i,a]=(0,he.useState)(null),l=(0,he.useRef)(null),c=((p=t.match(jt))==null?void 0:p.length)||0;return(0,he.useEffect)(()=>{let u;return l.current&&(a(l.current),u=new Be(l.current),u.on("change",({plainText:d})=>{s(Y.actions.userInput({text:d,selection:u.getSelection()}))}),u.on("keydown",d=>{s(Y.actions.registerKeyDown(Xn(d))),d.code==="Enter"&&d.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:d,selectionText:m})=>{s(Y.actions.registerPaste({text:d,selectionText:m}))}),u.on("cut",({selectionText:d})=>{s(Y.actions.registerCut(d))})),()=>{s(Y.actions.reset()),u.dispose(),u.deactivate()}},[l]),(0,he.useEffect)(()=>{t&&l.current&&(l.current.value=t)},[t,l]),(0,he.useEffect)(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let u=l.current.value.length;l.current.setSelectionRange(u,u),l.current.focus()},0)},[l]),(0,ee.jsxs)("div",{className:r.textInputWrapper,children:[(0,ee.jsx)("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&(0,ee.jsx)(ag,{inputElement:l.current,value:t}),(0,ee.jsxs)("div",{className:(0,Nr.default)(r.alert,c===0?r.success:r.warning),children:[(0,ee.jsx)("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?(0,ee.jsx)(nl,{}):(0,ee.jsx)(sl,{})]})]})},ag=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",Pr),n=(0,he.useRef)(null),s=rs(t);return(0,he.useEffect)(()=>{is(t,s)},[s,t]),(0,ee.jsx)(lg,{inputElement:t,children:(0,ee.jsxs)("div",{ref:n,className:(0,Nr.default)(o.root,o.agentText),children:[(0,ee.jsx)(al.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new $t("placeholders")],inputElement:t,boundaryRef:n}),(0,ee.jsx)("br",{})]})})},lg=({inputElement:t,children:e})=>{let o=(0,he.useRef)(null);return(0,he.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=Jt(t,{overlayContainer:o.current,mirrorOverflow:!0});return()=>{s()}},[o.current]),(0,ee.jsx)("div",{ref:o,children:e})},ll=ig;var oo=require("react");var cl=require("react"),ls=T(require("classnames"));var te={root:"_root_185k9_1",list:"_list_185k9_2",listWrapper:"_listWrapper_185k9_6",listHorizontal:"_listHorizontal_185k9_10",page:"_page_185k9_19",search:"_search_185k9_25",pageNav:"_pageNav_185k9_33",pageTitle:"_pageTitle_185k9_41",pageBackButton:"_pageBackButton_185k9_48",listHeading:"_listHeading_185k9_62",listItem:"_listItem_185k9_70",listItemContent:"_listItemContent_185k9_79",listItemText:"_listItemText_185k9_97",listItemDescription:"_listItemDescription_185k9_105",truncate:"_truncate_185k9_112",lineClamp:"_lineClamp_185k9_118",listItemTitle:"_listItemTitle_185k9_125",listItemAction:"_listItemAction_185k9_132",listItemPrimaryAction:"_listItemPrimaryAction_185k9_146",listItemSelected:"_listItemSelected_185k9_151",sources:"_sources_185k9_155",sourcesTitle:"_sourcesTitle_185k9_162",source:"_source_185k9_155",icon:"_icon_185k9_177",searchIcon:"_searchIcon_185k9_194",searchInputWrapper:"_searchInputWrapper_185k9_199",searchInput:"_searchInput_185k9_199",select:"_select_185k9_220",selectType:"_selectType_185k9_237",selectWrapper:"_selectWrapper_185k9_241",image:"_image_185k9_271",imageSrc:"_imageSrc_185k9_278",imageSrcHidden:"_imageSrcHidden_185k9_289",imageSrcStatus:"_imageSrcStatus_185k9_293",imageTitle:"_imageTitle_185k9_303",actions:"_actions_185k9_308",actionsWrapper:"_actionsWrapper_185k9_312",actionsBar:"_actionsBar_185k9_318",actionButton:"_actionButton_185k9_327",actionShortcut:"_actionShortcut_185k9_345",actionShortcutFixKerning:"_actionShortcutFixKerning_185k9_352"};var Rt={};V(Rt,{enUS:()=>cg,nlNL:()=>pg});var cg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},pg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var pt=require("react/jsx-runtime"),ug=({src:t,title:e})=>{let o=y("CommandPalette",te),[n,s]=(0,cl.useState)("loading"),r=E(Rt);return(0,pt.jsxs)("div",{className:o.image,children:[(0,pt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,ls.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,pt.jsx)("span",{className:(0,ls.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,pt.jsx)("span",{className:(0,ls.default)(o.imageSrc,o.imageSrcStatus),children:(0,pt.jsx)(Sn,{})}),e&&(0,pt.jsx)("span",{className:o.imageTitle,children:e})]})},pl=ug;var ul=T(require("react")),dl=T(require("classnames"));var Do=require("react/jsx-runtime");function Dr({children:t,heading:e,orientation:o}){let n=y("CommandPalette",te);return ul.default.Children.count(t)===0?null:(0,Do.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,Do.jsx)("h4",{className:n.listHeading,children:e}),(0,Do.jsx)("div",{className:(0,dl.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var Ho=T(require("classnames"));var cs=T(require("react")),fl=require("react/jsx-runtime"),gl=cs.default.createContext(void 0);function ut(){let t=cs.default.useContext(gl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var ml=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=cs.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,fl.jsx)(gl.Provider,{value:i,children:t})};var ye=require("react/jsx-runtime");function Hr({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onSourceClick:s,index:r,isExperimental:i,description:a,sources:l,styles:c,...p}){let{selected:u,onChangeOpen:d}=ut(),m=y("CommandPalette",te);function h(g){n(g),t&&d(!1)}return(0,ye.jsxs)("div",{className:(0,Ho.default)(m.listItem,u===r&&m.listItemSelected),children:[(0,ye.jsxs)("button",{type:"button",className:(0,Ho.default)("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:h,...p,children:[(0,ye.jsxs)("div",{className:m.listItemContent,children:[typeof o=="string"?(0,ye.jsx)("p",{className:(0,Ho.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,ye.jsx)("p",{className:(0,Ho.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate),children:a})]}),i&&(0,ye.jsx)(Dn,{})]}),l&&(0,ye.jsxs)("div",{className:m.sources,children:[(0,ye.jsx)("span",{className:m.sourcesTitle,children:"Sources"}),l.map(g=>g.url?(0,ye.jsx)("a",{className:m.source,href:g.url,target:"_blank",title:g.url,rel:"noopener noreferrer",onClick:()=>s&&s(g),children:g.name},g.url):(0,ye.jsx)("span",{className:m.source,children:g.name},g.name))]})]})}var dt=require("react/jsx-runtime");function Br({children:t,title:e,id:o,onDismiss:n,isExperimental:s}){let r=E(Rt),i=y("CommandPalette",te),{page:a}=ut();return a!==o?null:(0,dt.jsxs)("div",{className:i.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,dt.jsxs)("div",{className:i.pageNav,children:[(0,dt.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:n,children:[(0,dt.jsx)(os,{}),r("back")]}),e&&(0,dt.jsx)("h3",{className:i.pageTitle,children:e}),s&&(0,dt.jsx)(Dn,{})]}),t]})}var gt=require("react");var ps=()=>/Mac/i.test(navigator.platform);var ds=require("@reduxjs/toolkit");var dg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},P=dg;var Yt=require("@reduxjs/toolkit");function gg(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function O(t){return Array.isArray(t)?t.map(O):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[gg(o)]:O(t[o])}),{}):t}function Fr(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function z(t){return Array.isArray(t)?t.map(z):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Fr(o)]:z(t[o])}),{}):t}var mg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Fo=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},Bo=(0,Yt.createAsyncThunk)("info/setAgentInfo",async(t,e)=>{let{deepdeskAPI:o}=e.extra;if(!t.agentId&&!t.agentNickname)throw new Error("At least provide agentId or agentNickname");let n=await o.client.get("/apis/admin/session/me/",{version:null}),s={};return n.external_id||(s.external_id=t.agentId),n.nickname||(s.nickname=t.agentNickname),!s.external_id&&!s.nickname?O(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),O(n))}),Kr=(0,Yt.createAsyncThunk)("info/setAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.client.get("/apis/admin/session/me/",{version:null}),s={...typeof n.ui_config=="object"?n.ui_config:{},...t};return await o.client.patch("/apis/admin/session/me/",{ui_config:s}),s}),Ur=(0,Yt.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),hl=t=>t.info.agentInfo,yl=(0,Yt.createSlice)({name:"info",initialState:mg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Bo.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Bo.rejected,e=>{e.fetchState="error"}).addCase(Bo.fulfilled,(e,o)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...o.meta.arg,agentId:o.payload.externalId||o.meta.arg.agentId||"",agentNickname:o.payload.nickname||o.meta.arg.agentNickname||""}}).addCase(Kr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(Ur.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(L,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Sl}=yl.actions,vl=yl.reducer;var us={list:[],fetchState:"idle",isOpen:!1,page:"search"},_l=t=>t.search.isOpen,xl=t=>t.search.page,bl=t=>t.search.list;function Cl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var It=(0,ds.createAsyncThunk)("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:Fo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),wl=(0,ds.createSlice)({name:"search",initialState:us,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=us.fetchState,t.list=us.list}},extraReducers:t=>{t.addCase(It.pending,e=>{e.fetchState="loading"}).addCase(It.rejected,(e,o)=>{e.fetchState="error",P.error(o.error)}).addCase(It.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(L,()=>us)}}),{resetSearch:gs,setIsOpen:ae,setPage:X}=wl.actions,Tl=wl.reducer;var fg=/(https?:\/\/[^\s]+)/,ms=t=>t.split(" ").find(e=>fg.test(e));var zr=T(require("classnames"));var fs=require("react/jsx-runtime"),hg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",te);return(0,fs.jsxs)("button",{type:"button",...n,onClick:t,className:(0,zr.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,fs.jsx)("span",{className:(0,zr.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},eo=hg;var Fe=require("react/jsx-runtime"),yg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",te),a=E(Rt),{selected:l,setSelected:c}=ut(),p=r[l],u=p&&typeof p.text=="string"&&ms(p.text),d=(0,gt.useRef)(null);function m(_){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),w=0,C=0;_==="down"?(x.forEach((ue,B)=>{B===l&&(w=B)}),C=w===x.length-1?0:w+1):_==="up"?(x.forEach((ue,B)=>{B===l&&(w=B)}),C=w?w-1:x.length-1):c(0);let D=x[C];D&&typeof C=="number"&&(c(C),D.scrollIntoView&&D.scrollIntoView({behavior:"smooth",block:C?"center":"end"}))}function h(){if(!d.current)return;let _=d.current.querySelectorAll(".command-palette-list-item"),x=0;_.forEach((C,D)=>{D===l&&(x=D)});let w=_[x];w&&w.click()}let g=()=>{u&&window.open(u,"_blank")},v=()=>{p&&n(p,l)},k=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},f=(0,gt.useCallback)(_=>{if(_.key==="Enter"&&_.altKey&&u){g();return}if(_.key==="Enter"&&_.shiftKey){k();return}if(_.key==="ArrowDown"){_.preventDefault(),_.stopPropagation(),m("down");return}if(_.key==="ArrowUp"){_.preventDefault(),_.stopPropagation(),m("up");return}_.key==="Enter"&&l!==-1&&(_.preventDefault(),_.stopPropagation(),h())},[l]);return(0,gt.useEffect)(()=>(window.addEventListener("keyup",f),()=>{window.removeEventListener("keyup",f)}),[f]),(0,Fe.jsxs)("div",{className:i.actions,children:[(0,Fe.jsx)("div",{className:i.actionsWrapper,ref:d,children:t}),(0,Fe.jsxs)("div",{className:i.actionsBar,children:[u&&(0,Fe.jsx)(eo,{onClick:g,shortKeys:[ps()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Fe.jsxs)(gt.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,Fe.jsx)(eo,{onClick:k,shortKeys:[8679,8629],children:o}),(0,Fe.jsx)(eo,{onClick:v,shortKeys:[8629],children:e})]})]})]})},kl=yg;var Pl=require("react");var Ko=require("react/jsx-runtime"),to=()=>(0,Ko.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Ko.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Ko.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 Ee=require("react/jsx-runtime");function Sg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",te);return(0,Ee.jsxs)("div",{className:l.search,children:[(0,Ee.jsx)("div",{className:l.searchIcon,children:(0,Ee.jsx)(to,{})}),(0,Ee.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Ee.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&(0,Ee.jsx)("div",{className:l.selectWrapper,children:(0,Ee.jsxs)("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&&(0,Ee.jsx)("option",{children:n}),s.map(c=>(0,Ee.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Rl=(0,Pl.forwardRef)(Sg);var Uo=require("react/jsx-runtime");function Lt({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:u,search:d}){let[m,h]=(0,oo.useState)(0),g=(0,oo.useRef)(null),v=()=>{s&&s(o),i(void 0),r(""),a(!1)},k=()=>{var f;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(f=g.current)==null||f.focus();return}if(d.length>0){r("");return}a(!1)};return(0,oo.useEffect)(()=>{h(0)},[d,n]),(0,Uo.jsx)(Wt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:k,onClose:v,children:(0,Uo.jsxs)(ml,{selected:m,setSelected:h,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&(0,Uo.jsx)(Rl,{ref:g,onChange:r,onChangeType:i,placeholder:t,value:d,selectedType:l,types:c,typePlaceholder:e}),p]})})}Lt.Page=Br;Lt.List=Dr;Lt.Image=pl;Lt.ListItem=Hr;Lt.ActionsBar=kl;Lt.Button=eo;var A=Lt;var $=require("react/jsx-runtime"),vg=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",ja),l=(0,hs.useDispatch)(),c=E(kr),p=(0,hs.useSelector)(h=>h.overlayInput.text);(0,jr.useEffect)(()=>{t&&(l(Y.actions.reset()),l(Y.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Y.actions.commitSuggestion()))},[t]);let u=h=>{h.preventDefault(),d(p)},d=h=>{l(Jn(h)),e(h)},m=h=>g=>{p!==i?window.confirm(c("warning"))&&h(g):h(g)};return(0,jr.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,$.jsxs)("div",{className:a.root,children:[(0,$.jsxs)("div",{className:a.content,children:[t.title&&(0,$.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,$.jsx)(vr,{labels:t.searchKeywords}),(0,$.jsx)(ll,{onUse:d,value:p})]}),(0,$.jsxs)("form",{className:a.actions,onSubmit:u,children:[(0,$.jsxs)("div",{children:[(0,$.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&m(r),children:(0,$.jsx)(os,{})}),(0,$.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&m(s),children:(0,$.jsx)(Va,{})})]}),(0,$.jsxs)("div",{className:a.primaryButtons,children:[(0,$.jsx)(A.Button,{onClick:m(o),shortKeys:["esc"],children:c("dismiss")}),(0,$.jsx)(A.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},ys=vg;var At=require("@reduxjs/toolkit");var _g=["{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}"],xg=new RegExp(_g.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Il(t,e){let o=t.split(xg),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let u=a.charAt(0),d=0;do c=u?e.indexOf(u,c+1):-1,d+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&d>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function Ll(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Ml={suggestions:[],fetchState:"idle",isInitialRequest:null},Al={default:Ml},Ol=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},Nl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},Dl=t=>{let e=Object.keys(t.textSuggestions).map(o=>{var n;return(n=t.textSuggestions[o])==null?void 0:n.fetchState});return e.length===0?!0:e.every(o=>o!=="done")},no=t=>t.textSuggestions,Hl=t=>e=>e.text.startsWith(t),Ss=(0,At.createAction)("textSuggestions/refresh"),Ke=(0,At.createAsyncThunk)("textSuggestions/recommendations",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,inlineSuggestions:i}=n.settings,a=Vt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Fo(n),t);if(t==="default"){let p=i?l.filter(Hl(a)):l;e.dispatch(lt(p.slice(0,r)))}return l}),zo=(0,At.createAsyncThunk)("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getAutocompleteSuggestions(s,{...Fo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Hl(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Il(p.text,t):p.text}))),l=Ll(l,r),e.dispatch(lt(l)),l}),Bl=(0,At.createSlice)({name:"textSuggestions",initialState:Al,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:o}=e.payload;t[o].fetchState="done",t[o].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}},setSuggestionState(t,e){return e.payload}},extraReducers:t=>{t.addCase(Ke.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Ml;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Ke.rejected,(e,o)=>{let n=o.meta.arg;e[n].fetchState="error"}).addCase(Ke.fulfilled,(e,o)=>{let n=o.meta.arg;e[n].fetchState="done",e[n].suggestions=o.payload}).addCase(zo.pending,e=>{e.default.fetchState="loading"}).addCase(zo.rejected,e=>{e.default.fetchState="error"}).addCase(zo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(L,()=>Al)}}),{setTextSuggestions:Fl,setSuggestionState:Kl}=Bl.actions,Ul=Bl.reducer;var jl=require("@reduxjs/toolkit");var zl={contentType:null,suggestion:null},Vl=t=>t.activeSuggestion.suggestion,ql=t=>t.activeSuggestion.contentType,Wl=(0,jl.createSlice)({name:"activeSuggestion",initialState:zl,reducers:{setActiveSuggestion(t,e){let{contentType:o,suggestion:n}=e.payload;t.contentType=o,t.suggestion=n},resetActiveSuggestion(t){t.contentType=null,t.suggestion=null}},extraReducers:t=>{t.addCase(L,()=>zl)}}),{setActiveSuggestion:Ue,resetActiveSuggestion:Vr}=Wl.actions,Gl=Wl.reducer;var qr={};V(qr,{enUS:()=>bg,nlNL:()=>Cg});var bg={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},Cg={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};var $l=require("@reduxjs/toolkit"),wg={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Xl=({ui:t})=>t.overlayCollapsed;var Ql=(0,$l.createSlice)({name:"ui",initialState:wg,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:jo,setInputHasFocus:so,setOverlayCollapsed:ro,setOpenOverlayWhenTyping:Zl,setOverlayCollapsedUserOverwrite:Jl}=Ql.actions,Yl=Ql.reducer;var Vo=T(require("react")),tc=require("react/jsx-runtime"),ec=Vo.default.createContext(null),qo=({broadcastEvents:t,children:e})=>{let o=Vo.default.useMemo(()=>t,[]);return(0,tc.jsx)(ec.Provider,{value:o,children:e})},Se=()=>{let t=(0,Vo.useContext)(ec);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var io=require("@reduxjs/toolkit");var Tg={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ze=t=>t.auth.isLoggedIn,oc=t=>t.auth.loginFetchState,nc=t=>t.auth.verifyFetchState,sc=t=>t.auth.showLoginOverlay,mt=(0,io.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),rc=(0,io.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Wo=(0,io.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),ic=(0,io.createSlice)({name:"auth",initialState:Tg,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(mt.pending,e=>{e.loginFetchState="loading"}),t.addCase(mt.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(mt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Wo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Wo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Wo.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:ao,setShowLoginOverlay:ac}=ic.actions,lc=ic.reducer;var Wr="SetActiveSuggestion",lo="ShowLoginOverlay",Gr="UserLoggedIn",Eg="UserLoggedOut",je="ApplySuggestion",$r="ApplyImageSuggestion",kg="ShowCommandPalette",Pg=t=>({[Wr]:e=>{t.dispatch(Kl(e.state)),t.dispatch(Ue({contentType:e.contentType,suggestion:e.suggestion}))},[kg]:e=>{t.dispatch(ae(e.isOpen)),e.page&&t.dispatch(X(e.page))},[lo]:e=>{t.dispatch(ac(e))},[Gr]:()=>{t.dispatch(mt())},[Eg]:()=>{t.dispatch(mt())},[$r]:e=>{t.dispatch(es({suggestion:e.suggestion}))},[je]:e=>{t.dispatch(Te({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(ct())}}),cc=Pg;var Xr=require("react/jsx-runtime"),Rg=()=>{var h;let[t,e]=(0,pc.useState)(!1),o=(0,co.useSelector)(Vl),n=(0,co.useSelector)(ql),s=(0,co.useSelector)(no),r=(0,co.useDispatch)(),i=Se(),a=E(qr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Vr()),r(so(!0)),r(Y.actions.reset())},p=(g,v)=>{r(Vr()),r(so(!0)),i.send(je,{text:g,suggestion:{...v,source:`${v.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let u=(h=s[n])==null?void 0:h.suggestions.indexOf(o),d=u===0||u===null?void 0:()=>r(Ue({contentType:n,suggestion:s[n].suggestions[u-1]})),m=u===s[n].suggestions.length-1||u===null?void 0:()=>r(Ue({contentType:n,suggestion:s[n].suggestions[u+1]}));return(0,Xr.jsx)(Wt,{autoFocus:!0,isOpen:u!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Xr.jsx)(ys,{onTouched:e,onDismiss:c,onUse:g=>p(g,o),suggestion:o,onNext:m,onPrevious:d})})},uc=Rg;var Zr=require("react-redux");var vs=T(require("classnames")),ke=require("react"),_s=require("react-redux");var gc=T(require("classnames"));var dc={root:"_root_1ukx5_1"};var mc=require("react/jsx-runtime"),Ig=({className:t,value:e,...o})=>{let n=y("TextInput",dc);return(0,mc.jsx)("input",{className:(0,gc.default)(t,n.root),type:"text",value:e,...o})},Go=Ig;var Qr={};V(Qr,{enUS:()=>Lg,nlNL:()=>Ag});var Lg={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},Ag={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var fc={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};var K=require("react/jsx-runtime");var Mg=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Og=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(Qr),i=y("LoginTokenDialog",fc),a=(0,_s.useSelector)(nc),l=(0,_s.useDispatch)(),c=b("productName"),[p,u]=(0,ke.useState)(t||""),[d,m]=(0,ke.useState)(0),[h,g]=(0,ke.useState)(""),v=(0,ke.useCallback)(async x=>{x.preventDefault(),l(rc({email:p})),m(1)},[o,p]),k=()=>{g(""),m(0)},f=(0,ke.useCallback)(async x=>{x.preventDefault();let w=Mg(x.target.elements.token.value);if(!w){g(r("verifyCodeError",{login:_}));return}l(Wo({token:w}))},[o]),_=(0,ke.useMemo)(()=>x=>(0,K.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:k,children:x},"back-button"),[]);return(0,ke.useEffect)(()=>{a==="error"&&g(r("verifyCodeError",{login:_})),a==="done"&&n()},[a]),(0,K.jsx)(Wt,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,K.jsxs)("div",{className:i.root,children:[(0,K.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),d===0&&(0,K.jsxs)("form",{onSubmit:v,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,K.jsx)(Go,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:x=>u(x.target.value)}),(0,K.jsx)("div",{className:i.actions,children:(0,K.jsx)("button",{type:"submit",className:(0,vs.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),d===1&&(0,K.jsxs)("form",{onSubmit:f,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,K.jsx)(Go,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),h&&(0,K.jsx)("div",{className:i.errorMessage,children:h}),(0,K.jsxs)("div",{className:i.actions,children:[(0,K.jsx)("button",{type:"button",className:(0,vs.default)(i.button),onClick:k,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,vs.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},hc=Og;var Sc=require("react/jsx-runtime"),Ng=()=>{let t=(0,Zr.useSelector)(sc),e=(0,Zr.useSelector)(hl),o=b("adminUrl"),n=Se(),s=()=>n.send(lo,!1),r=()=>{n.send(lo,!1),n.send(Gr)};return(0,Sc.jsx)(hc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},yc=Ng;var Uc=T(require("lodash.debounce")),ne=require("react"),We=require("react-redux");var xs=require("@reduxjs/toolkit");var Dg={data:null,fetchState:"idle"},vc=t=>t.contentTypes.data,$o=(0,xs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Hg=(0,xs.createSlice)({name:"contentTypes",initialState:Dg,reducers:{},extraReducers:t=>{t.addCase($o.pending,e=>{e.fetchState="loading"}).addCase($o.rejected,e=>{e.fetchState="error"}).addCase($o.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),_c=Hg.reducer;function Xo(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}var xc=require("react");function bc(t,e){(0,xc.useEffect)(()=>{let o=n=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?n.metaKey:n.ctrlKey)&&n.key===t&&(n.preventDefault(),n.stopPropagation(),e())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o)}},[])}var Qo=require("react"),ws=require("react-redux");var bs=require("@reduxjs/toolkit");var Cc={data:null,fetchState:"idle"},Cs=t=>{var r;let e=[],{visitorName:o}=t.info.visitorInfo??{},{agentName:n,agentNickname:s}=t.info.agentInfo??{};return n&&n!==o&&e.push(n),s&&s!==o&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},Pe=(0,bs.createAsyncThunk)("entities/getEntities",async(t,e)=>{let{deepdeskAPI:o,dynamicThunkObject:n}=e.extra;if(!n.conversationQuery)return Promise.resolve([]);let s=n.conversationQuery,r=await s();return r.length===0?Promise.resolve([]):o.getEntities(r)}),Bg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Fg=(0,bs.createSlice)({name:"entities",initialState:Cc,reducers:{},extraReducers:t=>{t.addCase(Pe.pending,e=>{e.fetchState="loading"}).addCase(Pe.rejected,e=>{e.fetchState="error"}).addCase(Pe.fulfilled,(e,o)=>{e.fetchState="done",e.data=Bg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(L,()=>Cc)}}),wc=Fg.reducer;var Jr={};V(Jr,{enUS:()=>Kg,nlNL:()=>Ug});var Kg={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Ug={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Tc={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Mt=require("react/jsx-runtime"),zg=({onCopy:t,onUse:e})=>{let o=(0,Qo.useRef)(null),n=y("EntitiesList",Tc),s=E(Jr),r=(0,ws.useSelector)(Cs),i=(0,ws.useDispatch)();return(0,Qo.useEffect)(()=>{i(Pe())},[]),(0,Qo.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,Mt.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,Mt.jsx)(A.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:(0,Mt.jsx)(A.List,{children:r.map((a,l)=>(0,Mt.jsx)(A.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,Mt.jsx)("p",{className:n.empty,children:s("noResults")})]})},Ec=zg;var Re=require("react"),Zo=require("react-redux");var Ts=require("@reduxjs/toolkit");var kc={data:null,fetchState:"idle"},Pc=t=>t.summary.data,Rc=t=>t.summary.fetchState==="error",Ve=(0,Ts.createAsyncThunk)("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();if(i.length===0)return Promise.reject(new Error("No messages are included"));let a=await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return{original:i,summary:a}}),jg=(0,Ts.createSlice)({name:"summary",initialState:kc,reducers:{},extraReducers:t=>{t.addCase(Ve.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Ve.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Ve.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(L,()=>kc)}}),Ic=jg.reducer;var Yr={};V(Yr,{enUS:()=>Vg,nlNL:()=>qg});var Vg={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."}]},qg={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 Lc={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var qe=require("react/jsx-runtime"),Wg=({onCopy:t})=>{let e=(0,Re.useRef)(null),o=y("SummaryForm",Lc),[n,s]=(0,Re.useState)(""),r=E(Yr),i=(0,Zo.useSelector)(Pc),a=(0,Zo.useSelector)(Rc),l=(0,Zo.useDispatch)(),c=()=>{l(ie({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let u=document.getSelection();u&&l(ie({name:"summary copied to clipboard",data:{originalText:i,finalText:u==null?void 0:u.toString()},options:{includeConversationData:!0}}))};return(0,Re.useEffect)(()=>{l(Ve())},[]),(0,Re.useEffect)(()=>{s(i||"")},[i]),(0,Re.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Re.useEffect)(()=>{let u=d=>{d.key==="Enter"&&d.shiftKey&&c()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[n]),(0,qe.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,qe.jsx)("p",{className:o.error,children:r("error")}):(0,qe.jsxs)(Re.Fragment,{children:[(0,qe.jsx)("div",{className:o.main,children:(0,qe.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:u=>s(u.target.value)})}),(0,qe.jsx)("div",{className:o.actions,children:(0,qe.jsx)(A.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Ac=Wg;var ei={};V(ei,{enUS:()=>Gg,nlNL:()=>$g});var Gg={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},$g={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Vat gesprek samen"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var ft=T(require("react")),Yo=require("react-redux");var ti={};V(ti,{enUS:()=>Xg,nlNL:()=>Qg});var Xg={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"}]},Qg={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 Mc={root:"_root_cnaw4_1",title:"_title_cnaw4_9",empty:"_empty_cnaw4_20",status:"_status_cnaw4_24",form:"_form_cnaw4_30",input:"_input_cnaw4_43",submit:"_submit_cnaw4_55",question:"_question_cnaw4_63",answer:"_answer_cnaw4_67",alignRight:"_alignRight_cnaw4_73"};var uo=require("@reduxjs/toolkit");var oi={data:[],fetchState:"idle"},Oc=t=>{var e;return(e=t.answer)==null?void 0:e.data},Nc=t=>t.answer.fetchState,go=(0,uo.createAction)("answer/resetKnowledgeSearch"),po=(0,uo.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(i=e.getState().conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile is not defined");let r=await o.knowledgeSearch({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),Zg=(0,uo.createSlice)({name:"answer",initialState:oi,reducers:{},extraReducers:t=>{t.addCase(po.pending,e=>{e.fetchState="loading"}).addCase(po.rejected,e=>{e.fetchState="error"}).addCase(po.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(L,()=>oi).addCase(go,()=>oi)}}),Dc=Zg.reducer;var Jo=require("react/jsx-runtime"),Hc=()=>(0,Jo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Jo.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Jo.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 oe=require("react/jsx-runtime"),Jg=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=ft.default.useState(""),{setSelected:i}=ut(),a=(0,ft.useRef)(null),l=y("EntitiesList",Mc),c=E(ti),p=(0,Yo.useDispatch)(),u=(0,Yo.useSelector)(Oc),d=(0,Yo.useSelector)(Nc),m=async g=>{g.preventDefault(),g.stopPropagation(),s!==""&&p(po({question:s,promptInstruction:n}))},h=(g,v)=>{p(ie({name:"knowledge assist source viewed",data:{question:v,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return(0,ft.useEffect)(()=>{var g;o&&d==="idle"?p(po({question:o,promptInstruction:n})):(g=a.current)==null||g.focus()},[a,d]),(0,ft.useEffect)(()=>{d==="done"&&(p(ie({name:"knowledge assist question answered",data:{question:s||o,sources:u[u.length-1].answer.sources,isFollowUpQuestion:u.length>1},options:{includeConversationData:!0}})),i(u.length-1),r(""))},[d,u]),(0,ft.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,u]),(0,oe.jsxs)("div",{className:l.root,children:[u.length>0&&(0,oe.jsx)("div",{className:l.alignRight,children:(0,oe.jsx)(A.Button,{onClick:e,children:c("reset")})}),(0,oe.jsxs)(A.ActionsBar,{list:u.map(({answer:g})=>({text:g.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:g=>t(g.text),children:[u.map(({question:g,answer:v},k)=>(0,oe.jsx)(A.List,{children:(0,oe.jsx)(A.ListItem,{"data-testid":"knowledge-search-answer",index:k,description:v.answer,closeOnSelect:!0,onClick:()=>t(v.answer),onSourceClick:f=>h(f,g),sources:v.sources,styles:{title:l.question,description:l.answer},children:g})},`${v.answer}_${k}`)),d==="loading"&&(0,oe.jsx)("p",{className:l.status,children:c("loading")}),d==="error"&&(0,oe.jsx)("p",{className:l.status,children:c("error")}),(0,oe.jsxs)("form",{className:l.form,onSubmit:m,children:[(0,oe.jsx)("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:g=>{i(-1),r(g.target.value)}}),(0,oe.jsx)("button",{type:"submit",className:l.submit,children:(0,oe.jsx)(Hc,{})})]})]})]})},Bc=Jg;var Es=require("@reduxjs/toolkit");var Yg={data:null,fetchState:"idle"},mo=t=>t.profile.data,ks=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],en=(0,Es.createAsyncThunk)("profile/getProfile",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=n.profile.data)==null?void 0:r.code)===s.profileCode?n.profile.data:o.getProfile(s.profileCode)}),em=(0,Es.createSlice)({name:"profile",initialState:Yg,reducers:{},extraReducers:t=>{t.addCase(en.pending,e=>{e.fetchState="loading"}).addCase(en.rejected,e=>{e.fetchState="error"}).addCase(en.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Fc=em.reducer;var j=require("react/jsx-runtime"),tm=200,om=5,nm=4,sm=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Kc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),rm=()=>{let t=(0,We.useDispatch)(),e=Se(),o=E(ei),[n,s]=(0,ne.useState)(!1),[r,i]=(0,ne.useState)(""),a=(0,We.useSelector)(xl),l=(0,We.useSelector)(mo),[c,p]=(0,ne.useState)(null),[u,d]=(0,ne.useState)([]),[m,h]=(0,ne.useState)(),g=(0,We.useSelector)(ze),v=b("showSearch"),k=b("showEntitiesCommand"),f=b("showSummaryCommand"),_=b("showKnowledgeSearch"),x=b("showImageSearch"),w=b("searchTriggerKey"),C=(0,We.useSelector)(vc),D=(0,We.useSelector)(bl),ue=(0,We.useSelector)(_l),B=S=>ir(D.filter(M=>M.type===S.toUpperCase()),S),I=[{value:"PERSONAL",label:o("personalSuggestions"),list:B("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:B("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:B("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:B("IMAGE"),listOrientation:"horizontal",shouldShow:x}].filter(S=>S.shouldShow),U=[{label:o("entitiesClipboard"),onClick:()=>t(X("entities")),shouldShow:k&&Kc(o("entitiesClipboard"),r),experimental:!0},{label:o("summaryClipboard"),onClick:()=>t(X("summary")),shouldShow:f&&Kc(o("summaryClipboard"),r),experimental:!0},{label:r?`${o("knowledgeSearch")}: ${r}`:o("knowledgeSearch"),onClick:()=>t(X("knowledgeSearch")),shouldShow:_,experimental:!0}].filter(S=>S.shouldShow),J=(C==null?void 0:C.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:B(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],sr=(0,ne.useCallback)((0,Uc.default)((S,M)=>{t(It({query:S,type:M,tags:["search-overlay"]}))},tm),[]),bt=sm([...J,...I]),Yu=(0,ne.useCallback)((S,M)=>{if(!M)return;let nt=[...I,...J].find(({value:Ft})=>Ft===M);nt&&(t(X("edit")),p({...S,searchTerm:void 0}),d(nt.list))},[t,c,J]),rr=(0,ne.useCallback)((S,M)=>{switch(M.type){case"IMAGE":e.send($r,{suggestion:M});break;default:e.send(je,{text:S,suggestion:M})}t(ae(!1))},[t]),ed=S=>{Xo(S.text),t(ie({name:"entity copied",data:{entity:S,type:"copy"}})),t(ae(!1))},td=S=>{e.send(je,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(ie({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(X("search")),t(go()),t(ae(!1))},od=S=>{Xo(S),t(ae(!1))},nd=S=>{e.send(je,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(ae(!1))},sd=c===null||u.indexOf(c)-1<0?void 0:()=>p(u[u.indexOf(c)-1]),rd=c===null||u.indexOf(c)===u.length-1?void 0:()=>p(u[u.indexOf(c)+1]);function ir(S,M){return S.slice(0,m?10:M.toLowerCase()==="image"?nm:om)}function Fi(S,M,nt){return M.reduce((Ft,fn)=>nt&&m===nt?fn.length+Ft:ir(fn,nt).length+Ft,S)}function Bt(S){return M=>{n?window.confirm(o("warning"))&&(S(M),s(!1)):S(M)}}return(0,ne.useEffect)(()=>{r?sr(r,m):t(gs())},[r,m]),(0,ne.useEffect)(()=>{a==="search"&&t(go())},[a]),(0,ne.useEffect)(()=>{g&&t($o())},[g]),bc(w,()=>t(ae(!0))),!v||!l?null:(0,j.jsxs)(A,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Bt(S=>t(ae(S))),onChangeType:S=>h(S),onChangePage:Bt(S=>t(X(S))),selectedType:m,search:r,page:a,isOpen:ue,types:[...J,...I],children:[(0,j.jsx)(A.Page,{id:"search",children:(0,j.jsxs)(A.ActionsBar,{list:[...U.map(S=>({text:S.label,type:"command"})),...bt.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},M)=>rr(S,bt[M]),onSecondary:(S,M)=>{Yu(bt[M-U.length],bt[M-U.length].type)},children:[U.length>0&&(0,j.jsx)(A.List,{heading:o("commands"),children:U.map((S,M)=>(0,j.jsx)(A.ListItem,{index:Fi(M,[],"commands"),closeOnSelect:!1,onClick:S.onClick,isExperimental:S.experimental,children:S.label},S.label))}),[...J,...I].map(({value:S,label:M,list:nt,lineClamp:Ft,listOrientation:fn},id)=>(0,j.jsx)(A.List,{heading:M,orientation:fn==="horizontal"?"horizontal":"vertical",children:ir(nt,S).map((xe,ad)=>(0,j.jsx)(A.ListItem,{index:Fi(U.length+ad,[...J,...I].slice(0,id).map(({list:ld})=>ld),S),closeOnSelect:!1,lineClamp:Ft,onClick:()=>rr(xe.text,xe),description:S!=="IMAGE"?xe.title&&xe.text:void 0,children:S==="IMAGE"?(0,j.jsx)(A.Image,{title:xe.title||xe.text,src:xe.image}):xe.title||xe.text},`${xe.id}-${xe.text}`))},S))]})}),(0,j.jsx)(A.Page,{id:"edit",onDismiss:Bt(()=>{t(X("search")),p(null)}),children:c&&(0,j.jsx)(ys,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(X("search")),p(null),d([])},onNext:rd,onPrevious:sd,onUse:S=>{t(X("search")),rr(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(ae(!1)),d([]),p(null)}})}),(0,j.jsx)(A.Page,{id:"entities",title:o("entitiesTitle"),isExperimental:!0,onDismiss:Bt(()=>{t(X("search"))}),children:(0,j.jsx)(Ec,{onUse:nd,onCopy:ed})}),(0,j.jsx)(A.Page,{id:"summary",title:o("summaryTitle"),isExperimental:!0,onDismiss:Bt(()=>{t(X("search"))}),children:(0,j.jsx)(Ac,{onCopy:od})}),(0,j.jsx)(A.Page,{id:"knowledgeSearch",title:o("knowledgeSearch"),isExperimental:!0,onDismiss:Bt(()=>{t(go()),t(X("search"))}),children:(0,j.jsx)(Bc,{promptInstruction:l.knowledgeSearchPromptInstruction,question:r,onUse:td,onResetQuestion:()=>{t(go()),i("")}})})]})},zc=rm;var fo=require("react/jsx-runtime"),im=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,fo.jsxs)(jc.Fragment,{children:[t&&(0,fo.jsx)(zc,{}),(0,fo.jsx)(uc,{}),e&&(0,fo.jsx)(yc,{})]})},Vc=im;var qc=require("react-redux");var tn=require("react/jsx-runtime"),am=({children:t})=>{let o=b("locale").replace("-","");return(0,tn.jsx)(fr.Provider,{value:o,children:t})},lm=({store:t,customStyles:e={},children:o})=>(0,tn.jsx)(qc.Provider,{store:t,children:(0,tn.jsx)(am,{children:(0,tn.jsx)(wo.Provider,{value:e,children:o})})}),on=lm;var Ls=T(require("classnames")),So=require("react"),$e=require("react-redux");var Wc=require("react");function Gc(t,e){let[o,n]=(0,Wc.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return P.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){P.error(i)}}]}function Ps(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:o,showSuggestionsAfterPattern:n}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?o&&new RegExp(o).test(s.substring(r.end))||n&&new RegExp(n).test(s.substring(0,r.end))?!0:o===!1&&n===!1:!1}var Xc=T(require("classnames")),Ge=require("react");var ni={};V(ni,{enUS:()=>cm,nlNL:()=>pm});var cm={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"}]}]},pm={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:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var ht=require("react/jsx-runtime"),si=(t,e,o)=>n=>(0,ht.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),um=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=E(ni),r=Se(),i=y("Login",$c),a=b("productName"),l=(0,Ge.useCallback)(g=>{g.preventDefault(),n&&n(parseInt(g.target.value,10))},[]),c=(0,Ge.useCallback)(g=>{g.preventDefault(),r.send(lo,!0)},[e]),p=(0,Ge.useMemo)(()=>g=>(0,ht.jsx)("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),u=(0,Ge.useCallback)(g=>(0,ht.jsx)("button",{type:"button",className:i.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:d,hour:m,day:h}=(0,Ge.useMemo)(()=>({min:si(i,60*10,l),hour:si(i,60*60,l),day:si(i,60*60*12,l)}),[]);return(0,ht.jsxs)("div",{className:(0,Xc.default)(t,i.root),children:[s("loginPlease",{login:o?u:p,productName:a}),n&&(0,ht.jsxs)(Ge.Fragment,{children:[(0,ht.jsx)("br",{}),s("snooze",{min:d,hour:m,day:h})]})]})},Rs=um;var Zc=require("react-redux");var Qc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var nn=require("react/jsx-runtime"),dm=({title:t})=>{let e=y("SearchTrigger",Qc),o=(0,Zc.useDispatch)();return(0,nn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ae(!0)),children:[(0,nn.jsx)(to,{}),(0,nn.jsx)("span",{className:e.text,children:t})]})},Jc=dm;var ip=require("react");var sp=require("interweave"),yo=require("react"),Is=require("react-redux");var Yc=require("react");function ep(t,e,o){(0,Yc.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var gm=/[.*+?^${}()|[\]\\]/g,mm=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function fm(t){return t.replace(gm,"\\$&")}function hm(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function ri(t){return t.search(mm)}function tp(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${fm(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function op(t){return t.replace(jt,'<mark data-type="placeholder">$1</mark>')}function ho(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function ym(t,e){return t.split("").map((i,a)=>({char:i,index:a})).filter(({char:i,index:a})=>/\s/.test(i)&&a<=e).map(({index:i})=>i).reverse()[0]}function ii(t,e,o={}){if(e){let n=hm(e.toLowerCase(),t.toLowerCase()),s=ho(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=ri(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(ya).length>3||e.length>30?ym(e.trim(),n):0;return`${`${i>0?"\u2026":""}${ho(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var np={badge:"_badge_8rv7b_1",formattedText:"_formattedText_8rv7b_5"};var ai=require("react/jsx-runtime"),vm=["search","personal-collection-search","search-autocomplete"];function _m(t,e,o,n={}){let s="";return vm.includes(e)?s=tp(ii(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ii(t,o,n),n.placeholders===!0&&(s=op(s)),s}var xm=()=>{},bm=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=(0,Is.useSelector)(Vt),r=(0,Is.useDispatch)(),i=y("TextSuggestion",np),a=(0,yo.useRef)(null);(0,yo.useEffect)(()=>{let c=setTimeout(()=>{r(Na({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),ep(a,"click",()=>{r(ts(t)),r(Te({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,yo.useMemo)(()=>_m(o.text,o.source,s,{stripAgentPart:n,placeholders:!0,searchKeywords:o.searchKeywords}),[n,o.text,o.source,s,o.searchKeywords]);return o.source==="gpt"?null:(0,ai.jsx)(N,{ref:a,as:"button",selected:e,onClick:xm,children:(0,ai.jsx)(sp.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},rp=bm;var li=require("react/jsx-runtime"),Cm=({suggestions:t,selectedIndex:e})=>(0,li.jsx)(ip.Fragment,{children:t.slice().map((o,n)=>(0,li.jsx)(rp,{index:n,selected:n===e,suggestion:o},`${o.text}-${o.source}`)).reverse()}),ap=Cm;var ci={};V(ci,{enUS:()=>wm,nlNL:()=>Tm});var wm={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"}]},Tm={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 lp={root:"_root_4kcme_1",isInline:"_isInline_4kcme_14",toggleButton:"_toggleButton_4kcme_18",toggleButtonWrapper:"_toggleButtonWrapper_4kcme_22",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_4kcme_29",isCollapsed:"_isCollapsed_4kcme_33",collapsible:"_collapsible_4kcme_33",hints:"_hints_4kcme_41",hintsHidden:"_hintsHidden_4kcme_48",triggers:"_triggers_4kcme_53",triggersRight:"_triggersRight_4kcme_68"};var H=require("react/jsx-runtime"),Em=({inline:t=!1,textSuggestions:e,selectedIndex:o})=>{let n=y("SuggestionsOverlay",lp),s=E(ci),r=b("inlineSuggestions"),i=(0,$e.useSelector)(Ps),a=Ia(),l=(0,$e.useDispatch)(),c=(0,So.useRef)(null),p=b("searchTriggerKey"),u=b("productName"),d=(0,$e.useSelector)(Xl),m=(0,$e.useSelector)(ze),h=(0,$e.useSelector)(jn),[g,v]=(0,So.useState)(null),k=b("showSearch"),f=b("showTextSuggestions"),_=b("adminUrl"),x=b("isEmbedded"),[w,C]=Gc("dd-snooze-until-ms",0),D=d||w>Date.now(),ue=e.filter(U=>U.source!=="gpt").length,B=()=>{D&&C(0),l(Jl(!D))},I=U=>{let J=Date.now()+U*1e3;C(J),P.info(`Snooze until: ${new Date(J)}`),l(ro({collapse:!0}))};return(0,So.useEffect)(()=>{ue===0&&v(null)},[e,ue]),Qt(()=>{l(ro({collapse:!0,skipWhenInputFocus:!0}))}),r!==t||m===null||h===!1?null:m===!1?(0,H.jsxs)("div",{ref:c,className:(0,Ls.default)(n.root,{[n.isCollapsed]:D,[n.isInline]:t}),"data-inline":t,children:[!D&&(0,H.jsxs)("div",{className:n.triggers,children:[(0,H.jsx)("div",{style:{flex:1}}),(0,H.jsx)("div",{className:n.triggersRight,children:(0,H.jsx)(Et,{className:n.toggleButton,title:s("collapse"),onClick:B,isCollapsed:!1})})]}),(0,H.jsx)("div",{className:n.toggleButtonWrapper,children:(0,H.jsx)(Et,{className:n.toggleButton,title:s("open",{productName:u}),onClick:B,isCollapsed:!0})}),(0,H.jsx)("div",{className:n.collapsible,children:(0,H.jsx)(Rs,{loginUrl:_,isEmbedded:x,onSnooze:I})})]}):!a||!i?null:(0,H.jsxs)("div",{ref:c,className:(0,Ls.default)(n.root,{[n.isCollapsed]:D,[n.isInline]:t}),"data-inline":t,children:[!D&&(0,H.jsxs)("div",{className:n.triggers,children:[(0,H.jsx)("div",{style:{flex:1},children:k&&(0,H.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>v(s(ps()?"searchHintMac":"searchHintWindows",{searchTriggerKey:p.toUpperCase()})),onMouseLeave:()=>v(null),children:(0,H.jsx)(Jc,{title:s("search")})})}),(0,H.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,H.jsx)("div",{className:(0,Ls.default)(!g&&n.hintsHidden,n.hints),children:g}),(0,H.jsx)(Et,{className:n.toggleButton,title:s("collapse"),onClick:B,isCollapsed:!1})]})]}),(0,H.jsx)("div",{className:n.toggleButtonWrapper,children:(0,H.jsx)(Et,{className:n.toggleButton,title:s("open",{productName:u}),onClick:B,isCollapsed:!0})}),ue>0&&f&&(0,H.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,H.jsx)(Le,{children:(0,H.jsx)(ap,{suggestions:e,selectedIndex:o})})})]})},km=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),As=(0,$e.connect)(km)(Em);var qs=T(require("classnames")),Pp=require("interweave"),Je=require("react"),Rp=require("react-redux");var cp=require("react"),Pm=["div","span","mark","strong","b","i","u","em"];function pi(t,e,o=0){var r;let n=t[t.length-1],s=typeof n=="object"&&n!==null?(r=n.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,n];if(Pm.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,cp.cloneElement)(n,{children:pi(i,e,o+1)})]}return[...t,...e]}function Xe(t){return t.tagName.toLowerCase()==="textarea"}var pp={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};var hp=require("interweave"),Ds=require("react");var di=T(require("classnames")),ve=require("react");var Ms=require("react"),Rm=["bottom","height","left","right","top","width"],Im=(t={},e={})=>Rm.some(o=>t[o]!==e[o]),Qe=new Map,up,dp=()=>{let t=[],e=[];Qe.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Im(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Qe.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),up=window.requestAnimationFrame(dp)};function Lm(t,e){return{observe(){let o=Qe.size===0;if(Qe.has(t)){let n=Qe.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Qe.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&dp()},unobserve(){let o=Qe.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Qe.delete(t),Qe.size||cancelAnimationFrame(up)}}}}function ui(t){let[e,o]=(0,Ms.useState)(null);return(0,Ms.useLayoutEffect)(()=>{if(!t.current)return;let n=Lm(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var vo=require("react"),mp=require("react-dom");var gp={root:"_root_1jq08_1"};var fp=({children:t})=>{let[e,o]=(0,vo.useState)(null),n=(0,vo.useContext)(wo);return(0,vo.useLayoutEffect)(()=>{let s=document.createElement("div");return Pt(s),s.classList.add(gp.root),n!=null&&n.portalRootNode&&s.classList.add(n==null?void 0:n.portalRootNode),document.body.appendChild(s),o(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?(0,mp.createPortal)(t,e):null};var Ne={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};var Os=require("react/jsx-runtime"),_o=(t=!1)=>{let[e,o]=(0,ve.useState)(t),n=(0,ve.useCallback)(()=>o(!0),[]),s=(0,ve.useCallback)(()=>o(!1),[]),r=(0,ve.useCallback)(()=>o(a=>!a),[]),i=(0,ve.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function gi(t,e=null,o=0){if(!t)return{display:"none"};let n=e?t.top-e.top<0||t.top<e.top-o?e.top-o:t.top+t.height>e.top+e.height+o?e.top+e.height+o-t.height:t.top:t.top,s=e?t.left<e.left-o?e.left-o:t.left+t.width>e.left+e.width+o?e.left+e.width+o-t.width:t.left:t.left;return{top:n,left:s,height:t.height,width:t.width}}var xo=({className:t,triggerRef:e,boundaryRef:o=(0,ve.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=gi,...a})=>{let l=ui(e),c=ui(o),p=(0,ve.useMemo)(()=>i(l,c,0),[l,c]);return(0,Os.jsx)(fp,{children:(0,Os.jsx)("div",{className:(0,di.default)(Ne.ref,{[Ne.positionAbove]:n==="above",[Ne.positionBelow]:n==="below",[Ne.positionLeft]:n==="left",[Ne.positionRight]:n==="right",[Ne.alignStart]:s==="start",[Ne.alignCenter]:s==="center",[Ne.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,Os.jsx)("div",{className:(0,di.default)(t,Ne.root),children:r})})})};var yt=require("react/jsx-runtime"),Am=({inputStyle:t,inputElement:e})=>{let o=y("TabCompletion",fe),n=_o(document.activeElement===e);return Qt(()=>n.close()),(0,Ds.useEffect)(()=>{let s=()=>n.open();return e.addEventListener("focus",s),()=>{e.removeEventListener("focus",s)}},[]),(0,yt.jsxs)(Ds.Fragment,{children:[(0,yt.jsx)("mark",{className:fe.caret,ref:n.triggerRef}),n.opened&&(0,yt.jsx)(xo,{className:o.popoverSuggestionsRoot,triggerRef:n.triggerRef,position:"above",align:"start",children:(0,yt.jsx)("div",{style:t,className:o.suggestionsOverlayInputStyles,children:(0,yt.jsx)(As,{inline:!0})})})]})},Ns=class extends hp.Matcher{charCounter=0;charLength=0;found=!1;onlyAtEnd=!1;props;onBeforeParse(e,o){var n;return this.props=o,this.charCounter=0,this.onlyAtEnd=o.inlineSuggestionsOnlyAtEnd??!1,this.charLength=(Xe(o.inputElement)?o.inputElement.value.length:(n=o.inputElement.textContent)==null?void 0:n.length)??0,this.found=!1,e}match(e){if(this.found||!this.props||this.props.selection===null)return null;let[o,n]=this.props.selection;if(o!==n||this.onlyAtEnd&&o!==this.charLength)return null;let s=o,i=s>=this.charCounter&&s<=this.charCounter+e.length?{index:ri(e.slice(0,s))+1-this.charCounter,length:0,match:"",valid:!0}:null;return i&&(this.found=!0),this.charCounter+=e.length,i??null}replaceWith(e,o){return(0,yt.jsx)(Am,{inputStyle:o.inputStyle,inputElement:o.inputElement},"caret")}asTag(){return"mark"}};var _p=T(require("classnames")),xp=require("interweave"),Us=require("react");function yp(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Hs(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Sp(t){return t!=null}var vp=T(require("classnames")),Bs=require("react");var mi=require("react/jsx-runtime"),Fs=(0,Bs.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,Bs.useRef)(null),r=y("TabCompletion",fe);return(0,mi.jsx)("div",{ref:Hs([s,n]),className:(0,vp.default)(t,r.popoverContentContainer),...o,children:(0,mi.jsx)("div",{className:r.popoverContent,children:e})})});var St=require("react/jsx-runtime"),Mm=t=>e=>{let o=gi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Om=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",fe),i=_o(),a=(0,Us.useMemo)(()=>Mm(t.getBoundingClientRect()),[t]),[l,c]=ns(t);return(0,Us.useEffect)(()=>{c?i.open():i.close()},[c]),(0,St.jsxs)("span",{children:[(0,St.jsx)("mark",{ref:Hs([l,i.triggerRef]),className:(0,_p.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,St.jsx)(xo,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,St.jsx)(Fs,{style:o,children:(0,St.jsx)("div",{className:r.hintText,children:s})})})]})},Ks=class extends xp.Matcher{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(n=>({...n,keywordRegex:new RegExp(`\\b${yp(n.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(Sp);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return(0,St.jsx)(Om,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var js=T(require("classnames")),Ep=require("interweave"),Z=require("react"),kp=require("react-redux");var fi=require("react/jsx-runtime"),bp=()=>(0,fi.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,fi.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 vt=require("react"),sn=require("react-redux"),wp=T(require("lodash.debounce"));var Cp={root:"_root_1muu8_1",content:"_content_1muu8_7"};function zs(t,e,o){var s;let n=((s=t.imageSizes)==null?void 0:s[e])||t.image||o;if(!n)return null;try{return new URL(n).toString()}catch{return null}}function hi(t){return t.replace("https://www.","").replace("https://","")}var _e=require("react/jsx-runtime"),Nm=3,Dm=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Hm=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Nm})=>{let r=y("LinkSearch",Cp),[i,a]=(0,vt.useState)(""),l=(0,sn.useDispatch)(),c=(0,sn.useSelector)(Ol("url")),p=(0,sn.useSelector)(Cl("URL",Dm)),[u,d]=(0,vt.useState)(p.length-1),m=b("fallbackImage"),h=f=>{let _=f.target;a(_.value)},g=(f,_)=>{f.stopPropagation(),f.preventDefault(),window.open(_,"_blank")},v=f=>{var w;let _=u-1<0?p.length-1:u-1,x=u+1===p.length?0:u+1;f.code==="Escape"&&(a(""),e()),f.code==="ArrowUp"&&d(_),f.code==="ArrowDown"&&d(x),f.code==="Enter"&&t(((w=p[u])==null?void 0:w.text)||i)},k=(0,vt.useCallback)((0,wp.default)(f=>{l(It({query:f,type:"URL",tags:["link-search"]}))},300),[]);return(0,vt.useEffect)(()=>{i&&k(i)},[i]),(0,vt.useEffect)(()=>()=>{l(gs())},[]),(0,_e.jsxs)("div",{className:r.root,children:[(0,_e.jsx)(Le,{withDivider:!0,children:(i?p:c).slice(0,s).map((f,_)=>(0,_e.jsx)(N,{selected:u===_,onClick:()=>t(f.text),"data-testid":"linksearch-suggestion",children:(0,_e.jsxs)(F,{children:[(0,_e.jsx)(F.Image,{src:zs(f,"small",m||void 0),title:f.title||f.text}),(0,_e.jsxs)(F.Content,{className:r.content,cropText:!0,children:[(0,_e.jsx)(F.Title,{children:f.title||hi(f.text)}),f.title&&hi(f.text)]}),(0,_e.jsx)(N.Actions,{children:(0,_e.jsx)(N.ActionButton,{label:n,onClick:x=>g(x,f.text)})})]})},f.text))}),(0,_e.jsx)(Go,{value:i,onChange:h,autoFocus:!0,placeholder:o,onKeyUp:v})]})},Tp=Hm;var yi={};V(yi,{enUS:()=>Bm,nlNL:()=>Fm});var Bm={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Fm={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Q=require("react/jsx-runtime"),Km=(0,Z.forwardRef)((t,e)=>{let o=y("TabCompletion",fe);return(0,Q.jsx)("mark",{ref:e,className:(0,js.default)(o.matchSelection)},"selection-start")}),Um=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(yi),i=y("TabCompletion",fe),a=(0,Z.useRef)(null),l=(0,Z.useRef)(null),[c,p]=(0,Z.useState)(null),u=(0,kp.useDispatch)(),d=_o(document.activeElement===n),[m]=(0,Z.useState)(()=>document.createRange());d.triggerRef.current=m,(0,Z.useEffect)(()=>()=>m.detach(),[]),(0,Z.useEffect)(()=>{let g=t.current,v=a.current;!g||!v||(m.setStart(g,0),m.setEnd(v,0))},[t.current,a.current]),Qt(()=>{d.close()});let h=(0,Z.useCallback)(g=>{let v=m.toString(),k=/^http(s?):\/\//.test(g)?g:`https://${g}`;u(Qn({text:`[${v}](${k})`,replace:"selection"}))},[]);return(0,Q.jsxs)("span",{children:[(0,Q.jsx)("mark",{ref:a,className:(0,js.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:s}),d.opened&&(0,Q.jsx)(xo,{className:i.popoverRoot,triggerRef:d.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,Q.jsxs)(Fs,{style:o,ref:l,children:[(0,Q.jsx)("div",{className:(0,js.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,Q.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,Q.jsx)(bp,{}),(0,Q.jsx)("span",{children:"\xA0"}),(0,Q.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,Q.jsx)(Tp,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{p(null),d.close()}})]})})]},"selection-end")},Vs=class extends Ep.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,Z.createRef)(),this.foundIndex=0,e}match(e){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,n]=this.props.selection;if(o===n)return null;let s=this.foundIndex===0?o:n,r=s>=this.charCount&&s<=this.charCount+e.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;r&&this.foundIndex++;let i=this.foundIndex===1;return r&&i?this.charCount+=s-this.charCount:this.charCount+=e.length,r?{isStart:i,...r}:null}replaceWith(e,o){return o.isStart?(0,Q.jsx)(Km,{ref:this.startRef}):(0,Q.jsx)(Um,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Ze=require("react/jsx-runtime"),zm=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",pp),p=b("insertLink"),u=b("showMidSentenceSuggestions"),d=b("inlineSuggestions"),m=rs(a),h=(0,Je.useRef)(null);(0,Je.useEffect)(()=>{Xe(a)&&m&&is(a,m)},[m]);let g=(0,Je.useCallback)(f=>{if(!s||!o)return f;let _=[(0,Ze.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,Ze.jsx)("span",{className:(0,qs.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&_.push((0,Ze.jsx)("span",{className:(0,qs.default)(c.hint,c.resetIndent),children:(0,Ze.jsx)(Hn,{keyCode:"tab"},"tabHint")})),pi(f,_)},[s,o,n]),v=(0,Je.useMemo)(()=>{let f=[];return d&&f.push(new Ns("inline")),p&&f.push(new Vs("selection")),f.push(new $t("placeholders")),r&&f.push(new Ks("keywords")),f},[d,p,r]),k=(0,Je.useMemo)(()=>{let f=window.getComputedStyle(a);return{"--dd-color":f.color,"--dd-font-size":f.fontSize,"--dd-font-family":f.fontFamily,"--dd-font-variant":f.fontVariant}},[]);return t?(0,Ze.jsxs)("div",{ref:f=>{f!=null&&f.parentElement&&(h.current=f==null?void 0:f.parentElement)},className:c.root,style:k,children:[(0,Ze.jsx)(Pp.Interweave,{tagName:"span",containerTagName:"div",className:(0,qs.default)(c.container,c.agentText),disableLineBreaks:Xe(a),content:e||"\u200B",onAfterParse:g,matchers:v,selection:m,keywordMatches:i,inputElement:a,inputStyle:k,boundaryRef:h,inlineSuggestionsOnlyAtEnd:!u}),(0,Ze.jsx)("br",{})]}):null},jm=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var g;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??ho(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:u}=s,{showTabCompletion:d,visible:m,showStyleSuggestions:h}=o;return{showTabHint:p,showStyleSuggestions:h,showTabCompletion:d,content:l,tabText:c,source:a,keywordMatches:((g=n.list)==null?void 0:g.keywordMatches)??[],enabled:m&&u!==!1}},Ip=(0,Rp.connect)(jm)(zm);var xu=T(require("classnames")),bu=require("react"),W=require("react-redux");var _t=require("@reduxjs/toolkit");var Lp={list:[],fetchState:"idle",isInitialRequest:null},Mp=t=>t.autoflows.list||[],Ap=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ye=(0,_t.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Si=(0,_t.createAsyncThunk)("autoflows/start",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.startAutoflowSession(t),await o(Ye(t.platformSessionId))}),vi=(0,_t.createAsyncThunk)("autoflows/stop",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.stopAutoflowSession(t.platformSessionId),await o(Ye(t.platformSessionId))}),Vm=(0,_t.createSlice)({name:"autoflows",initialState:Lp,reducers:{},extraReducers:t=>{t.addCase(Si.pending,(e,o)=>{let n=Ap(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(vi.pending,(e,o)=>{let n=Ap(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Ye.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ye.rejected,e=>{e.fetchState="error"}),t.addCase(Ye.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(L,()=>Lp)}}),Op=(0,_t.createAsyncThunk)("autoflows/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");let s=n.openStream(t);s.on("sessionAborted",()=>{o(Ye(t))}),s.on("sessionCompleted",()=>{o(Ye(t))})}),Np=(0,_t.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Dp=Vm.reducer;var xt=require("@reduxjs/toolkit");var Hp={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Bp=t=>t.customMessages.list,Fp=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Kp=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Up=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),rn=(0,xt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Ws=(0,xt.createAsyncThunk)("customMessages/send",async(t,e)=>{let{platformSessionId:o,suggestion:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.sendCustomMessage(o,n)}),Gs=(0,xt.createAsyncThunk)("customMessages/answer",async(t,e)=>{let{platformSessionId:o,reply:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.answerCustomMessage(o,n)}),zp=(0,xt.createSlice)({name:"customMessages",initialState:Hp,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(rn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(rn.rejected,e=>{e.fetchState="error"}).addCase(rn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Ws.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Ws.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Gs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Gs.rejected,(e,o)=>{let n=e.answeredSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1)),e.answeredSuggestions.splice(n,1)}).addCase(L,()=>Hp)}}),jp=(0,xt.createAsyncThunk)("customMessages/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.openStream(t).on("customMessageSuggestion",r=>{o(zp.actions.onCustomMessage(r))})}),Vp=(0,xt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),qp=zp.reducer;var an=require("@reduxjs/toolkit"),qm={jwt:null,accountUrl:null,interval:null},Wp=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},_i=(0,an.createAsyncThunk)("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),xi=(0,an.createAsyncThunk)("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(_i()),setInterval(()=>n(_i()),o)}),Gp=(0,an.createSlice)({name:"exchangeToken",initialState:qm,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(_i.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(xi.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:$p}=Gp.actions,Xp=Gp.reducer;function Qp(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var ru=require("react"),iu=require("react-redux");var ou=T(require("classnames")),nu=require("react");var Jp=T(require("classnames"));var Zp={root:"_root_838fd_1"};var eu=require("react/jsx-runtime"),Wm=({className:t,children:e})=>{let o=y("Unicode",Zp);return(0,eu.jsx)("span",{className:(0,Jp.default)(t,o.root),children:e})},Yp=Wm;var tu={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var bi={};V(bi,{enUS:()=>Gm,nlNL:()=>$m});var Gm={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"}]},$m={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 le=require("react/jsx-runtime"),Qm=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",tu),a=E(bi),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,le.jsxs)(N,{className:(0,ou.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,le.jsx)(F,{children:(0,le.jsxs)(F.Content,{children:[(0,le.jsxs)(F.Title,{children:[e&&(0,le.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,le.jsx)("span",{children:n})]})}),(0,le.jsx)(N.Actions,{fixed:e==="Started",children:(0,le.jsx)(N.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,le.jsxs)(nu.Fragment,{children:[(0,le.jsx)(Yp,{children:c})," ",(0,le.jsx)("span",{children:a(l)})]})})})]})},su=Qm;var Ci=require("react/jsx-runtime"),Zm=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Jm=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Ci.jsx)(ru.Fragment,{children:t.map(s=>(0,Ci.jsx)(su,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Zm(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Ym=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},ef={onStartAutoflow:Si,onStopAutoflow:vi},au=(0,iu.connect)(Ym,ef)(Jm);var $s=require("react"),cu=require("react-redux"),Ei=T(require("classnames"));var wi=require("react/jsx-runtime"),Ti=()=>(0,wi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,wi.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 lu={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var De=require("react/jsx-runtime"),tf=({entities:t})=>{let e=y("EntitiesWidgetList",lu),[o,n]=(0,$s.useState)(void 0),s=(0,cu.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Xo(a.text),s(ie({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,$s.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,De.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,De.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,De.jsx)("span",{className:e.entityText,children:a.text}),(0,De.jsxs)("span",{className:e.iconWrapper,children:[(0,De.jsx)("span",{className:(0,Ei.default)(e.icon),children:(0,De.jsx)(Ti,{})}),(0,De.jsx)("span",{className:(0,Ei.default)(e.icon,o===l&&e.iconClicked),children:(0,De.jsx)(Ti,{})})]})]},a.text))})},pu=tf;var uu=T(require("classnames")),ki=require("react"),Ot=require("react-redux");var ln={};V(ln,{enUS:()=>of,nlNL:()=>nf});var of={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],answer:[{type:0,value:"Answer"}]},nf={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],answer:[{type:0,value:"Antwoord"}]};var et={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};var se=require("react/jsx-runtime"),sf=({suggestion:t})=>{let e=E(ln),o=(0,Ot.useDispatch)(),n=(0,Ot.useSelector)(Fp(t.text)),s=(0,Ot.useSelector)(Kp(t.text)),r=(0,Ot.useSelector)(Up(t.text)),i=(0,Ot.useSelector)(Un),{replyOptions:a}=t,l=(0,ki.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Ws({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,ki.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let u=parseInt(p.target.dataset.index,10),d=a[u];o(Gs({platformSessionId:i,reply:d,suggestion:t}))},[t,n,o,i]);return(0,se.jsxs)(N,{onClick:l,className:(0,uu.default)(et.root,{[et.isUsed]:n,[et.hasError]:r}),children:[(0,se.jsx)(F,{children:(0,se.jsxs)(F.Content,{children:[(0,se.jsxs)(F.Title,{className:et.title,children:[t.text," ",(0,se.jsx)(Bn,{className:et.label,children:"analyse tool"})," ",r&&(0,se.jsx)("span",{className:et.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,se.jsx)("ul",{className:et.quickReplies,children:a.map(p=>(0,se.jsx)("li",{className:et.quickReply,children:p.title},p.title))})]})}),(0,se.jsxs)(N.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,se.jsx)(N.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,u)=>(0,se.jsx)(N.DropdownItem,{index:u,label:p.title,onClick:c},p.title))}),(0,se.jsx)(N.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},du=sf;var Pi=require("react/jsx-runtime"),gu=()=>(0,Pi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Pi.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 hu=require("react-redux");var mu=require("react");var ce=require("react/jsx-runtime"),rf=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var d;let s=t.text||t.url||t.message,r=ms(s),i=E(ln),a=b("showImages"),l=b("fallbackImage"),c=m=>{m.preventDefault(),m.stopPropagation(),n(s)},p=m=>{m.preventDefault(),m.stopPropagation(),o(t)},u=(0,mu.useCallback)(m=>{window.open(r,"_blank"),m.stopPropagation(),m.preventDefault()},[r]);return(0,ce.jsxs)(N,{onClick:c,"data-testid":"edit-suggestion",children:[(0,ce.jsxs)(F,{children:[a&&t.image&&(0,ce.jsx)(F.Image,{src:zs(t,"small",l||void 0),title:t.title}),(0,ce.jsxs)(F.Content,{children:[t.title&&(0,ce.jsx)(F.Title,{children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&(0,ce.jsx)(N.Labels,{labels:t.searchKeywords}),(0,ce.jsx)(F.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,ce.jsxs)(N.Actions,{children:[r&&(0,ce.jsx)(N.ActionButton,{onClick:u,label:i("visitUrl")}),(0,ce.jsx)(N.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,ce.jsx)(N.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},fu=rf;var cn=require("react/jsx-runtime"),af=({contentType:t,lines:e,suggestions:o})=>{let n=Se(),s=(0,hu.useSelector)(no),r=a=>{n.send(Wr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(je,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,cn.jsx)(cn.Fragment,{children:o.map(a=>(0,cn.jsx)(fu,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},yu=af;var Ri={};V(Ri,{enUS:()=>lf,nlNL:()=>cf});var lf={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},cf={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Vat gesprek samen"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Su={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};var Ii=require("react/jsx-runtime"),vu=()=>(0,Ii.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ii.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 Li=require("react/jsx-runtime"),_u=()=>(0,Li.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Li.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 R=require("react/jsx-runtime"),Xs=(t,e)=>{let o=(0,W.useSelector)(ze);(0,bu.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},pf=()=>{let t=E(Ri),e=(0,W.useDispatch)(),o=b("isEmbedded"),n=y("Widget",Su),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=(0,W.useSelector)(mo),u=(0,W.useSelector)(ks),d=(0,W.useSelector)(Mp),m=(0,W.useSelector)(Cs),h=(0,W.useSelector)(Bp),g=(0,W.useSelector)(zn),v=(0,W.useSelector)(jn),k=(0,W.useSelector)(ze),f=(0,W.useSelector)(Un),_=(0,W.useSelector)(Qp),x=(0,W.useSelector)(no),w=Se(),C=(0,W.useSelector)(Dl),D=(0,W.useSelector)(Wp("/admin/personal-collection")),ue=b("adminUrl");if(Xs(()=>(e(rn(f)),e(jp(f)),()=>{e(Vp(f))}),[e,v,r,f]),Xs(()=>(e(Ye(f)),e(Op(f)),()=>{e(Np(f))}),[e,v,s,f]),Xs(()=>{u.forEach(({type:I})=>{e(I==="entities"?Pe():Ke(I))})},[e,v,g,p]),Xs(()=>(e(xi()),()=>{e($p())}),[e,v,i,g]),v===!1)return(0,R.jsx)("div",{className:n.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("notSupported")})})},"supported");if(k===!1)return(0,R.jsx)("div",{className:n.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Rs,{isEmbedded:o,loginUrl:ue})})},"login");if(!p||!f||k===null||C||_)return(0,R.jsx)("div",{className:n.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("waiting")})})},"waiting");let B=c||a||l||D;return(0,R.jsx)("div",{className:(0,xu.default)(n.root),"data-testid":"widget",children:(0,R.jsxs)(Fn,{className:n.sectionList,children:[B&&(0,R.jsx)(st,{title:t("actions"),type:"shortcuts",children:(0,R.jsxs)("div",{className:n.shortcutList,children:[c&&(0,R.jsxs)("button",{className:n.shortcut,onClick:()=>w.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(to,{}),t("linkSearch")]}),a&&(0,R.jsxs)("button",{className:n.shortcut,onClick:()=>w.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(_u,{}),t("linkSummary")]}),l&&(0,R.jsxs)("button",{className:n.shortcut,onClick:()=>w.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeSearch"}),children:[(0,R.jsx)(vu,{}),t("linkKnowledgeSearch")]}),D&&(0,R.jsxs)("a",{className:n.shortcut,target:"_blank",href:D,rel:"noreferrer",children:[(0,R.jsx)(gu,{}),t("linkPersonalcollection")]})]})}),r&&h.length>0&&(0,R.jsx)(st,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(Le,{withDivider:!0,children:h.map(I=>(0,R.jsx)(du,{suggestion:I},I.text))})}),s&&d.length>0&&(0,R.jsx)(st,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(Le,{withDivider:!0,children:(0,R.jsx)(au,{})})}),u.map(({type:I,title:U,amount:J,lines:sr})=>{var bt;switch(I){case"entities":return m&&m.length>0&&(0,R.jsx)(st,{type:I,title:U,"data-testid":`type-${I}`,children:(0,R.jsx)(pu,{entities:m})},I);default:return((bt=x[I])==null?void 0:bt.fetchState)==="done"&&x[I].suggestions.length>0&&(0,R.jsx)(st,{type:I,title:U,"data-testid":`type-${I}`,children:(0,R.jsx)(Le,{withDivider:!0,children:(0,R.jsx)(yu,{lines:sr,contentType:I,suggestions:x[I].suggestions.slice(0,J)||[]})})},I)}})]})})},Cu=pf;function wu(t){let e=new Range;return e.selectNodeContents(t),e}var pn=/[\u200B-\u200D\uFEFF]/g;function Nt(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(l))return c;for(let d=0;d<=l.length;d++)if(u.test(l[d])||p++,p===c)return d;throw new Error("Offset out of range")}function a(l){var c;switch(l.nodeType){case Node.TEXT_NODE:{let p=l.textContent,u=p.replace(pn,""),d=s+u.length,m=e>=s&&e<=d,h=o>=s&&o<=d;if(m){let g=i(p,e-s);g===0&&!h?n.setStartBefore(l):n.setStart(l,g)}h&&(n.setEnd(l,i(p,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(l.tagName==="BR"&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let u=0;u<l.childNodes.length&&(a(l.childNodes[u]),!r);u++);let p=(c=l.lastChild)==null?void 0:c.tagName;l.tagName==="DIV"&&p!=="DIV"&&p!=="BR"&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function Qs(t,e){if(!t.contains(e.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i,a,l=0;function c(p){let u=p===o,d=p===s;switch(p.nodeType){case Node.TEXT_NODE:{let m=p.textContent;u&&(i=l+m.substring(0,n).replace(pn,"").length),d&&(a=l+m.substring(0,r).replace(pn,"").length),l+=m.replace(pn,"").length;break}case Node.ELEMENT_NODE:{let{tagName:m}=p,h=p.nextSibling===null;m==="BR"&&!h&&l++;for(let g=0;g<p.childNodes.length&&(u&&g===n&&(i=l),c(p.childNodes[g]),d&&g===r-1&&(a=l),a===void 0);g++);!d&&m==="DIV"&&!h&&l++,d&&(a=l);break}default:break}}if(c(t),a===void 0)throw new Error("Could not determine start and end");return{start:i??a,end:a}}function un(t,e){if(!t.contains(e.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,u=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let d=p?n:0,m=u?r:void 0,h=c.textContent.replace(pn,"");d===0&&m===void 0?a+=h:a+=h.substring(d,m);break}case Node.ELEMENT_NODE:{let{tagName:d}=c,m=c.nextSibling===null;i===0&&d==="BR"&&!m&&(a+=`
4
4
  `);for(let h=p?n:0;h<(u?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[h]),i!==1);h++);!u&&i===0&&d==="DIV"&&!m&&(a+=`
5
- `);break}default:break}u&&i++}return l(t),a}var Nt=class extends He{observer;getText(){let e=new Range;return e.selectNodeContents(this.element),un(this.element,e)}getHTML(){return this.element.innerHTML||""}getSelection(){if(document.activeElement!==this.element)return null;let e=window.getSelection();if(!e||e.rangeCount===0)return null;let o=e.getRangeAt(0);return!o||!this.element.contains(o.commonAncestorContainer)?null:Qs(this.element,o)}getSelectedText(){if(!this.currentSelection)return"";let{start:e,end:o}=this.currentSelection;return un(this.element,Ot(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var Li=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Ai=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=this.createIframe(),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];createIframe(){let e=`deepdesk-iframe-${this.name}`,o=document.getElementById(e);if(o)return o;let n=document.createElement("iframe"),s=`${this.targetOrigin}/v2/widget/liveengage/channel.html`,r=new URLSearchParams({channel:this.name,host:window.location.origin});return this.options.debug&&r.set("debug","1"),n.style.position="absolute",n.style.left="-999em",n.style.width="0px",n.style.height="0px",n.tabIndex=-1,n.id=e,n.title=`iframe-${this.name}`,n.src=`${s}?${r.toString()}`,n}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Mi=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),P.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Ai(e,this.deepdeskUrl,{debug:!0}):new Li(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(P.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var s,r,i;if(!this.sessionId)return;P.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(r=(s=this.eventMap)[e])==null||r.call(s,o),(i=this.channel)==null||i.postMessage({...n,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Tu=Mi;var xo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Oi=t=>new Promise(e=>{setTimeout(e,t)});var bo=class extends xo{name="ClientError"},Ni=class extends xo{name="ServerError"},Ie=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:u=!0,retryOnError:d=x=>x instanceof TypeError,retryOnResponse:m=x=>x.status>=500,version:h="v1",...g}=o,v={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(v.headers={...v.headers,"X-CSRFToken":this.csrfToken}),typeof h=="string"&&(v.headers={...v.headers,"X-Deepdesk-API-Version":h});let k=c,f=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let _=async()=>(k--,a(i,v).then(async x=>m(x)&&!r.isAborted&&k>0?(await Oi(p),_()):x.status===401&&u===!0&&f===!1?(f=!0,await this.refreshToken(),_()):x).catch(async x=>{if(d(x)&&!r.isAborted&&k>0)return await Oi(p),_();throw x}));_().then(x=>x.json().catch(()=>null).then(w=>{x.status>=500?s(new Ni("Server Error",w)):x.status===401?s(new bo("Unauthorized",w)):x.status===403?s(new bo("Forbidden",w)):x.status===404?s(new bo("Not Found",w)):x.status>=400&&s(new bo("Bad Request",w)),delete this.latestRequestByUrl[i],n(w)})).catch(x=>{s(x)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var uf;(e=>{let t;(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"))(t=e.EventType||={})})(uf||={});function Zs(t){return{...O(t),tags:t.tags}}var tt=class t{constructor(e,o={}){this.options=o;this.client=new Ie(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),P.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...z(e),tags:e.tags},{version:"v2"});return Zs(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return O(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return O(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return O(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),P.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return Zs(r)}async isConversationSupported(e,o={}){P.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=z(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Zs(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...z(s),tags:s.tags})),{version:"v2"})).map(s=>Zs(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",z({...r,...s,data:n,name:e}),{version:"v2"})}async sendEventV1(e,o){let n=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[r,i])=>({...s,[r]:i}),{});return this.client.post("/api/events",{event:e,data:z({...o,...n})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(n=>n.text)})).entities}async getSummary(e,o={}){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source)},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw P.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",z(o),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,o={},n){return n==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${n}`,z(o),{abortLatest:!0})).map(r=>({...O(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,o){return(await this.client.post(`/api/conversations/${e}/autocomplete`,z(o),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let o=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return O(o).map(n=>({...n,text:n.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let o=await this.client.post("/api/style-suggestions",z(e),{abortLatest:!0});return O(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,z(e),{version:"v2"});return O(o)}async knowledgeSearch(e,o,n){let s=await this.client.post("/api/knowledge-search/search",z({question:e.question,promptInstruction:e.promptInstruction,profile:n,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return O(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return O(o)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return O(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(Sa);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&P.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var dn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Br(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,O(s))}catch{P.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var df;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(df||={});var gn=class{constructor(e,o={}){this.apiUrl=e;this.client=new Ie(e,o)}client;streams={};logger=P;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return O(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,z(o));return O(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,z(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return O(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",z(e));return O(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new dn(`${this.apiUrl}/sessions/${e}/events`),this.streams[e].connect()),this.streams[e]}closeStream(e){this.streams[e]||(this.streams[e].disconnect(),delete this.streams[e])}};var er=require("@reduxjs/toolkit");var ku=require("@reduxjs/toolkit");var Eu={startTime:null,stopTime:null},Pu=(0,ku.createSlice)({name:"handlingTime",initialState:Eu,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(L,()=>Eu)}}),{handlingTimeStart:Iu,handlingTimeStop:Js,handlingTimeReset:Ru}=Pu.actions,Lu=Pu.reducer;var Au=(t={})=>{let e={onAuthError:io(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var Ys=require("@reduxjs/toolkit");var Di={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Dt=(0,Ys.createAsyncThunk)("styleSuggestions/getAll",async({text:t},e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),{showStyleSuggestions:s}=n.settings,r=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)return Di.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),gf=(0,Ys.createSlice)({name:"styleSuggestions",initialState:Di,reducers:{},extraReducers:t=>{t.addCase(Dt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Dt.rejected,e=>{e.fetchState="error"}).addCase(Dt.fulfilled,(e,o)=>{e.fetchState="done",it(e.list,o.payload)||(e.list=o.payload)}).addCase(L,()=>Di)}}),Mu=gf.reducer;var Ou=(t={})=>{let e,o=!0,n={getStyleSuggestions:Dt,debounce:500,...t};return s=>r=>i=>{var m;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((m=c.conversation.current)==null?void 0:m.id)||!p)return l;let{text:d}=c.input;return d===a&&!o||(clearTimeout(e),d==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:d}))},t.debounce)),l}};function mf(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Nu=(t={})=>{let e={getTextSuggestions:Ke,getAutocompleteSuggestions:zo,debounce:200,check:Ps,...t},o;return n=>s=>r=>{var g;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,u=(g=l.conversation.current)==null?void 0:g.id,d=r.type===Ss.toString();if(!u||!c&&!p)return a;let{input:{userCommitted:m}}=l;return mf(m,i)&&!d||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=jt(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},d?0:e.debounce)),a}};var Du=Dt.fulfilled.toString();function ff(t,e){let o=new Set([...e.keywordMatches.map(s=>s.keyword)]),n=[];return o.forEach(s=>{let r=t.keywordMatches.filter(l=>l.keyword===s),i=e.keywordMatches.filter(l=>l.keyword===s),a=i.length-r.length;a<=0||n.push(...i.slice(0,a))}),n}var Hu=t=>e=>o=>n=>{var p;if(n.type!==Du){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(p=r.conversation)==null?void 0:p.current,{agentInfo:l}=r.info;if(s===i)return;let c=ff(s,i);n.type===Du&&c.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,agentId:l.agentId??(a==null?void 0:a.agentId),agentName:l.agentName??(a==null?void 0:a.agentName),agentEmail:l.agentEmail??(a==null?void 0:a.agentEmail),data:{keywordMatches:c}})};var hf=(0,er.combineReducers)({activeSuggestion:Gl,answer:Dc,auth:lc,autoflows:Dp,conversation:Ea,contentTypes:_c,customMessages:qp,exchangeToken:Xp,entities:wc,handlingTime:Lu,info:vl,input:Cr.reducer,overlayInput:Y.reducer,settings:ba,profile:Fc,search:Tl,summary:Rc,styleSuggestions:Mu,ui:Yl,textSuggestions:Ul});function Bu(t){return(0,er.configureStore)({reducer:hf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Au(),Nu({debounce:200}),Ou({debounce:500}),Hu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var yf=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Sf=t=>e=>o=>n=>{var a;let s=e.getState(),r=vr("inlineSuggestions")(s);switch(n.type){case Ue.toString():{let l=Nl(n.payload.contentType)(e.getState()),c=l.indexOf(n.payload.suggestion);t.emit("edit-suggestion",{contentType:n.payload.contentType,index:c,suggestions:l});break}case io.toString():{!n.payload&&t.emit("logout",void 0);break}case we.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:yf(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Qn.toString():{let{start:l,end:c}=s.input.selection;t.emit("replace",{...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Ao.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case es.toString():t.emit("select-image",n.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:n.payload.suggestion.image,title:n.payload.suggestion.title}});break;case ke.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case Ve.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{inputText:JSON.stringify(n.payload.original),summary:n.payload.summary}});break;case ie.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case Zn.toString():t.handleKeyDown(n.payload);break;case Lo.toString():t.logSendMessage(n.payload);break;case Jn.toString():t.logSendEditSuggestionMessage(n.payload);break;case Yn.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Lo.toString():t.handleAfterSendMessage(n.payload);break;case jo.toString():t.onUpdateShowTabHint(n.payload);break;case Js.toString():t.logHandlingTime();break;case we.toString():{r&&(e.dispatch(lt([])),e.dispatch(ct()));break}default:break}return i},Fu=Sf;function Hi(t){return t.toISOString().replace("T"," ").replace("Z","")}function Ku(t,e){var s,r,i;let{startTime:o,stopTime:n}=t.handlingTime;if(!o||!n)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:t.conversation.current.id,clientVersion:e.version,agentId:(s=t.info.agentInfo)==null?void 0:s.agentId,agentName:(r=t.info.agentInfo)==null?void 0:r.agentName,agentEmail:(i=t.info.agentInfo)==null?void 0:i.agentEmail,timeStart:Hi(o),timeStop:Hi(n)}}function Bi(t,e,o){var D,ue,B;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:u,cuts:d,deletions:m,textSuggestions:h,offeredTextSuggestions:g}}=e[t],v=n.length,f=h.reduce((R,{text:U,searchTerm:J})=>R+U.length-(J?J.length:0),0),_=c??Date.now(),x=(Date.now()-_)/1e3+(p||0),w=s/x,C=h.reduce((R,{searchTerm:U})=>R+(U?U.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:u,cuts:d,deletions:m,lenTextTyped:s+C,lenTextTotal:v,lenTextAssisted:f,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:x,charsPerSecond:w,numPastes:l,textSuggestionsV2:h,suggestionsCounters:[{source:"gpt",countOffered:g.filter(R=>R.source==="gpt").length}],agentId:(D=e.info.agentInfo)==null?void 0:D.agentId,agentName:(ue=e.info.agentInfo)==null?void 0:ue.agentName,agentEmail:(B=e.info.agentInfo)==null?void 0:B.agentEmail}}function Uu(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?Uu(n,e):null}function zu(t,e){return Uu(t,e)}function ju(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function tr(t){return t instanceof HTMLElement&&(Xe(t)||ss(t))}var Vu=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{P.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function vf(t){return t.offsetParent!==null}function qu(t){if(!vf(t))return!1;let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function or(t,e,o=100){let n=qu(t);e({isVisible:n});let s=setInterval(()=>{let r=qu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var pe=require("react/jsx-runtime"),Wu=Vu("showTabHint",!0),mn=class t{static version="10.1.8";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new tt(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Fu({emit:(u,d,m)=>this.emit(u,d,m),handleAfterSendMessage:u=>this.handleAfterSendMessage(u),handleInputChanged:u=>this.handleInputChanged(u),handleKeyDown:u=>this.handleKeyDown(u),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:u=>this.logSendMessage(u),logSendEditSuggestionMessage:u=>this.logSendEditMessage(u),onUpdateShowTabHint:u=>Wu.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new gn(o)}),this.store=Bu(p),this.broadcastEvents=new Tu({debug:!0,deepdeskUrl:c,eventMap:cc(this.store),createCustomChannel:l}),this.store.dispatch(Ro),this.store.dispatch(jo(Wu.value())),this.store.dispatch(Ro({locale:s,adminUrl:c,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?(P.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(P.warn("Profile has not been loaded (yet)"),!0):(P.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(io(null)),this.store.dispatch(mt()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ze(n)&&oc(n)!=="loading"&&e()});this.unmountHandlers.push(()=>{o()})})}isLoggedIn(){return this.deepdeskApi.isLoggedIn()}async setPlatformAgentId(e){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:e}),version:null})}catch(o){P.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(xr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Vn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(qn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(br(e))).payload}async postMessages(e){return(await this.store.dispatch(Gn(e))).payload}async updateConversation(e){return(await this.store.dispatch(Wn(e))).payload}resetConversation(){this.store.dispatch(L()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Ve());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Ro(e))}setVisitorInfo(e){this.store.dispatch(Sl(e))}async setAgentInfo(e){await this.store.dispatch(Bo(e))}async setAgentSettings(e){await this.store.dispatch(Fr(e))}async getAgentSettings(){return(await this.store.dispatch(Kr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();let e=[];return this.store.dispatch(Ss()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Yn(e))}syncInputHtml(e){this.store.dispatch(Ua(e))}notifyKeyDown(e){this.store.dispatch(Zn(e))}notifyPaste(e,o){this.store.dispatch(Fa({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ha(e))}notifyExternalSuggestion(e){this.store.dispatch(we(e)),this.store.dispatch(ct())}notifyEditSuggestion(e){this.store.dispatch(Fl(e.contentType,e.suggestions)),this.store.dispatch(Ue({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(so({collapse:!1})),this.inputMediator&&this.store.dispatch(La({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(lt([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(Ba(Xn(e))),!(e.key!=="Tab"&&!this.settings.showTextSuggestions))switch(e.key){case"Up":case"ArrowUp":if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Oa()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return;case"Down":case"ArrowDown":{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Da());let{selectedSuggestionIndex:c}=this.state.input;c===-1?this.store.dispatch(Ao()):i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return}case"Esc":case"Escape":{l?(this.store.dispatch(ts(-1)),this.store.dispatch(Ao()),e.preventDefault()):o||(this.store.dispatch(so({collapse:!0})),this.store.dispatch(Zl(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:c}=this.state.input,p=c.text.substring(0,c.selection.end),{tabCompletionSuggestion:u}=this.state.input;this.store.dispatch(jo(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):this.settings.showTabCompletion&&u&&u.text.startsWith(p)&&(this.store.dispatch(we({text:u.text,suggestion:u,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(ct())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ka()),this.store.dispatch(lt([]))}handlingTimeStart(){this.state.handlingTime.startTime||(P.info("Start handling time"),this.store.dispatch(Iu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(P.info("Stop handling time"),this.store.dispatch(Js()))}logSendMessage(e){let o=Bi("input",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=Bi("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Ma(this.state.overlayInput.metrics))}logHandlingTime(){let e=Ku(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Ru())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(ct()),this.store.dispatch(Lo(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(we({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){P.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),P.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=Zt(n,s);return r.dataset.testid=e,o!=null&&o.rootNode&&r.classList.add(o.rootNode),this.unmountHandlers.push(()=>{(0,ot.unmountComponentAtNode)(r),i(),r.remove()}),r}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return kt(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,o.appendChild(s),this.unmountHandlers.push(()=>{(0,ot.unmountComponentAtNode)(s),s.remove()}),s}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!tr(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:u,detectSubmit:d,insertLink:m,inputMediator:h,closestScrollSelector:g,appendOverlayTo:v,inlineSuggestions:k}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:m,isEmbedded:u,inlineSuggestions:k});let f=g&&zu(e,g)||void 0,_=this.overlayContainerFactory("deepdesk-tab-completion",n,f||e,{appendTo:v,closestScrollElement:f,mirrorOverflow:!0,onRemove:()=>this.unmount()}),x=this.overlayContainerFactory("deepdesk-suggestions-overlay",n,f||e,{appendTo:v});o.automaticHandlingTime&&this.setupHandlingTime(e),(0,ot.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Rp,{inputElement:e})})}),_),(0,ot.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(As,{})})}),x),(0,ot.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Vc,{})})}),this.createContainer("deepdesk-overlays")),kt(e),this.inputMediator=h||(Xe(e)?new Be(e):new Nt(e)),this.inputMediator.on("change",({plainText:C})=>{this.notifyInputChanged(C)}),this.inputMediator.on("updated",({rawHtml:C})=>{C!=null&&this.syncInputHtml(C)}),this.inputMediator.on("keydown",C=>{this.notifyKeyDown(C)}),this.inputMediator.on("paste",({pastedText:C,selectionText:D})=>{this.notifyPaste(C,D)}),this.inputMediator.on("cut",({selectionText:C})=>{this.notifyCut(C)});let w;this.inputMediator.on("selection",C=>{clearTimeout(w),C===null?w=setTimeout(()=>{C!==null&&this.store.dispatch(wr(C))},500):this.store.dispatch(wr(C))}),this.inputMediator.on("disabled",()=>{var C;(C=this.inputMediator)==null||C.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(no(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(no(!0))),this.store.dispatch(Aa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var C;this.refresh(),this.broadcastEvents.setSessionId((C=this.state.conversation.current)==null?void 0:C.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&P.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,showPersonalCollectionLink:r,isEmbedded:i}=o;this.widgetRoot=e,this.configure({showImages:s,showPersonalCollectionLink:r,isEmbedded:i}),(0,ot.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Cu,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,ot.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=or(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){ju(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(en());let e=go(this.state);e&&this.store.dispatch(Ro({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeSearch,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(P.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;P.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=ks(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(ke()):this.store.dispatch(Ke(n))})}catch(n){this.handleError(n)}}};async function Gu(t,e,o={}){let{value:n}=t,{start:s,end:r}=o.replace??{start:0,end:n.length},i=`${n.slice(0,s)}${e}${n.slice(r)}`,a=o.selectionAfter??{start:s+e.length,end:s+e.length},l=()=>{if(o.setValue)return o.setValue(i);t.value=i};return Promise.resolve(l()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function $u(t,e,o={}){let n=o.replace?Ot(t,o.replace.start,o.replace.end):wu(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),e.split(`
6
- `).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}),n.commonAncestorContainer===t&&n.surroundContents(document.createElement("div"))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?Ot(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Xu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Qu(t,e,o){await new tt(t).authenticateWithKey(e,o)}async function Zu(t){let o=await new Ie(t).get("/platform/config/",{version:null});return O(o)}async function _f(t){let o=await(t.fetch??window.fetch)(t.url),n=await o.blob();return new File([n],t.name,{type:t.mimeType??o.headers.get("Content-Type")??"image/jpeg"})}async function Ju(t,e){let o=await _f(e),n=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[o]}),t.dispatchEvent(n)}finally{Object.hasOwn(t,"files")&&delete t.files}}0&&(module.exports={Card,Chip,ContentEditableInput,DeepdeskAPI,DeepdeskSDK,HTTPClient,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createOverlayContainer,createRangeFromOffsets,escapeHTML,fetchPlatformConfig,formatTextMarkup,getRangeOffsets,getRangeText,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});
5
+ `);break}default:break}u&&i++}return l(t),a}var Dt=class extends He{observer;getText(){let e=new Range;return e.selectNodeContents(this.element),un(this.element,e)}getHTML(){return this.element.innerHTML||""}getSelection(){if(document.activeElement!==this.element)return null;let e=window.getSelection();if(!e||e.rangeCount===0)return null;let o=e.getRangeAt(0);return!o||!this.element.contains(o.commonAncestorContainer)?null:Qs(this.element,o)}getSelectedText(){if(!this.currentSelection)return"";let{start:e,end:o}=this.currentSelection;return un(this.element,Nt(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var Ai=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Mi=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=this.createIframe(),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];createIframe(){let e=`deepdesk-iframe-${this.name}`,o=document.getElementById(e);if(o)return o;let n=document.createElement("iframe"),s=`${this.targetOrigin}/v2/widget/liveengage/channel.html`,r=new URLSearchParams({channel:this.name,host:window.location.origin});return this.options.debug&&r.set("debug","1"),n.style.position="absolute",n.style.left="-999em",n.style.width="0px",n.style.height="0px",n.tabIndex=-1,n.id=e,n.title=`iframe-${this.name}`,n.src=`${s}?${r.toString()}`,n}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Oi=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),P.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Mi(e,this.deepdeskUrl,{debug:!0}):new Ai(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(P.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var s,r,i;if(!this.sessionId)return;P.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(r=(s=this.eventMap)[e])==null||r.call(s,o),(i=this.channel)==null||i.postMessage({...n,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Tu=Oi;var bo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Ni=t=>new Promise(e=>{setTimeout(e,t)});var Co=class extends bo{name="ClientError"},Di=class extends bo{name="ServerError"},Ie=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:u=!0,retryOnError:d=x=>x instanceof TypeError,retryOnResponse:m=x=>x.status>=500,version:h="v1",...g}=o,v={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(v.headers={...v.headers,"X-CSRFToken":this.csrfToken}),typeof h=="string"&&(v.headers={...v.headers,"X-Deepdesk-API-Version":h});let k=c,f=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let _=async()=>(k--,a(i,v).then(async x=>m(x)&&!r.isAborted&&k>0?(await Ni(p),_()):x.status===401&&u===!0&&f===!1?(f=!0,await this.refreshToken(),_()):x).catch(async x=>{if(d(x)&&!r.isAborted&&k>0)return await Ni(p),_();throw x}));_().then(x=>x.json().catch(()=>null).then(w=>{x.status>=500?s(new Di("Server Error",w)):x.status===401?s(new Co("Unauthorized",w)):x.status===403?s(new Co("Forbidden",w)):x.status===404?s(new Co("Not Found",w)):x.status>=400&&s(new Co("Bad Request",w)),delete this.latestRequestByUrl[i],n(w)})).catch(x=>{s(x)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var uf;(e=>{let t;(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"))(t=e.EventType||={})})(uf||={});function Zs(t){return{...O(t),tags:t.tags}}var tt=class t{constructor(e,o={}){this.options=o;this.client=new Ie(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),P.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...z(e),tags:e.tags},{version:"v2"});return Zs(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return O(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return O(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return O(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),P.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return Zs(r)}async isConversationSupported(e,o={}){P.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=z(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Zs(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...z(s),tags:s.tags})),{version:"v2"})).map(s=>Zs(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",z({...r,...s,data:n,name:e}),{version:"v2"})}async sendEventV1(e,o){let n=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[r,i])=>({...s,[r]:i}),{});return this.client.post("/api/events",{event:e,data:z({...o,...n})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(n=>n.text)})).entities}async getSummary(e,o={}){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source)},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw P.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",z(o),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,o={},n){return n==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${n}`,z(o),{abortLatest:!0})).map(r=>({...O(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,o){return(await this.client.post(`/api/conversations/${e}/autocomplete`,z(o),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let o=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return O(o).map(n=>({...n,text:n.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let o=await this.client.post("/api/style-suggestions",z(e),{abortLatest:!0});return O(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,z(e),{version:"v2"});return O(o)}async knowledgeSearch(e,o,n){let s=await this.client.post("/api/knowledge-search/search",z({question:e.question,promptInstruction:e.promptInstruction,profile:n,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return O(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return O(o)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return O(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(Sa);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&P.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var dn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Fr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,O(s))}catch{P.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var df;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(df||={});var gn=class{constructor(e,o={}){this.apiUrl=e;this.client=new Ie(e,o)}client;streams={};logger=P;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return O(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,z(o));return O(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,z(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return O(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",z(e));return O(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new dn(`${this.apiUrl}/sessions/${e}/events`),this.streams[e].connect()),this.streams[e]}closeStream(e){this.streams[e]||(this.streams[e].disconnect(),delete this.streams[e])}};var tr=require("@reduxjs/toolkit");var ku=require("@reduxjs/toolkit");var Eu={startTime:null,stopTime:null},Pu=(0,ku.createSlice)({name:"handlingTime",initialState:Eu,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(L,()=>Eu)}}),{handlingTimeStart:Ru,handlingTimeStop:Js,handlingTimeReset:Iu}=Pu.actions,Lu=Pu.reducer;var Au=(t={})=>{let e={onAuthError:ao(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var er=require("@reduxjs/toolkit");var Ys={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Ht=(0,er.createAsyncThunk)("styleSuggestions/getAll",async({text:t},e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),{showStyleSuggestions:s}=n.settings,r=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)return Ys.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),gf=(0,er.createSlice)({name:"styleSuggestions",initialState:Ys,reducers:{},extraReducers:t=>{t.addCase(Ht.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Ht.rejected,e=>{e.fetchState="error"}).addCase(Ht.fulfilled,(e,o)=>{e.fetchState="done",it(e.list,o.payload)||(e.list=o.payload)}).addCase(kt,e=>{e.list=Ys.list}).addCase(L,()=>Ys)}}),Mu=gf.reducer;var Ou=(t={})=>{let e,o=!0,n={getStyleSuggestions:Ht,debounce:500,...t};return s=>r=>i=>{var m;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((m=c.conversation.current)==null?void 0:m.id)||!p)return l;let{text:d}=c.input;return d===a&&!o||(clearTimeout(e),d==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:d}))},t.debounce)),l}};function mf(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Nu=(t={})=>{let e={getTextSuggestions:Ke,getAutocompleteSuggestions:zo,debounce:200,check:Ps,...t},o;return n=>s=>r=>{var g;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,u=(g=l.conversation.current)==null?void 0:g.id,d=r.type===Ss.toString();if(!u||!c&&!p)return a;let{input:{userCommitted:m}}=l;return mf(m,i)&&!d||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=Vt(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},d?0:e.debounce)),a}};var Du=Ht.fulfilled.toString();function ff(t,e){let o=new Set([...e.keywordMatches.map(s=>s.keyword)]),n=[];return o.forEach(s=>{let r=t.keywordMatches.filter(l=>l.keyword===s),i=e.keywordMatches.filter(l=>l.keyword===s),a=i.length-r.length;a<=0||n.push(...i.slice(0,a))}),n}var Hu=t=>e=>o=>n=>{var c;if(n.type!==Du){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(c=r.conversation)==null?void 0:c.current;if(s===i)return;let l=ff(s,i);n.type===Du&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var hf=(0,tr.combineReducers)({activeSuggestion:Gl,answer:Dc,auth:lc,autoflows:Dp,conversation:Ea,contentTypes:_c,customMessages:qp,exchangeToken:Xp,entities:wc,handlingTime:Lu,info:vl,input:wr.reducer,overlayInput:Y.reducer,settings:ba,profile:Fc,search:Tl,summary:Ic,styleSuggestions:Mu,ui:Yl,textSuggestions:Ul});function Bu(t){return(0,tr.configureStore)({reducer:hf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Au(),Nu({debounce:200}),Ou({debounce:500}),Hu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var yf=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Sf=t=>e=>o=>n=>{var a;let s=e.getState(),r=_r("inlineSuggestions")(s);switch(n.type){case Ue.toString():{let l=Nl(n.payload.contentType)(e.getState()),c=l.indexOf(n.payload.suggestion);t.emit("edit-suggestion",{contentType:n.payload.contentType,index:c,suggestions:l});break}case ao.toString():{!n.payload&&t.emit("logout",void 0);break}case Te.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:yf(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Qn.toString():{let{start:l,end:c}=s.input.selection;t.emit("replace",{...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Ao.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case es.toString():t.emit("select-image",n.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:n.payload.suggestion.image,title:n.payload.suggestion.title}});break;case Pe.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case Ve.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{inputText:JSON.stringify(n.payload.original),summary:n.payload.summary}});break;case ie.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case Zn.toString():t.handleKeyDown(n.payload);break;case kt.toString():t.logSendMessage(n.payload);break;case Jn.toString():t.logSendEditSuggestionMessage(n.payload);break;case Yn.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case kt.toString():t.handleAfterSendMessage(n.payload);break;case jo.toString():t.onUpdateShowTabHint(n.payload);break;case Js.toString():t.logHandlingTime();break;case Te.toString():{r&&(e.dispatch(lt([])),e.dispatch(ct()));break}default:break}return i},Fu=Sf;function Hi(t){return t.toISOString().replace("T"," ").replace("Z","")}function Ku(t,e){var s,r,i;let{startTime:o,stopTime:n}=t.handlingTime;if(!o||!n)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:t.conversation.current.id,clientVersion:e.version,agentId:(s=t.info.agentInfo)==null?void 0:s.agentId,agentName:(r=t.info.agentInfo)==null?void 0:r.agentName,agentEmail:(i=t.info.agentInfo)==null?void 0:i.agentEmail,timeStart:Hi(o),timeStop:Hi(n)}}function Bi(t,e,o){var D,ue,B;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:u,cuts:d,deletions:m,textSuggestions:h,offeredTextSuggestions:g}}=e[t],v=n.length,f=h.reduce((I,{text:U,searchTerm:J})=>I+U.length-(J?J.length:0),0),_=c??Date.now(),x=(Date.now()-_)/1e3+(p||0),w=s/x,C=h.reduce((I,{searchTerm:U})=>I+(U?U.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:u,cuts:d,deletions:m,lenTextTyped:s+C,lenTextTotal:v,lenTextAssisted:f,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:x,charsPerSecond:w,numPastes:l,textSuggestionsV2:h,suggestionsCounters:[{source:"gpt",countOffered:g.filter(I=>I.source==="gpt").length}],agentId:(D=e.info.agentInfo)==null?void 0:D.agentId,agentName:(ue=e.info.agentInfo)==null?void 0:ue.agentName,agentEmail:(B=e.info.agentInfo)==null?void 0:B.agentEmail}}function Uu(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?Uu(n,e):null}function zu(t,e){return Uu(t,e)}function ju(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function or(t){return t instanceof HTMLElement&&(Xe(t)||ss(t))}var Vu=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{P.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function vf(t){return t.offsetParent!==null}function qu(t){if(!vf(t))return!1;let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function nr(t,e,o=100){let n=qu(t);e({isVisible:n});let s=setInterval(()=>{let r=qu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var pe=require("react/jsx-runtime"),Wu=Vu("showTabHint",!0),mn=class t{static version="10.1.9";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new tt(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Fu({emit:(u,d,m)=>this.emit(u,d,m),handleAfterSendMessage:u=>this.handleAfterSendMessage(u),handleInputChanged:u=>this.handleInputChanged(u),handleKeyDown:u=>this.handleKeyDown(u),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:u=>this.logSendMessage(u),logSendEditSuggestionMessage:u=>this.logSendEditMessage(u),onUpdateShowTabHint:u=>Wu.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new gn(o)}),this.store=Bu(p),this.broadcastEvents=new Tu({debug:!0,deepdeskUrl:c,eventMap:cc(this.store),createCustomChannel:l}),this.store.dispatch(Lo),this.store.dispatch(jo(Wu.value())),this.store.dispatch(Lo({locale:s,adminUrl:c,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?(P.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(P.warn("Profile has not been loaded (yet)"),!0):(P.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(ao(null)),this.store.dispatch(mt()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ze(n)&&oc(n)!=="loading"&&e()});this.unmountHandlers.push(()=>{o()})})}isLoggedIn(){return this.deepdeskApi.isLoggedIn()}async setPlatformAgentId(e){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:e}),version:null})}catch(o){P.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(br({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Vn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(qn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Cr(e))).payload}async postMessages(e){return(await this.store.dispatch(Gn(e))).payload}async updateConversation(e){return(await this.store.dispatch(Wn(e))).payload}resetConversation(){this.store.dispatch(L()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Ve());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Lo(e))}setVisitorInfo(e){this.store.dispatch(Sl(e))}async setAgentInfo(e){await this.store.dispatch(Bo(e))}async setAgentSettings(e){await this.store.dispatch(Kr(e))}async getAgentSettings(){return(await this.store.dispatch(Ur())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();let e=[];return this.store.dispatch(Ss()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Yn(e))}syncInputHtml(e){this.store.dispatch(Ua(e))}notifyKeyDown(e){this.store.dispatch(Zn(e))}notifyPaste(e,o){this.store.dispatch(Fa({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ha(e))}notifyExternalSuggestion(e){this.store.dispatch(Te(e)),this.store.dispatch(ct())}notifyEditSuggestion(e){this.store.dispatch(Fl(e.contentType,e.suggestions)),this.store.dispatch(Ue({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(ro({collapse:!1})),this.inputMediator&&this.store.dispatch(La({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(lt([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(Ba(Xn(e))),!(e.key!=="Tab"&&!this.settings.showTextSuggestions))switch(e.key){case"Up":case"ArrowUp":if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Oa()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return;case"Down":case"ArrowDown":{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Da());let{selectedSuggestionIndex:c}=this.state.input;c===-1?this.store.dispatch(Ao()):i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return}case"Esc":case"Escape":{l?(this.store.dispatch(ts(-1)),this.store.dispatch(Ao()),e.preventDefault()):o||(this.store.dispatch(ro({collapse:!0})),this.store.dispatch(Zl(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:c}=this.state.input,p=c.text.substring(0,c.selection.end),{tabCompletionSuggestion:u}=this.state.input;this.store.dispatch(jo(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):this.settings.showTabCompletion&&u&&u.text.startsWith(p)&&(this.store.dispatch(Te({text:u.text,suggestion:u,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(ct())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ka()),this.store.dispatch(lt([]))}handlingTimeStart(){this.state.handlingTime.startTime||(P.info("Start handling time"),this.store.dispatch(Ru()))}handlingTimeStop(){this.state.handlingTime.startTime&&(P.info("Stop handling time"),this.store.dispatch(Js()))}logSendMessage(e){let o=Bi("input",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=Bi("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Ma(this.state.overlayInput.metrics))}logHandlingTime(){let e=Ku(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Iu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(ct()),this.store.dispatch(kt(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(Te({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){P.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),P.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=Jt(o,n);return r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,ot.unmountComponentAtNode)(r),i(),r.remove()}),r}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Pt(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,o.appendChild(s),this.unmountHandlers.push(()=>{(0,ot.unmountComponentAtNode)(s),s.remove()}),s}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!or(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:u,detectSubmit:d,insertLink:m,inputMediator:h,closestScrollSelector:g,appendOverlayTo:v,inlineSuggestions:k}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:m,isEmbedded:u,inlineSuggestions:k});let f=g&&zu(e,g)||void 0,_=this.overlayContainerFactory("deepdesk-tab-completion",f||e,{appendTo:v,closestScrollElement:f,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),x=this.overlayContainerFactory("deepdesk-suggestions-overlay",f||e,{appendTo:v},n==null?void 0:n.suggestionsRootNode);o.automaticHandlingTime&&this.setupHandlingTime(e),(0,ot.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Ip,{inputElement:e})})}),_),(0,ot.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(As,{})})}),x),(0,ot.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Vc,{})})}),this.createContainer("deepdesk-overlays")),Pt(e),this.inputMediator=h||(Xe(e)?new Be(e):new Dt(e)),this.inputMediator.on("change",({plainText:C})=>{this.notifyInputChanged(C)}),this.inputMediator.on("updated",({rawHtml:C})=>{C!=null&&this.syncInputHtml(C)}),this.inputMediator.on("keydown",C=>{this.notifyKeyDown(C)}),this.inputMediator.on("paste",({pastedText:C,selectionText:D})=>{this.notifyPaste(C,D)}),this.inputMediator.on("cut",({selectionText:C})=>{this.notifyCut(C)});let w;this.inputMediator.on("selection",C=>{clearTimeout(w),C===null?w=setTimeout(()=>{C!==null&&this.store.dispatch(Tr(C))},500):this.store.dispatch(Tr(C))}),this.inputMediator.on("disabled",()=>{var C;(C=this.inputMediator)==null||C.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(so(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(so(!0))),this.store.dispatch(Aa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var C;this.refresh(),this.broadcastEvents.setSessionId((C=this.state.conversation.current)==null?void 0:C.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&P.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,showPersonalCollectionLink:r,isEmbedded:i}=o;this.widgetRoot=e,this.configure({showImages:s,showPersonalCollectionLink:r,isEmbedded:i}),(0,ot.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Cu,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,ot.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=nr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){ju(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(en());let e=mo(this.state);e&&this.store.dispatch(Lo({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeSearch,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(P.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;P.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=ks(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Pe()):this.store.dispatch(Ke(n))})}catch(n){this.handleError(n)}}};async function Gu(t,e,o={}){let{value:n}=t,{start:s,end:r}=o.replace??{start:0,end:n.length},i=`${n.slice(0,s)}${e}${n.slice(r)}`,a=o.selectionAfter??{start:s+e.length,end:s+e.length},l=()=>{if(o.setValue)return o.setValue(i);t.value=i};return Promise.resolve(l()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function $u(t,e,o={}){let n=o.replace?Nt(t,o.replace.start,o.replace.end):wu(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),e.split(`
6
+ `).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}),n.commonAncestorContainer===t&&n.surroundContents(document.createElement("div"))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?Nt(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Xu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Qu(t,e,o){await new tt(t).authenticateWithKey(e,o)}async function Zu(t){let o=await new Ie(t).get("/platform/config/",{version:null});return O(o)}async function _f(t){let o=await(t.fetch??window.fetch)(t.url),n=await o.blob();return new File([n],t.name,{type:t.mimeType??o.headers.get("Content-Type")??"image/jpeg"})}async function Ju(t,e){let o=await _f(e),n=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[o]}),t.dispatchEvent(n)}finally{Object.hasOwn(t,"files")&&delete t.files}}0&&(module.exports={Card,Chip,ContentEditableInput,DeepdeskAPI,DeepdeskSDK,HTTPClient,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createOverlayContainer,createRangeFromOffsets,escapeHTML,fetchPlatformConfig,formatTextMarkup,getRangeOffsets,getRangeText,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});