@deepdesk/deepdesk-sdk 10.1.13 → 10.1.15

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 pd=Object.create;var Sn=Object.defineProperty;var ud=Object.getOwnPropertyDescriptor;var dd=Object.getOwnPropertyNames;var gd=Object.getPrototypeOf,md=Object.prototype.hasOwnProperty;var V=(t,e)=>{for(var o in e)Sn(t,o,{get:e[o],enumerable:!0})},Ui=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of dd(e))!md.call(t,s)&&s!==o&&Sn(t,s,{get:()=>e[s],enumerable:!(n=ud(e,s))||n.enumerable});return t};var w=(t,e,o)=>(o=t!=null?pd(gd(t)):{},Ui(e||!t||!t.__esModule?Sn(o,"default",{value:t,enumerable:!0}):o,t)),fd=t=>Ui(Sn({},"__esModule",{value:!0}),t);var bf={};V(bf,{Card:()=>F,Chip:()=>ta,ContentEditableInput:()=>Nt,DeepdeskAPI:()=>tt,DeepdeskSDK:()=>hn,HTTPClient:()=>Ie,InputMediator:()=>He,InputType:()=>rt,KeyboardHint:()=>Fn,Label:()=>Kn,Locale:()=>Lo,Section:()=>st,SectionList:()=>Un,Sources:()=>Ce,Suggestion:()=>N,SuggestionList:()=>Ae,TextAreaInput:()=>Be,ToggleButton:()=>Et,attachFile:()=>Yu,authenticateWithKey:()=>Zu,createFullRange:()=>bo,createOverlayContainer:()=>Jt,createRangeFromOffsets:()=>xt,escapeHTML:()=>ho,fetchPlatformConfig:()=>Ju,formatTextMarkup:()=>Qu,getRangeOffsets:()=>Co,getRangeText:()=>gn,isSupportedInputElement:()=>nr,updateContentEditable:()=>Xu,updateTextArea:()=>$u,useStyles:()=>y,waitForElementVisibilityChange:()=>sr});module.exports=fd(bf);var xn=w(require("classnames")),de=w(require("react"));var vn=w(require("react")),zi=w(require("classnames")),Eo=vn.default.createContext({});function y(t,e){let{debug:o,...n}=(0,vn.useContext)(Eo),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,zi.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var ji={root:"_root_vr71j_1"};var Ct=require("react/jsx-runtime"),_n=()=>(0,Ct.jsxs)("svg",{className:ji.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 lr={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"),bn=(0,de.createContext)(lr),hd=({title:t,src:e})=>{let o=(0,de.useContext)(bn),[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)(_n,{})})},yd=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,de.useContext)(bn);return(0,wt.jsx)("div",{className:(0,xn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Sd=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,de.useContext)(bn);return de.default.createElement(t,{className:(0,xn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Cn=({children:t})=>{let e=y("Card",lr);return(0,wt.jsx)("div",{className:(0,xn.default)(e.root),children:(0,wt.jsx)(bn.Provider,{value:e,children:t})})};Cn.Image=hd;Cn.Content=yd;Cn.Title=Sd;var F=Cn;var Vi={root:"_root_nkim0_1"};var Hn=require("react");var cr=function(t,e){return cr=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])},cr(t,e)};function ko(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");cr(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 qi(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 wn(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 Tn;(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"})(Tn||(Tn={}));var En=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 kn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(kn||(kn={}));function pr(t){return t.type===be.literal}function Wi(t){return t.type===be.argument}function Pn(t){return t.type===be.number}function Rn(t){return t.type===be.date}function In(t){return t.type===be.time}function An(t){return t.type===be.select}function Ln(t){return t.type===be.plural}function Gi(t){return t.type===be.pound}function Mn(t){return t.type===be.tag}function On(t){return!!(t&&typeof t=="object"&&t.type===kn.number)}function Po(t){return!!(t&&typeof t=="object"&&t.type===kn.dateTime)}function ur(t){t.forEach(function(e){if(delete e.location,An(e)||Ln(e))for(var o in e.options)delete e.options[o].location,ur(e.options[o].value);else Pn(e)&&On(e.style)||(Rn(e)||In(e))&&Po(e.style)?delete e.style.location:Mn(e)&&ur(e.children)})}function $i(t,e){e===void 0&&(e={}),e=re({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new En(t,e).parse();if(o.err){var n=SyntaxError(Tn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||ur(o.val),o.val}function Nn(t,e){var o=e&&e.cache?e.cache:wd,n=e&&e.serializer?e.serializer:Cd,s=e&&e.strategy?e.strategy:_d;return s(t,{cache:o,serializer:n})}function vd(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Xi(t,e,o,n){var s=vd(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Qi(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 dr(t,e,o,n,s){return o.bind(e,t,n,s)}function _d(t,e){var o=t.length===1?Xi:Qi;return dr(t,this,o,e.cache.create(),e.serializer)}function xd(t,e){return dr(t,this,Qi,e.cache.create(),e.serializer)}function bd(t,e){return dr(t,this,Xi,e.cache.create(),e.serializer)}var Cd=function(){return JSON.stringify(arguments)};function gr(){this.cache=Object.create(null)}gr.prototype.get=function(t){return this.cache[t]};gr.prototype.set=function(t,e){this.cache[t]=e};var wd={create:function(){return new gr}},Dn={variadic:xd,monadic:bd};var Tt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Tt||(Tt={}));var Ro=function(t){ko(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 mr=function(t){ko(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}(Ro);var Zi=function(t){ko(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}(Ro);var Ji=function(t){ko(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}(Ro);var G;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(G||(G={}));function Td(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 Ed(t){return typeof t=="function"}function Io(t,e,o,n,s,r,i){if(t.length===1&&pr(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(pr(p)){a.push({type:G.literal,value:p.value});continue}if(Gi(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 Ji(u,i);var d=s[u];if(Wi(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(Rn(p)){var m=typeof p.style=="string"?n.date[p.style]:Po(p.style)?p.style.parsedOptions:void 0;a.push({type:G.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(In(p)){var m=typeof p.style=="string"?n.time[p.style]:Po(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:G.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(Pn(p)){var m=typeof p.style=="string"?n.number[p.style]:On(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(Mn(p)){var h=p.children,g=p.value,v=s[g];if(!Ed(v))throw new Zi(g,"function",i);var k=Io(h,e,o,n,s,r),f=v(k.map(function(C){return C.value}));Array.isArray(f)||(f=[f]),a.push.apply(a,f.map(function(C){return{type:typeof C=="string"?G.literal:G.object,value:C}}))}if(An(p)){var _=p.options[d]||p.options.other;if(!_)throw new mr(p.value,d,Object.keys(p.options),i);a.push.apply(a,Io(_.value,e,o,n,s));continue}if(Ln(p)){var _=p.options["=".concat(d)];if(!_){if(!Intl.PluralRules)throw new Ro(`Intl.PluralRules is not available in this environment.
1
+ "use strict";var pd=Object.create;var Sn=Object.defineProperty;var ud=Object.getOwnPropertyDescriptor;var dd=Object.getOwnPropertyNames;var gd=Object.getPrototypeOf,md=Object.prototype.hasOwnProperty;var q=(t,e)=>{for(var o in e)Sn(t,o,{get:e[o],enumerable:!0})},Ui=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of dd(e))!md.call(t,s)&&s!==o&&Sn(t,s,{get:()=>e[s],enumerable:!(n=ud(e,s))||n.enumerable});return t};var w=(t,e,o)=>(o=t!=null?pd(gd(t)):{},Ui(e||!t||!t.__esModule?Sn(o,"default",{value:t,enumerable:!0}):o,t)),fd=t=>Ui(Sn({},"__esModule",{value:!0}),t);var bf={};q(bf,{Card:()=>F,Chip:()=>ta,ContentEditableInput:()=>Nt,DeepdeskAPI:()=>tt,DeepdeskSDK:()=>hn,HTTPClient:()=>Ie,InputMediator:()=>He,InputType:()=>rt,KeyboardHint:()=>Fn,Label:()=>Kn,Locale:()=>Ao,Section:()=>st,SectionList:()=>Un,Sources:()=>Ce,Suggestion:()=>N,SuggestionList:()=>Ae,TextAreaInput:()=>Be,ToggleButton:()=>Et,attachFile:()=>Yu,authenticateWithKey:()=>Zu,createFullRange:()=>bo,createOverlayContainer:()=>Jt,createRangeFromOffsets:()=>xt,escapeHTML:()=>ho,fetchPlatformConfig:()=>Ju,formatTextMarkup:()=>Qu,getRangeOffsets:()=>dn,getRangeText:()=>gn,isSupportedInputElement:()=>nr,updateContentEditable:()=>Xu,updateTextArea:()=>$u,useStyles:()=>y,waitForElementVisibilityChange:()=>sr});module.exports=fd(bf);var xn=w(require("classnames")),de=w(require("react"));var vn=w(require("react")),zi=w(require("classnames")),wo=vn.default.createContext({});function y(t,e){let{debug:o,...n}=(0,vn.useContext)(wo),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,zi.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var ji={root:"_root_vr71j_1"};var Ct=require("react/jsx-runtime"),_n=()=>(0,Ct.jsxs)("svg",{className:ji.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 lr={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 Tt=require("react/jsx-runtime"),bn=(0,de.createContext)(lr),hd=({title:t,src:e})=>{let o=(0,de.useContext)(bn),[n,s]=(0,de.useState)(!1);return(0,de.useEffect)(()=>{s(!1)},[e]),(0,Tt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,Tt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,Tt.jsx)(_n,{})})},yd=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,de.useContext)(bn);return(0,Tt.jsx)("div",{className:(0,xn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Sd=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,de.useContext)(bn);return de.default.createElement(t,{className:(0,xn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Cn=({children:t})=>{let e=y("Card",lr);return(0,Tt.jsx)("div",{className:(0,xn.default)(e.root),children:(0,Tt.jsx)(bn.Provider,{value:e,children:t})})};Cn.Image=hd;Cn.Content=yd;Cn.Title=Sd;var F=Cn;var qi={root:"_root_nkim0_1"};var Hn=require("react");var cr=function(t,e){return cr=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])},cr(t,e)};function Eo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");cr(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 Tn(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 wn;(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"})(wn||(wn={}));var En=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 kn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(kn||(kn={}));function pr(t){return t.type===be.literal}function Wi(t){return t.type===be.argument}function Pn(t){return t.type===be.number}function Rn(t){return t.type===be.date}function In(t){return t.type===be.time}function An(t){return t.type===be.select}function Ln(t){return t.type===be.plural}function Gi(t){return t.type===be.pound}function Mn(t){return t.type===be.tag}function On(t){return!!(t&&typeof t=="object"&&t.type===kn.number)}function ko(t){return!!(t&&typeof t=="object"&&t.type===kn.dateTime)}function ur(t){t.forEach(function(e){if(delete e.location,An(e)||Ln(e))for(var o in e.options)delete e.options[o].location,ur(e.options[o].value);else Pn(e)&&On(e.style)||(Rn(e)||In(e))&&ko(e.style)?delete e.style.location:Mn(e)&&ur(e.children)})}function $i(t,e){e===void 0&&(e={}),e=re({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new En(t,e).parse();if(o.err){var n=SyntaxError(wn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||ur(o.val),o.val}function Nn(t,e){var o=e&&e.cache?e.cache:Td,n=e&&e.serializer?e.serializer:Cd,s=e&&e.strategy?e.strategy:_d;return s(t,{cache:o,serializer:n})}function vd(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Xi(t,e,o,n){var s=vd(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Qi(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 dr(t,e,o,n,s){return o.bind(e,t,n,s)}function _d(t,e){var o=t.length===1?Xi:Qi;return dr(t,this,o,e.cache.create(),e.serializer)}function xd(t,e){return dr(t,this,Qi,e.cache.create(),e.serializer)}function bd(t,e){return dr(t,this,Xi,e.cache.create(),e.serializer)}var Cd=function(){return JSON.stringify(arguments)};function gr(){this.cache=Object.create(null)}gr.prototype.get=function(t){return this.cache[t]};gr.prototype.set=function(t,e){this.cache[t]=e};var Td={create:function(){return new gr}},Dn={variadic:xd,monadic:bd};var wt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(wt||(wt={}));var Po=function(t){Eo(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 mr=function(t){Eo(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('", "'),'"'),wt.INVALID_VALUE,r)||this}return e}(Po);var Zi=function(t){Eo(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),wt.INVALID_VALUE,s)||this}return e}(Po);var Ji=function(t){Eo(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,'"'),wt.MISSING_VALUE,n)||this}return e}(Po);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 Ed(t){return typeof t=="function"}function Ro(t,e,o,n,s,r,i){if(t.length===1&&pr(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(pr(p)){a.push({type:G.literal,value:p.value});continue}if(Gi(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 Ji(u,i);var d=s[u];if(Wi(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(Rn(p)){var m=typeof p.style=="string"?n.date[p.style]:ko(p.style)?p.style.parsedOptions:void 0;a.push({type:G.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(In(p)){var m=typeof p.style=="string"?n.time[p.style]:ko(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:G.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(Pn(p)){var m=typeof p.style=="string"?n.number[p.style]:On(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(Mn(p)){var f=p.children,g=p.value,S=s[g];if(!Ed(S))throw new Zi(g,"function",i);var T=Ro(f,e,o,n,s,r),h=S(T.map(function(C){return C.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(C){return{type:typeof C=="string"?G.literal:G.object,value:C}}))}if(An(p)){var _=p.options[d]||p.options.other;if(!_)throw new mr(p.value,d,Object.keys(p.options),i);a.push.apply(a,Ro(_.value,e,o,n,s));continue}if(Ln(p)){var _=p.options["=".concat(d)];if(!_){if(!Intl.PluralRules)throw new Po(`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 mr(p.value,d,Object.keys(p.options),i);a.push.apply(a,Io(_.value,e,o,n,s,d-(p.offset||0)));continue}}return Td(a)}function kd(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 Pd(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=kd(t[n],e[n]),o},re({},t)):t}function fr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Rd(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Nn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,wn([void 0],o,!1)))},{cache:fr(t.number),strategy:Dn.variadic}),getDateTimeFormat:Nn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,wn([void 0],o,!1)))},{cache:fr(t.dateTime),strategy:Dn.variadic}),getPluralRules:Nn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,wn([void 0],o,!1)))},{cache:fr(t.pluralRules),strategy:Dn.variadic})}}var Yi=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 Io(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=qi(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=Pd(t.formats,n),this.formatters=s&&s.formatters||Rd(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=$i,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 Ad="dummy",hr=(0,Hn.createContext)(null);function T(t){let e=(0,Hn.useContext)(hr);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 Yi(r).format(s):(e!==Ad&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var yr={};V(yr,{enUS:()=>Ld,nlNL:()=>Md});var Ld={experimental:[{type:0,value:"Experimental"}]},Md={experimental:[{type:0,value:"Experimenteel"}]};var Sr=require("react/jsx-runtime"),ea=({children:t})=>{let e=y("Chip",Vi);return(0,Sr.jsx)("span",{className:e.root,children:t})},Bn=()=>{let t=T(yr);return(0,Sr.jsx)(ea,{children:t("experimental")})},ta=ea;var na=w(require("classnames"));var oa={root:"_root_cq1yq_1"};var sa=require("react/jsx-runtime");var Od={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Nd=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",oa);return(0,sa.jsx)("span",{"data-key":Od[e],className:(0,na.default)(t,n.root),...o})},Fn=Nd;var ia=w(require("classnames"));var ra={root:"_root_4a08n_1"};var aa=require("react/jsx-runtime"),Dd=({className:t,children:e,...o})=>{let n=y("Label",ra);return(0,aa.jsx)("span",{...o,className:(0,ia.default)(t,n.root),children:e})},Kn=Dd;var la={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var Ft=require("react/jsx-runtime"),Hd=({title:t,children:e,type:o,...n})=>{let s=y("Section",la);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=Hd;var pa=w(require("classnames")),ua=w(require("react"));var ca={root:"_root_19wxp_1"};var da=require("react/jsx-runtime"),Bd=ua.default.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",ca);return(0,da.jsx)("div",{ref:o,className:(0,pa.default)(n.root,t),children:e})}),Un=Bd;var Ao=w(require("classnames")),me=w(require("react"));var vr={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)(vr),Fd=({fixed:t,children:e,...o})=>{let n=(0,me.useContext)(Kt);return(0,ge.jsx)("div",{...o,className:(0,Ao.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Kd=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,me.useContext)(Kt);return(0,ge.jsxs)("div",{className:(0,Ao.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})]})},Ud=({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})})},zd=({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,Ao.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},_r=({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",vr),l=(0,me.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,ge.jsx)(s,{...r,ref:i,className:(0,Ao.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,ge.jsx)(Kt.Provider,{value:a,children:n})})});Ut.Labels=_r;Ut.Actions=Fd;Ut.ActionButton=zd;Ut.DropdownButton=Kd;Ut.DropdownItem=Ud;var N=Ut;var ma=w(require("classnames"));var ga={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var fa=require("react/jsx-runtime"),jd=({withDivider:t,children:e})=>{let o=y("SuggestionList",ga);return(0,fa.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,ma.default)(o.root,{[o.isWithDivider]:t}),children:e})},Ae=jd;var ya=w(require("classnames"));var ha={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var zn=require("react/jsx-runtime"),Vd=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",ha);return(0,zn.jsx)("button",{type:"button",className:(0,ya.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,zn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,zn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Et=Vd;var Sa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,zt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var va=/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 Vc=require("react");var _a=require("@reduxjs/toolkit"),xa=require("react-redux");var Lo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Lo||{});var qd={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"},ba=(0,_a.createSlice)({name:"settings",initialState:qd,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Mo}=ba.actions,xr=t=>e=>e.settings[t],b=t=>(0,xa.useSelector)(xr(t)),Ca=ba.reducer;var uc=require("react"),co=require("react-redux");var Le=require("@reduxjs/toolkit"),Pa=require("diff"),Ra=require("react-redux");function wa(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function jt(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)=>jt(r,e[i],o-1)):wa(t)&&wa(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>jt(t[i],e[i],o-1)):!1}function Wd(t){return Math.max(...t.map(e=>e.length))}function Gd(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 Ta(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Wd(n);s++){let r=Gd(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 $d=2;function br(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Ta(t,$d);return o&&o.text!==e?o:t[0]}var we=require("@reduxjs/toolkit"),Ea={current:null,isSupported:null},A=(0,we.createAction)("resetConversation"),jn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Vn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},qn=t=>t.conversation.isSupported,Cr=(0,we.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Wn=(0,we.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Gn=(0,we.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),$n=(0,we.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Vn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),wr=(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})})}),Xn=(0,we.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Vn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Xd=[Wn.rejected,Gn.rejected,$n.rejected,Xn.rejected].map(t=>t==null?void 0:t.toString()),Qd=(0,we.createSlice)({name:"conversation",initialState:Ea,reducers:{},extraReducers:t=>{t.addCase(Cr.fulfilled,(e,o)=>{e.isSupported=o.payload}).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)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(wr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase($n.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Xn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(A,()=>Ea).addMatcher(e=>Xd.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),ka=Qd.reducer;var it={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 Zn(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 Jn=(0,Le.createAction)("input/replaceText"),Yn=(0,Le.createAction)("input/keyDown"),kt=(0,Le.createAction)("input/sendMessage"),es=(0,Le.createAction)("input/sendEditSuggestionMessage"),ts=(0,Le.createAction)("input/uiInputChange"),os=(0,Le.createAction)("input/applyImageSuggestion"),ie=(0,Le.createAction)("input/sendEvent");function Qn(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,Le.createSlice)({name:t,initialState:it,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,{...it,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=br(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(jt(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Qn(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},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,Pa.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=it.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Qn(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"&&Qn(e)},commitSuggestion(e){Qn(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=br(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(A,o=>{o.tabCompletionSuggestion=it.tabCompletionSuggestion,o.previousKeyDownEvent=it.previousKeyDownEvent,o.textSuggestions=it.textSuggestions,o.selectedSuggestionIndex=it.selectedSuggestionIndex,o.metrics=it.metrics})}}),Tr=Ia("input"),Vt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Zd=t=>t.input.selection,Aa=()=>(0,Ra.useSelector)(Zd),{userInput:La,changeSelection:Er,initialInput:Ma,mergeMetrics:Oa,nextTextSuggestionIndex:Na,offeredTextSuggestion:Da,previousTextSuggestionIndex:Ha,registerCut:Ba,registerKeyDown:Fa,registerPaste:Ka,reset:Ua,resetToCommitted:Oo,platformInput:za,setSelectedTextSuggestionIndex:ns,setTextSuggestions:at,stageSuggestion:Te,commitSuggestion:lt}=Tr.actions,Y=Ia("overlay");var qt=require("react");var ja={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var kr=require("react/jsx-runtime"),Jd=({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",ja);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,kr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,kr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},Wt=Jd;var Vr=require("react"),Ss=require("react-redux");var Pr={};V(Pr,{enUS:()=>Yd,nlNL:()=>eg});var Yd={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?"}]},eg={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 Va={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 No=require("react/jsx-runtime"),ss=()=>(0,No.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,No.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,No.jsx)("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});var Do=require("react/jsx-runtime"),qa=()=>(0,Do.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,Do.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,Do.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"),al=require("react-redux"),ll=require("interweave"),Dr=w(require("classnames"));var Rr={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 Ga=require("interweave"),$a=w(require("classnames"));var Gt=require("react");function Wa(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function rs(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]=Wa((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]=Wa(()=>{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_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var Ir=require("react/jsx-runtime"),tg=({inputElement:t,children:e})=>{let o=y("TabCompletion",fe),[n,s]=rs(t);return(0,Ir.jsx)("mark",{ref:n,className:(0,$a.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},$t=class extends Ga.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,Ir.jsx)(tg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Xt=require("react");function is(t){return t.contentEditable==="true"}function og(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 Xa(t){let{selectionStart:e,selectionEnd:o}=is(t)?og(t):t;return[e,o]}function as(t){let[,e]=(0,Xt.useState)(),o=(0,Xt.useRef)(null);return o.current=Xa(t),(0,Xt.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=Xa(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 ls(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 Qa=require("react");function Qt(t){(0,Qa.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 Za,Me=new Map,ng=["bottom","height","left","right","top","width"],sg=(t={},e={})=>ng.some(o=>t[o]!==e[o]),Ja=()=>{let t=[];Me.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Me.delete(o);return}let n=o.getBoundingClientRect();sg(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(o=>o(e.rect))}),Me.size!==0&&(Za=window.requestAnimationFrame(Ja))};function Ya(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&&Ja()},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(Za)}}}}var el,Oe=new Map,tl=()=>{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&&(el=window.requestAnimationFrame(tl))};function ol(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&&tl()},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(el)}}}}var Ar=["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 cs(t){return Math.round(t*1e6)}function nl(t){return t/1e6}function Mr(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=nl(cs(s)-cs(r)-cs(i)),c=nl(cs(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,Ar),Mr(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=ol(t,()=>{Lr(n,o,Ar),Mr(n,t,o),r(),setTimeout(r,0)}),a=Ya(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,Ar),Mr(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 Or={};V(Or,{enUS:()=>rg,nlNL:()=>ig});var rg={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"}]},ig={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 Ho=require("react/jsx-runtime"),sl=()=>(0,Ho.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Ho.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Ho.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 Nr=require("react/jsx-runtime"),rl=()=>(0,Nr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Nr.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 il=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(il||{}),He=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentHTML="";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}),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e}),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(il).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),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",o=>this.handlePaste(o)),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.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{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.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=()=>{var i,a;if(document.activeElement!==this.element)return;let r=this.getSelection();r.start===((i=this.lastKnownSelection)==null?void 0:i.start)&&r.end===((a=this.lastKnownSelection)==null?void 0:a.end)||(this.lastKnownSelection=r,this.emit("selection",r))};document.addEventListener("selectionchange",e),this.disposeHandlers.push(()=>{window.document&&document.removeEventListener("selectionchange",e)});let o=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var r;return(r=o==null?void 0:o.get)==null?void 0:r.call(this.element)},set:r=>{var i;(i=o==null?void 0:o.set)==null||i.call(this.element,r),this.triggerChange()}});let n=this.element.disabled,s=new MutationObserver(()=>{this.element.disabled!==n&&(n=this.element.disabled,this.emit(n?"disabled":"enabled"))});s.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>s.disconnect())}};var ee=require("react/jsx-runtime"),ag=({value:t,onUse:e,...o})=>{var p;let n=T(Or),s=(0,al.useDispatch)(),r=y("EditSuggestionTextInput",Rr),[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(Zn(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)(lg,{inputElement:l.current,value:t}),(0,ee.jsxs)("div",{className:(0,Dr.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)(sl,{}):(0,ee.jsx)(rl,{})]})]})},lg=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",Rr),n=(0,he.useRef)(null),s=as(t);return(0,he.useEffect)(()=>{ls(t,s)},[s,t]),(0,ee.jsx)(cg,{inputElement:t,children:(0,ee.jsxs)("div",{ref:n,className:(0,Dr.default)(o.root,o.agentText),children:[(0,ee.jsx)(ll.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new $t("placeholders")],inputElement:t,boundaryRef:n}),(0,ee.jsx)("br",{})]})})},cg=({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})},cl=ag;var oo=require("react");var pl=require("react"),ps=w(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:()=>pg,nlNL:()=>ug});var pg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},ug={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var ct=require("react/jsx-runtime"),dg=({src:t,title:e})=>{let o=y("CommandPalette",te),[n,s]=(0,pl.useState)("loading"),r=T(Rt);return(0,ct.jsxs)("div",{className:o.image,children:[(0,ct.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,ps.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,ct.jsx)("span",{className:(0,ps.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,ct.jsx)("span",{className:(0,ps.default)(o.imageSrc,o.imageSrcStatus),children:(0,ct.jsx)(_n,{})}),e&&(0,ct.jsx)("span",{className:o.imageTitle,children:e})]})},ul=dg;var dl=w(require("react")),gl=w(require("classnames"));var Bo=require("react/jsx-runtime");function Hr({children:t,heading:e,orientation:o}){let n=y("CommandPalette",te);return dl.default.Children.count(t)===0?null:(0,Bo.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,Bo.jsx)("h4",{className:n.listHeading,children:e}),(0,Bo.jsx)("div",{className:(0,gl.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var Fo=w(require("classnames"));var us=w(require("react")),hl=require("react/jsx-runtime"),ml=us.default.createContext(void 0);function pt(){let t=us.default.useContext(ml);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var fl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=us.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,hl.jsx)(ml.Provider,{value:i,children:t})};var ye=require("react/jsx-runtime");function Br({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}=pt(),m=y("CommandPalette",te);function h(g){n(g),t&&d(!1)}return(0,ye.jsxs)("div",{className:(0,Fo.default)(m.listItem,u===r&&m.listItemSelected),children:[(0,ye.jsxs)("button",{type:"button",className:(0,Fo.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,Fo.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,ye.jsx)("p",{className:(0,Fo.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate),children:a})]}),i&&(0,ye.jsx)(Bn,{})]}),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 ut=require("react/jsx-runtime");function Fr({children:t,title:e,id:o,onDismiss:n,isExperimental:s}){let r=T(Rt),i=y("CommandPalette",te),{page:a}=pt();return a!==o?null:(0,ut.jsxs)("div",{className:i.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,ut.jsxs)("div",{className:i.pageNav,children:[(0,ut.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:n,children:[(0,ut.jsx)(ss,{}),r("back")]}),e&&(0,ut.jsx)("h3",{className:i.pageTitle,children:e}),s&&(0,ut.jsx)(Bn,{})]}),t]})}var dt=require("react");var ds=()=>/Mac/i.test(navigator.platform);var ms=require("@reduxjs/toolkit");var gg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},P=gg;var Yt=require("@reduxjs/toolkit");function mg(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,[mg(o)]:O(t[o])}),{}):t}function Kr(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,[Kr(o)]:z(t[o])}),{}):t}var fg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Uo=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)||""}},Ko=(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))}),Ur=(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}),zr=(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}),yl=t=>t.info.agentInfo,Sl=(0,Yt.createSlice)({name:"info",initialState:fg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Ko.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Ko.rejected,e=>{e.fetchState="error"}).addCase(Ko.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(Ur.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(zr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(A,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:vl}=Sl.actions,_l=Sl.reducer;var gs={list:[],fetchState:"idle",isOpen:!1,page:"search"},xl=t=>t.search.isOpen,bl=t=>t.search.page,Cl=t=>t.search.list;function wl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var It=(0,ms.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:Uo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),Tl=(0,ms.createSlice)({name:"search",initialState:gs,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=gs.fetchState,t.list=gs.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(A,()=>gs)}}),{resetSearch:fs,setIsOpen:ae,setPage:X}=Tl.actions,El=Tl.reducer;var hg=/(https?:\/\/[^\s]+)/,hs=t=>t.split(" ").find(e=>hg.test(e));var jr=w(require("classnames"));var ys=require("react/jsx-runtime"),yg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",te);return(0,ys.jsxs)("button",{type:"button",...n,onClick:t,className:(0,jr.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,ys.jsx)("span",{className:(0,jr.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},eo=yg;var Fe=require("react/jsx-runtime"),Sg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",te),a=T(Rt),{selected:l,setSelected:c}=pt(),p=r[l],u=p&&typeof p.text=="string"&&hs(p.text),d=(0,dt.useRef)(null);function m(_){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),C=0,E=0;_==="down"?(x.forEach((ue,B)=>{B===l&&(C=B)}),E=C===x.length-1?0:C+1):_==="up"?(x.forEach((ue,B)=>{B===l&&(C=B)}),E=C?C-1:x.length-1):c(0);let D=x[E];D&&typeof E=="number"&&(c(E),D.scrollIntoView&&D.scrollIntoView({behavior:"smooth",block:E?"center":"end"}))}function h(){if(!d.current)return;let _=d.current.querySelectorAll(".command-palette-list-item"),x=0;_.forEach((E,D)=>{D===l&&(x=D)});let C=_[x];C&&C.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,dt.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,dt.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:[ds()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Fe.jsxs)(dt.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})]})]})]})},Pl=Sg;var Rl=require("react");var zo=require("react/jsx-runtime"),to=()=>(0,zo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,zo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,zo.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 vg({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 Il=(0,Rl.forwardRef)(vg);var jo=require("react/jsx-runtime");function At({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,jo.jsx)(Wt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:k,onClose:v,children:(0,jo.jsxs)(fl,{selected:m,setSelected:h,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&(0,jo.jsx)(Il,{ref:g,onChange:r,onChangeType:i,placeholder:t,value:d,selectedType:l,types:c,typePlaceholder:e}),p]})})}At.Page=Fr;At.List=Hr;At.Image=ul;At.ListItem=Br;At.ActionsBar=Pl;At.Button=eo;var L=At;var $=require("react/jsx-runtime"),_g=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",Va),l=(0,Ss.useDispatch)(),c=T(Pr),p=(0,Ss.useSelector)(h=>h.overlayInput.text);(0,Vr.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(es(h)),e(h)},m=h=>g=>{p!==i?window.confirm(c("warning"))&&h(g):h(g)};return(0,Vr.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)(_r,{labels:t.searchKeywords}),(0,$.jsx)(cl,{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)(ss,{})}),(0,$.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&m(s),children:(0,$.jsx)(qa,{})})]}),(0,$.jsxs)("div",{className:a.primaryButtons,children:[(0,$.jsx)(L.Button,{onClick:m(o),shortKeys:["esc"],children:c("dismiss")}),(0,$.jsx)(L.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},vs=_g;var Lt=require("@reduxjs/toolkit");var xg=["{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}"],bg=new RegExp(xg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Al(t,e){let o=t.split(bg),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 Ol={suggestions:[],fetchState:"idle",isInitialRequest:null},Ml={default:Ol},Nl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},Dl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},Hl=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,Bl=t=>e=>e.text.startsWith(t),_s=(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=Vt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Uo(n),t);if(t==="default"){let p=i?l.filter(Bl(a)):l;e.dispatch(at(p.slice(0,r)))}return l}),Vo=(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,{...Uo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Bl(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Al(p.text,t):p.text}))),l=Ll(l,r),e.dispatch(at(l)),l}),Fl=(0,Lt.createSlice)({name:"textSuggestions",initialState:Ml,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]||Ol;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Ke.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Ke.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Vo.pending,e=>{e.default.fetchState="loading"}).addCase(Vo.rejected,e=>{e.default.fetchState="error"}).addCase(Vo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(A,()=>Ml)}}),{setTextSuggestions:Kl,setSuggestionState:Ul}=Fl.actions,zl=Fl.reducer;var Vl=require("@reduxjs/toolkit");var jl={contentType:null,suggestion:null},ql=t=>t.activeSuggestion.suggestion,Wl=t=>t.activeSuggestion.contentType,Gl=(0,Vl.createSlice)({name:"activeSuggestion",initialState:jl,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(A,()=>jl)}}),{setActiveSuggestion:Ue,resetActiveSuggestion:qr}=Gl.actions,$l=Gl.reducer;var Wr={};V(Wr,{enUS:()=>Cg,nlNL:()=>wg});var Cg={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"}]},wg={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 Xl=require("@reduxjs/toolkit"),Tg={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Ql=({ui:t})=>t.overlayCollapsed;var Zl=(0,Xl.createSlice)({name:"ui",initialState:Tg,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:qo,setInputHasFocus:so,setOverlayCollapsed:ro,setOpenOverlayWhenTyping:Jl,setOverlayCollapsedUserOverwrite:Yl}=Zl.actions,ec=Zl.reducer;var Wo=w(require("react")),oc=require("react/jsx-runtime"),tc=Wo.default.createContext(null),Go=({broadcastEvents:t,children:e})=>{let o=Wo.default.useMemo(()=>t,[]);return(0,oc.jsx)(tc.Provider,{value:o,children:e})},Se=()=>{let t=(0,Wo.useContext)(tc);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var io=require("@reduxjs/toolkit");var Eg={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ze=t=>t.auth.isLoggedIn,nc=t=>t.auth.loginFetchState,sc=t=>t.auth.verifyFetchState,rc=t=>t.auth.showLoginOverlay,gt=(0,io.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),ic=(0,io.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),$o=(0,io.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),ac=(0,io.createSlice)({name:"auth",initialState:Eg,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(gt.pending,e=>{e.loginFetchState="loading"}),t.addCase(gt.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(gt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase($o.pending,e=>{e.verifyFetchState="loading"}),t.addCase($o.rejected,e=>{e.verifyFetchState="error"}),t.addCase($o.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:ao,setShowLoginOverlay:lc}=ac.actions,cc=ac.reducer;var Gr="SetActiveSuggestion",lo="ShowLoginOverlay",$r="UserLoggedIn",kg="UserLoggedOut",je="ApplySuggestion",Xr="ApplyImageSuggestion",Pg="ShowCommandPalette",Rg=t=>({[Gr]:e=>{t.dispatch(Ul(e.state)),t.dispatch(Ue({contentType:e.contentType,suggestion:e.suggestion}))},[Pg]:e=>{t.dispatch(ae(e.isOpen)),e.page&&t.dispatch(X(e.page))},[lo]:e=>{t.dispatch(lc(e))},[$r]:()=>{t.dispatch(gt())},[kg]:()=>{t.dispatch(gt())},[Xr]:e=>{t.dispatch(os({suggestion:e.suggestion}))},[je]:e=>{t.dispatch(Te({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(lt())}}),pc=Rg;var Qr=require("react/jsx-runtime"),Ig=()=>{var h;let[t,e]=(0,uc.useState)(!1),o=(0,co.useSelector)(ql),n=(0,co.useSelector)(Wl),s=(0,co.useSelector)(no),r=(0,co.useDispatch)(),i=Se(),a=T(Wr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(qr()),r(so(!0)),r(Y.actions.reset())},p=(g,v)=>{r(qr()),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,Qr.jsx)(Wt,{autoFocus:!0,isOpen:u!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Qr.jsx)(vs,{onTouched:e,onDismiss:c,onUse:g=>p(g,o),suggestion:o,onNext:m,onPrevious:d})})},dc=Ig;var Jr=require("react-redux");var xs=w(require("classnames")),ke=require("react"),bs=require("react-redux");var mc=w(require("classnames"));var gc={root:"_root_1ukx5_1"};var fc=require("react/jsx-runtime"),Ag=({className:t,value:e,...o})=>{let n=y("TextInput",gc);return(0,fc.jsx)("input",{className:(0,mc.default)(t,n.root),type:"text",value:e,...o})},Xo=Ag;var Zr={};V(Zr,{enUS:()=>Lg,nlNL:()=>Mg});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"}]},Mg={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 hc={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 Og=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Ng=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(Zr),i=y("LoginTokenDialog",hc),a=(0,bs.useSelector)(sc),l=(0,bs.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(ic({email:p})),m(1)},[o,p]),k=()=>{g(""),m(0)},f=(0,ke.useCallback)(async x=>{x.preventDefault();let C=Og(x.target.elements.token.value);if(!C){g(r("verifyCodeError",{login:_}));return}l($o({token:C}))},[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)(Xo,{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,xs.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)(Xo,{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,xs.default)(i.button),onClick:k,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,xs.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},yc=Ng;var vc=require("react/jsx-runtime"),Dg=()=>{let t=(0,Jr.useSelector)(rc),e=(0,Jr.useSelector)(yl),o=b("adminUrl"),n=Se(),s=()=>n.send(lo,!1),r=()=>{n.send(lo,!1),n.send($r)};return(0,vc.jsx)(yc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Sc=Dg;var zc=w(require("lodash.debounce")),ne=require("react"),We=require("react-redux");var Cs=require("@reduxjs/toolkit");var Hg={data:null,fetchState:"idle"},_c=t=>t.contentTypes.data,Qo=(0,Cs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Bg=(0,Cs.createSlice)({name:"contentTypes",initialState:Hg,reducers:{},extraReducers:t=>{t.addCase(Qo.pending,e=>{e.fetchState="loading"}).addCase(Qo.rejected,e=>{e.fetchState="error"}).addCase(Qo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),xc=Bg.reducer;function Zo(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 bc=require("react");function Cc(t,e){(0,bc.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 Jo=require("react"),Es=require("react-redux");var ws=require("@reduxjs/toolkit");var wc={data:null,fetchState:"idle"},Ts=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,ws.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)}),Fg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Kg=(0,ws.createSlice)({name:"entities",initialState:wc,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=Fg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(A,()=>wc)}}),Tc=Kg.reducer;var Yr={};V(Yr,{enUS:()=>Ug,nlNL:()=>zg});var Ug={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},zg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Ec={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Mt=require("react/jsx-runtime"),jg=({onCopy:t,onUse:e})=>{let o=(0,Jo.useRef)(null),n=y("EntitiesList",Ec),s=T(Yr),r=(0,Es.useSelector)(Ts),i=(0,Es.useDispatch)();return(0,Jo.useEffect)(()=>{i(Pe())},[]),(0,Jo.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)(L.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)(L.List,{children:r.map((a,l)=>(0,Mt.jsx)(L.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")})]})},kc=jg;var Re=require("react"),Yo=require("react-redux");var ks=require("@reduxjs/toolkit");var Pc={data:null,fetchState:"idle"},Rc=t=>t.summary.data,Ic=t=>t.summary.fetchState==="error",Ve=(0,ks.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}}),Vg=(0,ks.createSlice)({name:"summary",initialState:Pc,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(A,()=>Pc)}}),Ac=Vg.reducer;var ei={};V(ei,{enUS:()=>qg,nlNL:()=>Wg});var qg={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."}]},Wg={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"),Gg=({onCopy:t})=>{let e=(0,Re.useRef)(null),o=y("SummaryForm",Lc),[n,s]=(0,Re.useState)(""),r=T(ei),i=(0,Yo.useSelector)(Rc),a=(0,Yo.useSelector)(Ic),l=(0,Yo.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)(L.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Mc=Gg;var ti={};V(ti,{enUS:()=>$g,nlNL:()=>Xg});var $g={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},Xg={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"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var mt=w(require("react")),tn=require("react-redux");var oi={};V(oi,{enUS:()=>Qg,nlNL:()=>Zg});var Qg={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"}]},Zg={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 Oc={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 ni={data:[],fetchState:"idle"},Nc=t=>{var e;return(e=t.answer)==null?void 0:e.data},Dc=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.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),Jg=(0,uo.createSlice)({name:"answer",initialState:ni,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(A,()=>ni).addCase(go,()=>ni)}}),Hc=Jg.reducer;var en=require("react/jsx-runtime"),Bc=()=>(0,en.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,en.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,en.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"),Yg=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=mt.default.useState(""),{setSelected:i}=pt(),a=(0,mt.useRef)(null),l=y("EntitiesList",Oc),c=T(oi),p=(0,tn.useDispatch)(),u=(0,tn.useSelector)(Nc),d=(0,tn.useSelector)(Dc),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,mt.useEffect)(()=>{var g;o&&d==="idle"?p(po({question:o,promptInstruction:n})):(g=a.current)==null||g.focus()},[a,d]),(0,mt.useEffect)(()=>{d==="done"&&(p(ie({name:"knowledge assist question answered",data:{question:s||o,sources:u[u.length-1].answer.sources,answer:u[u.length-1].answer.answer,isFollowUpQuestion:u.length>1},options:{includeConversationData:!0}})),i(u.length-1),r(""))},[d,u]),(0,mt.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)(L.Button,{onClick:e,children:c("reset")})}),(0,oe.jsxs)(L.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)(L.List,{children:(0,oe.jsx)(L.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)(Bc,{})})]})]})]})},Fc=Yg;var Ps=require("@reduxjs/toolkit");var em={data:null,fetchState:"idle"},mo=t=>t.profile.data,Rs=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],on=(0,Ps.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)}),tm=(0,Ps.createSlice)({name:"profile",initialState:em,reducers:{},extraReducers:t=>{t.addCase(on.pending,e=>{e.fetchState="loading"}).addCase(on.rejected,e=>{e.fetchState="error"}).addCase(on.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Kc=tm.reducer;var j=require("react/jsx-runtime"),om=200,nm=5,sm=4,rm=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Uc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),im=()=>{let t=(0,We.useDispatch)(),e=Se(),o=T(ti),[n,s]=(0,ne.useState)(!1),[r,i]=(0,ne.useState)(""),a=(0,We.useSelector)(bl),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"),C=b("searchTriggerKey"),E=(0,We.useSelector)(_c),D=(0,We.useSelector)(Cl),ue=(0,We.useSelector)(xl),B=S=>ar(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&&Uc(o("entitiesClipboard"),r),experimental:!0},{label:o("summaryClipboard"),onClick:()=>t(X("summary")),shouldShow:f&&Uc(o("summaryClipboard"),r),experimental:!0},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(X("knowledgeAssist")),shouldShow:_,experimental:!0}].filter(S=>S.shouldShow),J=(E==null?void 0:E.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:B(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],rr=(0,ne.useCallback)((0,zc.default)((S,M)=>{t(It({query:S,type:M,tags:["search-overlay"]}))},om),[]),bt=rm([...J,...I]),ed=(0,ne.useCallback)((S,M)=>{if(!M)return;let nt=[...I,...J].find(({value:Bt})=>Bt===M);nt&&(t(X("edit")),p({...S,searchTerm:void 0}),d(nt.list))},[t,c,J]),ir=(0,ne.useCallback)((S,M)=>{switch(M.type){case"IMAGE":e.send(Xr,{suggestion:M});break;default:e.send(je,{text:S,suggestion:M})}t(ae(!1))},[t]),td=S=>{Zo(S.text),t(ie({name:"entity copied",data:{entity:S,type:"copy"}})),t(ae(!1))},od=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))},nd=S=>{Zo(S),t(ae(!1))},sd=S=>{e.send(je,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(ae(!1))},rd=c===null||u.indexOf(c)-1<0?void 0:()=>p(u[u.indexOf(c)-1]),id=c===null||u.indexOf(c)===u.length-1?void 0:()=>p(u[u.indexOf(c)+1]);function ar(S,M){return S.slice(0,m?10:M.toLowerCase()==="image"?sm:nm)}function Ki(S,M,nt){return M.reduce((Bt,yn)=>nt&&m===nt?yn.length+Bt:ar(yn,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?rr(r,m):t(fs())},[r,m]),(0,ne.useEffect)(()=>{a==="search"&&t(go())},[a]),(0,ne.useEffect)(()=>{g&&t(Qo())},[g]),Cc(C,()=>t(ae(!0))),!v||!l?null:(0,j.jsxs)(L,{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,...I],children:[(0,j.jsx)(L.Page,{id:"search",children:(0,j.jsxs)(L.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)=>ir(S,bt[M]),onSecondary:(S,M)=>{ed(bt[M-U.length],bt[M-U.length].type)},children:[U.length>0&&(0,j.jsx)(L.List,{heading:o("commands"),children:U.map((S,M)=>(0,j.jsx)(L.ListItem,{index:Ki(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:Bt,listOrientation:yn},ad)=>(0,j.jsx)(L.List,{heading:M,orientation:yn==="horizontal"?"horizontal":"vertical",children:ar(nt,S).map((xe,ld)=>(0,j.jsx)(L.ListItem,{index:Ki(U.length+ld,[...J,...I].slice(0,ad).map(({list:cd})=>cd),S),closeOnSelect:!1,lineClamp:Bt,onClick:()=>ir(xe.text,xe),description:S!=="IMAGE"?xe.title&&xe.text:void 0,children:S==="IMAGE"?(0,j.jsx)(L.Image,{title:xe.title||xe.text,src:xe.image}):xe.title||xe.text},`${xe.id}-${xe.text}`))},S))]})}),(0,j.jsx)(L.Page,{id:"edit",onDismiss:Ht(()=>{t(X("search")),p(null)}),children:c&&(0,j.jsx)(vs,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(X("search")),p(null),d([])},onNext:id,onPrevious:rd,onUse:S=>{t(X("search")),ir(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(ae(!1)),d([]),p(null)}})}),(0,j.jsx)(L.Page,{id:"entities",title:o("entitiesTitle"),isExperimental:!0,onDismiss:Ht(()=>{t(X("search"))}),children:(0,j.jsx)(kc,{onUse:sd,onCopy:td})}),(0,j.jsx)(L.Page,{id:"summary",title:o("summaryTitle"),isExperimental:!0,onDismiss:Ht(()=>{t(X("search"))}),children:(0,j.jsx)(Mc,{onCopy:nd})}),(0,j.jsx)(L.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),isExperimental:!0,onDismiss:Ht(()=>{t(go()),t(X("search"))}),children:(0,j.jsx)(Fc,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:od,onResetQuestion:()=>{t(go()),i("")}})})]})},jc=im;var fo=require("react/jsx-runtime"),am=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,fo.jsxs)(Vc.Fragment,{children:[t&&(0,fo.jsx)(jc,{}),(0,fo.jsx)(dc,{}),e&&(0,fo.jsx)(Sc,{})]})},qc=am;var Wc=require("react-redux");var nn=require("react/jsx-runtime"),lm=({children:t})=>{let o=b("locale").replace("-","");return(0,nn.jsx)(hr.Provider,{value:o,children:t})},cm=({store:t,customStyles:e={},children:o})=>(0,nn.jsx)(Wc.Provider,{store:t,children:(0,nn.jsx)(lm,{children:(0,nn.jsx)(Eo.Provider,{value:e,children:o})})}),sn=cm;var Ms=w(require("classnames")),So=require("react"),$e=require("react-redux");var Gc=require("react");function $c(t,e){let[o,n]=(0,Gc.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 Is(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 Qc=w(require("classnames")),Ge=require("react");var si={};V(si,{enUS:()=>pm,nlNL:()=>um});var pm={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Sign in"}]},{type:0,value:" to enable "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze for "},{type:8,value:"min",children:[{type:0,value:"10 minutes"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 hour"}]},{type:0,value:" or "},{type:8,value:"day",children:[{type:0,value:"1 day"}]}]},um={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 Xc={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var ft=require("react/jsx-runtime"),ri=(t,e,o)=>n=>(0,ft.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),dm=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=T(si),r=Se(),i=y("Login",Xc),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,ft.jsx)("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),u=(0,Ge.useCallback)(g=>(0,ft.jsx)("button",{type:"button",className:i.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:d,hour:m,day:h}=(0,Ge.useMemo)(()=>({min:ri(i,60*10,l),hour:ri(i,60*60,l),day:ri(i,60*60*12,l)}),[]);return(0,ft.jsxs)("div",{className:(0,Qc.default)(t,i.root),children:[s("loginPlease",{login:o?u:p,productName:a}),n&&(0,ft.jsxs)(Ge.Fragment,{children:[(0,ft.jsx)("br",{}),s("snooze",{min:d,hour:m,day:h})]})]})},As=dm;var Jc=require("react-redux");var Zc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var rn=require("react/jsx-runtime"),gm=({title:t})=>{let e=y("SearchTrigger",Zc),o=(0,Jc.useDispatch)();return(0,rn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ae(!0)),children:[(0,rn.jsx)(to,{}),(0,rn.jsx)("span",{className:e.text,children:t})]})},Yc=gm;var ap=require("react");var rp=require("interweave"),yo=require("react"),Ls=require("react-redux");var ep=require("react");function tp(t,e,o){(0,ep.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var mm=/[.*+?^${}()|[\]\\]/g,fm=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function hm(t){return t.replace(mm,"\\$&")}function ym(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function ii(t){return t.search(fm)}function op(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${hm(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function np(t){return t.replace(zt,'<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 Sm(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 ai(t,e,o={}){if(e){let n=ym(e.toLowerCase(),t.toLowerCase()),s=ho(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=ii(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Sa).length>3||e.length>30?Sm(e.trim(),n):0;return`${`${i>0?"\u2026":""}${ho(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var sp={badge:"_badge_8rv7b_1",formattedText:"_formattedText_8rv7b_5"};var li=require("react/jsx-runtime"),_m=["search","personal-collection-search","search-autocomplete"];function xm(t,e,o,n={}){let s="";return _m.includes(e)?s=op(ai(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ai(t,o,n),n.placeholders===!0&&(s=np(s)),s}var bm=()=>{},Cm=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=(0,Ls.useSelector)(Vt),r=(0,Ls.useDispatch)(),i=y("TextSuggestion",sp),a=(0,yo.useRef)(null);(0,yo.useEffect)(()=>{let c=setTimeout(()=>{r(Da({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),tp(a,"click",()=>{r(ns(t)),r(Te({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,yo.useMemo)(()=>xm(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,li.jsx)(N,{ref:a,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:bm,children:(0,li.jsx)(rp.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},ip=Cm;var ci=require("react/jsx-runtime"),wm=({suggestions:t,selectedIndex:e})=>(0,ci.jsx)(ap.Fragment,{children:t.slice().map((o,n)=>(0,ci.jsx)(ip,{index:n,selected:n===e,suggestion:o},`${o.text}-${o.source}`)).reverse()}),lp=wm;var pi={};V(pi,{enUS:()=>Tm,nlNL:()=>Em});var Tm={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"}]},Em={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 cp={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"),km=({inline:t=!1,textSuggestions:e,selectedIndex:o})=>{let n=y("SuggestionsOverlay",cp),s=T(pi),r=b("inlineSuggestions"),i=(0,$e.useSelector)(Is),a=Aa(),l=(0,$e.useDispatch)(),c=(0,So.useRef)(null),p=b("searchTriggerKey"),u=b("productName"),d=(0,$e.useSelector)(Ql),m=(0,$e.useSelector)(ze),h=(0,$e.useSelector)(qn),[g,v]=(0,So.useState)(null),k=b("showSearch"),f=b("showTextSuggestions"),_=b("adminUrl"),x=b("isEmbedded"),[C,E]=$c("dd-snooze-until-ms",0),D=d||C>Date.now(),ue=e.filter(U=>U.source!=="gpt").length,B=()=>{D&&E(0),l(Yl(!D))},I=U=>{let J=Date.now()+U*1e3;E(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,Ms.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)(As,{loginUrl:_,isEmbedded:x,onSnooze:I})})]}):!a||!i?null:(0,H.jsxs)("div",{ref:c,className:(0,Ms.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(ds()?"searchHintMac":"searchHintWindows",{searchTriggerKey:p.toUpperCase()})),onMouseLeave:()=>v(null),children:(0,H.jsx)(Yc,{title:s("search")})})}),(0,H.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,H.jsx)("div",{className:(0,Ms.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)(Ae,{children:(0,H.jsx)(lp,{suggestions:e,selectedIndex:o})})})]})},Pm=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Os=(0,$e.connect)(Pm)(km);var Gs=w(require("classnames")),Rp=require("interweave"),Je=require("react"),Ip=require("react-redux");var pp=require("react"),Rm=["div","span","mark","strong","b","i","u","em"];function ui(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(Rm.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,pp.cloneElement)(n,{children:ui(i,e,o+1)})]}return[...t,...e]}function Xe(t){return t.tagName.toLowerCase()==="textarea"}var up={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var yp=require("interweave"),Bs=require("react");var gi=w(require("classnames")),ve=require("react");var Ns=require("react"),Im=["bottom","height","left","right","top","width"],Am=(t={},e={})=>Im.some(o=>t[o]!==e[o]),Qe=new Map,dp,gp=()=>{let t=[],e=[];Qe.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Am(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))}),dp=window.requestAnimationFrame(gp)};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&&gp()},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(dp)}}}}function di(t){let[e,o]=(0,Ns.useState)(null);return(0,Ns.useLayoutEffect)(()=>{if(!t.current)return;let n=Lm(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var vo=require("react"),fp=require("react-dom");var mp={root:"_root_1jq08_1"};var hp=({children:t})=>{let[e,o]=(0,vo.useState)(null),n=(0,vo.useContext)(Eo);return(0,vo.useLayoutEffect)(()=>{let s=document.createElement("div");return Pt(s),s.classList.add(mp.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,fp.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 Ds=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 mi(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=mi,...a})=>{let l=di(e),c=di(o),p=(0,ve.useMemo)(()=>i(l,c,0),[l,c]);return(0,Ds.jsx)(hp,{children:(0,Ds.jsx)("div",{className:(0,gi.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,Ds.jsx)("div",{className:(0,gi.default)(t,Ne.root),children:r})})})};var ht=require("react/jsx-runtime"),Mm=({inputStyle:t,inputElement:e})=>{let o=y("TabCompletion",fe),n=_o(document.activeElement===e);return Qt(()=>n.close()),(0,Bs.useEffect)(()=>{let s=()=>n.open();return e.addEventListener("focus",s),()=>{e.removeEventListener("focus",s)}},[]),(0,ht.jsxs)(Bs.Fragment,{children:[(0,ht.jsx)("mark",{className:fe.caret,ref:n.triggerRef}),n.opened&&(0,ht.jsx)(xo,{className:o.popoverSuggestionsRoot,triggerRef:n.triggerRef,position:"above",align:"start",children:(0,ht.jsx)("div",{style:t,className:o.suggestionsOverlayInputStyles,children:(0,ht.jsx)(Os,{inline:!0})})})]})},Hs=class extends yp.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:ii(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,ht.jsx)(Mm,{inputStyle:o.inputStyle,inputElement:o.inputElement},"caret")}asTag(){return"mark"}};var xp=w(require("classnames")),bp=require("interweave"),js=require("react");function Sp(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Fs(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function vp(t){return t!=null}var _p=w(require("classnames")),Ks=require("react");var fi=require("react/jsx-runtime"),Us=(0,Ks.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,Ks.useRef)(null),r=y("TabCompletion",fe);return(0,fi.jsx)("div",{ref:Fs([s,n]),className:(0,_p.default)(t,r.popoverContentContainer),...o,children:(0,fi.jsx)("div",{className:r.popoverContent,children:e})})});var yt=require("react/jsx-runtime"),Om=t=>e=>{let o=mi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Nm=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",fe),i=_o(),a=(0,js.useMemo)(()=>Om(t.getBoundingClientRect()),[t]),[l,c]=rs(t);return(0,js.useEffect)(()=>{c?i.open():i.close()},[c]),(0,yt.jsxs)("span",{children:[(0,yt.jsx)("mark",{ref:Fs([l,i.triggerRef]),className:(0,xp.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,yt.jsx)(xo,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,yt.jsx)(Us,{style:o,children:(0,yt.jsx)("div",{className:r.hintText,children:s})})})]})},zs=class extends bp.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${Sp(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(vp);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,yt.jsx)(Nm,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var qs=w(require("classnames")),kp=require("interweave"),Z=require("react"),Pp=require("react-redux");var hi=require("react/jsx-runtime"),Cp=()=>(0,hi.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,hi.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 St=require("react"),an=require("react-redux"),Tp=w(require("lodash.debounce"));var wp={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Vs(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 yi(t){return t.replace("https://www.","").replace("https://","")}var _e=require("react/jsx-runtime"),Dm=3,Hm=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Bm=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Dm})=>{let r=y("LinkSearch",wp),[i,a]=(0,St.useState)(""),l=(0,an.useDispatch)(),c=(0,an.useSelector)(Nl("url")),p=(0,an.useSelector)(wl("URL",Hm)),[u,d]=(0,St.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 C;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(((C=p[u])==null?void 0:C.text)||i)},k=(0,St.useCallback)((0,Tp.default)(f=>{l(It({query:f,type:"URL",tags:["link-search"]}))},300),[]);return(0,St.useEffect)(()=>{i&&k(i)},[i]),(0,St.useEffect)(()=>()=>{l(fs())},[]),(0,_e.jsxs)("div",{className:r.root,children:[(0,_e.jsx)(Ae,{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:Vs(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||yi(f.text)}),f.title&&yi(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)(Xo,{value:i,onChange:h,autoFocus:!0,placeholder:o,onKeyUp:v})]})},Ep=Bm;var Si={};V(Si,{enUS:()=>Fm,nlNL:()=>Km});var Fm={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Km={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"),Um=(0,Z.forwardRef)((t,e)=>{let o=y("TabCompletion",fe);return(0,Q.jsx)("mark",{ref:e,className:(0,qs.default)(o.matchSelection)},"selection-start")}),zm=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(Si),i=y("TabCompletion",fe),a=(0,Z.useRef)(null),l=(0,Z.useRef)(null),[c,p]=(0,Z.useState)(null),u=(0,Pp.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(Jn({text:`[${v}](${k})`,replace:"selection"}))},[]);return(0,Q.jsxs)("span",{children:[(0,Q.jsx)("mark",{ref:a,className:(0,qs.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)(Us,{style:o,ref:l,children:[(0,Q.jsx)("div",{className:(0,qs.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)(Cp,{}),(0,Q.jsx)("span",{children:"\xA0"}),(0,Q.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,Q.jsx)(Ep,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{p(null),d.close()}})]})})]},"selection-end")},Ws=class extends kp.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)(Um,{ref:this.startRef}):(0,Q.jsx)(zm,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Ze=require("react/jsx-runtime"),jm=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",up),p=b("insertLink"),u=b("showMidSentenceSuggestions"),d=b("inlineSuggestions"),m=as(a),h=(0,Je.useRef)(null);(0,Je.useEffect)(()=>{Xe(a)&&m&&ls(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",{"data-testid":"tab-completion",className:(0,Gs.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&_.push((0,Ze.jsx)("span",{className:(0,Gs.default)(c.hint,c.resetIndent),children:(0,Ze.jsx)(Fn,{keyCode:"tab"},"tabHint")})),ui(f,_)},[s,o,n]),v=(0,Je.useMemo)(()=>{let f=[];return d&&f.push(new Hs("inline")),p&&f.push(new Ws("selection")),f.push(new $t("placeholders")),r&&f.push(new zs("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)(Rp.Interweave,{tagName:"span",containerTagName:"div",className:(0,Gs.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},Vm=({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}},Ap=(0,Ip.connect)(Vm)(jm);var bu=w(require("classnames")),Cu=require("react"),W=require("react-redux");var vt=require("@reduxjs/toolkit");var Lp={list:[],fetchState:"idle",isInitialRequest:null},Op=t=>t.autoflows.list||[],Mp=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ye=(0,vt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),vi=(0,vt.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))}),_i=(0,vt.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))}),qm=(0,vt.createSlice)({name:"autoflows",initialState:Lp,reducers:{},extraReducers:t=>{t.addCase(vi.pending,(e,o)=>{let n=Mp(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(_i.pending,(e,o)=>{let n=Mp(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(A,()=>Lp)}}),Np=(0,vt.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))})}),Dp=(0,vt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Hp=qm.reducer;var _t=require("@reduxjs/toolkit");var Bp={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Fp=t=>t.customMessages.list,Kp=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Up=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),zp=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),ln=(0,_t.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),$s=(0,_t.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)}),Xs=(0,_t.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)}),jp=(0,_t.createSlice)({name:"customMessages",initialState:Bp,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(ln.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(ln.rejected,e=>{e.fetchState="error"}).addCase(ln.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase($s.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase($s.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Xs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Xs.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(A,()=>Bp)}}),Vp=(0,_t.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(jp.actions.onCustomMessage(r))})}),qp=(0,_t.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Wp=jp.reducer;var cn=require("@reduxjs/toolkit"),Wm={jwt:null,accountUrl:null,interval:null},Gp=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},xi=(0,cn.createAsyncThunk)("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),bi=(0,cn.createAsyncThunk)("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(xi()),setInterval(()=>n(xi()),o)}),$p=(0,cn.createSlice)({name:"exchangeToken",initialState:Wm,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(xi.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(bi.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:Xp}=$p.actions,Qp=$p.reducer;function Zp(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var iu=require("react"),au=require("react-redux");var nu=w(require("classnames")),su=require("react");var Yp=w(require("classnames"));var Jp={root:"_root_838fd_1"};var tu=require("react/jsx-runtime"),Gm=({className:t,children:e})=>{let o=y("Unicode",Jp);return(0,tu.jsx)("span",{className:(0,Yp.default)(t,o.root),children:e})},eu=Gm;var ou={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 Ci={};V(Ci,{enUS:()=>$m,nlNL:()=>Xm});var $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"}]},Xm={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"),Zm=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",ou),a=T(Ci),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,le.jsxs)(N,{className:(0,nu.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)(su.Fragment,{children:[(0,le.jsx)(eu,{children:c})," ",(0,le.jsx)("span",{children:a(l)})]})})})]})},ru=Zm;var wi=require("react/jsx-runtime"),Jm=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Ym=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,wi.jsx)(iu.Fragment,{children:t.map(s=>(0,wi.jsx)(ru,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Jm(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),ef=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},tf={onStartAutoflow:vi,onStopAutoflow:_i},lu=(0,au.connect)(ef,tf)(Ym);var Qs=require("react"),pu=require("react-redux"),ki=w(require("classnames"));var Ti=require("react/jsx-runtime"),Ei=()=>(0,Ti.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,Ti.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 cu={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"),of=({entities:t})=>{let e=y("EntitiesWidgetList",cu),[o,n]=(0,Qs.useState)(void 0),s=(0,pu.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Zo(a.text),s(ie({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Qs.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,ki.default)(e.icon),children:(0,De.jsx)(Ei,{})}),(0,De.jsx)("span",{className:(0,ki.default)(e.icon,o===l&&e.iconClicked),children:(0,De.jsx)(Ei,{})})]})]},a.text))})},uu=of;var du=w(require("classnames")),Pi=require("react"),Ot=require("react-redux");var pn={};V(pn,{enUS:()=>nf,nlNL:()=>sf});var nf={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"}]},sf={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"),rf=({suggestion:t})=>{let e=T(pn),o=(0,Ot.useDispatch)(),n=(0,Ot.useSelector)(Kp(t.text)),s=(0,Ot.useSelector)(Up(t.text)),r=(0,Ot.useSelector)(zp(t.text)),i=(0,Ot.useSelector)(jn),{replyOptions:a}=t,l=(0,Pi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o($s({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Pi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let u=parseInt(p.target.dataset.index,10),d=a[u];o(Xs({platformSessionId:i,reply:d,suggestion:t}))},[t,n,o,i]);return(0,se.jsxs)(N,{onClick:l,className:(0,du.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)(Kn,{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")})]})]})},gu=rf;var Ri=require("react/jsx-runtime"),mu=()=>(0,Ri.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Ri.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 yu=require("react-redux");var fu=require("react");var ce=require("react/jsx-runtime"),af=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var d;let s=t.text||t.url||t.message,r=hs(s),i=T(pn),a=b("showImages"),l=b("fallbackImage"),c=m=>{m.preventDefault(),m.stopPropagation(),n(s)},p=m=>{m.preventDefault(),m.stopPropagation(),o(t)},u=(0,fu.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:Vs(t,"small",l||void 0),title:t.title}),(0,ce.jsxs)(F.Content,{children:[t.title&&(0,ce.jsx)(F.Title,{"data-testid":"widget-suggestion-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")})]})]})},hu=af;var un=require("react/jsx-runtime"),lf=({contentType:t,lines:e,suggestions:o})=>{let n=Se(),s=(0,yu.useSelector)(no),r=a=>{n.send(Gr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(je,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,un.jsx)(un.Fragment,{children:o.map(a=>(0,un.jsx)(hu,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Su=lf;var Ii={};V(Ii,{enUS:()=>cf,nlNL:()=>pf});var cf={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"}]},pf={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 vu={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 Ai=require("react/jsx-runtime"),_u=()=>(0,Ai.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ai.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"),xu=()=>(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"),Zs=(t,e)=>{let o=(0,W.useSelector)(ze);(0,Cu.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},uf=()=>{let t=T(Ii),e=(0,W.useDispatch)(),o=b("isEmbedded"),n=y("Widget",vu),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)(Rs),d=(0,W.useSelector)(Op),m=(0,W.useSelector)(Ts),h=(0,W.useSelector)(Fp),g=(0,W.useSelector)(Vn),v=(0,W.useSelector)(qn),k=(0,W.useSelector)(ze),f=(0,W.useSelector)(jn),_=(0,W.useSelector)(Zp),x=(0,W.useSelector)(no),C=Se(),E=(0,W.useSelector)(Hl),D=(0,W.useSelector)(Gp("/admin/personal-collection")),ue=b("adminUrl");if(Zs(()=>(e(ln(f)),e(Vp(f)),()=>{e(qp(f))}),[e,v,r,f]),Zs(()=>(e(Ye(f)),e(Np(f)),()=>{e(Dp(f))}),[e,v,s,f]),Zs(()=>{u.forEach(({type:I})=>{e(I==="entities"?Pe():Ke(I))})},[e,v,g,p]),Zs(()=>(e(bi()),()=>{e(Xp())}),[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)(As,{isEmbedded:o,loginUrl:ue})})},"login");if(!p||!f||k===null||E||_)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,bu.default)(n.root),"data-testid":"widget",children:(0,R.jsxs)(Un,{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,"data-testid":"shortcut-search",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(to,{}),t("linkSearch")]}),a&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-summary",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(xu,{}),t("linkSummary")]}),l&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(_u,{}),t("linkKnowledgeSearch")]}),D&&(0,R.jsxs)("a",{className:n.shortcut,target:"_blank",href:D,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[(0,R.jsx)(mu,{}),t("linkPersonalcollection")]})]})}),r&&h.length>0&&(0,R.jsx)(st,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(Ae,{withDivider:!0,children:h.map(I=>(0,R.jsx)(gu,{suggestion:I},I.text))})}),s&&d.length>0&&(0,R.jsx)(st,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(Ae,{withDivider:!0,children:(0,R.jsx)(lu,{})})}),u.map(({type:I,title:U,amount:J,lines:rr})=>{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)(uu,{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)(Ae,{withDivider:!0,children:(0,R.jsx)(Su,{lines:rr,contentType:I,suggestions:x[I].suggestions.slice(0,J)||[]})})},I)}})]})})},wu=uf;function bo(t){let e=new Range;return e.selectNodeContents(t),e}function Tu(t,e,o){try{return xt(t,e,o),!0}catch{return!1}}var dn=/[\u200B-\u200D\uFEFF]/g;function xt(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(dn,""),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 Co(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(dn,"").length),d&&(a=l+m.substring(0,r).replace(dn,"").length),l+=m.replace(dn,"").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 gn(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(dn,"");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
- `);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;lastKnownSelection=null;getText(){let e=new Range;return e.selectNodeContents(this.element),gn(this.element,e)}getHTML(){return this.element.innerHTML||""}getRange(){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:o}getSelection(){let e=this.getRange();if(e)return Co(this.element,e);let o=this.lastKnownSelection;if(o&&Tu(this.element,o.start,o.end))return o;let n=bo(this.element);return n.collapse(!1),Co(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return gn(this.element,xt(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();let e=()=>{var i,a;if(document.activeElement!==this.element)return;let s=this.getRange();if(!s)return;let r=Co(this.element,s);r.start===((i=this.lastKnownSelection)==null?void 0:i.start)&&r.end===((a=this.lastKnownSelection)==null?void 0:a.end)||(this.lastKnownSelection=r,this.emit("selection",r))};document.addEventListener("selectionchange",e),this.disposeHandlers.push(()=>{window.document&&document.removeEventListener("selectionchange",e)}),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let o=this.element.isContentEditable,n=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>n.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var Mi=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()}},Oi=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()}},Ni=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 Oi(e,this.deepdeskUrl,{debug:!0}):new Mi(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)}},Eu=Ni;var wo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Di=t=>new Promise(e=>{setTimeout(e,t)});var To=class extends wo{name="ClientError"},Hi=class extends wo{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 Di(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 Di(p),_();throw x}));_().then(x=>x.json().catch(()=>null).then(C=>{x.status>=500?s(new Hi("Server Error",C)):x.status===401?s(new To("Unauthorized",C)):x.status===403?s(new To("Forbidden",C)):x.status===404?s(new To("Not Found",C)):x.status>=400&&s(new To("Bad Request",C)),delete this.latestRequestByUrl[i],n(C)})).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 df;(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||={})})(df||={});function Js(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 Js(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 Js(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 Js(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=>Js(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 knowledgeAssist(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(va);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 mn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Kr(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 gf;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(gf||={});var fn=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 mn(`${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 or=require("@reduxjs/toolkit");var Pu=require("@reduxjs/toolkit");var ku={startTime:null,stopTime:null},Ru=(0,Pu.createSlice)({name:"handlingTime",initialState:ku,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(A,()=>ku)}}),{handlingTimeStart:Iu,handlingTimeStop:Ys,handlingTimeReset:Au}=Ru.actions,Lu=Ru.reducer;var Mu=(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 tr=require("@reduxjs/toolkit");var er={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Dt=(0,tr.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 er.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),mf=(0,tr.createSlice)({name:"styleSuggestions",initialState:er,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",jt(e.list,o.payload)||(e.list=o.payload)}).addCase(kt,e=>{e.list=er.list}).addCase(A,()=>er)}}),Ou=mf.reducer;var Nu=(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 ff(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Du=(t={})=>{let e={getTextSuggestions:Ke,getAutocompleteSuggestions:Vo,debounce:200,check:Is,...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===_s.toString();if(!u||!c&&!p)return a;let{input:{userCommitted:m}}=l;return ff(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 Hu=Dt.fulfilled.toString();function hf(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 Bu=t=>e=>o=>n=>{var c;if(n.type!==Hu){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=hf(s,i);n.type===Hu&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var yf=(0,or.combineReducers)({activeSuggestion:$l,answer:Hc,auth:cc,autoflows:Hp,conversation:ka,contentTypes:xc,customMessages:Wp,exchangeToken:Qp,entities:Tc,handlingTime:Lu,info:_l,input:Tr.reducer,overlayInput:Y.reducer,settings:Ca,profile:Kc,search:El,summary:Ac,styleSuggestions:Ou,ui:ec,textSuggestions:zl});function Fu(t){return(0,or.configureStore)({reducer:yf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Mu(),Du({debounce:200}),Nu({debounce:500}),Bu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Sf=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},vf=t=>e=>o=>n=>{var a;let s=e.getState(),r=xr("inlineSuggestions")(s);switch(n.type){case Ue.toString():{let l=Dl(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:Sf(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Jn.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 Oo.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case os.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 Yn.toString():t.handleKeyDown(n.payload);break;case kt.toString():t.logSendMessage(n.payload);break;case es.toString():t.logSendEditSuggestionMessage(n.payload);break;case ts.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case kt.toString():t.handleAfterSendMessage(n.payload);break;case qo.toString():t.onUpdateShowTabHint(n.payload);break;case Ys.toString():t.logHandlingTime();break;case Te.toString():{r&&(e.dispatch(at([])),e.dispatch(lt()));break}default:break}return i},Ku=vf;function Bi(t){return t.toISOString().replace("T"," ").replace("Z","")}function Uu(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:Bi(o),timeStop:Bi(n)}}function Fi(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),C=s/x,E=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+E,lenTextTotal:v,lenTextAssisted:f,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:x,charsPerSecond:C,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 zu(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?zu(n,e):null}function ju(t,e){return zu(t,e)}function Vu(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function nr(t){return t instanceof HTMLElement&&(Xe(t)||is(t))}var qu=(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 _f(t){return t.offsetParent!==null}function Wu(t){if(!_f(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 sr(t,e,o=100){let n=Wu(t);e({isVisible:n});let s=setInterval(()=>{let r=Wu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var pe=require("react/jsx-runtime"),Gu=qu("showTabHint",!0),hn=class t{static version="10.1.13";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:[Ku({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=>Gu.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new fn(o)}),this.store=Fu(p),this.broadcastEvents=new Eu({debug:!0,deepdeskUrl:c,eventMap:pc(this.store),createCustomChannel:l}),this.store.dispatch(Mo),this.store.dispatch(qo(Gu.value())),this.store.dispatch(Mo({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(gt()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ze(n)&&nc(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(Cr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Wn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Gn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(wr(e))).payload}async postMessages(e){return(await this.store.dispatch(Xn(e))).payload}async updateConversation(e){return(await this.store.dispatch($n(e))).payload}resetConversation(){this.store.dispatch(A()),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(Mo(e))}setVisitorInfo(e){this.store.dispatch(vl(e))}async setAgentInfo(e){await this.store.dispatch(Ko(e))}async setAgentSettings(e){await this.store.dispatch(Ur(e))}async getAgentSettings(){return(await this.store.dispatch(zr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(_s()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(ts(e))}notifyKeyDown(e){this.store.dispatch(Yn(e))}notifyPaste(e,o){this.store.dispatch(Ka({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ba(e))}notifyExternalSuggestion(e){this.store.dispatch(Te(e)),this.store.dispatch(lt())}notifyEditSuggestion(e){this.store.dispatch(Kl(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(at([])))}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(Fa(Zn(e))),!(e.key!=="Tab"&&!this.settings.showTextSuggestions))switch(e.key){case"Up":case"ArrowUp":if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Na()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return;case"Down":case"ArrowDown":{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Ha());let{selectedSuggestionIndex:c}=this.state.input;c===-1?this.store.dispatch(Oo()):i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return}case"Esc":case"Escape":{l?(this.store.dispatch(ns(-1)),this.store.dispatch(Oo()),e.preventDefault()):o||(this.store.dispatch(ro({collapse:!0})),this.store.dispatch(Jl(!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(qo(!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(lt())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ua()),this.store.dispatch(at([]))}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(Ys()))}logSendMessage(e){let o=Fi("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=Fi("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Oa(this.state.overlayInput.metrics))}logHandlingTime(){let e=Uu(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Au())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(lt()),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(!nr(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&&ju(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)(sn,{store:this.store,customStyles:n,children:(0,pe.jsx)(Go,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Ap,{inputElement:e})})}),_),(0,ot.render)((0,pe.jsx)(sn,{store:this.store,customStyles:n,children:(0,pe.jsx)(Go,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Os,{})})}),x),(0,ot.render)((0,pe.jsx)(sn,{store:this.store,customStyles:n,children:(0,pe.jsx)(Go,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(qc,{})})}),this.createContainer("deepdesk-overlays")),Pt(e),this.inputMediator=h||(Xe(e)?new Be(e):new Nt(e)),this.inputMediator.on("change",({plainText:E})=>{this.notifyInputChanged(E)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(za({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",E=>{this.notifyKeyDown(E)}),this.inputMediator.on("paste",({pastedText:E,selectionText:D})=>{this.notifyPaste(E,D)}),this.inputMediator.on("cut",({selectionText:E})=>{this.notifyCut(E)});let C;this.inputMediator.on("selection",E=>{clearTimeout(C),E===null?C=setTimeout(()=>{E!==null&&this.store.dispatch(Er(E))},500):this.store.dispatch(Er(E))}),this.inputMediator.on("disabled",()=>{var E;(E=this.inputMediator)==null||E.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(so(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(so(!0))),this.store.dispatch(Ma({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var E;this.refresh(),this.broadcastEvents.setSessionId((E=this.state.conversation.current)==null?void 0:E.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)(sn,{store:this.store,customStyles:n,children:(0,pe.jsx)(Go,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(wu,{})})}),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=sr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Vu(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(on());let e=mo(this.state);e&&this.store.dispatch(Mo({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeAssistForAgents,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=Rs(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 $u(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 Xu(t,e,o={}){let n=o.replace?xt(t,o.replace.start,o.replace.end):bo(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),o.insertBRs!==!1?e.split(`
3
+ `,wt.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 mr(p.value,d,Object.keys(p.options),i);a.push.apply(a,Ro(_.value,e,o,n,s,d-(p.offset||0)));continue}}return wd(a)}function kd(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 Pd(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=kd(t[n],e[n]),o},re({},t)):t}function fr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Rd(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Nn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Tn([void 0],o,!1)))},{cache:fr(t.number),strategy:Dn.variadic}),getDateTimeFormat:Nn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Tn([void 0],o,!1)))},{cache:fr(t.dateTime),strategy:Dn.variadic}),getPluralRules:Nn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Tn([void 0],o,!1)))},{cache:fr(t.pluralRules),strategy:Dn.variadic})}}var Yi=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 Ro(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=Pd(t.formats,n),this.formatters=s&&s.formatters||Rd(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=$i,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 Ad="dummy",hr=(0,Hn.createContext)(null);function E(t){let e=(0,Hn.useContext)(hr);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 Yi(r).format(s):(e!==Ad&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var yr={};q(yr,{enUS:()=>Ld,nlNL:()=>Md});var Ld={experimental:[{type:0,value:"Experimental"}]},Md={experimental:[{type:0,value:"Experimenteel"}]};var Sr=require("react/jsx-runtime"),ea=({children:t})=>{let e=y("Chip",qi);return(0,Sr.jsx)("span",{className:e.root,children:t})},Bn=()=>{let t=E(yr);return(0,Sr.jsx)(ea,{children:t("experimental")})},ta=ea;var na=w(require("classnames"));var oa={root:"_root_cq1yq_1"};var sa=require("react/jsx-runtime");var Od={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Nd=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",oa);return(0,sa.jsx)("span",{"data-key":Od[e],className:(0,na.default)(t,n.root),...o})},Fn=Nd;var ia=w(require("classnames"));var ra={root:"_root_4a08n_1"};var aa=require("react/jsx-runtime"),Dd=({className:t,children:e,...o})=>{let n=y("Label",ra);return(0,aa.jsx)("span",{...o,className:(0,ia.default)(t,n.root),children:e})},Kn=Dd;var la={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var Ft=require("react/jsx-runtime"),Hd=({title:t,children:e,type:o,...n})=>{let s=y("Section",la);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=Hd;var pa=w(require("classnames")),ua=w(require("react"));var ca={root:"_root_19wxp_1"};var da=require("react/jsx-runtime"),Bd=ua.default.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",ca);return(0,da.jsx)("div",{ref:o,className:(0,pa.default)(n.root,t),children:e})}),Un=Bd;var Io=w(require("classnames")),me=w(require("react"));var vr={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)(vr),Fd=({fixed:t,children:e,...o})=>{let n=(0,me.useContext)(Kt);return(0,ge.jsx)("div",{...o,className:(0,Io.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Kd=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,me.useContext)(Kt);return(0,ge.jsxs)("div",{className:(0,Io.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})]})},Ud=({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})})},zd=({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,Io.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},_r=({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",vr),l=(0,me.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,ge.jsx)(s,{...r,ref:i,className:(0,Io.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,ge.jsx)(Kt.Provider,{value:a,children:n})})});Ut.Labels=_r;Ut.Actions=Fd;Ut.ActionButton=zd;Ut.DropdownButton=Kd;Ut.DropdownItem=Ud;var N=Ut;var ma=w(require("classnames"));var ga={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var fa=require("react/jsx-runtime"),jd=({withDivider:t,children:e})=>{let o=y("SuggestionList",ga);return(0,fa.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,ma.default)(o.root,{[o.isWithDivider]:t}),children:e})},Ae=jd;var ya=w(require("classnames"));var ha={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var zn=require("react/jsx-runtime"),qd=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",ha);return(0,zn.jsx)("button",{type:"button",className:(0,ya.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,zn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,zn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Et=qd;var Sa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,zt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var va=/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 qc=require("react");var _a=require("@reduxjs/toolkit"),xa=require("react-redux");var Ao=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Ao||{});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"},ba=(0,_a.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}=ba.actions,xr=t=>e=>e.settings[t],b=t=>(0,xa.useSelector)(xr(t)),Ca=ba.reducer;var uc=require("react"),co=require("react-redux");var Le=require("@reduxjs/toolkit"),Pa=require("diff"),Ra=require("react-redux");function Ta(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function jt(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)=>jt(r,e[i],o-1)):Ta(t)&&Ta(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>jt(t[i],e[i],o-1)):!1}function Wd(t){return Math.max(...t.map(e=>e.length))}function Gd(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<Wd(n);s++){let r=Gd(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 $d=2;function br(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=wa(t,$d);return o&&o.text!==e?o:t[0]}var Te=require("@reduxjs/toolkit"),Ea={current:null,isSupported:null},A=(0,Te.createAction)("resetConversation"),jn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},qn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Vn=t=>t.conversation.isSupported,Cr=(0,Te.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Wn=(0,Te.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Gn=(0,Te.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),$n=(0,Te.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=qn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Tr=(0,Te.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})})}),Xn=(0,Te.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=qn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Xd=[Wn.rejected,Gn.rejected,$n.rejected,Xn.rejected].map(t=>t==null?void 0:t.toString()),Qd=(0,Te.createSlice)({name:"conversation",initialState:Ea,reducers:{},extraReducers:t=>{t.addCase(Cr.fulfilled,(e,o)=>{e.isSupported=o.payload}).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)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Tr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase($n.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Xn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(A,()=>Ea).addMatcher(e=>Xd.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),ka=Qd.reducer;var it={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 Zn(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 Jn=(0,Le.createAction)("input/replaceText"),Yn=(0,Le.createAction)("input/keyDown"),kt=(0,Le.createAction)("input/sendMessage"),es=(0,Le.createAction)("input/sendEditSuggestionMessage"),ts=(0,Le.createAction)("input/uiInputChange"),os=(0,Le.createAction)("input/applyImageSuggestion"),ie=(0,Le.createAction)("input/sendEvent");function Qn(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,Le.createSlice)({name:t,initialState:it,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,{...it,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=br(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(jt(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Qn(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:u,ctrlKey:d,metaKey:m,altKey:f}=e.previousKeyDownEvent;switch(p){case"Enter":u&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=e,{text:S}=o.payload,T=(0,Pa.diffChars)(g,S);g.length-S.length>1&&e.metrics.deletions.push(...T.filter(h=>h.removed).map(h=>h.value)),e.metrics.numCharsDeleted+=g.length-S.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&&!f){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=it.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Qn(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"&&Qn(e)},commitSuggestion(e){Qn(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=br(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(A,o=>{o.tabCompletionSuggestion=it.tabCompletionSuggestion,o.previousKeyDownEvent=it.previousKeyDownEvent,o.textSuggestions=it.textSuggestions,o.selectedSuggestionIndex=it.selectedSuggestionIndex,o.metrics=it.metrics})}}),wr=Ia("input"),qt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Zd=t=>t.input.selection,Aa=()=>(0,Ra.useSelector)(Zd),{userInput:La,changeSelection:Er,initialInput:Ma,mergeMetrics:Oa,nextTextSuggestionIndex:Na,offeredTextSuggestion:Da,previousTextSuggestionIndex:Ha,registerCut:Ba,registerKeyDown:Fa,registerPaste:Ka,reset:Ua,resetToCommitted:Mo,platformInput:za,setSelectedTextSuggestionIndex:ns,setTextSuggestions:at,stageSuggestion:we,commitSuggestion:lt}=wr.actions,Y=Ia("overlay");var Vt=require("react");var ja={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var kr=require("react/jsx-runtime"),Jd=({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",ja);return(0,Vt.useEffect)(()=>{var d,m;let p=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},u=f=>{let g=window.getSelection();g!=null&&g.toString()||f.target===a.current&&t&&n()};return(d=a.current)==null||d.addEventListener("click",u),(m=a.current)==null||m.addEventListener("keyup",p),()=>{var f,g;(f=a.current)==null||f.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,kr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,kr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},Wt=Jd;var qr=require("react"),Ss=require("react-redux");var Pr={};q(Pr,{enUS:()=>Yd,nlNL:()=>eg});var Yd={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?"}]},eg={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 qa={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 Oo=require("react/jsx-runtime"),ss=()=>(0,Oo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Oo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Oo.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 No=require("react/jsx-runtime"),Va=()=>(0,No.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,No.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,No.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"),al=require("react-redux"),ll=require("interweave"),Dr=w(require("classnames"));var Rr={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 Ga=require("interweave"),$a=w(require("classnames"));var Gt=require("react");function Wa(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function rs(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]=Wa((p,u)=>{let d=e.current;if(!d)return;let m=p/r,f=u/r,g=d.getBoundingClientRect(),S=m>g.x&&m<g.x+g.width&&f>g.y&&f<g.y+g.height;S&&!s?(s=!0,n(!0)):!S&&s&&(s=!1,n(!1))},({clientX:p,clientY:u})=>[p,u]),[l,c]=Wa(()=>{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_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var Ir=require("react/jsx-runtime"),tg=({inputElement:t,children:e})=>{let o=y("TabCompletion",fe),[n,s]=rs(t);return(0,Ir.jsx)("mark",{ref:n,className:(0,$a.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},$t=class extends Ga.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,Ir.jsx)(tg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Xt=require("react");function is(t){return t.contentEditable==="true"}function og(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 Xa(t){let{selectionStart:e,selectionEnd:o}=is(t)?og(t):t;return[e,o]}function as(t){let[,e]=(0,Xt.useState)(),o=(0,Xt.useRef)(null);return o.current=Xa(t),(0,Xt.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=Xa(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 ls(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 Qa=require("react");function Qt(t){(0,Qa.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 Za,Me=new Map,ng=["bottom","height","left","right","top","width"],sg=(t={},e={})=>ng.some(o=>t[o]!==e[o]),Ja=()=>{let t=[];Me.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Me.delete(o);return}let n=o.getBoundingClientRect();sg(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(o=>o(e.rect))}),Me.size!==0&&(Za=window.requestAnimationFrame(Ja))};function Ya(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&&Ja()},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(Za)}}}}var el,Oe=new Map,tl=()=>{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&&(el=window.requestAnimationFrame(tl))};function ol(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&&tl()},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(el)}}}}var Ar=["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 cs(t){return Math.round(t*1e6)}function nl(t){return t/1e6}function Mr(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=nl(cs(s)-cs(r)-cs(i)),c=nl(cs(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,Ar),Mr(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=ol(t,()=>{Lr(n,o,Ar),Mr(n,t,o),r(),setTimeout(r,0)}),a=Ya(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,Ar),Mr(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),f=p.top+d-c.top,g=c.top+c.height+-(p.top+p.height-m);o.style.clipPath=`inset(${f}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 Or={};q(Or,{enUS:()=>rg,nlNL:()=>ig});var rg={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"}]},ig={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 Do=require("react/jsx-runtime"),sl=()=>(0,Do.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Do.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Do.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 Nr=require("react/jsx-runtime"),rl=()=>(0,Nr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Nr.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 il=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(il||{}),He=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentSelection={start:0,end:0};currentHTML="";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}),n&&(this.currentSelection=this.getSelection()),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e}),this.currentHTML=o))}triggerSelection(){let e=this.getSelection();(e.start!==this.currentSelection.start||e.end!==this.currentSelection.end)&&(this.currentSelection=e,this.emit("selection",e))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(il).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),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",o=>this.handlePaste(o)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.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{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.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"),ag=({value:t,onUse:e,...o})=>{var p;let n=E(Or),s=(0,al.useDispatch)(),r=y("EditSuggestionTextInput",Rr),[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(Zn(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)(lg,{inputElement:l.current,value:t}),(0,ee.jsxs)("div",{className:(0,Dr.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)(sl,{}):(0,ee.jsx)(rl,{})]})]})},lg=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",Rr),n=(0,he.useRef)(null),s=as(t);return(0,he.useEffect)(()=>{ls(t,s)},[s,t]),(0,ee.jsx)(cg,{inputElement:t,children:(0,ee.jsxs)("div",{ref:n,className:(0,Dr.default)(o.root,o.agentText),children:[(0,ee.jsx)(ll.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new $t("placeholders")],inputElement:t,boundaryRef:n}),(0,ee.jsx)("br",{})]})})},cg=({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 n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,ee.jsx)("div",{ref:o,children:e})},cl=ag;var oo=require("react");var pl=require("react"),ps=w(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={};q(Rt,{enUS:()=>pg,nlNL:()=>ug});var pg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},ug={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var ct=require("react/jsx-runtime"),dg=({src:t,title:e})=>{let o=y("CommandPalette",te),[n,s]=(0,pl.useState)("loading"),r=E(Rt);return(0,ct.jsxs)("div",{className:o.image,children:[(0,ct.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,ps.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,ct.jsx)("span",{className:(0,ps.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,ct.jsx)("span",{className:(0,ps.default)(o.imageSrc,o.imageSrcStatus),children:(0,ct.jsx)(_n,{})}),e&&(0,ct.jsx)("span",{className:o.imageTitle,children:e})]})},ul=dg;var dl=w(require("react")),gl=w(require("classnames"));var Ho=require("react/jsx-runtime");function Hr({children:t,heading:e,orientation:o}){let n=y("CommandPalette",te);return dl.default.Children.count(t)===0?null:(0,Ho.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,Ho.jsx)("h4",{className:n.listHeading,children:e}),(0,Ho.jsx)("div",{className:(0,gl.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var Bo=w(require("classnames"));var us=w(require("react")),hl=require("react/jsx-runtime"),ml=us.default.createContext(void 0);function pt(){let t=us.default.useContext(ml);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var fl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=us.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,hl.jsx)(ml.Provider,{value:i,children:t})};var ye=require("react/jsx-runtime");function Br({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}=pt(),m=y("CommandPalette",te);function f(g){n(g),t&&d(!1)}return(0,ye.jsxs)("div",{className:(0,Bo.default)(m.listItem,u===r&&m.listItemSelected),children:[(0,ye.jsxs)("button",{type:"button",className:(0,Bo.default)("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:[(0,ye.jsxs)("div",{className:m.listItemContent,children:[typeof o=="string"?(0,ye.jsx)("p",{className:(0,Bo.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,ye.jsx)("p",{className:(0,Bo.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate),children:a})]}),i&&(0,ye.jsx)(Bn,{})]}),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 ut=require("react/jsx-runtime");function Fr({children:t,title:e,id:o,onDismiss:n,isExperimental:s}){let r=E(Rt),i=y("CommandPalette",te),{page:a}=pt();return a!==o?null:(0,ut.jsxs)("div",{className:i.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,ut.jsxs)("div",{className:i.pageNav,children:[(0,ut.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:n,children:[(0,ut.jsx)(ss,{}),r("back")]}),e&&(0,ut.jsx)("h3",{className:i.pageTitle,children:e}),s&&(0,ut.jsx)(Bn,{})]}),t]})}var dt=require("react");var ds=()=>/Mac/i.test(navigator.platform);var ms=require("@reduxjs/toolkit");var gg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},P=gg;var Yt=require("@reduxjs/toolkit");function mg(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,[mg(o)]:O(t[o])}),{}):t}function Kr(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,[Kr(o)]:z(t[o])}),{}):t}var fg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Ko=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)||""}},Fo=(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))}),Ur=(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}),zr=(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}),yl=t=>t.info.agentInfo,Sl=(0,Yt.createSlice)({name:"info",initialState:fg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Fo.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Fo.rejected,e=>{e.fetchState="error"}).addCase(Fo.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(Ur.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(zr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(A,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:vl}=Sl.actions,_l=Sl.reducer;var gs={list:[],fetchState:"idle",isOpen:!1,page:"search"},xl=t=>t.search.isOpen,bl=t=>t.search.page,Cl=t=>t.search.list;function Tl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var It=(0,ms.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:Ko(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),wl=(0,ms.createSlice)({name:"search",initialState:gs,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=gs.fetchState,t.list=gs.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(A,()=>gs)}}),{resetSearch:fs,setIsOpen:ae,setPage:X}=wl.actions,El=wl.reducer;var hg=/(https?:\/\/[^\s]+)/,hs=t=>t.split(" ").find(e=>hg.test(e));var jr=w(require("classnames"));var ys=require("react/jsx-runtime"),yg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",te);return(0,ys.jsxs)("button",{type:"button",...n,onClick:t,className:(0,jr.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,ys.jsx)("span",{className:(0,jr.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},eo=yg;var Fe=require("react/jsx-runtime"),Sg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",te),a=E(Rt),{selected:l,setSelected:c}=pt(),p=r[l],u=p&&typeof p.text=="string"&&hs(p.text),d=(0,dt.useRef)(null);function m(_){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),C=0,k=0;_==="down"?(x.forEach((ue,B)=>{B===l&&(C=B)}),k=C===x.length-1?0:C+1):_==="up"?(x.forEach((ue,B)=>{B===l&&(C=B)}),k=C?C-1:x.length-1):c(0);let D=x[k];D&&typeof k=="number"&&(c(k),D.scrollIntoView&&D.scrollIntoView({behavior:"smooth",block:k?"center":"end"}))}function f(){if(!d.current)return;let _=d.current.querySelectorAll(".command-palette-list-item"),x=0;_.forEach((k,D)=>{D===l&&(x=D)});let C=_[x];C&&C.click()}let g=()=>{u&&window.open(u,"_blank")},S=()=>{p&&n(p,l)},T=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=(0,dt.useCallback)(_=>{if(_.key==="Enter"&&_.altKey&&u){g();return}if(_.key==="Enter"&&_.shiftKey){T();return}if(_.key==="ArrowDown"){_.preventDefault(),_.stopPropagation(),m("down");return}if(_.key==="ArrowUp"){_.preventDefault(),_.stopPropagation(),m("up");return}_.key==="Enter"&&l!==-1&&(_.preventDefault(),_.stopPropagation(),f())},[l]);return(0,dt.useEffect)(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),(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:[ds()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Fe.jsxs)(dt.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,Fe.jsx)(eo,{onClick:T,shortKeys:[8679,8629],children:o}),(0,Fe.jsx)(eo,{onClick:S,shortKeys:[8629],children:e})]})]})]})},Pl=Sg;var Rl=require("react");var Uo=require("react/jsx-runtime"),to=()=>(0,Uo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Uo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Uo.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 vg({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 Il=(0,Rl.forwardRef)(vg);var zo=require("react/jsx-runtime");function At({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,f]=(0,oo.useState)(0),g=(0,oo.useRef)(null),S=()=>{s&&s(o),i(void 0),r(""),a(!1)},T=()=>{var h;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(h=g.current)==null||h.focus();return}if(d.length>0){r("");return}a(!1)};return(0,oo.useEffect)(()=>{f(0)},[d,n]),(0,zo.jsx)(Wt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:T,onClose:S,children:(0,zo.jsxs)(fl,{selected:m,setSelected:f,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&(0,zo.jsx)(Il,{ref:g,onChange:r,onChangeType:i,placeholder:t,value:d,selectedType:l,types:c,typePlaceholder:e}),p]})})}At.Page=Fr;At.List=Hr;At.Image=ul;At.ListItem=Br;At.ActionsBar=Pl;At.Button=eo;var L=At;var $=require("react/jsx-runtime"),_g=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",qa),l=(0,Ss.useDispatch)(),c=E(Pr),p=(0,Ss.useSelector)(f=>f.overlayInput.text);(0,qr.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=f=>{f.preventDefault(),d(p)},d=f=>{l(es(f)),e(f)},m=f=>g=>{p!==i?window.confirm(c("warning"))&&f(g):f(g)};return(0,qr.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)(_r,{labels:t.searchKeywords}),(0,$.jsx)(cl,{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)(ss,{})}),(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)(L.Button,{onClick:m(o),shortKeys:["esc"],children:c("dismiss")}),(0,$.jsx)(L.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},vs=_g;var Lt=require("@reduxjs/toolkit");var xg=["{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}"],bg=new RegExp(xg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Al(t,e){let o=t.split(bg),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 Ol={suggestions:[],fetchState:"idle",isInitialRequest:null},Ml={default:Ol},Nl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},Dl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},Hl=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,Bl=t=>e=>e.text.startsWith(t),_s=(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=qt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Ko(n),t);if(t==="default"){let p=i?l.filter(Bl(a)):l;e.dispatch(at(p.slice(0,r)))}return l}),jo=(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,{...Ko(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Bl(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Al(p.text,t):p.text}))),l=Ll(l,r),e.dispatch(at(l)),l}),Fl=(0,Lt.createSlice)({name:"textSuggestions",initialState:Ml,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]||Ol;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Ke.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Ke.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(jo.pending,e=>{e.default.fetchState="loading"}).addCase(jo.rejected,e=>{e.default.fetchState="error"}).addCase(jo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(A,()=>Ml)}}),{setTextSuggestions:Kl,setSuggestionState:Ul}=Fl.actions,zl=Fl.reducer;var ql=require("@reduxjs/toolkit");var jl={contentType:null,suggestion:null},Vl=t=>t.activeSuggestion.suggestion,Wl=t=>t.activeSuggestion.contentType,Gl=(0,ql.createSlice)({name:"activeSuggestion",initialState:jl,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(A,()=>jl)}}),{setActiveSuggestion:Ue,resetActiveSuggestion:Vr}=Gl.actions,$l=Gl.reducer;var Wr={};q(Wr,{enUS:()=>Cg,nlNL:()=>Tg});var Cg={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"}]},Tg={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 Xl=require("@reduxjs/toolkit"),wg={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Ql=({ui:t})=>t.overlayCollapsed;var Zl=(0,Xl.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:qo,setInputHasFocus:so,setOverlayCollapsed:ro,setOpenOverlayWhenTyping:Jl,setOverlayCollapsedUserOverwrite:Yl}=Zl.actions,ec=Zl.reducer;var Vo=w(require("react")),oc=require("react/jsx-runtime"),tc=Vo.default.createContext(null),Wo=({broadcastEvents:t,children:e})=>{let o=Vo.default.useMemo(()=>t,[]);return(0,oc.jsx)(tc.Provider,{value:o,children:e})},Se=()=>{let t=(0,Vo.useContext)(tc);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var io=require("@reduxjs/toolkit");var Eg={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ze=t=>t.auth.isLoggedIn,nc=t=>t.auth.loginFetchState,sc=t=>t.auth.verifyFetchState,rc=t=>t.auth.showLoginOverlay,gt=(0,io.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),ic=(0,io.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Go=(0,io.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),ac=(0,io.createSlice)({name:"auth",initialState:Eg,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(gt.pending,e=>{e.loginFetchState="loading"}),t.addCase(gt.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(gt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Go.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Go.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Go.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:ao,setShowLoginOverlay:lc}=ac.actions,cc=ac.reducer;var Gr="SetActiveSuggestion",lo="ShowLoginOverlay",$r="UserLoggedIn",kg="UserLoggedOut",je="ApplySuggestion",Xr="ApplyImageSuggestion",Pg="ShowCommandPalette",Rg=t=>({[Gr]:e=>{t.dispatch(Ul(e.state)),t.dispatch(Ue({contentType:e.contentType,suggestion:e.suggestion}))},[Pg]:e=>{t.dispatch(ae(e.isOpen)),e.page&&t.dispatch(X(e.page))},[lo]:e=>{t.dispatch(lc(e))},[$r]:()=>{t.dispatch(gt())},[kg]:()=>{t.dispatch(gt())},[Xr]:e=>{t.dispatch(os({suggestion:e.suggestion}))},[je]:e=>{t.dispatch(we({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(lt())}}),pc=Rg;var Qr=require("react/jsx-runtime"),Ig=()=>{var f;let[t,e]=(0,uc.useState)(!1),o=(0,co.useSelector)(Vl),n=(0,co.useSelector)(Wl),s=(0,co.useSelector)(no),r=(0,co.useDispatch)(),i=Se(),a=E(Wr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Vr()),r(so(!0)),r(Y.actions.reset())},p=(g,S)=>{r(Vr()),r(so(!0)),i.send(je,{text:g,suggestion:{...S,source:`${S.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let u=(f=s[n])==null?void 0:f.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,Qr.jsx)(Wt,{autoFocus:!0,isOpen:u!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Qr.jsx)(vs,{onTouched:e,onDismiss:c,onUse:g=>p(g,o),suggestion:o,onNext:m,onPrevious:d})})},dc=Ig;var Jr=require("react-redux");var xs=w(require("classnames")),ke=require("react"),bs=require("react-redux");var mc=w(require("classnames"));var gc={root:"_root_1ukx5_1"};var fc=require("react/jsx-runtime"),Ag=({className:t,value:e,...o})=>{let n=y("TextInput",gc);return(0,fc.jsx)("input",{className:(0,mc.default)(t,n.root),type:"text",value:e,...o})},$o=Ag;var Zr={};q(Zr,{enUS:()=>Lg,nlNL:()=>Mg});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"}]},Mg={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 hc={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 Og=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Ng=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(Zr),i=y("LoginTokenDialog",hc),a=(0,bs.useSelector)(sc),l=(0,bs.useDispatch)(),c=b("productName"),[p,u]=(0,ke.useState)(t||""),[d,m]=(0,ke.useState)(0),[f,g]=(0,ke.useState)(""),S=(0,ke.useCallback)(async x=>{x.preventDefault(),l(ic({email:p})),m(1)},[o,p]),T=()=>{g(""),m(0)},h=(0,ke.useCallback)(async x=>{x.preventDefault();let C=Og(x.target.elements.token.value);if(!C){g(r("verifyCodeError",{login:_}));return}l(Go({token:C}))},[o]),_=(0,ke.useMemo)(()=>x=>(0,K.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:T,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:S,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)($o,{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,xs.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),d===1&&(0,K.jsxs)("form",{onSubmit:h,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,K.jsx)($o,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&(0,K.jsx)("div",{className:i.errorMessage,children:f}),(0,K.jsxs)("div",{className:i.actions,children:[(0,K.jsx)("button",{type:"button",className:(0,xs.default)(i.button),onClick:T,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,xs.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},yc=Ng;var vc=require("react/jsx-runtime"),Dg=()=>{let t=(0,Jr.useSelector)(rc),e=(0,Jr.useSelector)(yl),o=b("adminUrl"),n=Se(),s=()=>n.send(lo,!1),r=()=>{n.send(lo,!1),n.send($r)};return(0,vc.jsx)(yc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Sc=Dg;var zc=w(require("lodash.debounce")),ne=require("react"),We=require("react-redux");var Cs=require("@reduxjs/toolkit");var Hg={data:null,fetchState:"idle"},_c=t=>t.contentTypes.data,Xo=(0,Cs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Bg=(0,Cs.createSlice)({name:"contentTypes",initialState:Hg,reducers:{},extraReducers:t=>{t.addCase(Xo.pending,e=>{e.fetchState="loading"}).addCase(Xo.rejected,e=>{e.fetchState="error"}).addCase(Xo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),xc=Bg.reducer;function Qo(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 bc=require("react");function Cc(t,e){(0,bc.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 Zo=require("react"),Es=require("react-redux");var Ts=require("@reduxjs/toolkit");var Tc={data:null,fetchState:"idle"},ws=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,Ts.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)}),Fg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Kg=(0,Ts.createSlice)({name:"entities",initialState:Tc,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=Fg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(A,()=>Tc)}}),wc=Kg.reducer;var Yr={};q(Yr,{enUS:()=>Ug,nlNL:()=>zg});var Ug={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},zg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Ec={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Mt=require("react/jsx-runtime"),jg=({onCopy:t,onUse:e})=>{let o=(0,Zo.useRef)(null),n=y("EntitiesList",Ec),s=E(Yr),r=(0,Es.useSelector)(ws),i=(0,Es.useDispatch)();return(0,Zo.useEffect)(()=>{i(Pe())},[]),(0,Zo.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)(L.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)(L.List,{children:r.map((a,l)=>(0,Mt.jsx)(L.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")})]})},kc=jg;var Re=require("react"),Jo=require("react-redux");var ks=require("@reduxjs/toolkit");var Pc={data:null,fetchState:"idle"},Rc=t=>t.summary.data,Ic=t=>t.summary.fetchState==="error",qe=(0,ks.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();return i.length===0?Promise.reject(new Error("No messages are included")):{summary:await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel})}}),qg=(0,ks.createSlice)({name:"summary",initialState:Pc,reducers:{},extraReducers:t=>{t.addCase(qe.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(qe.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(qe.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(A,()=>Pc)}}),Ac=qg.reducer;var ei={};q(ei,{enUS:()=>Vg,nlNL:()=>Wg});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."}]},Wg={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 Ve=require("react/jsx-runtime"),Gg=({onCopy:t})=>{let e=(0,Re.useRef)(null),o=y("SummaryForm",Lc),[n,s]=(0,Re.useState)(""),r=E(ei),i=(0,Jo.useSelector)(Rc),a=(0,Jo.useSelector)(Ic),l=(0,Jo.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(qe())},[]),(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,Ve.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,Ve.jsx)("p",{className:o.error,children:r("error")}):(0,Ve.jsxs)(Re.Fragment,{children:[(0,Ve.jsx)("div",{className:o.main,children:(0,Ve.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,Ve.jsx)("div",{className:o.actions,children:(0,Ve.jsx)(L.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Mc=Gg;var ti={};q(ti,{enUS:()=>$g,nlNL:()=>Xg});var $g={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},Xg={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var mt=w(require("react")),en=require("react-redux");var oi={};q(oi,{enUS:()=>Qg,nlNL:()=>Zg});var Qg={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"}]},Zg={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 Oc={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};var uo=require("@reduxjs/toolkit");var ni={data:[],fetchState:"idle"},Nc=t=>{var e;return(e=t.answer)==null?void 0:e.data},Dc=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.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),Jg=(0,uo.createSlice)({name:"answer",initialState:ni,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(A,()=>ni).addCase(go,()=>ni)}}),Hc=Jg.reducer;var Yo=require("react/jsx-runtime"),Bc=()=>(0,Yo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Yo.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Yo.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"),Yg=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=mt.default.useState(""),{setSelected:i}=pt(),a=(0,mt.useRef)(null),l=y("EntitiesList",Oc),c=E(oi),p=(0,en.useDispatch)(),u=(0,en.useSelector)(Nc),d=(0,en.useSelector)(Dc),m=async g=>{g.preventDefault(),g.stopPropagation(),s!==""&&p(po({question:s,promptInstruction:n}))},f=(g,S)=>{p(ie({name:"knowledge assist source viewed",data:{question:S,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return(0,mt.useEffect)(()=>{var g;o&&d==="idle"?p(po({question:o,promptInstruction:n})):(g=a.current)==null||g.focus()},[a,d]),(0,mt.useEffect)(()=>{d==="done"&&(p(ie({name:"knowledge assist question answered",data:{question:s||o,sources:u[u.length-1].answer.sources,answer:u[u.length-1].answer.answer,isFollowUpQuestion:u.length>1},options:{includeConversationData:!0}})),i(u.length-1),r(""))},[d,u]),(0,mt.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)(L.Button,{onClick:e,children:c("reset")})}),(0,oe.jsxs)(L.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:S},T)=>(0,oe.jsx)(L.List,{children:(0,oe.jsx)(L.ListItem,{"data-testid":"knowledge-search-answer",index:T,description:S.answer,closeOnSelect:!0,onClick:()=>t(S.answer),onSourceClick:h=>f(h,g),sources:S.sources,styles:{title:l.question,description:l.answer},children:g})},`${S.answer}_${T}`)),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)(Bc,{})})]})]})]})},Fc=Yg;var Ps=require("@reduxjs/toolkit");var em={data:null,fetchState:"idle"},mo=t=>t.profile.data,Rs=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],tn=(0,Ps.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)}),tm=(0,Ps.createSlice)({name:"profile",initialState:em,reducers:{},extraReducers:t=>{t.addCase(tn.pending,e=>{e.fetchState="loading"}).addCase(tn.rejected,e=>{e.fetchState="error"}).addCase(tn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Kc=tm.reducer;var j=require("react/jsx-runtime"),om=200,nm=5,sm=4,rm=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Uc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),im=()=>{let t=(0,We.useDispatch)(),e=Se(),o=E(ti),[n,s]=(0,ne.useState)(!1),[r,i]=(0,ne.useState)(""),a=(0,We.useSelector)(bl),l=(0,We.useSelector)(mo),[c,p]=(0,ne.useState)(null),[u,d]=(0,ne.useState)([]),[m,f]=(0,ne.useState)(),g=(0,We.useSelector)(ze),S=b("showSearch"),T=b("showEntitiesCommand"),h=b("showSummaryCommand"),_=b("showKnowledgeSearch"),x=b("showImageSearch"),C=b("searchTriggerKey"),k=(0,We.useSelector)(_c),D=(0,We.useSelector)(Cl),ue=(0,We.useSelector)(xl),B=v=>ar(D.filter(M=>M.type===v.toUpperCase()),v),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(v=>v.shouldShow),U=[{label:o("entitiesClipboard"),onClick:()=>t(X("entities")),shouldShow:T&&Uc(o("entitiesClipboard"),r),experimental:!0},{label:o("summaryClipboard"),onClick:()=>t(X("summary")),shouldShow:h&&Uc(o("summaryClipboard"),r),experimental:!0},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(X("knowledgeAssist")),shouldShow:_,experimental:!0}].filter(v=>v.shouldShow),J=(k==null?void 0:k.map(v=>({value:v.code.toUpperCase(),label:`${v.name}s`,list:B(v.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],rr=(0,ne.useCallback)((0,zc.default)((v,M)=>{t(It({query:v,type:M,tags:["search-overlay"]}))},om),[]),bt=rm([...J,...I]),ed=(0,ne.useCallback)((v,M)=>{if(!M)return;let nt=[...I,...J].find(({value:Bt})=>Bt===M);nt&&(t(X("edit")),p({...v,searchTerm:void 0}),d(nt.list))},[t,c,J]),ir=(0,ne.useCallback)((v,M)=>{switch(M.type){case"IMAGE":e.send(Xr,{suggestion:M});break;default:e.send(je,{text:v,suggestion:M})}t(ae(!1))},[t]),td=v=>{Qo(v.text),t(ie({name:"entity copied",data:{entity:v,type:"copy"}})),t(ae(!1))},od=v=>{e.send(je,{text:v,suggestion:{source:"knowledge-assist",text:v}}),t(ie({name:"answer used",data:{originalText:v},options:{includeConversationData:!0}})),i(""),t(X("search")),t(go()),t(ae(!1))},nd=v=>{Qo(v),t(ae(!1))},sd=v=>{e.send(je,{text:v.text,suggestion:{source:"entity",text:v.text}}),t(ae(!1))},rd=c===null||u.indexOf(c)-1<0?void 0:()=>p(u[u.indexOf(c)-1]),id=c===null||u.indexOf(c)===u.length-1?void 0:()=>p(u[u.indexOf(c)+1]);function ar(v,M){return v.slice(0,m?10:M.toLowerCase()==="image"?sm:nm)}function Ki(v,M,nt){return M.reduce((Bt,yn)=>nt&&m===nt?yn.length+Bt:ar(yn,nt).length+Bt,v)}function Ht(v){return M=>{n?window.confirm(o("warning"))&&(v(M),s(!1)):v(M)}}return(0,ne.useEffect)(()=>{r?rr(r,m):t(fs())},[r,m]),(0,ne.useEffect)(()=>{a==="search"&&t(go())},[a]),(0,ne.useEffect)(()=>{g&&t(Xo())},[g]),Cc(C,()=>t(ae(!0))),!S||!l?null:(0,j.jsxs)(L,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Ht(v=>t(ae(v))),onChangeType:v=>f(v),onChangePage:Ht(v=>t(X(v))),selectedType:m,search:r,page:a,isOpen:ue,types:[...J,...I],children:[(0,j.jsx)(L.Page,{id:"search",children:(0,j.jsxs)(L.ActionsBar,{list:[...U.map(v=>({text:v.label,type:"command"})),...bt.map(v=>({text:v.text||v.url||v.message,type:v.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:v},M)=>ir(v,bt[M]),onSecondary:(v,M)=>{ed(bt[M-U.length],bt[M-U.length].type)},children:[U.length>0&&(0,j.jsx)(L.List,{heading:o("commands"),children:U.map((v,M)=>(0,j.jsx)(L.ListItem,{index:Ki(M,[],"commands"),closeOnSelect:!1,onClick:v.onClick,isExperimental:v.experimental,children:v.label},v.label))}),[...J,...I].map(({value:v,label:M,list:nt,lineClamp:Bt,listOrientation:yn},ad)=>(0,j.jsx)(L.List,{heading:M,orientation:yn==="horizontal"?"horizontal":"vertical",children:ar(nt,v).map((xe,ld)=>(0,j.jsx)(L.ListItem,{index:Ki(U.length+ld,[...J,...I].slice(0,ad).map(({list:cd})=>cd),v),closeOnSelect:!1,lineClamp:Bt,onClick:()=>ir(xe.text,xe),description:v!=="IMAGE"?xe.title&&xe.text:void 0,children:v==="IMAGE"?(0,j.jsx)(L.Image,{title:xe.title||xe.text,src:xe.image}):xe.title||xe.text},`${xe.id}-${xe.text}`))},v))]})}),(0,j.jsx)(L.Page,{id:"edit",onDismiss:Ht(()=>{t(X("search")),p(null)}),children:c&&(0,j.jsx)(vs,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(X("search")),p(null),d([])},onNext:id,onPrevious:rd,onUse:v=>{t(X("search")),ir(v,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(ae(!1)),d([]),p(null)}})}),(0,j.jsx)(L.Page,{id:"entities",title:o("entitiesTitle"),isExperimental:!0,onDismiss:Ht(()=>{t(X("search"))}),children:(0,j.jsx)(kc,{onUse:sd,onCopy:td})}),(0,j.jsx)(L.Page,{id:"summary",title:o("summaryTitle"),isExperimental:!0,onDismiss:Ht(()=>{t(X("search"))}),children:(0,j.jsx)(Mc,{onCopy:nd})}),(0,j.jsx)(L.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),isExperimental:!0,onDismiss:Ht(()=>{t(go()),t(X("search"))}),children:(0,j.jsx)(Fc,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:od,onResetQuestion:()=>{t(go()),i("")}})})]})},jc=im;var fo=require("react/jsx-runtime"),am=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,fo.jsxs)(qc.Fragment,{children:[t&&(0,fo.jsx)(jc,{}),(0,fo.jsx)(dc,{}),e&&(0,fo.jsx)(Sc,{})]})},Vc=am;var Wc=require("react-redux");var on=require("react/jsx-runtime"),lm=({children:t})=>{let o=b("locale").replace("-","");return(0,on.jsx)(hr.Provider,{value:o,children:t})},cm=({store:t,customStyles:e={},children:o})=>(0,on.jsx)(Wc.Provider,{store:t,children:(0,on.jsx)(lm,{children:(0,on.jsx)(wo.Provider,{value:e,children:o})})}),nn=cm;var Ms=w(require("classnames")),So=require("react"),$e=require("react-redux");var Gc=require("react");function $c(t,e){let[o,n]=(0,Gc.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 Is(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 Qc=w(require("classnames")),Ge=require("react");var si={};q(si,{enUS:()=>pm,nlNL:()=>um});var pm={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Sign in"}]},{type:0,value:" to enable "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze for "},{type:8,value:"min",children:[{type:0,value:"10 minutes"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 hour"}]},{type:0,value:" or "},{type:8,value:"day",children:[{type:0,value:"1 day"}]}]},um={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 Xc={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var ft=require("react/jsx-runtime"),ri=(t,e,o)=>n=>(0,ft.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),dm=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=E(si),r=Se(),i=y("Login",Xc),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,ft.jsx)("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),u=(0,Ge.useCallback)(g=>(0,ft.jsx)("button",{type:"button",className:i.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:d,hour:m,day:f}=(0,Ge.useMemo)(()=>({min:ri(i,60*10,l),hour:ri(i,60*60,l),day:ri(i,60*60*12,l)}),[]);return(0,ft.jsxs)("div",{className:(0,Qc.default)(t,i.root),children:[s("loginPlease",{login:o?u:p,productName:a}),n&&(0,ft.jsxs)(Ge.Fragment,{children:[(0,ft.jsx)("br",{}),s("snooze",{min:d,hour:m,day:f})]})]})},As=dm;var Jc=require("react-redux");var Zc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var sn=require("react/jsx-runtime"),gm=({title:t})=>{let e=y("SearchTrigger",Zc),o=(0,Jc.useDispatch)();return(0,sn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ae(!0)),children:[(0,sn.jsx)(to,{}),(0,sn.jsx)("span",{className:e.text,children:t})]})},Yc=gm;var ap=require("react");var rp=require("interweave"),yo=require("react"),Ls=require("react-redux");var ep=require("react");function tp(t,e,o){(0,ep.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var mm=/[.*+?^${}()|[\]\\]/g,fm=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function hm(t){return t.replace(mm,"\\$&")}function ym(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function ii(t){return t.search(fm)}function op(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${hm(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function np(t){return t.replace(zt,'<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 Sm(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 ai(t,e,o={}){if(e){let n=ym(e.toLowerCase(),t.toLowerCase()),s=ho(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=ii(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Sa).length>3||e.length>30?Sm(e.trim(),n):0;return`${`${i>0?"\u2026":""}${ho(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var sp={badge:"_badge_8rv7b_1",formattedText:"_formattedText_8rv7b_5"};var li=require("react/jsx-runtime"),_m=["search","personal-collection-search","search-autocomplete"];function xm(t,e,o,n={}){let s="";return _m.includes(e)?s=op(ai(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ai(t,o,n),n.placeholders===!0&&(s=np(s)),s}var bm=()=>{},Cm=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=(0,Ls.useSelector)(qt),r=(0,Ls.useDispatch)(),i=y("TextSuggestion",sp),a=(0,yo.useRef)(null);(0,yo.useEffect)(()=>{let c=setTimeout(()=>{r(Da({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),tp(a,"click",()=>{r(ns(t)),r(we({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,yo.useMemo)(()=>xm(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,li.jsx)(N,{ref:a,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:bm,children:(0,li.jsx)(rp.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},ip=Cm;var ci=require("react/jsx-runtime"),Tm=({suggestions:t,selectedIndex:e})=>(0,ci.jsx)(ap.Fragment,{children:t.slice().map((o,n)=>(0,ci.jsx)(ip,{index:n,selected:n===e,suggestion:o},`${o.text}-${o.source}`)).reverse()}),lp=Tm;var pi={};q(pi,{enUS:()=>wm,nlNL:()=>Em});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"}]},Em={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 cp={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"),km=({inline:t=!1,textSuggestions:e,selectedIndex:o})=>{let n=y("SuggestionsOverlay",cp),s=E(pi),r=b("inlineSuggestions"),i=(0,$e.useSelector)(Is),a=Aa(),l=(0,$e.useDispatch)(),c=(0,So.useRef)(null),p=b("searchTriggerKey"),u=b("productName"),d=(0,$e.useSelector)(Ql),m=(0,$e.useSelector)(ze),f=(0,$e.useSelector)(Vn),[g,S]=(0,So.useState)(null),T=b("showSearch"),h=b("showTextSuggestions"),_=b("adminUrl"),x=b("isEmbedded"),[C,k]=$c("dd-snooze-until-ms",0),D=d||C>Date.now(),ue=e.filter(U=>U.source!=="gpt").length,B=()=>{D&&k(0),l(Yl(!D))},I=U=>{let J=Date.now()+U*1e3;k(J),P.info(`Snooze until: ${new Date(J)}`),l(ro({collapse:!0}))};return(0,So.useEffect)(()=>{ue===0&&S(null)},[e,ue]),Qt(()=>{l(ro({collapse:!0,skipWhenInputFocus:!0}))}),r!==t||m===null||f===!1?null:m===!1?(0,H.jsxs)("div",{ref:c,className:(0,Ms.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)(As,{loginUrl:_,isEmbedded:x,onSnooze:I})})]}):!a||!i?null:(0,H.jsxs)("div",{ref:c,className:(0,Ms.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:T&&(0,H.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>S(s(ds()?"searchHintMac":"searchHintWindows",{searchTriggerKey:p.toUpperCase()})),onMouseLeave:()=>S(null),children:(0,H.jsx)(Yc,{title:s("search")})})}),(0,H.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,H.jsx)("div",{className:(0,Ms.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&&h&&(0,H.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,H.jsx)(Ae,{children:(0,H.jsx)(lp,{suggestions:e,selectedIndex:o})})})]})},Pm=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Os=(0,$e.connect)(Pm)(km);var Gs=w(require("classnames")),Rp=require("interweave"),Je=require("react"),Ip=require("react-redux");var pp=require("react"),Rm=["div","span","mark","strong","b","i","u","em"];function ui(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(Rm.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,pp.cloneElement)(n,{children:ui(i,e,o+1)})]}return[...t,...e]}function Xe(t){return t.tagName.toLowerCase()==="textarea"}var up={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var yp=require("interweave"),Bs=require("react");var gi=w(require("classnames")),ve=require("react");var Ns=require("react"),Im=["bottom","height","left","right","top","width"],Am=(t={},e={})=>Im.some(o=>t[o]!==e[o]),Qe=new Map,dp,gp=()=>{let t=[],e=[];Qe.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Am(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))}),dp=window.requestAnimationFrame(gp)};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&&gp()},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(dp)}}}}function di(t){let[e,o]=(0,Ns.useState)(null);return(0,Ns.useLayoutEffect)(()=>{if(!t.current)return;let n=Lm(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var vo=require("react"),fp=require("react-dom");var mp={root:"_root_1jq08_1"};var hp=({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(mp.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,fp.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 Ds=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 mi(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=mi,...a})=>{let l=di(e),c=di(o),p=(0,ve.useMemo)(()=>i(l,c,0),[l,c]);return(0,Ds.jsx)(hp,{children:(0,Ds.jsx)("div",{className:(0,gi.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,Ds.jsx)("div",{className:(0,gi.default)(t,Ne.root),children:r})})})};var ht=require("react/jsx-runtime"),Mm=({inputStyle:t,inputElement:e})=>{let o=y("TabCompletion",fe),n=_o(document.activeElement===e);return Qt(()=>n.close()),(0,Bs.useEffect)(()=>{let s=()=>n.open();return e.addEventListener("focus",s),()=>{e.removeEventListener("focus",s)}},[]),(0,ht.jsxs)(Bs.Fragment,{children:[(0,ht.jsx)("mark",{className:fe.caret,ref:n.triggerRef}),n.opened&&(0,ht.jsx)(xo,{className:o.popoverSuggestionsRoot,triggerRef:n.triggerRef,position:"above",align:"start",children:(0,ht.jsx)("div",{style:t,className:o.suggestionsOverlayInputStyles,children:(0,ht.jsx)(Os,{inline:!0})})})]})},Hs=class extends yp.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:ii(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,ht.jsx)(Mm,{inputStyle:o.inputStyle,inputElement:o.inputElement},"caret")}asTag(){return"mark"}};var xp=w(require("classnames")),bp=require("interweave"),js=require("react");function Sp(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Fs(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function vp(t){return t!=null}var _p=w(require("classnames")),Ks=require("react");var fi=require("react/jsx-runtime"),Us=(0,Ks.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,Ks.useRef)(null),r=y("TabCompletion",fe);return(0,fi.jsx)("div",{ref:Fs([s,n]),className:(0,_p.default)(t,r.popoverContentContainer),...o,children:(0,fi.jsx)("div",{className:r.popoverContent,children:e})})});var yt=require("react/jsx-runtime"),Om=t=>e=>{let o=mi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Nm=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",fe),i=_o(),a=(0,js.useMemo)(()=>Om(t.getBoundingClientRect()),[t]),[l,c]=rs(t);return(0,js.useEffect)(()=>{c?i.open():i.close()},[c]),(0,yt.jsxs)("span",{children:[(0,yt.jsx)("mark",{ref:Fs([l,i.triggerRef]),className:(0,xp.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,yt.jsx)(xo,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,yt.jsx)(Us,{style:o,children:(0,yt.jsx)("div",{className:r.hintText,children:s})})})]})},zs=class extends bp.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${Sp(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(vp);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,yt.jsx)(Nm,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Vs=w(require("classnames")),kp=require("interweave"),Z=require("react"),Pp=require("react-redux");var hi=require("react/jsx-runtime"),Cp=()=>(0,hi.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,hi.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 St=require("react"),rn=require("react-redux"),wp=w(require("lodash.debounce"));var Tp={root:"_root_1muu8_1",content:"_content_1muu8_7"};function qs(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 yi(t){return t.replace("https://www.","").replace("https://","")}var _e=require("react/jsx-runtime"),Dm=3,Hm=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Bm=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Dm})=>{let r=y("LinkSearch",Tp),[i,a]=(0,St.useState)(""),l=(0,rn.useDispatch)(),c=(0,rn.useSelector)(Nl("url")),p=(0,rn.useSelector)(Tl("URL",Hm)),[u,d]=(0,St.useState)(p.length-1),m=b("fallbackImage"),f=h=>{let _=h.target;a(_.value)},g=(h,_)=>{h.stopPropagation(),h.preventDefault(),window.open(_,"_blank")},S=h=>{var C;let _=u-1<0?p.length-1:u-1,x=u+1===p.length?0:u+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&d(_),h.code==="ArrowDown"&&d(x),h.code==="Enter"&&t(((C=p[u])==null?void 0:C.text)||i)},T=(0,St.useCallback)((0,wp.default)(h=>{l(It({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,St.useEffect)(()=>{i&&T(i)},[i]),(0,St.useEffect)(()=>()=>{l(fs())},[]),(0,_e.jsxs)("div",{className:r.root,children:[(0,_e.jsx)(Ae,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,_)=>(0,_e.jsx)(N,{selected:u===_,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:(0,_e.jsxs)(F,{children:[(0,_e.jsx)(F.Image,{src:qs(h,"small",m||void 0),title:h.title||h.text}),(0,_e.jsxs)(F.Content,{className:r.content,cropText:!0,children:[(0,_e.jsx)(F.Title,{children:h.title||yi(h.text)}),h.title&&yi(h.text)]}),(0,_e.jsx)(N.Actions,{children:(0,_e.jsx)(N.ActionButton,{label:n,onClick:x=>g(x,h.text)})})]})},h.text))}),(0,_e.jsx)($o,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:S})]})},Ep=Bm;var Si={};q(Si,{enUS:()=>Fm,nlNL:()=>Km});var Fm={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Km={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"),Um=(0,Z.forwardRef)((t,e)=>{let o=y("TabCompletion",fe);return(0,Q.jsx)("mark",{ref:e,className:(0,Vs.default)(o.matchSelection)},"selection-start")}),zm=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(Si),i=y("TabCompletion",fe),a=(0,Z.useRef)(null),l=(0,Z.useRef)(null),[c,p]=(0,Z.useState)(null),u=(0,Pp.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,S=a.current;!g||!S||(m.setStart(g,0),m.setEnd(S,0))},[t.current,a.current]),Qt(()=>{d.close()});let f=(0,Z.useCallback)(g=>{let S=m.toString(),T=/^http(s?):\/\//.test(g)?g:`https://${g}`;u(Jn({text:`[${S}](${T})`,replace:"selection"}))},[]);return(0,Q.jsxs)("span",{children:[(0,Q.jsx)("mark",{ref:a,className:(0,Vs.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)(Us,{style:o,ref:l,children:[(0,Q.jsx)("div",{className:(0,Vs.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)(Cp,{}),(0,Q.jsx)("span",{children:"\xA0"}),(0,Q.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,Q.jsx)(Ep,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),d.close()}})]})})]},"selection-end")},Ws=class extends kp.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)(Um,{ref:this.startRef}):(0,Q.jsx)(zm,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Ze=require("react/jsx-runtime"),jm=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",up),p=b("insertLink"),u=b("showMidSentenceSuggestions"),d=b("inlineSuggestions"),m=as(a),f=(0,Je.useRef)(null);(0,Je.useEffect)(()=>{Xe(a)&&m&&ls(a,m)},[m]);let g=(0,Je.useCallback)(h=>{if(!s||!o)return h;let _=[(0,Ze.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,Ze.jsx)("span",{"data-testid":"tab-completion",className:(0,Gs.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&_.push((0,Ze.jsx)("span",{className:(0,Gs.default)(c.hint,c.resetIndent),children:(0,Ze.jsx)(Fn,{keyCode:"tab"},"tabHint")})),ui(h,_)},[s,o,n]),S=(0,Je.useMemo)(()=>{let h=[];return d&&h.push(new Hs("inline")),p&&h.push(new Ws("selection")),h.push(new $t("placeholders")),r&&h.push(new zs("keywords")),h},[d,p,r]),T=(0,Je.useMemo)(()=>{let h=window.getComputedStyle(a);return{"--dd-color":h.color,"--dd-font-size":h.fontSize,"--dd-font-family":h.fontFamily,"--dd-font-variant":h.fontVariant}},[]);return t?(0,Ze.jsxs)("div",{ref:h=>{h!=null&&h.parentElement&&(f.current=h==null?void 0:h.parentElement)},className:c.root,style:T,children:[(0,Ze.jsx)(Rp.Interweave,{tagName:"span",containerTagName:"div",className:(0,Gs.default)(c.container,c.agentText),disableLineBreaks:Xe(a),content:e||"\u200B",onAfterParse:g,matchers:S,selection:m,keywordMatches:i,inputElement:a,inputStyle:T,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!u}),(0,Ze.jsx)("br",{})]}):null},qm=({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:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:d,content:l,tabText:c,source:a,keywordMatches:((g=n.list)==null?void 0:g.keywordMatches)??[],enabled:m&&u!==!1}},Ap=(0,Ip.connect)(qm)(jm);var bu=w(require("classnames")),Cu=require("react"),W=require("react-redux");var vt=require("@reduxjs/toolkit");var Lp={list:[],fetchState:"idle",isInitialRequest:null},Op=t=>t.autoflows.list||[],Mp=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ye=(0,vt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),vi=(0,vt.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))}),_i=(0,vt.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,vt.createSlice)({name:"autoflows",initialState:Lp,reducers:{},extraReducers:t=>{t.addCase(vi.pending,(e,o)=>{let n=Mp(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(_i.pending,(e,o)=>{let n=Mp(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(A,()=>Lp)}}),Np=(0,vt.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))})}),Dp=(0,vt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Hp=Vm.reducer;var _t=require("@reduxjs/toolkit");var Bp={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Fp=t=>t.customMessages.list,Kp=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Up=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),zp=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),an=(0,_t.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),$s=(0,_t.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)}),Xs=(0,_t.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)}),jp=(0,_t.createSlice)({name:"customMessages",initialState:Bp,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(an.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(an.rejected,e=>{e.fetchState="error"}).addCase(an.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase($s.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase($s.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Xs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Xs.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(A,()=>Bp)}}),qp=(0,_t.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(jp.actions.onCustomMessage(r))})}),Vp=(0,_t.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Wp=jp.reducer;var ln=require("@reduxjs/toolkit"),Wm={jwt:null,accountUrl:null,interval:null},Gp=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},xi=(0,ln.createAsyncThunk)("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),bi=(0,ln.createAsyncThunk)("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(xi()),setInterval(()=>n(xi()),o)}),$p=(0,ln.createSlice)({name:"exchangeToken",initialState:Wm,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(xi.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(bi.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:Xp}=$p.actions,Qp=$p.reducer;function Zp(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var iu=require("react"),au=require("react-redux");var nu=w(require("classnames")),su=require("react");var Yp=w(require("classnames"));var Jp={root:"_root_838fd_1"};var tu=require("react/jsx-runtime"),Gm=({className:t,children:e})=>{let o=y("Unicode",Jp);return(0,tu.jsx)("span",{className:(0,Yp.default)(t,o.root),children:e})},eu=Gm;var ou={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 Ci={};q(Ci,{enUS:()=>$m,nlNL:()=>Xm});var $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"}]},Xm={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"),Zm=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",ou),a=E(Ci),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,le.jsxs)(N,{className:(0,nu.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)(su.Fragment,{children:[(0,le.jsx)(eu,{children:c})," ",(0,le.jsx)("span",{children:a(l)})]})})})]})},ru=Zm;var Ti=require("react/jsx-runtime"),Jm=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Ym=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Ti.jsx)(iu.Fragment,{children:t.map(s=>(0,Ti.jsx)(ru,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Jm(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),ef=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},tf={onStartAutoflow:vi,onStopAutoflow:_i},lu=(0,au.connect)(ef,tf)(Ym);var Qs=require("react"),pu=require("react-redux"),ki=w(require("classnames"));var wi=require("react/jsx-runtime"),Ei=()=>(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 cu={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"),of=({entities:t})=>{let e=y("EntitiesWidgetList",cu),[o,n]=(0,Qs.useState)(void 0),s=(0,pu.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Qo(a.text),s(ie({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Qs.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,ki.default)(e.icon),children:(0,De.jsx)(Ei,{})}),(0,De.jsx)("span",{className:(0,ki.default)(e.icon,o===l&&e.iconClicked),children:(0,De.jsx)(Ei,{})})]})]},a.text))})},uu=of;var du=w(require("classnames")),Pi=require("react"),Ot=require("react-redux");var cn={};q(cn,{enUS:()=>nf,nlNL:()=>sf});var nf={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"}]},sf={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"),rf=({suggestion:t})=>{let e=E(cn),o=(0,Ot.useDispatch)(),n=(0,Ot.useSelector)(Kp(t.text)),s=(0,Ot.useSelector)(Up(t.text)),r=(0,Ot.useSelector)(zp(t.text)),i=(0,Ot.useSelector)(jn),{replyOptions:a}=t,l=(0,Pi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o($s({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Pi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let u=parseInt(p.target.dataset.index,10),d=a[u];o(Xs({platformSessionId:i,reply:d,suggestion:t}))},[t,n,o,i]);return(0,se.jsxs)(N,{onClick:l,className:(0,du.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)(Kn,{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")})]})]})},gu=rf;var Ri=require("react/jsx-runtime"),mu=()=>(0,Ri.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Ri.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 yu=require("react-redux");var fu=require("react");var ce=require("react/jsx-runtime"),af=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var d;let s=t.text||t.url||t.message,r=hs(s),i=E(cn),a=b("showImages"),l=b("fallbackImage"),c=m=>{m.preventDefault(),m.stopPropagation(),n(s)},p=m=>{m.preventDefault(),m.stopPropagation(),o(t)},u=(0,fu.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:qs(t,"small",l||void 0),title:t.title}),(0,ce.jsxs)(F.Content,{children:[t.title&&(0,ce.jsx)(F.Title,{"data-testid":"widget-suggestion-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")})]})]})},hu=af;var pn=require("react/jsx-runtime"),lf=({contentType:t,lines:e,suggestions:o})=>{let n=Se(),s=(0,yu.useSelector)(no),r=a=>{n.send(Gr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(je,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,pn.jsx)(pn.Fragment,{children:o.map(a=>(0,pn.jsx)(hu,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Su=lf;var Ii={};q(Ii,{enUS:()=>cf,nlNL:()=>pf});var cf={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"}]},pf={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var vu={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 Ai=require("react/jsx-runtime"),_u=()=>(0,Ai.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ai.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"),xu=()=>(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"),Zs=(t,e)=>{let o=(0,W.useSelector)(ze);(0,Cu.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},uf=()=>{let t=E(Ii),e=(0,W.useDispatch)(),o=b("isEmbedded"),n=y("Widget",vu),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)(Rs),d=(0,W.useSelector)(Op),m=(0,W.useSelector)(ws),f=(0,W.useSelector)(Fp),g=(0,W.useSelector)(qn),S=(0,W.useSelector)(Vn),T=(0,W.useSelector)(ze),h=(0,W.useSelector)(jn),_=(0,W.useSelector)(Zp),x=(0,W.useSelector)(no),C=Se(),k=(0,W.useSelector)(Hl),D=(0,W.useSelector)(Gp("/admin/personal-collection")),ue=b("adminUrl");if(Zs(()=>(e(an(h)),e(qp(h)),()=>{e(Vp(h))}),[e,S,r,h]),Zs(()=>(e(Ye(h)),e(Np(h)),()=>{e(Dp(h))}),[e,S,s,h]),Zs(()=>{u.forEach(({type:I})=>{e(I==="entities"?Pe():Ke(I))})},[e,S,g,p]),Zs(()=>(e(bi()),()=>{e(Xp())}),[e,S,i,g]),S===!1)return(0,R.jsx)("div",{className:n.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("notSupported")})})},"supported");if(T===!1)return(0,R.jsx)("div",{className:n.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(As,{isEmbedded:o,loginUrl:ue})})},"login");if(!p||!h||T===null||k||_)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,bu.default)(n.root),"data-testid":"widget",children:(0,R.jsxs)(Un,{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,"data-testid":"shortcut-search",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(to,{}),t("linkSearch")]}),a&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-summary",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(xu,{}),t("linkSummary")]}),l&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(_u,{}),t("linkKnowledgeSearch")]}),D&&(0,R.jsxs)("a",{className:n.shortcut,target:"_blank",href:D,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[(0,R.jsx)(mu,{}),t("linkPersonalcollection")]})]})}),r&&f.length>0&&(0,R.jsx)(st,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(Ae,{withDivider:!0,children:f.map(I=>(0,R.jsx)(gu,{suggestion:I},I.text))})}),s&&d.length>0&&(0,R.jsx)(st,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(Ae,{withDivider:!0,children:(0,R.jsx)(lu,{})})}),u.map(({type:I,title:U,amount:J,lines:rr})=>{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)(uu,{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)(Ae,{withDivider:!0,children:(0,R.jsx)(Su,{lines:rr,contentType:I,suggestions:x[I].suggestions.slice(0,J)||[]})})},I)}})]})})},Tu=uf;function bo(t){let e=new Range;return e.selectNodeContents(t),e}function wu(t,e,o){try{return xt(t,e,o),!0}catch{return!1}}var un=/[\u200B-\u200D\uFEFF]/g;function xt(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(un,""),d=s+u.length,m=e>=s&&e<=d,f=o>=s&&o<=d;if(m){let g=i(p,e-s);g===0&&!f?n.setStartBefore(l):n.setStart(l,g)}f&&(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 dn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(u){let d=u===o,m=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let f=u.textContent;d&&(a=c+f.substring(0,n).replace(un,"").length),m&&(l=c+f.substring(0,r).replace(un,"").length),c+=f.replace(un,"").length;break}case Node.ELEMENT_NODE:{let{tagName:f}=u,g=u.nextSibling===null;f==="BR"&&!g&&c++;for(let S=0;S<u.childNodes.length;S++){let T=d&&S===n;if(T&&(a=c),(!T||!i)&&p(u.childNodes[S]),m&&S===r-1&&(l=c),l!==void 0)break}!m&&f==="DIV"&&!g&&c++,m&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function gn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))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,f=c.textContent.replace(un,"");d===0&&m===void 0?a+=f:a+=f.substring(d,m);break}case Node.ELEMENT_NODE:{let{tagName:d}=c,m=c.nextSibling===null;i===0&&d==="BR"&&!m&&(a+=`
4
+ `);for(let f=p?n:0;f<(u?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[f]),i!==1);f++);!u&&i===0&&d==="DIV"&&!m&&(a+=`
5
+ `);break}default:break}u&&i++}return l(t),a}var Nt=class extends He{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),gn(this.element,e)}getHTML(){return this.element.innerHTML||""}getRange(){var s;let e=this.getRootNode();if(e.activeElement!==this.element)return null;let o="getSelection"in e?e.getSelection():window.getSelection();if(!o)return null;let n="getComposedRanges"in o&&e instanceof ShadowRoot?(s=o.getComposedRanges(e))==null?void 0:s[0]:o.rangeCount>0?o.getRangeAt(0):null;return!n||!this.element.contains(n.startContainer)||!this.element.contains(n.endContainer)?null:n}getSelection(){let e=this.getRange();if(e)return dn(this.element,e);let o=this.lastKnownSelection;if(o&&wu(this.element,o.start,o.end))return o;let n=bo(this.element);return n.collapse(!1),dn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return gn(this.element,xt(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 Mi=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()}},Oi=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()}},Ni=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 Oi(e,this.deepdeskUrl,{debug:!0}):new Mi(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)}},Eu=Ni;var Co=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Di=t=>new Promise(e=>{setTimeout(e,t)});var To=class extends Co{name="ClientError"},Hi=class extends Co{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:f="v1",...g}=o,S={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(S.headers={...S.headers,"X-CSRFToken":this.csrfToken}),typeof f=="string"&&(S.headers={...S.headers,"X-Deepdesk-API-Version":f});let T=c,h=!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()=>(T--,a(i,S).then(async x=>m(x)&&!r.isAborted&&T>0?(await Di(p),_()):x.status===401&&u===!0&&h===!1?(h=!0,await this.refreshToken(),_()):x).catch(async x=>{if(d(x)&&!r.isAborted&&T>0)return await Di(p),_();throw x}));_().then(x=>x.json().catch(()=>null).then(C=>{x.status>=500?s(new Hi("Server Error",C)):x.status===401?s(new To("Unauthorized",C)):x.status===403?s(new To("Forbidden",C)):x.status===404?s(new To("Not Found",C)):x.status>=400&&s(new To("Bad Request",C)),delete this.latestRequestByUrl[i],n(C)})).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 df;(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||={})})(df||={});function Js(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 Js(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 Js(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 Js(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=>Js(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 knowledgeAssist(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(va);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 mn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Kr(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 gf;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(gf||={});var fn=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 mn(`${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 or=require("@reduxjs/toolkit");var Pu=require("@reduxjs/toolkit");var ku={startTime:null,stopTime:null},Ru=(0,Pu.createSlice)({name:"handlingTime",initialState:ku,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(A,()=>ku)}}),{handlingTimeStart:Iu,handlingTimeStop:Ys,handlingTimeReset:Au}=Ru.actions,Lu=Ru.reducer;var Mu=(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 tr=require("@reduxjs/toolkit");var er={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Dt=(0,tr.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 er.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),mf=(0,tr.createSlice)({name:"styleSuggestions",initialState:er,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",jt(e.list,o.payload)||(e.list=o.payload)}).addCase(kt,e=>{e.list=er.list}).addCase(A,()=>er)}}),Ou=mf.reducer;var Nu=(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 ff(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Du=(t={})=>{let e={getTextSuggestions:Ke,getAutocompleteSuggestions:jo,debounce:200,check:Is,...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===_s.toString();if(!u||!c&&!p)return a;let{input:{userCommitted:m}}=l;return ff(m,i)&&!d||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let S=qt(l);S===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(S))},d?0:e.debounce)),a}};var Hu=Dt.fulfilled.toString();function hf(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 Bu=t=>e=>o=>n=>{var c;if(n.type!==Hu){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=hf(s,i);n.type===Hu&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var yf=(0,or.combineReducers)({activeSuggestion:$l,answer:Hc,auth:cc,autoflows:Hp,conversation:ka,contentTypes:xc,customMessages:Wp,exchangeToken:Qp,entities:wc,handlingTime:Lu,info:_l,input:wr.reducer,overlayInput:Y.reducer,settings:Ca,profile:Kc,search:El,summary:Ac,styleSuggestions:Ou,ui:ec,textSuggestions:zl});function Fu(t){return(0,or.configureStore)({reducer:yf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Mu(),Du({debounce:200}),Nu({debounce:500}),Bu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Sf=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},vf=t=>e=>o=>n=>{var a;let s=e.getState(),r=xr("inlineSuggestions")(s);switch(n.type){case Ue.toString():{let l=Dl(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 we.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:Sf(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Jn.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 Mo.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case os.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 qe.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{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 Yn.toString():t.handleKeyDown(n.payload);break;case kt.toString():t.logSendMessage(n.payload);break;case es.toString():t.logSendEditSuggestionMessage(n.payload);break;case ts.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case kt.toString():t.handleAfterSendMessage(n.payload);break;case qo.toString():t.onUpdateShowTabHint(n.payload);break;case Ys.toString():t.logHandlingTime();break;case we.toString():{r&&(e.dispatch(at([])),e.dispatch(lt()));break}default:break}return i},Ku=vf;function Bi(t){return t.toISOString().replace("T"," ").replace("Z","")}function Uu(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:Bi(o),timeStop:Bi(n)}}function Fi(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:f,offeredTextSuggestions:g}}=e[t],S=n.length,h=f.reduce((I,{text:U,searchTerm:J})=>I+U.length-(J?J.length:0),0),_=c??Date.now(),x=(Date.now()-_)/1e3+(p||0),C=s/x,k=f.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+k,lenTextTotal:S,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:x,charsPerSecond:C,numPastes:l,textSuggestionsV2:f,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 zu(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?zu(n,e):null}function ju(t,e){return zu(t,e)}function qu(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function nr(t){return t instanceof HTMLElement&&(Xe(t)||is(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 _f(t){return t.offsetParent!==null}function Wu(t){if(!_f(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 sr(t,e,o=100){let n=Wu(t);e({isVisible:n});let s=setInterval(()=>{let r=Wu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var pe=require("react/jsx-runtime"),Gu=Vu("showTabHint",!0),hn=class t{static version="10.1.15";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:[Ku({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=>Gu.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new fn(o)}),this.store=Fu(p),this.broadcastEvents=new Eu({debug:!0,deepdeskUrl:c,eventMap:pc(this.store),createCustomChannel:l}),this.store.dispatch(Lo),this.store.dispatch(qo(Gu.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(gt()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ze(n)&&nc(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(Cr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Wn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Gn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Tr(e))).payload}async postMessages(e){return(await this.store.dispatch(Xn(e))).payload}async updateConversation(e){return(await this.store.dispatch($n(e))).payload}resetConversation(){this.store.dispatch(A()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(qe());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(vl(e))}async setAgentInfo(e){await this.store.dispatch(Fo(e))}async setAgentSettings(e){await this.store.dispatch(Ur(e))}async getAgentSettings(){return(await this.store.dispatch(zr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(_s()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(ts(e))}notifyKeyDown(e){this.store.dispatch(Yn(e))}notifyPaste(e,o){this.store.dispatch(Ka({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ba(e))}notifyExternalSuggestion(e){this.store.dispatch(we(e)),this.store.dispatch(lt())}notifyEditSuggestion(e){this.store.dispatch(Kl(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(at([])))}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(Fa(Zn(e))),!(e.key!=="Tab"&&!this.settings.showTextSuggestions))switch(e.key){case"Up":case"ArrowUp":if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Na()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return;case"Down":case"ArrowDown":{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Ha());let{selectedSuggestionIndex:c}=this.state.input;c===-1?this.store.dispatch(Mo()):i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return}case"Esc":case"Escape":{l?(this.store.dispatch(ns(-1)),this.store.dispatch(Mo()),e.preventDefault()):o||(this.store.dispatch(ro({collapse:!0})),this.store.dispatch(Jl(!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(qo(!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(lt())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ua()),this.store.dispatch(at([]))}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(Ys()))}logSendMessage(e){let o=Fi("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=Fi("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Oa(this.state.overlayInput.metrics))}logHandlingTime(){let e=Uu(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Au())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(lt()),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(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]=Jt(o,n);return r.setAttribute("translate","no"),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,s.setAttribute("translate","no"),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(!nr(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:f,closestScrollSelector:g,appendOverlayTo:S,inlineSuggestions:T}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:m,isEmbedded:u,inlineSuggestions:T});let h=g&&ju(e,g)||void 0,_=this.overlayContainerFactory("deepdesk-tab-completion",h||e,{appendTo:S,closestScrollElement:h,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),x=this.overlayContainerFactory("deepdesk-suggestions-overlay",h||e,{appendTo:S},n==null?void 0:n.suggestionsRootNode);o.automaticHandlingTime&&this.setupHandlingTime(e),(0,ot.render)((0,pe.jsx)(nn,{store:this.store,customStyles:n,children:(0,pe.jsx)(Wo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Ap,{inputElement:e})})}),_),(0,ot.render)((0,pe.jsx)(nn,{store:this.store,customStyles:n,children:(0,pe.jsx)(Wo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Os,{})})}),x),(0,ot.render)((0,pe.jsx)(nn,{store:this.store,customStyles:n,children:(0,pe.jsx)(Wo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Vc,{})})}),this.createContainer("deepdesk-overlays")),Pt(e),this.inputMediator=f||(Xe(e)?new Be(e):new Nt(e)),this.inputMediator.on("change",({plainText:k})=>{this.notifyInputChanged(k)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(za({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",k=>{this.notifyKeyDown(k)}),this.inputMediator.on("paste",({pastedText:k,selectionText:D})=>{this.notifyPaste(k,D)}),this.inputMediator.on("cut",({selectionText:k})=>{this.notifyCut(k)});let C;this.inputMediator.on("selection",k=>{clearTimeout(C),k===null?C=setTimeout(()=>{k!==null&&this.store.dispatch(Er(k))},500):this.store.dispatch(Er(k))}),this.inputMediator.on("disabled",()=>{var k;(k=this.inputMediator)==null||k.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(so(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(so(!0))),this.store.dispatch(Ma({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var k;this.refresh(),this.broadcastEvents.setSessionId((k=this.state.conversation.current)==null?void 0:k.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)(nn,{store:this.store,customStyles:n,children:(0,pe.jsx)(Wo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Tu,{})})}),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=sr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){qu(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(tn());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.knowledgeAssistForAgents,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=Rs(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 $u(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 Xu(t,e,o={}){let n=o.replace?xt(t,o.replace.start,o.replace.end):bo(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),o.insertBRs!==!1?e.split(`
6
6
  `).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}):n.insertNode(document.createTextNode(e))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?xt(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 Qu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Zu(t,e,o){await new tt(t).authenticateWithKey(e,o)}async function Ju(t){let o=await new Ie(t).get("/platform/config/",{version:null});return O(o)}async function xf(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 Yu(t,e){let o=await xf(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,createFullRange,createOverlayContainer,createRangeFromOffsets,escapeHTML,fetchPlatformConfig,formatTextMarkup,getRangeOffsets,getRangeText,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});